mbed port of tinydtls
Keyed-Hash Message Authentication Code (HMAC)
NIST Standard FIPS 198 describes the Keyed-Hash Message Authentication Code (HMAC) which is used as hash function for the DTLS PRF. More...
Data Structures | |
struct | dtls_hmac_context_t |
Context for HMAC generation. More... | |
Enumerations | |
enum | dtls_hashfunc_t |
List of known hash functions for use in dtls_hmac_init(). More... | |
Functions | |
void | dtls_hmac_init (dtls_hmac_context_t *ctx, const unsigned char *key, size_t klen) |
Initializes an existing HMAC context. | |
dtls_hmac_context_t * | dtls_hmac_new (const unsigned char *key, size_t klen) |
Allocates a new HMAC context ctx with the given secret key. | |
void | dtls_hmac_free (dtls_hmac_context_t *ctx) |
Releases the storage for ctx that has been allocated by dtls_hmac_new(). | |
void | dtls_hmac_update (dtls_hmac_context_t *ctx, const unsigned char *input, size_t ilen) |
Updates the HMAC context with data from input . | |
int | dtls_hmac_finalize (dtls_hmac_context_t *ctx, unsigned char *result) |
Completes the HMAC generation and writes the result to the given output parameter result . |
Detailed Description
NIST Standard FIPS 198 describes the Keyed-Hash Message Authentication Code (HMAC) which is used as hash function for the DTLS PRF.
Enumeration Type Documentation
enum dtls_hashfunc_t |
List of known hash functions for use in dtls_hmac_init().
The identifiers are the same as the HashAlgorithm defined in Section 7.4.1.4.1 of RFC 5246.
Function Documentation
int dtls_hmac_finalize | ( | dtls_hmac_context_t * | ctx, |
unsigned char * | result | ||
) |
Completes the HMAC generation and writes the result to the given output parameter result
.
The buffer must be large enough to hold the message digest created by the actual hash function. If in doubt, use DTLS_HMAC_MAX
. The function returns the number of bytes written to result
.
- Parameters:
-
ctx The HMAC context. result Output parameter where the MAC is written to.
- Returns:
- Length of the MAC written to
result
.
void dtls_hmac_free | ( | dtls_hmac_context_t * | ctx ) |
Releases the storage for ctx
that has been allocated by dtls_hmac_new().
- Parameters:
-
ctx The dtls_hmac_context_t to free.
void dtls_hmac_init | ( | dtls_hmac_context_t * | ctx, |
const unsigned char * | key, | ||
size_t | klen | ||
) |
dtls_hmac_context_t* dtls_hmac_new | ( | const unsigned char * | key, |
size_t | klen | ||
) |
Allocates a new HMAC context ctx
with the given secret key.
This function returns 1
if ctx
has been set correctly, or 0
or -1
otherwise. Note that this function allocates new storage that must be released by dtls_hmac_free().
- Parameters:
-
key The secret key. klen The length of key
.
- Returns:
- A new dtls_hmac_context_t object or
NULL
on error
void dtls_hmac_update | ( | dtls_hmac_context_t * | ctx, |
const unsigned char * | input, | ||
size_t | ilen | ||
) |
Generated on Thu Jul 14 2022 20:00:56 by 1.7.2