hmac.c File Reference

HMAC module implementation file. More...

#include "hmac.h"
#include "memory.h"
#include "security.h"
#include "log_util.h"
#include "string_util.h"
#include "definitions.h"
Include dependency graph for hmac.c:

Go to the source code of this file.

Macros

#define HMAC_MAXIMUM_KEY_SIZE   64
 
#define HMAC_SHA256_SIZE   32
 

Functions

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)
 

Variables

static const mcl_uint8_t hmac_ipad = 0x36
 
static const mcl_uint8_t hmac_opad = 0x5C
 

Detailed Description

HMAC module implementation file.


Date
Aug 16, 2016

Definition in file hmac.c.

Macro Definition Documentation

#define HMAC_MAXIMUM_KEY_SIZE   64

Definition at line 22 of file hmac.c.

Referenced by hmac_sha256().

#define HMAC_SHA256_SIZE   32

Definition at line 23 of file hmac.c.

Referenced by hmac_sha256().

Function Documentation

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 
)

Calculates 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.

Parameters
[in]dataData to calculate HMAC SHA256 for.
[in]data_sizeSize of data.
[in]keySecret key to be used during calculation.
[in]key_sizeSize of key.
[out]hashA newly allocated memory which contains the result of HMAC SHA256.
[out]hash_sizeSize of hash, which should be 32 bytes after SHA256 calculation.
Returns

Definition at line 27 of file hmac.c.

References ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, hmac_ipad, HMAC_MAXIMUM_KEY_SIZE, hmac_opad, HMAC_SHA256_SIZE, MCL_DEBUG, 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().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const mcl_uint8_t hmac_ipad = 0x36
static

Definition at line 24 of file hmac.c.

Referenced by hmac_sha256().

const mcl_uint8_t hmac_opad = 0x5C
static

Definition at line 25 of file hmac.c.

Referenced by hmac_sha256().