Debian Codegraph @

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