Skip to content

Commit e287379

Browse files
authored
Merge branch 'softhsm:develop' into develop
2 parents a254964 + 4be49e3 commit e287379

File tree

103 files changed

+2703
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2703
-416
lines changed

.appveyor.yml

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,42 @@ init:
4141
$env:RELEASE_DIR=Join-Path $env:BUILD_DIR "SoftHSMv2-$env:ENV_PLATFORM"
4242
4343
$env:CONFIGURE_OPTIONS = "$env:CONFIGURE_OPTIONS with-crypto-backend=$env:CRYPTO_BACKEND with-$env:CRYPTO_BACKEND=$env:CRYPTO_PACKAGE_PATH\ with-cppunit=$env:CPPUNIT_PATH\"
44+
cache:
45+
- C:/Tools/vcpkg/installed/
4446
environment:
47+
APPVEYOR_SAVE_CACHE_ON_ERROR: true
4548
matrix:
46-
- CRYPTO_BACKEND: botan
47-
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=botan
4849
- CRYPTO_BACKEND: openssl
4950
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=openssl
51+
DB_BACKEND: OFF
52+
- CRYPTO_BACKEND: openssl
53+
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=openssl
54+
DB_BACKEND: ON
55+
- CRYPTO_BACKEND: botan
56+
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=botan
57+
DB_BACKEND: OFF
5058
install:
59+
# Update vcpkg
60+
- cd c:\tools\vcpkg
61+
- cmd: git fetch
62+
- cmd: bootstrap-vcpkg.bat
63+
- cmd: vcpkg update
64+
- cmd: vcpkg upgrade --no-dry-run
5165
- cmd: vcpkg install sqlite3:x86-windows
66+
- cmd: vcpkg install openssl-windows:x86-windows
5267
- cmd: vcpkg install openssl-windows:x64-windows
5368
- cmd: vcpkg install botan:x86-windows
5469
- cmd: vcpkg install cppunit:x86-windows
55-
- cmd: vcpkg install getopt-win32:x86-windows
56-
build_script:
5770
- cmd: vcpkg integrate install
58-
- cmd: cmake -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DWITH_CRYPTO_BACKEND=%CRYPTO_BACKEND% -DBUILD_TESTS=OFF -DDISABLE_NON_PAGED_MEMORY=ON -DENABLE_GOST=OFF .
59-
- cmd: msbuild softhsm2.sln /p:Configuration="Release" /p:Platform="Win32" /p:PlatformToolset=v140 /target:Build
71+
build_script:
72+
- cmd: if exist "C:\projects\softhsmv2\build" rmdir /s /q C:\projects\softhsmv2\build
73+
- cmd: mkdir C:\projects\softhsmv2\build
74+
- cmd: cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=C:\Tools\vcpkg\scripts\buildsystems\vcpkg.cmake -DWITH_OBJECTSTORE_BACKEND_DB=%DB_BACKEND% -DWITH_CRYPTO_BACKEND=%CRYPTO_BACKEND% -DBUILD_TESTS=ON -DDISABLE_NON_PAGED_MEMORY=ON -DENABLE_GOST=OFF
75+
- cmd: cmake -Bbuild --build . --config RelWithDebInfo
76+
- cmd: ctest -Bbuild -C RelWithDebInfo --progress --verbose
77+
- cmd: cmake -Bbuild -DCMAKE_INSTALL_PREFIX=build/SoftHSMv2-$(Platform) -DCMAKE_INSTALL_CONFIG_NAME=RelWithDebInfo -P cmake_install.cmake
6078
- cmd: IF "%ENV_PLATFORM%"=="x86" ( CD win32\Release ) ELSE ( CD win32\x64\Release)
61-
- cmd: cryptotest.exe
62-
- cmd: datamgrtest.exe
63-
- cmd: handlemgrtest.exe
64-
- cmd: objstoretest.exe
65-
- cmd: p11test.exe
66-
- cmd: sessionmgrtest.exe
67-
- cmd: slotmgrtest.exe
68-
test: off
79+
test: on
6980
artifacts:
7081
- path: build/SoftHSMv2-$(Platform)
7182
name: SoftHSMv2-$(PACKAGE_VERSION_NAME)-$(Platform)

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @softhsm/core

