diff options
author | Paul Duncan <pabs@pablotron.org> | 2019-07-17 17:03:37 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2019-07-17 17:03:37 -0400 |
commit | 73100bf2aaa8a1bfc4b92f42a7461b99c587ef3d (patch) | |
tree | 4d1d988f6714e22e2b991e2f074a15e03667ac7f /hmac-sha2.h | |
parent | 2c9390c10b2f31c87830e0816ca207974ebfc590 (diff) | |
download | sha2-73100bf2aaa8a1bfc4b92f42a7461b99c587ef3d.tar.bz2 sha2-73100bf2aaa8a1bfc4b92f42a7461b99c587ef3d.zip |
add hmac-sha2 and update files
Diffstat (limited to 'hmac-sha2.h')
-rw-r--r-- | hmac-sha2.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/hmac-sha2.h b/hmac-sha2.h new file mode 100644 index 0000000..46908d2 --- /dev/null +++ b/hmac-sha2.h @@ -0,0 +1,51 @@ +#ifndef HMAC_SHA2_H_ +#define HMAC_SHA2_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <stdint.h> // uint8_t +#include "sha2.h" + +typedef struct { + uint8_t key[64]; + sha256_t ctx; +} hmac_sha256_t; + +void hmac_sha256_init( + hmac_sha256_t * const ctx, + const uint8_t * const key, + const size_t key_len +); + +void hmac_sha256_push( + hmac_sha256_t * const ctx, + const uint8_t * const buf, + const size_t buf_len +); + +void hmac_sha256_fini( + hmac_sha256_t * const ctx, + uint8_t * const out +); + +void hmac_sha256( + const uint8_t * const key, + const size_t key_len, + const uint8_t * const buf, + const size_t buf_len, + uint8_t * const out +); + +_Bool hmac_check( + const uint8_t * const a, + const uint8_t * const b, + const size_t len +); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* HMAC_SHA2_H_ */ |