diff --git a/dev/fips202/aarch64/x1_scalar.h b/dev/fips202/aarch64/x1_scalar.h index 5c6561935..42e1e7609 100644 --- a/dev/fips202/aarch64/x1_scalar.h +++ b/dev/fips202/aarch64/x1_scalar.h @@ -8,7 +8,7 @@ #define MLD_DEV_FIPS202_AARCH64_X1_SCALAR_H /* Part of backend API */ -#define MLD_USE_FIPS202_X1_NATIVE +#define MLD_USE_NATIVE_FIPS202_X1 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X1_SCALAR diff --git a/dev/fips202/aarch64/x1_v84a.h b/dev/fips202/aarch64/x1_v84a.h index 65d7352cd..4250b7a54 100644 --- a/dev/fips202/aarch64/x1_v84a.h +++ b/dev/fips202/aarch64/x1_v84a.h @@ -12,7 +12,7 @@ #endif /* Part of backend API */ -#define MLD_USE_FIPS202_X1_NATIVE +#define MLD_USE_NATIVE_FIPS202_X1 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X1_V84A diff --git a/dev/fips202/aarch64/x2_v84a.h b/dev/fips202/aarch64/x2_v84a.h index 178202fa4..02c1c895f 100644 --- a/dev/fips202/aarch64/x2_v84a.h +++ b/dev/fips202/aarch64/x2_v84a.h @@ -12,7 +12,7 @@ #endif /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X2_V84A diff --git a/dev/fips202/aarch64/x4_v8a_scalar.h b/dev/fips202/aarch64/x4_v8a_scalar.h index 75143a753..4c6f1c2d7 100644 --- a/dev/fips202/aarch64/x4_v8a_scalar.h +++ b/dev/fips202/aarch64/x4_v8a_scalar.h @@ -8,7 +8,7 @@ #define MLD_DEV_FIPS202_AARCH64_X4_V8A_SCALAR_H /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID diff --git a/dev/fips202/aarch64/x4_v8a_v84a_scalar.h b/dev/fips202/aarch64/x4_v8a_v84a_scalar.h index 57b7dcc5d..d4db6b3ef 100644 --- a/dev/fips202/aarch64/x4_v8a_v84a_scalar.h +++ b/dev/fips202/aarch64/x4_v8a_v84a_scalar.h @@ -12,7 +12,7 @@ #endif /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID diff --git a/dev/fips202/armv81m/mve.h b/dev/fips202/armv81m/mve.h index 03ff5798c..0adff0df4 100644 --- a/dev/fips202/armv81m/mve.h +++ b/dev/fips202/armv81m/mve.h @@ -10,9 +10,9 @@ #define MLD_FIPS202_NATIVE_ARMV81M /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE -#define MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE -#define MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 +#define MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES +#define MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES /* Guard for assembly file */ #define MLD_FIPS202_ARMV81M_NEED_X4 diff --git a/dev/fips202/x86_64/keccak_f1600_x4_avx2.h b/dev/fips202/x86_64/keccak_f1600_x4_avx2.h index a959126b4..0267b52c0 100644 --- a/dev/fips202/x86_64/keccak_f1600_x4_avx2.h +++ b/dev/fips202/x86_64/keccak_f1600_x4_avx2.h @@ -12,7 +12,7 @@ #define MLD_FIPS202_X86_64_NEED_X4_AVX2 /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 #if !defined(__ASSEMBLER__) #include "../api.h" diff --git a/examples/custom_backend/README.md b/examples/custom_backend/README.md index 9412dba97..a9ac58a76 100644 --- a/examples/custom_backend/README.md +++ b/examples/custom_backend/README.md @@ -31,7 +31,7 @@ The configuration file [mldsa_native_config.h](mldsa_native/mldsa_native_config. A custom backend consists of: 1. A metadata header (e.g., [custom.h](mldsa_native/src/fips202/native/custom/custom.h)) that: - - Sets `MLD_USE_FIPS202_X1_NATIVE` (and/or `X4`) to indicate which functions are replaced + - Sets `MLD_USE_NATIVE_FIPS202_X1` (and/or `X4`) to indicate which functions are replaced - Includes the implementation header 2. An implementation providing `mld_keccakf1600_native()` (and/or batched variants) @@ -41,7 +41,7 @@ Example backend metadata file: #define CUSTOM_FIPS202_BACKEND_H /* Indicate we're replacing 1-fold Keccak-f1600 */ -#define MLD_USE_FIPS202_X1_NATIVE +#define MLD_USE_NATIVE_FIPS202_X1 /* Include the implementation */ #include "custom/src/keccak_impl.h" diff --git a/examples/custom_backend/mldsa_native/src/fips202/native/custom/custom.h b/examples/custom_backend/mldsa_native/src/fips202/native/custom/custom.h index afd8a3fd3..23579cd37 100644 --- a/examples/custom_backend/mldsa_native/src/fips202/native/custom/custom.h +++ b/examples/custom_backend/mldsa_native/src/fips202/native/custom/custom.h @@ -10,7 +10,7 @@ #include "../api.h" #include "src/sha3.h" /* Replace (single) Keccak-F1600 by tiny-SHA3's */ -#define MLD_USE_FIPS202_X1_NATIVE +#define MLD_USE_NATIVE_FIPS202_X1 static MLD_INLINE int mld_keccak_f1600_x1_native(uint64_t *state) { tiny_sha3_keccakf(state); diff --git a/mldsa/mldsa_native.c b/mldsa/mldsa_native.c index 9365ed369..adf0e4e60 100644 --- a/mldsa/mldsa_native.c +++ b/mldsa/mldsa_native.c @@ -626,23 +626,23 @@ /* mldsa/src/fips202/native/aarch64/x1_scalar.h */ #undef MLD_FIPS202_AARCH64_NEED_X1_SCALAR #undef MLD_FIPS202_NATIVE_AARCH64_X1_SCALAR_H -#undef MLD_USE_FIPS202_X1_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X1 /* mldsa/src/fips202/native/aarch64/x1_v84a.h */ #undef MLD_FIPS202_AARCH64_NEED_X1_V84A #undef MLD_FIPS202_NATIVE_AARCH64_X1_V84A_H -#undef MLD_USE_FIPS202_X1_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X1 /* mldsa/src/fips202/native/aarch64/x2_v84a.h */ #undef MLD_FIPS202_AARCH64_NEED_X2_V84A #undef MLD_FIPS202_NATIVE_AARCH64_X2_V84A_H -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 /* mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h */ #undef MLD_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID #undef MLD_FIPS202_NATIVE_AARCH64_X4_V8A_SCALAR_H -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 /* mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h */ #undef MLD_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID #undef MLD_FIPS202_NATIVE_AARCH64_X4_V8A_V84A_SCALAR_H -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 #endif /* MLD_SYS_AARCH64 */ #if defined(MLD_SYS_X86_64) /* @@ -651,7 +651,7 @@ /* mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h */ #undef MLD_FIPS202_NATIVE_X86_64_KECCAK_F1600_X4_AVX2_H #undef MLD_FIPS202_X86_64_NEED_X4_AVX2 -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 /* mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h */ #undef MLD_FIPS202_NATIVE_X86_64_SRC_FIPS202_NATIVE_X86_64_H #undef mld_keccak_f1600_x4_avx2_asm @@ -667,9 +667,9 @@ #undef MLD_FIPS202_ARMV81M_NEED_X4 #undef MLD_FIPS202_NATIVE_ARMV81M #undef MLD_FIPS202_NATIVE_ARMV81M_MVE_H -#undef MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE -#undef MLD_USE_FIPS202_X4_NATIVE -#undef MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 +#undef MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES +#undef MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES #undef mld_keccak_f1600_x4_native_impl #undef mld_keccak_f1600_x4_state_extract_bytes #undef mld_keccak_f1600_x4_state_xor_bytes diff --git a/mldsa/mldsa_native_asm.S b/mldsa/mldsa_native_asm.S index 4877d5156..ba59f0134 100644 --- a/mldsa/mldsa_native_asm.S +++ b/mldsa/mldsa_native_asm.S @@ -639,23 +639,23 @@ /* mldsa/src/fips202/native/aarch64/x1_scalar.h */ #undef MLD_FIPS202_AARCH64_NEED_X1_SCALAR #undef MLD_FIPS202_NATIVE_AARCH64_X1_SCALAR_H -#undef MLD_USE_FIPS202_X1_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X1 /* mldsa/src/fips202/native/aarch64/x1_v84a.h */ #undef MLD_FIPS202_AARCH64_NEED_X1_V84A #undef MLD_FIPS202_NATIVE_AARCH64_X1_V84A_H -#undef MLD_USE_FIPS202_X1_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X1 /* mldsa/src/fips202/native/aarch64/x2_v84a.h */ #undef MLD_FIPS202_AARCH64_NEED_X2_V84A #undef MLD_FIPS202_NATIVE_AARCH64_X2_V84A_H -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 /* mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h */ #undef MLD_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID #undef MLD_FIPS202_NATIVE_AARCH64_X4_V8A_SCALAR_H -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 /* mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h */ #undef MLD_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID #undef MLD_FIPS202_NATIVE_AARCH64_X4_V8A_V84A_SCALAR_H -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 #endif /* MLD_SYS_AARCH64 */ #if defined(MLD_SYS_X86_64) /* @@ -664,7 +664,7 @@ /* mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h */ #undef MLD_FIPS202_NATIVE_X86_64_KECCAK_F1600_X4_AVX2_H #undef MLD_FIPS202_X86_64_NEED_X4_AVX2 -#undef MLD_USE_FIPS202_X4_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 /* mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h */ #undef MLD_FIPS202_NATIVE_X86_64_SRC_FIPS202_NATIVE_X86_64_H #undef mld_keccak_f1600_x4_avx2_asm @@ -680,9 +680,9 @@ #undef MLD_FIPS202_ARMV81M_NEED_X4 #undef MLD_FIPS202_NATIVE_ARMV81M #undef MLD_FIPS202_NATIVE_ARMV81M_MVE_H -#undef MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE -#undef MLD_USE_FIPS202_X4_NATIVE -#undef MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE +#undef MLD_USE_NATIVE_FIPS202_X4 +#undef MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES +#undef MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES #undef mld_keccak_f1600_x4_native_impl #undef mld_keccak_f1600_x4_state_extract_bytes #undef mld_keccak_f1600_x4_state_xor_bytes diff --git a/mldsa/src/fips202/keccakf1600.c b/mldsa/src/fips202/keccakf1600.c index 4218b9435..1fb5240a3 100644 --- a/mldsa/src/fips202/keccakf1600.c +++ b/mldsa/src/fips202/keccakf1600.c @@ -123,14 +123,14 @@ void mld_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0, unsigned char *data3, unsigned offset, unsigned length) { -#if defined(MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES) if (mld_keccakf1600_extract_bytes_x4_native(state, data0, data1, data2, data3, offset, length) == MLD_NATIVE_FUNC_SUCCESS) { return; } -#endif /* MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES */ mld_keccakf1600x4_extract_bytes_c(state, data0, data1, data2, data3, offset, length); } @@ -173,14 +173,14 @@ void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0, const unsigned char *data3, unsigned offset, unsigned length) { -#if defined(MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES) if (mld_keccakf1600_xor_bytes_x4_native(state, data0, data1, data2, data3, offset, length) == MLD_NATIVE_FUNC_SUCCESS) { return; } -#endif /* MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES */ mld_keccakf1600x4_xor_bytes_c(state, data0, data1, data2, data3, offset, length); } @@ -188,12 +188,12 @@ void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0, MLD_INTERNAL_API void mld_keccakf1600x4_permute(uint64_t *state) { -#if defined(MLD_USE_FIPS202_X4_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X4) if (mld_keccak_f1600_x4_native(state) == MLD_NATIVE_FUNC_SUCCESS) { return; } -#endif /* MLD_USE_FIPS202_X4_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X4 */ mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 0); mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 1); mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 2); @@ -491,12 +491,12 @@ __contract__( MLD_INTERNAL_API void mld_keccakf1600_permute(uint64_t *state) { -#if defined(MLD_USE_FIPS202_X1_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X1) if (mld_keccak_f1600_x1_native(state) == MLD_NATIVE_FUNC_SUCCESS) { return; } -#endif /* MLD_USE_FIPS202_X1_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X1 */ mld_keccakf1600_permute_c(state); } diff --git a/mldsa/src/fips202/native/aarch64/x1_scalar.h b/mldsa/src/fips202/native/aarch64/x1_scalar.h index 67505238e..94ac849f7 100644 --- a/mldsa/src/fips202/native/aarch64/x1_scalar.h +++ b/mldsa/src/fips202/native/aarch64/x1_scalar.h @@ -8,7 +8,7 @@ #define MLD_FIPS202_NATIVE_AARCH64_X1_SCALAR_H /* Part of backend API */ -#define MLD_USE_FIPS202_X1_NATIVE +#define MLD_USE_NATIVE_FIPS202_X1 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X1_SCALAR diff --git a/mldsa/src/fips202/native/aarch64/x1_v84a.h b/mldsa/src/fips202/native/aarch64/x1_v84a.h index 82f56c363..bb22ab8c3 100644 --- a/mldsa/src/fips202/native/aarch64/x1_v84a.h +++ b/mldsa/src/fips202/native/aarch64/x1_v84a.h @@ -12,7 +12,7 @@ #endif /* Part of backend API */ -#define MLD_USE_FIPS202_X1_NATIVE +#define MLD_USE_NATIVE_FIPS202_X1 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X1_V84A diff --git a/mldsa/src/fips202/native/aarch64/x2_v84a.h b/mldsa/src/fips202/native/aarch64/x2_v84a.h index 1cbc5d216..3e0558350 100644 --- a/mldsa/src/fips202/native/aarch64/x2_v84a.h +++ b/mldsa/src/fips202/native/aarch64/x2_v84a.h @@ -12,7 +12,7 @@ #endif /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X2_V84A diff --git a/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h b/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h index 07fa72089..047da77cf 100644 --- a/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +++ b/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h @@ -8,7 +8,7 @@ #define MLD_FIPS202_NATIVE_AARCH64_X4_V8A_SCALAR_H /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID diff --git a/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h b/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h index 064c2f5ee..c20ddfb65 100644 --- a/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +++ b/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h @@ -12,7 +12,7 @@ #endif /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 /* Guard for assembly file */ #define MLD_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID diff --git a/mldsa/src/fips202/native/api.h b/mldsa/src/fips202/native/api.h index 3b5b61afc..7abac85a4 100644 --- a/mldsa/src/fips202/native/api.h +++ b/mldsa/src/fips202/native/api.h @@ -39,13 +39,13 @@ * A _backend_ is a specific implementation of parts of this interface. * * You can replace 1-fold or 4-fold batched Keccak-F1600. - * To enable, set MLD_USE_FIPS202_X1_NATIVE or MLD_USE_FIPS202_X4_NATIVE + * To enable, set MLD_USE_NATIVE_FIPS202_X1 or MLD_USE_NATIVE_FIPS202_X4 * in your backend, and define the inline wrappers mld_keccak_f1600_x1_native() * and/or mld_keccak_f1600_x4_native(), respectively, to forward to your * implementation. */ -#if defined(MLD_USE_FIPS202_X1_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X1) MLD_MUST_CHECK_RETURN_VALUE static MLD_INLINE int mld_keccak_f1600_x1_native(uint64_t *state) __contract__( @@ -54,8 +54,8 @@ __contract__( ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS) ensures((return_value == MLD_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 1)) ); -#endif /* MLD_USE_FIPS202_X1_NATIVE */ -#if defined(MLD_USE_FIPS202_X4_NATIVE) +#endif /* MLD_USE_NATIVE_FIPS202_X1 */ +#if defined(MLD_USE_NATIVE_FIPS202_X4) MLD_MUST_CHECK_RETURN_VALUE static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state) __contract__( @@ -64,7 +64,7 @@ __contract__( ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS) ensures((return_value == MLD_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 4)) ); -#endif /* MLD_USE_FIPS202_X4_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X4 */ /* * Native x4 XOR bytes and extract bytes interface. @@ -78,12 +78,12 @@ __contract__( * NOTE: We assume that the custom representation of the zero state is the * all-zero state. * - * MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE: Backend provides native XOR bytes - * MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE: Backend provides native extract + * MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES: Backend provides native XOR bytes + * MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES: Backend provides native extract * bytes */ -#if defined(MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES) MLD_MUST_CHECK_RETURN_VALUE static MLD_INLINE int mld_keccakf1600_xor_bytes_x4_native( uint64_t *state, const unsigned char *data0, const unsigned char *data1, @@ -103,9 +103,9 @@ __contract__( assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4)) ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS) ensures((return_value == MLD_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 4))); -#endif /* MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES */ -#if defined(MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES) MLD_MUST_CHECK_RETURN_VALUE static MLD_INLINE int mld_keccakf1600_extract_bytes_x4_native( uint64_t *state, unsigned char *data0, unsigned char *data1, @@ -124,6 +124,6 @@ __contract__( assigns(memory_slice(data2, length)) assigns(memory_slice(data3, length)) ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS)); -#endif /* MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES */ #endif /* !MLD_FIPS202_NATIVE_API_H */ diff --git a/mldsa/src/fips202/native/armv81m/mve.h b/mldsa/src/fips202/native/armv81m/mve.h index 3d5e6f7db..2bce07076 100644 --- a/mldsa/src/fips202/native/armv81m/mve.h +++ b/mldsa/src/fips202/native/armv81m/mve.h @@ -10,9 +10,9 @@ #define MLD_FIPS202_NATIVE_ARMV81M /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE -#define MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE -#define MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 +#define MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES +#define MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES /* Guard for assembly file */ #define MLD_FIPS202_ARMV81M_NEED_X4 diff --git a/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h b/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h index 7c37e9308..097e2f5c0 100644 --- a/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +++ b/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h @@ -12,7 +12,7 @@ #define MLD_FIPS202_X86_64_NEED_X4_AVX2 /* Part of backend API */ -#define MLD_USE_FIPS202_X4_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 #if !defined(__ASSEMBLER__) #include "../api.h" diff --git a/proofs/cbmc/dummy_backend_fips202_x1.h b/proofs/cbmc/dummy_backend_fips202_x1.h index fb71bdc31..abd8f5f7a 100644 --- a/proofs/cbmc/dummy_backend_fips202_x1.h +++ b/proofs/cbmc/dummy_backend_fips202_x1.h @@ -7,7 +7,7 @@ #define MLD_DUMMY_FIPS202X1_BACKEND_H -#define MLD_USE_FIPS202_X1_NATIVE +#define MLD_USE_NATIVE_FIPS202_X1 #include "../../mldsa/src/fips202/native/api.h" diff --git a/proofs/cbmc/dummy_backend_fips202_x4.h b/proofs/cbmc/dummy_backend_fips202_x4.h index b42cbf34d..d487f8ab5 100644 --- a/proofs/cbmc/dummy_backend_fips202_x4.h +++ b/proofs/cbmc/dummy_backend_fips202_x4.h @@ -7,9 +7,9 @@ #define MLD_DUMMY_FIPS202X4_BACKEND_H -#define MLD_USE_FIPS202_X4_NATIVE -#define MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE -#define MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE +#define MLD_USE_NATIVE_FIPS202_X4 +#define MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES +#define MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES #include "../../mldsa/src/fips202/native/api.h" diff --git a/test/src/test_unit.c b/test/src/test_unit.c index e7a6a5cb2..357d62613 100644 --- a/test/src/test_unit.c +++ b/test/src/test_unit.c @@ -64,7 +64,7 @@ unsigned int mld_rej_eta_c(int32_t *a, unsigned int target, unsigned int offset, #endif void mld_keccakf1600_permute_c(uint64_t *state); -#if defined(MLD_USE_FIPS202_X1_NATIVE) +#if defined(MLD_USE_NATIVE_FIPS202_X1) static void print_u64_array(const char *label, const uint64_t *array, size_t len) { @@ -112,7 +112,7 @@ static int compare_u64_arrays(const uint64_t *a, const uint64_t *b, } return 1; } -#endif /* MLD_USE_FIPS202_X1_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X1 */ #if defined(MLD_USE_NATIVE_NTT) || defined(MLD_USE_NATIVE_INTT) || \ defined(MLD_USE_NATIVE_POLY_DECOMPOSE_32) || \ @@ -130,7 +130,7 @@ static int compare_u64_arrays(const uint64_t *a, const uint64_t *b, defined(MLD_USE_NATIVE_REJ_UNIFORM) || \ defined(MLD_USE_NATIVE_REJ_UNIFORM_ETA2) || \ defined(MLD_USE_NATIVE_REJ_UNIFORM_ETA4) || \ - defined(MLD_USE_FIPS202_X1_NATIVE) || defined(MLD_USE_FIPS202_X4_NATIVE) + defined(MLD_USE_NATIVE_FIPS202_X1) || defined(MLD_USE_NATIVE_FIPS202_X4) /* Backend unit test helper functions for arithmetic native backends */ #if defined(MLD_USE_NATIVE_NTT) || defined(MLD_USE_NATIVE_INTT) || \ @@ -1015,7 +1015,7 @@ static int test_native_rej_uniform_eta4(void) #endif /* !MLD_CONFIG_NO_KEYPAIR_API */ -#ifdef MLD_USE_FIPS202_X1_NATIVE +#ifdef MLD_USE_NATIVE_FIPS202_X1 static int test_keccakf1600_permute(void) { int ret = 1; @@ -1047,13 +1047,13 @@ static int test_keccakf1600_permute(void) MLD_FREE(state, uint64_t, MLD_KECCAK_LANES, NULL); return ret; } -#endif /* MLD_USE_FIPS202_X1_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X1 */ /* * Test that x4 Keccak (xor_bytes, permute, extract_bytes) produces * the same results as the x1 C reference. */ -#ifdef MLD_USE_FIPS202_X4_NATIVE +#ifdef MLD_USE_NATIVE_FIPS202_X4 #define MAX_RATE 136 static int test_keccakf1600x4_xor_permute_extract(void) @@ -1123,7 +1123,7 @@ static int test_keccakf1600x4_xor_permute_extract(void) } #undef MAX_RATE -#endif /* MLD_USE_FIPS202_X4_NATIVE */ +#endif /* MLD_USE_NATIVE_FIPS202_X4 */ static int test_backend_units(void) { @@ -1193,11 +1193,11 @@ static int test_backend_units(void) #endif #endif /* !MLD_CONFIG_NO_KEYPAIR_API */ -#ifdef MLD_USE_FIPS202_X1_NATIVE +#ifdef MLD_USE_NATIVE_FIPS202_X1 CHECK(test_keccakf1600_permute() == 0); #endif -#ifdef MLD_USE_FIPS202_X4_NATIVE +#ifdef MLD_USE_NATIVE_FIPS202_X4 CHECK(test_keccakf1600x4_xor_permute_extract() == 0); #endif @@ -1213,8 +1213,8 @@ static int test_backend_units(void) MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L7 || \ MLD_USE_NATIVE_POLYZ_UNPACK_17 || MLD_USE_NATIVE_POLYZ_UNPACK_19 || \ MLD_USE_NATIVE_REJ_UNIFORM || MLD_USE_NATIVE_REJ_UNIFORM_ETA2 || \ - MLD_USE_NATIVE_REJ_UNIFORM_ETA4 || MLD_USE_FIPS202_X1_NATIVE || \ - MLD_USE_FIPS202_X4_NATIVE */ + MLD_USE_NATIVE_REJ_UNIFORM_ETA4 || MLD_USE_NATIVE_FIPS202_X1 || \ + MLD_USE_NATIVE_FIPS202_X4 */ #if !defined(MLD_CONFIG_NO_SIGN_API) /* Test that eager and lazy polyvec init+get produce the same results */ @@ -1429,7 +1429,7 @@ int main(void) defined(MLD_USE_NATIVE_REJ_UNIFORM) || \ defined(MLD_USE_NATIVE_REJ_UNIFORM_ETA2) || \ defined(MLD_USE_NATIVE_REJ_UNIFORM_ETA4) || \ - defined(MLD_USE_FIPS202_X1_NATIVE) || defined(MLD_USE_FIPS202_X4_NATIVE) + defined(MLD_USE_NATIVE_FIPS202_X1) || defined(MLD_USE_NATIVE_FIPS202_X4) CHECK(test_backend_units() == 0); #endif /* MLD_USE_NATIVE_NTT || MLD_USE_NATIVE_INTT || \ MLD_USE_NATIVE_POLY_DECOMPOSE_32 || MLD_USE_NATIVE_POLY_DECOMPOSE_88 \ @@ -1441,8 +1441,8 @@ int main(void) MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L7 || \ MLD_USE_NATIVE_POLYZ_UNPACK_17 || MLD_USE_NATIVE_POLYZ_UNPACK_19 || \ MLD_USE_NATIVE_REJ_UNIFORM || MLD_USE_NATIVE_REJ_UNIFORM_ETA2 || \ - MLD_USE_NATIVE_REJ_UNIFORM_ETA4 || MLD_USE_FIPS202_X1_NATIVE || \ - MLD_USE_FIPS202_X4_NATIVE */ + MLD_USE_NATIVE_REJ_UNIFORM_ETA4 || MLD_USE_NATIVE_FIPS202_X1 || \ + MLD_USE_NATIVE_FIPS202_X4 */ return 0;