Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f8b76e0
libzpc: Harmonize length types in ecc API
holger-dengler Mar 9, 2026
d278e0c
cmake: Add cross-build architecture information
holger-dengler Mar 11, 2026
7c9a4d8
cmake: Add test header comment
holger-dengler Oct 1, 2025
2ca0af9
CONTRIBUTING: re-format
holger-dengler Apr 10, 2026
911117c
cmake: Add OpenSSL package
holger-dengler Oct 1, 2025
f0d2895
provider: Add base provider
holger-dengler Oct 1, 2025
ccce480
cmake: Integrate base provider
holger-dengler Oct 1, 2025
66ad25d
test: Add OpenSSL configuration template
holger-dengler Aug 19, 2025
141e6fb
test: Add provider tests
holger-dengler Oct 3, 2025
f662444
cmake: Integrate provider test
holger-dengler Oct 3, 2025
3d50465
provider: Add provider-specific key object
holger-dengler Feb 25, 2026
1c3919f
cmake: Integrate provider-specific key object
holger-dengler Feb 25, 2026
e6af4b0
provider: Add hbkzpc-URI parser
holger-dengler Jan 21, 2026
4ed730e
cmake: Integrate uri
holger-dengler Jan 21, 2026
ef6599c
provider: Add mapping helpers
holger-dengler Feb 25, 2026
5871096
cmake: Integrate mapping helpers
holger-dengler Feb 25, 2026
8e247be
provider: Add store-loader
holger-dengler Jan 21, 2026
6f49dea
cmake: Integrate store-loader
holger-dengler Jan 21, 2026
6b205d9
provider: Add asymmetric key management
holger-dengler Feb 18, 2026
33f3dcb
cmake: Add zpc dependency for provider
holger-dengler Oct 1, 2025
1aa12cf
cmake: Integrate asymmetric key management
holger-dengler Feb 18, 2026
97b2a0c
test: Add provider test for store-loader
holger-dengler Feb 12, 2026
01c4e9f
test: Add provider test for PKEY (store/keymgmt)
holger-dengler Feb 17, 2026
cbf1358
provider: Add signature algorithms
holger-dengler Mar 9, 2026
767db62
cmake: Integrate signature algorithms
holger-dengler Mar 9, 2026
2a6c319
test: Add provider test for signature algorithms
holger-dengler Mar 17, 2026
7fd337b
provider: Add tls-property helpers
holger-dengler Mar 10, 2026
4c8295c
cmake: Integrate tls-property helpers
holger-dengler Mar 10, 2026
015a0a6
asn1: Add ASN.1 module (definition and functions)
holger-dengler Mar 13, 2026
bd4d772
cmake: ASN.1 module integration
holger-dengler Mar 13, 2026
6ccf5ee
test: Add asn.1 tests
holger-dengler Mar 18, 2026
1d2edc6
provider: Add decoders for hbkzpc-URI
holger-dengler Mar 14, 2026
f70038a
cmake: Integrate decoder implementation
holger-dengler Mar 14, 2026
37affd1
test: Add decoder tests
holger-dengler Mar 24, 2026
d84e0c2
test: Add signature test (PEM)
holger-dengler Apr 8, 2026
ab5204e
WIP dbg: Add provider gdb-scripts
holger-dengler Feb 25, 2026
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
87 changes: 87 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ find_package(json-c
REQUIRED
)

find_package(OpenSSL
3.5.0
REQUIRED
)

