RTEMS 6.1-rc5
Loading...
Searching...
No Matches
Data Structures | Enumerator | Functions | Variables
Puf_driver

Data Structures

struct  puf_config_t
 

Functions

void PUF_GetDefaultConfig (puf_config_t *conf)
 Sets the default configuration of PUF.
 
status_t PUF_Init (PUF_Type *base, puf_config_t *conf)
 Initialize PUF.
 
void PUF_Deinit (PUF_Type *base, puf_config_t *conf)
 Denitialize PUF.
 
status_t PUF_Enroll (PUF_Type *base, uint8_t *activationCode, size_t activationCodeSize)
 Enroll PUF.
 
status_t PUF_Start (PUF_Type *base, const uint8_t *activationCode, size_t activationCodeSize)
 Start PUF.
 
status_t PUF_SetIntrinsicKey (PUF_Type *base, puf_key_index_register_t keyIndex, size_t keySize, uint8_t *keyCode, size_t keyCodeSize)
 Set intrinsic key.
 
status_t PUF_SetUserKey (PUF_Type *base, puf_key_index_register_t keyIndex, const uint8_t *userKey, size_t userKeySize, uint8_t *keyCode, size_t keyCodeSize)
 Set user key.
 
status_t PUF_GetKey (PUF_Type *base, const uint8_t *keyCode, size_t keyCodeSize, uint8_t *key, size_t keySize)
 Reconstruct key from a key code.
 
status_t PUF_GetHwKey (PUF_Type *base, const uint8_t *keyCode, size_t keyCodeSize, puf_key_slot_t keySlot, uint32_t keyMask)
 Reconstruct hw bus key from a key code.
 
status_t PUF_Zeroize (PUF_Type *base)
 Zeroize PUF.
 
bool PUF_IsGetKeyAllowed (PUF_Type *base)
 Checks if Get Key operation is allowed.
 
status_t PUF_PowerCycle (PUF_Type *base, puf_config_t *conf)
 Powercycle PUF.
 

Variables

uint32_t puf_config_t::dischargeTimeMsec
 
uint32_t puf_config_t::coreClockFrequencyHz
 

Driver version

enum  _puf_key_index_register {
  kPUF_KeyIndex_00 = 0x00U , kPUF_KeyIndex_01 = 0x01U , kPUF_KeyIndex_02 = 0x02U , kPUF_KeyIndex_03 = 0x03U ,
  kPUF_KeyIndex_04 = 0x04U , kPUF_KeyIndex_05 = 0x05U , kPUF_KeyIndex_06 = 0x06U , kPUF_KeyIndex_07 = 0x07U ,
  kPUF_KeyIndex_08 = 0x08U , kPUF_KeyIndex_09 = 0x09U , kPUF_KeyIndex_10 = 0x0AU , kPUF_KeyIndex_11 = 0x0BU ,
  kPUF_KeyIndex_12 = 0x0CU , kPUF_KeyIndex_13 = 0x0DU , kPUF_KeyIndex_14 = 0x0EU , kPUF_KeyIndex_15 = 0x0FU
}
 
enum  _puf_min_max { kPUF_KeySizeMin = 8u , kPUF_KeySizeMax = 512u , kPUF_KeyIndexMax = kPUF_KeyIndex_15 }
 
enum  _puf_key_slot { kPUF_KeySlot0 = 0U , kPUF_KeySlot1 = 1U }
 PUF key slot. More...
 
enum  { kStatus_EnrollNotAllowed = MAKE_STATUS(kStatusGroup_PUF, 1) , kStatus_StartNotAllowed = MAKE_STATUS(kStatusGroup_PUF, 2) }
 
typedef enum _puf_key_index_register puf_key_index_register_t
 
typedef enum _puf_min_max puf_min_max_t
 
typedef enum _puf_key_slot puf_key_slot_t
 PUF key slot.
 
#define FSL_PUF_DRIVER_VERSION   (MAKE_VERSION(2, 1, 6))
 PUF driver version. Version 2.1.6.
 
