Skip to content

Commit 20921a0

Browse files
committed
refactor: make code more robust and compilable on multiple platforms
Signed-off-by: Hubert Hardes <[email protected]>
1 parent 78deed2 commit 20921a0

File tree

5 files changed

+188
-126
lines changed

5 files changed

+188
-126
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1515

1616
option(COVERAGE "Build with coverage" ON)
1717

18+
find_package(OpenSSL REQUIRED COMPONENTS Crypto)
19+
find_package(PkgConfig REQUIRED)
20+
pkg_check_modules(P11Kit REQUIRED p11-kit-1)
21+
1822
if(COVERAGE)
1923
message(STATUS "Compiling test targets with coverage enabled")
2024
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-update=atomic")
@@ -25,5 +29,5 @@ file(GLOB_RECURSE SRC_FILES src/*.cpp)
2529

2630
add_library(pkcs11-to-cmd SHARED ${SRC_FILES})
2731

28-
target_link_libraries(pkcs11-to-cmd PRIVATE pthread)
29-
target_include_directories(pkcs11-to-cmd PRIVATE /usr/include/p11-kit-1/p11-kit)
32+
target_link_libraries(pkcs11-to-cmd PRIVATE OpenSSL::Crypto pthread)
33+
target_include_directories(pkcs11-to-cmd PRIVATE ${P11Kit_INCLUDE_DIRS})

src/blind_implementations.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111
#include "debug.hpp"
1212

13-
#include <pkcs11.h>
13+
#define CRYPTOKI_EXPORTS
14+
#include <p11-kit/pkcs11.h>
1415

1516
extern "C" {
1617
// LCOV_EXCL_START
1718
// --- PKCS#11 dummy implementations for all functions ---
1819
#define BLIND_FUNC_IMPL(name, ...) \
19-
CK_RV blind_##name(__VA_ARGS__) \
20+
CK_RV CK_SPEC blind_##name(__VA_ARGS__) \
2021
{ \
2122
debug("blind_" #name " called"); \
2223
return CKR_FUNCTION_NOT_SUPPORTED; \

src/consts.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#pragma once
1010

1111
constexpr const char* PROVIDER_NAME = "pkcs11-to-cmd";
12+
constexpr unsigned char PROVIDER_VERSION_MAJOR = 1;
13+
constexpr unsigned char PROVIDER_VERSION_MINOR = 0;
1214
constexpr const char* ENV_CMD = "P2C_CMD";
1315
constexpr const char* ENV_DATA = "P2C_DATA";
1416
constexpr const char* ENV_SIG = "P2C_SIG";

0 commit comments

Comments
 (0)