mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 12:11:27 -05:00 
			
		
		
		
	Local cleanups following the code move
No behavior change. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
		
							parent
							
								
									daa94c4ff5
								
							
						
					
					
						commit
						f1cb75fe13
					
				@ -686,7 +686,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
					#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
				
			||||||
    mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
 | 
					    mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    rng_context_t rng_context;
 | 
					    rng_context_t rng;
 | 
				
			||||||
    mbedtls_ssl_context ssl;
 | 
					    mbedtls_ssl_context ssl;
 | 
				
			||||||
    mbedtls_ssl_config conf;
 | 
					    mbedtls_ssl_config conf;
 | 
				
			||||||
    mbedtls_ssl_session saved_session;
 | 
					    mbedtls_ssl_session saved_session;
 | 
				
			||||||
@ -741,8 +741,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
    mbedtls_ssl_init( &ssl );
 | 
					    mbedtls_ssl_init( &ssl );
 | 
				
			||||||
    mbedtls_ssl_config_init( &conf );
 | 
					    mbedtls_ssl_config_init( &conf );
 | 
				
			||||||
    memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) );
 | 
					    memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) );
 | 
				
			||||||
    rng_context_t *rng = &rng_context;
 | 
					    rng_init( &rng );
 | 
				
			||||||
    rng_init( rng );
 | 
					 | 
				
			||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
					#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
				
			||||||
    mbedtls_x509_crt_init( &cacert );
 | 
					    mbedtls_x509_crt_init( &cacert );
 | 
				
			||||||
    mbedtls_x509_crt_init( &clicert );
 | 
					    mbedtls_x509_crt_init( &clicert );
 | 
				
			||||||
@ -1534,8 +1533,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
    mbedtls_printf( "\n  . Seeding the random number generator..." );
 | 
					    mbedtls_printf( "\n  . Seeding the random number generator..." );
 | 
				
			||||||
    fflush( stdout );
 | 
					    fflush( stdout );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int reproducible = opt.reproducible;
 | 
					    if( rng_seed( &rng, opt.reproducible, pers ) != 0 )
 | 
				
			||||||
    if( rng_seed( rng, reproducible, pers ) != 0 )
 | 
					 | 
				
			||||||
        goto exit;
 | 
					        goto exit;
 | 
				
			||||||
    mbedtls_printf( " ok\n" );
 | 
					    mbedtls_printf( " ok\n" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1882,7 +1880,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &rng->drbg );
 | 
					    mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &rng.drbg );
 | 
				
			||||||
    mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
 | 
					    mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout );
 | 
					    mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout );
 | 
				
			||||||
@ -3002,7 +3000,7 @@ exit:
 | 
				
			|||||||
    mbedtls_ssl_session_free( &saved_session );
 | 
					    mbedtls_ssl_session_free( &saved_session );
 | 
				
			||||||
    mbedtls_ssl_free( &ssl );
 | 
					    mbedtls_ssl_free( &ssl );
 | 
				
			||||||
    mbedtls_ssl_config_free( &conf );
 | 
					    mbedtls_ssl_config_free( &conf );
 | 
				
			||||||
    rng_free( rng );
 | 
					    rng_free( &rng );
 | 
				
			||||||
    if( session_data != NULL )
 | 
					    if( session_data != NULL )
 | 
				
			||||||
        mbedtls_platform_zeroize( session_data, session_data_len );
 | 
					        mbedtls_platform_zeroize( session_data, session_data_len );
 | 
				
			||||||
    mbedtls_free( session_data );
 | 
					    mbedtls_free( session_data );
 | 
				
			||||||
 | 
				
			|||||||
@ -1282,7 +1282,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
					#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
				
			||||||
    mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
 | 
					    mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    rng_context_t rng_context;
 | 
					    rng_context_t rng;
 | 
				
			||||||
    mbedtls_ssl_context ssl;
 | 
					    mbedtls_ssl_context ssl;
 | 
				
			||||||
    mbedtls_ssl_config conf;
 | 
					    mbedtls_ssl_config conf;
 | 
				
			||||||
#if defined(MBEDTLS_TIMING_C)
 | 
					#if defined(MBEDTLS_TIMING_C)
 | 
				
			||||||