#define PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(x)   ((160u + (((((x) << 3) + 255u) >> 8) << 8)) >> 3)
 Get Key Code size in bytes from key size in bytes at compile time.
 
#define PUF_MIN_KEY_CODE_SIZE   PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(8UL)
 
#define PUF_ACTIVATION_CODE_SIZE   1192U
 
#define KEYSTORE_PUF_DISCHARGE_TIME_FIRST_TRY_MS   50
 
#define KEYSTORE_PUF_DISCHARGE_TIME_MAX_MS   400
 

Detailed Description

Macro Definition Documentation

◆ FSL_PUF_DRIVER_VERSION

#define FSL_PUF_DRIVER_VERSION   (MAKE_VERSION(2, 1, 6))

PUF driver version. Version 2.1.6.

Current version: 2.1.6

Change log:

  • 2.0.0
    • Initial version.
  • 2.0.1
    • Fixed puf_wait_usec function optimization issue.
  • 2.0.2
    • Add PUF configuration structure and support for PUF SRAM controller. Remove magic constants.
  • 2.0.3
    • Fix MISRA C-2012 issue.
  • 2.1.0
    • Align driver with PUF SRAM controller registers on LPCXpresso55s16.
    • Update initizalition logic .
  • 2.1.1
    • Fix ARMGCC build warning .
  • 2.1.2
    • Update: Add automatic big to little endian swap for user (pre-shared) keys destinated to secret hardware bus (PUF key index 0).
  • 2.1.3
    • Fix MISRA C-2012 issue.
  • 2.1.4
    • Replace register uint32_t ticksCount with volatile uint32_t ticksCount in puf_wait_usec() to prevent optimization out delay loop.
  • 2.1.5
    • Use common SDK delay in puf_wait_usec()
  • 2.1.6
    • Changed wait time in PUF_Init(), when initialization fails it will try PUF_Powercycle() with shorter time. If this shorter time will also fail, initialization will be tried with worst case time as before.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

PUF status return codes.

◆ _puf_key_slot

PUF key slot.

Enumerator
kPUF_KeySlot0 

PUF key slot 0

kPUF_KeySlot1 

PUF key slot 1

Function Documentation

◆ PUF_Deinit()

void PUF_Deinit ( PUF_Type base,
puf_config_t conf 
)

Denitialize PUF.

This function disables power to PUF SRAM and peripheral clock.

Parameters
basePUF peripheral base address
confPUF configuration structure

brief Denitialize PUF

This function disables power to PUF SRAM and peripheral clock.

param base PUF peripheral base address param conf PUF configuration structure

◆ PUF_Enroll()

status_t PUF_Enroll ( PUF_Type base,
uint8_t *  activationCode,
size_t  activationCodeSize 
)

Enroll PUF.

This function derives a digital fingerprint, generates the corresponding Activation Code (AC) and returns it to be stored in an NVM or a file. This step needs to be performed only once for each device. This function may be permanently disallowed by a fuse.

Parameters
basePUF peripheral base address
[out]activationCodeWord aligned address of the resulting activation code.
activationCodeSizeSize of the activationCode buffer in bytes. Shall be 1192 bytes.
Returns
Status of enroll operation.

brief Enroll PUF

This function derives a digital fingerprint, generates the corresponding Activation Code (AC) and returns it to be stored in an NVM or a file. This step needs to be performed only once for each device. This function may be permanently disallowed by a fuse.

param base PUF peripheral base address param[out] activationCode Word aligned address of the resulting activation code. param activationCodeSize Size of the activationCode buffer in bytes. Shall be 1192 bytes. return Status of enroll operation.

◆ PUF_GetDefaultConfig()

void PUF_GetDefaultConfig ( puf_config_t conf)

Sets the default configuration of PUF.

This function initialize PUF config structure to default values.

Parameters
confPUF configuration structure

brief Sets the default configuration of PUF

This function initialize PUF config structure to default values.

param conf PUF configuration structure

◆ PUF_GetHwKey()

status_t PUF_GetHwKey ( PUF_Type base,
const uint8_t *  keyCode,
size_t  keyCodeSize,
puf_key_slot_t  keySlot,
uint32_t  keyMask 
)

