Module rustkey::trng

source ·
Expand description

trng is the module for the true-RNG. Note that this RNG is not guaranteed cryptographically- secure and it is recommended to mix the entropy from the TRNG with cryptographically-suitable mechanisms.

Entropy is produced at a rate of approximately 66.6 times per second.

Constants§

  • TRNG_BIT_READY is the bit (index) that hosts the ready-indicator.
  • TRNG_ENTROPY is the address for the TRNG entropy-source.
  • TRNG_FLAG_READY is the mask value for selecting specifically the ‘ready’-bit.
  • TRNG_STATUS the address that hosts the bit indicating whether the entropy-source is ready.

Functions§

  • gather reads entropy from the TRNG as it becomes ready and fills the provided buffer, blocking as it waits for new entropy to become available. The TRNG rate of production is about 66.6 times per second. This function should be used sparingly, if at all.
  • read reads data from the TRNG entropy location, regardless of whether new entropy is available. (Check ready to check availability.)
  • read_bytes reads data, as 4 bytes, from the entropy source, regardless of whether new entropy is available. (Check ready for availability.)
  • read_bytes_next waits for the TRNG to become ready then reads the available entropy from the entropy source.
  • read_next waits for the TRNG to become ready then reads the available entropy from the entropy source.
  • ready returns true iff new entropy is available.
  • wait waits for the entropy source to become ready. (blocking)