Skip to content

Sign with CA keys held on a PKCS #11 HSM - #33

Merged
JoeShook merged 3 commits into
mainfrom
pkcs11-provider
Nov 10, 2026
Merged

JoeShook merged 3 commits into
mainfrom
pkcs11-provider

Conversation

@JoeShook

Copy link
Copy Markdown
Owner

Adds Sigyll.Pkcs11, a signing provider (pkcs11) for CA keys held on a PKCS #11 HSM, built on Pkcs11Interop 5.3.0 (Apache-2.0, released 2025-02-02). SoftHSM stands in for the HSM in development and CI.

Provider

  • Keys are generated on the token as sensitive and never extractable (RSA; ECDSA P-256/384/521). Signing happens on the token: RSA PKCS Post-quantum certificate issuance #1 v1.5, and ECDSA with DER-encoded signatures.
  • A key is recorded as HSM-held (Fips1403) only when Pkcs11:HardwareProtected is set, the token is not SoftHSM, and the key's attributes show it was generated on the token and can never leave it. Otherwise it is recorded as software-protected, so a trust domain that requires HSM-held CA keys refuses it.
  • Configured by Pkcs11:LibraryPath, TokenLabel, UserPin (from a secret store, never appsettings) and HardwareProtected. Deleting a certificate's key destroys it on the token.
  • On Linux, Pkcs11Interop's libdl is resolved to libdl.so.2, which is all glibc 2.34+ (Ubuntu 24.04, the .NET images) installs without developer packages.

Elsewhere

  • Issuance reads any provider:key reference for an issuing CA instead of listing providers by name.
  • Vault Transit states its keys are software-protected instead of relying on the default.
  • Both Dockerfiles copy the new project; the issuance dialog names the pkcs11 option.
  • Docs: AUDIT-READINESS, SECURITY-ARCHITECTURE, FEATURES, ROADMAP, CLAUDE.md.

Tests

  • CI installs SoftHSM (Ubuntu's 2.6.1) and runs the token tests. Without SoftHSM they skip.
  • tools/softhsm/run-token-tests.ps1 runs them from Windows in the pinned .NET SDK container.
  • Token tests (9): private keys made on the token and never extractable (RSA, ECDSA); RSA and ECDSA P-256/P-384 signatures that verify; a token root that issues a certificate whose chain validates and signs a valid CRL; a destroyed key can't sign; SoftHSM recorded as software-protected even when hardware is claimed; a SoftHSM root refused where CA keys must be in an HSM.
  • Encoding tests (9, no token): curve OIDs, EC points wrapped or bare, P1363 to DER, SoftHSM detection.
  • All 18 pass against SoftHSM 2.6.1 in the container; the full suite passes locally (526, with the 7 token tests skipped).

Not yet

  • Running Sigyll itself with pkcs11 under the AppHost (a development image with SoftHSM, and where the dev token's PINs come from).
  • Where the production user PIN comes from (Vault KV is the likely place).
  • Tests against the chosen HSM model.

🤖 Generated with Claude Code

https://claude.ai/code/session_015WNuLiokmqeoddhdh8X3As

JoeShook and others added 3 commits November 9, 2026 16:22
Adds Sigyll.Pkcs11, a signing provider ("pkcs11") built on
Pkcs11Interop 5.3.0 (Apache-2.0) that loads the HSM vendor's PKCS #11
library, or SoftHSM in development and CI.

- Keys are generated on the token as sensitive and never extractable
  (RSA, ECDSA P-256/384/521); signing happens on the token with RSA
  PKCS #1 v1.5 or ECDSA, whose signatures are returned DER-encoded.
- A key is recorded as HSM-held (Fips1403) only when
  Pkcs11:HardwareProtected is set, the token is not SoftHSM, and the
  key's own attributes show it was generated on the token and can
  never leave it; otherwise it is recorded as software-protected, so a
  trust domain requiring HSM-held CA keys refuses it.
- Configured by Pkcs11:LibraryPath, TokenLabel, UserPin (from a secret
  store, never appsettings) and HardwareProtected. Deleting a
  certificate's key destroys it on the token.
- Issuance reads any "provider:key" reference for an issuing CA
  instead of listing providers by name.
- Vault Transit now states its keys are software-protected rather than
  relying on the default.
- On Linux, Pkcs11Interop's "libdl" is resolved to libdl.so.2, which is
  all glibc 2.34+ installs without developer packages.
- CI installs SoftHSM and runs the token tests: keys made on the token
  and never extractable, RSA and ECDSA signatures that verify, a token
  root that issues a certificate whose chain validates and signs a
  valid CRL, destroyed keys, and SoftHSM never counting as hardware.
  Without SoftHSM the token tests skip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015WNuLiokmqeoddhdh8X3As
SoftHSM has no maintained Windows build, so tools/softhsm/run-token-tests.ps1
runs the token tests in the .NET SDK image the Sigyll Dockerfile pins,
with SoftHSM from Ubuntu. The repository is mounted read-only and
copied, so nothing is installed on the machine and no build output
lands in the working tree. .gitattributes keeps shell scripts LF so
they run in the container from a Windows checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015WNuLiokmqeoddhdh8X3As
…e as a file

Its package declares the licence as LICENSE.txt rather than an SPDX expression, so the BOM records no licence. The file is the Apache License 2.0 (checked in 5.3.0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015WNuLiokmqeoddhdh8X3As
@JoeShook
JoeShook merged commit b7c0dca into main Nov 10, 2026
5 checks passed
@JoeShook
JoeShook deleted the pkcs11-provider branch November 10, 2026 20:20
@JoeShook
JoeShook restored the pkcs11-provider branch November 10, 2026 20:20
@JoeShook
JoeShook deleted the pkcs11-provider branch November 10, 2026 20:21
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