![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the PRINCE bus crypto engine module of MCUXpresso SDK devices.
..
This example code shows how to use the PRINCE driver.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/prince
Enumerations | |
enum | skboot_status_t { kStatus_SKBOOT_Success = 0x5ac3c35au, kStatus_SKBOOT_Fail = 0xc35ac35au, kStatus_SKBOOT_InvalidArgument = 0xc35a5ac3u, kStatus_SKBOOT_KeyStoreMarkerInvalid = 0xc3c35a5au } |
Secure status enumeration. More... | |
enum | secure_bool_t { kSECURE_TRUE = 0xc33cc33cU, kSECURE_FALSE = 0x5aa55aa5U } |
Secure boolean enumeration. More... | |
enum | prince_region_t { kPRINCE_Region0 = 0U, kPRINCE_Region1 = 1U, kPRINCE_Region2 = 2U } |
Prince region. More... | |
enum | prince_lock_t { kPRINCE_Region0Lock = 1U, kPRINCE_Region1Lock = 2U, kPRINCE_Region2Lock = 4U, kPRINCE_MaskLock = 256U } |
Prince lock. More... | |
enum | prince_flags_t { kPRINCE_Flag_None = 0U, kPRINCE_Flag_EraseCheck = 1U, kPRINCE_Flag_WriteCheck = 2U } |
Prince flag. More... | |
Functions | |
static void | PRINCE_EncryptEnable (PRINCE_Type *base) |
Enable data encryption. More... | |
static void | PRINCE_EncryptDisable (PRINCE_Type *base) |
Disable data encryption. More... | |
static bool | PRINCE_IsEncryptEnable (PRINCE_Type *base) |
Is Enable data encryption. More... | |
static void | PRINCE_SetMask (PRINCE_Type *base, uint64_t mask) |
Sets PRINCE data mask. More... | |
static void | PRINCE_SetLock (PRINCE_Type *base, uint32_t lock) |
Locks access for specified region registers or data mask register. More... | |
status_t | PRINCE_GenNewIV (prince_region_t region, uint8_t *iv_code, bool store, flash_config_t *flash_context) |
Generate new IV code. More... | |
status_t | PRINCE_LoadIV (prince_region_t region, uint8_t *iv_code) |
Load IV code. More... | |
status_t | PRINCE_SetEncryptForAddressRange (prince_region_t region, uint32_t start_address, uint32_t length, flash_config_t *flash_context, bool regenerate_iv) |
Allow encryption/decryption for specified address range. More... | |
status_t | PRINCE_GetRegionSREnable (PRINCE_Type *base, prince_region_t region, uint32_t *sr_enable) |
Gets the PRINCE Sub-Region Enable register. More... | |
status_t | PRINCE_GetRegionBaseAddress (PRINCE_Type *base, prince_region_t region, uint32_t *region_base_addr) |
Gets the PRINCE region base address register. More... | |
status_t | PRINCE_SetRegionIV (PRINCE_Type *base, prince_region_t region, const uint8_t iv[8]) |
Sets the PRINCE region IV. More... | |
status_t | PRINCE_SetRegionBaseAddress (PRINCE_Type *base, prince_region_t region, uint32_t region_base_addr) |
Sets the PRINCE region base address. More... | |
status_t | PRINCE_SetRegionSREnable (PRINCE_Type *base, prince_region_t region, uint32_t sr_enable) |
Sets the PRINCE Sub-Region Enable register. More... | |
status_t | PRINCE_FlashEraseWithChecker (flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key) |
Erases the flash sectors encompassed by parameters passed into function. More... | |
status_t | PRINCE_FlashProgramWithChecker (flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes) |
Programs flash with data at locations passed in through parameters. More... | |
Driver version | |
#define | FSL_PRINCE_DRIVER_VERSION (MAKE_VERSION(2, 5, 0)) |
PRINCE driver version 2.5.0. More... | |
#define FSL_PRINCE_DRIVER_VERSION (MAKE_VERSION(2, 5, 0)) |
Current version: 2.5.0
Change log:
enum skboot_status_t |
enum secure_bool_t |
enum prince_region_t |
enum prince_lock_t |
enum prince_flags_t |
|
inlinestatic |
This function enables PRINCE on-the-fly data encryption.
base | PRINCE peripheral address. |
|
inlinestatic |
This function disables PRINCE on-the-fly data encryption.
base | PRINCE peripheral address. |
|
inlinestatic |
This function test if PRINCE on-the-fly data encryption is enabled.
base | PRINCE peripheral address. |
|
inlinestatic |
This function sets the PRINCE mask that is used to mask decrypted data.
base | PRINCE peripheral address. |
mask | 64-bit data mask value. |
|
inlinestatic |
This function sets lock on specified region registers or mask register.
base | PRINCE peripheral address. |
lock | registers to lock. This is a logical OR of members of the enumeration prince_lock_t |
status_t PRINCE_GenNewIV | ( | prince_region_t | region, |
uint8_t * | iv_code, | ||
bool | store, | ||
flash_config_t * | flash_context | ||
) |
This function generates new IV code and stores it into the persistent memory. Ensure about 800 bytes free space on the stack when calling this routine with the store parameter set to true!
region | PRINCE region index. |
iv_code | IV code pointer used for storing the newly generated 52 bytes long IV code. |
store | flag to allow storing the newly generated IV code into the persistent memory (FFR). |
flash_context | pointer to the flash driver context structure. |
status_t PRINCE_LoadIV | ( | prince_region_t | region, |
uint8_t * | iv_code | ||
) |
This function enables IV code loading into the PRINCE bus encryption engine.
region | PRINCE region index. |
iv_code | IV code pointer used for passing the IV code. |
status_t PRINCE_SetEncryptForAddressRange | ( | prince_region_t | region, |
uint32_t | start_address, | ||
uint32_t | length, | ||
flash_config_t * | flash_context, | ||
bool | regenerate_iv | ||
) |
This function sets the encryption/decryption for specified address range. The SR mask value for the selected Prince region is calculated from provided start_address and length parameters. This calculated value is OR'ed with the actual SR mask value and stored into the PRINCE SR_ENABLE register and also into the persistent memory (FFR) to be used after the device reset. It is possible to define several nonadjacent encrypted areas within one Prince region when calling this function repeatedly. If the length parameter is set to 0, the SR mask value is set to 0 and thus the encryption/decryption for the whole selected Prince region is disabled. Ensure about 800 bytes free space on the stack when calling this routine!
region | PRINCE region index. |
start_address | start address of the area to be encrypted/decrypted. |
length | length of the area to be encrypted/decrypted. |
flash_context | pointer to the flash driver context structure. |
regenerate_iv | flag to allow IV code regenerating, storing into the persistent memory (FFR) and loading into the PRINCE engine |
status_t PRINCE_GetRegionSREnable | ( | PRINCE_Type * | base, |
prince_region_t | region, | ||
uint32_t * | sr_enable | ||
) |
This function gets PRINCE SR_ENABLE register.
base | PRINCE peripheral address. |
region | PRINCE region index. |
sr_enable | Sub-Region Enable register pointer. |
status_t PRINCE_GetRegionBaseAddress | ( | PRINCE_Type * | base, |
prince_region_t | region, | ||
uint32_t * | region_base_addr | ||
) |
This function gets PRINCE BASE_ADDR register.
base | PRINCE peripheral address. |
region | PRINCE region index. |
region_base_addr | Region base address pointer. |
status_t PRINCE_SetRegionIV | ( | PRINCE_Type * | base, |
prince_region_t | region, | ||
const uint8_t | iv[8] | ||
) |
This function sets specified AES IV for the given region.
base | PRINCE peripheral address. |
region | Selection of the PRINCE region to be configured. |
iv | 64-bit AES IV in little-endian byte order. |
status_t PRINCE_SetRegionBaseAddress | ( | PRINCE_Type * | base, |
prince_region_t | region, | ||
uint32_t | region_base_addr | ||
) |
This function configures PRINCE region base address.
base | PRINCE peripheral address. |
region | Selection of the PRINCE region to be configured. |
region_base_addr | Base Address for region. |
status_t PRINCE_SetRegionSREnable | ( | PRINCE_Type * | base, |
prince_region_t | region, | ||
uint32_t | sr_enable | ||
) |
This function configures PRINCE SR_ENABLE register.
base | PRINCE peripheral address. |
region | Selection of the PRINCE region to be configured. |
sr_enable | Sub-Region Enable register value. |
status_t PRINCE_FlashEraseWithChecker | ( | flash_config_t * | config, |
uint32_t | start, | ||
uint32_t | lengthInBytes, | ||
uint32_t | key | ||
) |
This function erases the appropriate number of flash sectors based on the desired start address and length. It deals with the flash erase function complenentary to the standard erase API of the IAP1 driver. This implementation additionally checks if the whole encrypted PRINCE subregions are erased at once to avoid secrets revealing. The checker implementation is limited to one contiguous PRINCE-controlled memory area.
config | The pointer to the flash driver context structure. |
start | The start address of the desired flash memory to be erased. The start address needs to be prince-sburegion-aligned. |
lengthInBytes | The length, given in bytes (not words or long-words) to be erased. Must be prince-sburegion-size-aligned. |
key | The value used to validate all flash erase APIs. |
status_t PRINCE_FlashProgramWithChecker | ( | flash_config_t * | config, |
uint32_t | start, | ||
uint8_t * | src, | ||
uint32_t | lengthInBytes | ||
) |
This function programs the flash memory with the desired data for a given flash area as determined by the start address and the length. It deals with the flash program function complenentary to the standard program API of the IAP1 driver. This implementation additionally checks if the whole PRINCE subregions are programmed at once to avoid secrets revealing. The checker implementation is limited to one contiguous PRINCE-controlled memory area.
config | The pointer to the flash driver context structure. |
start | The start address of the desired flash memory to be programmed. Must be prince-sburegion-aligned. |
src | A pointer to the source buffer of data that is to be programmed into the flash. |
lengthInBytes | The length, given in bytes (not words or long-words), to be programmed. Must be prince-sburegion-size-aligned. |