1 /* Copyright (c) 2024, Google LLC 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 #ifndef OPENSSL_HEADER_CRYPTO_SLHDSA_MERKLE_H 16 #define OPENSSL_HEADER_CRYPTO_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[SLHDSA_SHA2_128S_N], 31 const uint8_t sk_seed[SLHDSA_SHA2_128S_N], 32 uint32_t i /*target node index*/, 33 uint32_t z /*target node height*/, 34 const uint8_t pk_seed[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[SLHDSA_SHA2_128S_N], unsigned int idx, 40 const uint8_t sk_seed[SLHDSA_SHA2_128S_N], 41 const uint8_t pk_seed[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[SLHDSA_SHA2_128S_N], 47 const uint8_t xmss_sig[SLHDSA_SHA2_128S_XMSS_BYTES], unsigned int idx, 48 const uint8_t msg[SLHDSA_SHA2_128S_N], 49 const uint8_t pk_seed[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[SLHDSA_SHA2_128S_N], uint64_t idx_tree, 55 uint32_t idx_leaf, const uint8_t sk_seed[SLHDSA_SHA2_128S_N], 56 const uint8_t pk_seed[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[SLHDSA_SHA2_128S_N], uint64_t idx_tree, 62 uint32_t idx_leaf, const uint8_t pk_root[SLHDSA_SHA2_128S_N], 63 const uint8_t pk_seed[SLHDSA_SHA2_128S_N]); 64 65 66 #if defined(__cplusplus) 67 } // extern C 68 #endif 69 70 #endif // OPENSSL_HEADER_CRYPTO_SLHDSA_MERKLE_H 71