1 /* Copyright (c) 2023, 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_SPX_THASH_H 16 #define OPENSSL_HEADER_CRYPTO_SPX_THASH_H 17 18 #include <openssl/base.h> 19 20 #include "./params.h" 21 22 #if defined(__cplusplus) 23 extern "C" { 24 #endif 25 26 27 // Implements F: a hash function takes an n-byte message as input and produces 28 // an n-byte output. 29 void spx_thash_f(uint8_t *output, const uint8_t input[SPX_N], 30 const uint8_t pk_seed[SPX_N], uint8_t addr[32]); 31 32 // Implements H: a hash function takes a 2*n-byte message as input and produces 33 // an n-byte output. 34 void spx_thash_h(uint8_t *output, const uint8_t input[2 * SPX_N], 35 const uint8_t pk_seed[SPX_N], uint8_t addr[32]); 36 37 // Implements Hmsg: a hash function used to generate the digest of the message 38 // to be signed. 39 void spx_thash_hmsg(uint8_t *output, const uint8_t r[SPX_N], 40 const uint8_t pk_seed[SPX_N], const uint8_t pk_root[SPX_N], 41 const uint8_t *msg, size_t msg_len); 42 43 // Implements PRF: a pseudo-random function that is used to generate the secret 44 // values in WOTS+ and FORS private keys. 45 void spx_thash_prf(uint8_t *output, const uint8_t pk_seed[SPX_N], 46 const uint8_t sk_seed[SPX_N], uint8_t addr[32]); 47 48 // Implements PRF: a pseudo-random function that is used to generate the 49 // randomizer r for the randomized hashing of the message to be signed. values 50 // in WOTS+ and FORS private keys. 51 void spx_thash_prfmsg(uint8_t *output, const uint8_t sk_prf[SPX_N], 52 const uint8_t opt_rand[SPX_N], const uint8_t *msg, 53 size_t msg_len); 54 55 // Implements Tl: a hash function that maps an l*n-byte message to an n-byte 56 // message. 57 void spx_thash_tl(uint8_t *output, const uint8_t input[SPX_WOTS_BYTES], 58 const uint8_t pk_seed[SPX_N], uint8_t addr[32]); 59 60 // Implements Tk: a hash function that maps a k*n-byte message to an n-byte 61 // message. 62 void spx_thash_tk(uint8_t *output, const uint8_t input[SPX_FORS_TREES * SPX_N], 63 const uint8_t pk_seed[SPX_N], uint8_t addr[32]); 64 65 66 #if defined(__cplusplus) 67 } // extern C 68 #endif 69 70 #endif // OPENSSL_HEADER_CRYPTO_SPX_THASH_H 71