diff options
author | jsing <> | 2024-03-27 03:05:59 +0000 |
---|---|---|
committer | jsing <> | 2024-03-27 03:05:59 +0000 |
commit | 76ab412c4bf0a80924205a270be9e3cf5d65190f (patch) | |
tree | f4b361735e56ed005c16202fc3ddcac09fcb7b82 /src/lib | |
parent | 8d703ebb40c321a34627b32dd8d4803f0dbb4bb5 (diff) | |
download | openbsd-76ab412c4bf0a80924205a270be9e3cf5d65190f.tar.gz openbsd-76ab412c4bf0a80924205a270be9e3cf5d65190f.tar.bz2 openbsd-76ab412c4bf0a80924205a270be9e3cf5d65190f.zip |
Revert to r1.19 while we track down a bug in the last two commits.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/evp/m_sigver.c | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/src/lib/libcrypto/evp/m_sigver.c b/src/lib/libcrypto/evp/m_sigver.c index eea2de49e5..9472999417 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.21 2024/03/27 01:55:40 joshua Exp $ */ | 1 | /* $OpenBSD: m_sigver.c,v 1.22 2024/03/27 03:05:59 jsing 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 | */ |
@@ -166,52 +166,43 @@ int | |||
166 | EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) | 166 | EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) |
167 | { | 167 | { |
168 | EVP_PKEY_CTX *pctx = ctx->pctx; | 168 | EVP_PKEY_CTX *pctx = ctx->pctx; |
169 | EVP_MD_CTX *md_ctx = NULL; | 169 | int r = 0; |
170 | unsigned char md[EVP_MAX_MD_SIZE]; | ||
171 | unsigned int mdlen = 0; | ||
172 | int s; | ||
173 | int ret = 0; | ||
174 | 170 | ||
175 | if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) | 171 | if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) |
176 | return evp_digestsignfinal_sigctx_custom(ctx, sigret, siglen); | 172 | return evp_digestsignfinal_sigctx_custom(ctx, sigret, siglen); |
177 | 173 | ||
178 | if (sigret == NULL) { | 174 | if (sigret) { |
175 | EVP_MD_CTX tmp_ctx; | ||
176 | unsigned char md[EVP_MAX_MD_SIZE]; | ||
177 | unsigned int mdlen = 0; | ||
178 | EVP_MD_CTX_legacy_clear(&tmp_ctx); | ||
179 | if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) | ||
180 | return 0; | ||
181 | if (ctx->pctx->pmeth->signctx != NULL) { | ||
182 | r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx, | ||
183 | sigret, siglen, &tmp_ctx); | ||
184 | EVP_MD_CTX_cleanup(&tmp_ctx); | ||
185 | return r; | ||
186 | } | ||
187 | r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); | ||
188 | EVP_MD_CTX_cleanup(&tmp_ctx); | ||
189 | if (!r) | ||
190 | return r; | ||
191 | if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0) | ||
192 | return 0; | ||
193 | } else { | ||
179 | if (ctx->pctx->pmeth->signctx != NULL) { | 194 | if (ctx->pctx->pmeth->signctx != NULL) { |
180 | if (ctx->pctx->pmeth->signctx(ctx->pctx, NULL, | 195 | if (ctx->pctx->pmeth->signctx(ctx->pctx, sigret, |
181 | siglen, ctx) <= 0) | 196 | siglen, ctx) <= 0) |
182 | return 0; | 197 | return 0; |
183 | return 1; | 198 | } else { |
199 | int s = EVP_MD_size(ctx->digest); | ||
200 | if (s < 0 || EVP_PKEY_sign(ctx->pctx, sigret, siglen, | ||
201 | NULL, s) <= 0) | ||
202 | return 0; | ||
184 | } | 203 | } |
185 | |||
186 | if ((s = EVP_MD_size(ctx->digest)) < 0) | ||
187 | return 0; | ||
188 | if (EVP_PKEY_sign(ctx->pctx, NULL, siglen, NULL, s) <= 0) | ||
189 | return 0; | ||
190 | |||
191 | return 1; | ||
192 | } | 204 | } |
193 | 205 | return 1; | |
194 | |||
195 | if ((md_ctx = EVP_MD_CTX_new()) == NULL) | ||
196 | goto err; | ||
197 | if (!EVP_MD_CTX_copy_ex(md_ctx, ctx)) | ||
198 | goto err; | ||
199 | if (md_ctx->pctx->pmeth->signctx != NULL) { | ||
200 | if(md_ctx->pctx->pmeth->signctx(md_ctx->pctx, | ||
201 | sigret, siglen, md_ctx) <= 0) | ||
202 | goto err; | ||
203 | } | ||
204 | if (!EVP_DigestFinal_ex(md_ctx, md, &mdlen)) | ||
205 | goto err; | ||
206 | if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0) | ||
207 | goto err; | ||
208 | |||
209 | ret = 1; | ||
210 | |||
211 | err: | ||
212 | EVP_MD_CTX_free(md_ctx); | ||
213 | |||
214 | return ret; | ||
215 | } | 206 | } |
216 | 207 | ||
217 | int | 208 | int |