MTB CAT1 Peripheral driver library

General Description

Functions

cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Init (CRYPTOLITE_Type *base, uint8_t const *key, cy_stc_cryptolite_aes_state_t *cmacState, cy_stc_cryptolite_aes_buffers_t *aesBuffers)
 The function for initialization of CMAC operation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Start (CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *cmacState)
 Starts CMAC calculation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Update (CRYPTOLITE_Type *base, uint8_t const *message, uint32_t messageSize, cy_stc_cryptolite_aes_state_t *cmacState)
 Performs cmac update for multi stage operation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Finish (CRYPTOLITE_Type *base, uint8_t *cmac, cy_stc_cryptolite_aes_state_t *cmacState)
 Completes CMAC calculation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Free (CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *cmacState)
 Clears CMAC operation context. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Cmac (CRYPTOLITE_Type *base, uint8_t const *key, uint8_t const *message, uint32_t messageSize, uint8_t *cmac, cy_stc_cryptolite_aes_state_t *cmacState)
 Performs CMAC(Cipher-based Message Authentication Code) operation on a message to produce message authentication code using AES. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Init (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_hmac_sha256_t *cfContext)
 The function to initialize the HMAC operation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Start (CRYPTOLITE_Type *base, uint8_t const *key, uint32_t keyLength, cy_stc_cryptolite_context_hmac_sha256_t *cfContext)
 Initializes the initial Hash vector. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE_Type *base, uint8_t const *message, uint32_t messageSize, cy_stc_cryptolite_context_hmac_sha256_t *cfContext)
 Performs the HMAC update on message. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Finish (CRYPTOLITE_Type *base, uint8_t *hmac, cy_stc_cryptolite_context_hmac_sha256_t *cfContext)
 Completes the HMAC SHA256 calculation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Free (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_hmac_sha256_t *cfContext)
 Clears the used memory and context data. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Run (CRYPTOLITE_Type *base, uint8_t const *key, uint32_t keyLength, uint8_t const *message, uint32_t messageSize, uint8_t *hmac, cy_stc_cryptolite_context_hmac_sha256_t *cfContext)
 This function performs the HMAC SHA256 function. More...
 

Function Documentation

◆ Cy_Cryptolite_Cmac_Init()

cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Init ( CRYPTOLITE_Type *  base,
uint8_t const *  key,
cy_stc_cryptolite_aes_state_t cmacState,
cy_stc_cryptolite_aes_buffers_t aesBuffers 
)

The function for initialization of CMAC operation.

Parameters
baseThe pointer to the CRYPTOLITE instance.
keyThe pointer to the CMAC key.
cmacStateThe pointer to the AES state structure allocated by the user. The user must not modify anything in this structure.
aesBuffersThe buffers should be a SAHB mapped addresses. The pointer to the memory buffers storage.
Returns
cy_en_cryptolite_status_t

◆ Cy_Cryptolite_Cmac_Start()

cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Start ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_aes_state_t cmacState 
)

Starts CMAC calculation.

Parameters
baseThe pointer to the CRYPTOLITE instance.
cmacStateThe pointer to the structure which stores the CMAC context.
Returns
cy_en_cryptolite_status_t

◆ Cy_Cryptolite_Cmac_Update()

cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Update ( CRYPTOLITE_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
cy_stc_cryptolite_aes_state_t cmacState 
)

Performs cmac update for multi stage operation.

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

◆ Cy_Cryptolite_Cmac_Finish()

cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Finish ( CRYPTOLITE_Type *  base,
uint8_t *  cmac,
cy_stc_cryptolite_aes_state_t cmacState 
)

Completes CMAC calculation.

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

◆ Cy_Cryptolite_Cmac_Free()

cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Free ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_aes_state_t cmacState 
)

Clears CMAC operation context.

Parameters
baseThe pointer to the CRYPTOLITE instance.
cmacStateThe pointer to the AES state structure allocated by the user. The user must not modify anything in this structure.
Returns
cy_en_cryptolite_status_t

◆ Cy_Cryptolite_Cmac()

