Expand description
Bytes nobody can guess, from the operating system.
crate::rng is the generator everything else in the engine uses and it is
deliberately not this: it is nine lines of arithmetic on a seed, so a trial
that fails can be run again and SPOP can be tested. ACL GENPASS is the
one caller that wants the opposite property. It hands a client a password
that is going to guard a server, so the whole value of it is that the next
one cannot be worked out from the last one, and a seeded stream fails that
by construction.
So this asks the system, which is the only thing on the machine that is
collecting real entropy. /dev/urandom on unix and BCryptGenRandom on
Windows, both of which are the documented interface rather than the clever
one, and neither of which needs a handle opened up front or a fallback for
being called early.
There is no error path. A machine whose random device cannot be read is a machine that cannot keep a secret, and handing back a password anyway, filled with whatever was in the buffer, is worse than stopping. So this panics, which is the same call every serious implementation of this makes.
Functions§
- fill
- Fill
intowith bytes from the system’s random source.