Reconstruct hw bus key from a key code.

The digital fingerprint generated during the Start operation and the KC generated during a Set Key operation (Set intrinsic key or Set user key) are used to retrieve a stored key. This operation needs to be done every time a key is needed. This function accepts only Key Codes created for PUF index register kPUF_KeyIndex_00. Such a key is output directly to a dedicated hardware bus. The reconstructed key is not exposed to system memory.

Parameters
basePUF peripheral base address
keyCodeWord aligned address of the input key code.
keyCodeSizeSize of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(keySize).
keySlotkey slot to output on hw bus. Parameter is ignored on devices with less than two key slots.
keyMaskkey masking value. Shall be random for each POR/reset. Value does not have to be cryptographicaly secure.
Returns
Status of get key operation.

brief Reconstruct hw bus key from a key code

The digital fingerprint generated during the Start operation and the KC generated during a Set Key operation (Set intrinsic key or Set user key) are used to retrieve a stored key. This operation needs to be done every time a key is needed. This function accepts only Key Codes created for PUF index register kPUF_KeyIndex_00. Such a key is output directly to a dedicated hardware bus. The reconstructed key is not exposed to system memory.

param base PUF peripheral base address param keyCode Word aligned address of the input key code. param keyCodeSize Size of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(keySize). param keySlot key slot to output on hw bus. Parameter is ignored on devices with less than two key slots. param keyMask key masking value. Shall be random for each POR/reset. Value does not have to be cryptographicaly secure. return Status of get key operation.

◆ PUF_GetKey()

status_t PUF_GetKey ( PUF_Type base,
const uint8_t *  keyCode,
size_t  keyCodeSize,
uint8_t *  key,
size_t  keySize 
)

Reconstruct key from a key code.

The digital fingerprint generated during the Start operation and the KC generated during a Set Key operation (Set intrinsic key or Set user key) are used to retrieve a stored key. This operation needs to be done every time a key is needed. This function accepts only Key Codes created for PUF index registers kPUF_KeyIndex_01 to kPUF_KeyIndex_15.

Parameters
basePUF peripheral base address
keyCodeWord aligned address of the input key code.
keyCodeSizeSize of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(keySize).
[out]keyWord aligned address of output key.
keySizeSize of the output key in bytes.
Returns
Status of get key operation.

brief Reconstruct key from a key code

The digital fingerprint generated during the Start operation and the KC generated during a Set Key operation (Set intrinsic key or Set user key) are used to retrieve a stored key. This operation needs to be done every time a key is needed. This function accepts only Key Codes created for PUF index registers kPUF_KeyIndex_01 to kPUF_KeyIndex_15.

param base PUF peripheral base address param keyCode Word aligned address of the input key code. param keyCodeSize Size of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(keySize). param[out] key Word aligned address of output key. param keySize Size of the output key in bytes. return Status of get key operation.

◆ PUF_Init()

status_t PUF_Init ( PUF_Type base,
puf_config_t conf 
)

Initialize PUF.

This function enables power to PUF block and waits until the block initializes.

Parameters
basePUF peripheral base address
confPUF configuration structure
Returns
Status of the init operation

brief Initialize PUF

This function enables power to PUF block and waits until the block initializes.

param base PUF peripheral base address param conf PUF configuration structure return Status of the init operation

◆ PUF_IsGetKeyAllowed()

bool PUF_IsGetKeyAllowed ( PUF_Type base)

Checks if Get Key operation is allowed.

This function returns true if get key operation is allowed.

Parameters
basePUF peripheral base address
Returns
true if get key operation is allowed

brief Checks if Get Key operation is allowed.

This function returns true if get key operation is allowed.

param base PUF peripheral base address return true if get key operation is allowed

◆ PUF_PowerCycle()

status_t PUF_PowerCycle ( PUF_Type base,
puf_config_t conf 
)

Powercycle PUF.

This function make powercycle.

Parameters
basePUF peripheral base address
confPUF configuration structure
Returns
Status of the powercycle operation.

brief Powercycle PUF

This function make powercycle of PUF.

