diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-12-24 14:01:42 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-12-24 14:07:25 -0800 |
| commit | 252ea41be8bab992dadabec0e4f1d77650949f4c (patch) | |
| tree | 14e87f34b3137745cd2dd8c519070b3319330c3d /src/platform | |
| parent | 20dfa3c924dabf20bedf6f82969e7e1467e799af (diff) | |
| download | nng-252ea41be8bab992dadabec0e4f1d77650949f4c.tar.gz nng-252ea41be8bab992dadabec0e4f1d77650949f4c.tar.bz2 nng-252ea41be8bab992dadabec0e4f1d77650949f4c.zip | |
fixes #1038 Linux should use getentropy or getrandom
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_config.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/platform/posix/posix_config.h b/src/platform/posix/posix_config.h index 9afa70c8..2abe51b4 100644 --- a/src/platform/posix/posix_config.h +++ b/src/platform/posix/posix_config.h @@ -1,5 +1,5 @@ // -// Copyright 2016 Garrett D'Amore <garrett@damore.org> +// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -36,20 +36,30 @@ // #define NNG_USE_GETENTROPY // #define NNG_USE_ARC4RANDOM // #define NNG_USE_DEVURANDOM -// Thesse are options for obtaining entropy to seed the pRNG. +// These are options for obtaining entropy to seed the pRNG. // All known modern UNIX variants can support NNG_USE_DEVURANDOM, // but the other options are better still, but not portable. #include <time.h> #ifdef NNG_PLATFORM_POSIX - +#if !defined(NNG_USE_DEVURANDOM) && !defined(NNG_USE_GETENTROPY) && \ + !defined(NNG_USE_GETRANDOM) && !defined(NNG_USE_ARC4RANDOM) +#if defined(NNG_HAVE_GETENTROPY) +#define NNG_USE_GETENTROPY 1 +#elif defined(NNG_HAVE_GETRANDOM) +#define NNG_USE_GETRANDOM 1 +#elif defined(NNG_HAVE_ARC4RANDOM) +#define NNG_USE_ARC4RANDOM +#else // It should never hurt to use DEVURANDOM, since if the device does not // exist then we won't open it. (Provided: it would be bad if the device // exists but has somehow very very different semantics. We don't know // of any such concerns.) This won't be used if any of the other options // are defined and work. #define NNG_USE_DEVURANDOM 1 +#endif +#endif #define NNG_USE_CLOCKID CLOCK_REALTIME #ifndef CLOCK_REALTIME |
