Change OSSL_PARAM return size to not be a pointer.
[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_params_fn md5_sha1_set_params;
21
22 /* Special set_params method for SSL3 */
23 static int md5_sha1_set_params(void *vctx, const OSSL_PARAM params[])
24 {
25     const OSSL_PARAM *p;
26     MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx;
27
28     if (ctx != NULL && params != NULL) {
29         p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);
30         if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)
31             return md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size,
32                                  p->data);
33     }
34     return 0;
35 }
36
37 OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(md5_sha1, MD5_SHA1_CTX,
38                                   MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH,
39                                   md5_sha1_init, md5_sha1_update, md5_sha1_final,
40                                   md5_sha1_set_params)