Add support for getrandom()
This commit is contained in:
parent
d68b65199f
commit
18292456c5
2 changed files with 44 additions and 0 deletions
|
@ -1,5 +1,11 @@
|
||||||
PolarSSL ChangeLog (Sorted per branch, date)
|
PolarSSL ChangeLog (Sorted per branch, date)
|
||||||
|
|
||||||
|
= PolarSSL 1.3.10 released ???
|
||||||
|
|
||||||
|
Features
|
||||||
|
* Add support for getrandom() syscall on recent Linux kernels with Glibc or
|
||||||
|
a compatible enough libc (eg uClibc).
|
||||||
|
|
||||||
= PolarSSL 1.3.9 released 2014-10-20
|
= PolarSSL 1.3.9 released 2014-10-20
|
||||||
Security
|
Security
|
||||||
* Lowest common hash was selected from signature_algorithms extension in
|
* Lowest common hash was selected from signature_algorithms extension in
|
||||||
|
|
|
@ -73,6 +73,43 @@ int platform_entropy_poll( void *data, unsigned char *output, size_t len,
|
||||||
}
|
}
|
||||||
#else /* _WIN32 && !EFIX64 && !EFI32 */
|
#else /* _WIN32 && !EFIX64 && !EFI32 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test for Linux getrandom() support.
|
||||||
|
* Since there is no wrapper in the libc yet, use the generic syscall wrapper
|
||||||
|
* available in GNU libc and compatible libc's (eg uClibc).
|
||||||
|
*/
|
||||||
|
#if defined(__linux__) && defined(__GLIBC__)
|
||||||
|
#include <linux/version.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#if defined(SYS_getrandom)
|
||||||
|
#define HAVE_GETRANDOM
|
||||||
|
static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags )
|
||||||
|
{
|
||||||
|
return( syscall( SYS_getrandom, buf, buflen, flags ) );
|
||||||
|
}
|
||||||
|
#endif /* SYS_getrandom */
|
||||||
|
#endif /* __linux__ */
|
||||||
|
|
||||||
|
#if defined(HAVE_GETRANDOM)
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
int platform_entropy_poll( void *data,
|
||||||
|
unsigned char *output, size_t len, size_t *olen )
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
((void) data);
|
||||||
|
|
||||||
|
if( ( ret = getrandom_wrapper( output, len, 0 ) ) < 0 )
|
||||||
|
return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
|
||||||
|
|
||||||
|
*olen = ret;
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* HAVE_GETRANDOM */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int platform_entropy_poll( void *data,
|
int platform_entropy_poll( void *data,
|
||||||
|
@ -100,6 +137,7 @@ int platform_entropy_poll( void *data,
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_GETRANDOM */
|
||||||
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
||||||
#endif /* !POLARSSL_NO_PLATFORM_ENTROPY */
|
#endif /* !POLARSSL_NO_PLATFORM_ENTROPY */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue