Debian Codegraph @

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