@@ -94,6 +94,41 @@ int test_wc_RNG_GenerateBlock_Reseed(void)
9494 return EXPECT_RESULT ();
9595}
9696
97+ int test_wc_RNG_ReseedBoundary (void )
98+ {
99+ EXPECT_DECLS ;
100+ #if defined(HAVE_HASHDRBG ) && !defined(CUSTOM_RAND_GENERATE_BLOCK ) && \
101+ !defined(HAVE_FIPS ) && !defined(HAVE_SELFTEST )
102+ WC_RNG rng ;
103+ struct DRBG_internal * drbg ;
104+ byte out [32 ];
105+ #ifdef WORD64_AVAILABLE
106+ word64 startCtr ;
107+ #else
108+ word32 startCtr ;
109+ #endif
110+
111+ XMEMSET (& rng , 0 , sizeof (WC_RNG ));
112+ ExpectIntEQ (wc_InitRng (& rng ), 0 );
113+
114+ drbg = (struct DRBG_internal * )rng .drbg ;
115+ if (drbg != NULL && rng .status == WC_DRBG_OK ) {
116+ startCtr = drbg -> reseedCtr ;
117+ ExpectIntEQ (wc_RNG_GenerateBlock (& rng , out , sizeof (out )), 0 );
118+ if (drbg -> reseedCtr == startCtr + 1 ) {
119+ drbg -> reseedCtr = WC_RESEED_INTERVAL - 1 ;
120+ ExpectIntEQ (wc_RNG_GenerateBlock (& rng , out , sizeof (out )), 0 );
121+ ExpectTrue (drbg -> reseedCtr == WC_RESEED_INTERVAL );
122+ ExpectIntEQ (wc_RNG_GenerateBlock (& rng , out , sizeof (out )), 0 );
123+ ExpectTrue (drbg -> reseedCtr == 2 );
124+ }
125+ }
126+
127+ DoExpectIntEQ (wc_FreeRng (& rng ), 0 );
128+ #endif
129+ return EXPECT_RESULT ();
130+ }
131+
97132int test_wc_RNG_GenerateBlock (void )
98133{
99134 EXPECT_DECLS ;
0 commit comments