param base PUF peripheral base address param conf PUF configuration structure return Status of the powercycle operation.

◆ PUF_SetIntrinsicKey()

status_t PUF_SetIntrinsicKey ( PUF_Type base,
puf_key_index_register_t  keyIndex,
size_t  keySize,
uint8_t *  keyCode,
size_t  keyCodeSize 
)

Set intrinsic key.

The digital fingerprint generated during the Enroll/Start operations is used to generate a Key Code (KC) that defines a unique intrinsic key. This KC is returned to be stored in an NVM or a file. This operation needs to be done only once for each intrinsic key. Each time a Set Intrinsic Key operation is executed a new unique key is generated.

Parameters
basePUF peripheral base address
keyIndexPUF key index register
keySizeSize of the intrinsic key to generate in bytes.
[out]keyCodeWord aligned address of the resulting key code.
keyCodeSizeSize of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(keySize).
Returns
Status of set intrinsic key operation.

brief Set intrinsic key

The digital fingerprint generated during the Enroll/Start operations is used to generate a Key Code (KC) that defines a unique intrinsic key. This KC is returned to be stored in an NVM or a file. This operation needs to be done only once for each intrinsic key. Each time a Set Intrinsic Key operation is executed a new unique key is generated.

param base PUF peripheral base address param keyIndex PUF key index register param keySize Size of the intrinsic key to generate in bytes. param[out] keyCode Word aligned address of the resulting key code. param keyCodeSize Size of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(keySize). return Status of set intrinsic key operation.

◆ PUF_SetUserKey()

status_t PUF_SetUserKey ( PUF_Type base,
puf_key_index_register_t  keyIndex,
const uint8_t *  userKey,
size_t  userKeySize,
uint8_t *  keyCode,
size_t  keyCodeSize 
)

Set user key.

The digital fingerprint generated during the Enroll/Start operations and a user key (UK) provided as input are used to generate a Key Code (KC). This KC is sent returned to be stored in an NVM or a file. This operation needs to be done only once for each user key.

Parameters
basePUF peripheral base address
keyIndexPUF key index register
userKeyWord aligned address of input user key.
userKeySizeSize of the input user key in bytes.
[out]keyCodeWord aligned address of the resulting key code.
keyCodeSizeSize of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(userKeySize).
Returns
Status of set user key operation.

brief Set user key

The digital fingerprint generated during the Enroll/Start operations and a user key (UK) provided as input are used to generate a Key Code (KC). This KC is sent returned to be stored in an NVM or a file. This operation needs to be done only once for each user key.

param base PUF peripheral base address param keyIndex PUF key index register param userKey Word aligned address of input user key. param userKeySize Size of the input user key in bytes. param[out] keyCode Word aligned address of the resulting key code. param keyCodeSize Size of the keyCode buffer in bytes. Shall be PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(userKeySize). return Status of set user key operation.

◆ PUF_Start()

status_t PUF_Start ( PUF_Type base,
const uint8_t *  activationCode,
size_t  activationCodeSize 
)

Start PUF.

The Activation Code generated during the Enroll operation is used to reconstruct the digital fingerprint. This needs to be done after every power-up and reset.

Parameters
basePUF peripheral base address
activationCodeWord aligned address of the input activation code.
activationCodeSizeSize of the activationCode buffer in bytes. Shall be 1192 bytes.
Returns
Status of start operation.

brief Start PUF

The Activation Code generated during the Enroll operation is used to reconstruct the digital fingerprint. This needs to be done after every power-up and reset.

param base PUF peripheral base address param activationCode Word aligned address of the input activation code. param activationCodeSize Size of the activationCode buffer in bytes. Shall be 1192 bytes. return Status of start operation.

◆ PUF_Zeroize()

status_t PUF_Zeroize ( PUF_Type base)

Zeroize PUF.

This function clears all PUF internal logic and puts the PUF to error state.

Parameters
basePUF peripheral base address
Returns
Status of the zeroize operation.

brief Zeroize PUF

This function clears all PUF internal logic and puts the PUF to error state.

param base PUF peripheral base address return Status of the zeroize operation.