@ -1376,8 +1376,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
    mbedtls_net_init( &listen_fd );
 | 
					    mbedtls_net_init( &listen_fd );
 | 
				
			||||||
    mbedtls_ssl_init( &ssl );
 | 
					    mbedtls_ssl_init( &ssl );
 | 
				
			||||||
    mbedtls_ssl_config_init( &conf );
 | 
					    mbedtls_ssl_config_init( &conf );
 | 
				
			||||||
    rng_context_t *rng = &rng_context;
 | 
					    rng_init( &rng );
 | 
				
			||||||
    rng_init( rng );
 | 
					 | 
				
			||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
					#if defined(MBEDTLS_X509_CRT_PARSE_C)
 | 
				
			||||||
    mbedtls_x509_crt_init( &cacert );
 | 
					    mbedtls_x509_crt_init( &cacert );
 | 
				
			||||||
    mbedtls_x509_crt_init( &srvcert );
 | 
					    mbedtls_x509_crt_init( &srvcert );
 | 
				
			||||||
@ -2293,8 +2292,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
    mbedtls_printf( "\n  . Seeding the random number generator..." );
 | 
					    mbedtls_printf( "\n  . Seeding the random number generator..." );
 | 
				
			||||||
    fflush( stdout );
 | 
					    fflush( stdout );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int reproducible = opt.reproducible;
 | 
					    if( rng_seed( &rng, opt.reproducible, pers ) != 0 )
 | 
				
			||||||
    if( rng_seed( rng, reproducible, pers ) != 0 )
 | 
					 | 
				
			||||||
        goto exit;
 | 
					        goto exit;
 | 
				
			||||||
    mbedtls_printf( " ok\n" );
 | 
					    mbedtls_printf( " ok\n" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2684,7 +2682,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &rng->drbg );
 | 
					    mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &rng.drbg );
 | 
				
			||||||
    mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
 | 
					    mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(MBEDTLS_SSL_CACHE_C)
 | 
					#if defined(MBEDTLS_SSL_CACHE_C)
 | 
				
			||||||
@ -2703,7 +2701,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
    if( opt.tickets == MBEDTLS_SSL_SESSION_TICKETS_ENABLED )
 | 
					    if( opt.tickets == MBEDTLS_SSL_SESSION_TICKETS_ENABLED )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if( ( ret = mbedtls_ssl_ticket_setup( &ticket_ctx,
 | 
					        if( ( ret = mbedtls_ssl_ticket_setup( &ticket_ctx,
 | 
				
			||||||
                        mbedtls_ctr_drbg_random, &rng->drbg,
 | 
					                        mbedtls_ctr_drbg_random, &rng.drbg,
 | 
				
			||||||
                        MBEDTLS_CIPHER_AES_256_GCM,
 | 
					                        MBEDTLS_CIPHER_AES_256_GCM,
 | 
				
			||||||
                        opt.ticket_timeout ) ) != 0 )
 | 
					                        opt.ticket_timeout ) ) != 0 )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -2725,7 +2723,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
        if( opt.cookies > 0 )
 | 
					        if( opt.cookies > 0 )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if( ( ret = mbedtls_ssl_cookie_setup( &cookie_ctx,
 | 
					            if( ( ret = mbedtls_ssl_cookie_setup( &cookie_ctx,
 | 
				
			||||||
                                          mbedtls_ctr_drbg_random, &rng->drbg ) ) != 0 )
 | 
					                                          mbedtls_ctr_drbg_random, &rng.drbg ) ) != 0 )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                mbedtls_printf( " failed\n  ! mbedtls_ssl_cookie_setup returned %d\n\n", ret );
 | 
					                mbedtls_printf( " failed\n  ! mbedtls_ssl_cookie_setup returned %d\n\n", ret );
 | 
				
			||||||
                goto exit;
 | 
					                goto exit;
 | 
				
			||||||
