Coverage Report

Created: 2025-06-13 06:58

/src/openssl30/providers/implementations/keymgmt/mac_legacy_kmgmt.c
Line
Count
Source (jump to first uncovered line)
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
/* 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
1.42k
{
66
1.42k
    MAC_KEY *mackey;
67
68
1.42k
    if (!ossl_prov_is_running())
69
0
        return NULL;
70
71
1.42k
    mackey = OPENSSL_zalloc(sizeof(*mackey));
72
1.42k
    if (mackey == NULL)
73
0
        return NULL;
74
75
1.42k
    mackey->lock = CRYPTO_THREAD_lock_new();
76
1.42k
    if (mackey->lock == NULL) {
77
0
        OPENSSL_free(mackey);
78
0
        return NULL;
79
0
    }
80
1.42k
    mackey->libctx = libctx;
81
1.42k
    mackey->refcnt = 1;
82
1.42k
    mackey->cmac = cmac;
83
84
1.42k
    return mackey;
85
1.42k
}
86
87
void ossl_mac_key_free(MAC_KEY *mackey)
88
373k
{
89
373k
    int ref = 0;
90
91
373k
    if (mackey == NULL)
92
7.05k
        return;
93
94
365k
    CRYPTO_DOWN_REF(&mackey->refcnt, &ref, mackey->lock);
95
365k
    if (ref > 0)
96
358k
        return;
97
98
7.05k
    OPENSSL_secure_clear_free(mackey->priv_key, mackey->priv_key_len);
99
7.05k
    OPENSSL_free(mackey->properties);
100
7.05k
    ossl_prov_cipher_reset(&mackey->cipher);
101
7.05k
    CRYPTO_THREAD_lock_free(mackey->lock);
102
7.05k
    OPENSSL_free(mackey);
103
7.05k
}
104
105
int ossl_mac_key_up_ref(MAC_KEY *mackey)
106
358k
{
107
358k
    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
358k
    if (!ossl_prov_is_running())
117
0
        return 0;
118
119
358k
    CRYPTO_UP_REF(&mackey->refcnt, &ref, mackey->lock);
120
358k
    return 1;
121
358k
}
122
123
static void *mac_new(void *provctx)
124
7.05k
{
125
7.05k
    return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 0);
126
7.05k
}
127
128
static void *mac_new_cmac(void *provctx)
129
0
{
130
0
    return ossl_mac_key_new(PROV_LIBCTX_OF(provctx), 1);
131
0
}
132
133
static void mac_free(void *mackey)
134
7.05k
{
135
7.05k
    ossl_mac_key_free(mackey);
136
7.05k
}
137
138
static int mac_has(const void *keydata, int selection)
139
0
{
140
0
    const MAC_KEY *key = keydata;
141
0
    int ok = 0;
142
143
0
    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
0
        ok = 1;
150
151
0
        if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
152
0
            ok = key->priv_key != NULL;
153
0
    }
154
0
    return ok;
155
0
}
156
157
static int mac_match(const void *keydata1, const void *keydata2, int selection)
158
0
{
159
0
    const MAC_KEY *key1 = keydata1;
160
0
    const MAC_KEY *key2 = keydata2;
161
0
    int ok = 1;
162
163
0
    if (!ossl_prov_is_running())
164
0
        return 0;
165
166
0
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
167
0
        if ((key1->priv_key == NULL && key2->priv_key != NULL)
168
0
                || (key1->priv_key != NULL && key2->priv_key == NULL)
169
0
                || key1->priv_key_len != key2->priv_key_len
170
0
                || (key1->cipher.cipher == NULL && key2->cipher.cipher != NULL)
171
0
                || (key1->cipher.cipher != NULL && key2->cipher.cipher == NULL))
172
0
            ok = 0;
173
0
        else
174
0
            ok = ok && (key1->priv_key == NULL /* implies key2->privkey == NULL */
