LibISAAC  1.0.0
A modern reimplementation of the ISAAC CPRNG.
isaac.h
Go to the documentation of this file.
1 
49 #ifndef ISAAC_H
50 #define ISAAC_H
51 
52 #ifdef __cplusplus
53 extern "C"
54 {
55 #endif
56 
60 #define LIBISAAC_VERSION "1.0.0"
61 
62 #include <stdint.h>
63 #include <stddef.h>
64 
77 #ifndef ISAAC_BITS
78  #define ISAAC_BITS 64
79 #endif
80 #if (ISAAC_BITS == 32)
81 typedef uint32_t isaac_uint_t;
82 #elif (ISAAC_BITS == 64)
83 typedef uint64_t isaac_uint_t;
84 #else
85 _Static_assert(0, "ISAAC: only 32 or 64 bit words are supported.");
86 #endif
87 
91 #define ISAAC_ELEMENTS 256U
92 
96 #define ISAAC_SEED_MAX_BYTES ISAAC_ELEMENTS
97 
105 typedef struct
106 {
126 } isaac_ctx_t;
127 
172 void isaac_init(isaac_ctx_t* ctx, const uint8_t* seed, uint16_t seed_bytes);
173 
197 void isaac_stream(isaac_ctx_t* ctx, isaac_uint_t* ints, size_t amount);
198 
210 void isaac_cleanup(isaac_ctx_t* ctx);
211 
225 void isaac_to_little_endian(uint8_t* bytes,
226  const isaac_uint_t* values,
227  size_t amount_of_values);
228 
242 void isaac_to_big_endian(uint8_t* bytes,
243  const isaac_uint_t* values,
244  size_t amount_of_values);
245 
246 
247 #ifdef __cplusplus
248 }
249 #endif
250 
251 #endif /* ISAAC_H */
isaac_ctx_t::stream_index
isaac_uint_t stream_index
Index of the next value to output in the stream.
Definition: isaac.h:125
isaac_uint_t
uint64_t isaac_uint_t
Definition: isaac.h:83
isaac_to_little_endian
void isaac_to_little_endian(uint8_t *bytes, const isaac_uint_t *values, size_t amount_of_values)
Utility function, converting an array of 32-bit/64-bit integers into bytes using little endian byte o...
isaac_to_big_endian
void isaac_to_big_endian(uint8_t *bytes, const isaac_uint_t *values, size_t amount_of_values)
Utility function, converting an array of 32-bit/64-bit integers into bytes using big endian byte orde...
isaac_cleanup
void isaac_cleanup(isaac_ctx_t *ctx)
Safely erases the context.
ISAAC_ELEMENTS
#define ISAAC_ELEMENTS
Amount of elements in ISAAC's context arrays.
Definition: isaac.h:91
isaac_stream
void isaac_stream(isaac_ctx_t *ctx, isaac_uint_t *ints, size_t amount)
Provides the next pseudo-random integer.
isaac_ctx_t
Context of the ISAAC CPRNG.
Definition: isaac.h:105
isaac_ctx_t::b
isaac_uint_t b
Internal field.
Definition: isaac.h:116
isaac_init
void isaac_init(isaac_ctx_t *ctx, const uint8_t *seed, uint16_t seed_bytes)
Initialises the ISAAC CPRNG with a seed.
isaac_ctx_t::a
isaac_uint_t a
Internal field.
Definition: isaac.h:114
isaac_ctx_t::c
isaac_uint_t c
Internal field.
Definition: isaac.h:118