123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- #ifndef _PUF_H_
- #define _PUF_H_
- #include <stddef.h>
- #include <stdint.h>
- #include "fsl_common.h"
- #define swap_bytes(in) __REV(in)
- typedef 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,
- } puf_key_index_register_t;
- typedef enum _puf_min_max
- {
- kPUF_KeySizeMin = 8u,
- kPUF_KeySizeMax = 512u,
- kPUF_KeyIndexMax = kPUF_KeyIndex_15,
- } puf_min_max_t;
- typedef enum _puf_key_slot
- {
- kPUF_KeySlot0 = 0U,
- kPUF_KeySlot1 = 1U,
- #if defined(FSL_FEATURE_PUF_HAS_KEYSLOTS) && (FSL_FEATURE_PUF_HAS_KEYSLOTS > 2)
- kPUF_KeySlot2 = 2U,
- kPUF_KeySlot3 = 3U,
- #endif
- } puf_key_slot_t;
- #define PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(x) ((160u + ((((x << 3) + 255u) >> 8) << 8)) >> 3)
- #define PUF_MIN_KEY_CODE_SIZE PUF_GET_KEY_CODE_SIZE_FOR_KEY_SIZE(8)
- #define PUF_ACTIVATION_CODE_SIZE 1192
- #if defined(__cplusplus)
- extern "C" {
- #endif
- status_t PUF_Init(PUF_Type *base, uint32_t dischargeTimeMsec, uint32_t coreClockFrequencyHz);
- void PUF_Deinit(PUF_Type *base, uint32_t dischargeTimeMsec, uint32_t coreClockFrequencyHz);
- status_t PUF_Enroll(PUF_Type *base, uint8_t *activationCode, size_t activationCodeSize);
- status_t PUF_Start(PUF_Type *base, const uint8_t *activationCode, size_t activationCodeSize);
- status_t PUF_SetIntrinsicKey(
- PUF_Type *base, puf_key_index_register_t keyIndex, size_t keySize, uint8_t *keyCode, size_t keyCodeSize);
- 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);
- status_t PUF_GetKey(PUF_Type *base, const uint8_t *keyCode, size_t keyCodeSize, uint8_t *key, size_t keySize);
- status_t PUF_GetHwKey(
- PUF_Type *base, const uint8_t *keyCode, size_t keyCodeSize, puf_key_slot_t keySlot, uint32_t keyMask);
- status_t PUF_Zeroize(PUF_Type *base);
- bool PUF_IsGetKeyAllowed(PUF_Type *base);
- static inline void PUF_BlockSetKey(PUF_Type *base)
- {
- base->CFG |= PUF_CFG_BLOCKKEYOUTPUT_MASK;
- }
- static inline void PUF_BlockEnroll(PUF_Type *base)
- {
- base->CFG |= PUF_CFG_BLOCKENROLL_SETKEY_MASK;
- }
- #if defined(__cplusplus)
- }
- #endif
- #endif
|