175
0
                        || CRYPTO_memcmp(key1->priv_key, key2->priv_key,
176
0
                                         key1->priv_key_len) == 0);
177
0
        if (key1->cipher.cipher != NULL)
178
0
            ok = ok && EVP_CIPHER_is_a(key1->cipher.cipher,
179
0
                                       EVP_CIPHER_get0_name(key2->cipher.cipher));
180
0
    }
181
0
    return ok;
182
0
}
183
184
static int mac_key_fromdata(MAC_KEY *key, const OSSL_PARAM params[])
185
7.05k
{
186
7.05k
    const OSSL_PARAM *p;
187
188
7.05k
    p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
189
7.05k
    if (p != NULL) {
190
7.05k
        if (p->data_type != OSSL_PARAM_OCTET_STRING) {
191
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
192
0
            return 0;
193
0
        }
194
7.05k
        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
7.05k
        key->priv_key = OPENSSL_secure_malloc(p->data_size > 0 ? p->data_size : 1);
197
7.05k
        if (key->priv_key == NULL) {
198
0
            ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
199
0
            return 0;
200
0
        }
201
7.05k
        memcpy(key->priv_key, p->data, p->data_size);
202
7.05k
        key->priv_key_len = p->data_size;
203
7.05k
    }
204
205
7.05k
    p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES);
206
7.05k
    if (p != NULL) {
207
0
        if (p->data_type != OSSL_PARAM_UTF8_STRING) {
208
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
209
0
            return 0;
210
0
        }
211
0
        OPENSSL_free(key->properties);
212
0
        key->properties = OPENSSL_strdup(p->data);
213
0
        if (key->properties == NULL) {
214
0
            ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
215
0
            return 0;
216
0
        }
217
0
    }
218
219
7.05k
    if (key->cmac && !ossl_prov_cipher_load_from_params(&key->cipher, params,
220
0
                                                        key->libctx)) {
221
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
222
0
        return 0;
223
0
    }
224
225
7.05k
    if (key->priv_key != NULL)
226
7.05k
        return 1;
227
228
0
    return 0;
229
7.05k
}
230
231
static int mac_import(void *keydata, int selection, const OSSL_PARAM params[])
232
7.05k
{
233
7.05k
    MAC_KEY *key = keydata;
234
235
7.05k
    if (!ossl_prov_is_running() || key == NULL)
236
0
        return 0;
237
238
7.05k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0)
239
0
        return 0;
240
241
7.05k
    return mac_key_fromdata(key, params);
242
7.05k
}
243
244
static int key_to_params(MAC_KEY *key, OSSL_PARAM_BLD *tmpl,
245
                         OSSL_PARAM params[])
246
7.05k
{
247
7.05k
    if (key == NULL)
248
0
        return 0;
249
250
7.05k
    if (key->priv_key != NULL
251
7.05k
        && !ossl_param_build_set_octet_string(tmpl, params,
252
7.05k
                                              OSSL_PKEY_PARAM_PRIV_KEY,
253
7.05k
                                              key->priv_key, key->priv_key_len))
254
0
        return 0;
255
256
7.05k
    if (key->cipher.cipher != NULL
257
7.05k
        && !ossl_param_build_set_utf8_string(tmpl, params,
258
0
                                             OSSL_PKEY_PARAM_CIPHER,
259
0
                                             EVP_CIPHER_get0_name(key->cipher.cipher)))
260
0
        return 0;
261
262
7.05k
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
263
7.05k
    if (key->cipher.engine != NULL
264
7.05k
        && !ossl_param_build_set_utf8_string(tmpl, params,
265
0
                                             OSSL_PKEY_PARAM_ENGINE,
266
0
                                             ENGINE_get_id(key->cipher.engine)))
267
0
        return 0;
268
7.05k
#endif
269
270
7.05k
    return 1;
271
7.05k
}
272
273
static int mac_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
274
                      void *cbarg)
