summaryrefslogtreecommitdiffstats
path: root/test/ecdsatest.c
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-02-27 02:57:13 +0100
committerPauli <ppzgs1@gmail.com>2021-03-02 04:23:17 +0100
commitfccdb61aee9538268e2eecfdc5b1e31327803ee4 (patch)
tree3324b768a6c049de3a9ff0a0f4308b0cd478b276 /test/ecdsatest.c
parenttest: update test_random to create real contexts instead of sharing one (diff)
downloadopenssl-fccdb61aee9538268e2eecfdc5b1e31327803ee4.tar.xz
openssl-fccdb61aee9538268e2eecfdc5b1e31327803ee4.zip
test: update ECDSA and SM2 internal tests in line with the fake_random change
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14341)
Diffstat (limited to 'test/ecdsatest.c')
-rw-r--r--test/ecdsatest.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/ecdsatest.c b/test/ecdsatest.c
index d03eb6f01e..cf09419c94 100644
--- a/test/ecdsatest.c
+++ b/test/ecdsatest.c
@@ -25,18 +25,21 @@
# include "internal/nelem.h"
# include "ecdsatest.h"
+static fake_random_generate_cb fbytes;
+
static const char *numbers[2];
static size_t crv_len = 0;
static EC_builtin_curve *curves = NULL;
static OSSL_PROVIDER *fake_rand = NULL;
-static int fbytes(unsigned char *buf, size_t num)
+static int fbytes(unsigned char *buf, size_t num, ossl_unused const char *name,
+ EVP_RAND_CTX *ctx)
{
int ret = 0;
static int fbytes_counter = 0;
BIGNUM *tmp = NULL;
- fake_rand_set_callback(NULL);
+ fake_rand_set_callback(ctx, NULL);
if (!TEST_ptr(tmp = BN_new())
|| !TEST_int_lt(fbytes_counter, OSSL_NELEM(numbers))
@@ -114,7 +117,7 @@ static int x9_62_tests(int n)
goto err;
/* public key must match KAT */
- fake_rand_set_callback(&fbytes);
+ fake_rand_set_callback(RAND_get0_private(NULL), &fbytes);
if (!TEST_true(EC_KEY_generate_key(key))
|| !TEST_true(p_len = EC_KEY_key2buf(key, POINT_CONVERSION_UNCOMPRESSED,
&pbuf, NULL))
@@ -124,7 +127,7 @@ static int x9_62_tests(int n)
goto err;
/* create the signature via ECDSA_sign_setup to avoid use of ECDSA nonces */
- fake_rand_set_callback(&fbytes);
+ fake_rand_set_callback(RAND_get0_private(NULL), &fbytes);
if (!TEST_true(ECDSA_sign_setup(key, NULL, &kinv, &rp))
|| !TEST_ptr(signature = ECDSA_do_sign_ex(digest, dgst_len,
kinv, rp, key))