[riot-devel] To global seed or not to global seed

Mathias Tausig mathias.tausig at fh-campuswien.ac.at
Wed Mar 8 15:39:59 CET 2017


On Mit, 2017-03-08 at 09:09 +0100, Kaspar Schleiser wrote:
> Hey,
> 
> On 03/08/2017 12:18 AM, Cenk Gündoğan wrote:
> > 
> > we rather
> > should opt to allow local states for each thread (not excluding a global
> > state).
> Interesting. Up to now our trouble with RNGs was mostly on how to make
> them more random. Now we're trying to make them predictable. What's your
> use case for that?

Using the random numbers for a stream cipher, for instance.

> How about an interface a la
> 
> rand_init_<RNGname>(rnd_<RNGname>_t *rnd);
> rand_seed32(rnd_t *rnd, uint32_t);
> rand_seed(rnd_t *rnd, const uint8_t *in, size_t len);
> rand_get(rnd_t *rnd, uint8_t *out, size_t n);
> rand_get32(rnd_t *rnd);
> 
> typedef struct {
> 	<seed, get function pointer>
> } rnd_t;
> 
> typedef struct {
> 	rnd_t rnd;
> 	<tinymt32-state>;
> } rnd_tinymt32_t;
> 
> That way we'd have:
> 
> - user controlled state
> - the ability to overload (e.g., combine hwrng, collected entropy, prng
> but with the same interface)
> 

Look good, imo.

cheers
Mathias





More information about the devel mailing list