JFLib

plat/rand.rs#

Source: lib/plat/rand.rs

rand -- the operating system's cryptographic random number generator

  fill_random(&mut buf)        BCryptGenRandom (system-preferred RNG) / getrandom(2) / getentropy
                               (Apple) / arc4random_buf (Android: bionic's ChaCha20 generator,
                               seeded by the kernel, every API level)
  random_bytes::<N>() -> [u8; N]          random_u64()

Not in the browser: there the page's crypto.getRandomValues is the source.
There is no fallback: when the system RNG fails the process stops (a key made from weak
randomness is worse than no key).
  • fn fill_random(buf: &mut [u8]) fill a buffer with cryptographically secure random bytes (stops the process on failure)

  • fn random_bytes<const N: usize>() -> [u8; N] N random bytes

  • fn random_u64() -> u64 a random 64-bit number

Source: docs/API.md in the JFLib repository.