MTB CAT1 Peripheral driver library

General Description

Functions

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac (CRYPTO_Type *base, uint8_t const *message, uint32_t messageSize, uint8_t const *key, cy_en_crypto_aes_key_length_t keyLength, uint8_t *cmac, cy_stc_crypto_aes_state_t *aesState)
 Calculates the AES Cipher-based Message Authentication Code (CMAC) on the input message with the provided key. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Init (CRYPTO_Type *base, void *cmacState, void *buffer)
 The function for initialization of CMAC operation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Start (CRYPTO_Type *base, void *cmacState, uint8_t const *aesKey, cy_en_crypto_aes_key_length_t keyLength)
 Starts CMAC calculation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Update (CRYPTO_Type *base, void *cmacState, uint8_t const *message, uint32_t messageSize)
 Performs cmac update for multi stage operation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Finish (CRYPTO_Type *base, void *cmacState, uint8_t *cmac)
 Completes CMAC calculation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Free (CRYPTO_Type *base, void *cmacState)
 For CAT1C & CAT1D(CM55) devices when D-Cache is enabled parameter cmac must align and end in 32 byte boundary. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac (CRYPTO_Type *base, uint8_t *hmac, uint8_t const *message, uint32_t messageSize, uint8_t const *key, uint32_t keyLength, cy_en_crypto_sha_mode_t mode)
 Performs the HMAC calculation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Init (CRYPTO_Type *base, cy_stc_crypto_hmac_state_t *hmacState, cy_en_crypto_sha_mode_t mode, void *hmacBuffer)
 The function to initialize the HMAC operation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Start (CRYPTO_Type *base, cy_stc_crypto_hmac_state_t *hmacState, uint8_t const *key, uint32_t keyLength)
 Initializes the HMAC key. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Update (CRYPTO_Type *base, cy_stc_crypto_hmac_state_t *hmacState, uint8_t const *message, uint32_t messageSize)
 Performs the multipart hmac operation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Finish (CRYPTO_Type *base, cy_stc_crypto_hmac_state_t *hmacState, uint8_t *hmac)
 Finishes the hmac operation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Free (CRYPTO_Type *base, cy_stc_crypto_hmac_state_t *hmacState)
 Frees the internally stored buffers in hmac context. More...
 

Function Documentation

◆ Cy_Crypto_Core_Cmac()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac ( CRYPTO_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
uint8_t const *  key,
cy_en_crypto_aes_key_length_t  keyLength,
uint8_t *  cmac,
cy_stc_crypto_aes_state_t aesState 
)

Calculates the AES Cipher-based Message Authentication Code (CMAC) on the input message with the provided key.

Parameters
baseThe pointer to the CRYPTO instance.
messageThe pointer to the source plain text. Must be 4-byte aligned.
messageSizeThe size of the source plain text in bytes.
keyThe pointer to the encryption key. Must be 4-byte aligned.
keyLengthcy_en_crypto_aes_key_length_t
cmacThe pointer to the calculated CMAC.
aesStateThe pointer to the AES state structure allocated by the user. The user must not modify anything in this structure.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t cmacKey[CY_CRYPTO_AES_256_KEY_SIZE] =
{
0x60u, 0x3Du, 0xEBu, 0x10u, 0x15u, 0xCAu, 0x71u, 0xBEu,
0x2Bu, 0x73u, 0xAEu, 0xF0u, 0x85u, 0x7Du, 0x77u, 0x81u,
0x1Fu, 0x35u, 0x2Cu, 0x07u, 0x3Bu, 0x61u, 0x08u, 0xD7u,
0x2Du, 0x98u, 0x10u, 0xA3u, 0x09u, 0x14u, 0xDFu, 0xF4u
};
uint8_t cmac256PlainText[16] =
{
0x6Bu, 0xC1u, 0xBEu, 0xE2u, 0x2Eu, 0x40u, 0x9Fu, 0x96u,
0xE9u, 0x3Du, 0x7Eu, 0x11u, 0x73u, 0x93u, 0x17u, 0x2Au
};
/* Calculated CMAC */
uint8_t cmac[CY_CRYPTO_AES_BLOCK_SIZE] = {0};
cy_en_crypto_status_t cryptoStatus;
/* CMAC from the text message using AES-256 */
cryptoStatus = Cy_Crypto_Core_Cmac(
CRYPTO_HW, /* Pointer to Crypto instance */
cmac256PlainText, /* Pointer to plain text */
sizeof(cmac256PlainText), /* Size of plain text */
cmacKey, /* Pointer to encryption key */
CY_CRYPTO_KEY_AES_256, /* Size of encryption key */
cmac, /* Pointer to calculated CMAC */
&aesState); /* Pointer to AES state structure */
/* ... check for errors... */

