diff options
author | Peiwei Hu <jlu.hpw@foxmail.com> | 2022-05-28 23:46:33 +0800 |
---|---|---|
committer | Todd Short <todd.short@me.com> | 2022-06-02 10:54:14 -0400 |
commit | 6d5f63e57b7d7294b891b6de406d767468314dfe (patch) | |
tree | da8d58609f0bed2cc466bc74a6b27ba5d9aed971 /test | |
parent | 142e280924f8bcd4e86ddc539ac0687f2239373e (diff) |
Fix the checks of RAND_bytes
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)
(cherry picked from commit c2f7614fb7b93fe3792068077ff01384f42f39bc)
Diffstat (limited to 'test')
-rw-r--r-- | test/bad_dtls_test.c | 2 | ||||
-rw-r--r-- | test/drbgtest.c | 2 | ||||
-rw-r--r-- | test/ecdsatest.c | 2 | ||||
-rw-r--r-- | test/exptest.c | 6 | ||||
-rw-r--r-- | test/wpackettest.c | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/test/bad_dtls_test.c b/test/bad_dtls_test.c index f8c6b142d8..027ce8266d 100644 --- a/test/bad_dtls_test.c +++ b/test/bad_dtls_test.c @@ -331,7 +331,7 @@ static int send_record(BIO *rbio, unsigned char type, uint64_t seqnr, } while (len % 16); /* Generate IV, and encrypt */ - if (!TEST_true(RAND_bytes(iv, sizeof(iv))) + if (!TEST_int_gt(RAND_bytes(iv, sizeof(iv)), 0) || !TEST_ptr(enc_ctx = EVP_CIPHER_CTX_new()) || !TEST_true(EVP_CipherInit_ex(enc_ctx, EVP_aes_128_cbc(), NULL, enc_key, iv, 1)) diff --git a/test/drbgtest.c b/test/drbgtest.c index a6fd46595a..8af64d23b0 100644 --- a/test/drbgtest.c +++ b/test/drbgtest.c @@ -531,7 +531,7 @@ static int test_rand_fork_safety(int i) success = 0; /* request a single byte from each of the DRBGs before the next run */ - if (!TEST_true(RAND_bytes(random, 1) && RAND_priv_bytes(random, 1))) + if (!TEST_int_gt(RAND_bytes(random, 1), 0) || !TEST_int_gt(RAND_priv_bytes(random, 1), 0)) success = 0; return success; diff --git a/test/ecdsatest.c b/test/ecdsatest.c index 282b9660d3..0baeb89230 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -223,7 +223,7 @@ static int test_builtin(int n, int as) if (!TEST_ptr(mctx = EVP_MD_CTX_new()) /* get some random message data */ - || !TEST_true(RAND_bytes(tbs, sizeof(tbs))) + || !TEST_int_gt(RAND_bytes(tbs, sizeof(tbs)), 0) /* real key */ || !TEST_ptr(eckey = EC_KEY_new_by_curve_name(nid)) || !TEST_true(EC_KEY_generate_key(eckey)) diff --git a/test/exptest.c b/test/exptest.c index 84d972afe3..c2acc40bcd 100644 --- a/test/exptest.c +++ b/test/exptest.c @@ -144,21 +144,21 @@ static int test_mod_exp(int round) || !TEST_ptr(m = BN_new())) goto err; - if (!TEST_true(RAND_bytes(&c, 1))) + if (!TEST_int_gt(RAND_bytes(&c, 1), 0)) goto err; c = (c % BN_BITS) - BN_BITS2; if (!TEST_true(BN_rand(a, NUM_BITS + c, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))) goto err; - if (!TEST_true(RAND_bytes(&c, 1))) + if (!TEST_int_gt(RAND_bytes(&c, 1), 0)) goto err; c = (c % BN_BITS) - BN_BITS2; if (!TEST_true(BN_rand(b, NUM_BITS + c, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))) goto err; - if (!TEST_true(RAND_bytes(&c, 1))) + if (!TEST_int_gt(RAND_bytes(&c, 1), 0)) goto err; c = (c % BN_BITS) - BN_BITS2; if (!TEST_true(BN_rand(m, NUM_BITS + c, BN_RAND_TOP_ONE, diff --git a/test/wpackettest.c b/test/wpackettest.c index b03dfcd2e0..8adac25bd5 100644 --- a/test/wpackettest.c +++ b/test/wpackettest.c @@ -386,7 +386,7 @@ static int test_WPACKET_init_der(void) return cleanup(&pkt); /* Generate random packet data for test */ - if (!TEST_true(RAND_bytes(&testdata2[3], sizeof(testdata2) - 3))) + if (!TEST_int_gt(RAND_bytes(&testdata2[3], sizeof(testdata2) - 3), 0)) return 0; /* |