tests: Get rid of mbedtls_test_unhexify() in unit test code
In test functions calling mbedtls_test_unhexify(), change the
type of the associated parameters from `char*` to `data_t`.
That way the `unhexify` operation is done by the test
framework and not by the unit test code.
Use for the new parameters of type data_t the name of the
local variable that used to store the `unhexify` version of
the `char*` parameter.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/tests/suites/test_suite_ecdh.function b/tests/suites/test_suite_ecdh.function
index 640dc76..32d41e6 100644
--- a/tests/suites/test_suite_ecdh.function
+++ b/tests/suites/test_suite_ecdh.function
@@ -340,7 +340,7 @@
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE */
-void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
+void ecdh_restart( int id, data_t *dA, data_t *dB, data_t *z,
int enable, int max_ops, int min_restart, int max_restart )
{
int ret;
@@ -348,10 +348,6 @@
unsigned char buf[1000];
const unsigned char *vbuf;
size_t len;
- unsigned char z[MBEDTLS_ECP_MAX_BYTES];
- size_t z_len;
- unsigned char rnd_buf_A[MBEDTLS_ECP_MAX_BYTES];
- unsigned char rnd_buf_B[MBEDTLS_ECP_MAX_BYTES];
rnd_buf_info rnd_info_A, rnd_info_B;
int cnt_restart;
mbedtls_ecp_group grp;
@@ -360,13 +356,11 @@
mbedtls_ecdh_init( &srv );
mbedtls_ecdh_init( &cli );
- z_len = mbedtls_test_unhexify( z, z_str );
+ rnd_info_A.buf = dA->x;
+ rnd_info_A.length = dA->len;
- rnd_info_A.buf = rnd_buf_A;
- rnd_info_A.length = mbedtls_test_unhexify( rnd_buf_A, dA_str );
-
- rnd_info_B.buf = rnd_buf_B;
- rnd_info_B.length = mbedtls_test_unhexify( rnd_buf_B, dB_str );
+ rnd_info_B.buf = dB->x;
+ rnd_info_B.length = dB->len;
/* The ECDH context is not guaranteed ot have an mbedtls_ecp_group structure
* in every configuration, therefore we load it separately. */
@@ -436,8 +430,8 @@
TEST_ASSERT( cnt_restart >= min_restart );
TEST_ASSERT( cnt_restart <= max_restart );
- TEST_ASSERT( len == z_len );
- TEST_ASSERT( memcmp( buf, z, len ) == 0 );
+ TEST_ASSERT( len == z->len );
+ TEST_ASSERT( memcmp( buf, z->x, len ) == 0 );
/* client computes shared secret */
memset( buf, 0, sizeof( buf ) );
@@ -453,8 +447,8 @@
TEST_ASSERT( cnt_restart >= min_restart );
TEST_ASSERT( cnt_restart <= max_restart );
- TEST_ASSERT( len == z_len );
- TEST_ASSERT( memcmp( buf, z, len ) == 0 );
+ TEST_ASSERT( len == z->len );
+ TEST_ASSERT( memcmp( buf, z->x, len ) == 0 );
exit:
mbedtls_ecp_group_free( &grp );