hash.h (1881B)
1 #ifndef HASH_H 2 #define HASH_H 3 4 #include "context.h" 5 #include <stdint.h> 6 #include <stdlib.h> 7 8 #if defined(SLH_DSA_SHAKE_128S) || defined(SLH_DSA_SHAKE_128F) || \ 9 defined(SLH_DSA_SHAKE_192S) || defined(SLH_DSA_SHAKE_192F) || \ 10 defined(SLH_DSA_SHAKE_256S) || defined(SLH_DSA_SHAKE_256F) 11 12 #include <sha3.h> 13 14 #define hash_h(out, pk_seed, adrs, m) (hash_t(out, 2, pk_seed, adrs, m)) 15 #define hash_f(out, pk_seed, adrs, m) (hash_t(out, 1, pk_seed, adrs, m)) 16 #define hash_prf(out, pk_seed, sk_seed, adrs) \ 17 (hash_t(out, 1, pk_seed, adrs, sk_seed)) 18 19 #else 20 21 #include <openssl/evp.h> 22 #include <openssl/hmac.h> 23 #include <openssl/sha.h> 24 #include <stdio.h> 25 #include <string.h> 26 27 #define hash_h(out, pk_seed, adrs, m) (hash_t(out, 2, pk_seed, adrs, m)) 28 29 #if defined(SLH_DSA_SHA2_192S) || defined(SLH_DSA_SHA2_192F) || \ 30 defined(SLH_DSA_SHA2_256S) || defined(SLH_DSA_SHA2_256F) 31 32 void hash_f(uint8_t *out, const uint8_t pk_seed[ENN], 33 const uint32_t adrs[ADRS_LEN], const uint8_t *m1); 34 #define hash_prf(out, pk_seed, sk_seed, adrs) \ 35 (hash_f(out, pk_seed, adrs, sk_seed)) 36 37 #else 38 39 #define hash_f(out, pk_seed, adrs, m) (hash_t(out, 1, pk_seed, adrs, m)) 40 #define hash_prf(out, pk_seed, sk_seed, adrs) \ 41 (hash_t(out, 1, pk_seed, adrs, sk_seed)) 42 43 #endif 44 45 #endif 46 47 void hash_t(uint8_t *out, const size_t len, const uint8_t pk_seed[ENN], 48 const uint32_t adrs[ADRS_LEN], const uint8_t *m_ell); 49 50 void hash_prf_msg(uint8_t *out, const uint8_t *sk_prf, const uint8_t *opt_rand, 51 const uint8_t *m, const size_t mlen); 52 53 void hash_h_msg(uint8_t *out, const size_t out_len, const uint8_t *r, 54 const uint8_t *pk_seed, const uint8_t *pk_root, 55 const uint8_t *m, const size_t mlen); 56 57 #endif