linux/drivers/mxc/security/rng/include/shw_hmac.h File Reference

Data Structures

struct  shw_hmac_state

Typedefs

typedef struct shw_hmac_state shw_hmac_state_t

Functions

fsl_shw_return_t shw_hmac_init (shw_hmac_state_t *state, const uint8_t *key, unsigned int key_len)
fsl_shw_return_t shw_hmac_update (shw_hmac_state_t *state, const uint8_t *msg, unsigned int msg_len)
fsl_shw_return_t shw_hmac_final (shw_hmac_state_t *state, uint8_t *hmac, unsigned int hmac_len)

Detailed Description

This file contains definitions for use of the (internal) SHW HMAC software computation. It defines the usual three steps:

The only other item of note to callers is SHW_HASH_LEN, which is the number of bytes calculated for the HMAC.


Typedef Documentation

State for an HMAC

Note to callers: This structure contains key material and should be kept in a secure location, such as internal RAM.


Function Documentation

fsl_shw_return_t shw_hmac_final ( shw_hmac_state_t state,
uint8_t *  hmac,
unsigned int  hmac_len 
)

Calculate the final HMAC

Parameters:
state Address of HMAC state structure.
hmac Address of location to store the HMAC.
hmac_len Number of bytes of mac to be stored. Probably best if this value is no greater than SHW_HASH_LEN.
Returns:
FSL_RETURN_OK_S if all went well, otherwise an error code.

Calculate the final HMAC

Parameters:
state Address of HMAC state structure.
hmac Address of location to store the HMAC.
hmac_len Number of bytes of mac to be stored. Probably best if this value is no greater than SHW_HASH_LEN.

This function finalizes the internal hash, and uses that result as data for the outer hash. As many bytes of that result are passed to the user as desired.

Returns:
FSL_RETURN_OK_S if all went well, otherwise an error code.

References FSL_RETURN_OK_S, shw_hmac_state::inner_hash, shw_hmac_state::outer_hash, shw_hash_final(), SHW_HASH_LEN, and shw_hash_update().

fsl_shw_return_t shw_hmac_init ( shw_hmac_state_t state,
const uint8_t *  key,
unsigned int  key_len 
)

Initialize the HMAC state structure with the HMAC key

Parameters:
state Address of HMAC state structure.
key Address of the key to be used for the HMAC.
key_len Number of bytes of key. This must not be greater than the block size of the underlying hash (SHW_HASH_BLOCK_LEN).
Returns:
FSL_RETURN_OK_S if all went well, otherwise an error code.

Initialize the HMAC state structure with the HMAC key

Parameters:
state Address of HMAC state structure
key Address of the key to be used for the HMAC.
key_len Number of bytes of key.

Convert the key into its equivalent inner and outer hash state objects.

Returns:
FSL_RETURN_OK_S if all went well, otherwise an error code.

References FSL_HASH_ALG_SHA256, FSL_RETURN_BAD_KEY_LENGTH_S, FSL_RETURN_ERROR_S, FSL_RETURN_OK_S, shw_hmac_state::inner_hash, INNER_HASH_CONSTANT, shw_hmac_state::outer_hash, OUTER_HASH_CONSTANT, shw_hash_init(), and shw_hash_update().

fsl_shw_return_t shw_hmac_update ( shw_hmac_state_t state,
const uint8_t *  msg,
unsigned int  msg_len 
)

Put data into the HMAC calculation

Parameters:
state Address of HMAC state structure.
msg Address of the message data for the HMAC.
msg_len Number of bytes of msg.
Returns:
FSL_RETURN_OK_S if all went well, otherwise an error code.

Put data into the HMAC calculation

Send the msg data inner inner hash's update function.

Parameters:
state Address of HMAC state structure.
msg Address of the message data for the HMAC.
msg_len Number of bytes of msg.
Returns:
FSL_RETURN_OK_S if all went well, otherwise an error code.

References FSL_RETURN_OK_S, shw_hmac_state::inner_hash, and shw_hash_update().

footer
©  Freescale Semiconductor, Inc., 2007.  All rights reserved.
Freescale Confidential Proprietary
NDA Required
doxygen