Getting an open-source hardware security module over the line
NetHSM shipped as the first fully open-source hardware security module, with its entire network and application stack written in OCaml.
NetHSM had been eight years in the making and was nearly there. Tarides joined to close the gap between a working prototype and a product people could buy.
- Unikernel footprint
- ~30 MB
- Languages with client SDKs
- 35
- Contributing since
- 2022
Outcome
NetHSM shipped. It is the first fully open-source hardware security module: the firmware, the cryptographic core and the tooling are all published, so a buyer can audit the device they are trusting with their keys rather than take a vendor's word for it.
The whole stack above the separation kernel - TCP/IP, HTTP, TLS and the application itself - is written in OCaml from scratch. The resulting unikernel is around 30 MB, which is small enough that reading it is a realistic thing to ask of an auditor.
Robur and Nitrokey had designed and built the core by the time Tarides joined in mid-2022. What was left was the work that decides whether a product ships, including outstanding defects in networking and the endpoint interfaces, caching to reach the promised throughput, and a test suite you could release against.
Approach
The security-critical component is Keyfender, a MirageOS unikernel. It serves the NetHSM API, performs every cryptographic operation, and is the only part of the system with decrypted access to the key store. Work on it is therefore constrained in a specific way, and there is no part of it where a mistake is cheap.
Tarides worked inside Nitrokey's own repository and review process. The networking and endpoint fixes were the kind that only surface once a system is exercised in earnest, and each had to be made without disturbing the guarantees the rest of the design depends on.
Caching was added to meet the throughput the product needed, and the test suite was extended so that regressions in a component of this sensitivity would be caught before a release rather than after one.
Challenge
An HSM is bought precisely because it is the thing you do not have to trust blindly. That makes an open-source HSM a more difficult product than a closed one since every claim it makes is checkable, so none of them can be approximate.
NetHSM's design stacks guarantees rather than asserting them. At the lowest level the Muen separation kernel is formally verified to be free of runtime errors. The elliptic-curve code is derived from fiat-crypto, which generates primitives proved correct. Above both sits Keyfender, where memory safety comes from OCaml rather than from review discipline.
The remaining work was small in volume and tightly constrained. Every change had to leave the properties above it intact, which is a different kind of difficulty from building something new, and a slower one than the size of the work suggests.
Have a similar challenge?
Let's talk about how we can help you build something reliable, secure, and fast.
