LibISAAC
1.0.0
A modern reimplementation of the ISAAC CPRNG.
|
LibISAAC offers the tiny and fast ISAAC cryptographically secure pseudo random number generator (CSPRNG), in its 32-bit and 64-bit version wrapped into a modern, ISO C11, documented API, ready for embedded usage.
Quoting from its website:
ISAAC (Indirection, Shift, Accumulate, Add, and Count) generates 32-bit random numbers. Averaged out, it requires 18.75 machine cycles to generate each 32-bit value. Cycles are guaranteed to be at least 240 values long, and they are 28295 values long on average. The results are uniformly distributed, unbiased, and unpredictable unless you know the seed. [...] ISAAC-64 generates a different sequence than ISAAC, but it uses the same principles. It uses 64-bit arithmetic. It generates a 64-bit result every 19 instructions. All cycles are at least 272 values, and the average cycle length is 216583.
ISAAC and its original source code (on which this version is based on) were created by Bob Jenkins and released into the public domain.
Depending on your architecture, you may want to use the version of ISAAC optimised for 32 or 64 bit words. To do so, set the #define ISAAC_BITS
to 32
or 64
during compilation or directly in the header file. It defaults to 64 when unspecified.
Differences:
Please note that altering ISAAC_BITS
does not set your compiler to compile LibISAAC for a 32 or 64 target architecture, it simply chooses which integers to use based on your choice, not the compiler's. You may want to choose the best version for your system, but you can compile both versions on any system.
Examples:
ISAAC_BITS=32
ISAAC_BITS=64
ISAAC=BITS=32
to get the same output.Copy the inc/isaac.h
and src/isaac.c
files into your existing C project, add them to the source folders and compile..
If you prefer a specific bitness, redefine ISAAC_BITS
in the header file.
This will build all targets:
libisaac32.a
static librarytestisaac32
To compile with the optimisation for size, use the -DCMAKE_BUILD_TYPE=MinSizeRel
flag instead.
If you prefer using 64 bit integers, set -DISAAC_BITS=64
.