I’m dabbling with AI (starting with ChatGPT, then Gemini) to write and test hardware cryptography.
At first, I wrote the driver as a kernel add-on that works like on BSD systems but with Haiku’s structure.
Now, while continuing the driver development, I’m building an API for simplified use by developers (still to be finished, but basically functional).
The driver is controllable via IOCTL on /dev/crypto/v1.
On loading, it tries to detect the underlying hardware (for now, AES-NI (AMD/Intel), Padlock (VIA), Intel/AMD/VIA RNGs) and adds a software driver as fallback, classifying them by priority.
After preparing the request, you pass it to the driver via ioctl, and the driver chooses which acceleration to use.
The driver has been designed to support a future implementation of PCIe cards like the Intel QuickAssistant, but that’s another story.
For now, in it’s early state, this driver supporta syncronous requests.
Anyway…
The results are promising!
For now there’s a SMAP-friendly version driver that uses the heap(slow) (which integrates a stack-based solution as a SmallBufferOptimization).
A simple benchmark, that encrypts (aes_cbc) the same 100MB data with the driver and with openssl, returns these scores:
~/Progjets/testapps/crypto> ./CryptoBench
— Benchmark (Buffer: 1MB, Iterations: 100) —
OpenSSL: 380.65 ms (Average for 100 MB)
Haiku Driver: 162.46 ms (Average for 100 MB)
Actually it’s ready a faster version that produce a 73ms score.
The code is published in my haiku fork at the CryptoKit-addon
I hope this could be usefull and maybe one day elaborated/copied/restructured and integrated, as it can improve the averall performance of Haiku.