1 /*
2  * Copyright 2020-2023 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 /* We need to use some engine deprecated APIs */
11 #define OPENSSL_SUPPRESS_DEPRECATED
12 
13 #include <string.h>
14 #include <openssl/core_dispatch.h>
15 #include <openssl/core_names.h>
16 #include <openssl/params.h>
17 #include <openssl/err.h>
18 #include <openssl/evp.h>
19 #include <openssl/proverr.h>
20 #include <openssl/param_build.h>
21 #ifndef FIPS_MODULE
22 # include <openssl/engine.h>
23 #endif
24 #include "internal/param_build_set.h"
25 #include "prov/implementations.h"
26 #include "prov/providercommon.h"
27 #include "prov/provider_ctx.h"
28 #include "prov/macsignature.h"
29 
30 static OSSL_FUNC_keymgmt_new_fn mac_new;
31 static OSSL_FUNC_keymgmt_free_fn mac_free;
32 static OSSL_FUNC_keymgmt_gen_init_fn mac_gen_init;
33 static OSSL_FUNC_keymgmt_gen_fn mac_gen;
34 static OSSL_FUNC_keymgmt_gen_cleanup_fn mac_gen_cleanup;
35 static OSSL_FUNC_keymgmt_gen_set_params_fn mac_gen_set_params;
36 static OSSL_FUNC_keymgmt_gen_settable_params_fn mac_gen_settable_params;
37 static OSSL_FUNC_keymgmt_get_params_fn mac_get_params;
38 static OSSL_FUNC_keymgmt_gettable_params_fn mac_gettable_params;
39 static OSSL_FUNC_keymgmt_set_params_fn mac_set_params;
40 static OSSL_FUNC_keymgmt_settable_params_fn mac_settable_params;
41 static OSSL_FUNC_keymgmt_has_fn mac_has;
42 static OSSL_FUNC_keymgmt_match_fn mac_match;
43 static OSSL_FUNC_keymgmt_import_fn mac_import;
44 static OSSL_FUNC_keymgmt_import_types_fn mac_imexport_types;
45 static OSSL_FUNC_keymgmt_export_fn mac_export;
46 static OSSL_FUNC_keymgmt_export_types_fn mac_imexport_types;
47 
48 static OSSL_FUNC_keymgmt_new_fn mac_new_cmac;
49 static OSSL_FUNC_keymgmt_gettable_params_fn cmac_gettable_params;
50 static OSSL_FUNC_keymgmt_import_types_fn cmac_imexport_types;
51 static OSSL_FUNC_keymgmt_export_types_fn cmac_imexport_types;
52 static OSSL_FUNC_keymgmt_gen_init_fn cmac_gen_init;
53 static OSSL_FUNC_keymgmt_gen_set_params_fn cmac_gen_set_params;
54 static OSSL_FUNC_keymgmt_gen_settable_params_fn cmac_gen_settable_params;
55 
56 struct mac_gen_ctx {
57     OSSL_LIB_CTX *libctx;
58     int selection;
59     unsigned char *priv_key;
60     size_t priv_key_len;
61     PROV_CIPHER cipher;
62 };
63 
64 MAC_KEY *ossl_mac_key_new(OSSL_LIB_CTX *libctx, int cmac)
65 {
66     MAC_KEY *mackey;
67 
68     if (!ossl_prov_is_running())
69         return NULL;
70 
71     mackey = OPENSSL_zalloc(sizeof(*mackey));
72     if (mackey == NULL)
73         return NULL;
74 
75     mackey->lock = CRYPTO_THREAD_lock_new();
76     if (mackey->lock == NULL) {
77         OPENSSL_free(mackey);
78         return NULL;
79     }
80     mackey->libctx = libctx;
81     mackey->refcnt = 1;
82     mackey->cmac = cmac;
83 
84     return mackey;
85 }
86 
87 void ossl_mac_key_free(MAC_KEY *mackey)
88 {
89     int ref = 0;
90 
91     if (mackey == NULL)
92         return;
93 
94     CRYPTO_DOWN_REF(&mackey->refcnt, &ref, mackey->lock);
95     if (ref > 0)
96         return;
97 
98     OPENSSL_secure_clear_free(mackey->priv_key, mackey->priv_key_len);
99     OPENSSL_free(mackey->properties);
100     ossl_prov_cipher_reset(&mackey->cipher);
101     CRYPTO_THREAD_lock_free(mackey->lock);
102     OPENSSL_free(mackey);
103 }
104 
105 int ossl_mac_key_up_ref(MAC_KEY *mackey)
106 {
107     int ref = 0;
108 
109     /* This is effectively doing a new operation on the MAC_KEY and should be
110      * adequately guarded again modules' error states.  However, both current
111      * calls here are guarded propery in signature/mac_legacy.c.  Thus, it
112      * could be removed here.  The concern is that something in the future
113      * might call this function without adequate guards.  It's a cheap call,
114      * it seems best to leave it even though it is currently redundant.
115      */
116     if (!ossl_prov_is_running())
117         return 0;
118 
119     CRYPTO_UP_REF(&mackey->refcnt, &ref, mackey->lock);
120     return 1;
121 }
122 
123 static void *mac_new(void *provctx)
124 {
125     return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 0);
126 }
127 
128 static void *mac_new_cmac(void *provctx)
129 {
130     return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 1);
131 }
132 
133 static void mac_free(void *mackey)
134 {
135     ossl_mac_key_free(mackey);
136 }
137 
138 static int mac_has(const void *keydata, int selection)
139 {
140     const MAC_KEY *key = keydata;
141     int ok = 0;
142 
143     if (ossl_prov_is_running() && key != NULL) {
144         /*
145          * MAC keys always have all the parameters they need (i.e. none).
146          * Therefore we always return with 1, if asked about parameters.
147          * Similarly for public keys.
148          */
149         ok = 1;
150 
151         if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
152             ok = key->priv_key != NULL;
153     }
154     return ok;
155 }
156 
157 static int mac_match(const void *keydata1, const void *keydata2, int selection)
158 {
159     const MAC_KEY *key1 = keydata1;
160     const MAC_KEY *key2 = keydata2;
161     int ok = 1;
162 
163     if (!ossl_prov_is_running())
164         return 0;
165 
166     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
167         if ((key1->priv_key == NULL && key2->priv_key != NULL)
168                 || (key1->priv_key != NULL && key2->priv_key == NULL)
169                 || key1->priv_key_len != key2->priv_key_len
170                 || (key1->cipher.cipher == NULL && key2->cipher.cipher != NULL)
171                 || (key1->cipher.cipher != NULL && key2->cipher.cipher == NULL))
172             ok = 0;
173         else
174             ok = ok && (key1->priv_key == NULL /* implies key2->privkey == NULL */
175                         || CRYPTO_memcmp(key1->priv_key, key2->priv_key,
176                                          key1->priv_key_len) == 0);
177         if (key1->cipher.cipher != NULL)
178             ok = ok && EVP_CIPHER_is_a(key1->cipher.cipher,
179                                        EVP_CIPHER_get0_name(key2->cipher.cipher));
180     }
181     return ok;
182 }
183 
184 static int mac_key_fromdata(MAC_KEY *key, const OSSL_PARAM params[])
185 {
186     const OSSL_PARAM *p;
187 
188     p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
189     if (p != NULL) {
190         if (p->data_type != OSSL_PARAM_OCTET_STRING) {
191             ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
192             return 0;
193         }
194         OPENSSL_secure_clear_free(key->priv_key, key->priv_key_len);
195         /* allocate at least one byte to distinguish empty key from no key set */
196         key->priv_key = OPENSSL_secure_malloc(p->data_size > 0 ? p->data_size : 1);
197         if (key->priv_key == NULL) {
198             ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
199             return 0;
200         }
201         memcpy(key->priv_key, p->data, p->data_size);
202         key->priv_key_len = p->data_size;
203     }
204 
205     p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES);
206     if (p != NULL) {
207         if (p->data_type != OSSL_PARAM_UTF8_STRING) {
208             ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
209             return 0;
210         }
211         OPENSSL_free(key->properties);
212         key->properties = OPENSSL_strdup(p->data);
213         if (key->properties == NULL) {
214             ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
215             return 0;
216         }
217     }
218 
219     if (key->cmac && !ossl_prov_cipher_load_from_params(&key->cipher, params,
220                                                         key->libctx)) {
221         ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
222         return 0;
223     }
224 
225     if (key->priv_key != NULL)
226         return 1;
227 
228     return 0;
229 }
230 
231 static int mac_import(void *keydata, int selection, const OSSL_PARAM params[])
232 {
233     MAC_KEY *key = keydata;
234 
235     if (!ossl_prov_is_running() || key == NULL)
236         return 0;
237 
238     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0)
239         return 0;
240 
241     return mac_key_fromdata(key, params);
242 }
243 
244 static int key_to_params(MAC_KEY *key, OSSL_PARAM_BLD *tmpl,
245                          OSSL_PARAM params[])
246 {
247     if (key == NULL)
248         return 0;
249 
250     if (key->priv_key != NULL
251         && !ossl_param_build_set_octet_string(tmpl, params,
252                                               OSSL_PKEY_PARAM_PRIV_KEY,
253                                               key->priv_key, key->priv_key_len))
254         return 0;
255 
256     if (key->cipher.cipher != NULL
257         && !ossl_param_build_set_utf8_string(tmpl, params,
258                                              OSSL_PKEY_PARAM_CIPHER,
259                                              EVP_CIPHER_get0_name(key->cipher.cipher)))
260         return 0;
261 
262 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
263     if (key->cipher.engine != NULL
264         && !ossl_param_build_set_utf8_string(tmpl, params,
265                                              OSSL_PKEY_PARAM_ENGINE,
266                                              ENGINE_get_id(key->cipher.engine)))
267         return 0;
268 #endif
269 
270     return 1;
271 }
272 
273 static int mac_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
274                       void *cbarg)
275 {
276     MAC_KEY *key = keydata;
277     OSSL_PARAM_BLD *tmpl;
278     OSSL_PARAM *params = NULL;
279     int ret = 0;
280 
281     if (!ossl_prov_is_running() || key == NULL)
282         return 0;
283 
284     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0)
285         return 0;
286 
287     tmpl = OSSL_PARAM_BLD_new();
288     if (tmpl == NULL)
289         return 0;
290 
291     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0
292          && !key_to_params(key, tmpl, NULL))
293         goto err;
294 
295     params = OSSL_PARAM_BLD_to_param(tmpl);
296     if (params == NULL)
297         goto err;
298 
299     ret = param_cb(params, cbarg);
300     OSSL_PARAM_free(params);
301 err:
302     OSSL_PARAM_BLD_free(tmpl);
303     return ret;
304 }
305 
306 static const OSSL_PARAM mac_key_types[] = {
307     OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
308     OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0),
309     OSSL_PARAM_END
310 };
311 static const OSSL_PARAM *mac_imexport_types(int selection)
312 {
313     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
314         return mac_key_types;
315     return NULL;
316 }
317 
318 static const OSSL_PARAM cmac_key_types[] = {
319     OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
320     OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
321     OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_ENGINE, NULL, 0),
322     OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0),
323     OSSL_PARAM_END
324 };
325 static const OSSL_PARAM *cmac_imexport_types(int selection)
326 {
327     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
328         return cmac_key_types;
329     return NULL;
330 }
331 
332 static int mac_get_params(void *key, OSSL_PARAM params[])
333 {
334     return key_to_params(key, NULL, params);
335 }
336 
337 static const OSSL_PARAM *mac_gettable_params(void *provctx)
338 {
339     static const OSSL_PARAM gettable_params[] = {
340         OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
341         OSSL_PARAM_END
342     };
343     return gettable_params;
344 }
345 
346 static const OSSL_PARAM *cmac_gettable_params(void *provctx)
347 {
348     static const OSSL_PARAM gettable_params[] = {
349         OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
350         OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
351         OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_ENGINE, NULL, 0),
352         OSSL_PARAM_END
353     };
354     return gettable_params;
355 }
356 
357 static int mac_set_params(void *keydata, const OSSL_PARAM params[])
358 {
359     MAC_KEY *key = keydata;
360     const OSSL_PARAM *p;
361 
362     if (key == NULL)
363         return 0;
364 
365     p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
366     if (p != NULL)
367         return mac_key_fromdata(key, params);
368 
369     return 1;
370 }
371 
372 static const OSSL_PARAM *mac_settable_params(void *provctx)
373 {
374     static const OSSL_PARAM settable_params[] = {
375         OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
376         OSSL_PARAM_END
377     };
378     return settable_params;
379 }
380 
381 static void *mac_gen_init_common(void *provctx, int selection)
382 {
383     OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
384     struct mac_gen_ctx *gctx = NULL;
385 
386     if (!ossl_prov_is_running())
387         return NULL;
388 
389     if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) {
390         gctx->libctx = libctx;
391         gctx->selection = selection;
392     }
393     return gctx;
394 }
395 
396 static void *mac_gen_init(void *provctx, int selection,
397                           const OSSL_PARAM params[])
398 {
399     struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
400 
401     if (gctx != NULL && !mac_gen_set_params(gctx, params)) {
402         OPENSSL_free(gctx);
403         gctx = NULL;
404     }
405     return gctx;
406 }
407 
408 static void *cmac_gen_init(void *provctx, int selection,
409                            const OSSL_PARAM params[])
410 {
411     struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
412 
413     if (gctx != NULL && !cmac_gen_set_params(gctx, params)) {
414         OPENSSL_free(gctx);
415         gctx = NULL;
416     }
417     return gctx;
418 }
419 
420 static int mac_gen_set_params(void *genctx, const OSSL_PARAM params[])
421 {
422     struct mac_gen_ctx *gctx = genctx;
423     const OSSL_PARAM *p;
424 
425     if (gctx == NULL)
426         return 0;
427 
428     p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
429     if (p != NULL) {
430         if (p->data_type != OSSL_PARAM_OCTET_STRING) {
431             ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
432             return 0;
433         }
434         gctx->priv_key = OPENSSL_secure_malloc(p->data_size);
435         if (gctx->priv_key == NULL) {
436             ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
437             return 0;
438         }
439         memcpy(gctx->priv_key, p->data, p->data_size);
440         gctx->priv_key_len = p->data_size;
441     }
442 
443     return 1;
444 }
445 
446 static int cmac_gen_set_params(void *genctx, const OSSL_PARAM params[])
447 {
448     struct mac_gen_ctx *gctx = genctx;
449 
450     if (!mac_gen_set_params(genctx, params))
451         return 0;
452 
453     if (!ossl_prov_cipher_load_from_params(&gctx->cipher, params,
454                                            gctx->libctx)) {
455         ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
456         return 0;
457     }
458 
459     return 1;
460 }
461 
462 static const OSSL_PARAM *mac_gen_settable_params(ossl_unused void *genctx,
463                                                  ossl_unused void *provctx)
464 {
465     static OSSL_PARAM settable[] = {
466         OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
467         OSSL_PARAM_END
468     };
469     return settable;
470 }
471 
472 static const OSSL_PARAM *cmac_gen_settable_params(ossl_unused void *genctx,
473                                                   ossl_unused void *provctx)
474 {
475     static OSSL_PARAM settable[] = {
476         OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
477         OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
478         OSSL_PARAM_END
479     };
480     return settable;
481 }
482 
483 static void *mac_gen(void *genctx, OSSL_CALLBACK *cb, void *cbarg)
484 {
485     struct mac_gen_ctx *gctx = genctx;
486     MAC_KEY *key;
487 
488     if (!ossl_prov_is_running() || gctx == NULL)
489         return NULL;
490 
491     if ((key = ossl_mac_key_new(gctx->libctx, 0)) == NULL) {
492         ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
493         return NULL;
494     }
495 
496     /* If we're doing parameter generation then we just return a blank key */
497     if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
498         return key;
499 
500     if (gctx->priv_key == NULL) {
501         ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
502         ossl_mac_key_free(key);
503         return NULL;
504     }
505 
506     /*
507      * This is horrible but required for backwards compatibility. We don't
508      * actually do real key generation at all. We simply copy the key that was
509      * previously set in the gctx. Hopefully at some point in the future all
510      * of this can be removed and we will only support the EVP_KDF APIs.
511      */
512     if (!ossl_prov_cipher_copy(&key->cipher, &gctx->cipher)) {
513         ossl_mac_key_free(key);
514         ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
515         return NULL;
516     }
517     ossl_prov_cipher_reset(&gctx->cipher);
518     key->priv_key = gctx->priv_key;
519     key->priv_key_len = gctx->priv_key_len;
520     gctx->priv_key_len = 0;
521     gctx->priv_key = NULL;
522 
523     return key;
524 }
525 
526 static void mac_gen_cleanup(void *genctx)
527 {
528     struct mac_gen_ctx *gctx = genctx;
529 
530     OPENSSL_secure_clear_free(gctx->priv_key, gctx->priv_key_len);
531     ossl_prov_cipher_reset(&gctx->cipher);
532     OPENSSL_free(gctx);
533 }
534 
535 const OSSL_DISPATCH ossl_mac_legacy_keymgmt_functions[] = {
536     { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))mac_new },
537     { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))mac_free },
538     { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))mac_get_params },
539     { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))mac_gettable_params },
540     { OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))mac_set_params },
541     { OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))mac_settable_params },
542     { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))mac_has },
543     { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))mac_match },
544     { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))mac_import },
545     { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))mac_imexport_types },
546     { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))mac_export },
547     { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))mac_imexport_types },
548     { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))mac_gen_init },
549     { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))mac_gen_set_params },
550     { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
551         (void (*)(void))mac_gen_settable_params },
552     { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))mac_gen },
553     { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))mac_gen_cleanup },
554     { 0, NULL }
555 };
556 
557 const OSSL_DISPATCH ossl_cmac_legacy_keymgmt_functions[] = {
558     { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))mac_new_cmac },
559     { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))mac_free },
560     { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))mac_get_params },
561     { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))cmac_gettable_params },
562     { OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*) (void))mac_set_params },
563     { OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, (void (*) (void))mac_settable_params },
564     { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))mac_has },
565     { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))mac_match },
566     { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))mac_import },
567     { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))cmac_imexport_types },
568     { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))mac_export },
569     { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))cmac_imexport_types },
570     { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))cmac_gen_init },
571     { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))cmac_gen_set_params },
572     { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
573         (void (*)(void))cmac_gen_settable_params },
574     { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))mac_gen },
575     { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))mac_gen_cleanup },
576     { 0, NULL }
577 };
578 
579