MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Ltc_driver_dpa

Overview

Modules

 Ltc_driver_aes_with_dpa
 
 Ltc_driver_cmac_with_dpa
 
 Ltc_driver_des_with_dpa
 

Data Structures

struct  ltc_dpa_handle_t
 Handle for LTC DPA APIs. More...
 

Macros

#define LTC_DPA_AES_BLOCK_SIZE   16
 AES block size in bytes.
 
#define LTC_DPA_AES_IV_SIZE   16
 AES Input Vector size in bytes.
 
#define LTC_DPA_DES_BLOCK_SIZE   8
 LTC DES block size in bytes.
 
#define LTC_DPA_DES_KEY_SIZE   8
 LTC DES key size - 64 bits. More...
 
#define LTC_DPA_DES_IV_SIZE   8
 LTC DES IV size - 8 bytes.
 
#define LTC_DPA_AES_BLOCK_SIZE   16
 AES block size in bytes.
 
#define LTC_DPA_AES_IV_SIZE   16
 AES Input Vector size in bytes.
 
#define LTC_DPA_DES_BLOCK_SIZE   8
 LTC DES block size in bytes.
 
#define LTC_DPA_DES_KEY_SIZE   8
 LTC DES key size - 64 bits. More...
 
#define LTC_DPA_DES_IV_SIZE   8
 LTC DES IV size - 8 bytes.
 

Typedefs

typedef uint32_t ltc_dpa_request_t [250]
 User request details, also updated during processing.
 
typedef uint32_t ltc_dpa_request_t [250]
 User request details, also updated during processing.
 

Enumerations

enum  ltc_dpa_hash_algo_t
 Algorithm supported by LTC_CMAC_DPA APIs.
 
enum  ltc_dpa_hash_algo_t
 Algorithm supported by LTC_CMAC_DPA APIs.
 

Functions

void LTC_InitDPA (LTC_Type *base)
 Enable clock to LTC module. More...
 
void LTC_SetDpaMaskSeedDPA (LTC_Type *base, uint32_t mask)
 Sets the DPA Mask Seed register. More...
 
status_t LTC_CreateHandleDPA (LTC_Type *base, ltc_dpa_handle_t *handle, uint8_t seed[16])
 Init the LTC DPA handle which is used in transcational functions. More...
 
status_t LTC_AES_SetKeyDPA (LTC_Type *base, ltc_dpa_handle_t *handle, const uint8_t *key, size_t keySize)
 Set key for LTC DPA AES encryption. More...
 
void LTC_SetDummyNumberDPA (ltc_dpa_handle_t *handle, uint32_t num)
 Set number of dummy operations added per one real operation. More...
 
void LTC_SetDummyProbabilityDPA (ltc_dpa_handle_t *handle, uint32_t probability)
 Set probability a dummy operation runs to completion. More...
 
status_t LTC_IdleTimePrngBufferEnableDPA (ltc_dpa_handle_t *handle, uint32_t *prngBuffer, size_t prngBufferArraySize)
 Enables the Idle time PRNG buffer. More...
 
status_t LTC_IdleTimePrngBufferPutNextDPA (ltc_dpa_handle_t *handle)
 Runs PRNG algorithm and puts the 32-bit random word to associated memory buffer. More...
 

Data Structure Documentation

struct ltc_dpa_handle_t

Data Fields

ltc_dpa_request_t req
 Driver internals derived from user request and updated during request processing.
 

Macro Definition Documentation

#define LTC_DPA_DES_KEY_SIZE   8
#define LTC_DPA_DES_KEY_SIZE   8

Function Documentation

void LTC_InitDPA ( LTC_Type *  base)

This function enables clock to the LTC module.

Parameters
baseLTC peripheral base address
void LTC_SetDpaMaskSeedDPA ( LTC_Type *  base,
uint32_t  mask 
)

The DPA Mask Seed register reseeds the mask that provides resistance against DPA (differential power analysis) attacks on AES or DES keys.

Differential Power Analysis Mask (DPA) resistance uses a randomly changing mask that introduces "noise" into the power consumed by the AES or DES. This reduces the signal-to-noise ratio that differential power analysis attacks use to "guess" bits of the key. This randomly changing mask should be seeded at POR, and continues to provide DPA resistance from that point on. However, to provide even more DPA protection it is recommended that the DPA mask be reseeded after every 50,000 blocks have been processed. At that time, software can opt to write a new seed (preferably obtained from an RNG) into the DPA Mask Seed register (DPAMS), or software can opt to provide the new seed earlier or later, or not at all. DPA resistance continues even if the DPA mask is never reseeded.

