Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
35 #include "fsl_device_registers.h"
43 #if (S32K1_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 CSE_PRAM->RAMn[4].DATA_32 =
htobe32(key[0]);
64 CSE_PRAM->RAMn[5].DATA_32 =
htobe32(key[1]);
65 CSE_PRAM->RAMn[6].DATA_32 =
htobe32(key[2]);
66 CSE_PRAM->RAMn[7].DATA_32 =
htobe32(key[3]);
73 while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0)
78 return CSE_PRAM->RAMn[1].DATA_32 >> 16;
92 uint32_t
aesProcessData(uint32_t command,
size_t offset,
const uint8_t *input,
93 uint8_t *output,
size_t length)
103 CSE_PRAM->RAMn[i].DATA_32 =
LOAD32BE(input);
104 CSE_PRAM->RAMn[i + 1].DATA_32 =
LOAD32BE(input + 4);
105 CSE_PRAM->RAMn[i + 2].DATA_32 =
LOAD32BE(input + 8);
106 CSE_PRAM->RAMn[i + 3].DATA_32 =
LOAD32BE(input + 12);
116 while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0)
121 status = CSE_PRAM->RAMn[1].DATA_32 >> 16;
129 temp = CSE_PRAM->RAMn[i].DATA_32;
131 temp = CSE_PRAM->RAMn[i + 1].DATA_32;
133 temp = CSE_PRAM->RAMn[i + 2].DATA_32;
135 temp = CSE_PRAM->RAMn[i + 3].DATA_32;
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)
407 CSE_PRAM->RAMn[7].DATA_32 =
LOAD32BE(
iv + 12);
520 uint8_t *
iv,
const uint8_t *
c, uint8_t *
p,
size_t length)
545 if(aesContext->
nr == 10)
560 CSE_PRAM->RAMn[7].DATA_32 =
LOAD32BE(
iv + 12);
CipherAlgoDecryptBlock decryptBlock
error_t cbcEncrypt(const CipherAlgo *cipher, void *context, uint8_t *iv, const uint8_t *p, uint8_t *c, size_t length)
CBC encryption.
uint32_t aesLoadKey(const uint32_t *key)
Load AES key.
Collection of AEAD algorithms.
CipherAlgoEncryptBlock encryptBlock
S32K1 hardware cryptographic accelerator (CSEq)
#define osMemcpy(dest, src, length)
#define CSEQ_ERC_GENERAL_ERROR
@ ERROR_FAILURE
Generic error code.
#define CSEQ_ERC_NO_ERROR
uint32_t aesProcessData(uint32_t command, size_t offset, const uint8_t *input, uint8_t *output, size_t length)
Perform AES encryption or decryption.
General definitions for cryptographic algorithms.
#define CSEQ_CMD_LOAD_PLAIN_KEY
error_t cbcDecrypt(const CipherAlgo *cipher, void *context, uint8_t *iv, const uint8_t *c, uint8_t *p, size_t length)
CBC decryption.
S32K1 cipher hardware accelerator.
#define CSEQ_ERC_KEY_INVALID
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 CSEQ_CALL_SEQ_SUBSEQUENT
error_t ecbEncrypt(const CipherAlgo *cipher, void *context, const uint8_t *p, uint8_t *c, size_t length)
ECB encryption.
#define CSEQ_CALL_SEQ_FIRST
error_t ecbDecrypt(const CipherAlgo *cipher, void *context, const uint8_t *c, uint8_t *p, size_t length)
ECB decryption.