22 #define HMAC_MAXIMUM_KEY_SIZE 64 23 #define HMAC_SHA256_SIZE 32 29 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>, mcl_uint8_t **hash = <%p>, mcl_size_t *hash_size = <%p>",
30 data, data_size, key, key_size, hash, hash_size)
50 MCL_DEBUG(
"Resizing given key to its SHA256 value.");
53 ASSERT_CODE_MESSAGE(
MCL_OK == code, code,
"Given HMAC key size = <%u> was greater than allowed = <%u>, but new key couldn't be constructed from its SHA256 hash!",
57 key_local = key_resized;
61 MCL_DEBUG(
"Preparing buffers key_ipad and key_opad.");
68 if (key_resized == key_local)
81 if (key_resized == key_local)
89 for (index = 0; index < key_local_size; index++)
91 key_ipad[index] = key_local[index] ^
hmac_ipad;
92 key_opad[index] = key_local[index] ^
hmac_opad;
96 if (key_resized == key_local)
113 MCL_DEBUG(
"Calculating first SHA256 from XORed key + data");
126 if (HMAC_SHA256_SIZE != sha_output_size)
136 MCL_DEBUG(
"Copying first SHA256 result to buffer.");
140 MCL_DEBUG(
"Calculating second SHA256 from XORed key + <first SHA256>");
154 if ((
MCL_NULL != *hash) && (HMAC_SHA256_SIZE != *hash_size))
162 MCL_DEBUG(
"HMAC SHA256 calculated hash = <%p>, hash_size = <%u>", *hash, *hash_size);
#define HMAC_MAXIMUM_KEY_SIZE
Memory module header file.
static const mcl_uint8_t hmac_ipad
#define MCL_MALLOC(bytes)
Log utility module header file.
String utility module implementation file.
E_MCL_ERROR_CODE
MCL Error code definitions. Every function returning an error code uses this enum values...
E_MCL_ERROR_CODE 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)
#define ASSERT_STATEMENT_CODE_MESSAGE(condition, statement, return_code,...)
static const mcl_uint8_t hmac_opad
E_MCL_ERROR_CODE security_hash_sha256(const mcl_uint8_t *data, mcl_size_t data_size, mcl_uint8_t **hash, mcl_size_t *hash_size)
General invalid parameter fail.
void string_util_memcpy(void *destination, const void *source, mcl_size_t count)
Standard library memcpy wrapper.
#define ASSERT_CODE_MESSAGE(condition, return_code,...)
Definitions module header file.
Security module header file.Inner security interface. Contains security related functions like hashin...
If SHA256 calculation fails.
#define MCL_ERROR_RETURN(return_value,...)