The MCUXpresso SDK provides a peripheral driver for On The Fly AES-128 Decryption (OTFAD) module of MCUXpresso SDK devices.
This example code shows how to decrypt ciphertext in external memory using the OTFAD driver.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/otfad
|
enum | {
kStatus_OTFAD_ResRegAccessMode = MAKE_STATUS(kStatusGroup_OTFAD, 0),
kStatus_OTFAD_AddressError = MAKE_STATUS(kStatusGroup_OTFAD, 1),
kStatus_OTFAD_RegionOverlap,
kStatus_OTFAD_RegionMiss
} |
| Status codes for the OTFAD driver. More...
|
|
enum | {
kOTFAD_Context_0 = 0U,
kOTFAD_Context_1 = 1U,
kOTFAD_Context_2 = 2U,
kOTFAD_Context_3 = 3U
} |
| OTFAD context type. More...
|
|
enum | {
kOTFAD_NRM = 0x00U,
kOTFAD_SVM = 0x02U,
kOTFAD_LDM = 0x03U
} |
| OTFAD operate mode. More...
|
|
struct otfad_encryption_config_t |
Data Fields |
bool | valid |
| The context is valid or not.
|
|
bool | AESdecryption |
| AES decryption enable.
|
|
uint8_t | readOnly |
| read write attribute for the entire set of context registers
|
|
uint8_t | contextIndex |
| OTFAD context index.
|
|
uint32_t | startAddr |
| Start address.
|
|
uint32_t | endAddr |
| End address.
|
|
uint32_t | key [4] |
| Encryption key.
|
|
uint32_t | counter [2] |
| Encryption counter.
|
|
Enumerator |
---|
kStatus_OTFAD_ResRegAccessMode |
Restricted register mode.
|
kStatus_OTFAD_AddressError |
End address less than start address.
|
kStatus_OTFAD_RegionOverlap |
the OTFAD does not support any form of memory region overlap, for system accesses that hit in multiple contexts or no contexts, the fetched data is simply bypassed
|
kStatus_OTFAD_RegionMiss |
For accesses that hit in a single context, but not the selected one.
|
Enumerator |
---|
kOTFAD_Context_0 |
context 0
|
kOTFAD_Context_1 |
context 1
|
kOTFAD_Context_2 |
context 2
|
kOTFAD_Context_3 |
context 3
|
Enumerator |
---|
kOTFAD_NRM |
Normal Mode.
|
kOTFAD_SVM |
Security Violation Mode.
|
kOTFAD_LDM |
Logically Disabled Mode.
|
- Parameters
-
config | OTFAD configuration. |
- Parameters
-
base | OTFAD base address. |
config | OTFAD configuration. |
static uint32_t OTFAD_GetOperateMode |
( |
OTFAD_Type * |
base | ) |
|
|
inlinestatic |
static uint32_t OTFAD_GetStatus |
( |
OTFAD_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | OTFAD base address. |
config | encryption configuration. |
Note: if enable keyblob process, the first 256 bytes external memory is use for keyblob data, so this region shouldn't be in OTFAD region.
- Parameters
-
base | OTFAD base address. |
config | encryption configuration. |
Note: if enable keyblob process, the first 256 bytes external memory is use for keyblob data, so this region shouldn't be in OTFAD region.
status_t OTFAD_HitDetermination |
( |
OTFAD_Type * |
base, |
|
|
uint32_t |
address, |
|
|
uint8_t * |
contextIndex |
|
) |
| |
- Parameters
-
base | OTFAD base address. |
address | the physical address space assigned to the QuadSPI(FlexSPI) module. |
contextIndex | hitted context region index. |
- Returns
- status, such as kStatus_Success or kStatus_OTFAD_ResRegAccessMode.