Skip to content

Commit fd467dc

Browse files
committed
Added support for ML-DSA in softhsm2-util
1 parent 1b61bb0 commit fd467dc

18 files changed

Lines changed: 628 additions & 52 deletions

.github/workflows/ci.yml

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
run: |
143143
make check || (find . -name test-suite.log -exec cat {} \; && false)
144144
145-
windows:
145+
windows_botan_ossl11:
146146
name: Windows (${{ matrix.arch }}, ${{ matrix.backend }})
147147
runs-on: windows-2022
148148
strategy:
@@ -156,11 +156,11 @@ jobs:
156156
- arch: x64
157157
backend: botan
158158
target-platform: x64
159-
build-options: -DENABLE_ECC=OFF -DENABLE_EDDSA=OFF
159+
build-options: -DENABLE_ECC=OFF -DENABLE_EDDSA=OFF
160160
- arch: x86
161161
backend: openssl
162162
target-platform: Win32
163-
build-options: -DENABLE_ECC=OFF -DENABLE_EDDSA=OFF
163+
build-options: -DENABLE_ECC=OFF -DENABLE_EDDSA=OFF
164164
steps:
165165
- uses: actions/checkout@v4
166166
- uses: ilammy/msvc-dev-cmd@v1
@@ -188,3 +188,78 @@ jobs:
188188
CTEST_OUTPUT_ON_FAILURE: 1
189189
run: |
190190
cmake --build build --target RUN_TESTS
191+
windows_ossl30:
192+
name: Windows (${{ matrix.arch }}, OpenSSL 3.4)
193+
runs-on: windows-2022
194+
strategy:
195+
fail-fast: false
196+
matrix:
197+
include:
198+
- arch: x64
199+
target-platform: x64
200+
build-options:
201+
- arch: x86
202+
target-platform: Win32
203+
build-options: -DENABLE_ECC=OFF -DENABLE_EDDSA=OFF
204+
steps:
205+
- uses: actions/checkout@v4
206+
- uses: ilammy/msvc-dev-cmd@v1
207+
with:
208+
arch: ${{ matrix.arch }}
209+
- name: Create vcpkg.json
210+
run: >
211+
echo '{ "dependencies": [ "openssl", "cppunit" ],
212+
"overrides": [ { "name": "openssl", "version-string": "3.4.1" } ],
213+
"builtin-baseline": "38d1652f152d36481f2f4e8a85c0f1e14f3769f7" }' > vcpkg.json
214+
- uses: seanmiddleditch/vcpkg-action@master
215+
id: vcpkg
216+
with:
217+
manifest-dir: ${{ github.workspace }}
218+
triplet: ${{ matrix.arch }}-windows
219+
token: ${{ github.token }}
220+
- name: Build
221+
run: |
222+
mkdir build
223+
cmake -B build ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -A ${{ matrix.target-platform }} -DWITH_CRYPTO_BACKEND=openssl ${{ matrix.build-options }} -DDISABLE_NON_PAGED_MEMORY=ON -DBUILD_TESTS=ON
224+
cmake --build build
225+
- name: Test
226+
env:
227+
CTEST_OUTPUT_ON_FAILURE: 1
228+
run: |
229+
cmake --build build --target RUN_TESTS
230+
windows_ossl35:
231+
name: Windows (${{ matrix.arch }}, OpenSSL 3.5)
232+
runs-on: windows-2022
233+
strategy:
234+
fail-fast: false
235+
matrix:
236+
include:
237+
- arch: x64
238+
target-platform: x64
239+
build-options: -DENABLE_MLDSA=ON
240+
steps:
241+
- uses: actions/checkout@v4
242+
- uses: ilammy/msvc-dev-cmd@v1
243+
with:
244+
arch: ${{ matrix.arch }}
245+
- name: Create vcpkg.json
246+
run: >
247+
echo '{ "dependencies": [ "openssl", "cppunit" ],
248+
"overrides": [ { "name": "openssl", "version-string": "3.5.4" } ],
249+
"builtin-baseline": "38d1652f152d36481f2f4e8a85c0f1e14f3769f7" }' > vcpkg.json
250+
- uses: seanmiddleditch/vcpkg-action@master
251+
id: vcpkg
252+
with:
253+
manifest-dir: ${{ github.workspace }}
254+
triplet: ${{ matrix.arch }}-windows
255+
token: ${{ github.token }}
256+
- name: Build
257+
run: |
258+
mkdir build
259+
cmake -B build ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -A ${{ matrix.target-platform }} -DWITH_CRYPTO_BACKEND=openssl ${{ matrix.build-options }} -DDISABLE_NON_PAGED_MEMORY=ON -DBUILD_TESTS=ON
260+
cmake --build build
261+
- name: Test
262+
env:
263+
CTEST_OUTPUT_ON_FAILURE: 1
264+
run: |
265+
cmake --build build --target RUN_TESTS

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ src/lib/test/softhsm2-reset-on-fork.conf
8181
src/lib/test/softhsm2-mech.conf
8282
src/lib/test/softhsm2-negative-mech.conf
8383
src/lib/test/softhsm2.conf
84-
src/lib/test/tokens/64d6c3fe-1575-1736-1d26-5ccb28440ea7/
85-
src/lib/test/tokens/dummy
84+
src/lib/test/tokens
85+
src/bin/util/test/tokens

