From 3fa7c64edf2968b6c3549274a263d06b06310e99 Mon Sep 17 00:00:00 2001 From: gufe44 Date: Mon, 3 Aug 2020 17:56:50 +0200 Subject: [PATCH] Use arc4random_buf instead of rand on NetBSD Avoid old implementation of rand returning numbers with cyclical lower bits. Allow tests to pass. Signed-off-by: gufe44 --- library/rsa.c | 6 +++--- tests/suites/helpers.function | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/rsa.c b/library/rsa.c index af1cef651..f3b19184e 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -83,7 +83,7 @@ #include "mbedtls/md.h" #endif -#if defined(MBEDTLS_PKCS1_V15) && !defined(__OpenBSD__) +#if defined(MBEDTLS_PKCS1_V15) && !defined(__OpenBSD__) && !defined(__NetBSD__) #include #endif @@ -2590,7 +2590,7 @@ void mbedtls_rsa_free( mbedtls_rsa_context *ctx ) #if defined(MBEDTLS_PKCS1_V15) static int myrand( void *rng_state, unsigned char *output, size_t len ) { -#if !defined(__OpenBSD__) +#if !defined(__OpenBSD__) && !defined(__NetBSD__) size_t i; if( rng_state != NULL ) @@ -2603,7 +2603,7 @@ static int myrand( void *rng_state, unsigned char *output, size_t len ) rng_state = NULL; arc4random_buf( output, len ); -#endif /* !OpenBSD */ +#endif /* !OpenBSD && !NetBSD */ return( 0 ); } diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function index cd9346e5c..523db86e4 100644 --- a/tests/suites/helpers.function +++ b/tests/suites/helpers.function @@ -549,7 +549,7 @@ unsigned char *unhexify_alloc( const char *ibuf, size_t *olen ) */ static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len ) { -#if !defined(__OpenBSD__) +#if !defined(__OpenBSD__) && !defined(__NetBSD__) size_t i; if( rng_state != NULL ) @@ -562,7 +562,7 @@ static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len ) rng_state = NULL; arc4random_buf( output, len ); -#endif /* !OpenBSD */ +#endif /* !OpenBSD && !NetBSD */ return( 0 ); }