Debian Codegraph @

others/mbedtls/tf-psa-crypto/drivers/pqcp/mldsa-native/test/configs/no_asm_config.h

raw symbols SCIP
1 /*
2 * Copyright (c) The mldsa-native project authors
3 * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4 */
5
6 /* References
7 * ==========
8 *
9 * - [FIPS140_3_IG]
10 * Implementation Guidance for FIPS 140-3 and the Cryptographic Module
11 * Validation Program
12 * National Institute of Standards and Technology
13 * https://csrc.nist.gov/projects/cryptographic-module-validation-program/fips-140-3-ig-announcements
14 *
15 * - [FIPS204]
16 * FIPS 204 Module-Lattice-Based Digital Signature Standard
17 * National Institute of Standards and Technology
18 * https://csrc.nist.gov/pubs/fips/204/final
19 */
20
21 /*
22 * WARNING: This file is auto-generated from scripts/autogen
23 * in the mldsa-native repository.
24 * Do not modify it directly.
25 */
26
27 /*
28 * Test configuration: Test configuration with no assembly code
29 *
30 * This configuration differs from the default mldsa/mldsa_native_config.h in
31 * the following places:
32 * - MLD_CONFIG_NO_ASM
33 * - MLD_CONFIG_CUSTOM_ZEROIZE
34 */
35
36
37 #ifndef MLD_CONFIG_H
38 #define MLD_CONFIG_H
39
40 /******************************************************************************
41 * Name: MLD_CONFIG_PARAMETER_SET
42 *
43 * Description: Specifies the parameter set for ML-DSA
44 * - MLD_CONFIG_PARAMETER_SET=44 corresponds to ML-DSA-44
45 * - MLD_CONFIG_PARAMETER_SET=65 corresponds to ML-DSA-65
46 * - MLD_CONFIG_PARAMETER_SET=87 corresponds to ML-DSA-87
47 *
48 * If you want to support multiple parameter sets, build the
49 * library multiple times and set MLD_CONFIG_MULTILEVEL_BUILD.
50 * See MLD_CONFIG_MULTILEVEL_BUILD for how to do this while
51 * minimizing code duplication.
52 *
53 * This can also be set using CFLAGS.
54 *
55 *****************************************************************************/
56 #ifndef MLD_CONFIG_PARAMETER_SET
57 #define MLD_CONFIG_PARAMETER_SET \
58 44 /* Change this for different security strengths */
59 #endif
60
61 /******************************************************************************
62 * Name: MLD_CONFIG_FILE
63 *
64 * Description: If defined, this is a header that will be included instead
65 * of the default configuration file mldsa/mldsa_native_config.h.
66 *
67 * When you need to build mldsa-native in multiple configurations,
68 * using varying MLD_CONFIG_FILE can be more convenient
69 * then configuring everything through CFLAGS.
70 *
71 * To use, MLD_CONFIG_FILE _must_ be defined prior
72 * to the inclusion of any mldsa-native headers. For example,
73 * it can be set by passing `-DMLD_CONFIG_FILE="..."`
74 * on the command line.
75 *
76 *****************************************************************************/
77 /* #define MLD_CONFIG_FILE "mldsa_native_config.h" */
78
79 /******************************************************************************
80 * Name: MLD_CONFIG_NAMESPACE_PREFIX
81 *
82 * Description: The prefix to use to namespace global symbols from mldsa/.
83 *
84 * In a multi-level build, level-dependent symbols will
85 * additionally be prefixed with the parameter set (44/65/87).
86 *
87 * This can also be set using CFLAGS.
88 *
89 *****************************************************************************/
90 #if !defined(MLD_CONFIG_NAMESPACE_PREFIX)
91 #define MLD_CONFIG_NAMESPACE_PREFIX MLD_DEFAULT_NAMESPACE_PREFIX
92 #endif
93
94 /******************************************************************************
95 * Name: MLD_CONFIG_MULTILEVEL_BUILD
96 *
97 * Description: Set this if the build is part of a multi-level build supporting
98 * multiple parameter sets.
99 *
100 * If you need only a single parameter set, keep this unset.
101 *
102 * To build mldsa-native with support for all parameter sets,
103 * build it three times -- once per parameter set -- and set the
104 * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
105 * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
106 * MLD_CONFIG_MULTILEVEL_BUILD should be set for all of them.
107 *
108 * See examples/multilevel_build for an example.
109 *
110 * This can also be set using CFLAGS.
111 *
112 *****************************************************************************/
113 /* #define MLD_CONFIG_MULTILEVEL_BUILD */
114
115 /******************************************************************************
116 * Name: MLD_CONFIG_EXTERNAL_API_QUALIFIER
117 *
118 * Description: If set, this option provides an additional function
119 * qualifier to be added to declarations of mldsa-native's
120 * public API.
121 *
122 * The primary use case for this option are single-CU builds
123 * where the public API exposed by mldsa-native is wrapped by
124 * another API in the consuming application. In this case,
125 * even mldsa-native's public API can be marked `static`.
126 *
127 *****************************************************************************/
128 /* #define MLD_CONFIG_EXTERNAL_API_QUALIFIER */
129
130 /******************************************************************************
131 * Name: MLD_CONFIG_NO_RANDOMIZED_API
132 *
133 * Description: If this option is set, mldsa-native will be built without the
134 * randomized API functions (crypto_sign_keypair,
135 * crypto_sign, crypto_sign_signature, and
136 * crypto_sign_signature_extmu).
137 * This allows users to build mldsa-native without providing a
138 * randombytes() implementation if they only need the
139 * internal deterministic API
140 * (crypto_sign_keypair_internal, crypto_sign_signature_internal).
141 *
142 * NOTE: This option is incompatible with MLD_CONFIG_KEYGEN_PCT
143 * as the current PCT implementation requires
144 * crypto_sign_signature().
145 *
146 *****************************************************************************/
147 /* #define MLD_CONFIG_NO_RANDOMIZED_API */
148
149 /******************************************************************************
150 * Name: MLD_CONFIG_NO_SUPERCOP
151 *
152 * Description: By default, mldsa_native.h exposes the mldsa-native API in the
153 * SUPERCOP naming convention (crypto_sign_xxx). If you don't need
154 * this, set MLD_CONFIG_NO_SUPERCOP.
155 *
156 * NOTE: You must set this for a multi-level build as the SUPERCOP
157 * naming does not disambiguate between the parameter sets.
158 *
159 *****************************************************************************/
160 /* #define MLD_CONFIG_NO_SUPERCOP */
161
162 /******************************************************************************
163 * Name: MLD_CONFIG_CONSTANTS_ONLY
164 *
165 * Description: If you only need the size constants (MLDSA_PUBLICKEYBYTES, etc.)
166 * but no function declarations, set MLD_CONFIG_CONSTANTS_ONLY.
167 *
168 * This only affects the public header mldsa_native.h, not
169 * the implementation.
170 *
171 *****************************************************************************/
172 /* #define MLD_CONFIG_CONSTANTS_ONLY */
173
174 /******************************************************************************
175 *
176 * Build-only configuration options
177 *
178 * The remaining configurations are build-options only.
179 * They do not affect the API described in mldsa_native.h.
180 *
181 *****************************************************************************/
182
183 #if defined(MLD_BUILD_INTERNAL)
184 /******************************************************************************
185 * Name: MLD_CONFIG_MULTILEVEL_WITH_SHARED
186 *
187 * Description: This is for multi-level builds of mldsa-native only. If you
188 * need only a single parameter set, keep this unset.
189 *
190 * If this is set, all MLD_CONFIG_PARAMETER_SET-independent
191 * code will be included in the build, including code needed only
192 * for other parameter sets.
193 *
194 * Example: TODO: add example
195 *
196 * To build mldsa-native with support for all parameter sets,
197 * build it three times -- once per parameter set -- and set the
198 * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
199 * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
200 *
201 * See examples/multilevel_build_mldsa for an example.
202 *
203 * This can also be set using CFLAGS.
204 *
205 *****************************************************************************/
206 /* #define MLD_CONFIG_MULTILEVEL_WITH_SHARED */
207
208 /******************************************************************************
209 * Name: MLD_CONFIG_MULTILEVEL_NO_SHARED
210 *
211 * Description: This is for multi-level builds of mldsa-native only. If you
212 * need only a single parameter set, keep this unset.
213 *
214 * If this is set, no MLD_CONFIG_PARAMETER_SET-independent code
215 * will be included in the build.
216 *
217 * To build mldsa-native with support for all parameter sets,
218 * build it three times -- once per parameter set -- and set the
219 * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
220 * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
221 *
222 * See examples/multilevel_build_mldsa for an example.
223 *
224 * This can also be set using CFLAGS.
225 *
226 *****************************************************************************/
227 /* #define MLD_CONFIG_MULTILEVEL_NO_SHARED */
228
229 /******************************************************************************
230 * Name: MLD_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS
231 *
232 * Description: This is only relevant for single compilation unit (SCU)
233 * builds of mldsa-native. In this case, it determines whether
234 * directives defined in parameter-set-independent headers should
235 * be #undef'ined or not at the of the SCU file. This is needed
236 * in multilevel builds.
237 *
238 * See examples/multilevel_build_native for an example.
239 *
240 * This can also be set using CFLAGS.
241 *
242 *****************************************************************************/
243 /* #define MLD_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS */
244
245 /******************************************************************************
246 * Name: MLD_CONFIG_USE_NATIVE_BACKEND_ARITH
247 *
248 * Description: Determines whether an native arithmetic backend should be used.
249 *
250 * The arithmetic backend covers performance critical functions
251 * such as the number-theoretic transform (NTT).
252 *
253 * If this option is unset, the C backend will be used.
254 *
255 * If this option is set, the arithmetic backend to be use is
256 * determined by MLD_CONFIG_ARITH_BACKEND_FILE: If the latter is
257 * unset, the default backend for your the target architecture
258 * will be used. If set, it must be the name of a backend metadata
259 * file.
260 *
261 * This can also be set using CFLAGS.
262 *
263 *****************************************************************************/
264 #if !defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH)
265 /* #define MLD_CONFIG_USE_NATIVE_BACKEND_ARITH */
266 #endif
267
268 /******************************************************************************
269 * Name: MLD_CONFIG_ARITH_BACKEND_FILE
270 *
271 * Description: The arithmetic backend to use.
272 *
273 * If MLD_CONFIG_USE_NATIVE_BACKEND_ARITH is unset, this option
274 * is ignored.
275 *
276 * If MLD_CONFIG_USE_NATIVE_BACKEND_ARITH is set, this option must
277 * either be undefined or the filename of an arithmetic backend.
278 * If unset, the default backend will be used.
279 *
280 * This can be set using CFLAGS.
281 *
282 *****************************************************************************/
283 #if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH) && \
284 !defined(MLD_CONFIG_ARITH_BACKEND_FILE)
285 #define MLD_CONFIG_ARITH_BACKEND_FILE "native/meta.h"
286 #endif
287
288 /******************************************************************************
289 * Name: MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202
290 *
291 * Description: Determines whether an native FIPS202 backend should be used.
292 *
293 * The FIPS202 backend covers 1x/2x/4x-fold Keccak-f1600, which is
294 * the performance bottleneck of SHA3 and SHAKE.
295 *
296 * If this option is unset, the C backend will be used.
297 *
298 * If this option is set, the FIPS202 backend to be use is
299 * determined by MLD_CONFIG_FIPS202_BACKEND_FILE: If the latter is
300 * unset, the default backend for your the target architecture
301 * will be used. If set, it must be the name of a backend metadata
302 * file.
303 *
304 * This can also be set using CFLAGS.
305 *
306 *****************************************************************************/
307 #if !defined(MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202)
308 /* #define MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 */
309 #endif
310
311 /******************************************************************************
312 * Name: MLD_CONFIG_FIPS202_BACKEND_FILE
313 *
314 * Description: The FIPS-202 backend to use.
315 *
316 * If MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 is set, this option
317 * must either be undefined or the filename of a FIPS202 backend.
318 * If unset, the default backend will be used.
319 *
320 * This can be set using CFLAGS.
321 *
322 *****************************************************************************/
323 #if defined(MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202) && \
324 !defined(MLD_CONFIG_FIPS202_BACKEND_FILE)
325 #define MLD_CONFIG_FIPS202_BACKEND_FILE "fips202/native/auto.h"
326 #endif
327
328 /******************************************************************************
329 * Name: MLD_CONFIG_FIPS202_CUSTOM_HEADER
330 *
331 * Description: Custom header to use for FIPS-202
332 *
333 * This should only be set if you intend to use a custom
334 * FIPS-202 implementation, different from the one shipped
335 * with mldsa-native.
336 *
337 * If set, it must be the name of a file serving as the
338 * replacement for mldsa/src/fips202/fips202.h, and exposing
339 * the same API (see FIPS202.md).
340 *
341 *****************************************************************************/
342 /* #define MLD_CONFIG_FIPS202_CUSTOM_HEADER "SOME_FILE.h" */
343
344 /******************************************************************************
345 * Name: MLD_CONFIG_FIPS202X4_CUSTOM_HEADER
346 *
347 * Description: Custom header to use for FIPS-202-X4
348 *
349 * This should only be set if you intend to use a custom
350 * FIPS-202 implementation, different from the one shipped
351 * with mldsa-native.
352 *
353 * If set, it must be the name of a file serving as the
354 * replacement for mldsa/src/fips202/fips202x4.h, and exposing
355 * the same API (see FIPS202.md).
356 *
357 *****************************************************************************/
358 /* #define MLD_CONFIG_FIPS202X4_CUSTOM_HEADER "SOME_FILE.h" */
359
360 /******************************************************************************
361 * Name: MLD_CONFIG_CUSTOM_ZEROIZE
362 *
363 * Description: In compliance with @[FIPS204, Section 3.6.3], mldsa-native,
364 * zeroizes intermediate stack buffers before returning from
365 * function calls.
366 *
367 * Set this option and define `mld_zeroize` if you want to
368 * use a custom method to zeroize intermediate stack buffers.
369 * The default implementation uses SecureZeroMemory on Windows
370 * and a memset + compiler barrier otherwise. If neither of those
371 * is available on the target platform, compilation will fail,
372 * and you will need to use MLD_CONFIG_CUSTOM_ZEROIZE to provide
373 * a custom implementation of `mld_zeroize()`.
374 *
375 * WARNING:
376 * The explicit stack zeroization conducted by mldsa-native
377 * reduces the likelihood of data leaking on the stack, but
378 * does not eliminate it! The C standard makes no guarantee about
379 * where a compiler allocates structures and whether/where it makes
380 * copies of them. Also, in addition to entire structures, there
381 * may also be potentially exploitable leakage of individual values
382 * on the stack.
383 *
384 * If you need bullet-proof zeroization of the stack, you need to
385 * consider additional measures instead of what this feature
386 * provides. In this case, you can set mld_zeroize to a
387 * no-op.
388 *
389 *****************************************************************************/
390 #define MLD_CONFIG_CUSTOM_ZEROIZE
391 #if !defined(__ASSEMBLER__)
392 #include <stdint.h>
393 #include <string.h>
394 #include "../mldsa/src/sys.h"
395 static MLD_INLINE void mld_zeroize(void *ptr, size_t len)
396 {
397 explicit_bzero(ptr, len);
398 }
399 #endif /* !__ASSEMBLER__ */
400
401
402 /******************************************************************************
403 * Name: MLD_CONFIG_CUSTOM_RANDOMBYTES
404 *
405 * Description: mldsa-native does not provide a secure randombytes
406 * implementation. Such an implementation has to provided by the
407 * consumer.
408 *
409 * If this option is not set, mldsa-native expects a function
410 * int randombytes(uint8_t *out, size_t outlen).
411 *
412 * Set this option and define `mld_randombytes` if you want to
413 * use a custom method to sample randombytes with a different name
414 * or signature.
415 *
416 *****************************************************************************/
417 /* #define MLD_CONFIG_CUSTOM_RANDOMBYTES
418 #if !defined(__ASSEMBLER__)
419 #include <stdint.h>
420 #include "src/src.h"
421 static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
422 {
423 ... your implementation ...
424 return 0;
425 }
426 #endif
427 */
428
429 /******************************************************************************
430 * Name: MLD_CONFIG_CUSTOM_CAPABILITY_FUNC
431 *
432 * Description: mldsa-native backends may rely on specific hardware features.
433 * Those backends will only be included in an mldsa-native build
434 * if support for the respective features is enabled at
435 * compile-time. However, when building for a heteroneous set
436 * of CPUs to run the resulting binary/library on, feature
437 * detection at _runtime_ is needed to decided whether a backend
438 * can be used or not.
439 *
440 * Set this option and define `mld_sys_check_capability` if you
441 * want to use a custom method to dispatch between implementations.
442 *
443 * Return value 1 indicates that a capability is supported.
444 * Return value 0 indicates that a capability is not supported.
445 *
446 * If this option is not set, mldsa-native uses compile-time
447 * feature detection only to decide which backend to use.
448 *
449 * If you compile mldsa-native on a system with different
450 * capabilities than the system that the resulting binary/library
451 * will be run on, you must use this option.
452 *
453 *****************************************************************************/
454 /* #define MLD_CONFIG_CUSTOM_CAPABILITY_FUNC
455 static MLD_INLINE int mld_sys_check_capability(mld_sys_cap cap)
456 {
457 ... your implementation ...
458 }
459 */
460
461 /******************************************************************************
462 * Name: MLD_CONFIG_CUSTOM_ALLOC_FREE [EXPERIMENTAL]
463 *
464 * Description: Set this option and define `MLD_CUSTOM_ALLOC` and
465 * `MLD_CUSTOM_FREE` if you want to use custom allocation for
466 * large local structures or buffers.
467 *
468 * By default, all buffers/structures are allocated on the stack.
469 * If this option is set, most of them will be allocated via
470 * MLD_CUSTOM_ALLOC.
471 *
472 * Parameters to MLD_CUSTOM_ALLOC:
473 * - T* v: Target pointer to declare.
474 * - T: Type of structure to be allocated
475 * - N: Number of elements to be allocated.
476 *
477 * Parameters to MLD_CUSTOM_FREE:
478 * - T* v: Target pointer to free. May be NULL.
479 * - T: Type of structure to be freed.
480 * - N: Number of elements to be freed.
481 *
482 * WARNING: This option is experimental!
483 * Its scope, configuration and function/macro signatures may
484 * change at any time. We expect a stable API for v2.
485 *
486 * NOTE: Even if this option is set, some allocations further down
487 * the call stack will still be made from the stack. Those will
488 * likely be added to the scope of this option in the future.
489 *
490 * NOTE: MLD_CUSTOM_ALLOC need not guarantee a successful
491 * allocation nor include error handling. Upon failure, the
492 * target pointer should simply be set to NULL. The calling
493 * code will handle this case and invoke MLD_CUSTOM_FREE.
494 *
495 *****************************************************************************/
496 /* #define MLD_CONFIG_CUSTOM_ALLOC_FREE
497 #if !defined(__ASSEMBLER__)
498 #include <stdlib.h>
499 #define MLD_CUSTOM_ALLOC(v, T, N) \
500 T* (v) = (T *)aligned_alloc(MLD_DEFAULT_ALIGN, \
501 MLD_ALIGN_UP(sizeof(T) * (N)))
502 #define MLD_CUSTOM_FREE(v, T, N) free(v)
503 #endif
504 */
505
506 /******************************************************************************
507 * Name: MLD_CONFIG_CUSTOM_MEMCPY
508 *
509 * Description: Set this option and define `mld_memcpy` if you want to
510 * use a custom method to copy memory instead of the standard
511 * library memcpy function.
512 *
513 * The custom implementation must have the same signature and
514 * behavior as the standard memcpy function:
515 * void *mld_memcpy(void *dest, const void *src, size_t n)
516 *
517 *****************************************************************************/
518 /* #define MLD_CONFIG_CUSTOM_MEMCPY
519 #if !defined(__ASSEMBLER__)
520 #include <stdint.h>
521 #include "src/src.h"
522 static MLD_INLINE void *mld_memcpy(void *dest, const void *src, size_t n)
523 {
524 ... your implementation ...
525 }
526 #endif
527 */
528
529 /******************************************************************************
530 * Name: MLD_CONFIG_CUSTOM_MEMSET
531 *
532 * Description: Set this option and define `mld_memset` if you want to
533 * use a custom method to set memory instead of the standard
534 * library memset function.
535 *
536 * The custom implementation must have the same signature and
537 * behavior as the standard memset function:
538 * void *mld_memset(void *s, int c, size_t n)
539 *
540 *****************************************************************************/
541 /* #define MLD_CONFIG_CUSTOM_MEMSET
542 #if !defined(__ASSEMBLER__)
543 #include <stdint.h>
544 #include "src/src.h"
545 static MLD_INLINE void *mld_memset(void *s, int c, size_t n)
546 {
547 ... your implementation ...
548 }
549 #endif
550 */
551
552 /******************************************************************************
553 * Name: MLD_CONFIG_INTERNAL_API_QUALIFIER
554 *
555 * Description: If set, this option provides an additional function
556 * qualifier to be added to declarations of internal API.
557 *
558 * The primary use case for this option are single-CU builds,
559 * in which case this option can be set to `static`.
560 *
561 *****************************************************************************/
562 /* #define MLD_CONFIG_INTERNAL_API_QUALIFIER */
563
564 /******************************************************************************
565 * Name: MLD_CONFIG_CT_TESTING_ENABLED
566 *
567 * Description: If set, mldsa-native annotates data as secret / public using
568 * valgrind's annotations VALGRIND_MAKE_MEM_UNDEFINED and
569 * VALGRIND_MAKE_MEM_DEFINED, enabling various checks for secret-
570 * dependent control flow of variable time execution (depending
571 * on the exact version of valgrind installed).
572 *
573 *****************************************************************************/
574 /* #define MLD_CONFIG_CT_TESTING_ENABLED */
575
576 /******************************************************************************
577 * Name: MLD_CONFIG_NO_ASM
578 *
579 * Description: If this option is set, mldsa-native will be built without
580 * use of native code or inline assembly.
581 *
582 * By default, inline assembly is used to implement value barriers.
583 * Without inline assembly, mldsa-native will use a global volatile
584 * 'opt blocker' instead; see ct.h.
585 *
586 * Inline assembly is also used to implement a secure zeroization
587 * function on non-Windows platforms. If this option is set and
588 * the target platform is not Windows, you MUST set
589 * MLD_CONFIG_CUSTOM_ZEROIZE and provide a custom zeroization
590 * function.
591 *
592 * If this option is set, MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 and
593 * and MLD_CONFIG_USE_NATIVE_BACKEND_ARITH will be ignored, and no
594 * native backends will be used.
595 *
596 *****************************************************************************/
597 #define MLD_CONFIG_NO_ASM
598
599 /******************************************************************************
600 * Name: MLD_CONFIG_NO_ASM_VALUE_BARRIER
601 *
602 * Description: If this option is set, mldsa-native will be built without
603 * use of native code or inline assembly for value barriers.
604 *
605 * By default, inline assembly (if available) is used to implement
606 * value barriers.
607 * Without inline assembly, mldsa-native will use a global volatile
608 * 'opt blocker' instead; see ct.h.
609 *
610 *****************************************************************************/
611 /* #define MLD_CONFIG_NO_ASM_VALUE_BARRIER */
612
613 /******************************************************************************
614 * Name: MLD_CONFIG_KEYGEN_PCT
615 *
616 * Description: Compliance with @[FIPS140_3_IG, p.87] requires a
617 * Pairwise Consistency Test (PCT) to be carried out on a freshly
618 * generated keypair before it can be exported.
619 *
620 * Set this option if such a check should be implemented.
621 * In this case, crypto_sign_keypair_internal and
622 * crypto_sign_keypair will return a non-zero error code if the
623 * PCT failed.
624 *
625 * NOTE: This feature will drastically lower the performance of
626 * key generation.
627 *
628 *****************************************************************************/
629 /* #define MLD_CONFIG_KEYGEN_PCT */
630
631 /******************************************************************************
632 * Name: MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
633 *
634 * Description: If this option is set, the user must provide a runtime
635 * function `static inline int mld_break_pct() { ... }` to
636 * indicate whether the PCT should be made fail.
637 *
638 * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set.
639 *
640 *****************************************************************************/
641 /* #define MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
642 #if !defined(__ASSEMBLER__)
643 #include "src/src.h"
644 static MLD_INLINE int mld_break_pct(void)
645 {
646 ... return 0/1 depending on whether PCT should be broken ...
647 }
648 #endif
649 */
650
651 /******************************************************************************
652 * Name: MLD_CONFIG_SERIAL_FIPS202_ONLY
653 *
654 * Description: Set this to use a FIPS202 implementation with global state
655 * that supports only one active Keccak computation at a time
656 * (e.g. some hardware accelerators).
657 *
658 * If this option is set, ML-DSA will use FIPS202 operations
659 * serially, ensuring that only one SHAKE context is active
660 * at any given time.
661 *
662 * This allows offloading Keccak computations to a hardware
663 * accelerator that holds only a single Keccak state locally,
664 * rather than requiring support for multiple concurrent
665 * Keccak states.
666 *
667 * NOTE: Depending on the target CPU, this may reduce
668 * performance when using software FIPS202 implementations.
669 * Only enable this when you have to.
670 *
671 *****************************************************************************/
672 /* #define MLD_CONFIG_SERIAL_FIPS202_ONLY */
673
674 /******************************************************************************
675 * Name: MLD_CONFIG_CONTEXT_PARAMETER
676 *
677 * Description: Set this to add a context parameter that is provided to public
678 * API functions and is then available in custom callbacks.
679 *
680 * The type of the context parameter is configured via
681 * MLD_CONFIG_CONTEXT_PARAMETER_TYPE.
682 *
683 *****************************************************************************/
684 /* #define MLD_CONFIG_CONTEXT_PARAMETER */
685
686 /******************************************************************************
687 * Name: MLD_CONFIG_CONTEXT_PARAMETER_TYPE
688 *
689 * Description: Set this to define the type for the context parameter used by
690 * MLD_CONFIG_CONTEXT_PARAMETER.
691 *
692 * This is only relevant if MLD_CONFIG_CONTEXT_PARAMETER is set.
693 *
694 *****************************************************************************/
695 /* #define MLD_CONFIG_CONTEXT_PARAMETER_TYPE void* */
696
697 /******************************************************************************
698 * Name: MLD_CONFIG_REDUCE_RAM [EXPERIMENTAL]
699 *
700 * Description: Set this to reduce RAM usage.
701 * This trades memory for performance.
702 *
703 * For expected memory usage, see the MLD_TOTAL_ALLOC_* constants
704 * defined in mldsa_native.h.
705 *
706 * This option is useful for embedded systems with tight RAM
707 * constraints but relaxed performance requirements.
708 *
709 * WARNING: This option is experimental!
710 * CBMC proofs do not currently cover this configuration option.
711 * Its scope and configuration may change at any time.
712 *
713 *****************************************************************************/
714 /* #define MLD_CONFIG_REDUCE_RAM */
715
716 /************************* Config internals ********************************/
717
718 #endif /* MLD_BUILD_INTERNAL */
719
720 /* Default namespace
721 *
722 * Don't change this. If you need a different namespace, re-define
723 * MLD_CONFIG_NAMESPACE_PREFIX above instead, and remove the following.
724 *
725 * The default MLDSA namespace is
726 *
727 * PQCP_MLDSA_NATIVE_MLDSA<LEVEL>_
728 *
729 * e.g., PQCP_MLDSA_NATIVE_MLDSA44_
730 */
731
732 #if MLD_CONFIG_PARAMETER_SET == 44
733 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA44
734 #elif MLD_CONFIG_PARAMETER_SET == 65
735 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA65
736 #elif MLD_CONFIG_PARAMETER_SET == 87
737 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA87
738 #endif
739
740 #endif /* !MLD_CONFIG_H */