summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/evp/digest.c11
-rw-r--r--crypto/evp/evp_enc.c11
-rw-r--r--include/openssl/evp.h2
-rw-r--r--util/libcrypto.num2
4 files changed, 26 insertions, 0 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index d4685e6489..db2eed6355 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -505,6 +505,17 @@ legacy:
return ret;
}
+EVP_MD_CTX *EVP_MD_CTX_dup(const EVP_MD_CTX *in)
+{
+ EVP_MD_CTX *out = EVP_MD_CTX_new();
+
+ if (out != NULL && !EVP_MD_CTX_copy_ex(out, in)) {
+ EVP_MD_CTX_free(out);
+ out = NULL;
+ }
+ return out;
+}
+
int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
{
EVP_MD_CTX_reset(out);
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 519cab3f2b..1c02cafa16 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -1346,6 +1346,17 @@ int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
#endif /* FIPS_MODULE */
}
+EVP_CIPHER_CTX *EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in)
+{
+ EVP_CIPHER_CTX *out = EVP_CIPHER_CTX_new();
+
+ if (out != NULL && !EVP_CIPHER_CTX_copy(out, in)) {
+ EVP_CIPHER_CTX_free(out);
+ out = NULL;
+ }
+ return out;
+}
+
int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
{
if ((in == NULL) || (in->cipher == NULL)) {
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index be57127e36..ae8ddbcf41 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -634,6 +634,7 @@ unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_get_num(const EVP_CIPHER_CTX *ctx);
# define EVP_CIPHER_CTX_num EVP_CIPHER_CTX_get_num
int EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num);
+EVP_CIPHER_CTX *EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in);
int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
@@ -699,6 +700,7 @@ void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
# define EVP_MD_CTX_create() EVP_MD_CTX_new()
# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
+__owur EVP_MD_CTX *EVP_MD_CTX_dup(const EVP_MD_CTX *in);
__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 681cbf31b0..762e23a858 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -5426,3 +5426,5 @@ ASN1_TIME_print_ex 5553 3_0_0 EXIST::FUNCTION:
EVP_PKEY_get0_provider 5554 3_0_0 EXIST::FUNCTION:
EVP_PKEY_CTX_get0_provider 5555 3_0_0 EXIST::FUNCTION:
OSSL_STACK_OF_X509_free ? 3_1_0 EXIST::FUNCTION:
+EVP_MD_CTX_dup ? 3_1_0 EXIST::FUNCTION:
+EVP_CIPHER_CTX_dup ? 3_1_0 EXIST::FUNCTION: