diff options
Diffstat (limited to 'crypto/evp/digest.c')
-rw-r--r-- | crypto/evp/digest.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index a269bb8260..d3a28fa351 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -509,11 +509,20 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) { unsigned char *tmp_buf; - if (in == NULL || in->digest == NULL) { - ERR_raise(ERR_LIB_EVP, EVP_R_INPUT_NOT_INITIALIZED); + if (in == NULL) { + ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER); return 0; } + if (in->digest == NULL) { + /* copying uninitialized digest context */ + EVP_MD_CTX_reset(out); + if (out->fetched_digest != NULL) + EVP_MD_free(out->fetched_digest); + *out = *in; + return 1; + } + if (in->digest->prov == NULL || (in->flags & EVP_MD_CTX_FLAG_NO_INIT) != 0) goto legacy; |