CAT2 Peripheral Driver Library

Functions

cy_en_cryptolite_status_t Cy_Cryptolite_Sha_SetMode (cy_en_cryptolite_sha_mode_t mode, cy_stc_cryptolite_sha_context_t *shaContext)
 The function sets the SHA mode of operation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Init (CRYPTOLITE_Type *base, cy_stc_cryptolite_sha_context_t *shaContext)
 The function to initialize the SHA operation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Start (CRYPTOLITE_Type *base, cy_stc_cryptolite_sha_context_t *shaContext)
 Initializes the initial Hash vector. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Update (CRYPTOLITE_Type *base, uint8_t const *message, uint32_t messageSize, cy_stc_cryptolite_sha_context_t *shaContext)
 Performs the SHA calculation on one message based on the selected SHA mode. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Finish (CRYPTOLITE_Type *base, uint8_t *digest, cy_stc_cryptolite_sha_context_t *shaContext)
 Completes the SHA calculation. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Free (CRYPTOLITE_Type *base, cy_stc_cryptolite_sha_context_t *shaContext)
 Clears the used memory and context data. More...
 
cy_en_cryptolite_status_t Cy_Cryptolite_Sha (CRYPTOLITE_Type *base, uint8_t const *message, uint32_t messageSize, uint8_t *digest, cy_stc_cryptolite_sha_context_t *shaContext)
 This function performs the SHA256, SHA384 or SHA512 Hash function based on the SHA mode selected. More...
 

Detailed Description

Function Documentation

◆ Cy_Cryptolite_Sha_SetMode()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha_SetMode ( cy_en_cryptolite_sha_mode_t  mode,
cy_stc_cryptolite_sha_context_t shaContext 
)

The function sets the SHA mode of operation.

