Skip to content

Change isc_random() to be just PRNG, and add isc_nonce_buf() that uses CSPRNG

Ondřej Surý requested to merge 289-add-non-cs-prng into master

As discovered by @each and our QA, the (SYS_)getrandom() is very slow due syscalls. And even though using CSPRNG is better, we actually don't need CSPRNG at many places (only for generating nonces at few places).

This MR changes isc_random() API to use xoroshiro128** and adds isc_nonce_buf() function; therefore isc_random() family of functions MUST NOT be used for generating secrets.

The MR also makes more extensive use of isc_random_uniform() in places where the code looked like isc_random() % n. The isc_random_uniform() might be (randomly) slower than using plain modulo, but it has better (uniform) distribution of random numbers. This needs to be carefully reviewed.

Closes #289 (closed)

Edited by Ondřej Surý

Merge request reports