Skip to main content

Module xorshift32

Module xorshift32 

Source
Expand description

Xorshift32 PRNG helpers shared by RTOS platform crates that lack a hardware RNG.

The state is owned by the caller (typically a static mut inside the platform crate), so multiple platforms can share these helpers without the API crate carrying mutable state.

Quality is sufficient for zenoh session-ID seeding — not for cryptography. Pair with hardware entropy at boot (clock, MAC address, ADC noise) via seed().

Constants§

DEFAULT_SEED
Default seed used when entropy is unavailable. Xorshift cannot escape an all-zero state, so callers that pass 0 to seed fall back to this value.

Functions§

next
Advance state by one step and return the new value.
random_fill
Fill buf[..len] with bytes derived from xorshift32 output. No-op if buf is null.
seed
Replace state with value, falling back to DEFAULT_SEED if value == 0.
step
One xorshift32 step. Pure function — caller manages the state cell.