summaryrefslogtreecommitdiffstats
path: root/test/evp_libctx_test.c
diff options
context:
space:
mode:
authorJon Spillett <jon.spillett@oracle.com>2021-05-14 14:46:25 +1000
committerShane Lontis <shane.lontis@oracle.com>2021-05-26 07:27:25 +1000
commitb8c09a893c00588ea4e5ea615b9b0d117e952144 (patch)
tree087846a12e4f1d57a17850573e67ae11177f0be2 /test/evp_libctx_test.c
parent2710ddef6fdee65f0fc89c1e8698736f9317ed14 (diff)
Add special case to skip RC4 reinit
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/15276)
Diffstat (limited to 'test/evp_libctx_test.c')
-rw-r--r--test/evp_libctx_test.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/evp_libctx_test.c b/test/evp_libctx_test.c
index cb8b3b7fb4..1fcfdadeef 100644
--- a/test/evp_libctx_test.c
+++ b/test/evp_libctx_test.c
@@ -314,7 +314,7 @@ err:
static int test_cipher_reinit(int test_id)
{
- int ret = 0, diff, ccm, siv;
+ int ret = 0, diff, ccm, siv, no_null_key;
int out1_len = 0, out2_len = 0, out3_len = 0;
EVP_CIPHER *cipher = NULL;
EVP_CIPHER_CTX *ctx = NULL;
@@ -354,6 +354,14 @@ static int test_cipher_reinit(int test_id)
/* siv cannot be called with NULL key as the iv is irrelevant */
siv = (EVP_CIPHER_mode(cipher) == EVP_CIPH_SIV_MODE);
+ /*
+ * Skip init call with a null key for RC4 as the stream cipher does not
+ * handle reinit (1.1.1 behaviour).
+ */
+ no_null_key = EVP_CIPHER_is_a(cipher, "RC4")
+ || EVP_CIPHER_is_a(cipher, "RC4-40")
+ || EVP_CIPHER_is_a(cipher, "RC4-HMAC-MD5");
+
/* DES3-WRAP uses random every update - so it will give a different value */
diff = EVP_CIPHER_is_a(cipher, "DES3-WRAP");
@@ -362,9 +370,10 @@ static int test_cipher_reinit(int test_id)
|| !TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv))
|| !TEST_int_eq(EVP_EncryptUpdate(ctx, out2, &out2_len, in, sizeof(in)),
ccm ? 0 : 1)
- || !TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv))
+ || (!no_null_key
+ && (!TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv))
|| !TEST_int_eq(EVP_EncryptUpdate(ctx, out3, &out3_len, in, sizeof(in)),
- ccm || siv ? 0 : 1))
+ ccm || siv ? 0 : 1))))
goto err;
if (ccm == 0) {
@@ -375,7 +384,7 @@ static int test_cipher_reinit(int test_id)
goto err;
} else {
if (!TEST_mem_eq(out1, out1_len, out2, out2_len)
- || (!siv && !TEST_mem_eq(out1, out1_len, out3, out3_len)))
+ || (!siv && !no_null_key && !TEST_mem_eq(out1, out1_len, out3, out3_len)))
goto err;
}
}