Skip to content

Commit f773262

Browse files
flyndmkannwischer
authored andcommitted
fips202: Don't build Keccak-f1600x2/x4 unless used
When building with MLD_CONFIG_SERIAL_FIPS202_ONLY, Keccak-f1600x2/x4 is not used and can be skipped. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
1 parent af47899 commit f773262

5 files changed

Lines changed: 12 additions & 1 deletion

File tree

dev/fips202/aarch64/auto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "x1_scalar.h"
3838
#endif
3939

40+
#if !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
4041
/*
4142
* Keccak-f1600x2/x4
4243
*
@@ -68,4 +69,6 @@
6869

6970
#endif /* !__ARM_FEATURE_SHA3 */
7071

72+
#endif /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
73+
7174
#endif /* !MLD_DEV_FIPS202_AARCH64_AUTO_H */

mldsa/src/fips202/keccakf1600.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void mld_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
8484
#endif /* !MLD_SYS_LITTLE_ENDIAN */
8585
}
8686

87+
#if !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
8788
MLD_INTERNAL_API
8889
void mld_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
8990
unsigned char *data1, unsigned char *data2,
@@ -131,6 +132,7 @@ void mld_keccakf1600x4_permute(uint64_t *state)
131132
mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 2);
132133
mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 3);
133134
}
135+
#endif /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
134136

135137
static const uint64_t mld_KeccakF_RoundConstants[MLD_KECCAK_NROUNDS] = {
136138
(uint64_t)0x0000000000000001ULL, (uint64_t)0x0000000000008082ULL,

mldsa/src/fips202/keccakf1600.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ __contract__(
4343
assigns(memory_slice(state, sizeof(uint64_t) * MLD_KECCAK_LANES))
4444
);
4545

46+
#if !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
4647
#define mld_keccakf1600x4_extract_bytes \
4748
MLD_NAMESPACE(keccakf1600x4_extract_bytes)
4849
MLD_INTERNAL_API
@@ -93,6 +94,7 @@ __contract__(
9394
requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
9495
assigns(memory_slice(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
9596
);
97+
#endif /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
9698

9799
#define mld_keccakf1600_permute MLD_NAMESPACE(keccakf1600_permute)
98100
MLD_INTERNAL_API

mldsa/src/fips202/native/aarch64/auto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "x1_scalar.h"
3838
#endif
3939

40+
#if !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
4041
/*
4142
* Keccak-f1600x2/x4
4243
*
@@ -68,4 +69,6 @@
6869

6970
#endif /* !__ARM_FEATURE_SHA3 */
7071

72+
#endif /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
73+
7174
#endif /* !MLD_FIPS202_NATIVE_AARCH64_AUTO_H */

mldsa/src/fips202/native/auto.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include "aarch64/auto.h"
1717
#endif
1818

19-
#if defined(MLD_SYS_X86_64) && defined(MLD_SYS_X86_64_AVX2)
19+
#if defined(MLD_SYS_X86_64) && defined(MLD_SYS_X86_64_AVX2) && \
20+
!defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
2021
#include "x86_64/xkcp.h"
2122
#endif
2223

0 commit comments

Comments
 (0)