@ -2878,7 +2876,7 @@ int main( int argc, char *argv[] )
 | 
				
			|||||||
                                        - opt.async_private_error :
 | 
					                                        - opt.async_private_error :
 | 
				
			||||||
                                        opt.async_private_error );
 | 
					                                        opt.async_private_error );
 | 
				
			||||||
        ssl_async_keys.f_rng = mbedtls_ctr_drbg_random;
 | 
					        ssl_async_keys.f_rng = mbedtls_ctr_drbg_random;
 | 
				
			||||||
        ssl_async_keys.p_rng = &rng->drbg;
 | 
					        ssl_async_keys.p_rng = &rng.drbg;
 | 
				
			||||||
        mbedtls_ssl_conf_async_private_cb( &conf,
 | 
					        mbedtls_ssl_conf_async_private_cb( &conf,
 | 
				
			||||||
                                           sign,
 | 
					                                           sign,
 | 
				
			||||||
                                           decrypt,
 | 
					                                           decrypt,
 | 
				
			||||||
@ -3976,7 +3974,7 @@ exit:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    mbedtls_ssl_free( &ssl );
 | 
					    mbedtls_ssl_free( &ssl );
 | 
				
			||||||
    mbedtls_ssl_config_free( &conf );
 | 
					    mbedtls_ssl_config_free( &conf );
 | 
				
			||||||
    rng_free( rng );
 | 
					    rng_free( &rng );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(MBEDTLS_SSL_CACHE_C)
 | 
					#if defined(MBEDTLS_SSL_CACHE_C)
 | 
				
			||||||
    mbedtls_ssl_cache_free( &cache );
 | 
					    mbedtls_ssl_cache_free( &cache );
 | 
				
			||||||
 | 
				
			|||||||
@ -46,7 +46,7 @@ mbedtls_time_t dummy_constant_time( mbedtls_time_t* time )
 | 
				
			|||||||
    return 0x5af2a056;
 | 
					    return 0x5af2a056;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dummy_entropy( void *data, unsigned char *output, size_t len )
 | 
					static int dummy_entropy( void *data, unsigned char *output, size_t len )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    size_t i;
 | 
					    size_t i;
 | 
				
			||||||
    int ret;
 | 
					    int ret;
 | 
				
			||||||
@ -69,36 +69,24 @@ void rng_init( rng_context_t *rng )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int rng_seed( rng_context_t *rng, int reproducible, const char *pers )
 | 
					int rng_seed( rng_context_t *rng, int reproducible, const char *pers )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int ret = 0;
 | 
					    int ( *f_entropy )( void *, unsigned char *, size_t ) =
 | 
				
			||||||
 | 
					        ( reproducible ? dummy_entropy : mbedtls_entropy_func );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ( reproducible )
 | 
					    if ( reproducible )
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        srand( 1 );
 | 
					        srand( 1 );
 | 
				
			||||||
        if( ( ret = mbedtls_ctr_drbg_seed( &rng->drbg, dummy_entropy,
 | 
					 | 
				
			||||||
                                           &rng->entropy, (const unsigned char *) pers,
 | 
					 | 
				
			||||||
                                           strlen( pers ) ) ) != 0 )
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            mbedtls_printf( " failed\n  ! mbedtls_ctr_drbg_seed returned -0x%x\n",
 | 
					 | 
				
			||||||
                            (unsigned int) -ret );
 | 
					 | 
				
			||||||
            goto exit;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if( ( ret = mbedtls_ctr_drbg_seed( &rng->drbg, mbedtls_entropy_func,
 | 
					 | 
				
			||||||
                                           &rng->entropy, (const unsigned char *) pers,
 | 
					 | 
				
			||||||
                                           strlen( pers ) ) ) != 0 )
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            mbedtls_printf( " failed\n  ! mbedtls_ctr_drbg_seed returned -0x%x\n",
 | 
					 | 
				
			||||||
                            (unsigned int) -ret );
 | 
					 | 
				
			||||||
            goto exit;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int ret = mbedtls_ctr_drbg_seed( &rng->drbg,
 | 
				
			||||||
 | 
					                                     f_entropy, &rng->entropy,
 | 
				
			||||||
 | 
					                                     (const unsigned char *) pers,
 | 
				
			||||||
 | 
					                                     strlen( pers ) );
 | 
				
			||||||
 | 
					    if( ret != 0 )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        mbedtls_printf( " failed\n  ! mbedtls_ctr_drbg_seed returned -0x%x\n",
 | 
				
			||||||
 | 
					                        (unsigned int) -ret );
 | 
				
			||||||
 | 
					        return( ret );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return( 0 );
 | 
					    return( 0 );
 | 
				
			||||||
exit:
 | 
					 | 
				
			||||||
    return( 1 );
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void rng_free( rng_context_t *rng )
 | 
					void rng_free( rng_context_t *rng )
 | 
				
			||||||
 | 
				
			|||||||
@ -126,8 +126,6 @@ void my_debug( void *ctx, int level,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
mbedtls_time_t dummy_constant_time( mbedtls_time_t* time );
 | 
					mbedtls_time_t dummy_constant_time( mbedtls_time_t* time );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dummy_entropy( void *data, unsigned char *output, size_t len );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** A context for random number generation (RNG).
 | 
					/** A context for random number generation (RNG).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
typedef struct
 | 
					typedef struct
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user