From: Bernd Edlinger Date: Fri, 27 Aug 2021 11:11:39 +0000 (+0200) Subject: Fix the "Out of memory" EVP KDF scrypt test X-Git-Tag: openssl-3.0.0~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cce935b23ce2f7942e2ef4368dd93b60e21d3d83;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/16444) --- diff --git a/test/evp_test.c b/test/evp_test.c index 0009cae4425..075abc5ad93 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -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; } diff --git a/test/recipes/30-test_evp_data/evpkdf_scrypt.txt b/test/recipes/30-test_evp_data/evpkdf_scrypt.txt index 7aba716246d..64176091fc0 100644 --- a/test/recipes/30-test_evp_data/evpkdf_scrypt.txt +++ b/test/recipes/30-test_evp_data/evpkdf_scrypt.txt @@ -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 diff --git a/test/recipes/30-test_evp_data/evppkey_kdf_scrypt.txt b/test/recipes/30-test_evp_data/evppkey_kdf_scrypt.txt index 086451a44c5..1f7c06c6d4f 100644 --- a/test/recipes/30-test_evp_data/evppkey_kdf_scrypt.txt +++ b/test/recipes/30-test_evp_data/evppkey_kdf_scrypt.txt @@ -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