From 690f3ebe92cb93f0437a3bfdcee84b61c5b377ca Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Wed, 10 Jun 2020 10:42:18 +0200 Subject: [PATCH] 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 --- tests/include/test/helpers.h | 2 +- tests/src/helpers.c | 4 ++-- tests/suites/test_suite_aes.function | 4 ++-- tests/suites/test_suite_base64.function | 4 ++-- tests/suites/test_suite_pkcs5.function | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/include/test/helpers.h b/tests/include/test/helpers.h index 2d53cf9ea..134e49b7d 100644 --- a/tests/include/test/helpers.h +++ b/tests/include/test/helpers.h @@ -65,7 +65,7 @@ void mbedtls_test_hexify( unsigned char *obuf, * * 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. diff --git a/tests/src/helpers.c b/tests/src/helpers.c index 358f3e4ae..063ebcd68 100644 --- a/tests/src/helpers.c +++ b/tests/src/helpers.c @@ -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; 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; if( *olen == 0 ) - return( zero_alloc( *olen ) ); + return( mbedtls_test_zero_alloc( *olen ) ); obuf = mbedtls_calloc( 1, *olen ); TEST_HELPER_ASSERT( obuf != NULL ); diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function index 9734aa0d5..8fe0bda9b 100644 --- a/tests/suites/test_suite_aes.function +++ b/tests/suites/test_suite_aes.function @@ -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 ); 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_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 ); 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_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, src_len, diff --git a/tests/suites/test_suite_base64.function b/tests/suites/test_suite_base64.function index 3a8bf430f..dc6ec153b 100644 --- a/tests/suites/test_suite_base64.function +++ b/tests/suites/test_suite_base64.function @@ -55,7 +55,7 @@ void base64_encode_hex( data_t * src, char * dst, int dst_buf_size, unsigned char *res = NULL; 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 ); if( result == 0 ) @@ -76,7 +76,7 @@ void base64_decode_hex( char * src, data_t * dst, int dst_buf_size, unsigned char *res = NULL; 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, strlen( src ) ) == result ); diff --git a/tests/suites/test_suite_pkcs5.function b/tests/suites/test_suite_pkcs5.function index 26f1d3331..ee894f134 100644 --- a/tests/suites/test_suite_pkcs5.function +++ b/tests/suites/test_suite_pkcs5.function @@ -43,7 +43,7 @@ void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw, params.p = params_hex->x; 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( ¶ms, MBEDTLS_PKCS5_DECRYPT, pw->x, pw->len, data->x, data->len, my_out );