ndn-lite
Functions
tc_hmac.c File Reference
#include "tc_hmac.h"
#include "tc_constants.h"
#include "tc_utils.h"

Functions

static void rekey (uint8_t *key, const uint8_t *new_key, unsigned int key_size)
 
int tc_hmac_set_key (TCHmacState_t ctx, const uint8_t *key, unsigned int key_size)
 HMAC set key procedure Configures ctx to use key. More...
 
int tc_hmac_init (TCHmacState_t ctx)
 HMAC init procedure Initializes ctx to begin the next HMAC operation. More...
 
int tc_hmac_update (TCHmacState_t ctx, const void *data, unsigned int data_length)
 HMAC update procedure Mixes data_length bytes addressed by data into state. More...
 
int tc_hmac_final (uint8_t *tag, unsigned int taglen, TCHmacState_t ctx)
 HMAC final procedure Writes the HMAC tag into the tag buffer. More...
 

Function Documentation

◆ rekey()

static void rekey ( uint8_t *  key,
const uint8_t *  new_key,
unsigned int  key_size 
)
static

◆ tc_hmac_final()

int tc_hmac_final ( uint8_t *  tag,
unsigned int  taglen,
TCHmacState_t  ctx 
)

HMAC final procedure Writes the HMAC tag into the tag buffer.

Returns
returns TC_CRYPTO_SUCCESS (1) returns TC_CRYPTO_FAIL (0) if: tag == NULL or ctx == NULL or key == NULL or taglen != TC_SHA256_DIGEST_SIZE
Note
ctx is erased before exiting. This should never be changed/removed.
Assumes the tag bufer is at least sizeof(hmac_tag_size(state)) bytes state has been initialized by tc_hmac_init
Parameters
tagIN/OUT – buffer to receive computed HMAC tag
taglenIN – size of tag in bytes
ctxIN/OUT – the HMAC state for computing tag

◆ tc_hmac_init()

int tc_hmac_init ( TCHmacState_t  ctx)

HMAC init procedure Initializes ctx to begin the next HMAC operation.

Returns
returns TC_CRYPTO_SUCCESS (1) returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL
Parameters
ctxIN/OUT – struct tc_hmac_state_struct buffer to init

◆ tc_hmac_set_key()

int tc_hmac_set_key ( TCHmacState_t  ctx,
const uint8_t *  key,
unsigned int  key_size 
)

HMAC set key procedure Configures ctx to use key.

Returns
returns TC_CRYPTO_SUCCESS (1) returns TC_CRYPTO_FAIL (0) if ctx == NULL or key == NULL or key_size == 0
Parameters
ctxIN/OUT – the struct tc_hmac_state_struct to initial
keyIN – the HMAC key to configure
key_sizeIN – the HMAC key size

◆ tc_hmac_update()

int tc_hmac_update ( TCHmacState_t  ctx,
const void *  data,
unsigned int  data_length 
)

HMAC update procedure Mixes data_length bytes addressed by data into state.

Returns
returns TC_CRYPTO_SUCCCESS (1) returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL
Note
Assumes state has been initialized by tc_hmac_init
Parameters
ctxIN/OUT – state of HMAC computation so far
dataIN – data to incorporate into state
data_lengthIN – size of data in bytes