diff options
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
| -rw-r--r-- | src/lib/libcrypto/evp/evp_lib.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c index 8070fa45ae..c96813987f 100644 --- a/src/lib/libcrypto/evp/evp_lib.c +++ b/src/lib/libcrypto/evp/evp_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp_lib.c,v 1.22 2022/01/07 11:13:54 tb Exp $ */ | 1 | /* $OpenBSD: evp_lib.c,v 1.23 2022/01/09 15:15:25 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -385,6 +385,35 @@ EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx) | |||
| 385 | return ctx->md_data; | 385 | return ctx->md_data; |
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | EVP_PKEY_CTX * | ||
| 389 | EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx) | ||
| 390 | { | ||
| 391 | return ctx->pctx; | ||
| 392 | } | ||
| 393 | |||
| 394 | void | ||
| 395 | EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx) | ||
| 396 | { | ||
| 397 | if (EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX)) { | ||
| 398 | EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX); | ||
| 399 | } else { | ||
| 400 | EVP_PKEY_CTX_free(ctx->pctx); | ||
| 401 | } | ||
| 402 | |||
| 403 | ctx->pctx = pctx; | ||
| 404 | |||
| 405 | if (pctx != NULL) { | ||
| 406 | /* | ||
| 407 | * For unclear reasons it was decided that the caller keeps | ||
| 408 | * ownership of pctx. So a flag was invented to make sure we | ||
| 409 | * don't free it in EVP_MD_CTX_cleanup(). We also need to | ||
| 410 | * unset it in EVP_MD_CTX_copy_ex(). Fortunately, the flag | ||
| 411 | * isn't public... | ||
| 412 | */ | ||
| 413 | EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX); | ||
| 414 | } | ||
| 415 | } | ||
| 416 | |||
| 388 | void | 417 | void |
| 389 | EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags) | 418 | EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags) |
| 390 | { | 419 | { |
