Skip to content

Commit 9fe3b19

Browse files
authored
Merge pull request #9605 from Frauschi/build_system_fixes
Build systems improvements
2 parents 7258697 + 99bde32 commit 9fe3b19

4 files changed

Lines changed: 77 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,11 @@ add_option(WOLFSSL_MLKEM
603603
"Enable the wolfSSL PQ ML-KEM library (default: disabled)"
604604
"no" "yes;no")
605605

606+
# Dilithium
607+
add_option(WOLFSSL_DILITHIUM
608+
"Enable the wolfSSL PQ Dilithium (ML-DSA) implementation (default: disabled)"
609+
"no" "yes;no")
610+
606611
# LMS
607612
add_option(WOLFSSL_LMS
608613
"Enable the PQ LMS Stateful Hash-based Signature Scheme (default: disabled)"
@@ -700,6 +705,22 @@ if (WOLFSSL_EXPERIMENTAL)
700705
message(STATUS "Looking for WOLFSSL_LMS - not found")
701706
endif()
702707

708+
# Checking for experimental feature: Dilithium
709+
message(STATUS "Looking for WOLFSSL_DILITHIUM")
710+
if (WOLFSSL_DILITHIUM)
711+
set(WOLFSSL_FOUND_EXPERIMENTAL_FEATURE 1)
712+
713+
message(STATUS "Automatically set related requirements for Dilithium:")
714+
set_wolfssl_definitions("HAVE_DILITHIUM" RESUlT)
715+
set_wolfssl_definitions("WOLFSSL_WC_DILITHIUM" RESUlT)
716+
set_wolfssl_definitions("WOLFSSL_SHA3" RESUlT)
717+
set_wolfssl_definitions("WOLFSSL_SHAKE128" RESUlT)
718+
set_wolfssl_definitions("WOLFSSL_SHAKE256" RESUlT)
719+
message(STATUS "Looking for WOLFSSL_DILITHIUM - found")
720+
else()
721+
message(STATUS "Looking for WOLFSSL_DILITHIUM - not found")
722+
endif()
723+
703724
# Other experimental feature detection can be added here...
704725

705726
# Were any experimental features found? Display a message.
@@ -713,7 +734,9 @@ if (WOLFSSL_EXPERIMENTAL)
713734
if(WOLFSSL_OQS AND WOLFSSL_MLKEM)
714735
message(FATAL_ERROR "Error: cannot enable both WOLFSSL_OQS and WOLFSSL_MLKEM at the same time.")
715736
endif()
716-
737+
if(WOLFSSL_OQS AND WOLFSSL_DILITHIUM)
738+
message(FATAL_ERROR "Error: cannot enable both WOLFSSL_OQS and WOLFSSL_DILITHIUM at the same time.")
739+
endif()
717740
else()
718741
# Experimental mode not enabled, but were any experimental features enabled? Error out if so:
719742
message(STATUS "Looking for WOLFSSL_EXPERIMENTAL - not found")
@@ -723,6 +746,9 @@ else()
723746
if(WOLFSSL_MLKEM)
724747
message(FATAL_ERROR "Error: WOLFSSL_MLKEM requires WOLFSSL_EXPERIMENTAL at this time.")
725748
endif()
749+
if(WOLFSSL_DILITHIUM)
750+
message(FATAL_ERROR "Error: WOLFSSL_DILITHIUM requires WOLFSSL_EXPERIMENTAL at this time.")
751+
endif()
726752
endif()
727753

728754
# LMS
@@ -1866,6 +1892,15 @@ if(NOT WOLFSSL_PKCS12)
18661892
list(APPEND WOLFSSL_DEFINITIONS "-DNO_PKCS12")
18671893
endif()
18681894

1895+
# PKCS#11
1896+
add_option("WOLFSSL_PKCS11"
1897+
"Enable PKCS#11 (default: disabled)"
1898+
"no" "yes;no")
1899+
1900+
if(WOLFSSL_PKCS11 AND NOT WIN32)
1901+
list(APPEND WOLFSSL_LINK_LIBS ${CMAKE_DL_LIBS})
1902+
endif()
1903+
18691904

18701905
# PWDBASED has to come after certservice since we want it on w/o explicit on
18711906
# PWDBASED
@@ -1964,7 +1999,6 @@ add_option("WOLFSSL_CRYPT_TESTS_HELP"
19641999
"no" "yes;no")
19652000

19662001
# TODO: - LIBZ
1967-
# - PKCS#11
19682002
# - Cavium
19692003
# - Cavium V
19702004
# - Cavium Octeon

cmake/functions.cmake

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ function(generate_build_flags)
201201
if(WOLFSSL_MLKEM OR WOLFSSL_USER_SETTINGS)
202202
set(BUILD_WC_MLKEM "yes" PARENT_SCOPE)
203203
endif()
204+
if(WOLFSSL_DILITHIUM OR WOLFSSL_USER_SETTINGS)
205+
set(BUILD_DILITHIUM "yes" PARENT_SCOPE)
206+
endif()
204207
if(WOLFSSL_OQS OR WOLFSSL_USER_SETTINGS)
205208
set(BUILD_FALCON "yes" PARENT_SCOPE)
206209
set(BUILD_SPHINCS "yes" PARENT_SCOPE)
@@ -389,6 +392,10 @@ function(generate_lib_src_list LIB_SOURCES)
389392

390393
if(BUILD_INTELASM)
391394
list(APPEND LIB_SOURCES wolfcrypt/src/aes_gcm_asm.S)
395+
list(APPEND LIB_SOURCES wolfcrypt/src/sha3_asm.S)
396+
elseif(BUILD_ARMASM)
397+
list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha3-asm_c.c)
398+
list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha3-asm.S)
392399
endif()
393400
endif()
394401

