/src/openssl/providers/implementations/digests/mdc2_prov.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2019-2021 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 | | /* |
12 | | * MDC2 low level APIs are deprecated for public use, but still ok for |
13 | | * internal use. |
14 | | */ |
15 | | #include "internal/deprecated.h" |
16 | | |
17 | | #include <string.h> |
18 | | #include <openssl/crypto.h> |
19 | | #include <openssl/params.h> |
20 | | #include <openssl/mdc2.h> |
21 | | #include <openssl/core_names.h> |
22 | | #include <openssl/err.h> |
23 | | #include <openssl/proverr.h> |
24 | | #include <internal/common.h> |
25 | | #include "prov/digestcommon.h" |
26 | | #include "prov/implementations.h" |
27 | | |
28 | | static OSSL_FUNC_digest_set_ctx_params_fn mdc2_set_ctx_params; |
29 | | static OSSL_FUNC_digest_settable_ctx_params_fn mdc2_settable_ctx_params; |
30 | | |
31 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
32 | | #ifndef mdc2_set_ctx_params_list |
33 | | static const OSSL_PARAM mdc2_set_ctx_params_list[] = { |
34 | | OSSL_PARAM_uint(OSSL_DIGEST_PARAM_PAD_TYPE, NULL), |
35 | | OSSL_PARAM_END |
36 | | }; |
37 | | #endif |
38 | | |
39 | | #ifndef mdc2_set_ctx_params_st |
40 | | struct mdc2_set_ctx_params_st { |
41 | | OSSL_PARAM *pad; |
42 | | }; |
43 | | #endif |
44 | | |
45 | | #ifndef mdc2_set_ctx_params_decoder |
46 | | static int mdc2_set_ctx_params_decoder |
47 | | (const OSSL_PARAM *p, struct mdc2_set_ctx_params_st *r) |
48 | 56 | { |
49 | 56 | const char *s; |
50 | | |
51 | 56 | memset(r, 0, sizeof(*r)); |
52 | 56 | if (p != NULL) |
53 | 0 | for (; (s = p->key) != NULL; p++) |
54 | 0 | if (ossl_likely(strcmp("pad-type", s + 0) == 0)) { |
55 | | /* OSSL_DIGEST_PARAM_PAD_TYPE */ |
56 | 0 | if (ossl_unlikely(r->pad != NULL)) { |
57 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
58 | 0 | "param %s is repeated", s); |
59 | 0 | return 0; |
60 | 0 | } |
61 | 0 | r->pad = (OSSL_PARAM *)p; |
62 | 0 | } |
63 | 56 | return 1; |
64 | 56 | } |
65 | | #endif |
66 | | /* End of machine generated */ |
67 | | |
68 | | static const OSSL_PARAM *mdc2_settable_ctx_params(ossl_unused void *ctx, |
69 | | ossl_unused void *provctx) |
70 | 0 | { |
71 | 0 | return mdc2_set_ctx_params_list; |
72 | 0 | } |
73 | | |
74 | | static int mdc2_set_ctx_params(void *vctx, const OSSL_PARAM params[]) |
75 | 56 | { |
76 | 56 | struct mdc2_set_ctx_params_st p; |
77 | 56 | MDC2_CTX *ctx = (MDC2_CTX *)vctx; |
78 | | |
79 | 56 | if (ctx == NULL || !mdc2_set_ctx_params_decoder(params, &p)) |
80 | 0 | return 0; |
81 | | |
82 | 56 | if (p.pad != NULL && !OSSL_PARAM_get_uint(p.pad, &ctx->pad_type)) { |
83 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER); |
84 | 0 | return 0; |
85 | 0 | } |
86 | 56 | return 1; |
87 | 56 | } |
88 | | |
89 | | /* ossl_mdc2_functions */ |
90 | | IMPLEMENT_digest_functions_with_settable_ctx( Unexecuted instantiation: mdc2_prov.c:mdc2_newctx Unexecuted instantiation: mdc2_prov.c:mdc2_dupctx |
91 | | mdc2, MDC2_CTX, MDC2_BLOCK, MDC2_DIGEST_LENGTH, 0, |
92 | | MDC2_Init, MDC2_Update, MDC2_Final, |
93 | | mdc2_settable_ctx_params, mdc2_set_ctx_params) |