diff options
Diffstat (limited to 'src/lib/libcrypto/evp/m_sigver.c')
| -rw-r--r-- | src/lib/libcrypto/evp/m_sigver.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/lib/libcrypto/evp/m_sigver.c b/src/lib/libcrypto/evp/m_sigver.c index 9e313c3630..f7dcaff418 100644 --- a/src/lib/libcrypto/evp/m_sigver.c +++ b/src/lib/libcrypto/evp/m_sigver.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_sigver.c,v 1.7 2018/05/13 06:35:10 tb Exp $ */ | 1 | /* $OpenBSD: m_sigver.c,v 1.8 2021/03/29 15:57:23 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -74,15 +74,17 @@ do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, | |||
| 74 | if (ctx->pctx == NULL) | 74 | if (ctx->pctx == NULL) |
| 75 | return 0; | 75 | return 0; |
| 76 | 76 | ||
| 77 | if (type == NULL) { | 77 | if (!(ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM)) { |
| 78 | int def_nid; | 78 | if (type == NULL) { |
| 79 | if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) > 0) | 79 | int def_nid; |
| 80 | type = EVP_get_digestbynid(def_nid); | 80 | if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) > 0) |
| 81 | } | 81 | type = EVP_get_digestbynid(def_nid); |
| 82 | } | ||
| 82 | 83 | ||
| 83 | if (type == NULL) { | 84 | if (type == NULL) { |
| 84 | EVPerror(EVP_R_NO_DEFAULT_DIGEST); | 85 | EVPerror(EVP_R_NO_DEFAULT_DIGEST); |
| 85 | return 0; | 86 | return 0; |
| 87 | } | ||
| 86 | } | 88 | } |
| 87 | 89 | ||
| 88 | if (ver) { | 90 | if (ver) { |
| @@ -105,6 +107,8 @@ do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, | |||
| 105 | return 0; | 107 | return 0; |
| 106 | if (pctx) | 108 | if (pctx) |
| 107 | *pctx = ctx->pctx; | 109 | *pctx = ctx->pctx; |
| 110 | if (ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) | ||
| 111 | return 1; | ||
| 108 | if (!EVP_DigestInit_ex(ctx, type, e)) | 112 | if (!EVP_DigestInit_ex(ctx, type, e)) |
| 109 | return 0; | 113 | return 0; |
| 110 | return 1; | 114 | return 1; |
| @@ -127,7 +131,24 @@ EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, | |||
| 127 | int | 131 | int |
| 128 | EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) | 132 | EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) |
| 129 | { | 133 | { |
| 130 | int sctx, r = 0; | 134 | EVP_PKEY_CTX *pctx = ctx->pctx; |
| 135 | int sctx; | ||
| 136 | int r = 0; | ||
| 137 | |||
| 138 | if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) { | ||
| 139 | EVP_PKEY_CTX *dctx; | ||
| 140 | |||
| 141 | if (sigret == NULL) | ||
| 142 | return pctx->pmeth->signctx(pctx, sigret, siglen, ctx); | ||
| 143 | |||
| 144 | /* XXX - support EVP_MD_CTX_FLAG_FINALISE? */ | ||
| 145 | if ((dctx = EVP_PKEY_CTX_dup(ctx->pctx)) == NULL) | ||
| 146 | return 0; | ||
| 147 | r = dctx->pmeth->signctx(dctx, sigret, siglen, ctx); | ||
| 148 | EVP_PKEY_CTX_free(dctx); | ||
| 149 | |||
| 150 | return r; | ||
| 151 | } | ||
| 131 | 152 | ||
| 132 | if (ctx->pctx->pmeth->signctx) | 153 | if (ctx->pctx->pmeth->signctx) |
| 133 | sctx = 1; | 154 | sctx = 1; |
