Fix: drbgtest fails when tests are executed in random order
[extended tests]
The test_rand_reseed assumed that the global DRBGs were not used
previously. This assumption is false when the tests are executed
in random order (OPENSSL_TEST_RAND_ORDER). So we uninstantiate
them first and add a test for the first instantiation.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5680)
Dr. Matthias St. Pierre authored 6 years ago
Matt Caswell committed 6 years ago
690 | 690 | || !TEST_ptr_eq(private->parent, master)) |
691 | 691 | return 0; |
692 | 692 | |
693 | /* uninstantiate the three global DRBGs */ | |
694 | RAND_DRBG_uninstantiate(private); | |
695 | RAND_DRBG_uninstantiate(public); | |
696 | RAND_DRBG_uninstantiate(master); | |
697 | ||
698 | ||
693 | 699 | /* Install hooks for the following tests */ |
694 | 700 | hook_drbg(master, &master_ctx); |
695 | 701 | hook_drbg(public, &public_ctx); |
696 | 702 | hook_drbg(private, &private_ctx); |
697 | 703 | |
698 | /* | |
699 | * Test initial state of shared DRBs | |
704 | ||
705 | /* | |
706 | * Test initial seeding of shared DRBGs | |
707 | */ | |
708 | if (!TEST_true(test_drbg_reseed(1, master, public, private, 1, 1, 1))) | |
709 | goto error; | |
710 | reset_drbg_hook_ctx(); | |
711 | ||
712 | ||
713 | /* | |
714 | * Test initial state of shared DRBGs | |
700 | 715 | */ |
701 | 716 | if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 0))) |
702 | 717 | goto error; |