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