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

Kaspar Schleiser kaspar at schleiser.de
Wed Mar 8 09:09:34 CET 2017


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?

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)

Kaspar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 516 bytes
Desc: OpenPGP digital signature
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20170308/b5c86f1f/attachment.sig>


More information about the devel mailing list