26#ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32672_CTB_H_
27#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32672_CTB_H_
56 MXC_CTB_FEATURE_DMA = 1 << 0,
57 MXC_CTB_FEATURE_ECC = 1 << 1,
58 MXC_CTB_FEATURE_CRC = 1 << 2,
59 MXC_CTB_FEATURE_HASH = 1 << 4,
60 MXC_CTB_FEATURE_CIPHER = 1 << 5,
61 MXC_CTB_FEATURE_TRNG = 1 << 6
72struct _mxc_ctb_dma_req_t {
106struct _mxc_ctb_ecc_req_t {
117struct _mxc_ctb_crc_req_t {
138struct _mxc_ctb_hash_req_t {
163 MXC_CTB_HASH_SOURCE_INFIFO = 0,
164 MXC_CTB_HASH_SOURCE_OUTFIFO = 1
175struct _mxc_ctb_cipher_req_t {
213 MXC_CTB_CIPHER_KEY_SOFTWARE = 0,
214 MXC_CTB_CIPHER_KEY_AES_KEY2 = 2,
215 MXC_CTB_CIPHER_KEY_AES_KEY3 = 3
Registers, Bit Masks and Bit Positions for the CTB Peripheral Module.
#define MXC_V_CTB_CIPHER_CTRL_MODE_OFB
Definition: ctb_regs.h:275
#define MXC_V_CTB_CIPHER_CTRL_MODE_CFB
Definition: ctb_regs.h:273
#define MXC_V_CTB_CIPHER_CTRL_CIPHER_TDES
Definition: ctb_regs.h:264
#define MXC_V_CTB_CIPHER_CTRL_CIPHER_AES128
Definition: ctb_regs.h:256
#define MXC_V_CTB_CIPHER_CTRL_MODE_ECB
Definition: ctb_regs.h:269
#define MXC_V_CTB_CIPHER_CTRL_CIPHER_AES256
Definition: ctb_regs.h:260
#define MXC_V_CTB_CIPHER_CTRL_MODE_CTR
Definition: ctb_regs.h:277
#define MXC_V_CTB_CIPHER_CTRL_MODE_CBC
Definition: ctb_regs.h:271
#define MXC_V_CTB_CIPHER_CTRL_CIPHER_DES
Definition: ctb_regs.h:262
#define MXC_V_CTB_CIPHER_CTRL_CIPHER_AES192
Definition: ctb_regs.h:258
#define MXC_V_CTB_CIPHER_CTRL_CIPHER_DIS
Definition: ctb_regs.h:254
#define MXC_V_CTB_CTRL_WRSRC_CIPHEROUTPUT
Definition: ctb_regs.h:188
#define MXC_V_CTB_CTRL_WRSRC_READFIFO
Definition: ctb_regs.h:190
#define MXC_V_CTB_CTRL_RDSRC_DMAORAPB
Definition: ctb_regs.h:197
#define MXC_V_CTB_CTRL_RDSRC_RNG
Definition: ctb_regs.h:199
#define MXC_V_CTB_CTRL_WRSRC_NONE
Definition: ctb_regs.h:186
#define MXC_V_CTB_HASH_CTRL_HASH_SHA224
Definition: ctb_regs.h:312
#define MXC_V_CTB_HASH_CTRL_HASH_SHA512
Definition: ctb_regs.h:318
#define MXC_V_CTB_HASH_CTRL_HASH_SHA256
Definition: ctb_regs.h:314
#define MXC_V_CTB_HASH_CTRL_HASH_DIS
Definition: ctb_regs.h:308
#define MXC_V_CTB_HASH_CTRL_HASH_SHA384
Definition: ctb_regs.h:316
#define MXC_V_CTB_HASH_CTRL_HASH_SHA1
Definition: ctb_regs.h:310
mxc_ctb_complete_cb_t callback
Null callback indicates a blocking operation.
Definition: ctb.h:76
uint8_t * sourceBuffer
pointer to source data
Definition: ctb.h:73
uint8_t * destBuffer
pointer to destination buffer
Definition: ctb.h:74
uint32_t length
length of source data
Definition: ctb.h:75
void MXC_CTB_ECC_Enable(void)
Enable ECC Calculation.
void MXC_CTB_DMA_SetReadSource(mxc_ctb_dma_read_source_t source)
Set the source the DMA reads from.
void MXC_CTB_CRC_ComputeAsync(mxc_ctb_crc_req_t *req)
Perform a CRC computation asynchronously.
uint32_t MXC_CTB_CheckFeatures(void)
Detects what CTB features exist, see mxc_ctb_features_t.
mxc_ctb_cipher_t MXC_CTB_Cipher_GetCipher(void)
Get the cipher type used for cipher operations.
unsigned int MXC_CTB_Cipher_GetBlockSize(mxc_ctb_cipher_t cipher)
Get the block size for a given cipher type.
void MXC_CTB_ECC_Disable(void)
Disable ECC Calculation.
mxc_ctb_hash_func_t MXC_CTB_Hash_GetFunction(void)
Get the algorithm to use for hash computation.
mxc_ctb_crc_bitorder_t MXC_CTB_CRC_GetDirection(void)
Set the bit-order of CRC calculation.
mxc_ctb_dma_write_source_t
Enumeration type to select write source channel of DMA.
Definition: ctb.h:92
mxc_ctb_cipher_key_t MXC_CTB_Cipher_GetKeySource(void)
Get the cipher type used for cipher operations.
void MXC_CTB_DMA_SetDestination(uint8_t *dest)
Set the destination address of the DMA.
int MXC_CTB_Init(uint32_t features)
Enable portions of the CTB.
int MXC_CTB_CRC_Compute(mxc_ctb_crc_req_t *req)
Perform a CRC computation.
void MXC_CTB_Hash_SetSource(mxc_ctb_hash_source_t source)
Set the source of data for the hash computation.
int MXC_CTB_Cipher_Decrypt(mxc_ctb_cipher_req_t *req)
Perform a decryption using the cipher feature.
mxc_ctb_features_t
Enumeration type for Crypto Toolbox features.
Definition: ctb.h:55
uint32_t MXC_CTB_ECC_GetResult(void)
Get the Result of an ECC Calculation.
void MXC_CTB_CRC_SetDirection(mxc_ctb_crc_bitorder_t bitOrder)
Set the bit-order of CRC calculation.
void MXC_CTB_Hash_SetAutoPad(int pad)
Set whether to use automatic padding of the input data.
void MXC_CTB_CRC_SetPoly(uint32_t poly)
Set the Polynomial for CRC calculation.
void MXC_CTB_Hash_InitializeHash(void)
Initialize the hash computation unit.
mxc_ctb_cipher_mode_t MXC_CTB_Cipher_GetMode(void)
Get the block mode used for cipher operations.
int MXC_CTB_ECC_Compute(mxc_ctb_ecc_req_t *req)
Compute the ECC value for a block of data up to 8kB in size.
void MXC_CTB_Cipher_SetOperation(mxc_ctb_cipher_operation_t operation)
Configure for encryption or decryption.
void MXC_CTB_Hash_SetMessageSize(uint32_t size)
Set the size of the data input into the hash computation.
void MXC_CTB_CRC_SetFinalXORValue(uint32_t xor)
Set the value that will be bitwise XORed with the final output from the CRC computation....
void MXC_CTB_Hash_GetResult(uint8_t *digest, int *len)
Get the result of a hash computation.
mxc_ctb_cipher_t
Enumeration type to select Cipher function.
Definition: ctb.h:199
int MXC_CTB_Ready(void)
Checks the global CTB Ready Status.
uint32_t MXC_CTB_CRC_GetPoly(void)
Get the polynomial for CRC calculation.
int MXC_CTB_Cipher_Encrypt(mxc_ctb_cipher_req_t *req)
Perform an encryption using the cipher feature.
void MXC_CTB_DMA_SetSource(uint8_t *source)
Set the source address of the DMA.
uint32_t MXC_CTB_GetEnabledFeatures(void)
Check which CTB features are enabled.
void MXC_CTB_Cipher_SetMode(mxc_ctb_cipher_mode_t mode)
Set the block mode used for cipher operations.
unsigned int MXC_CTB_Cipher_GetKeySize(mxc_ctb_cipher_t cipher)
Get the key size for a given cipher type.
void MXC_CTB_Hash_ComputeAsync(mxc_ctb_hash_req_t *req)
Compute a Hash Digest.
int MXC_CTB_ECC_ErrorCheck(mxc_ctb_ecc_req_t *req)
Check for single or dual bit errors in a block of data.
void MXC_CTB_Cipher_SetCipher(mxc_ctb_cipher_t cipher)
Set the cipher type used for cipher operations.
int MXC_CTB_DMA_SetupOperation(mxc_ctb_dma_req_t *req)
Set the source and destination addresses of the DMA.
mxc_ctb_hash_source_t MXC_CTB_Hash_GetSource(void)
Get the source of data for the hash computation.
void MXC_CTB_DMA_SetWriteSource(mxc_ctb_dma_write_source_t source)
Set the source the DMA write fifo reads from.
int MXC_CTB_TRNG_Random(uint8_t *data, uint32_t len)
Get a random number of length len.
void MXC_CTB_Cipher_GetIV(uint8_t *ivOut, uint32_t len)
Get the initial value used for cipher operations.
void MXC_CTB_Cipher_SetKeySource(mxc_ctb_cipher_key_t source)
Set the source of the key used in cipher operations.
mxc_ctb_cipher_operation_t
Cipher operation.
Definition: ctb.h:222
void MXC_CTB_Handler(void)
This function should be called from the CTB ISR Handler when using Async functions.
mxc_ctb_cipher_mode_t
Enumeration type to select Cipher mode.
Definition: ctb.h:187
mxc_ctb_dma_read_source_t
Enumeration type to select read source channel of DMA.
Definition: ctb.h:83
void MXC_CTB_Cipher_SetKey(uint8_t *key, uint32_t len)
Set the cipher key.
int MXC_CTB_DMA_DoOperation(mxc_ctb_dma_req_t *req)
Start a DMA transfer defined by the request object Blocks until completion.
uint32_t MXC_CTB_Done(void)
Returns CTB features showing operations complete, see mxc_ctb_features_t.
void MXC_CTB_Cipher_SetIV(uint8_t *iv, uint32_t len)
Set the initial value used for cipher operations.
mxc_ctb_hash_source_t
Enumeration type to select FIFO source for Hash.
Definition: ctb.h:162
void MXC_CTB_DMA_StartTransfer(uint32_t length)
Start a DMA transfer of fixed size.
int MXC_CTB_Hash_Compute(mxc_ctb_hash_req_t *req)
Compute a Hash Digest.
void MXC_CTB_CRC_SetInitialValue(uint32_t seed)
Set the intial value used (the seed) when starting a CRC computation.
void MXC_CTB_ECC_ErrorCheckAsync(mxc_ctb_ecc_req_t *req)
Check for single or dual bit errors in a block of data.
void MXC_CTB_DoneClear(uint32_t features)
Clears the selected feature's done bits, see mxc_ctb_features_t.
int MXC_CTB_Hash_GetAutoPad(void)
Get whether to use automatic padding of the input data.
mxc_ctb_cipher_key_t
Enumeration type to select Cipher key.
Definition: ctb.h:212
mxc_ctb_dma_write_source_t MXC_CTB_DMA_GetWriteSource(void)
Set the source the DMA write fifo reads from.
void MXC_CTB_DisableInt(void)
Disable CTB Interrupts.
mxc_ctb_crc_bitorder_t
CRC data bit order.
Definition: ctb.h:128
uint32_t MXC_CTB_CRC_GetResult(void)
Get the result of a CRC calculation.
void MXC_CTB_CacheInvalidate(void)
Invalidates the CTB's internal cache.
unsigned int MXC_CTB_Hash_GetDigestSize(mxc_ctb_hash_func_t function)
Get the digest size for a given hash function.
void(* mxc_ctb_complete_cb_t)(void *req, int result)
Callback funtion for ctb.
Definition: ctb.h:49
void MXC_CTB_EnableInt(void)
Enable CTB Interrupts.
mxc_ctb_dma_read_source_t MXC_CTB_DMA_GetReadSource(void)
Get the source the DMA reads from.
void MXC_CTB_Cipher_LoadKey(void)
Load the cipher key from the selected source.
int MXC_CTB_Shutdown(uint32_t features)
Disable and reset portions of the CTB.
void MXC_CTB_Cipher_EncryptAsync(mxc_ctb_cipher_req_t *req)
Perform an encryption using the cipher feature.
int MXC_CTB_TRNG_RandomInt(void)
Get a random number.
void MXC_CTB_TRNG_RandomAsync(uint8_t *data, uint32_t len, mxc_ctb_complete_cb_t callback)
Get a random number of length len, do not block while generating data.
void MXC_CTB_Reset(uint32_t features)
Resets the selected features, see mxc_ctb_features_t.
unsigned int MXC_CTB_Hash_GetBlockSize(mxc_ctb_hash_func_t function)
Get the block size for a given hash function.
void MXC_CTB_Hash_SetFunction(mxc_ctb_hash_func_t function)
Set the algorithm to use for hash computation.
void MXC_CTB_ECC_ComputeAsync(mxc_ctb_ecc_req_t *req)
Compute the ECC value for a block of data up to 8kB in size.
void MXC_CTB_Cipher_DecryptAsync(mxc_ctb_cipher_req_t *req)
Perform a decryption using the cipher feature.
mxc_ctb_hash_func_t
Enumeration type to select Hash function.
Definition: ctb.h:149
@ MXC_CTB_CIPHER_DIS
Disable.
Definition: ctb.h:200
@ MXC_CTB_CIPHER_AES128
Select AES-128.
Definition: ctb.h:201
@ MXC_CTB_CIPHER_AES256
Select AES-256.
Definition: ctb.h:203
@ MXC_CTB_CIPHER_AES192
Select AES-192.
Definition: ctb.h:202
@ MXC_CTB_CIPHER_DES
Select DES.
Definition: ctb.h:204
@ MXC_CTB_CIPHER_TDES
Select TDES.
Definition: ctb.h:205
@ MXC_CTB_MODE_ECB
Electronic Code Book.
Definition: ctb.h:188
@ MXC_CTB_MODE_CTR
Counter.
Definition: ctb.h:191
@ MXC_CTB_MODE_CBC
Cipher Block Chaining.
Definition: ctb.h:189
@ MXC_CTB_MODE_OFB
Output Feedback.
Definition: ctb.h:192
@ MXC_CTB_MODE_CFB
Cipher Feedback.
Definition: ctb.h:190
Structure used to set up Cipher request.
Definition: ctb.h:175
Structure used to set up CRC request.
Definition: ctb.h:117
Structure for using DMA with CTB.
Definition: ctb.h:72
Structure used to set up ECC request.
Definition: ctb.h:106
Structure used to set up Hash request.
Definition: ctb.h:138