mac_legacy_kmgmt.c 18 KB

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