summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2021-08-27 13:11:39 +0200
committerBernd Edlinger <bernd.edlinger@hotmail.de>2021-08-28 16:45:38 +0200
commitcce935b23ce2f7942e2ef4368dd93b60e21d3d83 (patch)
treee5195f31aa259a7940b74ed13e6bbde46bb36bc5
parent20b39175b59b5ae83223bbb9f743c73ae822d681 (diff)
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)
-rw-r--r--test/evp_test.c4
-rw-r--r--test/recipes/30-test_evp_data/evpkdf_scrypt.txt2
-rw-r--r--test/recipes/30-test_evp_data/evppkey_kdf_scrypt.txt2
3 files changed, 4 insertions, 4 deletions
diff --git a/test/evp_test.c b/test/evp_test.c
index 0009cae442..075abc5ad9 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 7aba716246..64176091fc 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 086451a44c..1f7c06c6d4 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