diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-04-19 19:05:59 +0200 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-04-19 19:05:59 +0200 |
commit | ee1d9ec019a7584482bd95891404f1cad66a4a0a (patch) | |
tree | 54973962e56f5e576096c999be3b2bc3ca19c0fa /crypto/evp/p_verify.c | |
parent | Remove comment from SSLeay days about EVP_PKEY_METHOD. (diff) | |
download | openssl-ee1d9ec019a7584482bd95891404f1cad66a4a0a.tar.xz openssl-ee1d9ec019a7584482bd95891404f1cad66a4a0a.zip |
Remove link between digests and signature algorithms.
Use cross reference table in ASN1_item_sign(), ASN1_item_verify() to eliminate
the need for algorithm specific code.
Diffstat (limited to 'crypto/evp/p_verify.c')
-rw-r--r-- | crypto/evp/p_verify.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/crypto/evp/p_verify.c b/crypto/evp/p_verify.c index 21a40a375e..8db46412f3 100644 --- a/crypto/evp/p_verify.c +++ b/crypto/evp/p_verify.c @@ -70,6 +70,28 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, int i,ok=0,v; MS_STATIC EVP_MD_CTX tmp_ctx; + EVP_MD_CTX_init(&tmp_ctx); + EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); + EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len); + EVP_MD_CTX_cleanup(&tmp_ctx); + + if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) + { + EVP_PKEY_CTX *pkctx = NULL; + i = -1; + pkctx = EVP_PKEY_CTX_new(pkey, NULL); + if (!pkctx) + goto err; + if (EVP_PKEY_verify_init(pkctx) <= 0) + goto err; + if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0) + goto err; + i = EVP_PKEY_verify(pkctx, sigbuf, siglen, m, m_len); + err: + EVP_PKEY_CTX_free(pkctx); + return i; + } + for (i=0; i<4; i++) { v=ctx->digest->required_pkey_type[i]; @@ -85,10 +107,6 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); return(-1); } - EVP_MD_CTX_init(&tmp_ctx); - EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); - EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len); - EVP_MD_CTX_cleanup(&tmp_ctx); if (ctx->digest->verify == NULL) { EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); |