Add pkcs11 provider backend pkcs11_dynload - #168
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new PKCS#11 backend shim (pkcs11_dynload) intended to let the S-CORE PKCS#11 provider load an external/platform PKCS#11 module at runtime via dlopen(), while compiling against a selectable pkcs11.h header provider.
Changes:
- Adds a new
third_party/pkcs11_dynloadpackage with aC_GetFunctionListdynload shim and a Bazel build setting for selecting PKCS#11 header sources. - Documents usage of the dynloader and header-provider abstraction in a new README.
- Updates
MODULE.bazel.lock(lockfile regeneration).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| third_party/pkcs11_dynload/pkcs11_dynload.cpp | Adds the runtime dynloader shim exporting C_GetFunctionList() and loading the real module via dlopen(). |
| third_party/pkcs11_dynload/BUILD | Defines build setting + targets for selecting header providers and building the dynload shim library. |
| third_party/pkcs11_dynload/provider.bzl | Adds a small Starlark helper for publishing PKCS#11 headers in a uniform shape. |
| third_party/pkcs11_dynload/README.md | Documents configuration/usage, including selecting header providers and setting the module path. |
| MODULE.bazel.lock | Lockfile delta from Bazel module dependency resolution. |
Suppressed comments (1)
third_party/pkcs11_dynload/pkcs11_dynload.cpp:62
- After requiring
PKCS11_LIBto be a string literal, initializelibPathdirectly from the macro (the currentEXPANDTOSTRING(PKCS11_LIB)will no longer compile and is not needed).
std::string libPath{EXPANDTOSTRING(PKCS11_LIB)};
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
According to #134 , we are also supposed to document the AoU. Is at also part of this? |
ChansAlive
left a comment
There was a problem hiding this comment.
Initial review points
sunildevda
left a comment
There was a problem hiding this comment.
thanks for the changes. looks good for me too.
|
Documentation preview for this pull request is available at: |
There was a problem hiding this comment.
Minor doc fix.
Since no test is running in pipeline using the proposed backend, have tested it locally for the softhsm as the lib to be dynamically loaded. Test passed for pkcs11 provider test in linux.
For qnx, the path to the library had to be adapted to fit with the deployment. This however could be resolved when path is later obtained from the configuration.
Signed-off-by: Athul Mallappallil <80528108+ChansAlive@users.noreply.github.com>
This PR adds a new pkcs11 backend "pkcs11_dynload" to the S-CORE pkcs11 provider.
pkcs11_dynload loads a PKCS#11 module at runtime via dlopen(). It compiles against a selected pkcs11.h header set provided by one of several interchangeable PKCS#11 header providers. pkcs11_dynload is based on the backend integration mechanism introduced with PR92. pkcs11_dynload does not require changes of the S-CORE pkcs11 provider.
The main use case of pcks11_dynload is to enable the S-CORE pkcs11 provider to use a pkcs11 module coming from the platform, not from the S-CORE build. This may be necessary in cases where the pkc11 module is not fully open source, e.g., NXP pkcs11-hse.
More information on how to use pkcs11_dynload is available in third_party/pkcs11_dynload/README.md.
Simple example: use platform SoftHSMv2 (/usr/lib/softhsm/libsofthsm2.so):
By default, pkcs11_dynload is compiled against pkcs11.h extracted from @softhsm_source//:all.
The location of the pkcs11 module to be loaded must be provided by
Without definition of PKCS11_LIB, pkcs11_dynload will not compile.
closes #134