add_definitions(
-D_GNU_SOURCE
)
Expand Down Expand Up @@ -137,6 +142,80 @@ install(
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

###########################################################
# ASN.1

set (ASN1_SOURCES
src/asn1.c
)

add_custom_command(
OUTPUT asn1_gen.c
COMMAND ${CMAKE_C_COMPILER} -I${OPENSSL_INCLUDE_DIR} -x c -E ${CMAKE_SOURCE_DIR}/src/asn1_gen.c.in
| grep -v "^#"
| sed -n -e "1,/^BEGIN:$$/!p"
| clang-format --assume-filename=.c
> asn1_gen.c
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/src/asn1_gen.c.in
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(asn1_gen ALL DEPENDS asn1_gen.c)

add_library(asn1 OBJECT ${ASN1_SOURCES})
set_property(TARGET asn1 PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(asn1 PRIVATE ${OPENSSL_INCLUDE_DIR} ${CMAKE_BINARY_DIR})
add_dependencies(asn1 asn1_gen)

###########################################################
# zpcprovider

set(ZPCPROVIDER_SOURCES
src/provider.c
src/object.c
src/uri.c
src/map.c
src/store.c
src/keymgmt.c
src/signature.c
src/tls.c
src/decoder.c
)

add_library(zpcprovider MODULE ${ZPCPROVIDER_SOURCES})
set_target_properties(zpcprovider PROPERTIES PREFIX "")

target_include_directories(zpcprovider PRIVATE src include ${OPENSSL_INCLUDE_DIR})
target_link_libraries(zpcprovider PRIVATE zpc OpenSSL::Crypto $<TARGET_OBJECTS:asn1>)

install(
TARGETS zpcprovider
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}
)

set(OPENSSL_CONF
${CMAKE_BINARY_DIR}/openssl.cnf
)
set(OPENSSL_CONF_IN
${CMAKE_SOURCE_DIR}/openssl.cnf.in
)
set(ZPCPROVIDER_MODULE
${CMAKE_BINARY_DIR}/zpcprovider.so
)
configure_file(${OPENSSL_CONF_IN} ${OPENSSL_CONF} @ONLY)

# install(
# FILES ${CMAKE_SOURCE_DIR}/man/zpcprovider.cnf.5
# DESTINATION ${CMAKE_INSTALL_MANDIR}/man5
# )
#
# install(
# FILES ${CMAKE_SOURCE_DIR}/man/zpcprovider.7
# DESTINATION ${CMAKE_INSTALL_MANDIR}/man7
# )

###########################################################
# Test

option(BUILD_TEST OFF)

if (BUILD_TEST)
Expand Down Expand Up @@ -420,6 +499,14 @@ target_include_directories(runtest PRIVATE include src ${GTEST_INCLUDE_DIR})
include(GoogleTest)
gtest_discover_tests(runtest)

set (ZPCPROVIDER_TEST_SOURCES
test/tprovider.c
)
add_executable(runprovidertest ${ZPCPROVIDER_TEST_SOURCES})
add_dependencies(runprovidertest zpcprovider)
target_include_directories(runprovidertest PRIVATE src ${OPENSSL_INCLUDE_DIR})
target_link_libraries(runprovidertest PRIVATE OpenSSL::Crypto $<TARGET_OBJECTS:asn1>)

endif ()

###########################################################
Expand Down
25 changes: 18 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
Contributing {#contrib}
===

You can contribute to `libzpc` by submitting issues (feature requests, bug reports) or pull requests (code contributions) to the GitHub repository.
You can contribute to `libzpc` by submitting issues (feature requests, bug
reports) or pull requests (code contributions) to the GitHub repository.


Bug reports
---

When filing a bug report, please include all relevant information.

In all cases include the `libzpc` version, operating system and kernel version used.
In all cases include the `libzpc` version, operating system and kernel version
used.

Additionally, if it is a build error, include the toolchain version used. If it is a runtime error, include the crypto adapter config and processor model used.
Additionally, if it is a build error, include the toolchain version used. If it
is a runtime error, include the crypto adapter config and processor model used.

Ideally, detailed steps on how to reproduce the issue would be included.


Code contributions
---

All code contributions are reviewed by the `libzpc` maintainers who reverve the right to accept or reject a pull request.
All code contributions are reviewed by the `libzpc` maintainers who reverve the
right to accept or reject a pull request.

Please state clearly if your pull request changes the `libzpc` API or ABI, and if so, whether the changes are backward compatible.
Please state clearly if your pull request changes the `libzpc` API or ABI, and
if so, whether the changes are backward compatible.

If your pull request resolves an issue, please put a `"Fixes #<issue number>"` line in the commit message. Ideally, the pull request would add a corresponding regression test.
If your pull request resolves an issue, please put a `"Fixes #<issue number>"`
line in the commit message. Ideally, the pull request would add a corresponding
regression test.

If your pull request adds a new feature, please add a corresponding unit test.

The code base is formatted using the `indent` tool with the options specified in the enclosed `.indent.pro` file. All code contributions must not violate this coding style. When formatting `libzpc` code, you can use `indent` with the prescribed options by copying the file to your home directory or by setting the `INDENT_PROFILE` environment variable's value to name the file.
The code base is formatted using the `indent` tool with the options specified in
the enclosed `.indent.pro` file. All code contributions must not violate this
coding style. When formatting `libzpc` code, you can use `indent` with the
prescribed options by copying the file to your home directory or by setting the
`INDENT_PROFILE` environment variable's value to name the file.
10 changes: 5 additions & 5 deletions include/zpc/ecc_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int zpc_ec_key_set_apqns(struct zpc_ec_key *key, const char *apqns[]);
*/
__attribute__((visibility("default")))
int zpc_ec_key_import(struct zpc_ec_key *key, const unsigned char *seckey,
unsigned int seckeylen);
size_t seckeylen);

/**
* Import an EC clear-key pair. At least one of the key parts must be non-NULL.
Expand All @@ -150,8 +150,8 @@ int zpc_ec_key_import(struct zpc_ec_key *key, const unsigned char *seckey,
*/
__attribute__((visibility("default")))
int zpc_ec_key_import_clear(struct zpc_ec_key *key,
const unsigned char *pubkey, unsigned int publen,
const unsigned char *privkey, unsigned int privlen);
const unsigned char *pubkey, size_t publen,
const unsigned char *privkey, size_t privlen);

/**
* Export an EC secure-key. Depending on the key type (CCA or EP11), the secure
Expand All @@ -166,7 +166,7 @@ int zpc_ec_key_import_clear(struct zpc_ec_key *key,
*/
__attribute__((visibility("default")))
int zpc_ec_key_export(struct zpc_ec_key *key, unsigned char *seckey,
unsigned int *seckeylen);
size_t *seckeylen);

