Skip to content
Open
Show file tree
Hide file tree
Changes from 13 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
56 changes: 56 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,49 @@ install(
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

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

set(ZPCPROVIDER_SOURCES
src/provider.c
src/object.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 OpenSSL::Crypto)

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 +468,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)

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
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
38 changes: 19 additions & 19 deletions src/ecc_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ const u16 curve2pvsecret_type[] = {

static void __ec_key_reset(struct zpc_ec_key *);
static int ec_key_check_ep11_spki(const struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len);
const unsigned char *spki, size_t spki_len);
static void ec_key_use_maced_spki_from_buf(struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len);
const unsigned char *spki, size_t spki_len);
static int ec_key_use_raw_spki_from_buf(struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len);
const unsigned char *spki, size_t spki_len);
static int ec_key_spki_has_valid_mkvp(const struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len);
const unsigned char *spki, size_t spki_len);
static int ec_key_blob_has_valid_mkvp(struct zpc_ec_key *ec_key,
const unsigned char *buf);
static int ec_key_blob_is_pkey_extractable(struct zpc_ec_key *ec_key,
Expand Down Expand Up @@ -492,7 +492,7 @@ int zpc_ec_key_set_apqns(struct zpc_ec_key *ec_key, const char *apqns[])

int
zpc_ec_key_export(struct zpc_ec_key *ec_key, unsigned char *buf,
unsigned int *buflen)
size_t *buflen)
{
int rc, rv;

Expand Down Expand Up @@ -558,7 +558,7 @@ zpc_ec_key_export(struct zpc_ec_key *ec_key, unsigned char *buf,
}

int zpc_ec_key_export_public(struct zpc_ec_key *ec_key,
unsigned char *buf, unsigned int *buflen)
unsigned char *buf, size_t *buflen)
{
int rc, rv;

Expand Down Expand Up @@ -613,7 +613,7 @@ int zpc_ec_key_export_public(struct zpc_ec_key *ec_key,
}

int zpc_ec_key_import(struct zpc_ec_key *ec_key, const unsigned char *buf,
unsigned int buflen)
size_t buflen)
{
target_t target;
int rc, rv, seclen;
Expand Down Expand Up @@ -789,8 +789,8 @@ int zpc_ec_key_import(struct zpc_ec_key *ec_key, const unsigned char *buf,
}

int zpc_ec_key_import_clear(struct zpc_ec_key *ec_key, const unsigned char *pubkey,
unsigned int publen, const unsigned char *privkey,
unsigned int privlen)
size_t publen, const unsigned char *privkey,
size_t privlen)
{
unsigned int flags;
int rc, rv;
Expand Down Expand Up @@ -1057,7 +1057,7 @@ int zpc_ec_key_generate(struct zpc_ec_key *ec_key)
int zpc_ec_key_reencipher(struct zpc_ec_key *ec_key, unsigned int method)
{
struct ec_key reenc;
unsigned int seckeylen;
size_t seckeylen;
target_t target;
int rv, rc = ZPC_ERROR_APQNSNOTSET;
size_t i;
Expand Down Expand Up @@ -1343,8 +1343,8 @@ int ec_key_pvsec2prot(struct zpc_ec_key *ec_key)
}

int ec_key_clr2sec(struct zpc_ec_key *ec_key, unsigned int flags,
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)
{
target_t target;
int rv, rc = ZPC_ERROR_APQNSNOTSET;
Expand Down Expand Up @@ -1400,7 +1400,7 @@ int ec_key_sec2prot(struct zpc_ec_key *ec_key, enum ec_key_sec sec)
{
struct pkey_kblob2pkey3 io;
struct ec_key *key = NULL;
unsigned int keybuf_len;
size_t keybuf_len;
int rc, i;

assert(sec == EC_KEY_SEC_OLD || sec == EC_KEY_SEC_CUR);
Expand Down Expand Up @@ -1442,7 +1442,7 @@ int ec_key_sec2prot(struct zpc_ec_key *ec_key, enum ec_key_sec sec)
}

int ec_key_clr2prot(struct zpc_ec_key *ec_key, const unsigned char *privkey,
unsigned int privlen)
size_t privlen)
{
struct pkey_kblob2pkey3 io;
unsigned char buf[sizeof(struct clearkeytoken) + 80];
Expand Down Expand Up @@ -1529,7 +1529,7 @@ int ec_key_spki_valid_for_pubkey(const struct zpc_ec_key *ec_key,
}

static int ec_key_check_ep11_spki(const struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len)
const unsigned char *spki, size_t spki_len)
{
if (spki_len > curve2macedspkilen[ec_key->curve] &&
spki_len < curve2rawspkilen[ec_key->curve])
Expand All @@ -1550,7 +1550,7 @@ static int ec_key_check_ep11_spki(const struct zpc_ec_key *ec_key,
}

static void ec_key_use_maced_spki_from_buf(struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len)
const unsigned char *spki, size_t spki_len)
{
memcpy(ec_key->pub.spki, spki, spki_len);
ec_key->pub.spkilen = spki_len;
Expand All @@ -1563,7 +1563,7 @@ static void ec_key_use_maced_spki_from_buf(struct zpc_ec_key *ec_key,
}

static int ec_key_use_raw_spki_from_buf(struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len)
const unsigned char *spki, size_t spki_len)
{
target_t target;
int rc = -EIO, rv;
Expand Down Expand Up @@ -1600,7 +1600,7 @@ static int ec_key_use_raw_spki_from_buf(struct zpc_ec_key *ec_key,
}

static int ec_key_spki_has_valid_mkvp(const struct zpc_ec_key *ec_key,
const unsigned char *spki, unsigned int spki_len)
const unsigned char *spki, size_t spki_len)
{
(void)spki_len; /* suppress unused parm compiler warning */

Expand All @@ -1618,7 +1618,7 @@ static int ec_key_spki_has_valid_mkvp(const struct zpc_ec_key *ec_key,
static int ec_key_blob_has_valid_mkvp(struct zpc_ec_key *ec_key, const unsigned char *buf)
{
const unsigned char *mkvp;
unsigned int mkvp_len;
size_t mkvp_len;

if (ec_key->mkvp_set == 0)
return 1; /* cannot judge */
Expand Down
6 changes: 3 additions & 3 deletions src/ecc_key_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ struct zpc_ec_key {
};

int ec_key_clr2sec(struct zpc_ec_key *ec_key, unsigned int flags,
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);
int ec_key_sec2prot(struct zpc_ec_key *, enum ec_key_sec sec);
int ec_key_check(const struct zpc_ec_key *);
int ec_key_clr2prot(struct zpc_ec_key *ec_key, const unsigned char *privkey,
unsigned int privlen);
size_t privlen);
#endif
Loading