Note
This function is only applicable for CCG6xF_CFP devices, and this must be called before the Cy_Cryptolite_Sha_Init function call.
Parameters
modeSHA selection mode(SHA256, SHA384, SHA512).
shaContextThe pointer to the cy_stc_cryptolite_sha_context_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_DIGEST_SIZE] = {0};
cryptoStatus = Cy_Cryptolite_Sha_SetMode(
CY_CRYPTOLITE_SHA_MODE_SHA256, /* Cryptolite SHA Mode */
&context); /* Pointer to SHA context structure */
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Init (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Start (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Update (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size (in bytes) */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Finish (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256Digest, /* Pointer to digest buffer */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Free (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}

◆ Cy_Cryptolite_Sha_Init()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Init ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_sha_context_t shaContext 
)

The function to initialize the SHA operation.

Parameters
baseThe pointer to the Cryptolite instance.
shaContextThe pointer to the cy_stc_cryptolite_sha_context_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_DIGEST_SIZE] = {0};
cryptoStatus = Cy_Cryptolite_Sha_SetMode(
CY_CRYPTOLITE_SHA_MODE_SHA256, /* Cryptolite SHA Mode */
&context); /* Pointer to SHA context structure */
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Init (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Start (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Update (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size (in bytes) */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Finish (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256Digest, /* Pointer to digest buffer */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Free (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}

◆ Cy_Cryptolite_Sha_Start()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Start ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_sha_context_t shaContext 
)

Initializes the initial Hash vector.

Parameters
baseThe pointer to the CRYPTOLITE instance.
shaContextThe pointer to the cy_stc_cryptolite_sha_context_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_DIGEST_SIZE] = {0};
cryptoStatus = Cy_Cryptolite_Sha_SetMode(
CY_CRYPTOLITE_SHA_MODE_SHA256, /* Cryptolite SHA Mode */
&context); /* Pointer to SHA context structure */
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Init (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Start (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Update (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size (in bytes) */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Finish (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256Digest, /* Pointer to digest buffer */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Free (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}

◆ Cy_Cryptolite_Sha_Update()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Update ( CRYPTOLITE_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
cy_stc_cryptolite_sha_context_t shaContext 
)

Performs the SHA calculation on one message based on the selected SHA mode.

Parameters
baseThe pointer to the CRYPTOLITE instance.
messageThe pointer to the message whose Hash is being computed.
messageSizeThe size of the message whose Hash is being computed.
shaContextThe pointer to the cy_stc_cryptolite_sha_context_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
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_SHA_MAX_BLOCK_SIZE, will result in best execution time.
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_DIGEST_SIZE] = {0};
cryptoStatus = Cy_Cryptolite_Sha_SetMode(
CY_CRYPTOLITE_SHA_MODE_SHA256, /* Cryptolite SHA Mode */
&context); /* Pointer to SHA context structure */
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Init (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Start (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Update (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size (in bytes) */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Finish (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256Digest, /* Pointer to digest buffer */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Free (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}

◆ Cy_Cryptolite_Sha_Finish()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Finish ( CRYPTOLITE_Type *  base,
uint8_t *  digest,
cy_stc_cryptolite_sha_context_t shaContext 
)

Completes the SHA calculation.

Parameters
baseThe pointer to the CRYPTOLITE instance.
digestThe pointer to the calculated Hash digest.
shaContextThe pointer to the cy_stc_cryptolite_sha_context_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_DIGEST_SIZE] = {0};
cryptoStatus = Cy_Cryptolite_Sha_SetMode(
CY_CRYPTOLITE_SHA_MODE_SHA256, /* Cryptolite SHA Mode */
&context); /* Pointer to SHA context structure */
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Init (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Start (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Update (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size (in bytes) */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Finish (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256Digest, /* Pointer to digest buffer */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Free (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}

◆ Cy_Cryptolite_Sha_Free()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha_Free ( CRYPTOLITE_Type *  base,
cy_stc_cryptolite_sha_context_t shaContext 
)

Clears the used memory and context data.

Parameters
baseThe pointer to the CRYPTOLITE instance.
shaContextThe pointer to the cy_stc_cryptolite_sha_context_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_DIGEST_SIZE] = {0};
cryptoStatus = Cy_Cryptolite_Sha_SetMode(
CY_CRYPTOLITE_SHA_MODE_SHA256, /* Cryptolite SHA Mode */
&context); /* Pointer to SHA context structure */
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Init (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Start (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Update (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size (in bytes) */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Finish (
CRYPTOLITE, /* Base address of the Crypto block registers */
sha256Digest, /* Pointer to digest buffer */
&context); /* Pointer to SHA context structure */
}
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
cryptoStatus = Cy_Cryptolite_Sha_Free (
CRYPTOLITE, /* Base address of the Crypto block registers */
&context); /* Pointer to SHA context structure */
}

◆ Cy_Cryptolite_Sha()

cy_en_cryptolite_status_t Cy_Cryptolite_Sha ( CRYPTOLITE_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
uint8_t *  digest,
cy_stc_cryptolite_sha_context_t shaContext 
)

This function performs the SHA256, SHA384 or SHA512 Hash function based on the SHA mode selected.

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 pointer to a message whose hash value is being computed.
messageSizeThe size of a message in bytes.
digestThe pointer to the hash digest.
shaContextThe pointer to the cy_stc_cryptolite_sha_context_t structure that stores all internal variables for Cryptolite driver.
Returns
cy_en_cryptolite_status_t
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_SHA_MAX_BLOCK_SIZE, will result in best execution time.
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTOLITE_SHA256_DIGEST_SIZE] = {0};
cryptoStatus = Cy_Cryptolite_Sha_SetMode(
CY_CRYPTOLITE_SHA_MODE_SHA256, /* Cryptolite SHA Mode */
&context); /* Pointer to SHA context structure */
if (CY_CRYPTOLITE_SUCCESS == cryptoStatus)
{
/* Hash the message by using the Cryptolite SHA operation with SHA-256 mode */
cryptoStatus = Cy_Cryptolite_Sha(
CRYPTOLITE, /* Base address of the Crypto block registers */
(const uint8_t *)sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size (in bytes) */
sha256Digest, /* Pointer to digest buffer */
&context); /* Pointer to SHA context structure */
}
/* ... check for errors... */