Fix the "Out of memory" EVP KDF scrypt test

This test did not really execute, since usually
the OPENSSL_malloc(0) will fail and prevent the
execution of the KDF.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16444)
This commit is contained in:
Bernd Edlinger 2021-08-27 13:11:39 +02:00
parent 20b39175b5
commit cce935b23c
3 changed files with 4 additions and 4 deletions

View File

@ -2664,7 +2664,7 @@ static int kdf_test_run(EVP_TEST *t)
t->err = "KDF_CTRL_ERROR";
return 1;
}
if (!TEST_ptr(got = OPENSSL_malloc(got_len))) {
if (!TEST_ptr(got = OPENSSL_malloc(got_len == 0 ? 1 : got_len))) {
t->err = "INTERNAL_ERROR";
goto err;
}
@ -2760,7 +2760,7 @@ static int pkey_kdf_test_run(EVP_TEST *t)
unsigned char *got = NULL;
size_t got_len = expected->output_len;
if (!TEST_ptr(got = OPENSSL_malloc(got_len))) {
if (!TEST_ptr(got = OPENSSL_malloc(got_len == 0 ? 1 : got_len))) {
t->err = "INTERNAL_ERROR";
goto err;
}

View File

@ -60,4 +60,4 @@ Ctrl.salt = salt:SodiumChloride
Ctrl.N = n:1048576
Ctrl.r = r:8
Ctrl.p = p:1
Result = INTERNAL_ERROR
Result = KDF_MISMATCH

View File

@ -60,4 +60,4 @@ Ctrl.salt = salt:SodiumChloride
Ctrl.N = N:1048576
Ctrl.r = r:8
Ctrl.p = p:1
Result = INTERNAL_ERROR
Result = KDF_MISMATCH