diff --git a/lib/hmac.c b/lib/hmac.c index a88ce410..c9b98069 100644 --- a/lib/hmac.c +++ b/lib/hmac.c @@ -33,6 +33,11 @@ DECLARE_TEST_SUITE(hmac_test, "hmac functions test suite"); #endif +/** + * /brief populate the inner and outer pads + * + * + */ static void pad_init(unsigned char *inner_pad, unsigned char *outer_pad, const unsigned char * const key, const int key_len) @@ -56,8 +61,6 @@ pad_init(unsigned char *inner_pad, unsigned char *outer_pad, return; } -/* Begin MD5 HMAC functions -*/ void hmac_md5(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len) @@ -101,8 +104,6 @@ hmac_md5(const char *msg, const unsigned int msg_len, return; } -/* Begin SHA1 HMAC functions -*/ void hmac_sha1(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len) @@ -146,8 +147,6 @@ hmac_sha1(const char *msg, const unsigned int msg_len, return; } -/* Begin SHA256 HMAC functions -*/ void hmac_sha256(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len) @@ -191,8 +190,6 @@ hmac_sha256(const char *msg, const unsigned int msg_len, return; } -/* Begin SHA384 HMAC functions -*/ void hmac_sha384(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len) @@ -236,8 +233,6 @@ hmac_sha384(const char *msg, const unsigned int msg_len, return; } -/* Begin SHA512 HMAC functions -*/ void hmac_sha512(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len) diff --git a/lib/hmac.h b/lib/hmac.h index a5fb4785..9e81e36c 100644 --- a/lib/hmac.h +++ b/lib/hmac.h @@ -32,7 +32,7 @@ #include "digest.h" -#define MAX_DIGEST_BLOCK_LEN SHA3_256_BLOCK_LEN +#define MAX_DIGEST_BLOCK_LEN SHA3_256_BLOCK_LEN /**< The longest block length is from SHA3_256 */ /** * \brief Generate MD5 based HMAC * @@ -47,16 +47,88 @@ */ void hmac_md5(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len); +/** + * \brief Generate SHA1 based HMAC + * + * This function generates an HMAC verification hash, based on SHA1 + * + * \param msg Pointer to the message to be signed + * \param msg_len size of the message string + * \param hmac Pointer to the hmac buffer, where the final hmac will be stored + * \param hmac_key Pointer to the key to be used for generating the hmac + * \param hmac_key_len Size of the hmac key + * + */ void hmac_sha1(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len); +/** + * \brief Generate SHA256 based HMAC + * + * This function generates an HMAC verification hash, based on SHA256 + * + * \param msg Pointer to the message to be signed + * \param msg_len size of the message string + * \param hmac Pointer to the hmac buffer, where the final hmac will be stored + * \param hmac_key Pointer to the key to be used for generating the hmac + * \param hmac_key_len Size of the hmac key + * + */ void hmac_sha256(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len); +/** + * \brief Generate SHA384 based HMAC + * + * This function generates an HMAC verification hash, based on SHA384 + * + * \param msg Pointer to the message to be signed + * \param msg_len size of the message string + * \param hmac Pointer to the hmac buffer, where the final hmac will be stored + * \param hmac_key Pointer to the key to be used for generating the hmac + * \param hmac_key_len Size of the hmac key + * + */ void hmac_sha384(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len); +/** + * \brief Generate SHA512 based HMAC + * + * This function generates an HMAC verification hash, based on SHA512 + * + * \param msg Pointer to the message to be signed + * \param msg_len size of the message string + * \param hmac Pointer to the hmac buffer, where the final hmac will be stored + * \param hmac_key Pointer to the key to be used for generating the hmac + * \param hmac_key_len Size of the hmac key + * + */ void hmac_sha512(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len); +/** + * \brief Generate SHA3-256 based HMAC + * + * This function generates an HMAC verification hash, based on SHA3-256 + * + * \param msg Pointer to the message to be signed + * \param msg_len size of the message string + * \param hmac Pointer to the hmac buffer, where the final hmac will be stored + * \param hmac_key Pointer to the key to be used for generating the hmac + * \param hmac_key_len Size of the hmac key + * + */ void hmac_sha3_256(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len); +/** + * \brief Generate SHA3-512 based HMAC + * + * This function generates an HMAC verification hash, based on SHA3-512 + * + * \param msg Pointer to the message to be signed + * \param msg_len size of the message string + * \param hmac Pointer to the hmac buffer, where the final hmac will be stored + * \param hmac_key Pointer to the key to be used for generating the hmac + * \param hmac_key_len Size of the hmac key + * + */ void hmac_sha3_512(const char *msg, const unsigned int msg_len, unsigned char *hmac, const char *hmac_key, const int hmac_key_len);