From 73100bf2aaa8a1bfc4b92f42a7461b99c587ef3d Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 17 Jul 2019 17:03:37 -0400 Subject: add hmac-sha2 and update files --- hmac-sha2.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 hmac-sha2.h (limited to 'hmac-sha2.h') 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 // 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_ */ -- cgit v1.2.3