cmake/modules/CompilerOptions.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,27 @@ elseif(WITH_CRYPTO_BACKEND STREQUAL "openssl")
370370
message(STATUS "OpenSSL: Support for EDDSA is disabled")
371371
endif(ENABLE_EDDSA)
372372

373+
# acx_openssl_mldsa.m4
374+
if(ENABLE_MLDSA)
375+
# ML-DSA
376+
set(testfile ${CMAKE_SOURCE_DIR}/cmake/modules/tests/test_openssl_mldsa.c)
377+
try_run(RUN_MLDSA COMPILE_RESULT
378+
"${CMAKE_BINARY_DIR}/prebuild_santity_tests" ${testfile}
379+
LINK_LIBRARIES ${CRYPTO_LIBS}
380+
CMAKE_FLAGS
381+
"-DINCLUDE_DIRECTORIES=${CRYPTO_INCLUDES}"
382+
)
383+
if(COMPILE_RESULT AND RUN_MLDSA EQUAL 0)
384+
set(WITH_ML_DSA 1)
385+
message(STATUS "OpenSSL: Found ML-DSA")
386+
else()
387+
set(error_msg "OpenSSL: Cannot find ML-DSA! OpenSSL library has no ML-DSA support!")
388+
message(FATAL_ERROR ${error_msg})
389+
endif()
390+
else(ENABLE_MLDSA)
391+
message(STATUS "OpenSSL: Support for ML-DSA is disabled")
392+
endif(ENABLE_MLDSA)
393+
373394
# acx_openssl_gost.m4
374395
if(ENABLE_GOST)
375396
set(testfile ${CMAKE_SOURCE_DIR}/cmake/modules/tests/test_openssl_gost.c)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <openssl/evp.h>
2+
#include <openssl/objects.h>
3+
int main()
4+
{
5+
EVP_PKEY_CTX *ctx;
6+
ctx = EVP_PKEY_CTX_new_from_name(NULL, "ML-DSA-44", NULL);
7+
8+
if (ctx == NULL)
9+
return 1;
10+
return 0;
11+
}

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ AC_CONFIG_FILES([
232232
src/bin/keyconv/Makefile
233233
src/bin/migrate/Makefile
234234
src/bin/util/Makefile
235+
src/bin/util/test/Makefile
235236
])
236237

237238
AC_OUTPUT

src/bin/util/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ install(TARGETS ${PROJECT_NAME}
4343
install(FILES ${PROJECT_NAME}.1
4444
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
4545
)
46+
47+
if(BUILD_TESTS)
48+
add_subdirectory(test)
49+
endif(BUILD_TESTS)

src/bin/util/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ if WITH_BOTAN
3636
softhsm2_util_SOURCES += softhsm2-util-botan.cpp
3737
endif
3838

39+
SUBDIRS = test
40+
3941
EXTRA_DIST = $(srcdir)/CMakeLists.txt \
4042
$(srcdir)/*.h \
4143
$(srcdir)/*.cpp

0 commit comments

Comments
 (0)