275
0
{
276
0
    MAC_KEY *key = keydata;
277
0
    OSSL_PARAM_BLD *tmpl;
278
0
    OSSL_PARAM *params = NULL;
279
0
    int ret = 0;
280
281
0
    if (!ossl_prov_is_running() || key == NULL)
282
0
        return 0;
283
284
0
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0)
285
0
        return 0;
286
287
0
    tmpl = OSSL_PARAM_BLD_new();
288
0
    if (tmpl == NULL)
289
0
        return 0;
290
291
0
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0
292
0
         && !key_to_params(key, tmpl, NULL))
293
0
        goto err;
294
295
0
    params = OSSL_PARAM_BLD_to_param(tmpl);
296
0
    if (params == NULL)
297
0
        goto err;
298
299
0
    ret = param_cb(params, cbarg);
300
0
    OSSL_PARAM_free(params);
301
0
err:
302
0
    OSSL_PARAM_BLD_free(tmpl);
303
0
    return ret;
304
0
}
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
0
{
313
0
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
314
0
        return mac_key_types;
315
0
    return NULL;
316
0
}
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
0
{
327
0
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
328
0
        return cmac_key_types;
329
0
    return NULL;
330
0
}
331
332
static int mac_get_params(void *key, OSSL_PARAM params[])
333
7.05k
{
334
7.05k
    return key_to_params(key, NULL, params);
335
7.05k
}
336
337
static const OSSL_PARAM *mac_gettable_params(void *provctx)
338
0
{
339
0
    static const OSSL_PARAM gettable_params[] = {
340
0
        OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
341
0
        OSSL_PARAM_END
342
0
    };
343
0
    return gettable_params;
344
0
}
345
346
static const OSSL_PARAM *cmac_gettable_params(void *provctx)
347
0
{
348
0
    static const OSSL_PARAM gettable_params[] = {
349
0
        OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
350
0
        OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
351
0
        OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_ENGINE, NULL, 0),
352
0
        OSSL_PARAM_END
353
0
    };
354
0
    return gettable_params;
355
0
}
356
357
static int mac_set_params(void *keydata, const OSSL_PARAM params[])
358
0
{
359
0
    MAC_KEY *key = keydata;
360
0
    const OSSL_PARAM *p;
361
362
0
    if (key == NULL)
363
0
        return 0;
364
365
0
    p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
366
0
    if (p != NULL)
367
0
        return mac_key_fromdata(key, params);
368
369
0
    return 1;
370
0
}
371
372
static const OSSL_PARAM *mac_settable_params(void *provctx)
373
0
{
374
0
    static const OSSL_PARAM settable_params[] = {
375
0
        OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
376
0
        OSSL_PARAM_END
377
0
    };
378
0
    return settable_params;
379
0
}
380
381
static void *mac_gen_init_common(void *provctx, int selection)
382
0
{
383
0
    OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
384
0
    struct mac_gen_ctx *gctx = NULL;
385
386
0
    if (!ossl_prov_is_running())
387
0
        return NULL;
388
389
0
    if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) {
390
0
        gctx->libctx = libctx;
391
0
        gctx->selection = selection;
392
0
    }
393
0
    return gctx;
394
0
}
395
396
static void *mac_gen_init(void *provctx, int selection,
397
                          const OSSL_PARAM params[])
398
0
{
399
0
    struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
400
401
0
    if (gctx != NULL && !mac_gen_set_params(gctx, params)) {
402
0
        mac_gen_cleanup(gctx);
403
0
        gctx = NULL;
404
0
    }
405
0
    return gctx;
406
0
}
407
408
static void *cmac_gen_init(void *provctx, int selection,
409
                           const OSSL_PARAM params[])
