The Great Renaming

A simple execution of tmp/invoke-rename.pl
This commit is contained in:
Manuel Pégourié-Gonnard
2015-04-08 12:49:31 +02:00
parent b5904d25ef
commit 2cf5a7c98e
291 changed files with 36012 additions and 36012 deletions

View File

@@ -2,7 +2,7 @@
#include "mbedtls/ctr_drbg.h"
int test_offset_idx;
int entropy_func( void *data, unsigned char *buf, size_t len )
int mbedtls_entropy_func( void *data, unsigned char *buf, size_t len )
{
const unsigned char *p = (unsigned char *) data;
memcpy( buf, p + test_offset_idx, len );
@@ -12,7 +12,7 @@ int entropy_func( void *data, unsigned char *buf, size_t len )
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:POLARSSL_CTR_DRBG_C
* depends_on:MBEDTLS_CTR_DRBG_C
* END_DEPENDENCIES
*/
@@ -25,7 +25,7 @@ void ctr_drbg_validate_pr( char *add_init_string, char *entropy_string,
unsigned char add_init[512];
unsigned char add1[512];
unsigned char add2[512];
ctr_drbg_context ctx;
mbedtls_ctr_drbg_context ctx;
unsigned char buf[512];
unsigned char output_str[512];
int add_init_len, add1_len, add2_len;
@@ -38,16 +38,16 @@ void ctr_drbg_validate_pr( char *add_init_string, char *entropy_string,
add2_len = unhexify( add2, add2_string );
test_offset_idx = 0;
TEST_ASSERT( ctr_drbg_init_entropy_len( &ctx, entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
ctr_drbg_set_prediction_resistance( &ctx, CTR_DRBG_PR_ON );
TEST_ASSERT( mbedtls_ctr_drbg_init_entropy_len( &ctx, mbedtls_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
mbedtls_ctr_drbg_set_prediction_resistance( &ctx, MBEDTLS_CTR_DRBG_PR_ON );
TEST_ASSERT( ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 );
TEST_ASSERT( ctr_drbg_random_with_add( &ctx, buf, 16, add2, add2_len ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add2, add2_len ) == 0 );
hexify( output_str, buf, 16 );
TEST_ASSERT( strcmp( (char *) output_str, result_str ) == 0 );
exit:
ctr_drbg_free( &ctx );
mbedtls_ctr_drbg_free( &ctx );
}
/* END_CASE */
@@ -61,7 +61,7 @@ void ctr_drbg_validate_nopr( char *add_init_string, char *entropy_string,
unsigned char add1[512];
unsigned char add_reseed[512];
unsigned char add2[512];
ctr_drbg_context ctx;
mbedtls_ctr_drbg_context ctx;
unsigned char buf[512];
unsigned char output_str[512];
int add_init_len, add1_len, add_reseed_len, add2_len;
@@ -75,16 +75,16 @@ void ctr_drbg_validate_nopr( char *add_init_string, char *entropy_string,
add2_len = unhexify( add2, add2_string );
test_offset_idx = 0;
TEST_ASSERT( ctr_drbg_init_entropy_len( &ctx, entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_init_entropy_len( &ctx, mbedtls_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
TEST_ASSERT( ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 );
TEST_ASSERT( ctr_drbg_reseed( &ctx, add_reseed, add_reseed_len ) == 0 );
TEST_ASSERT( ctr_drbg_random_with_add( &ctx, buf, 16, add2, add2_len ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_reseed( &ctx, add_reseed, add_reseed_len ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add2, add2_len ) == 0 );
hexify( output_str, buf, 16 );
TEST_ASSERT( strcmp( (char *) output_str, result_str ) == 0 );
exit:
ctr_drbg_free( &ctx );
mbedtls_ctr_drbg_free( &ctx );
}
/* END_CASE */
@@ -94,7 +94,7 @@ void ctr_drbg_entropy_usage( )
unsigned char out[16];
unsigned char add[16];
unsigned char entropy[1024];
ctr_drbg_context ctx;
mbedtls_ctr_drbg_context ctx;
size_t i, reps = 10;
int last_idx;
@@ -105,7 +105,7 @@ void ctr_drbg_entropy_usage( )
/* Init must use entropy */
last_idx = test_offset_idx;
TEST_ASSERT( ctr_drbg_init( &ctx, entropy_func, entropy, NULL, 0 ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_init( &ctx, mbedtls_entropy_func, entropy, NULL, 0 ) == 0 );
TEST_ASSERT( last_idx < test_offset_idx );
/* By default, PR is off and reseed_interval is large,
@@ -113,8 +113,8 @@ void ctr_drbg_entropy_usage( )
last_idx = test_offset_idx;
for( i = 0; i < reps; i++ )
{
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) - 4 ) == 0 );
TEST_ASSERT( ctr_drbg_random_with_add( &ctx, out, sizeof( out ) - 4,
TEST_ASSERT( mbedtls_ctr_drbg_random( &ctx, out, sizeof( out ) - 4 ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, out, sizeof( out ) - 4,
add, sizeof( add ) ) == 0 );
}
TEST_ASSERT( last_idx == test_offset_idx );
@@ -127,62 +127,62 @@ void ctr_drbg_entropy_usage( )
/* Set reseed_interval to the number of calls done,
* so the next call should reseed */
ctr_drbg_set_reseed_interval( &ctx, 2 * reps );
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
mbedtls_ctr_drbg_set_reseed_interval( &ctx, 2 * reps );
TEST_ASSERT( mbedtls_ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( last_idx < test_offset_idx );
/* The new few calls should not reseed */
last_idx = test_offset_idx;
for( i = 0; i < reps / 2; i++ )
{
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( ctr_drbg_random_with_add( &ctx, out, sizeof( out ) ,
TEST_ASSERT( mbedtls_ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, out, sizeof( out ) ,
add, sizeof( add ) ) == 0 );
}
TEST_ASSERT( last_idx == test_offset_idx );
/* Call update with too much data (sizeof entropy > MAX(_SEED)_INPUT)
* (just make sure it doesn't cause memory corruption) */
ctr_drbg_update( &ctx, entropy, sizeof( entropy ) );
mbedtls_ctr_drbg_update( &ctx, entropy, sizeof( entropy ) );
/* Now enable PR, so the next few calls should all reseed */
ctr_drbg_set_prediction_resistance( &ctx, CTR_DRBG_PR_ON );
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
mbedtls_ctr_drbg_set_prediction_resistance( &ctx, MBEDTLS_CTR_DRBG_PR_ON );
TEST_ASSERT( mbedtls_ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( last_idx < test_offset_idx );
/* Finally, check setting entropy_len */
ctr_drbg_set_entropy_len( &ctx, 42 );
mbedtls_ctr_drbg_set_entropy_len( &ctx, 42 );
last_idx = test_offset_idx;
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( test_offset_idx - last_idx == 42 );
ctr_drbg_set_entropy_len( &ctx, 13 );
mbedtls_ctr_drbg_set_entropy_len( &ctx, 13 );
last_idx = test_offset_idx;
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
TEST_ASSERT( test_offset_idx - last_idx == 13 );
exit:
ctr_drbg_free( &ctx );
mbedtls_ctr_drbg_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_FS_IO */
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO */
void ctr_drbg_seed_file( char *path, int ret )
{
ctr_drbg_context ctx;
mbedtls_ctr_drbg_context ctx;
TEST_ASSERT( ctr_drbg_init( &ctx, rnd_std_rand, NULL, NULL, 0 ) == 0 );
TEST_ASSERT( ctr_drbg_write_seed_file( &ctx, path ) == ret );
TEST_ASSERT( ctr_drbg_update_seed_file( &ctx, path ) == ret );
TEST_ASSERT( mbedtls_ctr_drbg_init( &ctx, rnd_std_rand, NULL, NULL, 0 ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_write_seed_file( &ctx, path ) == ret );
TEST_ASSERT( mbedtls_ctr_drbg_update_seed_file( &ctx, path ) == ret );
exit:
ctr_drbg_free( &ctx );
mbedtls_ctr_drbg_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_SELF_TEST */
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
void ctr_drbg_selftest( )
{
TEST_ASSERT( ctr_drbg_self_test( 0 ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_self_test( 0 ) == 0 );
}
/* END_CASE */