MTB CAT1 Peripheral driver library

General Description

Functions

cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Init (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_sha256_t *cfContext)
 The function to initialize the SHA256 operation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Start (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_sha256_t *cfContext)
 Initializes the initial Hash vector. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Update (CRYPTOLITE_Type *base, uint8_t const *message, uint32_t messageSize, cy_stc_cryptolite_context_sha256_t *cfContext)
 Performs the SHA256 calculation on one message. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Finish (CRYPTOLITE_Type *base, uint8_t *digest, cy_stc_cryptolite_context_sha256_t *cfContext)
 Completes the SHA256 calculation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Free (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_sha256_t *cfContext)
 Clears the used memory and context data. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Run (CRYPTOLITE_Type *base, uint8_t const *message, uint32_t messageSize, uint8_t *digest, cy_stc_cryptolite_context_sha256_t *cfContext)
 This function performs the SHA256 Hash function. More...
 

Function Documentation

◆ Cy_Cryptolite_Sha256_Init()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Init ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_context_sha256_t cfContext 
)

The function to initialize the SHA256 operation.

Parameters
baseThe pointer to the Cryptolite instance.
cfContextThe pointer to the cy_stc_cryptolite_context_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Message is: */
uint8_t msg0[] = {
0x5a,0x86,0xb7,0x37,0xea,0xea,0x8e,0xe9,0x76,0xa0,0xa2,0x4d,0xa6,0x3e,0x7e,
0xd7,0xee,0xfa,0xd1,0x8a,0x10,0x1c,0x12,0x11,0xe2,0xb3,0x65,0x0c,0x51,0x87,
0xc2,0xa8,0xa6,0x50,0x54,0x72,0x08,0x25,0x1f,0x6d,0x42,0x37,0xe6,0x61,0xc7,
0xbf,0x4c,0x77,0xf3,0x35,0x39,0x03,0x94,0xc3,0x7f,0xa1,0xa9,0xf9,0xbe,0x83,
0x6a,0xc2,0x85,0x09,0x47,0x99,0x13,0x01,0x15,0x6d,0x1d,0x97,0x7c,0x03,0x38,
0xef,0xbc,0xad,0x41,0x00,0x41,0x33,0xae,0xfb,0xca,0x6b,0xcf,0x7e};
/* Calculated SHA-256 digest */
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* Hash the message by SHA256 */
status = Cy_Cryptolite_Sha256_Init(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Start( CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update( CRYPTOLITE, &msg0[0], 64, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update(CRYPTOLITE, &msg0[64], 24, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Finish(CRYPTOLITE, sha256Digest, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Free(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */

◆ Cy_Cryptolite_Sha256_Start()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Start ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_context_sha256_t cfContext 
)

Initializes the initial Hash vector.

Parameters
baseThe pointer to the CRYPTOLITE instance.
cfContextThe pointer to the cy_stc_cryptolite_context_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Message is: */
uint8_t msg0[] = {
0x5a,0x86,0xb7,0x37,0xea,0xea,0x8e,0xe9,0x76,0xa0,0xa2,0x4d,0xa6,0x3e,0x7e,
0xd7,0xee,0xfa,0xd1,0x8a,0x10,0x1c,0x12,0x11,0xe2,0xb3,0x65,0x0c,0x51,0x87,
0xc2,0xa8,0xa6,0x50,0x54,0x72,0x08,0x25,0x1f,0x6d,0x42,0x37,0xe6,0x61,0xc7,
0xbf,0x4c,0x77,0xf3,0x35,0x39,0x03,0x94,0xc3,0x7f,0xa1,0xa9,0xf9,0xbe,0x83,
0x6a,0xc2,0x85,0x09,0x47,0x99,0x13,0x01,0x15,0x6d,0x1d,0x97,0x7c,0x03,0x38,
0xef,0xbc,0xad,0x41,0x00,0x41,0x33,0xae,0xfb,0xca,0x6b,0xcf,0x7e};
/* Calculated SHA-256 digest */
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* Hash the message by SHA256 */
status = Cy_Cryptolite_Sha256_Init(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Start( CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update( CRYPTOLITE, &msg0[0], 64, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update(CRYPTOLITE, &msg0[64], 24, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Finish(CRYPTOLITE, sha256Digest, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Free(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */

◆ Cy_Cryptolite_Sha256_Update()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Update ( CRYPTOLITE_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
cy_stc_cryptolite_context_sha256_t cfContext 
)

Performs the SHA256 calculation on one 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_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Message is: */
uint8_t msg0[] = {
0x5a,0x86,0xb7,0x37,0xea,0xea,0x8e,0xe9,0x76,0xa0,0xa2,0x4d,0xa6,0x3e,0x7e,
0xd7,0xee,0xfa,0xd1,0x8a,0x10,0x1c,0x12,0x11,0xe2,0xb3,0x65,0x0c,0x51,0x87,
0xc2,0xa8,0xa6,0x50,0x54,0x72,0x08,0x25,0x1f,0x6d,0x42,0x37,0xe6,0x61,0xc7,
0xbf,0x4c,0x77,0xf3,0x35,0x39,0x03,0x94,0xc3,0x7f,0xa1,0xa9,0xf9,0xbe,0x83,
0x6a,0xc2,0x85,0x09,0x47,0x99,0x13,0x01,0x15,0x6d,0x1d,0x97,0x7c,0x03,0x38,
0xef,0xbc,0xad,0x41,0x00,0x41,0x33,0xae,0xfb,0xca,0x6b,0xcf,0x7e};
/* Calculated SHA-256 digest */
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* Hash the message by SHA256 */
status = Cy_Cryptolite_Sha256_Init(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Start( CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update( CRYPTOLITE, &msg0[0], 64, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update(CRYPTOLITE, &msg0[64], 24, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Finish(CRYPTOLITE, sha256Digest, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Free(CRYPTOLITE, &crp_cxt);
/* ... 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_Sha256_Finish()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Finish ( CRYPTOLITE_Type *  base,
uint8_t *  digest,
cy_stc_cryptolite_context_sha256_t cfContext 
)

Completes the SHA256 calculation.

Parameters
baseThe pointer to the CRYPTOLITE instance.
digestThe address pointer to the calculated Hash digest.
cfContextThe pointer to the cy_stc_cryptolite_context_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Message is: */
uint8_t msg0[] = {
0x5a,0x86,0xb7,0x37,0xea,0xea,0x8e,0xe9,0x76,0xa0,0xa2,0x4d,0xa6,0x3e,0x7e,
0xd7,0xee,0xfa,0xd1,0x8a,0x10,0x1c,0x12,0x11,0xe2,0xb3,0x65,0x0c,0x51,0x87,
0xc2,0xa8,0xa6,0x50,0x54,0x72,0x08,0x25,0x1f,0x6d,0x42,0x37,0xe6,0x61,0xc7,
0xbf,0x4c,0x77,0xf3,0x35,0x39,0x03,0x94,0xc3,0x7f,0xa1,0xa9,0xf9,0xbe,0x83,
0x6a,0xc2,0x85,0x09,0x47,0x99,0x13,0x01,0x15,0x6d,0x1d,0x97,0x7c,0x03,0x38,
0xef,0xbc,0xad,0x41,0x00,0x41,0x33,0xae,0xfb,0xca,0x6b,0xcf,0x7e};
/* Calculated SHA-256 digest */
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* Hash the message by SHA256 */
status = Cy_Cryptolite_Sha256_Init(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Start( CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update( CRYPTOLITE, &msg0[0], 64, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update(CRYPTOLITE, &msg0[64], 24, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Finish(CRYPTOLITE, sha256Digest, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Free(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */

◆ Cy_Cryptolite_Sha256_Free()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Free ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_context_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_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Message is: */
uint8_t msg0[] = {
0x5a,0x86,0xb7,0x37,0xea,0xea,0x8e,0xe9,0x76,0xa0,0xa2,0x4d,0xa6,0x3e,0x7e,
0xd7,0xee,0xfa,0xd1,0x8a,0x10,0x1c,0x12,0x11,0xe2,0xb3,0x65,0x0c,0x51,0x87,
0xc2,0xa8,0xa6,0x50,0x54,0x72,0x08,0x25,0x1f,0x6d,0x42,0x37,0xe6,0x61,0xc7,
0xbf,0x4c,0x77,0xf3,0x35,0x39,0x03,0x94,0xc3,0x7f,0xa1,0xa9,0xf9,0xbe,0x83,
0x6a,0xc2,0x85,0x09,0x47,0x99,0x13,0x01,0x15,0x6d,0x1d,0x97,0x7c,0x03,0x38,
0xef,0xbc,0xad,0x41,0x00,0x41,0x33,0xae,0xfb,0xca,0x6b,0xcf,0x7e};
/* Calculated SHA-256 digest */
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* Hash the message by SHA256 */
status = Cy_Cryptolite_Sha256_Init(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Start( CRYPTOLITE, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update( CRYPTOLITE, &msg0[0], 64, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Update(CRYPTOLITE, &msg0[64], 24, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Finish(CRYPTOLITE, sha256Digest, &crp_cxt);
/* ... check for errors... */
status = Cy_Cryptolite_Sha256_Free(CRYPTOLITE, &crp_cxt);
/* ... check for errors... */

◆ Cy_Cryptolite_Sha256_Run()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha256_Run ( CRYPTOLITE_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
uint8_t *  digest,
cy_stc_cryptolite_context_sha256_t cfContext 
)

This function performs the SHA256 Hash 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.
messageThe address pointer to a message whose hash value is being computed.
messageSizeThe size of a message in bytes.
digestThe address pointer to the hash digest.
cfContextThe pointer to the cy_stc_cryptolite_context_sha256_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
/* Message is: "abc" */
uint8_t msg0[] = {"abc"};
/* Calculated SHA-256 digest */
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_HASH_SIZE] = {0};
/* Hash the message by SHA256 */
status = Cy_Cryptolite_Sha256_Run(CRYPTOLITE, msg0, sizeof(msg0)-1u, sha256Digest, &crp_cxt);
/* ... 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.