Commit Graph

6 Commits (c78a2b5c8f8936e2d65fd8c750dc090a01d144e6)

Author SHA1 Message Date
Kevin Bracey c78a2b5c8f Mix input to randLIB_add_seed calls
Don't just xor in the 64-bit number given, splitmix64 it across the entire
state. Also, make sure we don't accidentally set the state to all-zero.

RANDLIB_ASSUME_GOOD_SEED dropped - we now assume splitmix64 will be
present for the seed additions.

(Note that add_seed will be somewhat slow on platforms like MSP430 with
slow multipliers - don't call it too much.)
2016-10-21 12:37:37 +01:00
Kevin Bracey 9a00890fde Fix DEVICE_RANDOM fread call
size and nitems parameters were the wrong way around, so the call did
not return 1 as expected, meaning DEVICE_RANDOM functionality failed.
2016-10-19 08:09:42 +01:00
Kevin Bracey c1634ba5a0 Allow splitmix64 code to be avoided
Potentially allow platforms with known-good seed generation to avoid the
code overhead of splitmix64. Not actually activating, as I don't believe
we have any such platforms yet...
2016-10-18 12:07:00 +01:00
Kevin Bracey fce09a935b Add local pseudo-RNG to randLIB
Rather than using system rand(), provide our own pseudo-RNG.

Generator used is "xoroshiro128+", which has 16 bytes of state and
2^128-1 period.

Main advantage is that we can now seed with up to 128 bits of entropy,
rather than the 32 bits srand() limited us to. We also can be assured of
the quality of the algorithm.

As the core generator is 64-bit, we now provide a get 64-bit function,
and others are based on this.

Incorporate Linux's /dev/urandom use into the main source file.
2016-10-18 09:23:32 +01:00
Tero Heinonen 32afec7f59 licence and copyrights updated 2015-08-03 13:53:57 +03:00
Seppo Takalo bb97e63b78 Move randlib away from libservice. 2015-07-13 15:51:05 +03:00