summaryrefslogtreecommitdiffstats
path: root/test/evp_extra_test.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-05-20 16:31:33 +0200
committerTomas Mraz <tomas@openssl.org>2022-05-23 08:50:42 +0200
commit091e60c42c5d2a194936da7f4de3ce82527b27a3 (patch)
treecb1f7beb62829036db43f78fb3480cb92f22181d /test/evp_extra_test.c
parent7a9e93dda58118c0fb1bade8fe915306b845325b (diff)
Test the default key length of the Blowfish ciphers
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18362)
Diffstat (limited to 'test/evp_extra_test.c')
-rw-r--r--test/evp_extra_test.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index c44b60ce3c..48b01cf72a 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -3267,6 +3267,31 @@ err:
}
#endif
+#ifndef OPENSSL_NO_BF
+static int test_evp_bf_default_keylen(int idx)
+{
+ int ret = 0;
+ static const char *algos[4] = {
+ "bf-ecb", "bf-cbc", "bf-cfb", "bf-ofb"
+ };
+ int ivlen[4] = { 0, 8, 8, 8 };
+ EVP_CIPHER *cipher = NULL;
+
+ if (lgcyprov == NULL)
+ return TEST_skip("Test requires legacy provider to be loaded");
+
+ if (!TEST_ptr(cipher = EVP_CIPHER_fetch(testctx, algos[idx], testpropq))
+ || !TEST_int_eq(EVP_CIPHER_get_key_length(cipher), 16)
+ || !TEST_int_eq(EVP_CIPHER_get_iv_length(cipher), ivlen[idx]))
+ goto err;
+
+ ret = 1;
+err:
+ EVP_CIPHER_free(cipher);
+ return ret;
+}
+#endif
+
#ifndef OPENSSL_NO_EC
static int ecpub_nids[] = {
NID_brainpoolP256r1, NID_X9_62_prime256v1,
@@ -4558,6 +4583,9 @@ int setup_tests(void)
#ifndef OPENSSL_NO_DES
ADD_ALL_TESTS(test_evp_iv_des, 6);
#endif
+#ifndef OPENSSL_NO_BF
+ ADD_ALL_TESTS(test_evp_bf_default_keylen, 4);
+#endif
ADD_TEST(test_EVP_rsa_pss_with_keygen_bits);
ADD_TEST(test_EVP_rsa_pss_set_saltlen);
#ifndef OPENSSL_NO_EC