Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
be78f41
fix ECC & GOST are now disabled by default
agrandville Apr 7, 2021
1cce158
fix set windows compiler warning W4
agrandville Apr 7, 2021
cc5ce56
fix set windows compile warning level W4
agrandville Apr 7, 2021
b86922c
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Apr 7, 2021
b5bd511
fix set windows compile warning level W4
agrandville Apr 7, 2021
78f482a
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Apr 7, 2021
0bdd642
fix DEFAULT_UMASK missing
agrandville Apr 7, 2021
7e1988f
fix add cmake windows compatibility files
agrandville Apr 7, 2021
72c6b80
feat change compile crypto backend order
agrandville Apr 7, 2021
4f82997
fix set warning level to W4 for softhsm libraries
agrandville Apr 7, 2021
5864eab
fix set warning level to W4 for softhsm test binaries
agrandville Apr 7, 2021
8fd89ec
fix Botan ECB mode dropped
agrandville Apr 8, 2021
d7bf262
fix cmake windows static lib
agrandville Apr 9, 2021
9344e4f
fix add Softhsm2-negative-mech.conf for p11test
agrandville Apr 10, 2021
f731525
feat add a message if cppunit library is missing
agrandville Apr 10, 2021
538daab
fix windows execution
agrandville Apr 10, 2021
e56c94f
fix windows duplicate define
agrandville Apr 10, 2021
025ef9c
fix enable post build tests
agrandville Apr 10, 2021
08d5af0
fix remove cppunit path
agrandville Apr 10, 2021
712cae0
fix cppunit vcpkg autodetect
agrandville Apr 10, 2021
7d5b332
fix enable appveyor cache on error
agrandville Apr 10, 2021
26942e8
fix enable appveyor cache on error
agrandville Apr 10, 2021
764e136
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Apr 11, 2021
029f043
fix cppunit vcpkg path
agrandville Apr 11, 2021
b33992c
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Apr 11, 2021
dd06d94
fix cppunit dll linkage
agrandville Apr 11, 2021
861217b
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Apr 11, 2021
05c60b9
fix disable ECB Tests
agrandville Apr 16, 2021
d9e6caa
fix build script for CppUnit
agrandville Apr 16, 2021
847a0e8
fix disable ECB test
agrandville Apr 16, 2021
1833a03
feat make tests more verbose
agrandville Apr 19, 2021
3eaadcc
feat add windows compile options
agrandville Apr 20, 2021
2aba7b2
feat add console output for test executable
agrandville Apr 26, 2021
0b4ca0c
fix compile options
agrandville Apr 26, 2021
c4105e6
fix vcpkg options
agrandville May 13, 2021
646e9e8
fix cmake MSVC flags
agrandville Jun 12, 2021
4193ec8
fix update appveyor vcpkg build tool
agrandville Jun 12, 2021
ba06c60
fix update appveyor vcpkg build tool
agrandville Jun 12, 2021
92ecbda
Update .appveyor.yml
agrandville Jun 12, 2021
18461ad
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Jun 12, 2021
916b636
fix update vcpkg build tool
agrandville Jun 12, 2021
562a4a3
fix appveyor build script
agrandville Jun 12, 2021
eec17b6
fix appveyor build script
agrandville Jun 12, 2021
e4fd6b9
Update .appveyor.yml
agrandville Jun 12, 2021
0c3353c
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Jun 12, 2021
a3fa176
fix appveyor build script
agrandville Jun 12, 2021
8045afd
fix remove windows getopt component under GNU license
agrandville Jun 12, 2021
345b4da
fix cppUnit path
agrandville Jun 12, 2021
849df03
fix missing cppunit include
agrandville Jun 12, 2021
01d7181
fix unreferenced formal parameter warning
agrandville Jun 12, 2021
553d4a7
fix cmake minimal version 3.20
agrandville Jun 12, 2021
fbfbf82
fix cppunit path
agrandville Jun 12, 2021
4580566
fix remove getopt from cache
agrandville Jun 12, 2021
18deb3a
fix cppunit handlemanager
agrandville Jun 12, 2021
aa6e93c
feat disable openssl backend
agrandville Jun 19, 2021
331e63b
feat make ctest ouput more verbose
agrandville Jun 19, 2021
47e2ca6
feat enable openssl build
agrandville Jun 19, 2021
a226eb6
feat make test output more verbose
agrandville Jun 19, 2021
1be3466
Merge branch 'develop' of https://github.com/opendnssec/SoftHSMv2 int…
agrandville Jun 19, 2021
c77251c
fix cmake minimal version (CMP0054)
agrandville Jun 19, 2021
997e95e
fix compilation warnings
agrandville Jun 19, 2021
ff5c351
feat enable DB backend for windows
agrandville Jun 21, 2021
5e895c4
fix db backend tools compilation errors
agrandville Jun 21, 2021
a5aac6f
fix check minimal botan version
agrandville Apr 19, 2021
465c531
Merge branch 'opendnssec:develop' into develop
agrandville Aug 2, 2021
c1e893c
doc add CMAKE build for windows
agrandville Aug 2, 2021
8a6bbec
Merge branch 'develop' of https://github.com/agrandville/SoftHSMv2 in…
agrandville Aug 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: 2.6.0-{build}
configuration: Release
platform:
- x86
- x64
init:
- ps: >-
If ($env:Platform -Match "x86") {
Expand Down Expand Up @@ -41,31 +40,47 @@ init:
$env:RELEASE_DIR=Join-Path $env:BUILD_DIR "SoftHSMv2-$env:ENV_PLATFORM"

$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\"
cache:
- C:/Tools/vcpkg/installed/
environment:
APPVEYOR_SAVE_CACHE_ON_ERROR: true
matrix:
- CRYPTO_BACKEND: botan
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=botan
- CRYPTO_BACKEND: openssl
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=openssl
DB_BACKEND: OFF
- CRYPTO_BACKEND: openssl
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=openssl
DB_BACKEND: ON
- CRYPTO_BACKEND: botan
ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=botan
DB_BACKEND: OFF
install:
# Update vcpkg
- cd c:\tools\vcpkg
- cmd: git fetch
- cmd: git checkout 2021.05.12
- cmd: bootstrap-vcpkg.bat
- cmd: vcpkg install sqlite3:x86-windows
- cmd: vcpkg install openssl-windows:x64-windows
- cmd: vcpkg install openssl-windows:x86-windows
- cmd: vcpkg install botan:x86-windows
- cmd: vcpkg install cppunit:x86-windows
- cmd: vcpkg install getopt-win32:x86-windows
# static link is forbidden with components under GNU license
# switch to a source code under a more permissive NETBSD license
#- cmd: vcpkg install getopt-win32:x86-windows-static
- cmd: vcpkg update
- cmd: vcpkg upgrade --no-dry-run
build_script:
- cmd: if exist "C:\projects\softhsmv2\build" rd /s /q C:\projects\softhsmv2\build
- cmd: mkdir C:\projects\softhsmv2\build
- cmd: cd C:\projects\softhsmv2\build
- cmd: vcpkg integrate install
- 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 .
- cmd: msbuild softhsm2.sln /p:Configuration="Release" /p:Platform="Win32" /p:PlatformToolset=v140 /target:Build
- cmd: IF "%ENV_PLATFORM%"=="x86" ( CD win32\Release ) ELSE ( CD win32\x64\Release)
- cmd: cryptotest.exe
- cmd: datamgrtest.exe
- cmd: handlemgrtest.exe
- cmd: objstoretest.exe
- cmd: p11test.exe
- cmd: sessionmgrtest.exe
- cmd: slotmgrtest.exe
test: off
- cmd: cmake .. -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
- cmd: cmake --build . --config RelWithDebInfo
- cmd: ctest -C RelWithDebInfo --progress --verbose
- cmd: cmake -DCMAKE_INSTALL_PREFIX=build/SoftHSMv2-$(Platform) -DCMAKE_INSTALL_CONFIG_NAME=RelWithDebInfo -P cmake_install.cmake
#on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
#test: off
artifacts:
- path: build/SoftHSMv2-$(Platform)
name: SoftHSMv2-$(PACKAGE_VERSION_NAME)-$(Platform)
74 changes: 74 additions & 0 deletions CMAKE-WIN-NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Building SoftHSMv2 for Windows

This document describes process of building both 32-bit and 64-bit versions of SoftHSMv2.

## Required software

- [Visual Studio](https://visualstudio.microsoft.com/vs/community/) (Community)
- [C/C++ dependency manager from Microsoft](https://vcpkg.io/)
- [CMake](https://cmake.org/)

## Prepare working directories

set VCPKG_HOME=C:\Projects\vcpkg
set SOFTHSM_HOME=C:\Projects\SoftHSMv2
git clone https://github.com/opendnssec/SoftHSMv2.git %SOFTHSM_HOME%
git clone https://github.com/Microsoft/vcpkg.git %VCPKG_HOME%

## Build dependencies

cd %VCPKG_HOME%
bootstrap-vcpkg.bat
git fetch
git checkout 2021.05.12

vcpkg install cppunit:x86-windows
vcpkg install cppunit:x86-windows-static
vcpkg install openssl-windows:x86-windows
vcpkg install botan:x86-windows
vcpkg install sqlite3:x86-windows

vcpkg install cppunit:x64-windows
vcpkg install cppunit:x64-windows-static
vcpkg install openssl-windows:x64-windows
vcpkg install botan:x64-windows
vcpkg install sqlite3:x64-windows

vcpkg integrate install

## Configure SoftHSMv2

Build can be configured using the following commands:

mkdir %SOFTHSM_HOME%\tmp32
cd %SOFTHSM_HOME%\tmp32
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

mkdir %SOFTHSM_HOME%\tmp64
cd %SOFTHSM_HOME%\tmp64
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

Some options (more can be found in CMakeLists.txt):

-DBUILD_TESTS=ON Compile tests along with libraries
-DENABLE_EDDSA=ON Enable support for EDDSA
-DWITH_MIGRATE=ON Build migration tool
-DWITH_CRYPTO_BACKEND= Select crypto backend (openssl|botan)
-DDISABLE_NON_PAGED_MEMORY=ON Disable non-paged memory for secure storage
-DWITH_OBJECTSTORE_BACKEND_DB=ON Enable sqlite3 data storage

## Compile

Compile the source code using the following command:

cmake --build . --config RelWithDebInfo

## Test

ctest -C RelWithDebInfo --output-on-failure --progress --verbose

## Install

Install the library using the follow command:

cmake -DCMAKE_INSTALL_CONFIG_NAME=RelWithDebInfo -P cmake_install.cmake
41 changes: 36 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
cmake_minimum_required(VERSION 3.5)

cmake_minimum_required(VERSION 3.16)
project(softhsm2 C CXX)

# Build Options
option(BUILD_TESTS "Compile tests along with libraries" OFF)
option(DISABLE_NON_PAGED_MEMORY "Disable non-paged memory for secure storage" OFF)
option(DISABLE_VISIBILITY "Disables and unsets -fvisibility=hidden" OFF)
option(ENABLE_64bit "Enable 64-bit compiling" OFF)
option(ENABLE_ECC "Enable support for ECC" ON)
option(ENABLE_ECC "Enable support for ECC" OFF)
option(ENABLE_EDDSA "Enable support for EDDSA" OFF)
option(ENABLE_GOST "Enable support for GOST" ON)
option(ENABLE_GOST "Enable support for GOST" OFF)
option(ENABLE_FIPS "Enable support for FIPS 140-2 mode" OFF)
option(ENABLE_P11_KIT "Enable p11-kit integration" ON)
option(ENABLE_PEDANTIC "Enable pedantic compile mode" OFF)
Expand Down Expand Up @@ -59,7 +58,7 @@ set(DEFAULT_TOKENDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/softhsm/tokens/"
CACHE STRING "The default location of the token directory")
set(DEFAULT_UMASK "0077"
CACHE STRING "The default file mode creation mask")

set(MAX_PIN_LEN 255 CACHE STRING "Maximum PIN length")
set(MIN_PIN_LEN 4 CACHE STRING "Minimum PIN length")

Expand All @@ -80,6 +79,32 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Default build type for SoftHSMv2 project" FORCE)
endif(NOT CMAKE_BUILD_TYPE)


set(CMAKE_CXX_FLAGS_MAINTAINER "-Wall -Wabi" CACHE STRING
"Flags used by the C++ compiler during maintainer builds."
FORCE)
set(CMAKE_C_FLAGS_MAINTAINER "-Wall -pedantic" CACHE STRING
"Flags used by the C compiler during maintainer builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
"Flags used for linking binaries during maintainer builds."
FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
"Flags used by the shared libraries linker during maintainer builds."
FORCE)
mark_as_advanced(
CMAKE_CXX_FLAGS_MAINTAINER
CMAKE_C_FLAGS_MAINTAINER
CMAKE_EXE_LINKER_FLAGS_MAINTAINER
CMAKE_SHARED_LINKER_FLAGS_MAINTAINER)

set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Maintainer."
FORCE)


message(STATUS "Build Configuration: ${CMAKE_BUILD_TYPE}")

# Build Modules Path
Expand All @@ -102,12 +127,18 @@ add_subdirectory(src)
# p11-kit
set(default_softhsm2_lib ${DEFAULT_PKCS11_LIB})
configure_file(softhsm2.module.in softhsm2.module)

if(ENABLE_P11_KIT)
install(FILES ${PROJECT_BINARY_DIR}/softhsm2.module
DESTINATION ${P11KIT_PATH}
)
endif(ENABLE_P11_KIT)

#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()

# Packaging
set(CPACK_PACKAGE_NAME ${PACKAGE_NAME})
set(CPACK_PACKAGE_VENDOR "OpenDNSSEC")
Expand Down
22 changes: 1 addition & 21 deletions config.h.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,11 @@
*/
#ifdef _WIN32

/* The default log level */
#undef DEFAULT_LOG_LEVEL
#define DEFAULT_LOG_LEVEL "INFO"

/* Default storage backend for token objects */
#undef DEFAULT_OBJECTSTORE_BACKEND
#define DEFAULT_OBJECTSTORE_BACKEND "file"

/* The default PKCS#11 library */
#undef DEFAULT_PKCS11_LIB
#define DEFAULT_PKCS11_LIB "softhsm2.dll"

/* The default location of softhsm2.conf */
#undef DEFAULT_SOFTHSM2_CONF
#define DEFAULT_SOFTHSM2_CONF "softhsm2.conf"

/* The default location of the token directory */
#undef DEFAULT_TOKENDIR
#define DEFAULT_TOKENDIR "tokens"

/* Whether LoadLibrary is available */
#undef HAVE_LOADLIBRARY
#define HAVE_LOADLIBRARY 1


/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
#define HAVE_STDLIB_H 1
Expand Down Expand Up @@ -262,4 +242,4 @@ int setenv(const char *name, const char *value, int overwrite);

// #pragma warning(disable: 4996)

#endif
#endif
47 changes: 29 additions & 18 deletions modules/CompilerOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
find_package(PkgConfig)

include(CheckCXXCompilerFlag)
include(CheckFunctionExists)
include(CheckIncludeFiles)
Expand Down Expand Up @@ -117,6 +119,14 @@ else(DISABLE_NON_PAGED_MEMORY)
endif(NOT "${MLOCK_SIZE}" STREQUAL "unlimited")
endif(DISABLE_NON_PAGED_MEMORY)


if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# disable
# C4996 warning for deprecated posix function name
# C4456 declaration of 'identifier' hides previous local declaration
set(COMPILE_OPTIONS "/MP;/W4;/wd4996;/wd4456")
endif()

# Check if -ldl exists (equivalent of acx_dlopen.m4)
check_library_exists(dl dlopen "" HAVE_DLOPEN)
check_function_exists(LoadLibrary HAVE_LOADLIBRARY)
Expand Down Expand Up @@ -150,8 +160,8 @@ if(WITH_CRYPTO_BACKEND STREQUAL "botan")
message(FATAL_ERROR "Failed to find Botan!")
endif()

set(CRYPTO_INCLUDES ${BOTAN_INCLUDE_DIRS})
set(CRYPTO_LIBS ${BOTAN_LIBRARIES})
set(CRYPTO_INCLUDES ${BOTAN_INCLUDE_DIR})
set(CRYPTO_LIBS ${BOTAN_LIBRARY})
message(STATUS "Botan: Includes: ${CRYPTO_INCLUDES}")
message(STATUS "Botan: Libs: ${CRYPTO_LIBS}")

Expand Down Expand Up @@ -433,12 +443,13 @@ if(WITH_SQLITE3)
message(STATUS "SQLite3: Includes: ${SQLITE3_INCLUDES}")
message(STATUS "SQLite3: Libs: ${SQLITE3_LIBS}")

check_include_files(sqlite3.h HAVE_SQLITE3_H)
check_library_exists(sqlite3 sqlite3_prepare_v2 "" HAVE_LIBSQLITE3)
find_program(SQLITE3_COMMAND NAMES sqlite3)
if(SQLITE3_COMMAND MATCHES "-NOTFOUND")
message(FATAL_ERROR "SQLite3: Command was not found")
endif(SQLITE3_COMMAND MATCHES "-NOTFOUND")
set(HAVE_SQLITE3_H 1)
#check_include_files(sqlite3.h HAVE_SQLITE3_H)
#check_library_exists(sqlite3 sqlite3_prepare_v2 "" HAVE_LIBSQLITE3)
#find_program(SQLITE3_COMMAND NAMES sqlite3)
#if(SQLITE3_COMMAND MATCHES "-NOTFOUND")
# message(FATAL_ERROR "SQLite3: Command was not found")
#endif(SQLITE3_COMMAND MATCHES "-NOTFOUND")
else(WITH_SQLITE3)
message(STATUS "Not including SQLite3 in build")
endif(WITH_SQLITE3)
Expand Down Expand Up @@ -475,17 +486,17 @@ else(ENABLE_P11_KIT)
endif(ENABLE_P11_KIT)

if(BUILD_TESTS)
# Find CppUnit (equivalent of acx_cppunit.m4)
set(CppUnit_FIND_QUIETLY ON)
set(CppUnit_FIND_QUIETLY OFF)

# Find CppUnit (equivalent of acx_cppunit.m4)
include(FindCppUnit)
if(NOT CPPUNIT_FOUND)
message(FATAL_ERROR "Failed to find CppUnit!")
endif(NOT CPPUNIT_FOUND)

set(CPPUNIT_INCLUDES ${CPPUNIT_INCLUDE_DIR})
set(CPPUNIT_LIBS ${CPPUNIT_LIBRARY})
message(STATUS "CppUnit: Includes: ${CPPUNIT_INCLUDES}")
message(STATUS "CppUnit: Libs: ${CPPUNIT_LIBS}")

if(NOT CppUnit_FOUND)
message(FATAL_ERROR "Failed to find CppUnit, try to set the path to CppUnit root folder in the system variable CPPUNIT_INCLUDE_DIR and library path in CPPUNIT_LIBRARY!")
else()
message(STATUS "CppUnit tests enabled.")
endif(NOT CppUnit_FOUND)

else(BUILD_TESTS)
message(STATUS "Not building tests")
endif(BUILD_TESTS)
Expand Down
5 changes: 3 additions & 2 deletions modules/FindBotan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
#
# This file is in the public domain

include(FindPkgConfig)
find_package(Botan CONFIG)

if(NOT BOTAN_FOUND)
pkg_check_modules(BOTAN botan-2)
pkg_check_modules(botan BOTAN_FOUND)
endif()


if(NOT BOTAN_FOUND)
find_path(BOTAN_INCLUDE_DIRS NAMES botan/botan.h
PATH_SUFFIXES botan-2
Expand Down
Loading