410
0
{
411
0
    struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
412
413
0
    if (gctx != NULL && !cmac_gen_set_params(gctx, params)) {
414
0
        mac_gen_cleanup(gctx);
415
0
        gctx = NULL;
416
0
    }
417
0
    return gctx;
418
0
}
419
420
static int mac_gen_set_params(void *genctx, const OSSL_PARAM params[])
421
0
{
422
0
    struct mac_gen_ctx *gctx = genctx;
423
0
    const OSSL_PARAM *p;
424
425
0
    if (gctx == NULL)
426
0
        return 0;
427
428
0
    p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
429
0
    if (p != NULL) {
430
0
        if (p->data_type != OSSL_PARAM_OCTET_STRING) {
431
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
432
0
            return 0;
433
0
        }
434
0
        gctx->priv_key = OPENSSL_secure_malloc(p->data_size);
435
0
        if (gctx->priv_key == NULL) {
436
0
            ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
437
0
            return 0;
438
0
        }
439
0
        memcpy(gctx->priv_key, p->data, p->data_size);
440
0
        gctx->priv_key_len = p->data_size;
441
0
    }
442
443
0
    return 1;
444
0
}
445
446
static int cmac_gen_set_params(void *genctx, const OSSL_PARAM params[])
447
0
{
448
0
    struct mac_gen_ctx *gctx = genctx;
449
450
0
    if (!mac_gen_set_params(genctx, params))
451
0
        return 0;
452
453
0
    if (!ossl_prov_cipher_load_from_params(&gctx->cipher, params,
454
0
                                           gctx->libctx)) {
455
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
456
0
        return 0;
457
0
    }
458
459
0
    return 1;
460
0
}
461
462
static const OSSL_PARAM *mac_gen_settable_params(ossl_unused void *genctx,
463
                                                 ossl_unused void *provctx)
464
0
{
465
0
    static OSSL_PARAM settable[] = {
466
0
        OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
467
0
        OSSL_PARAM_END
468
0
    };
469
0
    return settable;
470
0
}
471
472
static const OSSL_PARAM *cmac_gen_settable_params(ossl_unused void *genctx,
473
                                                  ossl_unused void *provctx)
474
0
{
475
0
    static OSSL_PARAM settable[] = {
476
0
        OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0),
477
0
        OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_CIPHER, NULL, 0),
478
0
        OSSL_PARAM_END
479
0
    };
480
0
    return settable;
481
0
}
482
483
static void *mac_gen(void *genctx, OSSL_CALLBACK *cb, void *cbarg)
484
0
{
485
0
    struct mac_gen_ctx *gctx = genctx;
486
0
    MAC_KEY *key;
487
488
0
    if (!ossl_prov_is_running() || gctx == NULL)
489
0
        return NULL;
490
491
0
    if ((key = ossl_mac_key_new(gctx->libctx, 0)) == NULL) {
492
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
493
0
        return NULL;
494
0
    }
495
496
    /* If we're doing parameter generation then we just return a blank key */
497
0
    if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
498
0
        return key;
499
500
0
    if (gctx->priv_key == NULL) {
501
0
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
502
0
        ossl_mac_key_free(key);
503
0
        return NULL;
504
0
    }
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
0
    if (!ossl_prov_cipher_copy(&key->cipher, &gctx->cipher)) {
513
0
        ossl_mac_key_free(key);
514
0
        ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
515
0
        return NULL;
516
0
    }
517
0
    ossl_prov_cipher_reset(&gctx->cipher);
518
0
    key->priv_key = gctx->priv_key;
519
0
    key->priv_key_len = gctx->priv_key_len;
520
0
    gctx->priv_key_len = 0;
521
0
    gctx->priv_key = NULL;
522
523
0
    return key;
524
0
}
525
526
static void mac_gen_cleanup(void *genctx)
527
0
{
528
0
    struct mac_gen_ctx *gctx = genctx;
529
530
0
    OPENSSL_secure_clear_free(gctx->priv_key, gctx->priv_key_len);
531
0
    ossl_prov_cipher_reset(&gctx->cipher);
532
0
    OPENSSL_free(gctx);
533
0
}
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