Arduino Cryptography Library
|
Abstract base class for random noise sources. More...
#include <NoiseSource.h>
Public Member Functions | |
NoiseSource () | |
Constructs a new random noise source. | |
virtual | ~NoiseSource () |
Destroys this random noise source. | |
virtual bool | calibrating () const =0 |
Determine if the noise source is still calibrating itself. More... | |
virtual void | stir ()=0 |
Stirs entropy from this noise source into the global random number pool. More... | |
virtual void | added () |
Called when the noise source is added to RNG with RNG.addNoiseSource(). More... | |
Protected Member Functions | |
virtual void | output (const uint8_t *data, size_t len, unsigned int credit) |
Called from subclasses to output noise to the global random number pool. More... | |
Abstract base class for random noise sources.
Definition at line 29 of file NoiseSource.h.
|
virtual |
Called when the noise source is added to RNG with RNG.addNoiseSource().
This function is intended for noise source initialization tasks that must be performed after RNG.begin() has been called to initialize the global random number pool. For example, if the noise source has a unique identifier or serial number then this function can stir it into the pool at startup time.
Definition at line 95 of file NoiseSource.cpp.
|
pure virtual |
Determine if the noise source is still calibrating itself.
Noise sources that require calibration start doing so at system startup and then switch over to random data generation once calibration is complete. Since no random data is being generated during calibration, the output from RNG.rand() may be predictable. Use RNG.available() to determine when sufficient entropy is available to generate good random values.
It is possible that the noise source never exits calibration. This can happen if the input voltage is insufficient to trigger noise or if the noise source is not connected. Noise sources may also periodically recalibrate themselves.
Implemented in TransistorNoiseSource, and RingOscillatorNoiseSource.
|
protectedvirtual |
Called from subclasses to output noise to the global random number pool.
data | Points to the noise data. |
len | Number of bytes of noise data. |
credit | The number of bits of entropy to credit for the data. Note that this is bits, not bytes. |
The default implementation of this function calls RNG.stir() to add the entropy from this noise source to the global random number pool.
This function may be overridden by subclasses to capture the raw output from the noise source before it is mixed into the pool to allow the raw data to be analyzed for randomness.
Definition at line 117 of file NoiseSource.cpp.
|
pure virtual |
Stirs entropy from this noise source into the global random number pool.
This function should call output() to add the entropy from this noise source to the global random number pool.
The noise source should batch up the entropy data, providing between 16 and 48 bytes of data each time. If the noise source does not have sufficient entropy data at the moment, it should return without stiring the current data in.
Implemented in TransistorNoiseSource, and RingOscillatorNoiseSource.