Make EVP_MD_CTX_ctrl() work for legacy use cases (ssl3).
[openssl.git] / providers / common / digests / sha2_prov.c
index 4b5979e..547d1bc 100644 (file)
@@ -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;
 }