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 /providers | |
parent | 3d700c3fde15086fcb514ab7c90097f7f0f5d75f (diff) | |
download | openssl-83b4a24384e62ed8cf91f51bf9a303f98017e13e.tar.gz |
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 'providers')
-rw-r--r-- | providers/common/digests/sha2_prov.c | 15 | ||||
-rw-r--r-- | providers/default/digests/md5_sha1_prov.c | 14 |
2 files changed, 9 insertions, 20 deletions
diff --git a/providers/common/digests/sha2_prov.c b/providers/common/digests/sha2_prov.c index 4b5979e4ab..547d1bcab6 100644 --- a/providers/common/digests/sha2_prov.c +++ b/providers/common/digests/sha2_prov.c @@ -10,6 +10,7 @@ #include <openssl/crypto.h> #include <openssl/core_numbers.h> #include <openssl/sha.h> +#include <openssl/evp.h> #include <openssl/params.h> #include <openssl/core_names.h> #include "internal/core_mkdigest.h" @@ -21,20 +22,14 @@ static OSSL_OP_digest_set_params_fn sha1_set_params; /* Special set_params method for SSL3 */ static int sha1_set_params(void *vctx, const OSSL_PARAM params[]) { - int cmd = 0; - size_t msg_len = 0; - const void *msg = NULL; const OSSL_PARAM *p; SHA_CTX *ctx = (SHA_CTX *)vctx; if (ctx != NULL && params != NULL) { - p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_CMD); - if (p != NULL && !OSSL_PARAM_get_int(p, &cmd)) - return 0; - p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_MSG); - if (p != NULL && !OSSL_PARAM_get_octet_ptr(p, &msg, &msg_len)) - return 0; - return sha1_ctrl(ctx, cmd, msg_len, (void *)msg); + p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SSL3_MS); + if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING) + return sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size, + p->data); } return 0; } diff --git a/providers/default/digests/md5_sha1_prov.c b/providers/default/digests/md5_sha1_prov.c index 59a7df83ff..e6091bd80f 100644 --- a/providers/default/digests/md5_sha1_prov.c +++ b/providers/default/digests/md5_sha1_prov.c @@ -22,20 +22,14 @@ static OSSL_OP_digest_set_params_fn md5_sha1_set_params; /* Special set_params method for SSL3 */ static int md5_sha1_set_params(void *vctx, const OSSL_PARAM params[]) { - int cmd = 0; - size_t msg_len = 0; - const void *msg = NULL; const OSSL_PARAM *p; MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx; if (ctx != NULL && params != NULL) { - p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_CMD); - if (p != NULL && !OSSL_PARAM_get_int(p, &cmd)) - return 0; - p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_MSG); - if (p != NULL && !OSSL_PARAM_get_octet_ptr(p, &msg, &msg_len)) - return 0; - return md5_sha1_ctrl(ctx, cmd, msg_len, (void *)msg); + p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SSL3_MS); + if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING) + return md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size, + p->data); } return 0; } |