/src/openssl/providers/implementations/signature/ml_dsa_sig.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2024-2025 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 "internal/deprecated.h" |
11 | | |
12 | | #include <assert.h> |
13 | | #include <string.h> /* memset */ |
14 | | #include <openssl/core_names.h> |
15 | | #include <openssl/err.h> |
16 | | #include <openssl/rand.h> |
17 | | #include <openssl/proverr.h> |
18 | | #include "prov/implementations.h" |
19 | | #include "prov/providercommon.h" |
20 | | #include "prov/provider_ctx.h" |
21 | | #include "prov/der_ml_dsa.h" |
22 | | #include "crypto/ml_dsa.h" |
23 | | #include "internal/common.h" |
24 | | #include "internal/packet.h" |
25 | | #include "internal/sizes.h" |
26 | | #include "internal/fips.h" |
27 | | |
28 | | #define ml_dsa_set_ctx_params_st ml_dsa_verifymsg_set_ctx_params_st |
29 | | #define ml_dsa_set_ctx_params_decoder ml_dsa_verifymsg_set_ctx_params_decoder |
30 | | |
31 | | #include "providers/implementations/signature/ml_dsa_sig.inc" |
32 | | |
33 | | #define ML_DSA_MESSAGE_ENCODE_RAW 0 |
34 | 0 | #define ML_DSA_MESSAGE_ENCODE_PURE 1 |
35 | | |
36 | | static OSSL_FUNC_signature_sign_message_init_fn ml_dsa_sign_msg_init; |
37 | | static OSSL_FUNC_signature_sign_message_update_fn ml_dsa_signverify_msg_update; |
38 | | static OSSL_FUNC_signature_sign_message_final_fn ml_dsa_sign_msg_final; |
39 | | static OSSL_FUNC_signature_sign_fn ml_dsa_sign; |
40 | | static OSSL_FUNC_signature_verify_message_init_fn ml_dsa_verify_msg_init; |
41 | | static OSSL_FUNC_signature_verify_message_update_fn ml_dsa_signverify_msg_update; |
42 | | static OSSL_FUNC_signature_verify_message_final_fn ml_dsa_verify_msg_final; |
43 | | static OSSL_FUNC_signature_verify_fn ml_dsa_verify; |
44 | | static OSSL_FUNC_signature_digest_sign_init_fn ml_dsa_digest_signverify_init; |
45 | | static OSSL_FUNC_signature_digest_sign_fn ml_dsa_digest_sign; |
46 | | static OSSL_FUNC_signature_digest_verify_fn ml_dsa_digest_verify; |
47 | | static OSSL_FUNC_signature_freectx_fn ml_dsa_freectx; |
48 | | static OSSL_FUNC_signature_set_ctx_params_fn ml_dsa_set_ctx_params; |
49 | | static OSSL_FUNC_signature_settable_ctx_params_fn ml_dsa_settable_ctx_params; |
50 | | static OSSL_FUNC_signature_get_ctx_params_fn ml_dsa_get_ctx_params; |
51 | | static OSSL_FUNC_signature_gettable_ctx_params_fn ml_dsa_gettable_ctx_params; |
52 | | static OSSL_FUNC_signature_dupctx_fn ml_dsa_dupctx; |
53 | | |
54 | | typedef struct { |
55 | | ML_DSA_KEY *key; |
56 | | OSSL_LIB_CTX *libctx; |
57 | | uint8_t context_string[ML_DSA_MAX_CONTEXT_STRING_LEN]; |
58 | | size_t context_string_len; |
59 | | uint8_t test_entropy[ML_DSA_ENTROPY_LEN]; |
60 | | size_t test_entropy_len; |
61 | | int msg_encode; |
62 | | int deterministic; |
63 | | int evp_type; |
64 | | /* The Algorithm Identifier of the signature algorithm */ |
65 | | uint8_t aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE]; |
66 | | size_t aid_len; |
67 | | int mu; /* Flag indicating we should begin from \mu, not the message */ |
68 | | |
69 | | int operation; |
70 | | EVP_MD_CTX *md_ctx; /* Ctx for msg_init/update/final interface */ |
71 | | unsigned char *sig; /* Signature, for verification */ |
72 | | size_t siglen; |
73 | | } PROV_ML_DSA_CTX; |
74 | | |
75 | | static void ml_dsa_freectx(void *vctx) |
76 | 0 | { |
77 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
78 | |
|
79 | 0 | EVP_MD_CTX_free(ctx->md_ctx); |
80 | 0 | OPENSSL_cleanse(ctx->test_entropy, ctx->test_entropy_len); |
81 | 0 | OPENSSL_free(ctx->sig); |
82 | 0 | OPENSSL_free(ctx); |
83 | 0 | } |
84 | | |
85 | | static void *ml_dsa_newctx(void *provctx, int evp_type, const char *propq) |
86 | 0 | { |
87 | 0 | PROV_ML_DSA_CTX *ctx; |
88 | |
|
89 | 0 | if (!ossl_prov_is_running()) |
90 | 0 | return NULL; |
91 | | |
92 | | #ifdef FIPS_MODULE |
93 | | if (!ossl_deferred_self_test(PROV_LIBCTX_OF(provctx), |
94 | | ST_ID_SIG_ML_DSA_65)) |
95 | | return NULL; |
96 | | #endif |
97 | | |
98 | 0 | ctx = OPENSSL_zalloc(sizeof(PROV_ML_DSA_CTX)); |
99 | 0 | if (ctx == NULL) |
100 | 0 | return NULL; |
101 | | |
102 | 0 | ctx->libctx = PROV_LIBCTX_OF(provctx); |
103 | 0 | ctx->msg_encode = ML_DSA_MESSAGE_ENCODE_PURE; |
104 | 0 | ctx->evp_type = evp_type; |
105 | 0 | return ctx; |
106 | 0 | } |
107 | | |
108 | | static void *ml_dsa_dupctx(void *vctx) |
109 | 0 | { |
110 | 0 | PROV_ML_DSA_CTX *srcctx = (PROV_ML_DSA_CTX *)vctx; |
111 | 0 | PROV_ML_DSA_CTX *dstctx; |
112 | |
|
113 | 0 | if (!ossl_prov_is_running()) |
114 | 0 | return NULL; |
115 | | |
116 | | /* |
117 | | * Note that the ML_DSA_KEY is ref counted via EVP_PKEY so we can just copy |
118 | | * the key here. |
119 | | */ |
120 | 0 | dstctx = OPENSSL_memdup(srcctx, sizeof(*srcctx)); |
121 | |
|
122 | 0 | if (dstctx == NULL) |
123 | 0 | return NULL; |
124 | | |
125 | 0 | if (srcctx->sig != NULL) { |
126 | 0 | dstctx->sig = OPENSSL_memdup(srcctx->sig, srcctx->siglen); |
127 | 0 | if (dstctx->sig == NULL) { |
128 | | /* |
129 | | * Can't call ml_dsa_freectx() here, as it would free |
130 | | * md_ctx which has not been duplicated yet. |
131 | | */ |
132 | 0 | OPENSSL_free(dstctx); |
133 | 0 | return NULL; |
134 | 0 | } |
135 | 0 | } |
136 | | |
137 | 0 | if (srcctx->md_ctx != NULL) { |
138 | 0 | dstctx->md_ctx = EVP_MD_CTX_dup(srcctx->md_ctx); |
139 | 0 | if (dstctx->md_ctx == NULL) { |
140 | 0 | ml_dsa_freectx(dstctx); |
141 | 0 | return NULL; |
142 | 0 | } |
143 | 0 | } |
144 | | |
145 | 0 | return dstctx; |
146 | 0 | } |
147 | | |
148 | | static int set_alg_id_buffer(PROV_ML_DSA_CTX *ctx) |
149 | 0 | { |
150 | 0 | int ret; |
151 | 0 | WPACKET pkt; |
152 | 0 | uint8_t *aid = NULL; |
153 | | |
154 | | /* |
155 | | * We do not care about DER writing errors. |
156 | | * All it really means is that for some reason, there's no |
157 | | * AlgorithmIdentifier to be had, but the operation itself is |
158 | | * still valid, just as long as it's not used to construct |
159 | | * anything that needs an AlgorithmIdentifier. |
160 | | */ |
161 | 0 | ctx->aid_len = 0; |
162 | 0 | ret = WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf)); |
163 | 0 | ret = ret && ossl_DER_w_algorithmIdentifier_ML_DSA(&pkt, -1, ctx->key); |
164 | 0 | if (ret && WPACKET_finish(&pkt)) { |
165 | 0 | WPACKET_get_total_written(&pkt, &ctx->aid_len); |
166 | 0 | aid = WPACKET_get_curr(&pkt); |
167 | 0 | } |
168 | 0 | WPACKET_cleanup(&pkt); |
169 | 0 | if (aid != NULL && ctx->aid_len != 0) |
170 | 0 | memmove(ctx->aid_buf, aid, ctx->aid_len); |
171 | 0 | return 1; |
172 | 0 | } |
173 | | |
174 | | static int ml_dsa_signverify_msg_init(void *vctx, void *vkey, |
175 | | const OSSL_PARAM params[], int operation, |
176 | | const char *desc) |
177 | 0 | { |
178 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
179 | 0 | ML_DSA_KEY *key = vkey; |
180 | |
|
181 | 0 | if (!ossl_prov_is_running() |
182 | 0 | || ctx == NULL) |
183 | 0 | return 0; |
184 | | |
185 | 0 | if (vkey == NULL && ctx->key == NULL) { |
186 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET); |
187 | 0 | return 0; |
188 | 0 | } |
189 | | |
190 | 0 | if (key != NULL) |
191 | 0 | ctx->key = vkey; |
192 | 0 | if (!ossl_ml_dsa_key_matches(ctx->key, ctx->evp_type)) |
193 | 0 | return 0; |
194 | | |
195 | 0 | set_alg_id_buffer(ctx); |
196 | 0 | ctx->mu = 0; |
197 | 0 | ctx->operation = operation; |
198 | |
|
199 | 0 | return ml_dsa_set_ctx_params(ctx, params); |
200 | 0 | } |
201 | | |
202 | | static int ml_dsa_sign_msg_init(void *vctx, void *vkey, const OSSL_PARAM params[]) |
203 | 0 | { |
204 | 0 | return ml_dsa_signverify_msg_init(vctx, vkey, params, |
205 | 0 | EVP_PKEY_OP_SIGNMSG, "ML_DSA Sign Init"); |
206 | 0 | } |
207 | | |
208 | | static int ml_dsa_digest_signverify_init(void *vctx, const char *mdname, |
209 | | void *vkey, const OSSL_PARAM params[]) |
210 | 0 | { |
211 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
212 | |
|
213 | 0 | if (mdname != NULL && mdname[0] != '\0') { |
214 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, |
215 | 0 | "Explicit digest not supported for ML-DSA operations"); |
216 | 0 | return 0; |
217 | 0 | } |
218 | | |
219 | 0 | ctx->mu = 0; |
220 | |
|
221 | 0 | if (vkey == NULL && ctx->key != NULL) |
222 | 0 | return ml_dsa_set_ctx_params(ctx, params); |
223 | | |
224 | 0 | return ml_dsa_signverify_msg_init(vctx, vkey, params, |
225 | 0 | EVP_PKEY_OP_SIGN, "ML_DSA Sign Init"); |
226 | 0 | } |
227 | | |
228 | | static int ml_dsa_signverify_msg_update(void *vctx, |
229 | | const unsigned char *data, |
230 | | size_t datalen) |
231 | 0 | { |
232 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
233 | |
|
234 | 0 | if (ctx == NULL) |
235 | 0 | return 0; |
236 | | |
237 | 0 | if (!ossl_prov_is_running()) |
238 | 0 | return 0; |
239 | | |
240 | 0 | if (ctx->mu) |
241 | 0 | return 0; |
242 | | |
243 | 0 | if (ctx->md_ctx == NULL) { |
244 | 0 | ctx->md_ctx = ossl_ml_dsa_mu_init(ctx->key, ctx->msg_encode, |
245 | 0 | ctx->context_string, |
246 | 0 | ctx->context_string_len); |
247 | 0 | if (ctx->md_ctx == NULL) |
248 | 0 | return 0; |
249 | 0 | } |
250 | | |
251 | 0 | return ossl_ml_dsa_mu_update(ctx->md_ctx, data, datalen); |
252 | 0 | } |
253 | | |
254 | | static int ml_dsa_sign_msg_final(void *vctx, unsigned char *sig, |
255 | | size_t *siglen, size_t sigsize) |
256 | 0 | { |
257 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
258 | 0 | uint8_t rand_tmp[ML_DSA_ENTROPY_LEN], *rnd = NULL; |
259 | 0 | uint8_t mu[ML_DSA_MU_BYTES]; |
260 | 0 | int ret = 0; |
261 | |
|
262 | 0 | if (ctx == NULL) |
263 | 0 | return 0; |
264 | | |
265 | 0 | if (!ossl_prov_is_running()) |
266 | 0 | return 0; |
267 | | |
268 | 0 | if (ctx->md_ctx == NULL) |
269 | 0 | return 0; |
270 | | |
271 | 0 | if (sig != NULL) { |
272 | 0 | if (ctx->test_entropy_len != 0) { |
273 | 0 | rnd = ctx->test_entropy; |
274 | 0 | } else { |
275 | 0 | rnd = rand_tmp; |
276 | |
|
277 | 0 | if (ctx->deterministic == 1) |
278 | 0 | memset(rnd, 0, sizeof(rand_tmp)); |
279 | 0 | else if (RAND_priv_bytes_ex(ctx->libctx, rnd, sizeof(rand_tmp), 0) <= 0) |
280 | 0 | return 0; |
281 | 0 | } |
282 | | |
283 | 0 | if (!ossl_ml_dsa_mu_finalize(ctx->md_ctx, mu, sizeof(mu))) |
284 | 0 | return 0; |
285 | 0 | } |
286 | | |
287 | 0 | ret = ossl_ml_dsa_sign(ctx->key, 1, mu, sizeof(mu), NULL, 0, rnd, |
288 | 0 | sizeof(rand_tmp), 0, sig, siglen, sigsize); |
289 | 0 | if (rnd != ctx->test_entropy) |
290 | 0 | OPENSSL_cleanse(rand_tmp, sizeof(rand_tmp)); |
291 | 0 | return ret; |
292 | 0 | } |
293 | | |
294 | | static int ml_dsa_sign(void *vctx, uint8_t *sig, size_t *siglen, size_t sigsize, |
295 | | const uint8_t *msg, size_t msg_len) |
296 | 0 | { |
297 | 0 | int ret = 0; |
298 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
299 | 0 | uint8_t rand_tmp[ML_DSA_ENTROPY_LEN], *rnd = NULL; |
300 | |
|
301 | 0 | if (!ossl_prov_is_running()) |
302 | 0 | return 0; |
303 | | |
304 | 0 | if (sig != NULL) { |
305 | 0 | if (ctx->test_entropy_len != 0) { |
306 | 0 | rnd = ctx->test_entropy; |
307 | 0 | } else { |
308 | 0 | rnd = rand_tmp; |
309 | |
|
310 | 0 | if (ctx->deterministic == 1) |
311 | 0 | memset(rnd, 0, sizeof(rand_tmp)); |
312 | 0 | else if (RAND_priv_bytes_ex(ctx->libctx, rnd, sizeof(rand_tmp), 0) <= 0) |
313 | 0 | return 0; |
314 | 0 | } |
315 | 0 | } |
316 | 0 | ret = ossl_ml_dsa_sign(ctx->key, ctx->mu, msg, msg_len, |
317 | 0 | ctx->context_string, ctx->context_string_len, |
318 | 0 | rnd, sizeof(rand_tmp), ctx->msg_encode, |
319 | 0 | sig, siglen, sigsize); |
320 | 0 | if (rnd != ctx->test_entropy) |
321 | 0 | OPENSSL_cleanse(rand_tmp, sizeof(rand_tmp)); |
322 | 0 | return ret; |
323 | 0 | } |
324 | | |
325 | | static int ml_dsa_digest_sign(void *vctx, uint8_t *sig, size_t *siglen, size_t sigsize, |
326 | | const uint8_t *tbs, size_t tbslen) |
327 | 0 | { |
328 | 0 | return ml_dsa_sign(vctx, sig, siglen, sigsize, tbs, tbslen); |
329 | 0 | } |
330 | | |
331 | | static int ml_dsa_verify_msg_init(void *vctx, void *vkey, const OSSL_PARAM params[]) |
332 | 0 | { |
333 | 0 | return ml_dsa_signverify_msg_init(vctx, vkey, params, EVP_PKEY_OP_VERIFYMSG, |
334 | 0 | "ML_DSA Verify Init"); |
335 | 0 | } |
336 | | |
337 | | static int ml_dsa_verify_msg_final(void *vctx) |
338 | 0 | { |
339 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
340 | 0 | uint8_t mu[ML_DSA_MU_BYTES]; |
341 | |
|
342 | 0 | if (!ossl_prov_is_running()) |
343 | 0 | return 0; |
344 | | |
345 | 0 | if (ctx->md_ctx == NULL) |
346 | 0 | return 0; |
347 | | |
348 | 0 | if (!ossl_ml_dsa_mu_finalize(ctx->md_ctx, mu, sizeof(mu))) |
349 | 0 | return 0; |
350 | | |
351 | 0 | return ossl_ml_dsa_verify(ctx->key, 1, mu, sizeof(mu), NULL, 0, 0, |
352 | 0 | ctx->sig, ctx->siglen); |
353 | 0 | } |
354 | | |
355 | | static int ml_dsa_verify(void *vctx, const uint8_t *sig, size_t siglen, |
356 | | const uint8_t *msg, size_t msg_len) |
357 | 0 | { |
358 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
359 | |
|
360 | 0 | if (!ossl_prov_is_running()) |
361 | 0 | return 0; |
362 | 0 | return ossl_ml_dsa_verify(ctx->key, ctx->mu, msg, msg_len, |
363 | 0 | ctx->context_string, ctx->context_string_len, |
364 | 0 | ctx->msg_encode, sig, siglen); |
365 | 0 | } |
366 | | static int ml_dsa_digest_verify(void *vctx, |
367 | | const uint8_t *sig, size_t siglen, |
368 | | const uint8_t *tbs, size_t tbslen) |
369 | 0 | { |
370 | 0 | return ml_dsa_verify(vctx, sig, siglen, tbs, tbslen); |
371 | 0 | } |
372 | | |
373 | | /* |
374 | | * Only need the param list for the signing case. The decoder and structure |
375 | | * are shared between the sign and verify cases. |
376 | | */ |
377 | | |
378 | | static int ml_dsa_set_ctx_params(void *vctx, const OSSL_PARAM params[]) |
379 | 0 | { |
380 | 0 | PROV_ML_DSA_CTX *pctx = (PROV_ML_DSA_CTX *)vctx; |
381 | 0 | struct ml_dsa_verifymsg_set_ctx_params_st p; |
382 | |
|
383 | 0 | if (pctx == NULL || !ml_dsa_verifymsg_set_ctx_params_decoder(params, &p)) |
384 | 0 | return 0; |
385 | | |
386 | 0 | if (p.ctx != NULL) { |
387 | 0 | void *vp = pctx->context_string; |
388 | |
|
389 | 0 | if (!OSSL_PARAM_get_octet_string(p.ctx, &vp, sizeof(pctx->context_string), |
390 | 0 | &(pctx->context_string_len))) { |
391 | 0 | pctx->context_string_len = 0; |
392 | 0 | return 0; |
393 | 0 | } |
394 | 0 | } |
395 | | |
396 | 0 | if (p.ent != NULL) { |
397 | 0 | void *vp = pctx->test_entropy; |
398 | |
|
399 | 0 | pctx->test_entropy_len = 0; |
400 | 0 | if (!OSSL_PARAM_get_octet_string(p.ent, &vp, sizeof(pctx->test_entropy), |
401 | 0 | &(pctx->test_entropy_len))) |
402 | 0 | return 0; |
403 | 0 | if (pctx->test_entropy_len != sizeof(pctx->test_entropy)) { |
404 | 0 | pctx->test_entropy_len = 0; |
405 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SEED_LENGTH); |
406 | 0 | return 0; |
407 | 0 | } |
408 | 0 | } |
409 | | |
410 | 0 | if (p.det != NULL && !OSSL_PARAM_get_int(p.det, &pctx->deterministic)) |
411 | 0 | return 0; |
412 | | |
413 | 0 | if (p.msgenc != NULL && !OSSL_PARAM_get_int(p.msgenc, &pctx->msg_encode)) |
414 | 0 | return 0; |
415 | | |
416 | 0 | if (p.mu != NULL && !OSSL_PARAM_get_int(p.mu, &pctx->mu)) |
417 | 0 | return 0; |
418 | | |
419 | 0 | if (p.sig != NULL && pctx->operation == EVP_PKEY_OP_VERIFYMSG) { |
420 | 0 | OPENSSL_free(pctx->sig); |
421 | 0 | pctx->sig = NULL; |
422 | 0 | pctx->siglen = 0; |
423 | 0 | if (!OSSL_PARAM_get_octet_string(p.sig, (void **)&pctx->sig, |
424 | 0 | 0, &pctx->siglen)) |
425 | 0 | return 0; |
426 | 0 | } |
427 | | |
428 | 0 | return 1; |
429 | 0 | } |
430 | | |
431 | | static const OSSL_PARAM *ml_dsa_settable_ctx_params(void *vctx, |
432 | | ossl_unused void *provctx) |
433 | 0 | { |
434 | 0 | PROV_ML_DSA_CTX *pctx = (PROV_ML_DSA_CTX *)vctx; |
435 | |
|
436 | 0 | if (pctx != NULL && pctx->operation == EVP_PKEY_OP_VERIFYMSG) |
437 | 0 | return ml_dsa_verifymsg_set_ctx_params_list; |
438 | 0 | else |
439 | 0 | return ml_dsa_set_ctx_params_list; |
440 | 0 | } |
441 | | |
442 | | static const OSSL_PARAM *ml_dsa_gettable_ctx_params(ossl_unused void *vctx, |
443 | | ossl_unused void *provctx) |
444 | 0 | { |
445 | 0 | return ml_dsa_get_ctx_params_list; |
446 | 0 | } |
447 | | |
448 | | static int ml_dsa_get_ctx_params(void *vctx, OSSL_PARAM *params) |
449 | 0 | { |
450 | 0 | PROV_ML_DSA_CTX *ctx = (PROV_ML_DSA_CTX *)vctx; |
451 | 0 | struct ml_dsa_get_ctx_params_st p; |
452 | |
|
453 | 0 | if (ctx == NULL || !ml_dsa_get_ctx_params_decoder(params, &p)) |
454 | 0 | return 0; |
455 | | |
456 | 0 | if (p.id != NULL |
457 | 0 | && !OSSL_PARAM_set_octet_string(p.id, |
458 | 0 | ctx->aid_len == 0 ? NULL : ctx->aid_buf, |
459 | 0 | ctx->aid_len)) |
460 | 0 | return 0; |
461 | | |
462 | 0 | return 1; |
463 | 0 | } |
464 | | |
465 | | #define MAKE_SIGNATURE_FUNCTIONS(alg) \ |
466 | | static OSSL_FUNC_signature_newctx_fn ml_dsa_##alg##_newctx; \ |
467 | | static void *ml_dsa_##alg##_newctx(void *provctx, const char *propq) \ |
468 | 0 | { \ |
469 | 0 | return ml_dsa_newctx(provctx, EVP_PKEY_ML_DSA_##alg, propq); \ |
470 | 0 | } \ Unexecuted instantiation: ml_dsa_sig.c:ml_dsa_44_newctx Unexecuted instantiation: ml_dsa_sig.c:ml_dsa_65_newctx Unexecuted instantiation: ml_dsa_sig.c:ml_dsa_87_newctx |
471 | | const OSSL_DISPATCH ossl_ml_dsa_##alg##_signature_functions[] = { \ |
472 | | { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))ml_dsa_##alg##_newctx }, \ |
473 | | { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_INIT, \ |
474 | | (void (*)(void))ml_dsa_sign_msg_init }, \ |
475 | | { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_UPDATE, \ |
476 | | (void (*)(void))ml_dsa_signverify_msg_update }, \ |
477 | | { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_FINAL, \ |
478 | | (void (*)(void))ml_dsa_sign_msg_final }, \ |
479 | | { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))ml_dsa_sign }, \ |
480 | | { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_INIT, \ |
481 | | (void (*)(void))ml_dsa_verify_msg_init }, \ |
482 | | { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_UPDATE, \ |
483 | | (void (*)(void))ml_dsa_signverify_msg_update }, \ |
484 | | { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_FINAL, \ |
485 | | (void (*)(void))ml_dsa_verify_msg_final }, \ |
486 | | { OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))ml_dsa_verify }, \ |
487 | | { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT, \ |
488 | | (void (*)(void))ml_dsa_digest_signverify_init }, \ |
489 | | { OSSL_FUNC_SIGNATURE_DIGEST_SIGN, \ |
490 | | (void (*)(void))ml_dsa_digest_sign }, \ |
491 | | { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT, \ |
492 | | (void (*)(void))ml_dsa_digest_signverify_init }, \ |
493 | | { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY, \ |
494 | | (void (*)(void))ml_dsa_digest_verify }, \ |
495 | | { OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))ml_dsa_freectx }, \ |
496 | | { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, \ |
497 | | (void (*)(void))ml_dsa_set_ctx_params }, \ |
498 | | { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS, \ |
499 | | (void (*)(void))ml_dsa_settable_ctx_params }, \ |
500 | | { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, \ |
501 | | (void (*)(void))ml_dsa_get_ctx_params }, \ |
502 | | { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS, \ |
503 | | (void (*)(void))ml_dsa_gettable_ctx_params }, \ |
504 | | { OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))ml_dsa_dupctx }, \ |
505 | | OSSL_DISPATCH_END \ |
506 | | } |
507 | | |
508 | | MAKE_SIGNATURE_FUNCTIONS(44); |
509 | | MAKE_SIGNATURE_FUNCTIONS(65); |
510 | | MAKE_SIGNATURE_FUNCTIONS(87); |