/**
* Export an EC public-key.
Expand All @@ -180,7 +180,7 @@ int zpc_ec_key_export(struct zpc_ec_key *key, unsigned char *seckey,
*/
__attribute__((visibility("default")))
int zpc_ec_key_export_public(struct zpc_ec_key *key, unsigned char *pubkey,
unsigned int *pubkeylen);
size_t *pubkeylen);

/**
* Generate an EC secure-key.
Expand Down
8 changes: 4 additions & 4 deletions include/zpc/ecdsa_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ int zpc_ecdsa_ctx_set_key(struct zpc_ecdsa_ctx *ctx, struct zpc_ec_key *key);
*/
__attribute__((visibility("default")))
int zpc_ecdsa_sign(struct zpc_ecdsa_ctx *ctx,
const unsigned char *hash, unsigned int hash_len,
unsigned char *signature, unsigned int *sig_len);
const unsigned char *hash, size_t hash_len,
unsigned char *signature, size_t *sig_len);

/**
* Do an ECDSA verify operation.
Expand All @@ -72,8 +72,8 @@ int zpc_ecdsa_sign(struct zpc_ecdsa_ctx *ctx,
*/
__attribute__((visibility("default")))
int zpc_ecdsa_verify(struct zpc_ecdsa_ctx *ctx,
const unsigned char *hash, unsigned int hash_len,
const unsigned char *signature, unsigned int sig_len);
const unsigned char *hash, size_t hash_len,
const unsigned char *signature, size_t sig_len);