.github/workflows/ci.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- master
8+
pull_request:
9+
10+
jobs:
11+
linux:
12+
name: Linux (${{ matrix.backend }})
13+
runs-on: ubuntu-20.04 # for OpenSSL 1.1.1
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- backend: openssl
19+
- backend: botan
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Prepare
23+
run: |
24+
sudo apt update -qq
25+
sudo apt install libcppunit-dev libbotan-2-dev p11-kit
26+
- name: Build
27+
env:
28+
CXXFLAGS: -Werror -DBOTAN_NO_DEPRECATED_WARNINGS
29+
run: |
30+
./autogen.sh
31+
./configure --with-crypto-backend=${{ matrix.backend }}
32+
make
33+
- name: Test
34+
run: |
35+
make check || (find . -name test-suite.log -exec cat {} \; && false)
36+
37+
macos:
38+
name: macOS (${{ matrix.backend }})
39+
runs-on: macos-14
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
- backend: openssl
45+
extra-options: --with-openssl=$(brew --prefix [email protected])
46+
- backend: botan
47+
extra-options: --with-botan=$(brew --prefix botan@2)
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Prepare
51+
run: |
52+
brew install automake libtool cppunit botan@2
53+
- name: Build
54+
env:
55+
CXXFLAGS: -Werror -DBOTAN_NO_DEPRECATED_WARNINGS
56+
run: |
57+
./autogen.sh
58+
./configure --with-crypto-backend=${{ matrix.backend }} ${{ matrix.extra-options }}
59+
make
60+
- name: Test
61+
run: |
62+
make check || (find . -name test-suite.log -exec cat {} \; && false)
63+
64+
windows:
65+
name: Windows (${{ matrix.arch }}, ${{ matrix.backend }})
66+
runs-on: windows-2022
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
include:
71+
- arch: x64
72+
backend: openssl
73+
target-platform: x64
74+
build-options:
75+
- arch: x64
76+
backend: botan
77+
target-platform: x64
78+
build-options: -DENABLE_ECC=OFF -DENABLE_EDDSA=OFF
79+
- arch: x86
80+
backend: openssl
81+
target-platform: Win32
82+
build-options: -DENABLE_ECC=OFF -DENABLE_EDDSA=OFF
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: ilammy/msvc-dev-cmd@v1
86+
with:
87+
arch: ${{ matrix.arch }}
88+
- name: Create vcpkg.json
89+
run: >
90+
echo '{ "dependencies": [ "openssl", "botan", "cppunit" ],
91+
"overrides": [ { "name": "openssl", "version-string": "1.1.1n" },
92+
{ "name": "botan", "version-string": "2.19.3" } ],
93+
"builtin-baseline": "38d1652f152d36481f2f4e8a85c0f1e14f3769f7" }' > vcpkg.json
94+
- uses: seanmiddleditch/vcpkg-action@master
95+
id: vcpkg
96+
with:
97+
manifest-dir: ${{ github.workspace }}
98+
triplet: ${{ matrix.arch }}-windows
99+
token: ${{ github.token }}
100+
- name: Build
101+
run: |
102+
mkdir build
103+
cmake -B build ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -A ${{ matrix.target-platform }} -DWITH_CRYPTO_BACKEND=${{ matrix.backend }} ${{ matrix.build-options }} -DDISABLE_NON_PAGED_MEMORY=ON -DBUILD_TESTS=ON
104+
cmake --build build
105+
- name: Test
106+
env:
107+
CTEST_OUTPUT_ON_FAILURE: 1
108+
run: |
109+
cmake --build build --target RUN_TESTS

