sskdf.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
  3. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
  4. *
  5. * Licensed under the Apache License 2.0 (the "License"). You may not use
  6. * this file except in compliance with the License. You can obtain a copy
  7. * in the file LICENSE in the source distribution or at
  8. * https://www.openssl.org/source/license.html
  9. */
  10. /*
  11. * Refer to https://csrc.nist.gov/publications/detail/sp/800-56c/rev-1/final
  12. * Section 4.1.
  13. *
  14. * The Single Step KDF algorithm is given by:
  15. *
  16. * Result(0) = empty bit string (i.e., the null string).
  17. * For i = 1 to reps, do the following:
  18. * Increment counter by 1.
  19. * Result(i) = Result(i - 1) || H(counter || Z || FixedInfo).
  20. * DKM = LeftmostBits(Result(reps), L))
  21. *
  22. * NOTES:
  23. * Z is a shared secret required to produce the derived key material.
  24. * counter is a 4 byte buffer.
  25. * FixedInfo is a bit string containing context specific data.
  26. * DKM is the output derived key material.
  27. * L is the required size of the DKM.
  28. * reps = [L / H_outputBits]
  29. * H(x) is the auxiliary function that can be either a hash, HMAC or KMAC.
  30. * H_outputBits is the length of the output of the auxiliary function H(x).
  31. *
  32. * Currently there is not a comprehensive list of test vectors for this
  33. * algorithm, especially for H(x) = HMAC and H(x) = KMAC.
  34. * Test vectors for H(x) = Hash are indirectly used by CAVS KAS tests.
  35. */
  36. #include <stdlib.h>
  37. #include <stdarg.h>
  38. #include <string.h>
  39. #include <openssl/hmac.h>
  40. #include <openssl/evp.h>
  41. #include <openssl/kdf.h>
  42. #include <openssl/core_names.h>
  43. #include <openssl/params.h>
  44. #include <openssl/proverr.h>
  45. #include "internal/cryptlib.h"
  46. #include "internal/numbers.h"
  47. #include "crypto/evp.h"
  48. #include "prov/provider_ctx.h"
  49. #include "prov/providercommon.h"
  50. #include "prov/implementations.h"
  51. #include "prov/provider_util.h"
  52. #include "internal/params.h"
  53. typedef struct {
  54. void *provctx;
  55. EVP_MAC_CTX *macctx; /* H(x) = HMAC_hash OR H(x) = KMAC */
  56. PROV_DIGEST digest; /* H(x) = hash(x) */
  57. unsigned char *secret;
  58. size_t secret_len;
  59. unsigned char *info;
  60. size_t info_len;
  61. unsigned char *salt;
  62. size_t salt_len;
  63. size_t out_len; /* optional KMAC parameter */
  64. int is_kmac;
  65. } KDF_SSKDF;
  66. #define SSKDF_MAX_INLEN (1<<30)
  67. #define SSKDF_KMAC128_DEFAULT_SALT_SIZE (168 - 4)
  68. #define SSKDF_KMAC256_DEFAULT_SALT_SIZE (136 - 4)
  69. /* KMAC uses a Customisation string of 'KDF' */
  70. static const unsigned char kmac_custom_str[] = { 0x4B, 0x44, 0x46 };
  71. static OSSL_FUNC_kdf_newctx_fn sskdf_new;
  72. static OSSL_FUNC_kdf_dupctx_fn sskdf_dup;
  73. static OSSL_FUNC_kdf_freectx_fn sskdf_free;
  74. static OSSL_FUNC_kdf_reset_fn sskdf_reset;
  75. static OSSL_FUNC_kdf_derive_fn sskdf_derive;
  76. static OSSL_FUNC_kdf_derive_fn x963kdf_derive;
  77. static OSSL_FUNC_kdf_settable_ctx_params_fn sskdf_settable_ctx_params;
  78. static OSSL_FUNC_kdf_set_ctx_params_fn sskdf_set_ctx_params;
  79. static OSSL_FUNC_kdf_gettable_ctx_params_fn sskdf_gettable_ctx_params;
  80. static OSSL_FUNC_kdf_get_ctx_params_fn sskdf_get_ctx_params;
  81. /*
  82. * Refer to https://csrc.nist.gov/publications/detail/sp/800-56c/rev-1/final
  83. * Section 4. One-Step Key Derivation using H(x) = hash(x)
  84. * Note: X9.63 also uses this code with the only difference being that the
  85. * counter is appended to the secret 'z'.
  86. * i.e.
  87. * result[i] = Hash(counter || z || info) for One Step OR
  88. * result[i] = Hash(z || counter || info) for X9.63.
  89. */
  90. static int SSKDF_hash_kdm(const EVP_MD *kdf_md,
  91. const unsigned char *z, size_t z_len,
  92. const unsigned char *info, size_t info_len,
  93. unsigned int append_ctr,
  94. unsigned char *derived_key, size_t derived_key_len)
  95. {
  96. int ret = 0, hlen;
  97. size_t counter, out_len, len = derived_key_len;
  98. unsigned char c[4];
  99. unsigned char mac[EVP_MAX_MD_SIZE];
  100. unsigned char *out = derived_key;
  101. EVP_MD_CTX *ctx = NULL, *ctx_init = NULL;
  102. if (z_len > SSKDF_MAX_INLEN || info_len > SSKDF_MAX_INLEN
  103. || derived_key_len > SSKDF_MAX_INLEN
  104. || derived_key_len == 0)
  105. return 0;
  106. hlen = EVP_MD_get_size(kdf_md);
  107. if (hlen <= 0)
  108. return 0;
  109. out_len = (size_t)hlen;
  110. ctx = EVP_MD_CTX_create();
  111. ctx_init = EVP_MD_CTX_create();
  112. if (ctx == NULL || ctx_init == NULL)
  113. goto end;
  114. if (!EVP_DigestInit(ctx_init, kdf_md))
  115. goto end;
  116. for (counter = 1;; counter++) {
  117. c[0] = (unsigned char)((counter >> 24) & 0xff);
  118. c[1] = (unsigned char)((counter >> 16) & 0xff);
  119. c[2] = (unsigned char)((counter >> 8) & 0xff);
  120. c[3] = (unsigned char)(counter & 0xff);
  121. if (!(EVP_MD_CTX_copy_ex(ctx, ctx_init)
  122. && (append_ctr || EVP_DigestUpdate(ctx, c, sizeof(c)))
  123. && EVP_DigestUpdate(ctx, z, z_len)
  124. && (!append_ctr || EVP_DigestUpdate(ctx, c, sizeof(c)))
  125. && EVP_DigestUpdate(ctx, info, info_len)))
  126. goto end;
  127. if (len >= out_len) {
  128. if (!EVP_DigestFinal_ex(ctx, out, NULL))
  129. goto end;
  130. out += out_len;
  131. len -= out_len;
  132. if (len == 0)
  133. break;
  134. } else {
  135. if (!EVP_DigestFinal_ex(ctx, mac, NULL))
  136. goto end;
  137. memcpy(out, mac, len);
  138. break;
  139. }
  140. }
  141. ret = 1;
  142. end:
  143. EVP_MD_CTX_destroy(ctx);
  144. EVP_MD_CTX_destroy(ctx_init);
  145. OPENSSL_cleanse(mac, sizeof(mac));
  146. return ret;
  147. }
  148. static int kmac_init(EVP_MAC_CTX *ctx, const unsigned char *custom,
  149. size_t custom_len, size_t kmac_out_len,
  150. size_t derived_key_len, unsigned char **out)
  151. {
  152. OSSL_PARAM params[2];
  153. /* Only KMAC has custom data - so return if not KMAC */
  154. if (custom == NULL)
  155. return 1;
  156. params[0] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_CUSTOM,
  157. (void *)custom, custom_len);
  158. params[1] = OSSL_PARAM_construct_end();
  159. if (!EVP_MAC_CTX_set_params(ctx, params))
  160. return 0;
  161. /* By default only do one iteration if kmac_out_len is not specified */
  162. if (kmac_out_len == 0)
  163. kmac_out_len = derived_key_len;
  164. /* otherwise check the size is valid */
  165. else if (!(kmac_out_len == derived_key_len
  166. || kmac_out_len == 20
  167. || kmac_out_len == 28
  168. || kmac_out_len == 32
  169. || kmac_out_len == 48
  170. || kmac_out_len == 64))
  171. return 0;
  172. params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE,
  173. &kmac_out_len);
  174. if (EVP_MAC_CTX_set_params(ctx, params) <= 0)
  175. return 0;
  176. /*
  177. * For kmac the output buffer can be larger than EVP_MAX_MD_SIZE: so
  178. * alloc a buffer for this case.
  179. */
  180. if (kmac_out_len > EVP_MAX_MD_SIZE) {
  181. *out = OPENSSL_zalloc(kmac_out_len);
  182. if (*out == NULL)
  183. return 0;
  184. }
  185. return 1;
  186. }
  187. /*
  188. * Refer to https://csrc.nist.gov/publications/detail/sp/800-56c/rev-1/final
  189. * Section 4. One-Step Key Derivation using MAC: i.e either
  190. * H(x) = HMAC-hash(salt, x) OR
  191. * H(x) = KMAC#(salt, x, outbits, CustomString='KDF')
  192. */
  193. static int SSKDF_mac_kdm(EVP_MAC_CTX *ctx_init,
  194. const unsigned char *kmac_custom,
  195. size_t kmac_custom_len, size_t kmac_out_len,
  196. const unsigned char *salt, size_t salt_len,
  197. const unsigned char *z, size_t z_len,
  198. const unsigned char *info, size_t info_len,
  199. unsigned char *derived_key, size_t derived_key_len)
  200. {
  201. int ret = 0;
  202. size_t counter, out_len, len;
  203. unsigned char c[4];
  204. unsigned char mac_buf[EVP_MAX_MD_SIZE];
  205. unsigned char *out = derived_key;
  206. EVP_MAC_CTX *ctx = NULL;
  207. unsigned char *mac = mac_buf, *kmac_buffer = NULL;
  208. if (z_len > SSKDF_MAX_INLEN || info_len > SSKDF_MAX_INLEN
  209. || derived_key_len > SSKDF_MAX_INLEN
  210. || derived_key_len == 0)
  211. return 0;
  212. if (!kmac_init(ctx_init, kmac_custom, kmac_custom_len, kmac_out_len,
  213. derived_key_len, &kmac_buffer))
  214. goto end;
  215. if (kmac_buffer != NULL)
  216. mac = kmac_buffer;
  217. if (!EVP_MAC_init(ctx_init, salt, salt_len, NULL))
  218. goto end;
  219. out_len = EVP_MAC_CTX_get_mac_size(ctx_init); /* output size */
  220. if (out_len <= 0 || (mac == mac_buf && out_len > sizeof(mac_buf)))
  221. goto end;
  222. len = derived_key_len;
  223. for (counter = 1;; counter++) {
  224. c[0] = (unsigned char)((counter >> 24) & 0xff);
  225. c[1] = (unsigned char)((counter >> 16) & 0xff);
  226. c[2] = (unsigned char)((counter >> 8) & 0xff);
  227. c[3] = (unsigned char)(counter & 0xff);
  228. ctx = EVP_MAC_CTX_dup(ctx_init);
  229. if (!(ctx != NULL
  230. && EVP_MAC_update(ctx, c, sizeof(c))
  231. && EVP_MAC_update(ctx, z, z_len)
  232. && EVP_MAC_update(ctx, info, info_len)))
  233. goto end;
  234. if (len >= out_len) {
  235. if (!EVP_MAC_final(ctx, out, NULL, len))
  236. goto end;
  237. out += out_len;
  238. len -= out_len;
  239. if (len == 0)
  240. break;
  241. } else {
  242. if (!EVP_MAC_final(ctx, mac, NULL, out_len))
  243. goto end;
  244. memcpy(out, mac, len);
  245. break;
  246. }
  247. EVP_MAC_CTX_free(ctx);
  248. ctx = NULL;
  249. }
  250. ret = 1;
  251. end:
  252. if (kmac_buffer != NULL)
  253. OPENSSL_clear_free(kmac_buffer, kmac_out_len);
  254. else
  255. OPENSSL_cleanse(mac_buf, sizeof(mac_buf));
  256. EVP_MAC_CTX_free(ctx);
  257. return ret;
  258. }
  259. static void *sskdf_new(void *provctx)
  260. {
  261. KDF_SSKDF *ctx;
  262. if (!ossl_prov_is_running())
  263. return NULL;
  264. if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) != NULL)
  265. ctx->provctx = provctx;
  266. return ctx;
  267. }
  268. static void sskdf_reset(void *vctx)
  269. {
  270. KDF_SSKDF *ctx = (KDF_SSKDF *)vctx;
  271. void *provctx = ctx->provctx;
  272. EVP_MAC_CTX_free(ctx->macctx);
  273. ossl_prov_digest_reset(&ctx->digest);
  274. OPENSSL_clear_free(ctx->secret, ctx->secret_len);
  275. OPENSSL_clear_free(ctx->info, ctx->info_len);
  276. OPENSSL_clear_free(ctx->salt, ctx->salt_len);
  277. memset(ctx, 0, sizeof(*ctx));
  278. ctx->provctx = provctx;
  279. }
  280. static void sskdf_free(void *vctx)
  281. {
  282. KDF_SSKDF *ctx = (KDF_SSKDF *)vctx;
  283. if (ctx != NULL) {
  284. sskdf_reset(ctx);
  285. OPENSSL_free(ctx);
  286. }
  287. }
  288. static void *sskdf_dup(void *vctx)
  289. {
  290. const KDF_SSKDF *src = (const KDF_SSKDF *)vctx;
  291. KDF_SSKDF *dest;
  292. dest = sskdf_new(src->provctx);
  293. if (dest != NULL) {
  294. if (src->macctx != NULL) {
  295. dest->macctx = EVP_MAC_CTX_dup(src->macctx);
  296. if (dest->macctx == NULL)
  297. goto err;
  298. }
  299. if (!ossl_prov_memdup(src->info, src->info_len,
  300. &dest->info, &dest->info_len)
  301. || !ossl_prov_memdup(src->salt, src->salt_len,
  302. &dest->salt , &dest->salt_len)
  303. || !ossl_prov_memdup(src->secret, src->secret_len,
  304. &dest->secret, &dest->secret_len)
  305. || !ossl_prov_digest_copy(&dest->digest, &src->digest))
  306. goto err;
  307. dest->out_len = src->out_len;
  308. dest->is_kmac = src->is_kmac;
  309. }
  310. return dest;
  311. err:
  312. sskdf_free(dest);
  313. return NULL;
  314. }
  315. static size_t sskdf_size(KDF_SSKDF *ctx)
  316. {
  317. int len;
  318. const EVP_MD *md = NULL;
  319. if (ctx->is_kmac)
  320. return SIZE_MAX;
  321. md = ossl_prov_digest_md(&ctx->digest);
  322. if (md == NULL) {
  323. ERR_raise(ERR_LIB_PROV, PROV_R_MISSING_MESSAGE_DIGEST);
  324. return 0;
  325. }
  326. len = EVP_MD_get_size(md);
  327. return (len <= 0) ? 0 : (size_t)len;
  328. }
  329. static int sskdf_derive(void *vctx, unsigned char *key, size_t keylen,
  330. const OSSL_PARAM params[])
  331. {
  332. KDF_SSKDF *ctx = (KDF_SSKDF *)vctx;
  333. const EVP_MD *md;
  334. if (!ossl_prov_is_running() || !sskdf_set_ctx_params(ctx, params))
  335. return 0;
  336. if (ctx->secret == NULL) {
  337. ERR_raise(ERR_LIB_PROV, PROV_R_MISSING_SECRET);
  338. return 0;
  339. }
  340. md = ossl_prov_digest_md(&ctx->digest);
  341. if (ctx->macctx != NULL) {
  342. /* H(x) = KMAC or H(x) = HMAC */
  343. int ret;
  344. const unsigned char *custom = NULL;
  345. size_t custom_len = 0;
  346. int default_salt_len;
  347. EVP_MAC *mac = EVP_MAC_CTX_get0_mac(ctx->macctx);
  348. if (EVP_MAC_is_a(mac, OSSL_MAC_NAME_HMAC)) {
  349. /* H(x) = HMAC(x, salt, hash) */
  350. if (md == NULL) {
  351. ERR_raise(ERR_LIB_PROV, PROV_R_MISSING_MESSAGE_DIGEST);
  352. return 0;
  353. }
  354. default_salt_len = EVP_MD_get_size(md);
  355. if (default_salt_len <= 0)
  356. return 0;
  357. } else if (ctx->is_kmac) {
  358. /* H(x) = KMACzzz(x, salt, custom) */
  359. custom = kmac_custom_str;
  360. custom_len = sizeof(kmac_custom_str);
  361. if (EVP_MAC_is_a(mac, OSSL_MAC_NAME_KMAC128))
  362. default_salt_len = SSKDF_KMAC128_DEFAULT_SALT_SIZE;
  363. else
  364. default_salt_len = SSKDF_KMAC256_DEFAULT_SALT_SIZE;
  365. } else {
  366. ERR_raise(ERR_LIB_PROV, PROV_R_UNSUPPORTED_MAC_TYPE);
  367. return 0;
  368. }
  369. /* If no salt is set then use a default_salt of zeros */
  370. if (ctx->salt == NULL || ctx->salt_len <= 0) {
  371. ctx->salt = OPENSSL_zalloc(default_salt_len);
  372. if (ctx->salt == NULL)
  373. return 0;
  374. ctx->salt_len = default_salt_len;
  375. }
  376. ret = SSKDF_mac_kdm(ctx->macctx,
  377. custom, custom_len, ctx->out_len,
  378. ctx->salt, ctx->salt_len,
  379. ctx->secret, ctx->secret_len,
  380. ctx->info, ctx->info_len, key, keylen);
  381. return ret;
  382. } else {
  383. /* H(x) = hash */
  384. if (md == NULL) {
  385. ERR_raise(ERR_LIB_PROV, PROV_R_MISSING_MESSAGE_DIGEST);
  386. return 0;
  387. }
  388. return SSKDF_hash_kdm(md, ctx->secret, ctx->secret_len,
  389. ctx->info, ctx->info_len, 0, key, keylen);
  390. }
  391. }
  392. static int x963kdf_derive(void *vctx, unsigned char *key, size_t keylen,
  393. const OSSL_PARAM params[])
  394. {
  395. KDF_SSKDF *ctx = (KDF_SSKDF *)vctx;
  396. const EVP_MD *md;
  397. if (!ossl_prov_is_running() || !sskdf_set_ctx_params(ctx, params))
  398. return 0;
  399. if (ctx->secret == NULL) {
  400. ERR_raise(ERR_LIB_PROV, PROV_R_MISSING_SECRET);
  401. return 0;
  402. }
  403. if (ctx->macctx != NULL) {
  404. ERR_raise(ERR_LIB_PROV, PROV_R_NOT_SUPPORTED);
  405. return 0;
  406. }
  407. /* H(x) = hash */
  408. md = ossl_prov_digest_md(&ctx->digest);
  409. if (md == NULL) {
  410. ERR_raise(ERR_LIB_PROV, PROV_R_MISSING_MESSAGE_DIGEST);
  411. return 0;
  412. }
  413. return SSKDF_hash_kdm(md, ctx->secret, ctx->secret_len,
  414. ctx->info, ctx->info_len, 1, key, keylen);
  415. }
  416. static int sskdf_set_ctx_params(void *vctx, const OSSL_PARAM params[])
  417. {
  418. const OSSL_PARAM *p;
  419. KDF_SSKDF *ctx = vctx;
  420. OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(ctx->provctx);
  421. size_t sz;
  422. int r;
  423. if (params == NULL)
  424. return 1;
  425. if (!ossl_prov_macctx_load_from_params(&ctx->macctx, params,
  426. NULL, NULL, NULL, libctx))
  427. return 0;
  428. if (ctx->macctx != NULL) {
  429. if (EVP_MAC_is_a(EVP_MAC_CTX_get0_mac(ctx->macctx),
  430. OSSL_MAC_NAME_KMAC128)
  431. || EVP_MAC_is_a(EVP_MAC_CTX_get0_mac(ctx->macctx),
  432. OSSL_MAC_NAME_KMAC256)) {
  433. ctx->is_kmac = 1;
  434. }
  435. }
  436. if (!ossl_prov_digest_load_from_params(&ctx->digest, params, libctx))
  437. return 0;
  438. r = ossl_param_get1_octet_string(params, OSSL_KDF_PARAM_SECRET,
  439. &ctx->secret, &ctx->secret_len);
  440. if (r == -1)
  441. r = ossl_param_get1_octet_string(params, OSSL_KDF_PARAM_KEY,
  442. &ctx->secret, &ctx->secret_len);
  443. if (r == 0)
  444. return 0;
  445. if (ossl_param_get1_concat_octet_string(params, OSSL_KDF_PARAM_INFO,
  446. &ctx->info, &ctx->info_len, 0) == 0)
  447. return 0;
  448. if (ossl_param_get1_octet_string(params, OSSL_KDF_PARAM_SALT,
  449. &ctx->salt, &ctx->salt_len) == 0)
  450. return 0;
  451. if ((p = OSSL_PARAM_locate_const(params, OSSL_KDF_PARAM_MAC_SIZE))
  452. != NULL) {
  453. if (!OSSL_PARAM_get_size_t(p, &sz) || sz == 0)
  454. return 0;
  455. ctx->out_len = sz;
  456. }
  457. return 1;
  458. }
  459. static const OSSL_PARAM *sskdf_settable_ctx_params(ossl_unused void *ctx,
  460. ossl_unused void *provctx)
  461. {
  462. static const OSSL_PARAM known_settable_ctx_params[] = {
  463. OSSL_PARAM_octet_string(OSSL_KDF_PARAM_SECRET, NULL, 0),
  464. OSSL_PARAM_octet_string(OSSL_KDF_PARAM_KEY, NULL, 0),
  465. OSSL_PARAM_octet_string(OSSL_KDF_PARAM_INFO, NULL, 0),
  466. OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_PROPERTIES, NULL, 0),
  467. OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_DIGEST, NULL, 0),
  468. OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_MAC, NULL, 0),
  469. OSSL_PARAM_octet_string(OSSL_KDF_PARAM_SALT, NULL, 0),
  470. OSSL_PARAM_size_t(OSSL_KDF_PARAM_MAC_SIZE, NULL),
  471. OSSL_PARAM_END
  472. };
  473. return known_settable_ctx_params;
  474. }
  475. static int sskdf_get_ctx_params(void *vctx, OSSL_PARAM params[])
  476. {
  477. KDF_SSKDF *ctx = (KDF_SSKDF *)vctx;
  478. OSSL_PARAM *p;
  479. if ((p = OSSL_PARAM_locate(params, OSSL_KDF_PARAM_SIZE)) != NULL)
  480. return OSSL_PARAM_set_size_t(p, sskdf_size(ctx));
  481. return -2;
  482. }
  483. static const OSSL_PARAM *sskdf_gettable_ctx_params(ossl_unused void *ctx,
  484. ossl_unused void *provctx)
  485. {
  486. static const OSSL_PARAM known_gettable_ctx_params[] = {
  487. OSSL_PARAM_size_t(OSSL_KDF_PARAM_SIZE, NULL),
  488. OSSL_PARAM_END
  489. };
  490. return known_gettable_ctx_params;
  491. }
  492. const OSSL_DISPATCH ossl_kdf_sskdf_functions[] = {
  493. { OSSL_FUNC_KDF_NEWCTX, (void(*)(void))sskdf_new },
  494. { OSSL_FUNC_KDF_DUPCTX, (void(*)(void))sskdf_dup },
  495. { OSSL_FUNC_KDF_FREECTX, (void(*)(void))sskdf_free },
  496. { OSSL_FUNC_KDF_RESET, (void(*)(void))sskdf_reset },
  497. { OSSL_FUNC_KDF_DERIVE, (void(*)(void))sskdf_derive },
  498. { OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS,
  499. (void(*)(void))sskdf_settable_ctx_params },
  500. { OSSL_FUNC_KDF_SET_CTX_PARAMS, (void(*)(void))sskdf_set_ctx_params },
  501. { OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS,
  502. (void(*)(void))sskdf_gettable_ctx_params },
  503. { OSSL_FUNC_KDF_GET_CTX_PARAMS, (void(*)(void))sskdf_get_ctx_params },
  504. OSSL_DISPATCH_END
  505. };
  506. const OSSL_DISPATCH ossl_kdf_x963_kdf_functions[] = {
  507. { OSSL_FUNC_KDF_NEWCTX, (void(*)(void))sskdf_new },
  508. { OSSL_FUNC_KDF_DUPCTX, (void(*)(void))sskdf_dup },
  509. { OSSL_FUNC_KDF_FREECTX, (void(*)(void))sskdf_free },
  510. { OSSL_FUNC_KDF_RESET, (void(*)(void))sskdf_reset },
  511. { OSSL_FUNC_KDF_DERIVE, (void(*)(void))x963kdf_derive },
  512. { OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS,
  513. (void(*)(void))sskdf_settable_ctx_params },
  514. { OSSL_FUNC_KDF_SET_CTX_PARAMS, (void(*)(void))sskdf_set_ctx_params },
  515. { OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS,
  516. (void(*)(void))sskdf_gettable_ctx_params },
  517. { OSSL_FUNC_KDF_GET_CTX_PARAMS, (void(*)(void))sskdf_get_ctx_params },
  518. OSSL_DISPATCH_END
  519. };