Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use arc4random_buf instead of rand on NetBSD #3540

Merged
merged 3 commits into from Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions 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.
6 changes: 3 additions & 3 deletions library/rsa.c
Expand Up @@ -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 <stdlib.h>
#endif

Expand Down Expand Up @@ -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 )
Expand All @@ -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 );
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/random.c
Expand Up @@ -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 )
Expand All @@ -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 );
}
Expand Down