Skip to content

Commit a1c6259

Browse files
authored
Merge pull request #161 from Frauschi/pkcs11_mldsa
Add ML-DSA support
2 parents 426f30c + 5ba32b1 commit a1c6259

17 files changed

Lines changed: 2187 additions & 49 deletions

.github/workflows/build-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
working-directory: ./wolfssl
3636
run: |
3737
./configure --enable-cryptocb --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt --enable-md5 \
38-
C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
38+
--enable-mldsa C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
3939
- name: wolfssl make install
4040
working-directory: ./wolfssl
4141
run: make

.github/workflows/clang-tidy.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,21 @@ on:
2929
jobs:
3030
clang-tidy:
3131
runs-on: ubuntu-latest
32-
32+
3333
strategy:
3434
fail-fast: false
3535
matrix:
3636
config:
3737
- name: "Standard Build"
3838
configure_flags: ""
39-
- name: "NSS Build"
39+
- name: "NSS Build"
4040
configure_flags: "--enable-nss"
4141
- name: "TPM Build"
4242
configure_flags: "--enable-tpm"
4343
- name: "NSS+TPM Build"
4444
configure_flags: "--enable-nss --enable-tpm"
45+
- name: "PKCS#11 V3.2 PQC Build"
46+
configure_flags: "--enable-pkcs11v32 --enable-mldsa"
4547

4648
steps:
4749
# Checkout wolfPKCS11
@@ -70,7 +72,7 @@ jobs:
7072
cd wolfssl
7173
./autogen.sh
7274
./configure --enable-cryptocb --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt --enable-md5 \
73-
C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
75+
--enable-mldsa C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
7476
make -j$(nproc)
7577
sudo make install
7678
sudo ldconfig

.github/workflows/cmake.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ jobs:
6161
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWOLFPKCS11_INSTALL:BOOL=yes -DWOLFPKCS11_DEBUG:BOOL=yes \
6262
-DWOLFPKCS11_AESKEYWRAP:BOOL=yes -DWOLFPKCS11_AESCTR:BOOL=yes -DWOLFPKCS11_AESCCM:BOOL=yes \
6363
-DWOLFPKCS11_AESECB:BOOL=yes -DWOLFPKCS11_AESCTS:BOOL=yes -DWOLFPKCS11_AESCMAC:BOOL=yes \
64-
-DWOLFPKCS11_PBKDF2:BOOL=yes -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/${CMAKE_INSTALL_LIBDIR}" \
64+
-DWOLFPKCS11_PBKDF2:BOOL=yes -DWOLFPKCS11_SHA3:BOOL=yes -DWOLFPKCS11_PKCS11_V3_0:BOOL=yes \
65+
-DWOLFPKCS11_PKCS11_V3_2:BOOL=yes -DWOLFPKCS11_MLDSA:BOOL=yes \
66+
-DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/${CMAKE_INSTALL_LIBDIR}" \
6567
..
6668
cmake --build .
6769
ctest -j $(nproc)

.github/workflows/sanitizer-tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ jobs:
1919
config:
2020
- name: "Standard Build"
2121
configure_flags: ""
22-
- name: "NSS Build"
22+
- name: "NSS Build"
2323
configure_flags: "--enable-nss"
2424
- name: "TPM Build"
2525
configure_flags: "--enable-tpm"
2626
- name: "NSS+TPM Build"
2727
configure_flags: "--enable-nss --enable-tpm"
28+
- name: "PKCS#11 V3.2 PQC Build"
29+
configure_flags: "--enable-pkcs11v32 --enable-mldsa"
2830

2931
steps:
3032
#pull wolfPKCS11
@@ -73,7 +75,7 @@ jobs:
7375
;;
7476
esac
7577
./configure --enable-cryptocb --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt --enable-md5 --enable-debug \
76-
C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
78+
--enable-mldsa C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
7779
- name: wolfssl make
7880
working-directory: ./wolfssl
7981
run: |

.github/workflows/scan-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
configure_flags: "--enable-tpm"
4545
- name: "NSS+TPM Build"
4646
configure_flags: "--enable-nss --enable-tpm"
47+
- name: "PKCS#11 V3.2 PQC Build"
48+
configure_flags: "--enable-pkcs11v32 --enable-mldsa"
4749

4850
steps:
4951
# Checkout wolfPKCS11
@@ -72,7 +74,7 @@ jobs:
7274
cd wolfssl
7375
./autogen.sh
7476
./configure --enable-cryptocb --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt --enable-md5 \
75-
C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
77+
--enable-mldsa C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT -DHAVE_AES_ECB -DHAVE_AES_KEYWRAP"
7678
make -j$(nproc)
7779
sudo make install
7880
sudo ldconfig

.github/workflows/unit-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ jobs:
102102
uses: ./.github/workflows/build-workflow.yml
103103
with:
104104
config: --enable-pkcs11v32 --disable-shared
105+
mldsa:
106+
uses: ./.github/workflows/build-workflow.yml
107+
with:
108+
config: --enable-mldsa
105109
debug:
106110
uses: ./.github/workflows/build-workflow.yml
107111
with:

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,24 @@ if(WOLFPKCS11_PKCS11_V3_2)
462462
endif()
463463

464464

465+
# ML-DSA
466+
add_option("WOLFPKCS11_MLDSA"
467+
"Enable wolfPKCS11 ML-DSA support (default: disabled)"
468+
"no" "yes;no"
469+
)
470+
471+
if(NOT WOLFPKCS11_SHA3)
472+
override_cache(WOLFPKCS11_MLDSA "no")
473+
endif()
474+
475+
if(WOLFPKCS11_MLDSA)
476+
if(NOT WOLFPKCS11_PKCS11_V3_2)
477+
message(FATAL_ERROR "ML-DSA requires PKCS#11 Version 3.2 support (enable WOLFPKCS11_PKCS11_V3_2)")
478+
endif()
479+
list(APPEND WOLFPKCS11_DEFINITIONS "-DWOLFPKCS11_MLDSA")
480+
endif()
481+
482+
465483
# If wolfpkcs11/options.h exists, delete it to avoid
466484
# a mixup with build/wolfpkcs11/options.h.
467485
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/wolfpkcs11/options.h")

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ configure step.
5454
WARNING: ECB (Electronic Code Book) mode AES is generally considered to be
5555
insecure. Please consider using a different mode of AES.
5656

57+
### Optional: PQC ML-DSA Support
58+
59+
To have ML-DSA support in wolfPKCS11, configure wolfSSL with ML-DSA (Dilithium)
60+
support enabled, either by adding `--enable-mldsa` to `./configure` or by
61+
setting `WOLFSSL_DILITHIUM` to `yes` in CMake.
62+
63+
As ML-DSA is a feature of PKCS#11 version 3.2, support for that is required,
64+
too. Hence, to enable all in wolfPKCS11, add `--enable-pkcs11v32 --enable-mldsa`
65+
during the configure step.
66+
5767
### Build options and defines
5868

