summaryrefslogtreecommitdiffstats
path: root/test/evp_extra_test.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-11-12 16:31:35 +0100
committerTomas Mraz <tomas@openssl.org>2021-11-15 09:25:42 +0100
commitbef9b48e5071cdd2b41a4f486d1bcb5e14b2a5c3 (patch)
tree1c519ac26b87291506e32ecd6719f32685b230e6 /test/evp_extra_test.c
parent293e251e6f0367a9aa0d3d46037b19d1a6c91b20 (diff)
Add null digest implementation to the default provider
This is necessary to keep compatibility with 1.1.1. Fixes #16660 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17016)
Diffstat (limited to 'test/evp_extra_test.c')
-rw-r--r--test/evp_extra_test.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index 8ac8a4299d..d026ef0c1c 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -1445,6 +1445,35 @@ static int test_EVP_Digest(void)
return ret;
}
+static int test_EVP_md_null(void)
+{
+ int ret = 0;
+ EVP_MD_CTX *md_ctx = NULL;
+ const EVP_MD *md_null = EVP_md_null();
+ unsigned char md_value[EVP_MAX_MD_SIZE];
+ unsigned int md_len = sizeof(md_value);
+
+ if (nullprov != NULL)
+ return TEST_skip("Test does not support a non-default library context");
+
+ if (!TEST_ptr(md_null)
+ || !TEST_ptr(md_ctx = EVP_MD_CTX_new()))
+ goto out;
+
+ if (!TEST_true(EVP_DigestInit_ex(md_ctx, md_null, NULL))
+ || !TEST_true(EVP_DigestUpdate(md_ctx, "test", 4))
+ || !TEST_true(EVP_DigestFinal_ex(md_ctx, md_value, &md_len)))
+ goto out;
+
+ if (!TEST_uint_eq(md_len, 0))
+ goto out;
+
+ ret = 1;
+ out:
+ EVP_MD_CTX_free(md_ctx);
+ return ret;
+}
+
static int test_d2i_AutoPrivateKey(int i)
{
int ret = 0;
@@ -4249,6 +4278,7 @@ int setup_tests(void)
ADD_TEST(test_siphash_digestsign);
#endif
ADD_TEST(test_EVP_Digest);
+ ADD_TEST(test_EVP_md_null);
ADD_ALL_TESTS(test_EVP_PKEY_sign, 3);
ADD_ALL_TESTS(test_EVP_Enveloped, 2);
ADD_ALL_TESTS(test_d2i_AutoPrivateKey, OSSL_NELEM(keydata));