Skip to content

PKCS #11 relay: reach SoftHSM over TCP for development and tests - #53

Merged
JoeShook merged 2 commits into
mainfrom
pkcs11-relay
Nov 13, 2026
Merged

JoeShook merged 2 commits into
mainfrom
pkcs11-relay

Conversation

@JoeShook

Copy link
Copy Markdown
Owner

What

tools/pkcs11-relay: a stand-in for a network HSM.

It forwards the 23 functions Sigyll and its tests use. A lost connection is reported as CKR_DEVICE_REMOVED.

Why

SoftHSM has no maintained Windows build, so Sigyll running on Windows had no PKCS #11 token to load. With the relay it uses SoftHSM in a container, through the Windows form of PKCS #11 (4-byte CK_ULONG, packed structures) that a vendor's Windows library uses.

Tested

  • Windows: ./tools/pkcs11-relay/run-token-tests.ps1 — 18 of 18 PKCS Bump the microsoft group with 18 updates #11 tests pass through the DLL, tests and provider unchanged.
  • Linux (container): the same 18 pass with the client built as a .so.

CI

  • PKCS Bump the microsoft group with 18 updates #11 over the network (Ubuntu): builds the client, starts the server container, runs the token tests through it, and fails if the server never saw a connection.
  • Relay client for Windows: builds the DLL and keeps it as an artifact. Not tested there: Windows runners cannot run the Linux container.

Notes

  • Development and tests only: the connection is not encrypted or authenticated. The README says so.
  • The projects are not in Sigyll.slnx; nothing here ships with Sigyll.
  • README has the diagrams (parts, one call end to end, CI).

🤖 Generated with Claude Code

https://claude.ai/code/session_015WNuLiokmqeoddhdh8X3As

JoeShook and others added 2 commits November 13, 2026 14:57
Sigyll loads an HSM vendor's PKCS #11 library into its own process, and
with a network HSM that library hides the connection. SoftHSM has no
maintained Windows build, so a Sigyll running on Windows had no token to
load at all.

tools/pkcs11-relay recreates the network arrangement for development and
tests: a client library, built from C# with Native AOT and loaded like
any PKCS #11 library, forwards each call over TCP to a server that passes
it to SoftHSM in a container. It forwards the 23 functions Sigyll and its
tests use; the rest answer CKR_FUNCTION_NOT_SUPPORTED. A lost connection
is reported as CKR_DEVICE_REMOVED.

The existing PKCS #11 tests pass through it unchanged, on Windows
(run-token-tests.ps1) and on Linux. CI runs them through the relay on
Ubuntu and builds the Windows DLL.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015WNuLiokmqeoddhdh8X3As
@JoeShook
JoeShook merged commit baaad06 into main Nov 13, 2026
7 checks passed
@JoeShook
JoeShook deleted the pkcs11-relay branch November 20, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant