Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
35 #include "fsl_device_registers.h"
43 #if (MCXE247_CRYPTO_CIPHER_SUPPORT == ENABLED && AES_SUPPORT == ENABLED)
55 while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0)
60 FTFC->FSTAT = FTFC_FSTAT_FPVIOL_MASK | FTFC_FSTAT_ACCERR_MASK;
63 ELA_CSEC->DATA_32[4] =
htobe32(key[0]);
64 ELA_CSEC->DATA_32[5] =
htobe32(key[1]);
65 ELA_CSEC->DATA_32[6] =
htobe32(key[2]);
66 ELA_CSEC->DATA_32[7] =
htobe32(key[3]);
73 while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0)
78 return ELA_CSEC->DATA_32[1] >> 16;
92 uint32_t
aesProcessData(uint32_t command,
size_t offset,
const uint8_t *input,
93 uint8_t *output,
size_t length)
103 ELA_CSEC->DATA_32[i] =
LOAD32BE(input);
104 ELA_CSEC->DATA_32[i + 1] =
LOAD32BE(input + 4);
105 ELA_CSEC->DATA_32[i + 2] =
LOAD32BE(input + 8);
106 ELA_CSEC->DATA_32[i + 3] =
LOAD32BE(input + 12);
116 while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0)
121 status = ELA_CSEC->DATA_32[1] >> 16;
129 temp = ELA_CSEC->DATA_32[i];
131 temp = ELA_CSEC->DATA_32[i + 1];
133 temp = ELA_CSEC->DATA_32[i + 2];
135 temp = ELA_CSEC->DATA_32[i + 3];
148 #if (ECB_SUPPORT == ENABLED)
161 const uint8_t *
p, uint8_t *
c,
size_t length)
185 if(aesContext->
nr == 10)
263 const uint8_t *
c, uint8_t *
p,
size_t length)
287 if(aesContext->
nr == 10)
354 #if (CBC_SUPPORT == ENABLED)
368 uint8_t *
iv,
const uint8_t *
p, uint8_t *
c,
size_t length)
392 if(aesContext->
nr == 10)
520 uint8_t *
iv,
const uint8_t *
c, uint8_t *
p,
size_t length)
545 if(aesContext->
nr == 10)
error_t cbcDecrypt(const CipherAlgo *cipher, void *context, uint8_t *iv, const uint8_t *c, uint8_t *p, size_t length)
CBC decryption.
NXP MCX E247 cipher hardware accelerator.
#define CSEC_CMD_LOAD_PLAIN_KEY
CipherAlgoDecryptBlock decryptBlock
#define CSEC_ERC_NO_ERROR
Collection of AEAD algorithms.
#define CSEC_CALL_SEQ_SUBSEQUENT
CipherAlgoEncryptBlock encryptBlock
uint32_t aesLoadKey(const uint32_t *key)
Load AES key.
error_t ecbEncrypt(const CipherAlgo *cipher, void *context, const uint8_t *p, uint8_t *c, size_t length)
ECB encryption.
#define osMemcpy(dest, src, length)
@ ERROR_FAILURE
Generic error code.
#define CSEC_CALL_SEQ_FIRST
General definitions for cryptographic algorithms.
NXP MCX E247 hardware cryptographic accelerator (ELA_CSEC)
error_t cbcEncrypt(const CipherAlgo *cipher, void *context, uint8_t *iv, const uint8_t *p, uint8_t *c, size_t length)
CBC encryption.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
Common interface for encryption algorithms.
#define CSEC_ERC_KEY_INVALID
OsMutex mcxe247CryptoMutex
uint32_t aesProcessData(uint32_t command, size_t offset, const uint8_t *input, uint8_t *output, size_t length)
Perform AES encryption or decryption.
error_t ecbDecrypt(const CipherAlgo *cipher, void *context, const uint8_t *c, uint8_t *p, size_t length)
ECB decryption.
#define CSEC_ERC_GENERAL_ERROR