diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2007-04-08 16:53:50 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2007-04-08 16:53:50 +0000 |
commit | baecb96e8a7d109cfbf816038abea45d1d6c78e3 (patch) | |
tree | 710667a93bcebd87f4fa9988cff5de3e5570d7c1 /crypto | |
parent | 6181f5e4046a2e1380bae1a9163e186a4d26df15 (diff) |
Fix digest signing so digest type is set after init.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/m_sigver.c | 17 |
1 files 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; } |