diff options
author | Pauli <pauli@openssl.org> | 2022-01-07 11:46:33 +1100 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2022-01-19 21:50:22 +1100 |
commit | 4e62f1a3af36512a1f5e1273d2dc54e3ce7f5fca (patch) | |
tree | 5a490d1c6cfcda784c86704d0026cf1686696ae4 /crypto | |
parent | 2c9da416a608e2aaf19c16d920baddf2473c8392 (diff) |
Add context dup functions for digests and ciphers
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17529)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/digest.c | 11 | ||||
-rw-r--r-- | crypto/evp/evp_enc.c | 11 |
2 files changed, 22 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)) { |