◆ Cy_Crypto_Core_Cmac_Init()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Init ( CRYPTO_Type *  base,
void *  cmacState,
void *  buffer 
)

The function for initialization of CMAC operation.

Parameters
baseThe pointer to the CRYPTO instance.
cmacStateThe pointer to the structure which stores the CMAC context.
bufferThe pointer to the cmac buffer.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Cmac_Start()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Start ( CRYPTO_Type *  base,
void *  cmacState,
uint8_t const *  aesKey,
cy_en_crypto_aes_key_length_t  keyLength 
)

Starts CMAC calculation.

Parameters
baseThe pointer to the CRYPTO instance.
cmacStateThe pointer to the structure which stores the CMAC context.
aesKeyThe pointer to the cmac key.
keyLengthcy_en_crypto_aes_key_length_t
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Cmac_Update()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Update ( CRYPTO_Type *  base,
void *  cmacState,
uint8_t const *  message,
uint32_t  messageSize 
)

Performs cmac update for multi stage operation.

For CAT1C & CAT1D(CM55) devices when D-Cache is enabled parameter message must align and end in 32 byte boundary.

Parameters
baseThe pointer to the CRYPTO instance.
cmacStateThe pointer to the structure which stores the CMAC context.
messageThe pointer to the message whose CMAC is being computed.
messageSizeThe size of the message whose CMAC is being computed.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Cmac_Finish()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Finish ( CRYPTO_Type *  base,
void *  cmacState,
uint8_t *  cmac 
)

Completes CMAC calculation.

For CAT1C & CAT1D(CM55) devices when D-Cache is enabled parameter cmac must align and end in 32 byte boundary.

Parameters
cmacStateThe pointer to the structure which stores the CMAC context.
baseThe pointer to the CRYPTO instance.
cmacThe pointer to the computed CMAC value.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Cmac_Free()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac_Free ( CRYPTO_Type *  base,
void *  cmacState 
)

For CAT1C & CAT1D(CM55) devices when D-Cache is enabled parameter cmac must align and end in 32 byte boundary.

Parameters
baseThe pointer to the CRYPTO instance.
cmacStateThe pointer to the structure which stores the CMAC context.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Hmac()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac ( CRYPTO_Type *  base,
uint8_t *  hmac,
uint8_t const *  message,
uint32_t  messageSize,
uint8_t const *  key,
uint32_t  keyLength,
cy_en_crypto_sha_mode_t  mode 
)

Performs the HMAC calculation.

