HMAC module header file. More...
#include "mcl_core/mcl_core_common.h"
Go to the source code of this file.
Functions | |
MCL_LOCAL 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) |
HMAC module header file.
This module defines several hashing functions required by other modules.
Definition in file hmac.h.
MCL_LOCAL 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 | ||
) |
This function is used for calculating HMAC SHA256 for given data with provided secret key
. If secret key
exceeds maximum allowed size of 64 bytes it will be reduced to 32 bytes. The reduction is done by calculating SHA256 hash of the key, which returns 32 bytes.
[in] | data | Data to calculate HMAC SHA256 for. |
[in] | data_size | Size of data . |
[in] | key | Secret key to be used during calculation. |
[in] | key_size | Size of key . |
[out] | hash | A newly allocated memory which contains the result of HMAC SHA256. |
[out] | hash_size | Size of hash , which should be 32 bytes after SHA256 calculation. |
key_size
is zero. Definition at line 21 of file hmac.c.
References hmac_ipad, HMAC_MAXIMUM_KEY_SIZE, hmac_opad, HMAC_SHA256_SIZE, MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_STATEMENT_CODE_MESSAGE, MCL_DEBUG, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_RETURN, MCL_FREE, MCL_INVALID_PARAMETER, MCL_MALLOC, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_SHA256_CALCULATION_FAIL, security_hash_sha256(), and string_util_memcpy().
Referenced by security_handler_hmac_sha256().