/src/openssl/providers/implementations/keymgmt/mac_legacy_kmgmt.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2020-2025 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 | | /* We need to use some engine deprecated APIs */ |
12 | | #define OPENSSL_SUPPRESS_DEPRECATED |
13 | | |
14 | | #include <string.h> |
15 | | #include <openssl/core_dispatch.h> |
16 | | #include <openssl/core_names.h> |
17 | | #include <openssl/params.h> |
18 | | #include <openssl/err.h> |
19 | | #include <openssl/evp.h> |
20 | | #include <openssl/proverr.h> |
21 | | #include <openssl/param_build.h> |
22 | | #ifndef FIPS_MODULE |
23 | | # include <openssl/engine.h> |
24 | | #endif |
25 | | #include "internal/param_build_set.h" |
26 | | #include "prov/implementations.h" |
27 | | #include "prov/providercommon.h" |
28 | | #include "prov/provider_ctx.h" |
29 | | #include "prov/macsignature.h" |
30 | | |
31 | | static OSSL_FUNC_keymgmt_new_fn mac_new; |
32 | | static OSSL_FUNC_keymgmt_free_fn mac_free; |
33 | | static OSSL_FUNC_keymgmt_gen_init_fn mac_gen_init; |
34 | | static OSSL_FUNC_keymgmt_gen_fn mac_gen; |
35 | | static OSSL_FUNC_keymgmt_gen_cleanup_fn mac_gen_cleanup; |
36 | | static OSSL_FUNC_keymgmt_gen_set_params_fn mac_gen_set_params; |
37 | | static OSSL_FUNC_keymgmt_gen_settable_params_fn mac_gen_settable_params; |
38 | | static OSSL_FUNC_keymgmt_get_params_fn mac_get_params; |
39 | | static OSSL_FUNC_keymgmt_gettable_params_fn mac_gettable_params; |
40 | | static OSSL_FUNC_keymgmt_set_params_fn mac_set_params; |
41 | | static OSSL_FUNC_keymgmt_settable_params_fn mac_settable_params; |
42 | | static OSSL_FUNC_keymgmt_has_fn mac_has; |
43 | | static OSSL_FUNC_keymgmt_match_fn mac_match; |
44 | | static OSSL_FUNC_keymgmt_import_fn mac_import; |
45 | | static OSSL_FUNC_keymgmt_import_types_fn mac_imexport_types; |
46 | | static OSSL_FUNC_keymgmt_export_fn mac_export; |
47 | | static OSSL_FUNC_keymgmt_export_types_fn mac_imexport_types; |
48 | | |
49 | | static OSSL_FUNC_keymgmt_new_fn mac_new_cmac; |
50 | | static OSSL_FUNC_keymgmt_get_params_fn cmac_get_params; |
51 | | static OSSL_FUNC_keymgmt_gettable_params_fn cmac_gettable_params; |
52 | | static OSSL_FUNC_keymgmt_import_fn cmac_import; |
53 | | static OSSL_FUNC_keymgmt_import_types_fn cmac_imexport_types; |
54 | | static OSSL_FUNC_keymgmt_export_types_fn cmac_imexport_types; |
55 | | static OSSL_FUNC_keymgmt_gen_init_fn cmac_gen_init; |
56 | | static OSSL_FUNC_keymgmt_gen_set_params_fn cmac_gen_set_params; |
57 | | static OSSL_FUNC_keymgmt_gen_settable_params_fn cmac_gen_settable_params; |
58 | | |
59 | | struct mac_gen_ctx { |
60 | | OSSL_LIB_CTX *libctx; |
61 | | int selection; |
62 | | unsigned char *priv_key; |
63 | | size_t priv_key_len; |
64 | | PROV_CIPHER cipher; |
65 | | }; |
66 | | |
67 | | MAC_KEY *ossl_mac_key_new(OSSL_LIB_CTX *libctx, int cmac) |
68 | 0 | { |
69 | 0 | MAC_KEY *mackey; |
70 | |
|
71 | 0 | if (!ossl_prov_is_running()) |
72 | 0 | return NULL; |
73 | | |
74 | 0 | mackey = OPENSSL_zalloc(sizeof(*mackey)); |
75 | 0 | if (mackey == NULL) |
76 | 0 | return NULL; |
77 | | |
78 | 0 | if (!CRYPTO_NEW_REF(&mackey->refcnt, 1)) { |
79 | 0 | OPENSSL_free(mackey); |
80 | 0 | return NULL; |
81 | 0 | } |
82 | 0 | mackey->libctx = libctx; |
83 | 0 | mackey->cmac = cmac; |
84 | |
|
85 | 0 | return mackey; |
86 | 0 | } |
87 | | |
88 | | void ossl_mac_key_free(MAC_KEY *mackey) |
89 | 0 | { |
90 | 0 | int ref = 0; |
91 | |
|
92 | 0 | if (mackey == NULL) |
93 | 0 | return; |
94 | | |
95 | 0 | CRYPTO_DOWN_REF(&mackey->refcnt, &ref); |
96 | 0 | if (ref > 0) |
97 | 0 | return; |
98 | | |
99 | 0 | OPENSSL_secure_clear_free(mackey->priv_key, mackey->priv_key_len); |
100 | 0 | OPENSSL_free(mackey->properties); |
101 | 0 | ossl_prov_cipher_reset(&mackey->cipher); |
102 | 0 | CRYPTO_FREE_REF(&mackey->refcnt); |
103 | 0 | OPENSSL_free(mackey); |
104 | 0 | } |
105 | | |
106 | | int ossl_mac_key_up_ref(MAC_KEY *mackey) |
107 | 0 | { |
108 | 0 | int ref = 0; |
109 | | |
110 | | /* This is effectively doing a new operation on the MAC_KEY and should be |
111 | | * adequately guarded again modules' error states. However, both current |
112 | | * calls here are guarded properly in signature/mac_legacy.c. Thus, it |
113 | | * could be removed here. The concern is that something in the future |
114 | | * might call this function without adequate guards. It's a cheap call, |
115 | | * it seems best to leave it even though it is currently redundant. |
116 | | */ |
117 | 0 | if (!ossl_prov_is_running()) |
118 | 0 | return 0; |
119 | | |
120 | 0 | CRYPTO_UP_REF(&mackey->refcnt, &ref); |
121 | 0 | return 1; |
122 | 0 | } |
123 | | |
124 | | static void *mac_new(void *provctx) |
125 | 0 | { |
126 | 0 | return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 0); |
127 | 0 | } |
128 | | |
129 | | static void *mac_new_cmac(void *provctx) |
130 | 0 | { |
131 | 0 | return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 1); |
132 | 0 | } |
133 | | |
134 | | static void mac_free(void *mackey) |
135 | 0 | { |
136 | 0 | ossl_mac_key_free(mackey); |
137 | 0 | } |
138 | | |
139 | | static int mac_has(const void *keydata, int selection) |
140 | 0 | { |
141 | 0 | const MAC_KEY *key = keydata; |
142 | 0 | int ok = 0; |
143 | |
|
144 | 0 | if (ossl_prov_is_running() && key != NULL) { |
145 | | /* |
146 | | * MAC keys always have all the parameters they need (i.e. none). |
147 | | * Therefore we always return with 1, if asked about parameters. |
148 | | * Similarly for public keys. |
149 | | */ |
150 | 0 | ok = 1; |
151 | |
|
152 | 0 | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) |
153 | 0 | ok = key->priv_key != NULL; |
154 | 0 | } |
155 | 0 | return ok; |
156 | 0 | } |
157 | | |
158 | | static int mac_match(const void *keydata1, const void *keydata2, int selection) |
159 | 0 | { |
160 | 0 | const MAC_KEY *key1 = keydata1; |
161 | 0 | const MAC_KEY *key2 = keydata2; |
162 | 0 | int ok = 1; |
163 | |
|
164 | 0 | if (!ossl_prov_is_running()) |
165 | 0 | return 0; |
166 | | |
167 | 0 | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) { |
168 | 0 | if ((key1->priv_key == NULL && key2->priv_key != NULL) |
169 | 0 | || (key1->priv_key != NULL && key2->priv_key == NULL) |
170 | 0 | || key1->priv_key_len != key2->priv_key_len |
171 | 0 | || (key1->cipher.cipher == NULL && key2->cipher.cipher != NULL) |
172 | 0 | || (key1->cipher.cipher != NULL && key2->cipher.cipher == NULL)) |
173 | 0 | ok = 0; |
174 | 0 | else |
175 | 0 | ok = ok && (key1->priv_key == NULL /* implies key2->privkey == NULL */ |
176 | 0 | || CRYPTO_memcmp(key1->priv_key, key2->priv_key, |
177 | 0 | key1->priv_key_len) == 0); |
178 | 0 | if (key1->cipher.cipher != NULL) |
179 | 0 | ok = ok && EVP_CIPHER_is_a(key1->cipher.cipher, |
180 | 0 | EVP_CIPHER_get0_name(key2->cipher.cipher)); |
181 | 0 | } |
182 | 0 | return ok; |
183 | 0 | } |
184 | | |
185 | | /* Common structure to handle the MAC parameters for various calls */ |
186 | | struct mac_common_params_st { |
187 | | OSSL_PARAM *key; |
188 | | OSSL_PARAM *cipher; /* CMAC */ |
189 | | OSSL_PARAM *propq; |
190 | | OSSL_PARAM *engine; |
191 | | }; |
192 | | |
193 | | static int mac_key_fromdata(MAC_KEY *key, const struct mac_common_params_st *p) |
194 | 0 | { |
195 | 0 | if (p->key != NULL) { |
196 | 0 | if (p->key->data_type != OSSL_PARAM_OCTET_STRING) { |
197 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); |
198 | 0 | return 0; |
199 | 0 | } |
200 | 0 | OPENSSL_secure_clear_free(key->priv_key, key->priv_key_len); |
201 | | /* allocate at least one byte to distinguish empty key from no key set */ |
202 | 0 | key->priv_key = OPENSSL_secure_malloc(p->key->data_size > 0 |
203 | 0 | ? p->key->data_size : 1); |
204 | 0 | if (key->priv_key == NULL) |
205 | 0 | return 0; |
206 | 0 | memcpy(key->priv_key, p->key->data, p->key->data_size); |
207 | 0 | key->priv_key_len = p->key->data_size; |
208 | 0 | } |
209 | | |
210 | 0 | if (p->propq != NULL) { |
211 | 0 | if (p->propq->data_type != OSSL_PARAM_UTF8_STRING) { |
212 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); |
213 | 0 | return 0; |
214 | 0 | } |
215 | 0 | OPENSSL_free(key->properties); |
216 | 0 | key->properties = OPENSSL_strdup(p->propq->data); |
217 | 0 | if (key->properties == NULL) |
218 | 0 | return 0; |
219 | 0 | } |
220 | | |
221 | 0 | if (key->cmac && !ossl_prov_cipher_load(&key->cipher, p->cipher, p->propq, |
222 | 0 | p->engine, key->libctx)) { |
223 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); |
224 | 0 | return 0; |
225 | 0 | } |
226 | | |
227 | 0 | if (key->priv_key != NULL) |
228 | 0 | return 1; |
229 | | |
230 | 0 | return 0; |
231 | 0 | } |
232 | | |
233 | | #define mac_import_st mac_common_params_st |
234 | | |
235 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
236 | | #ifndef mac_import_list |
237 | | static const OSSL_PARAM mac_import_list[] = { |
238 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), |
239 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0), |
240 | | OSSL_PARAM_END |
241 | | }; |
242 | | #endif |
243 | | |
244 | | #ifndef mac_import_st |
245 | | struct mac_import_st { |
246 | | OSSL_PARAM *key; |
247 | | OSSL_PARAM *propq; |
248 | | }; |
249 | | #endif |
250 | | |
251 | | #ifndef mac_import_decoder |
252 | | static int mac_import_decoder |
253 | | (const OSSL_PARAM *p, struct mac_import_st *r) |
254 | 0 | { |
255 | 0 | const char *s; |
256 | |
|
257 | 0 | memset(r, 0, sizeof(*r)); |
258 | 0 | if (p != NULL) |
259 | 0 | for (; (s = p->key) != NULL; p++) |
260 | 0 | switch(s[0]) { |
261 | 0 | default: |
262 | 0 | break; |
263 | 0 | case 'p': |
264 | 0 | switch(s[1]) { |
265 | 0 | default: |
266 | 0 | break; |
267 | 0 | case 'r': |
268 | 0 | switch(s[2]) { |
269 | 0 | default: |
270 | 0 | break; |
271 | 0 | case 'i': |
272 | 0 | if (ossl_likely(strcmp("v", s + 3) == 0)) { |
273 | | /* OSSL_PKEY_PARAM_PRIV_KEY */ |
274 | 0 | if (ossl_unlikely(r->key != NULL)) { |
275 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
276 | 0 | "param %s is repeated", s); |
277 | 0 | return 0; |
278 | 0 | } |
279 | 0 | r->key = (OSSL_PARAM *)p; |
280 | 0 | } |
281 | 0 | break; |
282 | 0 | case 'o': |
283 | 0 | if (ossl_likely(strcmp("perties", s + 3) == 0)) { |
284 | | /* OSSL_PKEY_PARAM_PROPERTIES */ |
285 | 0 | if (ossl_unlikely(r->propq != NULL)) { |
286 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
287 | 0 | "param %s is repeated", s); |
288 | 0 | return 0; |
289 | 0 | } |
290 | 0 | r->propq = (OSSL_PARAM *)p; |
291 | 0 | } |
292 | 0 | } |
293 | 0 | } |
294 | 0 | } |
295 | 0 | return 1; |
296 | 0 | } |
297 | | #endif |
298 | | /* End of machine generated */ |
299 | | |
300 | | static int mac_import(void *keydata, int selection, const OSSL_PARAM params[]) |
301 | 0 | { |
302 | 0 | MAC_KEY *key = keydata; |
303 | 0 | struct mac_common_params_st p; |
304 | |
|
305 | 0 | if (key == NULL |
306 | 0 | || (selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0 |
307 | 0 | || !ossl_prov_is_running() |
308 | 0 | || !mac_import_decoder(params, &p)) |
309 | 0 | return 0; |
310 | | |
311 | 0 | return mac_key_fromdata(key, &p); |
312 | 0 | } |
313 | | |
314 | | static const OSSL_PARAM *mac_imexport_types(int selection) |
315 | 0 | { |
316 | 0 | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) |
317 | 0 | return mac_import_list; |
318 | 0 | return NULL; |
319 | 0 | } |
320 | | |
321 | | #define cmac_import_st mac_common_params_st |
322 | | |
323 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
324 | | #ifndef cmac_import_list |
325 | | static const OSSL_PARAM cmac_import_list[] = { |
326 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), |
327 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0), |
328 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0), |
329 | | OSSL_PARAM_END |
330 | | }; |
331 | | #endif |
332 | | |
333 | | #ifndef cmac_import_st |
334 | | struct cmac_import_st { |
335 | | OSSL_PARAM *cipher; |
336 | | OSSL_PARAM *engine; |
337 | | OSSL_PARAM *key; |
338 | | OSSL_PARAM *propq; |
339 | | }; |
340 | | #endif |
341 | | |
342 | | #ifndef cmac_import_decoder |
343 | | static int cmac_import_decoder |
344 | | (const OSSL_PARAM *p, struct cmac_import_st *r) |
345 | 0 | { |
346 | 0 | const char *s; |
347 | |
|
348 | 0 | memset(r, 0, sizeof(*r)); |
349 | 0 | if (p != NULL) |
350 | 0 | for (; (s = p->key) != NULL; p++) |
351 | 0 | switch(s[0]) { |
352 | 0 | default: |
353 | 0 | break; |
354 | 0 | case 'c': |
355 | 0 | if (ossl_likely(strcmp("ipher", s + 1) == 0)) { |
356 | | /* OSSL_PKEY_PARAM_CIPHER */ |
357 | 0 | if (ossl_unlikely(r->cipher != NULL)) { |
358 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
359 | 0 | "param %s is repeated", s); |
360 | 0 | return 0; |
361 | 0 | } |
362 | 0 | r->cipher = (OSSL_PARAM *)p; |
363 | 0 | } |
364 | 0 | break; |
365 | 0 | case 'e': |
366 | 0 | if (ossl_likely(strcmp("ngine", s + 1) == 0)) { |
367 | | /* OSSL_PKEY_PARAM_ENGINE */ |
368 | 0 | if (ossl_unlikely(r->engine != NULL)) { |
369 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
370 | 0 | "param %s is repeated", s); |
371 | 0 | return 0; |
372 | 0 | } |
373 | 0 | r->engine = (OSSL_PARAM *)p; |
374 | 0 | } |
375 | 0 | break; |
376 | 0 | case 'p': |
377 | 0 | switch(s[1]) { |
378 | 0 | default: |
379 | 0 | break; |
380 | 0 | case 'r': |
381 | 0 | switch(s[2]) { |
382 | 0 | default: |
383 | 0 | break; |
384 | 0 | case 'i': |
385 | 0 | if (ossl_likely(strcmp("v", s + 3) == 0)) { |
386 | | /* OSSL_PKEY_PARAM_PRIV_KEY */ |
387 | 0 | if (ossl_unlikely(r->key != NULL)) { |
388 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
389 | 0 | "param %s is repeated", s); |
390 | 0 | return 0; |
391 | 0 | } |
392 | 0 | r->key = (OSSL_PARAM *)p; |
393 | 0 | } |
394 | 0 | break; |
395 | 0 | case 'o': |
396 | 0 | if (ossl_likely(strcmp("perties", s + 3) == 0)) { |
397 | | /* OSSL_PKEY_PARAM_PROPERTIES */ |
398 | 0 | if (ossl_unlikely(r->propq != NULL)) { |
399 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
400 | 0 | "param %s is repeated", s); |
401 | 0 | return 0; |
402 | 0 | } |
403 | 0 | r->propq = (OSSL_PARAM *)p; |
404 | 0 | } |
405 | 0 | } |
406 | 0 | } |
407 | 0 | } |
408 | 0 | return 1; |
409 | 0 | } |
410 | | #endif |
411 | | /* End of machine generated */ |
412 | | |
413 | | static int cmac_import(void *keydata, int selection, const OSSL_PARAM params[]) |
414 | 0 | { |
415 | 0 | MAC_KEY *key = keydata; |
416 | 0 | struct mac_common_params_st p; |
417 | |
|
418 | 0 | if (key == NULL |
419 | 0 | || (selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0 |
420 | 0 | || !ossl_prov_is_running() |
421 | 0 | || !cmac_import_decoder(params, &p)) |
422 | 0 | return 0; |
423 | | |
424 | 0 | return mac_key_fromdata(key, &p); |
425 | 0 | } |
426 | | |
427 | | static const OSSL_PARAM *cmac_imexport_types(int selection) |
428 | 0 | { |
429 | 0 | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) |
430 | 0 | return cmac_import_list; |
431 | 0 | return NULL; |
432 | 0 | } |
433 | | |
434 | | static int key_to_params(MAC_KEY *key, OSSL_PARAM_BLD *tmpl, |
435 | | struct mac_common_params_st *p) |
436 | 0 | { |
437 | 0 | struct mac_common_params_st empty; |
438 | |
|
439 | 0 | if (p == NULL) |
440 | 0 | memset(p = &empty, 0, sizeof(empty)); |
441 | |
|
442 | 0 | if (key->priv_key != NULL |
443 | 0 | && !ossl_param_build_set_octet_string(tmpl, p->key, |
444 | 0 | OSSL_PKEY_PARAM_PRIV_KEY, |
445 | 0 | key->priv_key, key->priv_key_len)) |
446 | 0 | return 0; |
447 | | |
448 | 0 | if (key->cipher.cipher != NULL |
449 | 0 | && !ossl_param_build_set_utf8_string(tmpl, p->cipher, |
450 | 0 | OSSL_PKEY_PARAM_CIPHER, |
451 | 0 | EVP_CIPHER_get0_name(key->cipher.cipher))) |
452 | 0 | return 0; |
453 | | |
454 | 0 | #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE) |
455 | 0 | if (key->cipher.engine != NULL |
456 | 0 | && !ossl_param_build_set_utf8_string(tmpl, p->engine, |
457 | 0 | OSSL_PKEY_PARAM_ENGINE, |
458 | 0 | ENGINE_get_id(key->cipher.engine))) |
459 | 0 | return 0; |
460 | 0 | #endif |
461 | | |
462 | 0 | return 1; |
463 | 0 | } |
464 | | |
465 | | static int mac_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, |
466 | | void *cbarg) |
467 | 0 | { |
468 | 0 | MAC_KEY *key = keydata; |
469 | 0 | OSSL_PARAM_BLD *tmpl; |
470 | 0 | OSSL_PARAM *params = NULL; |
471 | 0 | int ret = 0; |
472 | |
|
473 | 0 | if (!ossl_prov_is_running() || key == NULL) |
474 | 0 | return 0; |
475 | | |
476 | 0 | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0) |
477 | 0 | return 0; |
478 | | |
479 | 0 | tmpl = OSSL_PARAM_BLD_new(); |
480 | 0 | if (tmpl == NULL) |
481 | 0 | return 0; |
482 | | |
483 | 0 | if (!key_to_params(key, tmpl, NULL)) |
484 | 0 | goto err; |
485 | | |
486 | 0 | params = OSSL_PARAM_BLD_to_param(tmpl); |
487 | 0 | if (params == NULL) |
488 | 0 | goto err; |
489 | | |
490 | 0 | ret = param_cb(params, cbarg); |
491 | 0 | OSSL_PARAM_free(params); |
492 | 0 | err: |
493 | 0 | OSSL_PARAM_BLD_free(tmpl); |
494 | 0 | return ret; |
495 | 0 | } |
496 | | |
497 | | #define mac_get_params_st mac_common_params_st |
498 | | |
499 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
500 | | #ifndef mac_get_params_list |
501 | | static const OSSL_PARAM mac_get_params_list[] = { |
502 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), |
503 | | OSSL_PARAM_END |
504 | | }; |
505 | | #endif |
506 | | |
507 | | #ifndef mac_get_params_st |
508 | | struct mac_get_params_st { |
509 | | OSSL_PARAM *key; |
510 | | }; |
511 | | #endif |
512 | | |
513 | | #ifndef mac_get_params_decoder |
514 | | static int mac_get_params_decoder |
515 | | (const OSSL_PARAM *p, struct mac_get_params_st *r) |
516 | 0 | { |
517 | 0 | const char *s; |
518 | |
|
519 | 0 | memset(r, 0, sizeof(*r)); |
520 | 0 | if (p != NULL) |
521 | 0 | for (; (s = p->key) != NULL; p++) |
522 | 0 | if (ossl_likely(strcmp("priv", s + 0) == 0)) { |
523 | | /* OSSL_PKEY_PARAM_PRIV_KEY */ |
524 | 0 | if (ossl_unlikely(r->key != NULL)) { |
525 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
526 | 0 | "param %s is repeated", s); |
527 | 0 | return 0; |
528 | 0 | } |
529 | 0 | r->key = (OSSL_PARAM *)p; |
530 | 0 | } |
531 | 0 | return 1; |
532 | 0 | } |
533 | | #endif |
534 | | /* End of machine generated */ |
535 | | |
536 | | static int mac_get_params(void *keydata, OSSL_PARAM params[]) |
537 | 0 | { |
538 | 0 | struct mac_common_params_st p; |
539 | 0 | MAC_KEY *key = keydata; |
540 | |
|
541 | 0 | if (key == NULL || !mac_get_params_decoder(params, &p)) |
542 | 0 | return 0; |
543 | | |
544 | 0 | return key_to_params(key, NULL, &p); |
545 | 0 | } |
546 | | |
547 | | static const OSSL_PARAM *mac_gettable_params(void *provctx) |
548 | 0 | { |
549 | 0 | return mac_get_params_list; |
550 | 0 | } |
551 | | |
552 | | #define cmac_get_params_st mac_common_params_st |
553 | | |
554 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
555 | | #ifndef cmac_get_params_list |
556 | | static const OSSL_PARAM cmac_get_params_list[] = { |
557 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), |
558 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0), |
559 | | OSSL_PARAM_END |
560 | | }; |
561 | | #endif |
562 | | |
563 | | #ifndef cmac_get_params_st |
564 | | struct cmac_get_params_st { |
565 | | OSSL_PARAM *cipher; |
566 | | OSSL_PARAM *engine; |
567 | | OSSL_PARAM *key; |
568 | | }; |
569 | | #endif |
570 | | |
571 | | #ifndef cmac_get_params_decoder |
572 | | static int cmac_get_params_decoder |
573 | | (const OSSL_PARAM *p, struct cmac_get_params_st *r) |
574 | 0 | { |
575 | 0 | const char *s; |
576 | |
|
577 | 0 | memset(r, 0, sizeof(*r)); |
578 | 0 | if (p != NULL) |
579 | 0 | for (; (s = p->key) != NULL; p++) |
580 | 0 | switch(s[0]) { |
581 | 0 | default: |
582 | 0 | break; |
583 | 0 | case 'c': |
584 | 0 | if (ossl_likely(strcmp("ipher", s + 1) == 0)) { |
585 | | /* OSSL_PKEY_PARAM_CIPHER */ |
586 | 0 | if (ossl_unlikely(r->cipher != NULL)) { |
587 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
588 | 0 | "param %s is repeated", s); |
589 | 0 | return 0; |
590 | 0 | } |
591 | 0 | r->cipher = (OSSL_PARAM *)p; |
592 | 0 | } |
593 | 0 | break; |
594 | 0 | case 'e': |
595 | 0 | if (ossl_likely(strcmp("ngine", s + 1) == 0)) { |
596 | | /* OSSL_PKEY_PARAM_ENGINE */ |
597 | 0 | if (ossl_unlikely(r->engine != NULL)) { |
598 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
599 | 0 | "param %s is repeated", s); |
600 | 0 | return 0; |
601 | 0 | } |
602 | 0 | r->engine = (OSSL_PARAM *)p; |
603 | 0 | } |
604 | 0 | break; |
605 | 0 | case 'p': |
606 | 0 | if (ossl_likely(strcmp("riv", s + 1) == 0)) { |
607 | | /* OSSL_PKEY_PARAM_PRIV_KEY */ |
608 | 0 | if (ossl_unlikely(r->key != NULL)) { |
609 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
610 | 0 | "param %s is repeated", s); |
611 | 0 | return 0; |
612 | 0 | } |
613 | 0 | r->key = (OSSL_PARAM *)p; |
614 | 0 | } |
615 | 0 | } |
616 | 0 | return 1; |
617 | 0 | } |
618 | | #endif |
619 | | /* End of machine generated */ |
620 | | |
621 | | static int cmac_get_params(void *keydata, OSSL_PARAM params[]) |
622 | 0 | { |
623 | 0 | struct mac_common_params_st p; |
624 | 0 | MAC_KEY *key = keydata; |
625 | |
|
626 | 0 | if (key == NULL || !cmac_get_params_decoder(params, &p)) |
627 | 0 | return 0; |
628 | | |
629 | 0 | return key_to_params(key, NULL, &p); |
630 | 0 | } |
631 | | |
632 | | |
633 | | static const OSSL_PARAM *cmac_gettable_params(void *provctx) |
634 | 0 | { |
635 | 0 | return cmac_get_params_list; |
636 | 0 | } |
637 | | |
638 | | #define mac_set_params_st mac_common_params_st |
639 | | |
640 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
641 | | #ifndef mac_set_params_list |
642 | | static const OSSL_PARAM mac_set_params_list[] = { |
643 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), |
644 | | OSSL_PARAM_END |
645 | | }; |
646 | | #endif |
647 | | |
648 | | #ifndef mac_set_params_st |
649 | | struct mac_set_params_st { |
650 | | OSSL_PARAM *key; |
651 | | }; |
652 | | #endif |
653 | | |
654 | | #ifndef mac_set_params_decoder |
655 | | static int mac_set_params_decoder |
656 | | (const OSSL_PARAM *p, struct mac_set_params_st *r) |
657 | 0 | { |
658 | 0 | const char *s; |
659 | |
|
660 | 0 | memset(r, 0, sizeof(*r)); |
661 | 0 | if (p != NULL) |
662 | 0 | for (; (s = p->key) != NULL; p++) |
663 | 0 | if (ossl_likely(strcmp("priv", s + 0) == 0)) { |
664 | | /* OSSL_PKEY_PARAM_PRIV_KEY */ |
665 | 0 | if (ossl_unlikely(r->key != NULL)) { |
666 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
667 | 0 | "param %s is repeated", s); |
668 | 0 | return 0; |
669 | 0 | } |
670 | 0 | r->key = (OSSL_PARAM *)p; |
671 | 0 | } |
672 | 0 | return 1; |
673 | 0 | } |
674 | | #endif |
675 | | /* End of machine generated */ |
676 | | |
677 | | static int mac_set_params(void *keydata, const OSSL_PARAM params[]) |
678 | 0 | { |
679 | 0 | MAC_KEY *key = keydata; |
680 | 0 | struct mac_common_params_st p; |
681 | |
|
682 | 0 | if (key == NULL || !mac_set_params_decoder(params, &p)) |
683 | 0 | return 0; |
684 | | |
685 | 0 | if (p.key != NULL) |
686 | 0 | return mac_key_fromdata(key, &p); |
687 | | |
688 | 0 | return 1; |
689 | 0 | } |
690 | | |
691 | | static const OSSL_PARAM *mac_settable_params(void *provctx) |
692 | 0 | { |
693 | 0 | return mac_set_params_list; |
694 | 0 | } |
695 | | |
696 | | static void *mac_gen_init_common(void *provctx, int selection) |
697 | 0 | { |
698 | 0 | OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx); |
699 | 0 | struct mac_gen_ctx *gctx = NULL; |
700 | |
|
701 | 0 | if (!ossl_prov_is_running()) |
702 | 0 | return NULL; |
703 | | |
704 | 0 | if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) { |
705 | 0 | gctx->libctx = libctx; |
706 | 0 | gctx->selection = selection; |
707 | 0 | } |
708 | 0 | return gctx; |
709 | 0 | } |
710 | | |
711 | | static void *mac_gen_init(void *provctx, int selection, |
712 | | const OSSL_PARAM params[]) |
713 | 0 | { |
714 | 0 | struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection); |
715 | |
|
716 | 0 | if (gctx != NULL && !mac_gen_set_params(gctx, params)) { |
717 | 0 | mac_gen_cleanup(gctx); |
718 | 0 | gctx = NULL; |
719 | 0 | } |
720 | 0 | return gctx; |
721 | 0 | } |
722 | | |
723 | | static void *cmac_gen_init(void *provctx, int selection, |
724 | | const OSSL_PARAM params[]) |
725 | 0 | { |
726 | 0 | struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection); |
727 | |
|
728 | 0 | if (gctx != NULL && !cmac_gen_set_params(gctx, params)) { |
729 | 0 | mac_gen_cleanup(gctx); |
730 | 0 | gctx = NULL; |
731 | 0 | } |
732 | 0 | return gctx; |
733 | 0 | } |
734 | | |
735 | | static int mac_gen_set_params_common(struct mac_gen_ctx *gctx, |
736 | | const struct mac_common_params_st *p) |
737 | 0 | { |
738 | 0 | if (p->key != NULL) { |
739 | 0 | if (p->key->data_type != OSSL_PARAM_OCTET_STRING) { |
740 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); |
741 | 0 | return 0; |
742 | 0 | } |
743 | 0 | gctx->priv_key = OPENSSL_secure_malloc(p->key->data_size); |
744 | 0 | if (gctx->priv_key == NULL) |
745 | 0 | return 0; |
746 | 0 | memcpy(gctx->priv_key, p->key->data, p->key->data_size); |
747 | 0 | gctx->priv_key_len = p->key->data_size; |
748 | 0 | } |
749 | | |
750 | 0 | return 1; |
751 | 0 | } |
752 | | |
753 | | #define mac_gen_set_params_st mac_common_params_st |
754 | | |
755 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
756 | | #ifndef mac_gen_set_params_list |
757 | | static const OSSL_PARAM mac_gen_set_params_list[] = { |
758 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), |
759 | | OSSL_PARAM_END |
760 | | }; |
761 | | #endif |
762 | | |
763 | | #ifndef mac_gen_set_params_st |
764 | | struct mac_gen_set_params_st { |
765 | | OSSL_PARAM *key; |
766 | | }; |
767 | | #endif |
768 | | |
769 | | #ifndef mac_gen_set_params_decoder |
770 | | static int mac_gen_set_params_decoder |
771 | | (const OSSL_PARAM *p, struct mac_gen_set_params_st *r) |
772 | 0 | { |
773 | 0 | const char *s; |
774 | |
|
775 | 0 | memset(r, 0, sizeof(*r)); |
776 | 0 | if (p != NULL) |
777 | 0 | for (; (s = p->key) != NULL; p++) |
778 | 0 | if (ossl_likely(strcmp("priv", s + 0) == 0)) { |
779 | | /* OSSL_PKEY_PARAM_PRIV_KEY */ |
780 | 0 | if (ossl_unlikely(r->key != NULL)) { |
781 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
782 | 0 | "param %s is repeated", s); |
783 | 0 | return 0; |
784 | 0 | } |
785 | 0 | r->key = (OSSL_PARAM *)p; |
786 | 0 | } |
787 | 0 | return 1; |
788 | 0 | } |
789 | | #endif |
790 | | /* End of machine generated */ |
791 | | |
792 | | static int mac_gen_set_params(void *genctx, const OSSL_PARAM params[]) |
793 | 0 | { |
794 | 0 | struct mac_gen_ctx *gctx = genctx; |
795 | 0 | struct mac_common_params_st p; |
796 | |
|
797 | 0 | if (gctx == NULL || !mac_gen_set_params_decoder(params, &p)) |
798 | 0 | return 0; |
799 | | |
800 | 0 | return mac_gen_set_params_common(gctx, &p); |
801 | 0 | } |
802 | | |
803 | | #define cmac_gen_set_params_st mac_common_params_st |
804 | | |
805 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
806 | | #ifndef cmac_gen_set_params_list |
807 | | static const OSSL_PARAM cmac_gen_set_params_list[] = { |
808 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), |
809 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0), |
810 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0), |
811 | | OSSL_PARAM_END |
812 | | }; |
813 | | #endif |
814 | | |
815 | | #ifndef cmac_gen_set_params_st |
816 | | struct cmac_gen_set_params_st { |
817 | | OSSL_PARAM *cipher; |
818 | | OSSL_PARAM *engine; |
819 | | OSSL_PARAM *key; |
820 | | OSSL_PARAM *propq; |
821 | | }; |
822 | | #endif |
823 | | |
824 | | #ifndef cmac_gen_set_params_decoder |
825 | | static int cmac_gen_set_params_decoder |
826 | | (const OSSL_PARAM *p, struct cmac_gen_set_params_st *r) |
827 | 0 | { |
828 | 0 | const char *s; |
829 | |
|
830 | 0 | memset(r, 0, sizeof(*r)); |
831 | 0 | if (p != NULL) |
832 | 0 | for (; (s = p->key) != NULL; p++) |
833 | 0 | switch(s[0]) { |
834 | 0 | default: |
835 | 0 | break; |
836 | 0 | case 'c': |
837 | 0 | if (ossl_likely(strcmp("ipher", s + 1) == 0)) { |
838 | | /* OSSL_PKEY_PARAM_CIPHER */ |
839 | 0 | if (ossl_unlikely(r->cipher != NULL)) { |
840 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
841 | 0 | "param %s is repeated", s); |
842 | 0 | return 0; |
843 | 0 | } |
844 | 0 | r->cipher = (OSSL_PARAM *)p; |
845 | 0 | } |
846 | 0 | break; |
847 | 0 | case 'e': |
848 | 0 | if (ossl_likely(strcmp("ngine", s + 1) == 0)) { |
849 | | /* OSSL_PKEY_PARAM_ENGINE */ |
850 | 0 | if (ossl_unlikely(r->engine != NULL)) { |
851 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
852 | 0 | "param %s is repeated", s); |
853 | 0 | return 0; |
854 | 0 | } |
855 | 0 | r->engine = (OSSL_PARAM *)p; |
856 | 0 | } |
857 | 0 | break; |
858 | 0 | case 'p': |
859 | 0 | switch(s[1]) { |
860 | 0 | default: |
861 | 0 | break; |
862 | 0 | case 'r': |
863 | 0 | switch(s[2]) { |
864 | 0 | default: |
865 | 0 | break; |
866 | 0 | case 'i': |
867 | 0 | if (ossl_likely(strcmp("v", s + 3) == 0)) { |
868 | | /* OSSL_PKEY_PARAM_PRIV_KEY */ |
869 | 0 | if (ossl_unlikely(r->key != NULL)) { |
870 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
871 | 0 | "param %s is repeated", s); |
872 | 0 | return 0; |
873 | 0 | } |
874 | 0 | r->key = (OSSL_PARAM *)p; |
875 | 0 | } |
876 | 0 | break; |
877 | 0 | case 'o': |
878 | 0 | if (ossl_likely(strcmp("perties", s + 3) == 0)) { |
879 | | /* OSSL_PKEY_PARAM_PROPERTIES */ |
880 | 0 | if (ossl_unlikely(r->propq != NULL)) { |
881 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
882 | 0 | "param %s is repeated", s); |
883 | 0 | return 0; |
884 | 0 | } |
885 | 0 | r->propq = (OSSL_PARAM *)p; |
886 | 0 | } |
887 | 0 | } |
888 | 0 | } |
889 | 0 | } |
890 | 0 | return 1; |
891 | 0 | } |
892 | | #endif |
893 | | /* End of machine generated */ |
894 | | |
895 | | static int cmac_gen_set_params(void *genctx, const OSSL_PARAM params[]) |
896 | 0 | { |
897 | 0 | struct mac_gen_ctx *gctx = genctx; |
898 | 0 | struct mac_common_params_st p; |
899 | |
|
900 | 0 | if (gctx == NULL || !cmac_gen_set_params_decoder(params, &p)) |
901 | 0 | return 0; |
902 | | |
903 | 0 | if (!mac_gen_set_params_common(gctx, &p)) |
904 | 0 | return 0; |
905 | | |
906 | 0 | if (!ossl_prov_cipher_load(&gctx->cipher, p.cipher, p.propq, |
907 | 0 | p.engine, gctx->libctx)) { |
908 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); |
909 | 0 | return 0; |
910 | 0 | } |
911 | | |
912 | 0 | return 1; |
913 | 0 | } |
914 | | |
915 | | static const OSSL_PARAM *mac_gen_settable_params(ossl_unused void *genctx, |
916 | | ossl_unused void *provctx) |
917 | 0 | { |
918 | 0 | return mac_gen_set_params_list; |
919 | 0 | } |
920 | | |
921 | | static const OSSL_PARAM *cmac_gen_settable_params(ossl_unused void *genctx, |
922 | | ossl_unused void *provctx) |
923 | 0 | { |
924 | 0 | return cmac_gen_set_params_list; |
925 | 0 | } |
926 | | |
927 | | static void *mac_gen(void *genctx, OSSL_CALLBACK *cb, void *cbarg) |
928 | 0 | { |
929 | 0 | struct mac_gen_ctx *gctx = genctx; |
930 | 0 | MAC_KEY *key; |
931 | |
|
932 | 0 | if (!ossl_prov_is_running() || gctx == NULL) |
933 | 0 | return NULL; |
934 | | |
935 | 0 | if ((key = ossl_mac_key_new(gctx->libctx, 0)) == NULL) { |
936 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_PROV_LIB); |
937 | 0 | return NULL; |
938 | 0 | } |
939 | | |
940 | | /* If we're doing parameter generation then we just return a blank key */ |
941 | 0 | if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0) |
942 | 0 | return key; |
943 | | |
944 | 0 | if (gctx->priv_key == NULL) { |
945 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY); |
946 | 0 | ossl_mac_key_free(key); |
947 | 0 | return NULL; |
948 | 0 | } |
949 | | |
950 | | /* |
951 | | * This is horrible but required for backwards compatibility. We don't |
952 | | * actually do real key generation at all. We simply copy the key that was |
953 | | * previously set in the gctx. Hopefully at some point in the future all |
954 | | * of this can be removed and we will only support the EVP_KDF APIs. |
955 | | */ |
956 | 0 | if (!ossl_prov_cipher_copy(&key->cipher, &gctx->cipher)) { |
957 | 0 | ossl_mac_key_free(key); |
958 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR); |
959 | 0 | return NULL; |
960 | 0 | } |
961 | 0 | ossl_prov_cipher_reset(&gctx->cipher); |
962 | 0 | key->priv_key = gctx->priv_key; |
963 | 0 | key->priv_key_len = gctx->priv_key_len; |
964 | 0 | gctx->priv_key_len = 0; |
965 | 0 | gctx->priv_key = NULL; |
966 | |
|
967 | 0 | return key; |
968 | 0 | } |
969 | | |
970 | | static void mac_gen_cleanup(void *genctx) |
971 | 0 | { |
972 | 0 | struct mac_gen_ctx *gctx = genctx; |
973 | |
|
974 | 0 | if (gctx == NULL) |
975 | 0 | return; |
976 | | |
977 | 0 | OPENSSL_secure_clear_free(gctx->priv_key, gctx->priv_key_len); |
978 | 0 | ossl_prov_cipher_reset(&gctx->cipher); |
979 | 0 | OPENSSL_free(gctx); |
980 | 0 | } |
981 | | |
982 | | const OSSL_DISPATCH ossl_mac_legacy_keymgmt_functions[] = { |
983 | | { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))mac_new }, |
984 | | { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))mac_free }, |
985 | | { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))mac_get_params }, |
986 | | { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))mac_gettable_params }, |
987 | | { OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))mac_set_params }, |
988 | | { OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))mac_settable_params }, |
989 | | { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))mac_has }, |
990 | | { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))mac_match }, |
991 | | { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))mac_import }, |
992 | | { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))mac_imexport_types }, |
993 | | { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))mac_export }, |
994 | | { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))mac_imexport_types }, |
995 | | { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))mac_gen_init }, |
996 | | { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))mac_gen_set_params }, |
997 | | { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, |
998 | | (void (*)(void))mac_gen_settable_params }, |
999 | | { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))mac_gen }, |
1000 | | { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))mac_gen_cleanup }, |
1001 | | OSSL_DISPATCH_END |
1002 | | }; |
1003 | | |
1004 | | const OSSL_DISPATCH ossl_cmac_legacy_keymgmt_functions[] = { |
1005 | | { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))mac_new_cmac }, |
1006 | | { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))mac_free }, |
1007 | | { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))cmac_get_params }, |
1008 | | { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))cmac_gettable_params }, |
1009 | | { OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))mac_set_params }, |
1010 | | { OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))mac_settable_params }, |
1011 | | { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))mac_has }, |
1012 | | { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))mac_match }, |
1013 | | { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))cmac_import }, |
1014 | | { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))cmac_imexport_types }, |
1015 | | { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))mac_export }, |
1016 | | { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))cmac_imexport_types }, |
1017 | | { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))cmac_gen_init }, |
1018 | | { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))cmac_gen_set_params }, |
1019 | | { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, |
1020 | | (void (*)(void))cmac_gen_settable_params }, |
1021 | | { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))mac_gen }, |
1022 | | { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))mac_gen_cleanup }, |
1023 | | OSSL_DISPATCH_END |
1024 | | }; |
1025 | | |