diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 11:49:28 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-03-18 12:33:41 +0100 |
commit | f74cf1350e4633892b6ee6db3664eec38579a709 (patch) | |
tree | 583373429fc4615e9189b2116c455db38af700f6 /newlib/libc/include | |
parent | 55c239d83413d3092c38acde8191d9249cf9f0ee (diff) | |
download | cygnal-f74cf1350e4633892b6ee6db3664eec38579a709.tar.gz cygnal-f74cf1350e4633892b6ee6db3664eec38579a709.tar.bz2 cygnal-f74cf1350e4633892b6ee6db3664eec38579a709.zip |
Add arc4random() etc. from OpenBSD 5.8
According to the OpenBSD man page, "A Replacement Call for Random". It
offers high quality random numbers derived from input data obtained by
the OpenBSD specific getentropy() system call which is declared in
<unistd.h> and must be implemented for each Newlib port externally. The
arc4random() functions are used for example in LibreSSL and OpenSSH.
Cygwin provides currently its own implementation of the arc4random
family. Maybe it makes sense to use this getentropy() implementation:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libcrypto/crypto/getentropy_win.c?rev=1.4&content-type=text/x-cvsweb-markup
* libc/include/stdlib.h (arc4random): Declare if __BSD_VISIBLE.
(arc4random_buf): Likewise.
(arc4random_uniform): Likewise.
* libc/include/sys/unistd.h (getentropy): Likewise.
* libc/include/machine/_arc4random.h: New file.
* libc/stdlib/arc4random.c: Likewise.
* libc/stdlib/arc4random.h: Likewise.
* libc/stdlib/arc4random_uniform.c: Likewise.
* libc/stdlib/chacha_private.h: Likewise.
* libc/sys/rtems/include/machine/_arc4random.h: Likewise.
* libc/stdlib/Makefile.am (EXTENDED_SOURCES): Add arc4random.c
and arc4random_uniform.c.
* libc/stdlib/Makefile.in: Regenerate.
Diffstat (limited to 'newlib/libc/include')
-rw-r--r-- | newlib/libc/include/machine/_arc4random.h | 1 | ||||
-rw-r--r-- | newlib/libc/include/stdlib.h | 5 | ||||
-rw-r--r-- | newlib/libc/include/sys/unistd.h | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/newlib/libc/include/machine/_arc4random.h b/newlib/libc/include/machine/_arc4random.h new file mode 100644 index 000000000..52808d722 --- /dev/null +++ b/newlib/libc/include/machine/_arc4random.h @@ -0,0 +1 @@ +/* Use default implementation, see arc4random.h */ diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h index b0856fa08..f4b262698 100644 --- a/newlib/libc/include/stdlib.h +++ b/newlib/libc/include/stdlib.h @@ -64,6 +64,11 @@ int _EXFUN(__locale_mb_cur_max,(_VOID)); _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((__noreturn__))); int _EXFUN(abs,(int)); +#if __BSD_VISIBLE +__uint32_t _EXFUN(arc4random, (void)); +__uint32_t _EXFUN(arc4random_uniform, (__uint32_t)); +void _EXFUN(arc4random_buf, (void *, size_t)); +#endif int _EXFUN(atexit,(_VOID (*__func)(_VOID))); double _EXFUN(atof,(const char *__nptr)); #if __MISC_VISIBLE diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h index d07b82660..c8299bb02 100644 --- a/newlib/libc/include/sys/unistd.h +++ b/newlib/libc/include/sys/unistd.h @@ -87,6 +87,9 @@ char * _EXFUN(getcwd, (char *__buf, size_t __size )); #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500) int _EXFUN(getdomainname ,(char *__name, size_t __len)); #endif +#if __BSD_VISIBLE +int _EXFUN(getentropy, (void *, size_t)); +#endif #if !defined(__INSIDE_CYGWIN__) gid_t _EXFUN(getegid, (void )); uid_t _EXFUN(geteuid, (void )); |