/**
* Free an ECDSA context.
Expand Down
5 changes: 5 additions & 0 deletions misc/dbg/decoder.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set breakpoint pending on
break decoder_newctx
break decoder_freectx
break decoder_pem_hbkzpc_der_decode
break decoder_der_hbkzpc_ec_decode
6 changes: 6 additions & 0 deletions misc/dbg/kmgmt.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set breakpoint pending on
break ec_new
break ec_free
break ec_load
break ec_has
# disable
12 changes: 12 additions & 0 deletions misc/dbg/store.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set breakpoint pending on
break store_ctx_init
break store_ctx_free
break store_ctx_expect
break store_open
break store_open_ex
break store_load
break store_eof
break store_close
break store_set_ctx_params
break store_settable_ctx_params
disable
28 changes: 28 additions & 0 deletions openssl.cnf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
HOME = .

# Use this in order to automatically load providers.
openssl_conf = openssl_init

config_diagnostics = 1

[openssl_init]
providers = provider_sect
alg_section = evp_properties

[provider_sect]
default = default_sect
base = base_sect
hbkzpc = hbkzpc_sect

[evp_properties]

[base_sect]
activate = 1

[default_sect]
activate = 1

[hbkzpc_sect]
module = @ZPCPROVIDER_MODULE@
identity = hbkzpc
activate = 1
1 change: 1 addition & 0 deletions s390x-tc-debian.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR s390x)

set(CMAKE_C_COMPILER s390x-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER s390x-linux-gnu-g++)
Expand Down
21 changes: 21 additions & 0 deletions src/asn1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the libzpc project
#include "asn1.h"

ASN1_SEQUENCE(ZPCHBK) = {
ASN1_EXP(ZPCHBK, desc, ASN1_VISIBLESTRING, 0),
ASN1_EXP(ZPCHBK, uri, ASN1_UTF8STRING, 1),
} ASN1_SEQUENCE_END(ZPCHBK);

#include "asn1_gen.c"

int i2d_ZPCHBK_bio(BIO *bp, const ZPCHBK *hbkp)
{
return ASN1_i2d_bio_of(ZPCHBK, i2d_ZPCHBK, bp, hbkp);
}

ZPCHBK *d2i_ZPCHBK_bio(BIO *bp, ZPCHBK **hbkpp)
{
return ASN1_d2i_bio_of(ZPCHBK, ZPCHBK_new, d2i_ZPCHBK,
bp, hbkpp);
}
24 changes: 24 additions & 0 deletions src/asn1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the libzpc project
#ifndef _ASN1_H
#define _ASN1_H

#include <openssl/asn1t.h>
#include <openssl/pem.h>

#define HBKZPC_PEM_STRING "ZPC HARDWARE BACKED KEY"
#define HBKZPC_DER_DESC "HBKZPC Provider URI v1.0"

struct zpc_hardware_backed_key_sequence_st {
ASN1_VISIBLESTRING *desc;
ASN1_UTF8STRING *uri;
};
typedef struct zpc_hardware_backed_key_sequence_st ZPCHBK;
DECLARE_ASN1_FUNCTIONS(ZPCHBK)

int i2d_ZPCHBK_bio(BIO *bp, const ZPCHBK *hbkp);
ZPCHBK *d2i_ZPCHBK_bio(BIO *bp, ZPCHBK **hbkpp);

DECLARE_PEM_write_bio(ZPCHBK, ZPCHBK)
DECLARE_PEM_read_bio(ZPCHBK, ZPCHBK)
#endif /* _ASN1_H */
10 changes: 10 additions & 0 deletions src/asn1_gen.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the libzpc project
#include <openssl/asn1t.h>
#include <openssl/pem.h>
#include <openssl/x509.h>

BEGIN:
IMPLEMENT_ASN1_FUNCTIONS(ZPCHBK)
IMPLEMENT_PEM_write_bio(ZPCHBK, ZPCHBK, HBKZPC_PEM_STRING, ZPCHBK)
IMPLEMENT_PEM_read_bio(ZPCHBK, ZPCHBK, HBKZPC_PEM_STRING, ZPCHBK)
Loading