Parameters
baseThe pointer to the CRYPTO instance.
hmacThe pointer to the calculated HMAC. Must be 4-byte aligned.
messageThe pointer to the message whose hash value is being computed.
messageSizeThe size of the message.
keyThe pointer to the key.
keyLengthThe length of the key.
modecy_en_crypto_sha_mode_t
Returns
cy_en_crypto_status_t
Function Usage
uint8_t hmac256Key[CY_CRYPTO_AES_256_KEY_SIZE] =
{
0x00u, 0x01u, 0x02u, 0x03u, 0x04u, 0x05u, 0x06u, 0x07u,
0x08u, 0x09u, 0x0Au, 0x0Bu, 0x0Cu, 0x0Du, 0x0Eu, 0x0Fu,
0x10u, 0x11u, 0x12u, 0x13u, 0x14u, 0x15u, 0x16u, 0x17u,
0x18u, 0x19u, 0x1Au, 0x1Bu, 0x1Cu, 0x1Du, 0x1Eu, 0x1Fu
};
uint8_t hmac256PlainText[34] =
{
0x53u, 0x61u,
0x6Du, 0x70u, 0x6Cu, 0x65u, 0x20u, 0x6Du, 0x65u, 0x73u,
0x73u, 0x61u, 0x67u, 0x65u, 0x20u, 0x66u, 0x6Fu, 0x72u,
0x20u, 0x6Bu, 0x65u, 0x79u, 0x6Cu, 0x65u, 0x6Eu, 0x3Cu,
0x62u, 0x6Cu, 0x6Fu, 0x63u, 0x6Bu, 0x6Cu, 0x65u, 0x6Eu
};
/* Calculated HMAC */
uint8_t hmac256[CY_CRYPTO_SHA256_DIGEST_SIZE] = {0};
cy_en_crypto_status_t cryptoStatus;
/* HMAC from the text message using SHA256 */
cryptoStatus = Cy_Crypto_Core_Hmac(
CRYPTO_HW, /* Pointer to Crypto instance */
hmac256, /* Pointer to calculated HMAC */
hmac256PlainText, /* Pointer to plain text */
sizeof(hmac256PlainText), /* Size of plain text */
hmac256Key, /* Pointer to encryption key */
sizeof(hmac256Key), /* Size of encryption key */
CY_CRYPTO_MODE_SHA256); /* SHA method */
/* ... check for errors... */

◆ Cy_Crypto_Core_Hmac_Init()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Init ( CRYPTO_Type *  base,
cy_stc_crypto_hmac_state_t hmacState,
cy_en_crypto_sha_mode_t  mode,
void *  hmacBuffer 
)

The function to initialize the HMAC operation.

For CAT1C & CAT1D(CM55) devices when D-Cache is enabled parameters hmacState and hmacBuffer must align and end in 32 byte boundary.

Parameters
baseThe pointer to the CRYPTO instance.
hmacStateThe pointer to the HMAC state.
hmacBufferThe pointer to the chmac buffer structure that stores all buffers for HMAC operation.
modecy_en_crypto_sha_mode_t
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Hmac_Start()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Start ( CRYPTO_Type *  base,
cy_stc_crypto_hmac_state_t hmacState,
uint8_t const *  key,
uint32_t  keyLength 
)

Initializes the HMAC key.

For CAT1C & CAT1D(CM55) devices when D-Cache is enabled parameters key & hmacState (m0Key) must align and end in 32 byte boundary.

Parameters
baseThe pointer to the CRYPTO instance.
hmacStateThe pointer to the HMAC state.
keythe pointer to the hmac key
keyLengththe length of the key
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Hmac_Update()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Update ( CRYPTO_Type *  base,
cy_stc_crypto_hmac_state_t hmacState,
uint8_t const *  message,
uint32_t  messageSize 
)

Performs the multipart hmac operation.

Parameters
baseThe pointer to the CRYPTO instance.
hmacStateThe pointer to the HMAC state.
messagethe pointer to the message
messageSizethe length of the message
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Hmac_Finish()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Finish ( CRYPTO_Type *  base,
cy_stc_crypto_hmac_state_t hmacState,
uint8_t *  hmac 
)

Finishes the hmac operation.

Parameters
baseThe pointer to the CRYPTO instance.
hmacStateThe pointer to the HMAC state.
hmacthe pointer to store the hmac.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Hmac_Free()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac_Free ( CRYPTO_Type *  base,
cy_stc_crypto_hmac_state_t hmacState 
)

Frees the internally stored buffers in hmac context.

For CAT1C & CAT1D(CM55) devices when D-Cache is enabled parameters hmacState must align and end in 32 byte boundary.

Parameters
baseThe pointer to the CRYPTO instance.
hmacStateThe pointer to the HMAC state.
Returns
cy_en_crypto_status_t