tillitis / tkey-libs

TKey device libs
GNU General Public License v2.0
4 stars 2 forks source link

Add DRBG/CSPRNG functionality #46

Open secworks opened 4 months ago

secworks commented 4 months ago

Currently the Tkey sports a TRNG. There is also an app, The Tkey random generator that implements a proper Digital Bit Random Generator (DRBG), also known as a Secure Random Number Generator (CSPRNG). Basically an implementation of Hash-DRBG using the Blake2s hash function.

We want to help app developers to know shoot themselves in the foot. One potential foot gun is using the TRNG directly for deriving things related to security - keys for example. In a future when we have more resources, I would love to move a DRBG-functionality into the HW (similar to what we did in the Cryptech HSM project).

But just adding the functionality of the RNG app into tkey-libs would make it much easier for app developers to do the right thing. This would also improve RND capacity for the apps (since most RND will be generated by the DRBG, not the TRNG).

One could also look at the secure RNG added to the Go std lib for inspiration. The point is, we should provide functions to do this. One issue may be how RNG context is to be handled. Should the lib create an internal context, or should the app create a context (by calling a drbg_init() function for example)?