/src/openssl35/providers/implementations/keymgmt/slh_dsa_kmgmt.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2024-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 | | #include <openssl/core_dispatch.h> |
11 | | #include <openssl/core_names.h> |
12 | | #include <openssl/param_build.h> |
13 | | #include <openssl/self_test.h> |
14 | | #include <openssl/proverr.h> |
15 | | #include "crypto/slh_dsa.h" |
16 | | #include "internal/fips.h" |
17 | | #include "internal/param_build_set.h" |
18 | | #include "prov/implementations.h" |
19 | | #include "prov/providercommon.h" |
20 | | #include "prov/provider_ctx.h" |
21 | | #include "fips/fipsindicator.h" |
22 | | |
23 | | #ifdef FIPS_MODULE |
24 | | static int slh_dsa_fips140_pairwise_test(const SLH_DSA_KEY *key, |
25 | | SLH_DSA_HASH_CTX *ctx); |
26 | | #endif /* FIPS_MODULE */ |
27 | | |
28 | | static OSSL_FUNC_keymgmt_free_fn slh_dsa_free_key; |
29 | | static OSSL_FUNC_keymgmt_has_fn slh_dsa_has; |
30 | | static OSSL_FUNC_keymgmt_match_fn slh_dsa_match; |
31 | | static OSSL_FUNC_keymgmt_import_fn slh_dsa_import; |
32 | | static OSSL_FUNC_keymgmt_export_fn slh_dsa_export; |
33 | | static OSSL_FUNC_keymgmt_import_types_fn slh_dsa_imexport_types; |
34 | | static OSSL_FUNC_keymgmt_export_types_fn slh_dsa_imexport_types; |
35 | | static OSSL_FUNC_keymgmt_load_fn slh_dsa_load; |
36 | | static OSSL_FUNC_keymgmt_get_params_fn slh_dsa_get_params; |
37 | | static OSSL_FUNC_keymgmt_gettable_params_fn slh_dsa_gettable_params; |
38 | | static OSSL_FUNC_keymgmt_validate_fn slh_dsa_validate; |
39 | | static OSSL_FUNC_keymgmt_gen_init_fn slh_dsa_gen_init; |
40 | | static OSSL_FUNC_keymgmt_gen_cleanup_fn slh_dsa_gen_cleanup; |
41 | | static OSSL_FUNC_keymgmt_gen_set_params_fn slh_dsa_gen_set_params; |
42 | | static OSSL_FUNC_keymgmt_gen_settable_params_fn slh_dsa_gen_settable_params; |
43 | | static OSSL_FUNC_keymgmt_dup_fn slh_dsa_dup_key; |
44 | | |
45 | 1.92k | #define SLH_DSA_POSSIBLE_SELECTIONS (OSSL_KEYMGMT_SELECT_KEYPAIR) |
46 | | |
47 | | struct slh_dsa_gen_ctx { |
48 | | SLH_DSA_HASH_CTX *ctx; |
49 | | OSSL_LIB_CTX *libctx; |
50 | | char *propq; |
51 | | uint8_t entropy[SLH_DSA_MAX_N * 3]; |
52 | | size_t entropy_len; |
53 | | }; |
54 | | |
55 | | static void *slh_dsa_new_key(void *provctx, const char *alg) |
56 | 727 | { |
57 | 727 | if (!ossl_prov_is_running()) |
58 | 0 | return 0; |
59 | | |
60 | 727 | return ossl_slh_dsa_key_new(PROV_LIBCTX_OF(provctx), NULL, alg); |
61 | 727 | } |
62 | | |
63 | | static void slh_dsa_free_key(void *keydata) |
64 | 2.89k | { |
65 | 2.89k | ossl_slh_dsa_key_free((SLH_DSA_KEY *)keydata); |
66 | 2.89k | } |
67 | | |
68 | | static void *slh_dsa_dup_key(const void *keydata_from, int selection) |
69 | 24 | { |
70 | 24 | if (ossl_prov_is_running()) |
71 | 24 | return ossl_slh_dsa_key_dup(keydata_from, selection); |
72 | 0 | return NULL; |
73 | 24 | } |
74 | | |
75 | | static int slh_dsa_has(const void *keydata, int selection) |
76 | 1.78k | { |
77 | 1.78k | const SLH_DSA_KEY *key = keydata; |
78 | | |
79 | 1.78k | if (!ossl_prov_is_running() || key == NULL) |
80 | 0 | return 0; |
81 | 1.78k | if ((selection & SLH_DSA_POSSIBLE_SELECTIONS) == 0) |
82 | 24 | return 1; /* the selection is not missing */ |
83 | | |
84 | 1.75k | return ossl_slh_dsa_key_has(key, selection); |
85 | 1.78k | } |
86 | | |
87 | | static int slh_dsa_match(const void *keydata1, const void *keydata2, int selection) |
88 | 723 | { |
89 | 723 | const SLH_DSA_KEY *key1 = keydata1; |
90 | 723 | const SLH_DSA_KEY *key2 = keydata2; |
91 | | |
92 | 723 | if (!ossl_prov_is_running()) |
93 | 0 | return 0; |
94 | 723 | if (key1 == NULL || key2 == NULL) |
95 | 0 | return 0; |
96 | 723 | return ossl_slh_dsa_key_equal(key1, key2, selection); |
97 | 723 | } |
98 | | |
99 | | static int slh_dsa_validate(const void *key_data, int selection, int check_type) |
100 | 96 | { |
101 | 96 | const SLH_DSA_KEY *key = key_data; |
102 | | |
103 | 96 | if (!slh_dsa_has(key, selection)) |
104 | 0 | return 0; |
105 | | |
106 | 96 | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == OSSL_KEYMGMT_SELECT_KEYPAIR) |
107 | 24 | return ossl_slh_dsa_key_pairwise_check(key); |
108 | 72 | return 1; |
109 | 96 | } |
110 | | |
111 | | static int slh_dsa_import(void *keydata, int selection, const OSSL_PARAM params[]) |
112 | 145 | { |
113 | 145 | SLH_DSA_KEY *key = keydata; |
114 | 145 | int include_priv; |
115 | | |
116 | 145 | if (!ossl_prov_is_running() || key == NULL) |
117 | 0 | return 0; |
118 | | |
119 | 145 | if ((selection & SLH_DSA_POSSIBLE_SELECTIONS) == 0) |
120 | 0 | return 0; |
121 | | |
122 | 145 | include_priv = ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0); |
123 | 145 | return ossl_slh_dsa_key_fromdata(key, params, include_priv); |
124 | 145 | } |
125 | | |
126 | | #define SLH_DSA_IMEXPORTABLE_PARAMETERS \ |
127 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0), \ |
128 | | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0) |
129 | | |
130 | | static const OSSL_PARAM slh_dsa_key_types[] = { |
131 | | SLH_DSA_IMEXPORTABLE_PARAMETERS, |
132 | | OSSL_PARAM_END |
133 | | }; |
134 | | static const OSSL_PARAM *slh_dsa_imexport_types(int selection) |
135 | 0 | { |
136 | 0 | if ((selection & SLH_DSA_POSSIBLE_SELECTIONS) == 0) |
137 | 0 | return NULL; |
138 | 0 | return slh_dsa_key_types; |
139 | 0 | } |
140 | | |
141 | | static const OSSL_PARAM slh_dsa_params[] = { |
142 | | OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL), |
143 | | OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL), |
144 | | OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL), |
145 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_MANDATORY_DIGEST, NULL, 0), |
146 | | SLH_DSA_IMEXPORTABLE_PARAMETERS, |
147 | | OSSL_PARAM_END |
148 | | }; |
149 | | static const OSSL_PARAM *slh_dsa_gettable_params(void *provctx) |
150 | 0 | { |
151 | 0 | return slh_dsa_params; |
152 | 0 | } |
153 | | |
154 | | static int key_to_params(SLH_DSA_KEY *key, OSSL_PARAM_BLD *tmpl, |
155 | | int selection) |
156 | 538 | { |
157 | | /* Error if there is no key or public key */ |
158 | 538 | if (key == NULL || ossl_slh_dsa_key_get_pub(key) == NULL) |
159 | 0 | return 0; |
160 | | |
161 | 538 | if (((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) |
162 | 538 | && ossl_slh_dsa_key_get_priv(key) != NULL) |
163 | 538 | if (ossl_param_build_set_octet_string(tmpl, NULL, |
164 | 538 | OSSL_PKEY_PARAM_PRIV_KEY, |
165 | 538 | ossl_slh_dsa_key_get_priv(key), |
166 | 538 | ossl_slh_dsa_key_get_priv_len(key)) |
167 | 538 | != 1) |
168 | 0 | return 0; |
169 | | |
170 | 538 | if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) == 0) |
171 | 0 | return 1; |
172 | | |
173 | 538 | return ossl_param_build_set_octet_string(tmpl, NULL, |
174 | 538 | OSSL_PKEY_PARAM_PUB_KEY, |
175 | 538 | ossl_slh_dsa_key_get_pub(key), |
176 | 538 | ossl_slh_dsa_key_get_pub_len(key)); |
177 | 538 | } |
178 | | |
179 | | static int slh_dsa_get_params(void *keydata, OSSL_PARAM params[]) |
180 | 669 | { |
181 | 669 | SLH_DSA_KEY *key = keydata; |
182 | 669 | OSSL_PARAM *p; |
183 | 669 | const uint8_t *pub, *priv; |
184 | | |
185 | 669 | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL |
186 | 669 | && !OSSL_PARAM_set_int(p, 8 * ossl_slh_dsa_key_get_pub_len(key))) |
187 | 0 | return 0; |
188 | 669 | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != NULL |
189 | 669 | && !OSSL_PARAM_set_int(p, 8 * ossl_slh_dsa_key_get_n(key))) |
190 | 0 | return 0; |
191 | 669 | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL |
192 | 669 | && !OSSL_PARAM_set_int(p, ossl_slh_dsa_key_get_sig_len(key))) |
193 | 0 | return 0; |
194 | | |
195 | 669 | priv = ossl_slh_dsa_key_get_priv(key); |
196 | 669 | if (priv != NULL) { |
197 | 669 | p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PRIV_KEY); |
198 | | /* Note: ossl_slh_dsa_key_get_priv_len() includes the public key */ |
199 | 669 | if (p != NULL |
200 | 0 | && !OSSL_PARAM_set_octet_string(p, priv, |
201 | 0 | ossl_slh_dsa_key_get_priv_len(key))) |
202 | 0 | return 0; |
203 | 669 | } |
204 | 669 | pub = ossl_slh_dsa_key_get_pub(key); |
205 | 669 | if (pub != NULL) { |
206 | 669 | p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PUB_KEY); |
207 | 669 | if (p != NULL |
208 | 0 | && !OSSL_PARAM_set_octet_string(p, pub, |
209 | 0 | ossl_slh_dsa_key_get_pub_len(key))) |
210 | 0 | return 0; |
211 | 669 | } |
212 | | /* |
213 | | * This allows apps to use an empty digest, so that the old API |
214 | | * for digest signing can be used. |
215 | | */ |
216 | 669 | p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MANDATORY_DIGEST); |
217 | 669 | if (p != NULL && !OSSL_PARAM_set_utf8_string(p, "")) |
218 | 0 | return 0; |
219 | 669 | return 1; |
220 | 669 | } |
221 | | |
222 | | static int slh_dsa_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, |
223 | | void *cbarg) |
224 | 198 | { |
225 | 198 | SLH_DSA_KEY *key = keydata; |
226 | 198 | OSSL_PARAM_BLD *tmpl; |
227 | 198 | OSSL_PARAM *params = NULL, *p; |
228 | 198 | int ret = 0; |
229 | | |
230 | 198 | if (!ossl_prov_is_running() || key == NULL) |
231 | 0 | return 0; |
232 | | |
233 | 198 | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0) |
234 | 0 | return 0; |
235 | | |
236 | 198 | tmpl = OSSL_PARAM_BLD_new(); |
237 | 198 | if (tmpl == NULL) |
238 | 0 | return 0; |
239 | | |
240 | 198 | if (!key_to_params(key, tmpl, selection)) |
241 | 0 | goto err; |
242 | | |
243 | 198 | params = OSSL_PARAM_BLD_to_param(tmpl); |
244 | 198 | if (params == NULL) |
245 | 0 | goto err; |
246 | | |
247 | 198 | ret = param_cb(params, cbarg); |
248 | | /* |
249 | | * OSSL_PARAM_free() only wipes the secure-heap data block, |
250 | | * so wipe the key material copies held in the params first. |
251 | | */ |
252 | 594 | for (p = params; p->key != NULL; p++) |
253 | 396 | OPENSSL_cleanse(p->data, p->data_size); |
254 | 198 | OSSL_PARAM_free(params); |
255 | 198 | err: |
256 | 198 | OSSL_PARAM_BLD_free(tmpl); |
257 | 198 | return ret; |
258 | 198 | } |
259 | | |
260 | | static void *slh_dsa_load(const void *reference, size_t reference_sz) |
261 | 191 | { |
262 | 191 | SLH_DSA_KEY *key = NULL; |
263 | | |
264 | 191 | if (ossl_prov_is_running() && reference_sz == sizeof(key)) { |
265 | | /* The contents of the reference is the address to our object */ |
266 | 191 | key = *(SLH_DSA_KEY **)reference; |
267 | | /* We grabbed, so we detach it */ |
268 | 191 | *(SLH_DSA_KEY **)reference = NULL; |
269 | 191 | return key; |
270 | 191 | } |
271 | 0 | return NULL; |
272 | 191 | } |
273 | | |
274 | | static void *slh_dsa_gen_init(void *provctx, int selection, |
275 | | const OSSL_PARAM params[]) |
276 | 1.95k | { |
277 | 1.95k | OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx); |
278 | 1.95k | struct slh_dsa_gen_ctx *gctx = NULL; |
279 | | |
280 | 1.95k | if (!ossl_prov_is_running()) |
281 | 0 | return NULL; |
282 | | |
283 | 1.95k | if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) { |
284 | 1.95k | gctx->libctx = libctx; |
285 | 1.95k | if (!slh_dsa_gen_set_params(gctx, params)) { |
286 | 0 | OPENSSL_free(gctx); |
287 | 0 | gctx = NULL; |
288 | 0 | } |
289 | 1.95k | } |
290 | 1.95k | return gctx; |
291 | 1.95k | } |
292 | | |
293 | | #ifdef FIPS_MODULE |
294 | | /* |
295 | | * Refer to FIPS 140-3 IG 10.3.A Additional Comment 1 |
296 | | * Perform a pairwise test for SLH_DSA by signing and verifying a signature. |
297 | | */ |
298 | | static int slh_dsa_fips140_pairwise_test(const SLH_DSA_KEY *key, |
299 | | SLH_DSA_HASH_CTX *ctx) |
300 | | { |
301 | | int ret = 0; |
302 | | OSSL_SELF_TEST *st = NULL; |
303 | | OSSL_CALLBACK *cb = NULL; |
304 | | void *cb_arg = NULL; |
305 | | uint8_t msg[16] = { 0 }; |
306 | | size_t msg_len = sizeof(msg); |
307 | | uint8_t *sig = NULL; |
308 | | size_t sig_len = 0; |
309 | | OSSL_LIB_CTX *lib_ctx; |
310 | | int alloc_ctx = 0; |
311 | | |
312 | | /* During self test, it is a waste to do this test */ |
313 | | if (ossl_fips_self_testing()) |
314 | | return 1; |
315 | | |
316 | | if (ctx == NULL) { |
317 | | ctx = ossl_slh_dsa_hash_ctx_new(key); |
318 | | if (ctx == NULL) |
319 | | return 0; |
320 | | alloc_ctx = 1; |
321 | | } |
322 | | lib_ctx = ossl_slh_dsa_key_get0_libctx(key); |
323 | | |
324 | | OSSL_SELF_TEST_get_callback(lib_ctx, &cb, &cb_arg); |
325 | | st = OSSL_SELF_TEST_new(cb, cb_arg); |
326 | | if (st == NULL) |
327 | | goto err; |
328 | | |
329 | | OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_PCT, |
330 | | OSSL_SELF_TEST_DESC_PCT_SLH_DSA); |
331 | | |
332 | | sig_len = ossl_slh_dsa_key_get_sig_len(key); |
333 | | sig = OPENSSL_malloc(sig_len); |
334 | | if (sig == NULL) |
335 | | goto err; |
336 | | |
337 | | if (ossl_slh_dsa_sign(ctx, msg, msg_len, NULL, 0, NULL, 0, |
338 | | sig, &sig_len, sig_len) |
339 | | != 1) |
340 | | goto err; |
341 | | |
342 | | OSSL_SELF_TEST_oncorrupt_byte(st, sig); |
343 | | |
344 | | if (ossl_slh_dsa_verify(ctx, msg, msg_len, NULL, 0, 0, sig, sig_len) != 1) |
345 | | goto err; |
346 | | |
347 | | ret = 1; |
348 | | err: |
349 | | if (alloc_ctx) |
350 | | ossl_slh_dsa_hash_ctx_free(ctx); |
351 | | OPENSSL_clear_free(sig, sig_len); |
352 | | OSSL_SELF_TEST_onend(st, ret); |
353 | | OSSL_SELF_TEST_free(st); |
354 | | return ret; |
355 | | } |
356 | | #endif /* FIPS_MODULE */ |
357 | | |
358 | | static void *slh_dsa_gen(void *genctx, const char *alg) |
359 | 1.95k | { |
360 | 1.95k | struct slh_dsa_gen_ctx *gctx = genctx; |
361 | 1.95k | SLH_DSA_KEY *key = NULL; |
362 | 1.95k | SLH_DSA_HASH_CTX *ctx = NULL; |
363 | | |
364 | 1.95k | if (!ossl_prov_is_running()) |
365 | 0 | return NULL; |
366 | 1.95k | key = ossl_slh_dsa_key_new(gctx->libctx, gctx->propq, alg); |
367 | 1.95k | if (key == NULL) |
368 | 0 | return NULL; |
369 | 1.95k | ctx = ossl_slh_dsa_hash_ctx_new(key); |
370 | 1.95k | if (ctx == NULL) |
371 | 0 | goto err; |
372 | 1.95k | if (!ossl_slh_dsa_generate_key(ctx, key, gctx->libctx, |
373 | 1.95k | gctx->entropy, gctx->entropy_len)) |
374 | 0 | goto err; |
375 | | #ifdef FIPS_MODULE |
376 | | if (!slh_dsa_fips140_pairwise_test(key, ctx)) |
377 | | goto err; |
378 | | #endif /* FIPS_MODULE */ |
379 | 1.95k | ossl_slh_dsa_hash_ctx_free(ctx); |
380 | 1.95k | return key; |
381 | 0 | err: |
382 | 0 | ossl_slh_dsa_hash_ctx_free(ctx); |
383 | 0 | ossl_slh_dsa_key_free(key); |
384 | 0 | return NULL; |
385 | 1.95k | } |
386 | | |
387 | | static int slh_dsa_gen_set_params(void *genctx, const OSSL_PARAM params[]) |
388 | 504 | { |
389 | 504 | struct slh_dsa_gen_ctx *gctx = genctx; |
390 | 504 | const OSSL_PARAM *p; |
391 | | |
392 | 504 | if (gctx == NULL) |
393 | 0 | return 0; |
394 | | |
395 | 504 | p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_SLH_DSA_SEED); |
396 | 504 | if (p != NULL) { |
397 | 0 | void *vp = gctx->entropy; |
398 | 0 | size_t len = sizeof(gctx->entropy); |
399 | |
|
400 | 0 | if (!OSSL_PARAM_get_octet_string(p, &vp, len, &(gctx->entropy_len))) { |
401 | 0 | gctx->entropy_len = 0; |
402 | 0 | return 0; |
403 | 0 | } |
404 | 0 | } |
405 | | |
406 | 504 | p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES); |
407 | 504 | if (p != NULL) { |
408 | 0 | if (p->data_type != OSSL_PARAM_UTF8_STRING) |
409 | 0 | return 0; |
410 | 0 | OPENSSL_free(gctx->propq); |
411 | 0 | gctx->propq = OPENSSL_strdup(p->data); |
412 | 0 | if (gctx->propq == NULL) |
413 | 0 | return 0; |
414 | 0 | } |
415 | 504 | return 1; |
416 | 504 | } |
417 | | |
418 | | static const OSSL_PARAM *slh_dsa_gen_settable_params(ossl_unused void *genctx, |
419 | | ossl_unused void *provctx) |
420 | 0 | { |
421 | 0 | static OSSL_PARAM settable[] = { |
422 | 0 | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0), |
423 | 0 | OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_SLH_DSA_SEED, NULL, 0), |
424 | 0 | OSSL_PARAM_END |
425 | 0 | }; |
426 | 0 | return settable; |
427 | 0 | } |
428 | | |
429 | | static void slh_dsa_gen_cleanup(void *genctx) |
430 | 1.95k | { |
431 | 1.95k | struct slh_dsa_gen_ctx *gctx = genctx; |
432 | | |
433 | 1.95k | if (gctx == NULL) |
434 | 0 | return; |
435 | | |
436 | 1.95k | OPENSSL_cleanse(gctx->entropy, sizeof(gctx->entropy)); |
437 | 1.95k | OPENSSL_free(gctx->propq); |
438 | 1.95k | OPENSSL_free(gctx); |
439 | 1.95k | } |
440 | | |
441 | | #define MAKE_KEYMGMT_FUNCTIONS(alg, fn) \ |
442 | | static OSSL_FUNC_keymgmt_new_fn slh_dsa_##fn##_new_key; \ |
443 | | static OSSL_FUNC_keymgmt_gen_fn slh_dsa_##fn##_gen; \ |
444 | | static void *slh_dsa_##fn##_new_key(void *provctx) \ |
445 | 727 | { \ |
446 | 727 | return slh_dsa_new_key(provctx, alg); \ |
447 | 727 | } \ slh_dsa_kmgmt.c:slh_dsa_sha2_128s_new_key Line | Count | Source | 445 | 129 | { \ | 446 | 129 | return slh_dsa_new_key(provctx, alg); \ | 447 | 129 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_128f_new_key Line | Count | Source | 445 | 56 | { \ | 446 | 56 | return slh_dsa_new_key(provctx, alg); \ | 447 | 56 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_192s_new_key Line | Count | Source | 445 | 53 | { \ | 446 | 53 | return slh_dsa_new_key(provctx, alg); \ | 447 | 53 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_192f_new_key Line | Count | Source | 445 | 107 | { \ | 446 | 107 | return slh_dsa_new_key(provctx, alg); \ | 447 | 107 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_256s_new_key Line | Count | Source | 445 | 36 | { \ | 446 | 36 | return slh_dsa_new_key(provctx, alg); \ | 447 | 36 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_256f_new_key Line | Count | Source | 445 | 44 | { \ | 446 | 44 | return slh_dsa_new_key(provctx, alg); \ | 447 | 44 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_128s_new_key Line | Count | Source | 445 | 54 | { \ | 446 | 54 | return slh_dsa_new_key(provctx, alg); \ | 447 | 54 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_128f_new_key Line | Count | Source | 445 | 44 | { \ | 446 | 44 | return slh_dsa_new_key(provctx, alg); \ | 447 | 44 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_192s_new_key Line | Count | Source | 445 | 66 | { \ | 446 | 66 | return slh_dsa_new_key(provctx, alg); \ | 447 | 66 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_192f_new_key Line | Count | Source | 445 | 37 | { \ | 446 | 37 | return slh_dsa_new_key(provctx, alg); \ | 447 | 37 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_256s_new_key Line | Count | Source | 445 | 60 | { \ | 446 | 60 | return slh_dsa_new_key(provctx, alg); \ | 447 | 60 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_256f_new_key Line | Count | Source | 445 | 41 | { \ | 446 | 41 | return slh_dsa_new_key(provctx, alg); \ | 447 | 41 | } \ |
|
448 | | static void *slh_dsa_##fn##_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg) \ |
449 | 1.95k | { \ |
450 | 1.95k | return slh_dsa_gen(genctx, alg); \ |
451 | 1.95k | } \ slh_dsa_kmgmt.c:slh_dsa_sha2_128s_gen Line | Count | Source | 449 | 299 | { \ | 450 | 299 | return slh_dsa_gen(genctx, alg); \ | 451 | 299 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_128f_gen Line | Count | Source | 449 | 265 | { \ | 450 | 265 | return slh_dsa_gen(genctx, alg); \ | 451 | 265 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_192s_gen Line | Count | Source | 449 | 93 | { \ | 450 | 93 | return slh_dsa_gen(genctx, alg); \ | 451 | 93 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_192f_gen Line | Count | Source | 449 | 346 | { \ | 450 | 346 | return slh_dsa_gen(genctx, alg); \ | 451 | 346 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_256s_gen Line | Count | Source | 449 | 125 | { \ | 450 | 125 | return slh_dsa_gen(genctx, alg); \ | 451 | 125 | } \ |
slh_dsa_kmgmt.c:slh_dsa_sha2_256f_gen Line | Count | Source | 449 | 147 | { \ | 450 | 147 | return slh_dsa_gen(genctx, alg); \ | 451 | 147 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_128s_gen Line | Count | Source | 449 | 75 | { \ | 450 | 75 | return slh_dsa_gen(genctx, alg); \ | 451 | 75 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_128f_gen Line | Count | Source | 449 | 52 | { \ | 450 | 52 | return slh_dsa_gen(genctx, alg); \ | 451 | 52 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_192s_gen Line | Count | Source | 449 | 136 | { \ | 450 | 136 | return slh_dsa_gen(genctx, alg); \ | 451 | 136 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_192f_gen Line | Count | Source | 449 | 175 | { \ | 450 | 175 | return slh_dsa_gen(genctx, alg); \ | 451 | 175 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_256s_gen Line | Count | Source | 449 | 139 | { \ | 450 | 139 | return slh_dsa_gen(genctx, alg); \ | 451 | 139 | } \ |
slh_dsa_kmgmt.c:slh_dsa_shake_256f_gen Line | Count | Source | 449 | 98 | { \ | 450 | 98 | return slh_dsa_gen(genctx, alg); \ | 451 | 98 | } \ |
|
452 | | const OSSL_DISPATCH ossl_slh_dsa_##fn##_keymgmt_functions[] = { \ |
453 | | { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))slh_dsa_##fn##_new_key }, \ |
454 | | { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))slh_dsa_free_key }, \ |
455 | | { OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))slh_dsa_dup_key }, \ |
456 | | { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))slh_dsa_has }, \ |
457 | | { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))slh_dsa_match }, \ |
458 | | { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))slh_dsa_import }, \ |
459 | | { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))slh_dsa_imexport_types }, \ |
460 | | { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))slh_dsa_export }, \ |
461 | | { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))slh_dsa_imexport_types }, \ |
462 | | { OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))slh_dsa_load }, \ |
463 | | { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*)(void))slh_dsa_get_params }, \ |
464 | | { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*)(void))slh_dsa_gettable_params }, \ |
465 | | { OSSL_FUNC_KEYMGMT_VALIDATE, (void (*)(void))slh_dsa_validate }, \ |
466 | | { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))slh_dsa_gen_init }, \ |
467 | | { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))slh_dsa_##fn##_gen }, \ |
468 | | { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))slh_dsa_gen_cleanup }, \ |
469 | | { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, \ |
470 | | (void (*)(void))slh_dsa_gen_set_params }, \ |
471 | | { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, \ |
472 | | (void (*)(void))slh_dsa_gen_settable_params }, \ |
473 | | OSSL_FIPS_IND_APPROVED_DISPATCH(OSSL_FUNC_KEYMGMT_GEN_GET_PARAMS, \ |
474 | | OSSL_FUNC_KEYMGMT_GEN_GETTABLE_PARAMS) \ |
475 | | OSSL_DISPATCH_END \ |
476 | | } |
477 | | |
478 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHA2-128s", sha2_128s); |
479 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHA2-128f", sha2_128f); |
480 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHA2-192s", sha2_192s); |
481 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHA2-192f", sha2_192f); |
482 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHA2-256s", sha2_256s); |
483 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHA2-256f", sha2_256f); |
484 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHAKE-128s", shake_128s); |
485 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHAKE-128f", shake_128f); |
486 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHAKE-192s", shake_192s); |
487 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHAKE-192f", shake_192f); |
488 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHAKE-256s", shake_256s); |
489 | | MAKE_KEYMGMT_FUNCTIONS("SLH-DSA-SHAKE-256f", shake_256f); |