diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-08 15:28:37 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-08 17:33:05 -0800 |
| commit | c5b5bd910507520f7974a156a1de9d187f23bc2f (patch) | |
| tree | 9766716c795d88fe902c7196696c1389d76717ba /src/core/random.h | |
| parent | 4b166dd8ae417b818a5ba214d8f2e648ac1d5be9 (diff) | |
| download | nng-c5b5bd910507520f7974a156a1de9d187f23bc2f.tar.gz nng-c5b5bd910507520f7974a156a1de9d187f23bc2f.tar.bz2 nng-c5b5bd910507520f7974a156a1de9d187f23bc2f.zip | |
New ISAAC pRNG. This replaces other local hacks for random data.
Platforms must seed the pRNGs by offering an nni_plat_seed_prng()
routine. Implementations for POSIX using various options (including
the /dev/urandom device) are supplied.
Diffstat (limited to 'src/core/random.h')
| -rw-r--r-- | src/core/random.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/random.h b/src/core/random.h new file mode 100644 index 00000000..cf365380 --- /dev/null +++ b/src/core/random.h @@ -0,0 +1,26 @@ +// +// Copyright 2017 Garrett D'Amore <garrett@damore.org> +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#ifndef CORE_RANDOM_H +#define CORE_RANDOM_H + +// nni_random_init initializes the pRNG subsystem. This includes obtaining +// suitable seeding material from the platform. +extern int nni_random_init(void); + +// nni_random_fini destroys the pRNG subsystem. +extern void nni_random_fini(void); + +// nni_random returns a random 32-bit integer. Note that this routine is +// thread-safe/reentrant. The pRNG is very robust, should be of crypto +// quality. However, its usefulness for cryptography will be determined +// by the quality of the seeding material provided by the platform. +extern uint32_t nni_random(void); + +#endif // CORE_RANDOM_H |