@@ -563,11 +570,13 @@ function(generate_lib_src_list LIB_SOURCES)
563570
if(BUILD_ARMASM_INLINE)
564571
list(APPEND LIB_SOURCES
565572
wolfcrypt/src/port/arm/armv8-sha256.c
566-
wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c)
573+
wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c
574+
wolfcrypt/src/port/arm/armv8-sha256-asm_c.c)
567575
else()
568576
list(APPEND LIB_SOURCES
569-
wolfcrypt/src/port/arm/armv8-sha256-asm.S
570-
wolfcrypt/src/port/arm/armv8-32-sha256-asm.S)
577+
wolfcrypt/src/port/arm/armv8-sha256.c
578+
wolfcrypt/src/port/arm/armv8-32-sha256-asm.S
579+
wolfcrypt/src/port/arm/armv8-sha256-asm.S)
571580
endif()
572581
if(BUILD_ARMASM_INLINE AND BUILD_ARM_THUMB)
573582
list(APPEND LIB_SOURCES
@@ -990,6 +999,10 @@ function(generate_lib_src_list LIB_SOURCES)
990999

9911000
if(BUILD_DILITHIUM)
9921001
list(APPEND LIB_SOURCES wolfcrypt/src/dilithium.c)
1002+
1003+
if(BUILD_INTELASM)
1004+
list(APPEND LIB_SOURCES wolfcrypt/src/wc_mldsa_asm.S)
1005+
endif()
9931006
endif()
9941007

9951008
if(BUILD_WC_MLKEM)

cmake/options.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ extern "C" {
9696
#cmakedefine HAVE_CURVE448
9797
#undef HAVE_DH_DEFAULT_PARAMS
9898
#cmakedefine HAVE_DH_DEFAULT_PARAMS
99+
#undef HAVE_DILITHIUM
100+
#cmakedefine HAVE_DILITHIUM
99101
#undef HAVE_ECC
100102
#cmakedefine HAVE_ECC
101103
#undef HAVE_ECH
@@ -354,6 +356,8 @@ extern "C" {
354356
#cmakedefine WOLFSSL_TLS13
355357
#undef WOLFSSL_USE_ALIGN
356358
#cmakedefine WOLFSSL_USE_ALIGN
359+
#undef WOLFSSL_USER_SETTINGS
360+
#cmakedefine WOLFSSL_USER_SETTINGS
357361
#undef WOLFSSL_USER_SETTINGS_ASM
358362
#cmakedefine WOLFSSL_USER_SETTINGS_ASM
359363
#undef WOLFSSL_W64_WRAPPER
@@ -370,6 +374,8 @@ extern "C" {
370374
#cmakedefine WOLFSSL_HAVE_MLKEM
371375
#undef WOLFSSL_WC_MLKEM
372376
#cmakedefine WOLFSSL_WC_MLKEM
377+
#undef WOLFSSL_WC_DILITHIUM
378+
#cmakedefine WOLFSSL_WC_DILITHIUM
373379
#undef NO_WOLFSSL_STUB
374380
#cmakedefine NO_WOLFSSL_STUB
375381
#undef HAVE_ECC_SECPR2

wolfcrypt/src/aes_asm.S

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@
2727
* by Intel Mobility Group, Israel Development Center, Israel Shay Gueron
2828
*/
2929

30+
#ifdef WOLFSSL_USER_SETTINGS
31+
#ifdef WOLFSSL_USER_SETTINGS_ASM
32+
/*
33+
* user_settings_asm.h is a file generated by the script user_settings_asm.sh.
34+
* The script takes in a user_settings.h and produces user_settings_asm.h, which
35+
* is a stripped down version of user_settings.h containing only preprocessor
36+
* directives. This makes the header safe to include in assembly (.S) files.
37+
*/
38+
#include "user_settings_asm.h"
39+
#else
40+
/*
41+
* Note: if user_settings.h contains any C code (e.g. a typedef or function
42+
* prototype), including it here in an assembly (.S) file will cause an
43+
* assembler failure. See user_settings_asm.h above.
44+
*/
45+
#include "user_settings.h"
46+
#endif /* WOLFSSL_USER_SETTINGS_ASM */
47+
#endif /* WOLFSSL_USER_SETTINGS */
48+
3049
#ifdef WOLFSSL_X86_64_BUILD
3150

3251
/*

0 commit comments

Comments
 (0)