diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2015-04-27 12:06:13 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2015-04-27 12:06:13 +0000 |
commit | 6480faa8a215e5f8ff3f4eeab9356d69ff815472 (patch) | |
tree | 14cceba201665fa4473ab2e6d268a513a1b0ef35 /contrib/unbound/compat/getentropy_linux.c | |
parent | 22889169f8b463811a1f0a890ee136951e8d1b4c (diff) | |
parent | 0ea28240053521a309698413a426b4d730a3d60c (diff) | |
download | src-test2-6480faa8a215e5f8ff3f4eeab9356d69ff815472.tar.gz src-test2-6480faa8a215e5f8ff3f4eeab9356d69ff815472.zip |
Notes
Diffstat (limited to 'contrib/unbound/compat/getentropy_linux.c')
-rw-r--r-- | contrib/unbound/compat/getentropy_linux.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/contrib/unbound/compat/getentropy_linux.c b/contrib/unbound/compat/getentropy_linux.c index 32d58a7cdbb9..d4adab2852d4 100644 --- a/contrib/unbound/compat/getentropy_linux.c +++ b/contrib/unbound/compat/getentropy_linux.c @@ -93,6 +93,13 @@ getentropy(void *buf, size_t len) return -1; } +#ifdef SYS_getrandom + /* try to use getrandom syscall introduced with kernel 3.17 */ + ret = syscall(SYS_getrandom, buf, len, 0); + if (ret != -1) + return (ret); +#endif /* SYS_getrandom */ + /* * Try to get entropy with /dev/urandom * @@ -474,22 +481,24 @@ getentropy_fallback(void *buf, size_t len) HD(cnt); } -#ifdef AT_RANDOM +#ifdef HAVE_GETAUXVAL +# ifdef AT_RANDOM /* Not as random as you think but we take what we are given */ p = (char *) getauxval(AT_RANDOM); if (p) HR(p, 16); -#endif -#ifdef AT_SYSINFO_EHDR +# endif +# ifdef AT_SYSINFO_EHDR p = (char *) getauxval(AT_SYSINFO_EHDR); if (p) HR(p, pgs); -#endif -#ifdef AT_BASE +# endif +# ifdef AT_BASE p = (char *) getauxval(AT_BASE); if (p) HD(p); -#endif +# endif +#endif /* HAVE_GETAUXVAL */ SHA512_Final(results, &ctx); memcpy((char*)buf + i, results, min(sizeof(results), len - i)); |