← all projects
Work2026· Lead developer
Software & physical HSM integration
Connected the KMS to SoftHSM2 and two physical HSMs (HyperSecu HYP2003 and SmartCard-HSM), with a three-tier access model and PINs that are never stored.
- Rust
- PKCS#11
- PKCS#15
- SoftHSM2
- OpenSC
- libusb
- Docker
01//problem
Hardware-protected keys require the KMS to talk to vendor-specific PKCS#11 libraries and USB devices from inside Docker, stay safe under concurrent requests, and never persist HSM PINs.
02//solution
Added multi-slot SoftHSM2 support, loaded vendor PKCS#11 libraries dynamically (dlopen) behind a vendor-catalog abstraction, passed USB devices and the pcscd socket into Docker, and designed a three-tier RBAC model with a per-request PIN.
03//result
New HSM vendors can be added without recompiling, and PINs never touch disk or environment variables.
Architecture
Technical details
- SoftHSM2 multi-slot support with slot-ownership enforcement and ghost-key cleanup
- LRU object-handle cache to cut C_FindObjects round-trips, and mutex serialization against interleaved concurrent requests
- HyperSecu HYP2003 in BUDDY mode via the vendor PKCS#11 library and direct libusb access, supporting AES-128/192/256 and RSA-1024/2048
- SmartCard-HSM via OpenSC's PKCS#15 library, including driver configuration for a non-standard device
- Three-tier physical-HSM RBAC: management / crypto / readonly