diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/evp/digest.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c index 0623ddf1f0..b22eed4421 100644 --- a/src/lib/libcrypto/evp/digest.c +++ b/src/lib/libcrypto/evp/digest.c | |||
| @@ -248,7 +248,6 @@ int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in) | |||
| 248 | 248 | ||
| 249 | int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) | 249 | int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) |
| 250 | { | 250 | { |
| 251 | unsigned char *tmp_buf; | ||
| 252 | if ((in == NULL) || (in->digest == NULL)) | 251 | if ((in == NULL) || (in->digest == NULL)) |
| 253 | { | 252 | { |
| 254 | EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED); | 253 | EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED); |
| @@ -263,22 +262,15 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) | |||
| 263 | } | 262 | } |
| 264 | #endif | 263 | #endif |
| 265 | 264 | ||
| 266 | if (out->digest == in->digest) | ||
| 267 | { | ||
| 268 | tmp_buf = out->md_data; | ||
| 269 | EVP_MD_CTX_set_flags(out,EVP_MD_CTX_FLAG_REUSE); | ||
| 270 | } | ||
| 271 | else tmp_buf = NULL; | ||
| 272 | EVP_MD_CTX_cleanup(out); | 265 | EVP_MD_CTX_cleanup(out); |
| 273 | memcpy(out,in,sizeof *out); | 266 | memcpy(out,in,sizeof *out); |
| 274 | 267 | ||
| 275 | if (out->digest->ctx_size) | 268 | if (out->digest->ctx_size) |
| 276 | { | 269 | { |
| 277 | if (tmp_buf) out->md_data = tmp_buf; | 270 | out->md_data=OPENSSL_malloc(out->digest->ctx_size); |
| 278 | else out->md_data=OPENSSL_malloc(out->digest->ctx_size); | ||
| 279 | memcpy(out->md_data,in->md_data,out->digest->ctx_size); | 271 | memcpy(out->md_data,in->md_data,out->digest->ctx_size); |
| 280 | } | 272 | } |
| 281 | 273 | ||
| 282 | if (out->digest->copy) | 274 | if (out->digest->copy) |
| 283 | return out->digest->copy(out,in); | 275 | return out->digest->copy(out,in); |
| 284 | 276 | ||
| @@ -316,8 +308,7 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) | |||
| 316 | if (ctx->digest && ctx->digest->cleanup | 308 | if (ctx->digest && ctx->digest->cleanup |
| 317 | && !EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED)) | 309 | && !EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED)) |
| 318 | ctx->digest->cleanup(ctx); | 310 | ctx->digest->cleanup(ctx); |
| 319 | if (ctx->digest && ctx->digest->ctx_size && ctx->md_data | 311 | if (ctx->digest && ctx->digest->ctx_size && ctx->md_data) |
| 320 | && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) | ||
| 321 | { | 312 | { |
| 322 | OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size); | 313 | OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size); |
| 323 | OPENSSL_free(ctx->md_data); | 314 | OPENSSL_free(ctx->md_data); |
