diff options
author | Paul Yang <yang.yang@baishancloud.com> | 2018-09-04 00:51:04 +0800 |
---|---|---|
committer | Paul Yang <yang.yang@baishancloud.com> | 2018-09-07 18:12:26 +0800 |
commit | 0a8fdef7523ae796ca2e734c279791737148c001 (patch) | |
tree | b8373ba17b5d293a7e9c81743e33f8a763a97c53 /crypto | |
parent | 00902d9414b4c6e46f78d7a6b6c8edc4d313d4b7 (diff) |
Support pmeth->digest_custom
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7113)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/m_sigver.c | 8 | ||||
-rw-r--r-- | crypto/evp/pmeth_lib.c | 15 | ||||
-rw-r--r-- | crypto/include/internal/evp_int.h | 2 |
3 files changed, 25 insertions, 0 deletions
diff --git a/crypto/evp/m_sigver.c b/crypto/evp/m_sigver.c index 2377944f66..4a0e5d5c55 100644 --- a/crypto/evp/m_sigver.c +++ b/crypto/evp/m_sigver.c @@ -75,6 +75,14 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, return 1; if (!EVP_DigestInit_ex(ctx, type, e)) return 0; + if (ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_DIGEST_CUSTOM) { + /* + * This indicates the current algorithm requires + * special treatment before hashing the tbs-message. + */ + if (ctx->pctx->pmeth->digest_custom) + return ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx); + } return 1; } diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index ef923fdc5e..7e6388e8f5 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -655,6 +655,13 @@ void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth, pmeth->param_check = check; } +void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth, + int (*digest_custom) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx)) +{ + pmeth->digest_custom = digest_custom; +} + void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth, int (**pinit) (EVP_PKEY_CTX *ctx)) { @@ -842,3 +849,11 @@ void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth, if (*pcheck) *pcheck = pmeth->param_check; } + +void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth, + int (**pdigest_custom) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx)) +{ + if (*pdigest_custom) + *pdigest_custom = pmeth->digest_custom; +} diff --git a/crypto/include/internal/evp_int.h b/crypto/include/internal/evp_int.h index daf2e459e2..3264b3df71 100644 --- a/crypto/include/internal/evp_int.h +++ b/crypto/include/internal/evp_int.h @@ -79,6 +79,8 @@ struct evp_pkey_method_st { int (*check) (EVP_PKEY *pkey); int (*public_check) (EVP_PKEY *pkey); int (*param_check) (EVP_PKEY *pkey); + + int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); } /* EVP_PKEY_METHOD */ ; DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD) |