16 #define HMAC_MAXIMUM_KEY_SIZE 64 17 #define HMAC_SHA256_SIZE 32 37 MCL_DEBUG_ENTRY(
"const mcl_uint8_t *data = <%p>, mcl_size_t data_size = <%u>, const mcl_uint8_t *key = <%p>, mcl_size_t key_size = <%u>, "\
38 "mcl_uint8_t **hash = <%p>, mcl_size_t *hash_size = <%p>", data, data_size, key, key_size, hash, hash_size);
44 MCL_DEBUG(
"Resizing given key to its SHA256 value.");
51 key_local = key_resized;
55 MCL_DEBUG(
"Preparing buffers key_ipad and key_opad.");
62 if (key_resized == key_local)
75 if (key_resized == key_local)
83 for (index = 0; index < key_local_size; ++index)
85 key_ipad[index] = key_local[index] ^
hmac_ipad;
86 key_opad[index] = key_local[index] ^
hmac_opad;
90 if (key_resized == key_local)
107 MCL_DEBUG(
"Calculating first SHA256 from XORed key + data.");
120 if (HMAC_SHA256_SIZE != sha_output_size)
130 MCL_DEBUG(
"Copying first SHA256 result to buffer.");
134 MCL_DEBUG(
"Calculating second SHA256 from XORed key + <first SHA256>.");
148 if ((
MCL_NULL != *hash) && (HMAC_SHA256_SIZE != *hash_size))
156 MCL_DEBUG(
"HMAC SHA256 calculated hash = <%p>, hash_size = <%u>", *hash, *hash_size);
#define HMAC_MAXIMUM_KEY_SIZE
If SHA256 calculation fails.
Assert module header file.
static const mcl_uint8_t hmac_ipad
#define MCL_DEBUG_ENTRY(...)
String utility module header file.
#define MCL_ASSERT_CODE_MESSAGE(condition, return_code,...)
static const mcl_uint8_t hmac_opad
mcl_error_t security_hash_sha256(const mcl_uint8_t *data, mcl_size_t data_size, mcl_uint8_t **hash, mcl_size_t *hash_size)
void string_util_memcpy(void *destination, const void *source, mcl_size_t count)
#define MCL_ASSERT_STATEMENT_CODE_MESSAGE(condition, statement, return_code,...)
#define MCL_ERROR_RETURN(return_value,...)
Security interface header file.
#define MCL_MALLOC(bytes)
mcl_error_t hmac_sha256(const mcl_uint8_t *data, mcl_size_t data_size, const mcl_uint8_t *key, mcl_size_t key_size, mcl_uint8_t **hash, mcl_size_t *hash_size)
General invalid parameter fail.
#define MCL_DEBUG_LEAVE(...)
Memory module interface header file.