/* * Circe configuration for mldsa-native. * * Selected instead of contrib/mldsa-native/mldsa/mldsa_native_config.h by * building with -DMLD_CONFIG_FILE="circe_mldsa_config.h" (see * contrib/meson.build). * * Circe only needs ML-DSA-44 with the randomized (randombytes) API. */ #ifndef MLD_CONFIG_H #define MLD_CONFIG_H /* ML-DSA-44. */ #define MLD_CONFIG_PARAMETER_SET 44 /* Namespace prefix for exported symbols (matches the upstream default for 44). */ #define MLD_CONFIG_NAMESPACE_PREFIX PQCP_MLDSA_NATIVE_MLDSA44 /* * Randomized API. * * We deliberately leave MLD_CONFIG_NO_RANDOMIZED_API and * MLD_CONFIG_CUSTOM_RANDOMBYTES *unset*: mldsa-native keeps the randomized * signing API and expects the consumer to provide * * int randombytes(uint8_t *out, size_t outlen); // 0 on success * * No deterministic/derand-only build. */ /* * Implementation-only options. * * MLD_BUILD_INTERNAL is defined by the library's src/common.h before this file * is included, so these only affect the library build, not consumers that * merely include mldsa_native.h. */ #if defined(MLD_BUILD_INTERNAL) /* * Use the optimized native backends on AArch64 and x86-64, and the portable C * backends everywhere else. The architecture is detected from the compiler's * predefined macros, matching mldsa-native's own src/sys.h; the actual backend * (NEON / AVX2, and the SHA3/Keccak accelerator) is then selected * automatically from the -march flags passed by contrib/meson.build. */ #if defined(__aarch64__) || defined(__x86_64__) #define MLD_CONFIG_USE_NATIVE_BACKEND_ARITH #define MLD_CONFIG_ARITH_BACKEND_FILE "native/meta.h" #define MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 #define MLD_CONFIG_FIPS202_BACKEND_FILE "fips202/native/auto.h" #endif /* * Freestanding build: no libc is linked, so route mldsa-native's memcpy / * memset / stack-zeroization through Circe's portable implementations in * common/memory.c. This drops the library's includes and leaves no * unresolved libc symbols. */ #define MLD_CONFIG_CUSTOM_MEMCPY #define MLD_CONFIG_CUSTOM_MEMSET #define MLD_CONFIG_CUSTOM_ZEROIZE #if !defined(__ASSEMBLER__) #include "src/sys.h" /* for MLD_INLINE */ #include #include /* Defined in common/memory.c */ void *circe_memcpy (void *restrict dest, const void *restrict src, size_t n); void *circe_memset (void *dest, int value, size_t count); static MLD_INLINE void * mld_memcpy (void *dest, const void *src, size_t n) { return circe_memcpy (dest, src, n); } static MLD_INLINE void * mld_memset (void *s, int c, size_t n) { return circe_memset (s, c, n); } static MLD_INLINE void mld_zeroize (void *ptr, size_t len) { circe_memset (ptr, 0, len); } #endif /* !__ASSEMBLER__ */ #endif /* MLD_BUILD_INTERNAL */ #endif /* MLD_CONFIG_H */