mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 21:35:35 +00:00
Revert "Use glibc's getrandom() instead of syscall when glibc > 2.25."
This reverts commit 9c46a60e6c3edc35d6369afdf5252a5c66aef5b3. When the library is dynamically linked against Glibc (as is usually the case with Glibc), it now requires a recent Glibc at runtime if it was compiled with a recent Glibc. This is a loss of functionality for no demonstrated benefit. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
e85c0c469d
commit
c6468ee247
@ -1,2 +0,0 @@
|
|||||||
Changes
|
|
||||||
Use glibc's getrandom() instead of syscall when glibc > 2.25.
|
|
@ -18,15 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#if !defined(_GNU_SOURCE)
|
|
||||||
/* Ensure that syscall() is available even when compiling with -std=c99 */
|
/* Ensure that syscall() is available even when compiling with -std=c99 */
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
#include <features.h>
|
|
||||||
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25)
|
|
||||||
#define HAVE_SYS_RANDOM 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@ -92,16 +86,10 @@ int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Test for Linux getrandom() support.
|
* Test for Linux getrandom() support.
|
||||||
* When the C library is GNU libc and its version is greater than 2.25,
|
* Since there is no wrapper in the libc yet, use the generic syscall wrapper
|
||||||
* include sys/random.h to use getrandom(),
|
|
||||||
* otherwise use the generic use the generic syscall wrapper
|
|
||||||
* available in GNU libc and compatible libc's (eg uClibc).
|
* available in GNU libc and compatible libc's (eg uClibc).
|
||||||
*/
|
*/
|
||||||
#if HAVE_SYS_RANDOM
|
#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__midipix__))
|
||||||
#include <sys/random.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#define HAVE_GETRANDOM
|
|
||||||
#elif (defined(__linux__) && defined(__GLIBC__)) || defined(__midipix__)
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#if defined(SYS_getrandom)
|
#if defined(SYS_getrandom)
|
||||||
@ -167,11 +155,7 @@ int mbedtls_platform_entropy_poll( void *data,
|
|||||||
((void) data);
|
((void) data);
|
||||||
|
|
||||||
#if defined(HAVE_GETRANDOM)
|
#if defined(HAVE_GETRANDOM)
|
||||||
#if HAVE_SYS_RANDOM
|
|
||||||
ret = getrandom(output, len, 0);
|
|
||||||
#else
|
|
||||||
ret = getrandom_wrapper( output, len, 0 );
|
ret = getrandom_wrapper( output, len, 0 );
|
||||||
#endif
|
|
||||||
if( ret >= 0 )
|
if( ret >= 0 )
|
||||||
{
|
{
|
||||||
*olen = ret;
|
*olen = ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user