mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 08:44:22 +01:00
Update ctr_drbg_init() usage in programs
This commit is contained in:
parent
8d128efd48
commit
ec160c0f53
@ -87,6 +87,7 @@ int main( void )
|
||||
memset( &rsa, 0, sizeof( rsa ) );
|
||||
mbedtls_dhm_init( &dhm );
|
||||
mbedtls_aes_init( &aes );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
/*
|
||||
* 1. Setup the RNG
|
||||
@ -95,11 +96,11 @@ int main( void )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ int main( void )
|
||||
FILE *fout;
|
||||
|
||||
mbedtls_mpi_init( &G ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
mbedtls_entropy_init( &entropy );
|
||||
|
||||
if( ( ret = mbedtls_mpi_read_string( &G, 10, GENERATOR ) ) != 0 )
|
||||
@ -92,11 +93,11 @@ int main( void )
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,7 @@ int main( void )
|
||||
memset( &rsa, 0, sizeof( rsa ) );
|
||||
mbedtls_dhm_init( &dhm );
|
||||
mbedtls_aes_init( &aes );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
/*
|
||||
* 1. Setup the RNG
|
||||
@ -96,11 +97,11 @@ int main( void )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
mbedtls_ecdsa_init( &ctx_sign );
|
||||
mbedtls_ecdsa_init( &ctx_verify );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
memset(sig, 0, sizeof( sig ) );
|
||||
ret = 1;
|
||||
@ -132,11 +133,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,7 @@ int main( int argc, char *argv[] )
|
||||
* Set to sane values
|
||||
*/
|
||||
mbedtls_pk_init( &key );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
|
||||
if( argc == 0 )
|
||||
@ -296,11 +297,11 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
#endif /* !_WIN32 && MBEDTLS_FS_IO */
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned -0x%04x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ int main( int argc, char *argv[] )
|
||||
const char *pers = "mbedtls_pk_decrypt";
|
||||
((void) argv);
|
||||
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
memset(result, 0, sizeof( result ) );
|
||||
ret = 1;
|
||||
|
||||
@ -88,11 +89,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ int main( int argc, char *argv[] )
|
||||
const char *pers = "mbedtls_pk_encrypt";
|
||||
|
||||
ret = 1;
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
if( argc != 3 )
|
||||
{
|
||||
@ -86,11 +87,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned -0x%04x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ int main( int argc, char *argv[] )
|
||||
size_t olen = 0;
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
mbedtls_pk_init( &pk );
|
||||
|
||||
if( argc != 3 )
|
||||
@ -97,11 +98,11 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned -0x%04x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ int main( int argc, char *argv[] )
|
||||
((void) argv);
|
||||
|
||||
memset(result, 0, sizeof( result ) );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
ret = 1;
|
||||
|
||||
if( argc != 1 )
|
||||
@ -86,11 +87,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ int main( int argc, char *argv[] )
|
||||
unsigned char buf[512];
|
||||
const char *pers = "rsa_encrypt";
|
||||
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
ret = 1;
|
||||
|
||||
if( argc != 2 )
|
||||
@ -85,11 +86,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -70,15 +70,17 @@ int main( void )
|
||||
FILE *fpriv = NULL;
|
||||
const char *pers = "rsa_genkey";
|
||||
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
mbedtls_pk_init( &pk );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
if( argc != 3 )
|
||||
{
|
||||
@ -97,11 +98,11 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,8 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_entropy_context entropy;
|
||||
unsigned char buf[1024];
|
||||
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
if( argc < 2 )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
|
||||
@ -71,10 +73,10 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *) "RANDOM_GEN", 10 );
|
||||
ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *) "RANDOM_GEN", 10 );
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( "failed in mbedtls_ctr_drbg_init: %d\n", ret );
|
||||
mbedtls_printf( "failed in mbedtls_ctr_drbg_seed: %d\n", ret );
|
||||
goto cleanup;
|
||||
}
|
||||
mbedtls_ctr_drbg_set_prediction_resistance( &ctr_drbg, MBEDTLS_CTR_DRBG_PR_OFF );
|
||||
|
@ -106,16 +106,17 @@ int main( int argc, char *argv[] )
|
||||
*/
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,7 @@ int main( void )
|
||||
mbedtls_x509_crt_init( &srvcert );
|
||||
mbedtls_pk_init( &pkey );
|
||||
mbedtls_entropy_init( &entropy );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
#if defined(MBEDTLS_DEBUG_C)
|
||||
mbedtls_debug_set_threshold( DEBUG_LEVEL );
|
||||
@ -173,11 +174,11 @@ int main( void )
|
||||
printf( " . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ const unsigned char ca_cert[] = {
|
||||
enum exit_codes
|
||||
{
|
||||
exit_ok = 0,
|
||||
ctr_drbg_init_failed,
|
||||
ctr_drbg_seed_failed,
|
||||
ssl_init_failed,
|
||||
socket_failed,
|
||||
connect_failed,
|
||||
@ -167,6 +167,7 @@ int main( void )
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
mbedtls_ssl_context ssl;
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
/*
|
||||
* 0. Initialize and setup stuff
|
||||
@ -177,7 +178,7 @@ int main( void )
|
||||
#endif
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers, strlen( pers ) ) != 0 )
|
||||
{
|
||||
ret = ssl_init_failed;
|
||||
|
@ -94,16 +94,17 @@ int main( void )
|
||||
*/
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -416,6 +416,7 @@ int main( int argc, char *argv[] )
|
||||
server_fd = 0;
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &clicert );
|
||||
@ -899,11 +900,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned -0x%x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,7 @@ int main( void )
|
||||
mbedtls_entropy_init( &entropy );
|
||||
mbedtls_pk_init( &pkey );
|
||||
mbedtls_x509_crt_init( &srvcert );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
signal( SIGCHLD, SIG_IGN );
|
||||
|
||||
@ -120,11 +121,11 @@ int main( void )
|
||||
mbedtls_printf( "\n . Initial seeding of the random generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &clicert );
|
||||
mbedtls_pk_init( &pkey );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
if( argc == 0 )
|
||||
{
|
||||
@ -471,11 +472,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ static void *handle_ssl_connection( void *data )
|
||||
|
||||
/* Make sure memory references are valid */
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
memset( &ctr_drbg, 0, sizeof( mbedtls_ctr_drbg_context ) );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
mbedtls_snprintf( pers, sizeof(pers), "SSL Pthread Thread %d", thread_id );
|
||||
mbedtls_printf( " [ #%d ] Client FD %d\n", thread_id, client_fd );
|
||||
@ -142,11 +142,11 @@ static void *handle_ssl_connection( void *data )
|
||||
|
||||
/* mbedtls_entropy_func() is thread-safe if MBEDTLS_THREADING_C is set
|
||||
*/
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, thread_info->entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, thread_info->entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " [ #%d ] failed: mbedtls_ctr_drbg_init returned -0x%04x\n",
|
||||
mbedtls_printf( " [ #%d ] failed: mbedtls_ctr_drbg_seed returned -0x%04x\n",
|
||||
thread_id, -ret );
|
||||
goto thread_exit;
|
||||
}
|
||||
|
@ -110,6 +110,7 @@ int main( void )
|
||||
mbedtls_x509_crt_init( &srvcert );
|
||||
mbedtls_pk_init( &pkey );
|
||||
mbedtls_entropy_init( &entropy );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
#if defined(MBEDTLS_DEBUG_C)
|
||||
mbedtls_debug_set_threshold( DEBUG_LEVEL );
|
||||
@ -172,11 +173,11 @@ int main( void )
|
||||
mbedtls_printf( " . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -762,6 +762,7 @@ int main( int argc, char *argv[] )
|
||||
*/
|
||||
listen_fd = 0;
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &srvcert );
|
||||
@ -1296,11 +1297,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned -0x%x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,7 @@ int main( int argc, char *argv[] )
|
||||
* Set to sane values
|
||||
*/
|
||||
server_fd = 0;
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &clicert );
|
||||
#if defined(MBEDTLS_X509_CRL_PARSE_C)
|
||||
@ -365,11 +366,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_x509write_csr_init( &req );
|
||||
mbedtls_x509write_csr_set_md_alg( &req, MBEDTLS_MD_SHA256 );
|
||||
mbedtls_pk_init( &key );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
|
||||
if( argc == 0 )
|
||||
@ -259,11 +260,11 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_pk_init( &loaded_issuer_key );
|
||||
mbedtls_pk_init( &loaded_subject_key );
|
||||
mbedtls_mpi_init( &serial );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
#if defined(MBEDTLS_X509_CSR_PARSE_C)
|
||||
mbedtls_x509_csr_init( &csr );
|
||||
#endif
|
||||
@ -371,12 +372,12 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_strerror( ret, buf, 1024 );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned %d - %s\n", ret, buf );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d - %s\n", ret, buf );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user