1 #ifndef crypto_auth_hmacsha256_H 2 #define crypto_auth_hmacsha256_H 3 4 #include <stddef.h> 5 #include "crypto_hash_sha256.h" 6 #include "export.h" 7 8 #ifdef __cplusplus 9 # ifdef __GNUC__ 10 # pragma GCC diagnostic ignored "-Wlong-long" 11 # endif 12 extern "C" { 13 #endif 14 15 #define crypto_auth_hmacsha256_BYTES 32U 16 SODIUM_EXPORT 17 size_t crypto_auth_hmacsha256_bytes(void); 18 19 #define crypto_auth_hmacsha256_KEYBYTES 32U 20 SODIUM_EXPORT 21 size_t crypto_auth_hmacsha256_keybytes(void); 22 23 SODIUM_EXPORT 24 int crypto_auth_hmacsha256(unsigned char *out, 25 const unsigned char *in, 26 unsigned long long inlen, 27 const unsigned char *k); 28 29 SODIUM_EXPORT 30 int crypto_auth_hmacsha256_verify(const unsigned char *h, 31 const unsigned char *in, 32 unsigned long long inlen, 33 const unsigned char *k) 34 __attribute__ ((warn_unused_result)); 35 36 /* ------------------------------------------------------------------------- */ 37 38 typedef struct crypto_auth_hmacsha256_state { 39 crypto_hash_sha256_state ictx; 40 crypto_hash_sha256_state octx; 41 } crypto_auth_hmacsha256_state; 42 43 SODIUM_EXPORT 44 size_t crypto_auth_hmacsha256_statebytes(void); 45 46 SODIUM_EXPORT 47 int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state, 48 const unsigned char *key, 49 size_t keylen); 50 51 SODIUM_EXPORT 52 int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state, 53 const unsigned char *in, 54 unsigned long long inlen); 55 56 SODIUM_EXPORT 57 int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state, 58 unsigned char *out); 59 60 61 SODIUM_EXPORT 62 void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES]); 63 64 #ifdef __cplusplus 65 } 66 #endif 67 68 #endif 69