@@ -172,6 +172,35 @@ static void random_scalar_order_b32(unsigned char *b32) {
172172 secp256k1_scalar_get_b32 (b32 , & num );
173173}
174174
175+ static void run_xoshiro256pp_tests (void ) {
176+ {
177+ size_t i ;
178+ /* Sanity check that we run before the actual seeding. */
179+ for (i = 0 ; i < sizeof (secp256k1_test_state )/sizeof (secp256k1_test_state [0 ]); i ++ ) {
180+ CHECK (secp256k1_test_state [i ] == 0 );
181+ }
182+ }
183+ {
184+ int i ;
185+ unsigned char buf32 [32 ];
186+ unsigned char seed16 [16 ] = {
187+ 'C' , 'H' , 'I' , 'C' , 'K' , 'E' , 'N' , '!' ,
188+ 'C' , 'H' , 'I' , 'C' , 'K' , 'E' , 'N' , '!' ,
189+ };
190+ unsigned char buf32_expected [32 ] = {
191+ 0xAF , 0xCC , 0xA9 , 0x16 , 0xB5 , 0x6C , 0xE3 , 0xF0 ,
192+ 0x44 , 0x3F , 0x45 , 0xE0 , 0x47 , 0xA5 , 0x08 , 0x36 ,
193+ 0x4C , 0xCC , 0xC1 , 0x18 , 0xB2 , 0xD8 , 0x8F , 0xEF ,
194+ 0x43 , 0x26 , 0x15 , 0x57 , 0x37 , 0x00 , 0xEF , 0x30 ,
195+ };
196+ secp256k1_testrand_seed (seed16 );
197+ for (i = 0 ; i < 17 ; i ++ ) {
198+ secp256k1_testrand256 (buf32 );
199+ }
200+ CHECK (secp256k1_memcmp_var (buf32 , buf32_expected , sizeof (buf32 )) == 0 );
201+ }
202+ }
203+
175204static void run_selftest_tests (void ) {
176205 /* Test public API */
177206 secp256k1_selftest ();
@@ -7621,6 +7650,9 @@ int main(int argc, char **argv) {
76217650 }
76227651 printf ("test count = %i\n" , COUNT );
76237652
7653+ /* run test RNG tests (must run before we really initialize the test RNG) */
7654+ run_xoshiro256pp_tests ();
7655+
76247656 /* find random seed */
76257657 secp256k1_testrand_init (argc > 2 ? argv [2 ] : NULL );
76267658
0 commit comments