Fix the "Out of memory" EVP KDF scrypt test
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 27 Aug 2021 11:11:39 +0000 (13:11 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Sat, 28 Aug 2021 14:45:38 +0000 (16:45 +0200)
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)

test/evp_test.c
test/recipes/30-test_evp_data/evpkdf_scrypt.txt
test/recipes/30-test_evp_data/evppkey_kdf_scrypt.txt

index 0009cae4425772251e81b428bceff4de60210280..075abc5ad93aa6e8a67889ffcf1846449c5f0963 100644 (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;
     }
index 7aba716246db3f671683529c30ceeb8aca64b5b4..64176091fc089ab88b9c765dfff7dfbccf0250e0 100644 (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
index 086451a44c569871c2b46f2eee8e3d3840c9dcaf..1f7c06c6d4f2e743274bf28b18514a330e904429 100644 (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