diff options
author | Matt Caswell <matt@openssl.org> | 2019-05-23 16:51:55 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2019-06-07 12:04:34 +0100 |
commit | 4e297b7441a070f9dd557445665365b4377e9498 (patch) | |
tree | dd38bcc49056319332f1bccbd6f13a93835f7eb3 /test | |
parent | da0d114cd962e89b2614f4707902c404acab7ebd (diff) |
Make the rand_crng code OPENSSL_CTX aware
This is in preparation for moving this code inside the FIPS module.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9039)
Diffstat (limited to 'test')
-rw-r--r-- | test/drbgtest.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/test/drbgtest.c b/test/drbgtest.c index 9e0aba83ab..618403fd3a 100644 --- a/test/drbgtest.c +++ b/test/drbgtest.c @@ -1264,7 +1264,8 @@ static const size_t crngt_num_cases = 6; static size_t crngt_case, crngt_idx; -static int crngt_entropy_cb(unsigned char *buf, unsigned char *md, +static int crngt_entropy_cb(OPENSSL_CTX *ctx, unsigned char *buf, + unsigned char *md, unsigned int *md_size) { size_t i, z; @@ -1288,19 +1289,16 @@ static int test_crngt(int n) size_t ent; int res = 0; int expect; + OPENSSL_CTX *ctx = OPENSSL_CTX_new(); - if (!TEST_true(rand_crngt_single_init())) - return 0; - rand_crngt_cleanup(); - - if (!TEST_ptr(drbg = RAND_DRBG_new(dt->nid, dt->flags, NULL))) + if (!TEST_ptr(ctx)) return 0; + if (!TEST_ptr(drbg = RAND_DRBG_new_ex(ctx, dt->nid, dt->flags, NULL))) + goto err; ent = (drbg->min_entropylen + CRNGT_BUFSIZ - 1) / CRNGT_BUFSIZ; crngt_case = n % crngt_num_cases; crngt_idx = 0; crngt_get_entropy = &crngt_entropy_cb; - if (!TEST_true(rand_crngt_init())) - goto err; #ifndef FIPS_MODE if (!TEST_true(RAND_DRBG_set_callbacks(drbg, &rand_crngt_get_entropy, &rand_crngt_cleanup_entropy, @@ -1333,6 +1331,7 @@ err: uninstantiate(drbg); RAND_DRBG_free(drbg); crngt_get_entropy = &rand_crngt_get_entropy_cb; + OPENSSL_CTX_free(ctx); return res; } |