libdecaf
spongerng.h
Go to the documentation of this file.
1 
12 #ifndef __DECAF_SPONGERNG_H__
13 #define __DECAF_SPONGERNG_H__
14 
15 #include <decaf/shake.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
22 typedef struct {
25 
28 
30 void DECAF_API_VIS decaf_spongerng_init_from_buffer (
31  decaf_keccak_prng_t prng,
32  const uint8_t *__restrict__ in,
33  size_t len,
34  int deterministic
35 ) DECAF_NONNULL;
36 
44  decaf_keccak_prng_t prng,
45  const char *file,
46  size_t len,
47  int deterministic
48 ) DECAF_NONNULL DECAF_WARN_UNUSED;
49 
57  decaf_keccak_prng_t prng
58 ) DECAF_WARN_UNUSED;
59 
61 void DECAF_API_VIS decaf_spongerng_next (
62  decaf_keccak_prng_t prng,
63  uint8_t * __restrict__ out,
64  size_t len
65 );
66 
68 void DECAF_API_VIS decaf_spongerng_stir (
69  decaf_keccak_prng_t prng,
70  const uint8_t * __restrict__ in,
71  size_t len
72 ) DECAF_NONNULL;
73 
75 static DECAF_INLINE void
76 decaf_spongerng_destroy (
77  decaf_keccak_prng_t doomed
78 );
79 
81 /***************************************/
82 /* Implementations of inline functions */
83 /***************************************/
84 void decaf_spongerng_destroy (decaf_keccak_prng_t doomed) {
85  decaf_sha3_destroy(doomed->sponge);
86 } /* internal */
88 
89 #ifdef __cplusplus
90 } /* extern "C" */
91 #endif
92 
93 #endif /* __DECAF_SPONGERNG_H__ */
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.
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.
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
decaf_keccak_sponge_t sponge
Internal sponge object.
Definition: spongerng.h:23
Keccak CSPRNG structure as struct.
Definition: spongerng.h:22
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.
struct decaf_keccak_sponge_s decaf_keccak_sponge_t[1]
Convenience GMP-style one-element array version.
Definition: shake.h:33
decaf_keccak_prng_s decaf_keccak_prng_t[1]
Keccak CSPRNG structure as one-element array.
Definition: spongerng.h:27
decaf_error_t DECAF_API_VIS decaf_spongerng_init_from_dev_urandom(decaf_keccak_prng_t prng) DECAF_WARN_UNUSED
Initialize a nondeterministic sponge-based CSPRNG from /dev/urandom.
SHA2-512.
void DECAF_API_VIS decaf_sha3_destroy(decaf_keccak_sponge_t sponge)
Destroy a DECAF_SHA3 or DECAF_SHAKE sponge context by overwriting it with 0.