From baecb96e8a7d109cfbf816038abea45d1d6c78e3 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sun, 8 Apr 2007 16:53:50 +0000 Subject: [PATCH] Fix digest signing so digest type is set after init. --- crypto/evp/m_sigver.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/crypto/evp/m_sigver.c b/crypto/evp/m_sigver.c index 4f9282d029..6ab71907ab 100644 --- a/crypto/evp/m_sigver.c +++ b/crypto/evp/m_sigver.c @@ -67,24 +67,18 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey, int ver) { + int r = 0; if (ctx->pctx == NULL) ctx->pctx = EVP_PKEY_CTX_new(pkey, e); if (ctx->pctx == NULL) return 0; - if (EVP_PKEY_CTX_set_signature_md(ctx->pctx, type) <= 0) - return 0; - if (pctx) - *pctx = ctx->pctx; if (ver) { if (ctx->pctx->pmeth->verifyctx_init) { - int r; r = ctx->pctx->pmeth->verifyctx_init(ctx->pctx, ctx); if (r <= 0) return 0; - if (r == 2) - return 1; } else if (EVP_PKEY_verify_init(ctx->pctx) <= 0) return 0; @@ -93,17 +87,18 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, { if (ctx->pctx->pmeth->signctx_init) { - int r; r = ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx); if (r <= 0) return 0; - if (r == 2) - return 1; } if (EVP_PKEY_sign_init(ctx->pctx) <= 0) return 0; } - if (!EVP_DigestInit_ex(ctx, type, e)) + if (EVP_PKEY_CTX_set_signature_md(ctx->pctx, type) <= 0) + return 0; + if (pctx) + *pctx = ctx->pctx; + if ((r != 2) && !EVP_DigestInit_ex(ctx, type, e)) return 0; return 1; } -- 2.25.1