diff --git a/ChangeLog.d/netbsd-rand-arc4random_buf.txt b/ChangeLog.d/netbsd-rand-arc4random_buf.txt new file mode 100644 index 000000000..8539d1f5e --- /dev/null +++ b/ChangeLog.d/netbsd-rand-arc4random_buf.txt @@ -0,0 +1,3 @@ +Bugfix + * Use arc4random_buf on NetBSD instead of rand implementation with cyclical + lower bits. Fix contributed in #3540. diff --git a/library/rsa.c b/library/rsa.c index 83ed3c937..c6c5956dc 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -53,7 +53,7 @@ #include "mbedtls/md.h" #endif -#if defined(MBEDTLS_PKCS1_V15) && !defined(__OpenBSD__) +#if defined(MBEDTLS_PKCS1_V15) && !defined(__OpenBSD__) && !defined(__NetBSD__) #include #endif @@ -2569,7 +2569,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 ) @@ -2582,7 +2582,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/src/random.c b/tests/src/random.c index 3345f78be..45748a943 100644 --- a/tests/src/random.c +++ b/tests/src/random.c @@ -32,7 +32,7 @@ int mbedtls_test_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 ) @@ -45,7 +45,7 @@ int mbedtls_test_rnd_std_rand( void *rng_state, rng_state = NULL; arc4random_buf( output, len ); -#endif /* !OpenBSD */ +#endif /* !OpenBSD && !NetBSD */ return( 0 ); }