cy_en_cryptolite_status_t Cy_Cryptolite_Cmac ( CRYPTOLITE_Type *  base,
uint8_t const *  key,
uint8_t const *  message,
uint32_t  messageSize,
uint8_t *  cmac,
cy_stc_cryptolite_aes_state_t cmacState 
)

Performs CMAC(Cipher-based Message Authentication Code) operation on a message to produce message authentication code using AES.

Parameters
baseThe pointer to the CRYPTOLITE instance.
messageThe pointer to a source plain text.
messageSizeThe size of a source plain text.
keyThe pointer to the encryption key.
cmacThe pointer to the calculated CMAC.
cmacStateThe pointer to the AES state structure allocated by the user. The user must not modify anything in this structure.
Returns
cy_en_cryptolite_status_t

◆ Cy_Cryptolite_Hmac_Sha256_Init()

cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Init ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_context_hmac_sha256_t cfContext 
)

The function to initialize the HMAC operation.

Parameters
baseThe pointer to the Cryptolite instance.
cfContextThe pointer to the cy_stc_cryptolite_context_hmac_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Key : */
const uint8_t HMAC_SHA256_Vector0_Key0[] = {0x6f,0x35,0x62,0x8d,0x65,0x81,0x34,0x35,0x53,0x4b,0x5d,0x67,0xfb,0xdb,0x54,0xcb,0x33,0x40,0x3d,0x04,0xe8,0x43,0x10,0x3e,0x63,0x99,0xf8,0x06,0xcb,0x5d,0xf9,0x5f,0xeb,0xbd,0xd6,0x12,0x36,0xf3,0x32,0x45};
/* Message : */
const uint8_t HMAC_SHA256_Vector0_Msg0[] = {0x75,0x2c,0xff,0x52,0xe4,0xb9,0x07,0x68,0x55,0x8e,0x53,0x69,0xe7,0x5d,0x97,0xc6,0x96,0x43,0x50,0x9a,0x5e,0x59,0x04,0xe0,0xa3,0x86,0xcb,0xe4,0xd0,0x97,0x0e,0xf7,0x3f,0x91,0x8f,0x67,0x59,0x45,0xa9,0xae,0xfe,0x26,0xda,0xea,0x27,0x58,0x7e,0x8d,0xc9,0x09,0xdd,0x56,0xfd,0x04,0x68,0x80,0x5f,0x83,0x40,0x39,0xb3,0x45,0xf8,0x55,0xcf,0xe1,0x9c,0x44,0xb5,0x5a,0xf2,0x41,0xff,0xf3,0xff,0xcd,0x80,0x45,0xcd,0x5c,0x28,0x8e,0x6c,0x4e,0x28,0x4c,0x37,0x20,0x57,0x0b,0x58,0xe4,0xd4,0x7b,0x8f,0xee,0xed,0xc5,0x2f,0xd1,0x40,0x1f,0x69,0x8a,0x20,0x9f,0xcc,0xfa,0x3b,0x4c,0x0d,0x9a,0x79,0x7b,0x04,0x6a,0x27,0x59,0xf8,0x2a,0x54,0xc4,0x1c,0xcd,0x7b,0x5f,0x59,0x2b,};
/* Calculated HMAC-SHA-256*/
uint8_t hmac[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* MAC calculation */
status = Cy_Cryptolite_Hmac_Sha256_Init (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Start (CRYPTOLITE, HMAC_SHA256_Vector0_Key0, sizeof(HMAC_SHA256_Vector0_Key0), &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[0], 10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[10], sizeof(HMAC_SHA256_Vector0_Msg0)-10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Finish (CRYPTOLITE, hmac, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Free (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */

◆ Cy_Cryptolite_Hmac_Sha256_Start()

cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Start ( CRYPTOLITE_Type *  base,
uint8_t const *  key,
uint32_t  keyLength,
cy_stc_cryptolite_context_hmac_sha256_t cfContext 
)

Initializes the initial Hash vector.

Parameters
baseThe pointer to the CRYPTOLITE instance.
keyThe pointer to the HMAC key.
keyLengthThe length of the HMAC key.

key The pointer to the HMAC key.

keyLength The length of the HMAC key.

Parameters
cfContextThe pointer to the cy_stc_cryptolite_context_hmac_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Key : */
const uint8_t HMAC_SHA256_Vector0_Key0[] = {0x6f,0x35,0x62,0x8d,0x65,0x81,0x34,0x35,0x53,0x4b,0x5d,0x67,0xfb,0xdb,0x54,0xcb,0x33,0x40,0x3d,0x04,0xe8,0x43,0x10,0x3e,0x63,0x99,0xf8,0x06,0xcb,0x5d,0xf9,0x5f,0xeb,0xbd,0xd6,0x12,0x36,0xf3,0x32,0x45};
/* Message : */
const uint8_t HMAC_SHA256_Vector0_Msg0[] = {0x75,0x2c,0xff,0x52,0xe4,0xb9,0x07,0x68,0x55,0x8e,0x53,0x69,0xe7,0x5d,0x97,0xc6,0x96,0x43,0x50,0x9a,0x5e,0x59,0x04,0xe0,0xa3,0x86,0xcb,0xe4,0xd0,0x97,0x0e,0xf7,0x3f,0x91,0x8f,0x67,0x59,0x45,0xa9,0xae,0xfe,0x26,0xda,0xea,0x27,0x58,0x7e,0x8d,0xc9,0x09,0xdd,0x56,0xfd,0x04,0x68,0x80,0x5f,0x83,0x40,0x39,0xb3,0x45,0xf8,0x55,0xcf,0xe1,0x9c,0x44,0xb5,0x5a,0xf2,0x41,0xff,0xf3,0xff,0xcd,0x80,0x45,0xcd,0x5c,0x28,0x8e,0x6c,0x4e,0x28,0x4c,0x37,0x20,0x57,0x0b,0x58,0xe4,0xd4,0x7b,0x8f,0xee,0xed,0xc5,0x2f,0xd1,0x40,0x1f,0x69,0x8a,0x20,0x9f,0xcc,0xfa,0x3b,0x4c,0x0d,0x9a,0x79,0x7b,0x04,0x6a,0x27,0x59,0xf8,0x2a,0x54,0xc4,0x1c,0xcd,0x7b,0x5f,0x59,0x2b,};
/* Calculated HMAC-SHA-256*/
uint8_t hmac[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* MAC calculation */
status = Cy_Cryptolite_Hmac_Sha256_Init (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Start (CRYPTOLITE, HMAC_SHA256_Vector0_Key0, sizeof(HMAC_SHA256_Vector0_Key0), &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[0], 10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[10], sizeof(HMAC_SHA256_Vector0_Msg0)-10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Finish (CRYPTOLITE, hmac, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Free (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */

◆ Cy_Cryptolite_Hmac_Sha256_Update()

cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Update ( CRYPTOLITE_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
cy_stc_cryptolite_context_hmac_sha256_t cfContext 
)

Performs the HMAC update on message.

Parameters
baseThe pointer to the CRYPTOLITE instance.
messageThe address pointer to the message whose Hash is being computed.
messageSizeThe size of the message whose Hash is being computed.
cfContextThe pointer to the cy_stc_cryptolite_context_hmac_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Key : */
const uint8_t HMAC_SHA256_Vector0_Key0[] = {0x6f,0x35,0x62,0x8d,0x65,0x81,0x34,0x35,0x53,0x4b,0x5d,0x67,0xfb,0xdb,0x54,0xcb,0x33,0x40,0x3d,0x04,0xe8,0x43,0x10,0x3e,0x63,0x99,0xf8,0x06,0xcb,0x5d,0xf9,0x5f,0xeb,0xbd,0xd6,0x12,0x36,0xf3,0x32,0x45};
/* Message : */
const uint8_t HMAC_SHA256_Vector0_Msg0[] = {0x75,0x2c,0xff,0x52,0xe4,0xb9,0x07,0x68,0x55,0x8e,0x53,0x69,0xe7,0x5d,0x97,0xc6,0x96,0x43,0x50,0x9a,0x5e,0x59,0x04,0xe0,0xa3,0x86,0xcb,0xe4,0xd0,0x97,0x0e,0xf7,0x3f,0x91,0x8f,0x67,0x59,0x45,0xa9,0xae,0xfe,0x26,0xda,0xea,0x27,0x58,0x7e,0x8d,0xc9,0x09,0xdd,0x56,0xfd,0x04,0x68,0x80,0x5f,0x83,0x40,0x39,0xb3,0x45,0xf8,0x55,0xcf,0xe1,0x9c,0x44,0xb5,0x5a,0xf2,0x41,0xff,0xf3,0xff,0xcd,0x80,0x45,0xcd,0x5c,0x28,0x8e,0x6c,0x4e,0x28,0x4c,0x37,0x20,0x57,0x0b,0x58,0xe4,0xd4,0x7b,0x8f,0xee,0xed,0xc5,0x2f,0xd1,0x40,0x1f,0x69,0x8a,0x20,0x9f,0xcc,0xfa,0x3b,0x4c,0x0d,0x9a,0x79,0x7b,0x04,0x6a,0x27,0x59,0xf8,0x2a,0x54,0xc4,0x1c,0xcd,0x7b,0x5f,0x59,0x2b,};
/* Calculated HMAC-SHA-256*/
uint8_t hmac[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* MAC calculation */
status = Cy_Cryptolite_Hmac_Sha256_Init (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Start (CRYPTOLITE, HMAC_SHA256_Vector0_Key0, sizeof(HMAC_SHA256_Vector0_Key0), &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[0], 10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[10], sizeof(HMAC_SHA256_Vector0_Msg0)-10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Finish (CRYPTOLITE, hmac, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Free (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */
Note
There is no alignment or size restriction for message buffer, However providing a four byte aligned buffer with size in multiple of CY_CRYPTOLITE_SHA256_BLOCK_SIZE, will result in best execution time.

◆ Cy_Cryptolite_Hmac_Sha256_Finish()

cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Finish ( CRYPTOLITE_Type *  base,
uint8_t *  hmac,
cy_stc_cryptolite_context_hmac_sha256_t cfContext 
)

Completes the HMAC SHA256 calculation.

Parameters
baseThe pointer to the CRYPTOLITE instance.
hmacThe address pointer to the calculated Hmac.
cfContextThe pointer to the cy_stc_cryptolite_context_hmac_sha_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Key : */
const uint8_t HMAC_SHA256_Vector0_Key0[] = {0x6f,0x35,0x62,0x8d,0x65,0x81,0x34,0x35,0x53,0x4b,0x5d,0x67,0xfb,0xdb,0x54,0xcb,0x33,0x40,0x3d,0x04,0xe8,0x43,0x10,0x3e,0x63,0x99,0xf8,0x06,0xcb,0x5d,0xf9,0x5f,0xeb,0xbd,0xd6,0x12,0x36,0xf3,0x32,0x45};
/* Message : */
const uint8_t HMAC_SHA256_Vector0_Msg0[] = {0x75,0x2c,0xff,0x52,0xe4,0xb9,0x07,0x68,0x55,0x8e,0x53,0x69,0xe7,0x5d,0x97,0xc6,0x96,0x43,0x50,0x9a,0x5e,0x59,0x04,0xe0,0xa3,0x86,0xcb,0xe4,0xd0,0x97,0x0e,0xf7,0x3f,0x91,0x8f,0x67,0x59,0x45,0xa9,0xae,0xfe,0x26,0xda,0xea,0x27,0x58,0x7e,0x8d,0xc9,0x09,0xdd,0x56,0xfd,0x04,0x68,0x80,0x5f,0x83,0x40,0x39,0xb3,0x45,0xf8,0x55,0xcf,0xe1,0x9c,0x44,0xb5,0x5a,0xf2,0x41,0xff,0xf3,0xff,0xcd,0x80,0x45,0xcd,0x5c,0x28,0x8e,0x6c,0x4e,0x28,0x4c,0x37,0x20,0x57,0x0b,0x58,0xe4,0xd4,0x7b,0x8f,0xee,0xed,0xc5,0x2f,0xd1,0x40,0x1f,0x69,0x8a,0x20,0x9f,0xcc,0xfa,0x3b,0x4c,0x0d,0x9a,0x79,0x7b,0x04,0x6a,0x27,0x59,0xf8,0x2a,0x54,0xc4,0x1c,0xcd,0x7b,0x5f,0x59,0x2b,};
/* Calculated HMAC-SHA-256*/
uint8_t hmac[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* MAC calculation */
status = Cy_Cryptolite_Hmac_Sha256_Init (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Start (CRYPTOLITE, HMAC_SHA256_Vector0_Key0, sizeof(HMAC_SHA256_Vector0_Key0), &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[0], 10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[10], sizeof(HMAC_SHA256_Vector0_Msg0)-10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Finish (CRYPTOLITE, hmac, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Free (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */

◆ Cy_Cryptolite_Hmac_Sha256_Free()

cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Free ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_context_hmac_sha256_t cfContext 
)

Clears the used memory and context data.

Parameters
baseThe pointer to the CRYPTOLITE instance.
cfContextThe pointer to the cy_stc_cryptolite_context_hmac_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Key : */
const uint8_t HMAC_SHA256_Vector0_Key0[] = {0x6f,0x35,0x62,0x8d,0x65,0x81,0x34,0x35,0x53,0x4b,0x5d,0x67,0xfb,0xdb,0x54,0xcb,0x33,0x40,0x3d,0x04,0xe8,0x43,0x10,0x3e,0x63,0x99,0xf8,0x06,0xcb,0x5d,0xf9,0x5f,0xeb,0xbd,0xd6,0x12,0x36,0xf3,0x32,0x45};
/* Message : */
const uint8_t HMAC_SHA256_Vector0_Msg0[] = {0x75,0x2c,0xff,0x52,0xe4,0xb9,0x07,0x68,0x55,0x8e,0x53,0x69,0xe7,0x5d,0x97,0xc6,0x96,0x43,0x50,0x9a,0x5e,0x59,0x04,0xe0,0xa3,0x86,0xcb,0xe4,0xd0,0x97,0x0e,0xf7,0x3f,0x91,0x8f,0x67,0x59,0x45,0xa9,0xae,0xfe,0x26,0xda,0xea,0x27,0x58,0x7e,0x8d,0xc9,0x09,0xdd,0x56,0xfd,0x04,0x68,0x80,0x5f,0x83,0x40,0x39,0xb3,0x45,0xf8,0x55,0xcf,0xe1,0x9c,0x44,0xb5,0x5a,0xf2,0x41,0xff,0xf3,0xff,0xcd,0x80,0x45,0xcd,0x5c,0x28,0x8e,0x6c,0x4e,0x28,0x4c,0x37,0x20,0x57,0x0b,0x58,0xe4,0xd4,0x7b,0x8f,0xee,0xed,0xc5,0x2f,0xd1,0x40,0x1f,0x69,0x8a,0x20,0x9f,0xcc,0xfa,0x3b,0x4c,0x0d,0x9a,0x79,0x7b,0x04,0x6a,0x27,0x59,0xf8,0x2a,0x54,0xc4,0x1c,0xcd,0x7b,0x5f,0x59,0x2b,};
/* Calculated HMAC-SHA-256*/
uint8_t hmac[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* MAC calculation */
status = Cy_Cryptolite_Hmac_Sha256_Init (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Start (CRYPTOLITE, HMAC_SHA256_Vector0_Key0, sizeof(HMAC_SHA256_Vector0_Key0), &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[0], 10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Update (CRYPTOLITE, &HMAC_SHA256_Vector0_Msg0[10], sizeof(HMAC_SHA256_Vector0_Msg0)-10u, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Finish (CRYPTOLITE, hmac, &hmac_ctx);
/* ... check for errors... */
status = Cy_Cryptolite_Hmac_Sha256_Free (CRYPTOLITE, &hmac_ctx);
/* ... check for errors... */

◆ Cy_Cryptolite_Hmac_Sha256_Run()

cy_en_cryptolite_status_t Cy_Cryptolite_Hmac_Sha256_Run ( CRYPTOLITE_Type *  base,
uint8_t const *  key,
uint32_t  keyLength,
uint8_t const *  message,
uint32_t  messageSize,
uint8_t *  hmac,
cy_stc_cryptolite_context_hmac_sha256_t cfContext 
)

This function performs the HMAC SHA256 function.

Provide the required parameters and the pointer to the context structure when making this function call. It is independent of the previous Crypto state because it already contains preparation, calculation, and finalization steps.

Parameters
baseThe pointer to the CRYPTOLITE instance.
keyThe pointer to the HMAC key.
keyLengthThe length of the HMAC key.
messageThe address pointer to a message whose hash value is being computed.
messageSizeThe size of a message in bytes.
hmacThe address pointer to the hmac.
cfContextThe pointer to the cy_stc_cryptolite_context_hmac_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Key : */
const uint8_t HMAC_SHA256_Vector0_Key0[] = {0x6f,0x35,0x62,0x8d,0x65,0x81,0x34,0x35,0x53,0x4b,0x5d,0x67,0xfb,0xdb,0x54,0xcb,0x33,0x40,0x3d,0x04,0xe8,0x43,0x10,0x3e,0x63,0x99,0xf8,0x06,0xcb,0x5d,0xf9,0x5f,0xeb,0xbd,0xd6,0x12,0x36,0xf3,0x32,0x45};
/* Message : */
const uint8_t HMAC_SHA256_Vector0_Msg0[] = {0x75,0x2c,0xff,0x52,0xe4,0xb9,0x07,0x68,0x55,0x8e,0x53,0x69,0xe7,0x5d,0x97,0xc6,0x96,0x43,0x50,0x9a,0x5e,0x59,0x04,0xe0,0xa3,0x86,0xcb,0xe4,0xd0,0x97,0x0e,0xf7,0x3f,0x91,0x8f,0x67,0x59,0x45,0xa9,0xae,0xfe,0x26,0xda,0xea,0x27,0x58,0x7e,0x8d,0xc9,0x09,0xdd,0x56,0xfd,0x04,0x68,0x80,0x5f,0x83,0x40,0x39,0xb3,0x45,0xf8,0x55,0xcf,0xe1,0x9c,0x44,0xb5,0x5a,0xf2,0x41,0xff,0xf3,0xff,0xcd,0x80,0x45,0xcd,0x5c,0x28,0x8e,0x6c,0x4e,0x28,0x4c,0x37,0x20,0x57,0x0b,0x58,0xe4,0xd4,0x7b,0x8f,0xee,0xed,0xc5,0x2f,0xd1,0x40,0x1f,0x69,0x8a,0x20,0x9f,0xcc,0xfa,0x3b,0x4c,0x0d,0x9a,0x79,0x7b,0x04,0x6a,0x27,0x59,0xf8,0x2a,0x54,0xc4,0x1c,0xcd,0x7b,0x5f,0x59,0x2b,};
/* Calculated HMAC-SHA-256*/
uint8_t hmac[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* MAC calculation */
status = Cy_Cryptolite_Hmac_Sha256_Run(CRYPTOLITE,
HMAC_SHA256_Vector0_Key0,
sizeof(HMAC_SHA256_Vector0_Key0),
HMAC_SHA256_Vector0_Msg0,
sizeof(HMAC_SHA256_Vector0_Msg0),
hmac,
&hmac_ctx);
/* ... check for errors... */
Note
There is no alignment or size restriction for message buffer, However providing a four byte aligned buffer with size in multiple of CY_CRYPTOLITE_SHA256_BLOCK_SIZE, will result in best execution time.