Parameters
baseLTC peripheral base address
maskThe DPA mask seed.
status_t LTC_CreateHandleDPA ( LTC_Type *  base,
ltc_dpa_handle_t handle,
uint8_t  seed[16] 
)

This function creates internal context for the LTC DPA functions. This function also initializes LTC DPA Mask Seed DPAMS register with a 32-bit word, where the word is derived from the seed[].

Parameters
baseLTC module base address
[in,out]handlePointer to ltc_dpa_handle_t structure
seedPointer to 128-bit entropy input.
Returns
kStatus_Success is successfull or kStatus_InvalidArgument if error.
status_t LTC_AES_SetKeyDPA ( LTC_Type *  base,
ltc_dpa_handle_t handle,
const uint8_t *  key,
size_t  keySize 
)

This function sets key for usage with LTC DPA AES functions.

Parameters
baseLTC module base address
[in,out]handlePointer to ltc_dpa_handle_t structure
probabilityProbability that a dummy operation runs to completion.
Returns
Status.
void LTC_SetDummyNumberDPA ( ltc_dpa_handle_t handle,
uint32_t  num 
)

LTC_CreateHandleDPA() uses this function to configure default Nd = 15.

This function sets runtime parameter of number of dummy operation added per one real operation. Possible values have an upper limit FSL_LTC_DPA_MAX_ND. The parameter is stored in the handle and read by the driver from the handle when it executes encryption or decryption. This function can be called any time.

Parameters
[in,out]handlePointer to ltc_dpa_handle_t structure
probabilityProbability that a dummy operation runs to completion.
void LTC_SetDummyProbabilityDPA ( ltc_dpa_handle_t handle,
uint32_t  probability 
)

LTC_CreateHandleDPA() uses this function to configure default probability = 100%, means in default setting all dummy operations run to completion.

This function sets runtime parameter of probability a dummy operation runs to completion. The parameter is stored in the handle and read by the driver from the handle when it executes encryption or decryption. This function can be called any time.

Parameters
[in,out]handlePointer to ltc_dpa_handle_t structure
probabilityProbability that a dummy operation runs to completion. Possible values are integer values 0 to 100.
status_t LTC_IdleTimePrngBufferEnableDPA ( ltc_dpa_handle_t handle,
uint32_t *  prngBuffer,
size_t  prngBufferArraySize 
)

This feature is intended to enable pseudo-random numbers generation during system idle time. These idle time pre-generated numbers are simply consumed by LTC_DPA encrypt/decrypt functions.

Parameters
[in,out]handlePointer to ltc_dpa_handle_t structure
prngBufferMemory buffer to be used as storage for random 32-bit words.
prngBufferArraySizeNumber of items (array size) in the prngBuffer[] array.
status_t LTC_IdleTimePrngBufferPutNextDPA ( ltc_dpa_handle_t handle)

This function is intended and designed to be used during system idle time to generate random numbers, to be consumed by LTC_DPA encrypt/decrypt APIs.

Example usage FreeRTOS Idle Time Hook:

* static uint32_t s_prngBuffer[2048];
* LTC_IdleTimePrngBufferEnableDPA(g_ltcDpaHandle, s_prngBuffer, 2048);
* ...
* void vApplicationIdleHook(void)
* {
* if (kStatus_Success != LTC_IdleTimePrngBufferPutNextDPA(g_ltcDpaHandle)
* {
* __WFI();
* }
* }
*

Example usage in Super Loop (bare metal):

* static uint32_t s_prngBuffer[2048];
* LTC_IdleTimePrngBufferEnableDPA(g_ltcDpaHandle, s_prngBuffer, 2048);
* ...
* while (1)
* {
* ...
* ...
* ...
* if (kStatus_Success != LTC_IdleTimePrngBufferPutNextDPA(g_ltcDpaHandle)
* {
* __WFI();
* }
* }
*
Parameters
[in,out]handlePointer to ltc_dpa_handle_t structure
Returns
kStatus_Success Sucesfully generated next random number. prngBuffer[] is not full yet.
kStatus_LTC_PrngRingBufferFull prngBuffer[] is full.
kStatus_InvalidArgument prngBuffer[] is not configured. Use LTC_IdleTimePrngBufferEnableDPA().