Debian Codegraph @

others/mbedtls/tf-psa-crypto/drivers/pqcp/mldsa-native/test/configs/custom_stdlib_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 stdlib functions
29 *
30 * This configuration differs from the default mldsa/mldsa_native_config.h in
31 * the following places:
32 * - MLD_CONFIG_CUSTOM_MEMCPY
33 * - MLD_CONFIG_CUSTOM_MEMSET
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 <stddef.h>
520 #include <stdint.h>
521 #include "../mldsa/src/sys.h"
522 static MLD_INLINE void *mld_memcpy(void *dest, const void *src, size_t n)
523 {
524 /* Simple byte-by-byte copy implementation for testing */
525 unsigned char *d = (unsigned char *)dest;
526 const unsigned char *s = (const unsigned char *)src;
527 for (size_t i = 0; i < n; i++)
528 {
529 d[i] = s[i];
530 }
531 return dest;
532 }
533 #endif /* !__ASSEMBLER__ */
534
535
536 /******************************************************************************
537 * Name: MLD_CONFIG_CUSTOM_MEMSET
538 *
539 * Description: Set this option and define `mld_memset` if you want to
540 * use a custom method to set memory instead of the standard
541 * library memset function.
542 *
543 * The custom implementation must have the same signature and
544 * behavior as the standard memset function:
545 * void *mld_memset(void *s, int c, size_t n)
546 *
547 *****************************************************************************/
548 #define MLD_CONFIG_CUSTOM_MEMSET
549 #if !defined(__ASSEMBLER__)
550 #include <stddef.h>
551 #include <stdint.h>
552 #include "../mldsa/src/sys.h"
553 static MLD_INLINE void *mld_memset(void *s, int c, size_t n)
554 {
555 /* Simple byte-by-byte set implementation for testing */
556 unsigned char *ptr = (unsigned char *)s;
557 for (size_t i = 0; i < n; i++)
558 {
559 ptr[i] = (unsigned char)c;
560 }
561 return s;
562 }
563 #endif /* !__ASSEMBLER__ */
564
565
566 /******************************************************************************
567 * Name: MLD_CONFIG_INTERNAL_API_QUALIFIER
568 *
569 * Description: If set, this option provides an additional function
570 * qualifier to be added to declarations of internal API.
571 *
572 * The primary use case for this option are single-CU builds,
573 * in which case this option can be set to `static`.
574 *
575 *****************************************************************************/
576 /* #define MLD_CONFIG_INTERNAL_API_QUALIFIER */
577
578 /******************************************************************************
579 * Name: MLD_CONFIG_CT_TESTING_ENABLED
580 *
581 * Description: If set, mldsa-native annotates data as secret / public using
582 * valgrind's annotations VALGRIND_MAKE_MEM_UNDEFINED and
583 * VALGRIND_MAKE_MEM_DEFINED, enabling various checks for secret-
584 * dependent control flow of variable time execution (depending
585 * on the exact version of valgrind installed).
586 *
587 *****************************************************************************/
588 /* #define MLD_CONFIG_CT_TESTING_ENABLED */
589
590 /******************************************************************************
591 * Name: MLD_CONFIG_NO_ASM
592 *
593 * Description: If this option is set, mldsa-native will be built without
594 * use of native code or inline assembly.
595 *
596 * By default, inline assembly is used to implement value barriers.
597 * Without inline assembly, mldsa-native will use a global volatile
598 * 'opt blocker' instead; see ct.h.
599 *
600 * Inline assembly is also used to implement a secure zeroization
601 * function on non-Windows platforms. If this option is set and
602 * the target platform is not Windows, you MUST set
603 * MLD_CONFIG_CUSTOM_ZEROIZE and provide a custom zeroization
604 * function.
605 *
606 * If this option is set, MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 and
607 * and MLD_CONFIG_USE_NATIVE_BACKEND_ARITH will be ignored, and no
608 * native backends will be used.
609 *
610 *****************************************************************************/
611 /* #define MLD_CONFIG_NO_ASM */
612
613 /******************************************************************************
614 * Name: MLD_CONFIG_NO_ASM_VALUE_BARRIER
615 *
616 * Description: If this option is set, mldsa-native will be built without
617 * use of native code or inline assembly for value barriers.
618 *
619 * By default, inline assembly (if available) is used to implement
620 * value barriers.
621 * Without inline assembly, mldsa-native will use a global volatile
622 * 'opt blocker' instead; see ct.h.
623 *
624 *****************************************************************************/
625 /* #define MLD_CONFIG_NO_ASM_VALUE_BARRIER */
626
627 /******************************************************************************
628 * Name: MLD_CONFIG_KEYGEN_PCT
629 *
630 * Description: Compliance with @[FIPS140_3_IG, p.87] requires a
631 * Pairwise Consistency Test (PCT) to be carried out on a freshly
632 * generated keypair before it can be exported.
633 *
634 * Set this option if such a check should be implemented.
635 * In this case, crypto_sign_keypair_internal and
636 * crypto_sign_keypair will return a non-zero error code if the
637 * PCT failed.
638 *
639 * NOTE: This feature will drastically lower the performance of
640 * key generation.
641 *
642 *****************************************************************************/
643 /* #define MLD_CONFIG_KEYGEN_PCT */
644
645 /******************************************************************************
646 * Name: MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
647 *
648 * Description: If this option is set, the user must provide a runtime
649 * function `static inline int mld_break_pct() { ... }` to
650 * indicate whether the PCT should be made fail.
651 *
652 * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set.
653 *
654 *****************************************************************************/
655 /* #define MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
656 #if !defined(__ASSEMBLER__)
657 #include "src/src.h"
658 static MLD_INLINE int mld_break_pct(void)
659 {
660 ... return 0/1 depending on whether PCT should be broken ...
661 }
662 #endif
663 */
664
665 /******************************************************************************
666 * Name: MLD_CONFIG_SERIAL_FIPS202_ONLY
667 *
668 * Description: Set this to use a FIPS202 implementation with global state
669 * that supports only one active Keccak computation at a time
670 * (e.g. some hardware accelerators).
671 *
672 * If this option is set, ML-DSA will use FIPS202 operations
673 * serially, ensuring that only one SHAKE context is active
674 * at any given time.
675 *
676 * This allows offloading Keccak computations to a hardware
677 * accelerator that holds only a single Keccak state locally,
678 * rather than requiring support for multiple concurrent
679 * Keccak states.
680 *
681 * NOTE: Depending on the target CPU, this may reduce
682 * performance when using software FIPS202 implementations.
683 * Only enable this when you have to.
684 *
685 *****************************************************************************/
686 /* #define MLD_CONFIG_SERIAL_FIPS202_ONLY */
687
688 /******************************************************************************
689 * Name: MLD_CONFIG_CONTEXT_PARAMETER
690 *
691 * Description: Set this to add a context parameter that is provided to public
692 * API functions and is then available in custom callbacks.
693 *
694 * The type of the context parameter is configured via
695 * MLD_CONFIG_CONTEXT_PARAMETER_TYPE.
696 *
697 *****************************************************************************/
698 /* #define MLD_CONFIG_CONTEXT_PARAMETER */
699
700 /******************************************************************************
701 * Name: MLD_CONFIG_CONTEXT_PARAMETER_TYPE
702 *
703 * Description: Set this to define the type for the context parameter used by
704 * MLD_CONFIG_CONTEXT_PARAMETER.
705 *
706 * This is only relevant if MLD_CONFIG_CONTEXT_PARAMETER is set.
707 *
708 *****************************************************************************/
709 /* #define MLD_CONFIG_CONTEXT_PARAMETER_TYPE void* */
710
711 /******************************************************************************
712 * Name: MLD_CONFIG_REDUCE_RAM [EXPERIMENTAL]
713 *
714 * Description: Set this to reduce RAM usage.
715 * This trades memory for performance.
716 *
717 * For expected memory usage, see the MLD_TOTAL_ALLOC_* constants
718 * defined in mldsa_native.h.
719 *
720 * This option is useful for embedded systems with tight RAM
721 * constraints but relaxed performance requirements.
722 *
723 * WARNING: This option is experimental!
724 * CBMC proofs do not currently cover this configuration option.
725 * Its scope and configuration may change at any time.
726 *
727 *****************************************************************************/
728 /* #define MLD_CONFIG_REDUCE_RAM */
729
730 /************************* Config internals ********************************/
731
732 #endif /* MLD_BUILD_INTERNAL */
733
734 /* Default namespace
735 *
736 * Don't change this. If you need a different namespace, re-define
737 * MLD_CONFIG_NAMESPACE_PREFIX above instead, and remove the following.
738 *
739 * The default MLDSA namespace is
740 *
741 * PQCP_MLDSA_NATIVE_MLDSA<LEVEL>_
742 *
743 * e.g., PQCP_MLDSA_NATIVE_MLDSA44_
744 */
745
746 #if MLD_CONFIG_PARAMETER_SET == 44
747 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA44
748 #elif MLD_CONFIG_PARAMETER_SET == 65
749 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA65
750 #elif MLD_CONFIG_PARAMETER_SET == 87
751 #define MLD_DEFAULT_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA87
752 #endif
753
754 #endif /* !MLD_CONFIG_H */