CMAKE-WIN-NOTES.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Building SoftHSMv2 for Windows
2+
3+
This document describes process of building both 32-bit and 64-bit versions of SoftHSMv2.
4+
5+
## Required software
6+
7+
- [Visual Studio](https://visualstudio.microsoft.com/vs/community/) (Community)
8+
- [C/C++ dependency manager from Microsoft](https://vcpkg.io/)
9+
- [CMake](https://cmake.org/)
10+
11+
## Prepare working directories
12+
13+
set VCPKG_HOME=C:\Projects\vcpkg
14+
set SOFTHSM_HOME=C:\Projects\SoftHSMv2
15+
git clone https://github.com/opendnssec/SoftHSMv2.git %SOFTHSM_HOME%
16+
git clone https://github.com/Microsoft/vcpkg.git %VCPKG_HOME%
17+
18+
## Build dependencies
19+
20+
cd %VCPKG_HOME%
21+
bootstrap-vcpkg.bat
22+
git fetch
23+
git checkout 2021.05.12
24+
25+
vcpkg install cppunit:x86-windows
26+
vcpkg install cppunit:x86-windows-static
27+
vcpkg install openssl-windows:x86-windows
28+
vcpkg install botan:x86-windows
29+
vcpkg install sqlite3:x86-windows
30+
31+
vcpkg install cppunit:x64-windows
32+
vcpkg install cppunit:x64-windows-static
33+
vcpkg install openssl-windows:x64-windows
34+
vcpkg install botan:x64-windows
35+
vcpkg install sqlite3:x64-windows
36+
37+
vcpkg integrate install
38+
39+
## Configure SoftHSMv2
40+
41+
Build can be configured using the following commands:
42+
43+
mkdir %SOFTHSM_HOME%\tmp32
44+
cd %SOFTHSM_HOME%\tmp32
45+
cmake .. -G "Visual Studio 15 2017" -A Win32 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_HOME%\scripts\buildsystems\vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%SOFTHSM_HOME%\out32 -DBUILD_TESTS=ON -DWITH_CRYPTO_BACKEND=openssl -DWITH_OBJECTSTORE_BACKEND_DB=OFF
46+
47+
mkdir %SOFTHSM_HOME%\tmp64
48+
cd %SOFTHSM_HOME%\tmp64
49+
cmake .. -G "Visual Studio 15 2017" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_HOME%\scripts\buildsystems\vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%SOFTHSM_HOME%\out64 -DBUILD_TESTS=ON -DWITH_CRYPTO_BACKEND=botan -DWITH_OBJECTSTORE_BACKEND_DB=ON
50+
51+
Some options (more can be found in CMakeLists.txt):
52+
53+
-DBUILD_TESTS=ON Compile tests along with libraries
54+
-DENABLE_EDDSA=ON Enable support for EDDSA
55+
-DWITH_MIGRATE=ON Build migration tool
56+
-DWITH_CRYPTO_BACKEND= Select crypto backend (openssl|botan)
57+
-DDISABLE_NON_PAGED_MEMORY=ON Disable non-paged memory for secure storage
58+
-DWITH_OBJECTSTORE_BACKEND_DB=ON Enable sqlite3 data storage
59+
60+
## Compile
61+
62+
Compile the source code using the following command:
63+
64+
cmake --build . --config RelWithDebInfo
65+
66+
## Test
67+
68+
ctest -C RelWithDebInfo --output-on-failure --progress --verbose
69+
70+
## Install
71+
72+
Install the library using the follow command:
73+
74+
cmake -DCMAKE_INSTALL_CONFIG_NAME=RelWithDebInfo -P cmake_install.cmake

CMakeLists.txt

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
2-
1+
cmake_minimum_required(VERSION 3.16)
32
project(softhsm2 C CXX)
43

54
# Build Options
@@ -8,8 +7,8 @@ option(DISABLE_NON_PAGED_MEMORY "Disable non-paged memory for secure storage" OF
87
option(DISABLE_VISIBILITY "Disables and unsets -fvisibility=hidden" OFF)
98
option(ENABLE_64bit "Enable 64-bit compiling" OFF)
109
option(ENABLE_ECC "Enable support for ECC" ON)
11-
option(ENABLE_EDDSA "Enable support for EDDSA" OFF)
12-
option(ENABLE_GOST "Enable support for GOST" ON)
10+
option(ENABLE_EDDSA "Enable support for EDDSA" ON)
11+
option(ENABLE_GOST "Enable support for GOST" OFF)
1312
option(ENABLE_FIPS "Enable support for FIPS 140-2 mode" OFF)
1413
option(ENABLE_P11_KIT "Enable p11-kit integration" ON)
1514
option(ENABLE_PEDANTIC "Enable pedantic compile mode" OFF)
@@ -51,7 +50,7 @@ set(DEFAULT_LOG_LEVEL "INFO"
5150
CACHE STRING "The default log level")
5251
set(DEFAULT_OBJECTSTORE_BACKEND "file"
5352
CACHE STRING "Default storage backend for token objects")
54-
set(DEFAULT_PKCS11_LIB "${CMAKE_INSTALL_FULL_LIBDIR}/softhsm/libsofthsm2.so"
53+
set(DEFAULT_PKCS11_LIB "${CMAKE_INSTALL_FULL_LIBDIR}/softhsm/libsofthsm2${CMAKE_SHARED_LIBRARY_SUFFIX}"
5554
CACHE STRING "The default PKCS#11 library")
5655
set(DEFAULT_SOFTHSM2_CONF "${CMAKE_INSTALL_FULL_SYSCONFDIR}/softhsm2.conf"
5756
CACHE STRING "The default location of softhsm.conf")
@@ -80,11 +79,37 @@ if(NOT CMAKE_BUILD_TYPE)
8079
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Default build type for SoftHSMv2 project" FORCE)
8180
endif(NOT CMAKE_BUILD_TYPE)
8281

82+
83+
set(CMAKE_CXX_FLAGS_MAINTAINER "-Wall -Wabi" CACHE STRING
84+
"Flags used by the C++ compiler during maintainer builds."
85+
FORCE)
86+
set(CMAKE_C_FLAGS_MAINTAINER "-Wall -pedantic" CACHE STRING
87+
"Flags used by the C compiler during maintainer builds."
88+
FORCE)
89+
set(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
90+
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
91+
"Flags used for linking binaries during maintainer builds."
92+
FORCE)
93+
set(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
94+
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
95+
"Flags used by the shared libraries linker during maintainer builds."
96+
FORCE)
97+
mark_as_advanced(
98+
CMAKE_CXX_FLAGS_MAINTAINER
99+
CMAKE_C_FLAGS_MAINTAINER
100+
CMAKE_EXE_LINKER_FLAGS_MAINTAINER
101+
CMAKE_SHARED_LINKER_FLAGS_MAINTAINER)
102+
103+
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
104+
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Maintainer."
105+
FORCE)
106+
107+
83108
message(STATUS "Build Configuration: ${CMAKE_BUILD_TYPE}")
84109

85110
# Build Modules Path
86111
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
87-
${CMAKE_SOURCE_DIR}/modules
112+
${CMAKE_SOURCE_DIR}/cmake/modules
88113
)
89114

90115
# Custom Modules
@@ -102,6 +127,7 @@ add_subdirectory(src)
102127
# p11-kit
103128
set(default_softhsm2_lib ${DEFAULT_PKCS11_LIB})
104129
configure_file(softhsm2.module.in softhsm2.module)
130+
105131
if(ENABLE_P11_KIT)
106132
install(FILES ${PROJECT_BINARY_DIR}/softhsm2.module
107133
DESTINATION ${P11KIT_PATH}

Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ EXTRA_DIST = $(srcdir)/CMakeLists.txt \
2121
$(srcdir)/FIPS-NOTES.md \
2222
$(srcdir)/LICENSE \
2323
$(srcdir)/m4/*.m4 \
24-
$(srcdir)/modules/*.cmake \
25-
$(srcdir)/modules/tests/*.c \
26-
$(srcdir)/modules/tests/*.cpp \
24+
$(srcdir)/cmake/modules/*.cmake \
25+
$(srcdir)/cmake/modules/tests/*.c \
26+
$(srcdir)/cmake/modules/tests/*.cpp \
2727
$(srcdir)/OSX-NOTES.md \
2828
$(srcdir)/README.md \
2929
$(srcdir)/win32/convarch/convarch.vcxproj.in \

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SoftHSM version 2
22

3-
SoftHSM is part of the OpenDNSSEC project. Read more at www.opendnssec.org.
3+
SoftHSM started as part of the OpenDNSSEC project. Today it's a standalone
4+
project.
45

56
[![Travis Build Status](https://api.travis-ci.org/opendnssec/SoftHSMv2.png)](https://travis-ci.org/opendnssec/SoftHSMv2)
67
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/opendnssec/SoftHSMv2?svg=true)](https://ci.appveyor.com/project/opendnssec/softhsmv2)
@@ -18,7 +19,7 @@ computer.
1819
A potential problem with the use of the PKCS#11 interface is that it might
1920
limit the wide spread use of OpenDNSSEC, since a potential user might not be
2021
willing to invest in a new hardware device. To counter this effect, OpenDNSSEC
21-
is providing a software implementation of a generic cryptographic device with a
22+
provided a software implementation of a generic cryptographic device with a
2223
PKCS#11 interface, the SoftHSM. SoftHSM is designed to meet the requirements of
2324
OpenDNSSEC, but can also work together with other cryptographic products
2425
because of the PKCS#11 interface.
@@ -64,7 +65,7 @@ The unit tests requires CppUnit.
6465
If the code is downloaded directly from the code repository, you have to
6566
prepare the configuration scripts before continuing.
6667

67-
1. You need to install automake, autoconf, libtool, libtool-ltdl-devel (RHEL/CentOS), pkg-config.
68+
1. You need to install automake, autoconf, libtool, libtool-ltdl-devel (RHEL/CentOS/Fedora), pkg-config.
6869
2. Run the command 'sh autogen.sh'
6970

7071
### Configure
@@ -113,18 +114,18 @@ Running the unit tests requires CppUnit.
113114

114115
### Install Library
115116

116-
Install the library using the follow command:
117+
Install the library using the following command:
117118

118119
sudo make install
119120

120121
### Configure
121122

122123
The default location of the config file is /etc/softhsm2.conf. This location
123-
can be change by setting the environment variable.
124+
can be changed by setting the SOFTHSM2\_CONF environment variable.
124125

125126
export SOFTHSM2_CONF=/home/user/config.file
126127

127-
Details on the configuration can be found in "man softhsm2.conf".
128+
Details on the configuration can be found through command "man softhsm2.conf".
128129

129130
Create the token directory you defined in your config file:
130131

0 commit comments

Comments
 (0)