1/*
2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include <string.h>
11#include <openssl/crypto.h>
12#include <openssl/evp.h>
13#include <openssl/params.h>
14#include <openssl/core_names.h>
15#include "prov/md5_sha1.h"
16#include "prov/digestcommon.h"
17#include "prov/implementations.h"
18
19static OSSL_OP_digest_set_ctx_params_fn md5_sha1_set_ctx_params;
20static OSSL_OP_digest_settable_ctx_params_fn md5_sha1_settable_ctx_params;
21
22static const OSSL_PARAM known_md5_sha1_settable_ctx_params[] = {
23 {OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0},
24 OSSL_PARAM_END
25};
26
27static const OSSL_PARAM *md5_sha1_settable_ctx_params(void)
28{
29 return known_md5_sha1_settable_ctx_params;
30}
31
32/* Special set_params method for SSL3 */
33static int md5_sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])
34{
35 const OSSL_PARAM *p;
36 MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx;
37
38 if (ctx != NULL && params != NULL) {
39 p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);
40 if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)
41 return md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size,
42 p->data);
43 }
44 return 0;
45}
46
47/* md5_sha1_functions */
48IMPLEMENT_digest_functions_with_settable_ctx(
49 md5_sha1, MD5_SHA1_CTX, MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0,
50 md5_sha1_init, md5_sha1_update, md5_sha1_final,
51 md5_sha1_settable_ctx_params, md5_sha1_set_ctx_params)
52