@@ -291,6 +291,37 @@ if((((ARCH STREQUAL "x86_64") AND NOT MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) OR
291
291
${S2N_BIGNUM_DIR} /generic/bignum_copy_row_from_table_16.S
292
292
${S2N_BIGNUM_DIR} /generic/bignum_copy_row_from_table_32.S
293
293
)
294
+
295
+ #
296
+ # Keccak assembly from s2n-bignum/mlkem-native
297
+ #
298
+
299
+ # Check if assembler supports SHA3 extension
300
+ include (CheckCSourceCompiles )
301
+ set (CMAKE_REQUIRED_FLAGS_BACKUP "${CMAKE_REQUIRED_FLAGS} " )
302
+ set (CMAKE_REQUIRED_FLAGS "-march=armv8.4-a+sha3" )
303
+ check_c_source_compiles ("
304
+ int main(void) {
305
+ __asm__(\" eor3 v0.16b, v1.16b, v2.16b, v3.16b\" );
306
+ __asm__(\" bcax v0.16b, v1.16b, v2.16b, v3.16b\" );
307
+ __asm__(\" rax1 v0.2d, v1.2d, v2.2d \" );
308
+ __asm__(\" xar v0.2d, v1.2d, v2.2d, #0x2a \" );
309
+ return 0;
310
+ }
311
+ " MY_ASSEMBLER_SUPPORTS_NEON_SHA3_EXTENSION )
312
+ set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_BACKUP} " )
313
+
314
+ # Scalar Keccak-x1 assembly from s2n-bignum/mlkem-native
315
+ list (APPEND BCM_ASM_SOURCES
316
+ ${S2N_BIGNUM_DIR} /sha3/sha3_keccak_f1600.S
317
+ )
318
+
319
+ # SIMD Keccak-x1 assembly from s2n-bignum/mlkem-native, using SHA3 extension
320
+ if (MY_ASSEMBLER_SUPPORTS_NEON_SHA3_EXTENSION )
321
+ list (APPEND BCM_ASM_SOURCES ${S2N_BIGNUM_DIR} /sha3/sha3_keccak_f1600_alt.S )
322
+ set_source_files_properties (${S2N_BIGNUM_DIR} /sha3/sha3_keccak_f1600_alt.S
323
+ PROPERTIES COMPILE_FLAGS "-march=armv8.4-a+sha3" )
324
+ endif ()
294
325
endif ()
295
326
296
327
endif ()
0 commit comments