1 // Copyright 2024 The BoringSSL Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef OPENSSL_HEADER_CRYPTO_FIPSMODULE_SLHDSA_MERKLE_H 16 #define OPENSSL_HEADER_CRYPTO_FIPSMODULE_SLHDSA_MERKLE_H 17 18 #include <openssl/base.h> 19 20 #include <sys/types.h> 21 22 #include "./params.h" 23 24 #if defined(__cplusplus) 25 extern "C" { 26 #endif 27 28 29 // Implements Algorithm 9: xmss_node function (page 23) 30 void slhdsa_treehash(uint8_t out_pk[BCM_SLHDSA_SHA2_128S_N], 31 const uint8_t sk_seed[BCM_SLHDSA_SHA2_128S_N], 32 uint32_t i /*target node index*/, 33 uint32_t z /*target node height*/, 34 const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N], 35 uint8_t addr[32]); 36 37 // Implements Algorithm 10: xmss_sign function (page 24) 38 void slhdsa_xmss_sign(uint8_t sig[SLHDSA_SHA2_128S_XMSS_BYTES], 39 const uint8_t msg[BCM_SLHDSA_SHA2_128S_N], unsigned int idx, 40 const uint8_t sk_seed[BCM_SLHDSA_SHA2_128S_N], 41 const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N], 42 uint8_t addr[32]); 43 44 // Implements Algorithm 11: xmss_pkFromSig function (page 25) 45 void slhdsa_xmss_pk_from_sig( 46 uint8_t root[BCM_SLHDSA_SHA2_128S_N], 47 const uint8_t xmss_sig[SLHDSA_SHA2_128S_XMSS_BYTES], unsigned int idx, 48 const uint8_t msg[BCM_SLHDSA_SHA2_128S_N], 49 const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N], uint8_t addr[32]); 50 51 // Implements Algorithm 12: ht_sign function (page 27) 52 void slhdsa_ht_sign( 53 uint8_t sig[SLHDSA_SHA2_128S_D * SLHDSA_SHA2_128S_XMSS_BYTES], 54 const uint8_t message[BCM_SLHDSA_SHA2_128S_N], uint64_t idx_tree, 55 uint32_t idx_leaf, const uint8_t sk_seed[BCM_SLHDSA_SHA2_128S_N], 56 const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N]); 57 58 // Implements Algorithm 13: ht_verify function (page 28) 59 int slhdsa_ht_verify( 60 const uint8_t sig[SLHDSA_SHA2_128S_D * SLHDSA_SHA2_128S_XMSS_BYTES], 61 const uint8_t message[BCM_SLHDSA_SHA2_128S_N], uint64_t idx_tree, 62 uint32_t idx_leaf, const uint8_t pk_root[BCM_SLHDSA_SHA2_128S_N], 63 const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N]); 64 65 66 #if defined(__cplusplus) 67 } // extern C 68 #endif 69 70 #endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_SLHDSA_MERKLE_H 71