CLI-first PKCS#11 test suite with segfault survival, interface forcing, and pytest plugin
Project description
pkcs11-check
CLI-first PKCS#11 test suite with segfault survival, interface forcing, and pytest plugin.
What it does
pkcs11-check runs comprehensive tests against PKCS#11 modules (hardware HSMs, software tokens, smart cards). It catches:
- Crashes and segfaults — per-file subprocess isolation recovers from SIGSEGV
- CKR return code violations — different spec conditions checked against OASIS PKCS#11 standard
- CVE regressions — tests for known CVEs across NSS, SoftHSM2, TPM2, OpenCryptoki
- Security policy violations — Tookan paper vectors, attribute fuzzing, padding oracle detection
- Interface negotiation bugs — v2.40/v3.0/v3.1/v3.2 with automatic fallback
Quick start
# Install
git clone https://github.com/mingulov/pkcs11-check
cd pkcs11-check
uv sync
# Run against SoftHSM2
bash local-builds/build.sh softhsm2
bash local-builds/test.sh softhsm2
# Run against Kryoptic (v3.2 with PQC)
bash local-builds/build.sh kryoptic
bash local-builds/test.sh kryoptic
# Run against system NSS
bash local-builds/test.sh nss-softokn
From PyPI (installed)
pip install pkcs11-check
pkcs11-check fetch-data all # download test vectors (~800 MB)
pkcs11-check test --module /path/to/module.so --pin 1234
Test suite
Test categories:
| Category | Description |
|---|---|
| Core crypto | AES, RSA, ECDSA, EdDSA, HMAC, digest |
| Wycheproof | Edge-case vectors from C2SP |
| PQC (v3.2) | ML-KEM, ML-DSA, SLH-DSA |
| CKR compliance | Return code verification per OASIS spec |
| CVE regression | Known vulnerability tests |
| Security | Attribute fuzz, Tookan, handle reuse |
| Stress | Threading, resource exhaustion |
Supported modules
| Module | Version | Status |
|---|---|---|
| SoftHSM2 | 2.7.0 | Full support |
| Kryoptic | 1.5.0+PQC | Full support (v3.2) |
| NSS softokn | system | Crypto services (slot 0) |
| OpenCryptoki | 3.26 | Docker only |
| pkcs11-mock | 2.0.0 | Stub testing |
| tpm2-pkcs11 | 1.9.0 | Hardware TPM |
| BouncyHSM | 2.0.1 | Docker only |
| qryptotoken | 0.4.1 | Docker only |
Known limitations in v0.1.0
- SO login is not implemented yet, so trusted-certificate import with
CKA_TRUSTED=Trueis not fully covered throughCKU_SOworkflows. - CloudHSM/Thales in-band IV profiles, proxy/loader mutable-parameter preservation checks, and broader mutable-output simulator targets are tracked as post-v0.1.0 interop work.
Architecture
src/pkcs11_check/
raw/ — pure ctypes PKCS#11 binding (v2.40-v3.2, PQC)
cli/ — typer CLI (test, info, version commands)
core/ — module loader, isolation runner, preflight
testcases/ — test files (the product)
ckr/ — CKR return code compliance tests
plugin.py — pytest plugin (markers, fixtures, collection)
fixtures.py — p11_session, p11_module, p11_config
config.py — four-layer config (CLI > env > TOML > defaults)
local-builds/ — build scripts for soft token providers
docker/ — Docker test targets
Key features
pkcs11_check.raw— pure Python ctypes binding with v2.40/v3.0/v3.1/v3.2 interface negotiation, 50+ PQC mechanisms, all 68 standard functions--isolation filemode runs each test file in its own subprocess — crashes don't kill the suite--ckr-strictmode enforces exact OASIS spec CKR codes (not just "any error")- Wycheproof + ACVP vectors — cross-verification against C2SP and NIST test vectors
Documentation
docs/architecture.md— codebase structure and test writing guidedocs/commands.md— build, test, and Docker commandsdocs/module-issues.md— per-module bugs and quirksdocs/mechanism-output-parameters.md— generated IV/nonce/tag output-parameter coveragedocs/docker-provider-results.md— release Docker provider source and result snapshotdocs/todo.md— public roadmap and known limitationsdocs/cve-regression.md— CVE coverage trackerdocs/file-isolation.md— isolation runner designdocs/docker-artifacts.md— Docker test runner contract
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Third-party attributions
pkcs11-check bundles the public-domain PKCS#11 v3.2 header from
latchset/pkcs11-headers, and its fetch-data command downloads test
vectors from C2SP and NIST. See
THIRD_PARTY_LICENSES.md for the full list and
per-source license terms.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pkcs11_check-0.1.0.tar.gz.
File metadata
- Download URL: pkcs11_check-0.1.0.tar.gz
- Upload date:
- Size: 895.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7f175189127926a054eae9b5deb0d1a3a0920bec139a09d8523778eaee37e9c
|
|
| MD5 |
c93f7011f1948033a4d17a7279efb3dd
|
|
| BLAKE2b-256 |
5c4064adc120e7a07ace02e7f88dbbd588487bd43d36e06c3d6fa66ed504ae7b
|
Provenance
The following attestation bundles were made for pkcs11_check-0.1.0.tar.gz:
Publisher:
publish.yml on mingulov/pkcs11-check
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pkcs11_check-0.1.0.tar.gz -
Subject digest:
f7f175189127926a054eae9b5deb0d1a3a0920bec139a09d8523778eaee37e9c - Sigstore transparency entry: 1547079671
- Sigstore integration time:
-
Permalink:
mingulov/pkcs11-check@e93ee6521f90756e8ec9158445408f359f83c40a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mingulov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e93ee6521f90756e8ec9158445408f359f83c40a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pkcs11_check-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pkcs11_check-0.1.0-py3-none-any.whl
- Upload date:
- Size: 924.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa98f25672c75f490f8a2a0ef868cb1599b2ef32893d133960140b8ea608263a
|
|
| MD5 |
1e8779c8eefe9d699f382e11e635e0c0
|
|
| BLAKE2b-256 |
80c9395e84e41391accd808721f9723f72265d8fb2a5050ef1d5c7f13908680c
|
Provenance
The following attestation bundles were made for pkcs11_check-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mingulov/pkcs11-check
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pkcs11_check-0.1.0-py3-none-any.whl -
Subject digest:
aa98f25672c75f490f8a2a0ef868cb1599b2ef32893d133960140b8ea608263a - Sigstore transparency entry: 1547079680
- Sigstore integration time:
-
Permalink:
mingulov/pkcs11-check@e93ee6521f90756e8ec9158445408f359f83c40a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mingulov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e93ee6521f90756e8ec9158445408f359f83c40a -
Trigger Event:
workflow_dispatch
-
Statement type: