]>
Commit | Line | Data |
---|---|---|
d5e5e2ff SL |
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 | int cmd = 0; | |
26 | size_t msg_len = 0; | |
27 | const void *msg = NULL; | |
28 | const OSSL_PARAM *p; | |
29 | MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx; | |
30 | ||
31 | if (ctx != NULL && params != NULL) { | |
32 | p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_CMD); | |
33 | if (p != NULL && !OSSL_PARAM_get_int(p, &cmd)) | |
34 | return 0; | |
35 | p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_MSG); | |
36 | if (p != NULL && !OSSL_PARAM_get_octet_ptr(p, &msg, &msg_len)) | |
37 | return 0; | |
38 | return md5_sha1_ctrl(ctx, cmd, msg_len, (void *)msg); | |
39 | } | |
40 | return 0; | |
41 | } | |
42 | ||
43 | OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(md5_sha1, MD5_SHA1_CTX, | |
44 | MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, | |
45 | md5_sha1_init, md5_sha1_update, md5_sha1_final, | |
46 | md5_sha1_set_params) |