summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorwangcheng <bangwangnj@163.com>2024-10-26 11:10:38 +0200
committerTomas Mraz <tomas@openssl.org>2024-11-20 14:12:53 +0100
commit4c41aa4b338ca181a394483c8bb6aeb6366c6f96 (patch)
treeb520cd03abb8bd591666f8ce3a8fcc4971b63f6f /include
parentx509_vfy.c and x509_lu.c: refactor find_issuer(), X509_STORE_CTX_get1_issuer(... (diff)
downloadopenssl-4c41aa4b338ca181a394483c8bb6aeb6366c6f96.tar.xz
openssl-4c41aa4b338ca181a394483c8bb6aeb6366c6f96.zip
Add CTX copy function for EVP_MD to optimize the performance of EVP_MD_CTX_copy_ex.
1. Add OSSL_FUNC_digest_copyctx_fn function for EVP_MD, which is used to copy algctx from the old EVP_MD_CTX to the new one. 2. Add implementation of OSSL_FUNC_digest_copyctx_fn function for default providers. 3. Modify EVP_MD_CTX_copy_ex: When the fetched digest is the same in in and out contexts, use the copy function to copy the members in EVP_MD_CTX if the OSSL_FUNC_digest_copyctx_fn function exists. Otherwise, use the previous method to copy. 4. Add documentation for OSSL_FUNC_digest_copyctx function in doc/man7/provider-digest.pod. 5. Add testcase. Fixes #25703 Signed-off-by: wangcheng <bangwangnj@163.com> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/25726)
Diffstat (limited to 'include')
-rw-r--r--include/crypto/evp.h1
-rw-r--r--include/openssl/core_dispatch.h2
2 files changed, 3 insertions, 0 deletions
diff --git a/include/crypto/evp.h b/include/crypto/evp.h
index 72d9995e8f..4775c05ecd 100644
--- a/include/crypto/evp.h
+++ b/include/crypto/evp.h
@@ -285,6 +285,7 @@ struct evp_md_st {
OSSL_FUNC_digest_squeeze_fn *dsqueeze;
OSSL_FUNC_digest_digest_fn *digest;
OSSL_FUNC_digest_freectx_fn *freectx;
+ OSSL_FUNC_digest_copyctx_fn *copyctx;
OSSL_FUNC_digest_dupctx_fn *dupctx;
OSSL_FUNC_digest_get_params_fn *get_params;
OSSL_FUNC_digest_set_ctx_params_fn *set_ctx_params;
diff --git a/include/openssl/core_dispatch.h b/include/openssl/core_dispatch.h
index 03838ddd0e..9243aa9ec1 100644
--- a/include/openssl/core_dispatch.h
+++ b/include/openssl/core_dispatch.h
@@ -305,6 +305,7 @@ OSSL_CORE_MAKE_FUNC(int, provider_self_test, (void *provctx))
# define OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS 12
# define OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS 13
# define OSSL_FUNC_DIGEST_SQUEEZE 14
+# define OSSL_FUNC_DIGEST_COPYCTX 15
OSSL_CORE_MAKE_FUNC(void *, digest_newctx, (void *provctx))
OSSL_CORE_MAKE_FUNC(int, digest_init, (void *dctx, const OSSL_PARAM params[]))
@@ -322,6 +323,7 @@ OSSL_CORE_MAKE_FUNC(int, digest_digest,
OSSL_CORE_MAKE_FUNC(void, digest_freectx, (void *dctx))
OSSL_CORE_MAKE_FUNC(void *, digest_dupctx, (void *dctx))
+OSSL_CORE_MAKE_FUNC(void, digest_copyctx, (void *outctx, void *inctx))
OSSL_CORE_MAKE_FUNC(int, digest_get_params, (OSSL_PARAM params[]))
OSSL_CORE_MAKE_FUNC(int, digest_set_ctx_params,