tests: Add mbedtls_test_ prefix to zero_alloc()

Add mbedtls_test_ prefix to zero_alloc() test helper
function.

Command to change *.function files:
find . -name "*.function" -exec awk -i inplace \
    '{sub(/zero_alloc/,"mbedtls_test_&")}1' {} \;

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2020-06-10 10:42:18 +02:00
parent ff31eab938
commit 690f3ebe92
5 changed files with 8 additions and 8 deletions

View file

@ -65,7 +65,7 @@ void mbedtls_test_hexify( unsigned char *obuf,
* *
* For convenience, dies if allocation fails. * For convenience, dies if allocation fails.
*/ */
unsigned char *zero_alloc( size_t len ); unsigned char *mbedtls_test_zero_alloc( size_t len );
/** /**
* Allocate and fill a buffer from hex data. * Allocate and fill a buffer from hex data.

View file

@ -100,7 +100,7 @@ void mbedtls_test_hexify( unsigned char *obuf,
} }
} }
unsigned char *zero_alloc( size_t len ) unsigned char *mbedtls_test_zero_alloc( size_t len )
{ {
void *p; void *p;
size_t actual_len = ( len != 0 ) ? len : 1; size_t actual_len = ( len != 0 ) ? len : 1;
@ -120,7 +120,7 @@ unsigned char *unhexify_alloc( const char *ibuf, size_t *olen )
*olen = strlen( ibuf ) / 2; *olen = strlen( ibuf ) / 2;
if( *olen == 0 ) if( *olen == 0 )
return( zero_alloc( *olen ) ); return( mbedtls_test_zero_alloc( *olen ) );
obuf = mbedtls_calloc( 1, *olen ); obuf = mbedtls_calloc( 1, *olen );
TEST_HELPER_ASSERT( obuf != NULL ); TEST_HELPER_ASSERT( obuf != NULL );

View file

@ -129,7 +129,7 @@ void aes_encrypt_xts( char *hex_key_string, char *hex_data_unit_string,
dst = unhexify_alloc( hex_dst_string, &dst_len ); dst = unhexify_alloc( hex_dst_string, &dst_len );
TEST_ASSERT( src_len == dst_len ); TEST_ASSERT( src_len == dst_len );
output = zero_alloc( dst_len ); output = mbedtls_test_zero_alloc( dst_len );
TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == 0 );
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, src_len, TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, src_len,
@ -172,7 +172,7 @@ void aes_decrypt_xts( char *hex_key_string, char *hex_data_unit_string,
dst = unhexify_alloc( hex_dst_string, &dst_len ); dst = unhexify_alloc( hex_dst_string, &dst_len );
TEST_ASSERT( src_len == dst_len ); TEST_ASSERT( src_len == dst_len );
output = zero_alloc( dst_len ); output = mbedtls_test_zero_alloc( dst_len );
TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == 0 );
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, src_len, TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, src_len,

View file

@ -55,7 +55,7 @@ void base64_encode_hex( data_t * src, char * dst, int dst_buf_size,
unsigned char *res = NULL; unsigned char *res = NULL;
size_t len; size_t len;
res = zero_alloc( dst_buf_size ); res = mbedtls_test_zero_alloc( dst_buf_size );
TEST_ASSERT( mbedtls_base64_encode( res, dst_buf_size, &len, src->x, src->len ) == result ); TEST_ASSERT( mbedtls_base64_encode( res, dst_buf_size, &len, src->x, src->len ) == result );
if( result == 0 ) if( result == 0 )
@ -76,7 +76,7 @@ void base64_decode_hex( char * src, data_t * dst, int dst_buf_size,
unsigned char *res = NULL; unsigned char *res = NULL;
size_t len; size_t len;
res = zero_alloc( dst_buf_size ); res = mbedtls_test_zero_alloc( dst_buf_size );
TEST_ASSERT( mbedtls_base64_decode( res, dst_buf_size, &len, (unsigned char *) src, TEST_ASSERT( mbedtls_base64_decode( res, dst_buf_size, &len, (unsigned char *) src,
strlen( src ) ) == result ); strlen( src ) ) == result );

View file

@ -43,7 +43,7 @@ void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw,
params.p = params_hex->x; params.p = params_hex->x;
params.len = params_hex->len; params.len = params_hex->len;
my_out = zero_alloc( ref_out->len ); my_out = mbedtls_test_zero_alloc( ref_out->len );
my_ret = mbedtls_pkcs5_pbes2( &params, MBEDTLS_PKCS5_DECRYPT, my_ret = mbedtls_pkcs5_pbes2( &params, MBEDTLS_PKCS5_DECRYPT,
pw->x, pw->len, data->x, data->len, my_out ); pw->x, pw->len, data->x, data->len, my_out );