1+
2+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
3+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra" )
4+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic" )
5+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes" )
6+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls" )
7+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow" )
8+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith" )
9+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2" )
10+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mbmi2" )
11+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mpopcnt" )
12+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native" )
13+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=native" )
14+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3" )
15+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer" )
16+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -z noexecstack" )
17+
18+ set (NISTFLAGS "${NISTFLAGS} "
19+ -Wno-unused-result
20+ -mavx2
21+ -mbmi2
22+ -mpopcnt
23+ -march=native
24+ -mtune=native
25+ -O3
26+ -fomit-frame-pointer
27+ )
28+
29+ set (securitylevel 2 3 4)
30+
31+
32+ # build fips202 shared library
33+ set (SRCS fips202.c fips202x4.c keccak4x/KeccakP-1600-times4-SIMD256.c symmetric-shake.c)
34+
35+ foreach (level IN LISTS securitylevel)
36+ MATH (EXPR NBITS "256 * ${level} " OUTPUT_FORMAT DECIMAL )
37+ set (name pqccrystals_fips202x4_avx2_${NBITS} )
38+
39+ add_library (${name} SHARED ${SRCS} )
40+ target_compile_definitions (${name} PUBLIC KYBER_K=${level} )
41+ endforeach ()
42+
43+ set (SRCS
44+ kem.c
45+ indcpa.c
46+ polyvec.c
47+ poly.c
48+ shuffle.S
49+ fq.S
50+ ntt.S
51+ invntt.S
52+ basemul.S
53+ consts.c
54+ rejsample.c
55+ cbd.c
56+ verify.c
57+ )
58+
59+ # build algorithm shared library
60+ foreach (level IN LISTS securitylevel)
61+ MATH (EXPR NBITS "256 * ${level} " OUTPUT_FORMAT DECIMAL )
62+ set (name pqccrystals_kyber${NBITS} _avx2)
63+
64+ add_library (${name} SHARED ${SRCS} )
65+ target_compile_definitions (${name} PUBLIC KYBER_K=${level} )
66+ target_link_libraries (${name} pqccrystals_fips202x4_avx2_${NBITS} )
67+ target_include_directories (${name} PRIVATE . )
68+ endforeach ()
69+
70+ # build test_kyber
71+ foreach (level IN LISTS securitylevel)
72+ MATH (EXPR NBITS "256 * ${level} " OUTPUT_FORMAT DECIMAL )
73+
74+ add_executable (test_kyber${NBITS}_avx2 test /test_kyber.c )
75+ target_link_libraries (test_kyber${NBITS}_avx2
76+ pqccrystals_kyber${NBITS}_avx2
77+ randombytes )
78+ endforeach ()
79+
80+ # build test_vector
81+ foreach (level IN LISTS securitylevel)
82+ MATH (EXPR NBITS "256 * ${level} " OUTPUT_FORMAT DECIMAL )
83+
84+ add_executable (test_vectors${NBITS}_avx2 test /test_vectors.c )
85+ target_link_libraries (test_vectors${NBITS}_avx2
86+ pqccrystals_kyber${NBITS}_avx2 )
87+ endforeach ()
88+
89+ # build test_speed
90+ foreach (level IN LISTS securitylevel)
91+ MATH (EXPR NBITS "256 * ${level} " OUTPUT_FORMAT DECIMAL )
92+
93+ add_executable (test_speed${NBITS}_avx2
94+ test /cpucycles.c
95+ test /speed_print.c
96+ test /test_speed.c
97+ )
98+ target_link_libraries (test_speed${NBITS}_avx2
99+ pqccrystals_kyber${NBITS}_avx2
100+ randombytes )
101+ endforeach ()
0 commit comments