14 #ifndef __DECAF_SPONGERNG_HXX__ 15 #define __DECAF_SPONGERNG_HXX__ 20 #include <sys/types.h> 24 #if __cplusplus >= 201103L 25 #define DECAF_NOEXCEPT noexcept 26 #define DECAF_DELETE = delete 28 #define DECAF_NOEXCEPT throw() 52 const char *
const what_;
56 const char *
what() const DECAF_NOEXCEPT {
return what_; }
69 if (!decaf_successful(ret)) {
75 inline void stir(
const Block &data ) DECAF_NOEXCEPT {
80 inline ~SpongeRng() DECAF_NOEXCEPT { decaf_spongerng_destroy(sp); }
86 #if __cplusplus >= 201103L void DECAF_API_VIS decaf_spongerng_init_from_buffer(decaf_keccak_prng_t prng, const uint8_t *__restrict__ in, size_t len, int deterministic) DECAF_NONNULL
Initialize a sponge-based CSPRNG from a buffer.
const int err_code
errno that caused the reseed to fail.
Definition: spongerng.hxx:55
void DECAF_API_VIS decaf_spongerng_next(decaf_keccak_prng_t prng, uint8_t *__restrict__ out, size_t len)
Output bytes from a sponge-based CSPRNG.
Exception thrown when The RNG fails (to seed itself)
Definition: spongerng.hxx:49
decaf_error_t DECAF_API_VIS decaf_spongerng_init_from_file(decaf_keccak_prng_t prng, const char *file, size_t len, int deterministic) DECAF_NONNULL DECAF_WARN_UNUSED
Initialize a sponge-based CSPRNG from a file.
decaf_error_t
Another boolean type used to indicate success or failure.
Definition: common.h:120
RngException(int err_code, const char *what_) DECAF_NOEXCEPT
Construct.
Definition: spongerng.hxx:57
A reference to a writable block of data.
Definition: secure_buffer.hxx:264
Prototype of a random number generator.
Definition: secure_buffer.hxx:138
const char * what() const DECAF_NOEXCEPT
Description of exception.
Definition: spongerng.hxx:56
virtual void read(Buffer buffer) DECAF_NOEXCEPT=0
Read into a Buffer.
Sponge-based random-number generator.
Definition: spongerng.hxx:36
virtual void read(Buffer buffer) DECAF_NOEXCEPT
Read data to a buffer.
Definition: spongerng.hxx:85
Deterministic
Deterministic flag.
Definition: spongerng.hxx:46
void DECAF_API_VIS decaf_spongerng_stir(decaf_keccak_prng_t prng, const uint8_t *__restrict__ in, size_t len) DECAF_NONNULL
Stir entropy data into a sponge-based CSPRNG from a buffer.
decaf_keccak_prng_s decaf_keccak_prng_t[1]
Keccak CSPRNG structure as one-element array.
Definition: spongerng.h:27
void stir(const Block &data) DECAF_NOEXCEPT
Stir in new data.
Definition: spongerng.hxx:75
A reference to a block of data, which (when accessed through this base class) is const.
Definition: secure_buffer.hxx:159
~SpongeRng() DECAF_NOEXCEPT
Securely destroy by overwriting state.
Definition: spongerng.hxx:80
SpongeRng(const std::string &in="/dev/urandom", size_t len=32, Deterministic det=RANDOM)
Initialize, non-deterministically by default, from C/C++ filename.
Definition: spongerng.hxx:66
SpongeRng(const Block &in, Deterministic det)
Initialize, deterministically by default, from block.
Definition: spongerng.hxx:61
const unsigned char * data() const DECAF_NOEXCEPT
Get const data.
Definition: secure_buffer.hxx:193
Namespace for all libdecaf C++ objects.
Definition: ed255.hxx:41
size_t size() const DECAF_NOEXCEPT
Get the size.
Definition: secure_buffer.hxx:202