1 #ifndef PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_UTILS_H 2 #define PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_UTILS_H 3 4 #include "hash_state.h" 5 #include "params.h" 6 #include <stddef.h> 7 #include <stdint.h> 8 9 /** 10 * Converts the value of 'in' to 'outlen' bytes in big-endian byte order. 11 */ 12 void PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_ull_to_bytes( 13 unsigned char *out, size_t outlen, unsigned long long in); 14 15 /** 16 * Converts the inlen bytes in 'in' from big-endian byte order to an integer. 17 */ 18 unsigned long long PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_bytes_to_ull( 19 const unsigned char *in, size_t inlen); 20 21 /** 22 * Computes a root node given a leaf and an auth path. 23 * Expects address to be complete other than the tree_height and tree_index. 24 */ 25 void PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_compute_root( 26 unsigned char *root, const unsigned char *leaf, 27 uint32_t leaf_idx, uint32_t idx_offset, 28 const unsigned char *auth_path, uint32_t tree_height, 29 const unsigned char *pub_seed, uint32_t addr[8], 30 const hash_state *hash_state_seeded); 31 32 /** 33 * For a given leaf index, computes the authentication path and the resulting 34 * root node using Merkle's TreeHash algorithm. 35 * Expects the layer and tree parts of the tree_addr to be set, as well as the 36 * tree type (i.e. PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_ADDR_TYPE_HASHTREE or PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_ADDR_TYPE_FORSTREE). 37 * Applies the offset idx_offset to indices before building addresses, so that 38 * it is possible to continue counting indices across trees. 39 */ 40 void PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_treehash_FORS_HEIGHT( 41 unsigned char *root, unsigned char *auth_path, 42 const unsigned char *sk_seed, const unsigned char *pub_seed, 43 uint32_t leaf_idx, uint32_t idx_offset, 44 void (*gen_leaf)( 45 unsigned char * /* leaf */, 46 const unsigned char * /* sk_seed */, 47 const unsigned char * /* pub_seed */, 48 uint32_t /* addr_idx */, const uint32_t[8] /* tree_addr */, 49 const hash_state * /* hash_state_seeded */), 50 uint32_t tree_addr[8], const hash_state *hash_state_seeded); 51 52 void PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_treehash_TREE_HEIGHT( 53 unsigned char *root, unsigned char *auth_path, 54 const unsigned char *sk_seed, const unsigned char *pub_seed, 55 uint32_t leaf_idx, uint32_t idx_offset, 56 void (*gen_leaf)( 57 unsigned char * /* leaf */, 58 const unsigned char * /* sk_seed */, 59 const unsigned char * /* pub_seed */, 60 uint32_t /* addr_idx */, const uint32_t[8] /* tree_addr */, 61 const hash_state * /* hash_state_seeded */), 62 uint32_t tree_addr[8], const hash_state *hash_state_seeded); 63 64 #endif 65