[openssl] OpenSSL_1_1_1-stable update
matthias.st.pierre at ncp-e.com
matthias.st.pierre at ncp-e.com
Wed Jul 22 23:17:55 UTC 2020
The branch OpenSSL_1_1_1-stable has been updated
via 72a9868fe53e01bfe912a56b56e4474ff6e0a063 (commit)
from 48fc6cd59c6d4a8f6ecd57d85d6ef4e6373ff147 (commit)
- Log -----------------------------------------------------------------
commit 72a9868fe53e01bfe912a56b56e4474ff6e0a063
Author: Vitezslav Cizek <vcizek at suse.com>
Date: Fri Jul 10 21:33:00 2020 +0200
test/drbgtest.c: Fix error check test
The condition in test_error_checks() was inverted, so the test succeeded
as long as error_check() failed. Incidently, error_check() contained
several bugs that assured it always failed, thus giving overall drbg
test success.
Remove the broken explicit zero check.
RAND_DRBG_uninstantiate() cleanses the data via drbg_ctr_uninstantiate(),
but right after that it resets drbg->data.ctr using RAND_DRBG_set(),
so TEST_mem_eq(zero, sizeof(drbg->data)) always failed.
(backport from https://github.com/openssl/openssl/pull/11195)
Signed-off-by: Vitezslav Cizek <vcizek at suse.com>
Reviewed-by: Paul Dale <paul.dale at oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12517)
-----------------------------------------------------------------------
Summary of changes:
test/drbgtest.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/test/drbgtest.c b/test/drbgtest.c
index 2aff4aaf03..be001ee18e 100644
--- a/test/drbgtest.c
+++ b/test/drbgtest.c
@@ -286,7 +286,6 @@ static int instantiate(RAND_DRBG *drbg, DRBG_SELFTEST_DATA *td,
*/
static int error_check(DRBG_SELFTEST_DATA *td)
{
- static char zero[sizeof(RAND_DRBG)];
RAND_DRBG *drbg = NULL;
TEST_CTX t;
unsigned char buff[1024];
@@ -302,7 +301,7 @@ static int error_check(DRBG_SELFTEST_DATA *td)
/* Test detection of too large personalisation string */
if (!init(drbg, td, &t)
- || RAND_DRBG_instantiate(drbg, td->pers, drbg->max_perslen + 1) > 0)
+ || !TEST_false(RAND_DRBG_instantiate(drbg, td->pers, drbg->max_perslen + 1)))
goto err;
/*
@@ -311,7 +310,7 @@ static int error_check(DRBG_SELFTEST_DATA *td)
/* Test entropy source failure detection: i.e. returns no data */
t.entropylen = 0;
- if (TEST_int_le(RAND_DRBG_instantiate(drbg, td->pers, td->perslen), 0))
+ if (!TEST_false(RAND_DRBG_instantiate(drbg, td->pers, td->perslen)))
goto err;
/* Try to generate output from uninstantiated DRBG */
@@ -321,16 +320,18 @@ static int error_check(DRBG_SELFTEST_DATA *td)
goto err;
/* Test insufficient entropy */
+ if (!init(drbg, td, &t))
+ goto err;
t.entropylen = drbg->min_entropylen - 1;
- if (!init(drbg, td, &t)
- || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
+ if (!TEST_false(RAND_DRBG_instantiate(drbg, td->pers, td->perslen))
|| !uninstantiate(drbg))
goto err;
/* Test too much entropy */
+ if (!init(drbg, td, &t))
+ goto err;
t.entropylen = drbg->max_entropylen + 1;
- if (!init(drbg, td, &t)
- || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
+ if (!TEST_false(RAND_DRBG_instantiate(drbg, td->pers, td->perslen))
|| !uninstantiate(drbg))
goto err;
@@ -340,18 +341,20 @@ static int error_check(DRBG_SELFTEST_DATA *td)
/* Test too small nonce */
if (drbg->min_noncelen) {
+ if (!init(drbg, td, &t))
+ goto err;
t.noncelen = drbg->min_noncelen - 1;
- if (!init(drbg, td, &t)
- || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
+ if (!TEST_false(RAND_DRBG_instantiate(drbg, td->pers, td->perslen))
|| !uninstantiate(drbg))
goto err;
}
/* Test too large nonce */
if (drbg->max_noncelen) {
+ if (!init(drbg, td, &t))
+ goto err;
t.noncelen = drbg->max_noncelen + 1;
- if (!init(drbg, td, &t)
- || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
+ if (!TEST_false(RAND_DRBG_instantiate(drbg, td->pers, td->perslen))
|| !uninstantiate(drbg))
goto err;
}
@@ -377,7 +380,7 @@ static int error_check(DRBG_SELFTEST_DATA *td)
* failure.
*/
t.entropylen = 0;
- if (TEST_false(RAND_DRBG_generate(drbg, buff, td->exlen, 1,
+ if (!TEST_false(RAND_DRBG_generate(drbg, buff, td->exlen, 1,
td->adin, td->adinlen))
|| !uninstantiate(drbg))
goto err;
@@ -428,12 +431,12 @@ static int error_check(DRBG_SELFTEST_DATA *td)
/* Test explicit reseed with too large additional input */
if (!instantiate(drbg, td, &t)
- || RAND_DRBG_reseed(drbg, td->adin, drbg->max_adinlen + 1, 0) > 0)
+ || !TEST_false(RAND_DRBG_reseed(drbg, td->adin, drbg->max_adinlen + 1, 0)))
goto err;
/* Test explicit reseed with entropy source failure */
t.entropylen = 0;
- if (!TEST_int_le(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0), 0)
+ if (!TEST_false(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0))
|| !uninstantiate(drbg))
goto err;
@@ -441,7 +444,7 @@ static int error_check(DRBG_SELFTEST_DATA *td)
if (!instantiate(drbg, td, &t))
goto err;
t.entropylen = drbg->max_entropylen + 1;
- if (!TEST_int_le(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0), 0)
+ if (!TEST_false(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0))
|| !uninstantiate(drbg))
goto err;
@@ -449,14 +452,10 @@ static int error_check(DRBG_SELFTEST_DATA *td)
if (!instantiate(drbg, td, &t))
goto err;
t.entropylen = drbg->min_entropylen - 1;
- if (!TEST_int_le(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0), 0)
+ if (!TEST_false(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0))
|| !uninstantiate(drbg))
goto err;
- /* Standard says we have to check uninstantiate really zeroes */
- if (!TEST_mem_eq(zero, sizeof(drbg->data), &drbg->data, sizeof(drbg->data)))
- goto err;
-
ret = 1;
err:
@@ -483,7 +482,7 @@ static int test_error_checks(int i)
DRBG_SELFTEST_DATA *td = &drbg_test[i];
int rv = 0;
- if (error_check(td))
+ if (!error_check(td))
goto err;
rv = 1;
More information about the openssl-commits
mailing list