@@ -324,6 +324,7 @@ static int32_t test_reseed(void)
324
324
uint8_t output [32 ];
325
325
TCCtrPrng_t ctx ;
326
326
int32_t ret ;
327
+ uint32_t i ;
327
328
328
329
(void )tc_ctr_prng_init (& ctx , entropy , sizeof entropy , 0 , 0U );
329
330
@@ -362,6 +363,59 @@ static int32_t test_reseed(void)
362
363
goto exitTest ;
363
364
}
364
365
366
+ /* confirm entropy and additional_input are being used correctly */
367
+ /* first, entropy only */
368
+ memset (& ctx , 0x0 , sizeof ctx );
369
+ for (i = 0U ; i < sizeof entropy ; i ++ )
370
+ {
371
+ entropy [i ] = i ;
372
+ }
373
+ ret = tc_ctr_prng_reseed (& ctx , entropy , sizeof entropy , 0 , 0U );
374
+ if (1 != ret )
375
+ {
376
+ result = TC_FAIL ;
377
+ goto exitTest ;
378
+ }
379
+ {
380
+ uint8_t expectedV [] =
381
+ {0x7EU , 0xE3U , 0xA0U , 0xCBU , 0x6DU , 0x5CU , 0x4BU , 0xC2U ,
382
+ 0x4BU , 0x7EU , 0x3CU , 0x48U , 0x88U , 0xC3U , 0x69U , 0x70U };
383
+ for (i = 0U ; i < sizeof expectedV ; i ++ )
384
+ {
385
+ if (ctx .V [i ] != expectedV [i ])
386
+ {
387
+ result = TC_FAIL ;
388
+ goto exitTest ;
389
+ }
390
+ }
391
+ }
392
+
393
+ /* now, entropy and additional_input */
394
+ memset (& ctx , 0x0 , sizeof ctx );
395
+ for (i = 0U ; i < sizeof additional_input ; i ++ )
396
+ {
397
+ additional_input [i ] = i * 2U ;
398
+ }
399
+ ret = tc_ctr_prng_reseed (& ctx , entropy , sizeof entropy , additional_input , sizeof additional_input );
400
+ if (1 != ret )
401
+ {
402
+ result = TC_FAIL ;
403
+ goto exitTest ;
404
+ }
405
+ {
406
+ uint8_t expectedV [] =
407
+ {0x5EU , 0xC1U , 0x84U , 0xEDU , 0x45U , 0x76U , 0x67U , 0xECU ,
408
+ 0x7BU , 0x4CU , 0x08U , 0x7EU , 0xB0U , 0xF9U , 0x55U , 0x4EU };
409
+ for (i = 0U ; i < sizeof expectedV ; i ++ )
410
+ {
411
+ if (ctx .V [i ] != expectedV [i ])
412
+ {
413
+ result = TC_FAIL ;
414
+ goto exitTest ;
415
+ }
416
+ }
417
+ }
418
+
365
419
exitTest :
366
420
if (TC_FAIL == result )
367
421
{
0 commit comments