I last used Haskell about 5 years ago and had not kept up with it since. With so much new systems work happening in Rust, I wanted to revisit Haskell and explore its strengths in a practical project.
The result is Haskoki, a PKCS#11 software token, now at version 0.5 (PKCS#11 is a standard API that lets applications use cryptographic keys and operations provided by hardware or software ‘tokens’).
It is a playground for testing clients and experimenting with features, not a production HSM. The goal was to explore as much of the latest PKCS#11 standard (3.2) as possible, including post-quantum cryptography and legacy algorithms available through OpenSSL, which handles the cryptography while Haskell models sessions, objects, permissions and operation states behind a C interface.
Overall, my experience is positive. But FFI, native resource lifetimes and runtime concurrency took more work than I expected - really much more. For example, I encountered intermittent hangs that appear related to GHC issue #27272.
And to be honest - by github stats, just 65.6% of code is in Haskell, and C - 20.1%.
Development was heavily AI-assisted, with me directing the design and reviewing the results. I have documented that process separately: timeline and cost. Briefly, the work took roughly 1 month with agents running almost 24/7, and used about 20 billion tokens (mostly cached, but still equivalent to roughly $5,000 at API prices, not my actual spending).
There is a Docker demo, so you can try it without installing Haskell or building anything. I would especially welcome feedback on the Haskell design and the first-run experience.
Try it - link to Docker demo info
And one more warning - this is not a production HSM. Securely storing or protecting sensitive information, whether on disk or in memory, was never a goal.