From 816f72d08834ee35ba2615f624b4a29f2717d1c7 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Thu, 4 Nov 2021 15:35:40 +0100 Subject: [PATCH] test: Add testing of reinitialization via EVP_DigestSignInit() Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/16964) --- test/evp_extra_test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index a8ae3e44e0..6a323394b9 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -1143,6 +1143,7 @@ err: * Test 12: Use EVP_DigestSign (Implicit fetch digest, RSA) * Test 13: Use EVP_DigestSign (Implicit fetch digest, DSA) * Test 14: Use EVP_DigestSign (Implicit fetch digest, HMAC) + * Test 15-29: Same as above with reinitialization */ static int test_EVP_DigestSignInit(int tst) { @@ -1156,10 +1157,16 @@ static int test_EVP_DigestSignInit(int tst) size_t written; const EVP_MD *md; EVP_MD *mdexp = NULL; + int reinit = 0; if (nullprov != NULL) return TEST_skip("Test does not support a non-default library context"); + if (tst >= 15) { + reinit = 1; + tst -= 15; + } + if (tst >= 6 && tst <= 8) { membio = BIO_new(BIO_s_mem()); mdbio = BIO_new(BIO_f_md()); @@ -1198,6 +1205,9 @@ static int test_EVP_DigestSignInit(int tst) if (!TEST_true(EVP_DigestSignInit(md_ctx, NULL, md, NULL, pkey))) goto out; + if (reinit && !TEST_true(EVP_DigestSignInit(md_ctx, NULL, NULL, NULL, NULL))) + goto out; + if (tst >= 6 && tst <= 8) { if (!BIO_write_ex(mdbio, kMsg, sizeof(kMsg), &written)) goto out; @@ -4182,7 +4192,7 @@ int setup_tests(void) } ADD_TEST(test_EVP_set_default_properties); - ADD_ALL_TESTS(test_EVP_DigestSignInit, 15); + ADD_ALL_TESTS(test_EVP_DigestSignInit, 30); ADD_TEST(test_EVP_DigestVerifyInit); ADD_TEST(test_EVP_Digest); ADD_ALL_TESTS(test_EVP_PKEY_sign, 3);