4343 #include <wolfcrypt/src/misc.c>
4444#endif
4545
46+ typedef enum nxp_hwpuf_keytype {
47+ nxp_hwpuf_keytype_user = 0 ,
48+ nxp_hwpuf_keytype_intrinsic = 1 ,
49+ nxp_hwpuf_keytype_max = nxp_hwpuf_keytype_intrinsic
50+ } nxp_hwpuf_keytype ;
51+
4652typedef struct nxp_hwpuf_ctx {
4753 word32 keyMask ; /* unique per reset */
4854} nxp_hwpuf_ctx ;
@@ -51,18 +57,8 @@ static nxp_hwpuf_ctx ctx;
5157static puf_config_t conf ;
5258
5359
54- static int getACFromPFR (byte * ac )
55- {
56- int ret ;
57- flash_config_t flashInstance ;
58-
59- memset (& flashInstance , 0 , sizeof (flash_config_t ));
60- FLASH_Init (& flashInstance );
61- FFR_Init (& flashInstance );
62-
63- ret = FFR_KeystoreGetAC (& flashInstance , ac );
64- return ret != kStatus_Success ;
65- }
60+ #define NXP_HWPUF_USER_KEY 0
61+ #define NXP_HWPUF_INTRINSIC_KEY 0
6662
6763static int keyCodeCheck (byte * keyCode , word32 * keytype ,
6864 word32 * keyidx , word32 * keysize )
@@ -71,16 +67,18 @@ static int keyCodeCheck(byte* keyCode, word32* keytype,
7167 * keyidx = keyCode [1 ];
7268 * keysize = keyCode [3 ] == 0 ? 512 : 8 * keyCode [3 ] ;
7369
74- if (* keytype >= 2 )
70+ if (* keytype > nxp_hwpuf_keytype_max )
7571 return 1 ;
76- if (* keyidx >= 16 )
72+ if (* keyidx > kPUF_KeyIndexMax )
7773 return 2 ;
7874 if ( !HWPUF_KEY_SIZE_IS_VALID (* keysize ) )
7975 return 3 ;
8076
8177 return 0 ;
8278}
8379
80+ static int nxp_rng_initialized = 0 ;
81+
8482static int nxp_hwpuf_Init (wc_HWPUF * hwpuf )
8583{
8684 WOLFSSL_ENTER ("nxp_hwpuf_Init" );
@@ -93,6 +91,10 @@ static int nxp_hwpuf_Init(wc_HWPUF* hwpuf)
9391 PUF_Deinit (PUF , & conf );
9492 return HWPUF_INIT_E ;
9593 }
94+ if (!nxp_rng_initialized ) {
95+ RNG_Init (RNG );
96+ nxp_rng_initialized = 1 ;
97+ }
9698 ctx .keyMask = RNG -> RANDOM_NUMBER ;
9799 return 0 ;
98100}
@@ -191,6 +193,12 @@ static int nxp_hwpuf_SetKey(wc_HWPUF* hwpuf, byte keyIdx,
191193 if (hwpuf == NULL )
192194 return BAD_FUNC_ARG ;
193195
196+ (void )keyIdx ;
197+ (void )key ;
198+ (void )keySz ;
199+ (void )keyCode ;
200+ (void )keyCodeSz ;
201+
194202 return CRYPTOCB_UNAVAILABLE ;
195203}
196204
@@ -255,12 +263,14 @@ static int nxp_hwpuf_Zeroize(wc_HWPUF* hwpuf)
255263 return 0 ;
256264}
257265
258- static int nxp_hwpuf_CryptoDevCb (int devId , wc_CryptoInfo * info , void * ctx )
266+ static int nxp_hwpuf_CryptoDevCb (int devId , wc_CryptoInfo * info , void * devCtx )
259267{
260268 int ret = CRYPTOCB_UNAVAILABLE ;
261269
262270 WOLFSSL_ENTER ("nxp_hwpuf_CryptoDevCb" );
263271
272+ (void )devCtx ;
273+
264274 if (info == NULL )
265275 return BAD_FUNC_ARG ;
266276 if (devId == INVALID_DEVID )
0 commit comments