diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2019-06-07 12:05:23 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2019-06-11 20:25:33 +1000 |
commit | 83b4a24384e62ed8cf91f51bf9a303f98017e13e (patch) | |
tree | 736978aa1768b11fae53518b03378c272180a70b /crypto | |
parent | 3d700c3fde15086fcb514ab7c90097f7f0f5d75f (diff) |
Make EVP_MD_CTX_ctrl() work for legacy use cases (ssl3).
This is still required currently by engines and digestsign/digestverify.
This PR contains merged in code from Richard Levitte's PR #9126.
[extended tests]
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9103)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/digest.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index faa6ccf0de..604bf7fea0 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -539,30 +539,34 @@ int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]) return 0; } -#if !OPENSSL_API_3 +/* TODO(3.0): Remove legacy code below - only used by engines & DigestSign */ int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2) { if (ctx->digest != NULL) { - OSSL_PARAM params[2]; - size_t i, sz, n = 0; - - switch (cmd) { - case EVP_MD_CTRL_XOF_LEN: - if (ctx->digest->set_params == NULL) - break; - i = (size_t)p1; - params[n++] = OSSL_PARAM_construct_size_t( - OSSL_DIGEST_PARAM_XOFLEN, &i, &sz); - params[n++] = OSSL_PARAM_construct_end(); - return ctx->digest->set_params(ctx->provctx, params) > 0; - case EVP_MD_CTRL_MICALG: - if (ctx->digest->get_params == NULL) - break; - params[n++] = OSSL_PARAM_construct_utf8_string( - OSSL_DIGEST_PARAM_MICALG, p2, p1 ? p1 : 9999, - &sz); - params[n++] = OSSL_PARAM_construct_end(); - return ctx->digest->get_params(ctx->provctx, params); + if (ctx->digest->prov != NULL) { + OSSL_PARAM params[2]; + size_t i, sz, n = 0; + + switch (cmd) { + case EVP_MD_CTRL_XOF_LEN: + if (ctx->digest->set_params == NULL) + break; + i = (size_t)p1; + params[n++] = + OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN, &i, + &sz); + params[n++] = OSSL_PARAM_construct_end(); + return ctx->digest->set_params(ctx->provctx, params); + case EVP_MD_CTRL_MICALG: + if (ctx->digest->get_params == NULL) + break; + params[n++] = + OSSL_PARAM_construct_utf8_string(OSSL_DIGEST_PARAM_MICALG, + p2, p1 ? p1 : 9999, &sz); + params[n++] = OSSL_PARAM_construct_end(); + return ctx->digest->get_params(ctx->provctx, params); + } + return 0; } /* legacy code */ if (ctx->digest->md_ctrl != NULL) { @@ -574,7 +578,6 @@ int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2) } return 0; } -#endif static void *evp_md_from_dispatch(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov) |