NimBLE-Arduino 2.1.2
|
Interface to an HMAC implementation. More...
Go to the source code of this file.
Functions | |
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. | |
int | tc_hmac_init (TCHmacState_t ctx) |
HMAC init procedure Initializes ctx to begin the next HMAC operation. | |
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. | |
int | tc_hmac_final (uint8_t *tag, unsigned int taglen, TCHmacState_t ctx) |
HMAC final procedure Writes the HMAC tag into the tag buffer. | |
Interface to an HMAC implementation.
Overview: HMAC is a message authentication code based on hash functions. TinyCrypt hard codes SHA-256 as the hash function. A message authentication code based on hash functions is also called a keyed cryptographic hash function since it performs a transformation specified by a key in an arbitrary length data set into a fixed length data set (also called tag).
Security: The security of the HMAC depends on the length of the key and on the security of the hash function. Note that HMAC primitives are much less affected by collision attacks than their corresponding hash functions.
Requires: SHA-256
Usage: 1) call tc_hmac_set_key to set the HMAC key.
2) call tc_hmac_init to initialize a struct hash_state before processing the data. 3) call tc_hmac_update to process the next input segment; tc_hmac_update can be called as many times as needed to process all of the segments of the input; the order is important. 4) call tc_hmac_final to out put the tag.
int tc_hmac_final | ( | uint8_t * | tag, |
unsigned int | taglen, | ||
TCHmacState_t | ctx | ||
) |
HMAC final procedure Writes the HMAC tag into the tag buffer.
tag | IN/OUT – buffer to receive computed HMAC tag |
taglen | IN – size of tag in bytes |
ctx | IN/OUT – the HMAC state for computing tag |
int tc_hmac_init | ( | TCHmacState_t | ctx | ) |
HMAC init procedure Initializes ctx to begin the next HMAC operation.
ctx | IN/OUT – struct tc_hmac_state_struct buffer to init |
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.
ctx | IN/OUT – the struct tc_hmac_state_struct to initial |
key | IN – the HMAC key to configure |
key_size | IN – the HMAC key size |
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.
ctx | IN/OUT – state of HMAC computation so far |
data | IN – data to incorporate into state |
data_length | IN – size of data in bytes |