mbed port of tinydtls

Embed: (wiki syntax)

« Back to documentation index

Keyed-Hash Message Authentication Code (HMAC)

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_tdtls_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

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.

Definition at line 78 of file hmac.h.


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:
ctxThe HMAC context.
resultOutput parameter where the MAC is written to.
Returns:
Length of the MAC written to result.

Definition at line 123 of file hmac.c.

void dtls_hmac_free ( dtls_hmac_context_t ctx )

Releases the storage for ctx that has been allocated by dtls_hmac_new().

Parameters:
ctxThe dtls_hmac_context_t to free.

Definition at line 117 of file hmac.c.

void dtls_hmac_init ( dtls_hmac_context_t ctx,
const unsigned char *  key,
size_t  klen 
)

Initializes an existing HMAC context.

Parameters:
ctxThe HMAC context to initialize.
keyThe secret key.
klenThe length of key.

Definition at line 90 of file hmac.c.

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:
keyThe secret key.
klenThe length of key.
Returns:
A new dtls_hmac_context_t object or NULL on error

Definition at line 79 of file hmac.c.

void dtls_hmac_update ( dtls_hmac_context_t ctx,
const unsigned char *  input,
size_t  ilen 
)

Updates the HMAC context with data from input.

Parameters:
ctxThe HMAC context.
inputThe input data.
ilenSize of input.

Definition at line 72 of file hmac.c.