5969
#### Define WOLFPKCS11_TPM_STORE
@@ -116,7 +126,8 @@ cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
116126
-DWOLFSSL_SHA=yes -DWOLFSSL_SHA224=yes -DWOLFSSL_SHA3=yes \
117127
-DWOLFSSL_SHA384=yes -DWOLFSSL_SHA512=yes \
118128
-DWOLFSSL_SP_MATH_ALL=yes -DWOLFSSL_PUBLIC_MP=yes \
119-
-DWOLFSSL_WC_RSA_DIRECT=yes -DCMAKE_BUILD_TYPE=Release \
129+
-DWOLFSSL_WC_RSA_DIRECT=yes -DWOLFSSL_DILITHIUM=yes \
130+
-DCMAKE_BUILD_TYPE=Release \
120131
..
121132
cmake --build .
122133
sudo cmake --install .
@@ -147,6 +158,8 @@ cmake -DWOLFPKCS11_DEBUG=yes \
147158
-DWOLFPKCS11_AESCTS=yes \
148159
-DWOLFPKCS11_AESCMAC=yes \
149160
-DWOLFPKCS11_PBKDF2=yes \
161+
-DWOLFPKCS11_PKCS11_V3_2=yes \
162+
-DWOLFPKCS11_MLDSA=yes \
150163
..
151164
cmake --build .
152165
ctest
@@ -194,6 +207,7 @@ cmake -DCMAKE_PREFIX_PATH=/path/to/wolfssl/install ..
194207
| `WOLFPKCS11_NSS` | `no` | NSS-specific modifications |
195208
| `WOLFPKCS11_PKCS11_V3_0` | `yes` | PKCS#11 v3.0 support |
196209
| `WOLFPKCS11_PKCS11_V3_2` | `no` | PKCS#11 v3.2 support |
210+
| `WOLFPKCS11_MLDSA` | `no`| ML-DSA support |
197211
| `WOLFPKCS11_EXAMPLES` | `yes` | Build examples |
198212
| `WOLFPKCS11_TESTS` | `yes` | Build and register tests |
199213
| `WOLFPKCS11_COVERAGE` | `no` | Code coverage support |

cmake/options.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ extern "C" {
9292
#cmakedefine WOLFSSL_SHA512
9393
#undef WOLFSSL_SHA3
9494
#cmakedefine WOLFSSL_SHA3
95+
#undef WOLFPKCS11_MLDSA
96+
#cmakedefine WOLFPKCS11_MLDSA
9597
#undef WOLFPKCS11_TPM
9698
#cmakedefine WOLFPKCS11_TPM
9799
#undef WOLFPKCS11_NSS

configure.ac

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,27 @@ then
516516
AM_CFLAGS="$AM_CFLAGS -DWOLFPKCS11_PKCS11_V3_2"
517517
fi
518518

519+
AC_ARG_ENABLE([mldsa],
520+
[AS_HELP_STRING([--enable-mldsa],[Enable ML-DSA (default: disabled)])],
521+
[ ENABLED_MLDSA=$enableval ],
522+
[ ENABLED_MLDSA=no ]
523+
)
524+
525+
if test "$ENABLED_SHA3" = "no"
526+
then
527+
echo "ML-DSA requires SHA-3 support (disabled), disabling ML-DSA"
528+
ENABLED_MLDSA=no
529+
fi
530+
531+
if test "$ENABLED_MLDSA" = "yes"
532+
then
533+
if test "$ENABLED_PKCS11V3_2" = "no"; then
534+
ENABLED_PKCS11V3_2=yes
535+
AM_CFLAGS="$AM_CFLAGS -DWOLFPKCS11_PKCS11_V3_2"
536+
fi
537+
AM_CFLAGS="$AM_CFLAGS -DWOLFPKCS11_MLDSA"
538+
fi
539+
519540

520541
AM_CONDITIONAL([BUILD_STATIC],[test "x$enable_shared" = "xno"])
521542

@@ -703,6 +724,7 @@ echo " * RSA-PSS: $ENABLED_RSAPSS"
703724
echo " * DH: $ENABLED_DH"
704725
echo " * ECC: $ENABLED_ECC"
705726
echo " * HKDF: $ENABLED_HKDF"
727+
echo " * ML-DSA: $ENABLED_MLDSA"
706728
echo " * NSS modifications: $ENABLED_NSS"
707729
echo " * Default token path: $WOLFPKCS11_DEFAULT_TOKEN_PATH"
708730
echo " * PKCS#11 Version 3.0: $ENABLED_PKCS11V3_0"

0 commit comments

Comments
 (0)