Style fixes

This commit is contained in:
Philippe Antoine 2019-06-07 15:04:32 +02:00
parent aa4d15264a
commit 986b6f20a9
2 changed files with 46 additions and 36 deletions

View file

@ -554,7 +554,8 @@ int dummy_random( void *p_rng, unsigned char *output, size_t output_len )
//use mbedtls_ctr_drbg_random to find bugs in it
ret = mbedtls_ctr_drbg_random( p_rng, output, output_len );
for (i=0; i<output_len; i++) {
for ( i = 0; i < output_len; i++ )
{
//replace result with pseudo random
output[i] = (unsigned char) rand();
}
@ -566,10 +567,9 @@ int dummy_entropy( void *data, unsigned char *output, size_t len )
size_t i;
(void) data;
//use mbedtls_entropy_func to find bugs in it
//test performance impact of entropy
//ret = mbedtls_entropy_func( data, output, len );
for (i=0; i<len; i++) {
for ( i = 0; i < len; i++ )
{
//replace result with pseudo random
output[i] = (unsigned char) rand();
}
@ -1706,7 +1706,8 @@ int main( int argc, char *argv[] )
fflush( stdout );
mbedtls_entropy_init( &entropy );
if (opt.reproducible) {
if (opt.reproducible)
{
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy,
&entropy, (const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
@ -1715,7 +1716,9 @@ int main( int argc, char *argv[] )
-ret );
goto exit;
}
} else {
}
else
{
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
&entropy, (const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
@ -2003,15 +2006,18 @@ int main( int argc, char *argv[] )
}
#endif
if (opt.reproducible) {
if (opt.reproducible)
{
srand( 1 );
mbedtls_ssl_conf_rng( &conf, dummy_random, &ctr_drbg );
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
mbedtls_platform_set_time( dummy_constant_time );
#else
fprintf(stderr, "Warning: reprpduce without constant time\n");
fprintf( stderr, "Warning: reproduce without constant time\n" );
#endif
} else {
}
else
{
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
}
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );

View file

@ -679,8 +679,6 @@ int dummy_entropy( void *data, unsigned char *output, size_t len )
size_t i;
(void) data;
//use mbedtls_entropy_func to find bugs in it
//test performance impact of entropy
//ret = mbedtls_entropy_func( data, output, len );
for (i = 0; i < len; i++ ) {
//replace result with pseudo random
@ -2488,7 +2486,8 @@ int main( int argc, char *argv[] )
fflush( stdout );
mbedtls_entropy_init( &entropy );
if (opt.reproducible) {
if (opt.reproducible)
{
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy,
&entropy, (const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
@ -2497,7 +2496,9 @@ int main( int argc, char *argv[] )
-ret );
goto exit;
}
} else {
}
else
{
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
&entropy, (const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
@ -2824,15 +2825,18 @@ int main( int argc, char *argv[] )
}
#endif
if (opt.reproducible) {
if (opt.reproducible)
{
srand( 1 );
mbedtls_ssl_conf_rng( &conf, dummy_random, &ctr_drbg );
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
mbedtls_platform_set_time( dummy_constant_time );
#else
fprintf(stderr, "Warning: reprpduce without constant time\n");
fprintf( stderr, "Warning: reproduce without constant time\n" );
#endif
} else {
}
else
{
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
}
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );