Debian Codegraph @

others/mbedtls/tf-psa-crypto/drivers/pqcp/mldsa-native/test/configs/break_pct_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 for PCT breakage testing
29 *
30 * This configuration differs from the default mldsa/mldsa_native_config.h in
31 * the following places:
32 * - MLD_CONFIG_KEYGEN_PCT
33 * - MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
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 "src/src.h"
394 static MLD_INLINE void mld_zeroize(void *ptr, size_t len)
395 {
396 ... your implementation ...
397 }
398 #endif
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 <stdlib.h>
643 #include <string.h>
644 #include "../mldsa/src/sys.h"
645 static MLD_INLINE int mld_break_pct(void)
646 {
647 /* Break PCT if and only if MLD_BREAK_PCT is set to 1 */
648 const char *val = getenv("MLD_BREAK_PCT");
649 return val != NULL && strcmp(val, "1") == 0;
650 }
651 #endif /* !__ASSEMBLER__ */
652
653
654 /******************************************************************************
655 * Name: MLD_CONFIG_SERIAL_FIPS202_ONLY
656 *
657 * Description: Set this to use a FIPS202 implementation with global state
658 * that supports only one active Keccak computation at a time
659 * (e.g. some hardware accelerators).
660 *
661 * If this option is set, ML-DSA will use FIPS202 operations
662 * serially, ensuring that only one SHAKE context is active
663 * at any given time.
664 *
665 * This allows offloading Keccak computations to a hardware
666 * accelerator that holds only a single Keccak state locally,
667 * rather than requiring support for multiple concurrent
668 * Keccak states.
669 *
670 * NOTE: Depending on the target CPU, this may reduce
671 * performance when using software FIPS202 implementations.
672 * Only enable this when you have to.
673 *
674 *****************************************************************************/
675 /* #define MLD_CONFIG_SERIAL_FIPS202_ONLY */
676
677 /******************************************************************************
678 * Name: MLD_CONFIG_CONTEXT_PARAMETER
679 *
680 * Description: Set this to add a context parameter that is provided to public
681 * API functions and is then available in custom callbacks.
682 *
683 * The type of the context parameter is configured via
684 * MLD_CONFIG_CONTEXT_PARAMETER_TYPE.
685 *
686 *****************************************************************************/
687 /* #define MLD_CONFIG_CONTEXT_PARAMETER */
688
689 /******************************************************************************
690 * Name: MLD_CONFIG_CONTEXT_PARAMETER_TYPE
691 *
692 * Description: Set this to define the type for the context parameter used by
693 * MLD_CONFIG_CONTEXT_PARAMETER.
694 *
695 * This is only relevant if MLD_CONFIG_CONTEXT_PARAMETER is set.
696 *
697 *****************************************************************************/
698 /* #define MLD_CONFIG_CONTEXT_PARAMETER_TYPE void* */
699
700 /******************************************************************************
701 * Name: MLD_CONFIG_REDUCE_RAM [EXPERIMENTAL]
702 *
703 * Description: Set this to reduce RAM usage.
704 * This trades memory for performance.
705 *
706 * For expected memory usage, see the MLD_TOTAL_ALLOC_* constants
707 * defined in mldsa_native.h.
708 *
709 * This option is useful for embedded systems with tight RAM
710 * constraints but relaxed performance requirements.
711 *
712 * WARNING: This option is experimental!
713 * CBMC proofs do not currently cover this configuration option.
714 * Its scope and configuration may change at any time.
715 *
716 *****************************************************************************/
717 /* #define MLD_CONFIG_REDUCE_RAM */
718
719 /************************* Config internals ********************************/
720
721 #endif /* MLD_BUILD_INTERNAL */
722
723 /* Default namespace
724 *
725 * Don't change this. If you need a different namespace, re-define
726 * MLD_CONFIG_NAMESPACE_PREFIX above instead, and remove the following.
727 *
728 * The default MLDSA namespace is
729 *
730 * PQCP_MLDSA_NATIVE_MLDSA<LEVEL>_
731 *
732 * e.g., PQCP_MLDSA_NATIVE_MLDSA44_
733 */
734
735 #if MLD_CONFIG_PARAMETER_SET == 44
736 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA44
737 #elif MLD_CONFIG_PARAMETER_SET == 65
738 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA65
739 #elif MLD_CONFIG_PARAMETER_SET == 87
740 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA87
741 #endif
742
743 #endif /* !MLD_CONFIG_H */