mac_legacy_kmgmt.c 18 KB

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