Skip to content

Commit

Permalink
Entropy changed back to non-pointer in ssl_server2.c
Browse files Browse the repository at this point in the history
Changed because CI failures. Also some minor improvements.
  • Loading branch information
Teppo Järvelin committed Oct 17, 2019
1 parent bcded35 commit 287f493
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions programs/ssl/ssl_server2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1561,16 +1561,16 @@ int main( int argc, char *argv[] )
#if defined(MBEDTLS_X509_CRT_PARSE_C)
mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
#endif
mbedtls_entropy_context *entropy;
mbedtls_entropy_context entropy;
#if defined(MBEDTLS_CTR_DRBG_C)
mbedtls_ctr_drbg_context *ctr_drbg;
mbedtls_ctr_drbg_context *ctr_drbg = NULL;
#else
mbedtls_hmac_drbg_context *hmac_drbg;
mbedtls_hmac_drbg_context *hmac_drbg = NULL;
#endif
mbedtls_ssl_context *ssl = NULL;
mbedtls_ssl_config *conf = NULL;
#if defined(MBEDTLS_TIMING_C)
mbedtls_timing_delay_context *timer;
mbedtls_timing_delay_context *timer = NULL;
#endif
#if defined(MBEDTLS_SSL_RENEGOTIATION)
unsigned char renego_period[8] = { 0 };
Expand All @@ -1594,7 +1594,7 @@ int main( int argc, char *argv[] )
mbedtls_ssl_cache_context *cache = NULL;
#endif
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
mbedtls_ssl_ticket_context *ticket_ctx;
mbedtls_ssl_ticket_context *ticket_ctx = NULL;
#endif
#if defined(SNI_OPTION)
sni_entry *sni_info = NULL;
Expand Down Expand Up @@ -2292,14 +2292,15 @@ int main( int argc, char *argv[] )
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
#endif

#if defined(MBEDTLS_X509_CRT_PARSE_C)
ssl = mbedtls_calloc( 1, sizeof( *ssl ) );
conf = mbedtls_calloc( 1, sizeof( *conf ) );
cacert = mbedtls_calloc( 1, sizeof( *cacert ) );
srvcert = mbedtls_calloc( 1, sizeof( *srvcert ) );
pkey = mbedtls_calloc( 1, sizeof( *pkey ) );
srvcert2 = mbedtls_calloc( 1, sizeof( *srvcert2 ) );
pkey2 = mbedtls_calloc( 1, sizeof( *pkey2 ) );
#endif
#if defined(MBEDTLS_SSL_CACHE_C)
cache = mbedtls_calloc( 1, sizeof( *cache ) );
#endif
Expand All @@ -2309,17 +2310,20 @@ int main( int argc, char *argv[] )
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
ticket_ctx = mbedtls_calloc( 1, sizeof( *ticket_ctx ) );
#endif
entropy = mbedtls_calloc( 1, sizeof( *entropy ) );

#if defined(MBEDTLS_CTR_DRBG_C)
ctr_drbg = mbedtls_calloc( 1, sizeof( *ctr_drbg ) );
#else
hmac_drbg = mbedtls_calloc( 1, sizeof( *hmac_drbg ) );
#endif

if( ssl == NULL || conf == NULL ||
if(
#if defined(MBEDTLS_X509_CRT_PARSE_C)
ssl == NULL || conf == NULL ||
cacert == NULL || srvcert == NULL ||
pkey == NULL || srvcert2 == NULL ||
pkey2 == NULL ||
#endif
#if defined(MBEDTLS_SSL_CACHE_C)
cache == NULL ||
#endif
Expand All @@ -2334,7 +2338,7 @@ int main( int argc, char *argv[] )
#else
hmac_drbg == NULL ||
#endif
entropy == NULL )
1 == 0) // just to please compiler
{
goto exit;
}
Expand Down Expand Up @@ -2380,7 +2384,6 @@ int main( int argc, char *argv[] )




#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
if( unhexify( cid, opt.cid_val, &cid_len ) != 0 )
{
Expand Down Expand Up @@ -2504,10 +2507,10 @@ int main( int argc, char *argv[] )
mbedtls_printf( "\n . Seeding the random number generator..." );
fflush( stdout );

mbedtls_entropy_init( entropy );
mbedtls_entropy_init( &entropy );
#if defined(MBEDTLS_CTR_DRBG_C)
if( ( ret = mbedtls_ctr_drbg_seed( ctr_drbg, mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
&entropy, (const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
Expand All @@ -2519,7 +2522,7 @@ int main( int argc, char *argv[] )
mbedtls_md_info_from_type(
available_hashes[0] ),
mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
&entropy, (const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
Expand Down Expand Up @@ -3976,7 +3979,7 @@ int main( int argc, char *argv[] )
#else
mbedtls_hmac_drbg_free( hmac_drbg );
#endif
mbedtls_entropy_free( entropy );
mbedtls_entropy_free( &entropy );

#if defined(MBEDTLS_SSL_CACHE_C)
mbedtls_ssl_cache_free( cache );
Expand All @@ -4000,15 +4003,17 @@ int main( int argc, char *argv[] )

mbedtls_free( ssl );
mbedtls_free( conf );
#if defined(MBEDTLS_X509_CRT_PARSE_C)
mbedtls_free( cacert );
mbedtls_free( srvcert );
mbedtls_free( pkey );
mbedtls_free( srvcert2 );
mbedtls_free( pkey2 );
#endif
#if defined(MBEDTLS_TIMING_C)
mbedtls_free( timer );
#endif
mbedtls_free( entropy );

#if defined(MBEDTLS_CTR_DRBG_C)
mbedtls_free( ctr_drbg );
#else
Expand Down

0 comments on commit 287f493

Please sign in to comment.