Loading...
Searching...
No Matches
spongerng.h
Go to the documentation of this file.
#ifndef __DECAF_SPONGERNG_H__
#define __DECAF_SPONGERNG_H__
#include <decaf/shake.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
decaf_keccak_sponge_t sponge;
} decaf_keccak_prng_s;
typedef decaf_keccak_prng_s decaf_keccak_prng_t[1];
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;
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;
decaf_error_t DECAF_API_VIS decaf_spongerng_init_from_dev_urandom (
decaf_keccak_prng_t prng
) DECAF_WARN_UNUSED;
void DECAF_API_VIS decaf_spongerng_next (
decaf_keccak_prng_t prng,
uint8_t * __restrict__ out,
size_t len
);
void DECAF_API_VIS decaf_spongerng_stir (
decaf_keccak_prng_t prng,
const uint8_t * __restrict__ in,
size_t len
) DECAF_NONNULL;
static DECAF_INLINE void
decaf_spongerng_destroy (
decaf_keccak_prng_t doomed
);
/***************************************/
/* Implementations of inline functions */
/***************************************/
void decaf_spongerng_destroy (decaf_keccak_prng_t doomed) {
decaf_sha3_destroy(doomed->sponge);
}
/* internal */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __DECAF_SPONGERNG_H__ */
decaf_error_t
decaf_error_t
Another boolean type used to indicate success or failure.
Definition common.h:120
shake.h
SHA2-512.
decaf_sha3_destroy
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.
decaf_keccak_sponge_t
struct decaf_keccak_sponge_s decaf_keccak_sponge_t[1]
Convenience GMP-style one-element array version.
Definition shake.h:33
decaf_spongerng_init_from_buffer
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.
decaf_spongerng_next
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_spongerng_init_from_dev_urandom
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.
decaf_spongerng_init_from_file
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_spongerng_stir
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_t
decaf_keccak_prng_s decaf_keccak_prng_t[1]
Keccak CSPRNG structure as one-element array.
Definition spongerng.h:27
decaf_keccak_prng_s
Keccak CSPRNG structure as struct.
Definition spongerng.h:22
decaf_keccak_prng_s::sponge
decaf_keccak_sponge_t sponge
Internal sponge object.
Definition spongerng.h:23