Coverage Report

Created: 2026-10-28 06:28

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