Rename ctx_{get,set}_params to {get,set}_ctx_params
[openssl.git] / providers / default / digests / md5_sha1_prov.c
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
11 #include <string.h>
12 #include <openssl/crypto.h>
13 #include <openssl/evp.h>
14 #include <openssl/params.h>
15 #include <openssl/core_names.h>
16 #include "internal/core_mkdigest.h"
17 #include "internal/md5_sha1.h"
18 #include "internal/provider_algs.h"
19
20 static OSSL_OP_digest_set_ctx_params_fn md5_sha1_set_ctx_params;
21 static OSSL_OP_digest_settable_ctx_params_fn md5_sha1_settable_ctx_params;
22
23 static const OSSL_PARAM known_md5_sha1_settable_ctx_params[] = {
24     {OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0},
25     OSSL_PARAM_END
26 };
27
28 static const OSSL_PARAM *md5_sha1_settable_ctx_params(void)
29 {
30     return known_md5_sha1_settable_ctx_params;
31 }
32
33 /* Special set_params method for SSL3 */
34 static int md5_sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])
35 {
36     const OSSL_PARAM *p;
37     MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx;
38
39     if (ctx != NULL && params != NULL) {
40         p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);
41         if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)
42             return md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size,
43                                  p->data);
44     }
45     return 0;
46 }
47
48 OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(md5_sha1, MD5_SHA1_CTX,
49                                   MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0,
50                                   md5_sha1_init, md5_sha1_update, md5_sha1_final,
51                                   md5_sha1_settable_ctx_params,
52                                   md5_sha1_set_ctx_params)