From: Tomas Mraz Date: Tue, 23 Nov 2021 15:01:28 +0000 (+0100) Subject: Add test for copying uninitialized EVP_MD_CTX X-Git-Tag: openssl-3.2.0-alpha1~3290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c86529fe1b9ade0794c6f557ca8936f0c0de431;p=thirdparty%2Fopenssl.git Add test for copying uninitialized EVP_MD_CTX Reviewed-by: Matt Caswell Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/17118) --- diff --git a/test/evp_extra_test2.c b/test/evp_extra_test2.c index 5be8bb5a404..b70c168d9db 100644 --- a/test/evp_extra_test2.c +++ b/test/evp_extra_test2.c @@ -853,6 +853,22 @@ static int test_rsa_pss_sign(void) return ret; } +static int test_evp_md_ctx_copy(void) +{ + EVP_MD_CTX *mdctx = NULL; + EVP_MD_CTX *copyctx = NULL; + int ret; + + /* test copying freshly initialized context */ + ret = TEST_ptr(mdctx = EVP_MD_CTX_new()) + && TEST_ptr(copyctx = EVP_MD_CTX_new()) + && TEST_true(EVP_MD_CTX_copy_ex(copyctx, mdctx)); + + EVP_MD_CTX_free(mdctx); + EVP_MD_CTX_free(copyctx); + return ret; +} + int setup_tests(void) { if (!test_get_libctx(&mainctx, &nullprov, NULL, NULL, NULL)) { @@ -879,6 +895,7 @@ int setup_tests(void) #endif ADD_ALL_TESTS(test_PEM_read_bio_negative, OSSL_NELEM(keydata)); ADD_TEST(test_rsa_pss_sign); + ADD_TEST(test_evp_md_ctx_copy); return 1; }