MTB CAT1 Peripheral driver library

General Description

Functions

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha (CRYPTO_Type *base, uint8_t const *message, uint32_t messageSize, uint8_t *digest, cy_en_crypto_sha_mode_t mode)
 Performs the SHA Hash function. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Init (CRYPTO_Type *base, cy_stc_crypto_sha_state_t *shaHashState, cy_en_crypto_sha_mode_t mode, void *shaBuffers)
 The function to initialize the SHA operation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Start (CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState)
 Initializes the initial Hash vector. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Update (CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState, uint8_t const *message, uint32_t messageSize)
 Performs the SHA calculation on one message. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Finish (CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState, uint8_t *digest)
 Completes the SHA calculation. More...
 
__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Free (CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState)
 Clears the used memory buffers. More...
 

Function Documentation

◆ Cy_Crypto_Core_Sha()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha ( CRYPTO_Type *  base,
uint8_t const *  message,
uint32_t  messageSize,
uint8_t *  digest,
cy_en_crypto_sha_mode_t  mode 
)

Performs the SHA Hash function.

Parameters
baseThe pointer to the CRYPTO instance.
modecy_en_crypto_sha_mode_t
messageThe pointer to the message whose hash value is being computed.
messageSizeThe size of the message.
digestThe pointer to the hash digest.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t sha256PlainText[3] = "abc";
uint8_t sha256Digest[CY_CRYPTO_SHA256_DIGEST_SIZE] = {0};
cy_en_crypto_status_t cryptoStatus;
/* Hash the message by SHA256 */
cryptoStatus = Cy_Crypto_Core_Sha(
CRYPTO_HW, /* Pointer to Crypto instance */
sha256PlainText, /* Pointer to message */
sizeof(sha256PlainText), /* Message size */
sha256Digest, /* Pointer to digest buffer */
CY_CRYPTO_MODE_SHA256); /* Hash mode */
/* ... check for errors... */

◆ Cy_Crypto_Core_Sha_Init()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Init ( CRYPTO_Type *  base,
cy_stc_crypto_sha_state_t shaHashState,
cy_en_crypto_sha_mode_t  mode,
void *  shaBuffers 
)

The function to initialize the SHA operation.

Parameters
baseThe pointer to the CRYPTO instance.
shaHashStateThe pointer to a Hash state.
modeOne of these: cy_en_crypto_sha_mode_t
shaBuffersThe pointer to the memory buffers storage. Can be one of two buffers types according to selected hardware platform: cy_stc_crypto_v1_sha_buffers_t or cy_stc_crypto_v2_sha_buffers_t
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Sha_Start()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Start ( CRYPTO_Type *  base,
cy_stc_crypto_sha_state_t hashState 
)

Initializes the initial Hash vector.

Parameters
baseThe pointer to the CRYPTO instance.
hashStateThe pointer to the SHA context.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Sha_Update()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Update ( CRYPTO_Type *  base,
cy_stc_crypto_sha_state_t hashState,
uint8_t const *  message,
uint32_t  messageSize 
)

Performs the SHA calculation on one message.

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.
hashStateThe pointer to the SHA context.
messageThe pointer to the message whose Hash is being computed.
messageSizeThe size of the message whose Hash is being computed.
Returns
cy_en_crypto_status_t
Note
This function can be called several times only with message lengths dividable by the block size. Only the last call to the function can process a message with a not-dividable size.

◆ Cy_Crypto_Core_Sha_Finish()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Finish ( CRYPTO_Type *  base,
cy_stc_crypto_sha_state_t hashState,
uint8_t *  digest 
)

Completes the SHA calculation.

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

Parameters
baseThe pointer to the CRYPTO instance.
hashStateThe pointer to the SHA context.
digestThe pointer to the calculated Hash digest.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Sha_Free()

__STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Free ( CRYPTO_Type *  base,
cy_stc_crypto_sha_state_t hashState 
)

Clears the used memory buffers.

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

Parameters
baseThe pointer to the CRYPTO instance.
hashStateThe pointer to the SHA context.
Returns
cy_en_crypto_status_t