Timings for random

Kurt Roeckx kurt at roeckx.be
Sat Jan 28 22:18:01 UTC 2017


On Sat, Jan 28, 2017 at 12:48:34PM -0800, Gary E. Miller wrote:
> Yo Hal!
> 
> On Sat, 28 Jan 2017 12:39:02 -0800
> Hal Murray <hmurray at megapathdsl.net> wrote:
> 
> > Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz
> > Stdlib: 1000000 calls to rand() took 0.021 microseconds each
> > Sodium: 1000000 calls to randombytes_buf() took 0.367 microseconds
> > each 
> > OpenSSL: 1000000 calls to RAND_pseudo_bytes() took 0.630
> > microseconds each
> 
> rand() and RAND_pseudo_rand() are not random, just psuedo random, thus
> not for NTP.

I have no idea what you're using random numbers for, but if
unpredicable is what you want rand() is probably not what you
want.

> What about the OpenSSL RAND_bytes()?

RAND_pseudo_rand() has been deprecated anyway. The only difference
in behaviour was when it didn't get seeded properly.


Kurt



More information about the devel mailing list