mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-03-04 03:53:02 +00:00
- Changed the used random function pointer to more flexible format. Renamed havege_rand() to havege_random() to prevent mistakes. Lots of changes as a consequence in library code and programs
This commit is contained in:
@@ -47,12 +47,27 @@
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
static int myrand( void *rng_state )
|
||||
static int myrand( void *rng_state, unsigned char *output, size_t len )
|
||||
{
|
||||
size_t use_len;
|
||||
int rnd;
|
||||
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
return( rand() );
|
||||
while( len > 0 )
|
||||
{
|
||||
use_len = len;
|
||||
if( use_len > sizeof(int) )
|
||||
use_len = sizeof(int);
|
||||
|
||||
rnd = rand();
|
||||
memcpy( output, &rnd, use_len );
|
||||
output += use_len;
|
||||
len -= use_len;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
unsigned char buf[BUFSIZE];
|
||||
|
||||
@@ -257,7 +257,7 @@ static int ssl_test( struct options *opt )
|
||||
|
||||
ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
|
||||
|
||||
ssl_set_rng( &ssl, havege_rand, &hs );
|
||||
ssl_set_rng( &ssl, havege_random, &hs );
|
||||
ssl_set_dbg( &ssl, my_debug, opt );
|
||||
ssl_set_bio( &ssl, net_recv, &client_fd,
|
||||
net_send, &client_fd );
|
||||
|
||||
Reference in New Issue
Block a user