Skip to content

Commit d86a33b

Browse files
Ron EldorRon Eldor
Ron Eldor
authored and
Ron Eldor
committed
Add platform context to the test functions
Add the platform context to the test functions, as these are the functions handling the cryptographic modules.
1 parent 4582a93 commit d86a33b

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

benchmark/main.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,13 @@ typedef struct {
300300
rsa, dhm, ecdsa, ecdh;
301301
} todo_list;
302302

303-
static void test_md( const todo_list * todo )
303+
static void test_md( const todo_list * todo, mbedtls_platform_context* ctx )
304304
{
305305
unsigned char tmp[200];
306+
// The call below is used to avoid the "unused parameter" warning.
307+
// The context itself can be used by cryptographic calls which require it.
308+
// Please refer to https://github.com/ARMmbed/mbedtls/issues/1200 for more information.
309+
(void)ctx;
306310
memset( tmp, 0xBB, sizeof( tmp ) );
307311

308312
#if defined(MBEDTLS_MD4_C)
@@ -336,10 +340,14 @@ static void test_md( const todo_list * todo )
336340
#endif
337341
}
338342

339-
static void test_crypt( const todo_list * todo )
343+
static void test_crypt( const todo_list * todo, mbedtls_platform_context* ctx )
340344
{
341345
unsigned char tmp[200];
342346
char title[TITLE_LEN];
347+
// The call below is used to avoid the "unused parameter" warning.
348+
// The context itself can be used by cryptographic calls which require it.
349+
// Please refer to https://github.com/ARMmbed/mbedtls/issues/1200 for more information.
350+
(void)ctx;
343351
memset( tmp, 0xBB, sizeof( tmp ) );
344352

345353
#if defined(MBEDTLS_ARC4_C)
@@ -563,9 +571,13 @@ static void test_crypt( const todo_list * todo )
563571

564572
}
565573

566-
static void test_rng( const todo_list * todo )
574+
static void test_rng( const todo_list * todo, mbedtls_platform_context* ctx )
567575
{
568576
unsigned char tmp[200];
577+
// The call below is used to avoid the "unused parameter" warning.
578+
// The context itself can be used by cryptographic calls which require it.
579+
// Please refer to https://github.com/ARMmbed/mbedtls/issues/1200 for more information.
580+
(void)ctx;
569581
memset( tmp, 0xBB, sizeof( tmp ) );
570582

571583
#if defined(MBEDTLS_HAVEGE_C)
@@ -654,10 +666,14 @@ static void test_rng( const todo_list * todo )
654666
#endif
655667
}
656668

657-
static void test_pk( const todo_list * todo )
669+
static void test_pk( const todo_list * todo, mbedtls_platform_context* ctx )
658670
{
659671
unsigned char tmp[200];
660672
char title[TITLE_LEN];
673+
// The call below is used to avoid the "unused parameter" warning.
674+
// The context itself can be used by cryptographic calls which require it.
675+
// Please refer to https://github.com/ARMmbed/mbedtls/issues/1200 for more information.
676+
(void)ctx;
661677
memset( tmp, 0xBB, sizeof( tmp ) );
662678

663679
#if defined(MBEDTLS_RSA_C) && \
@@ -903,10 +919,7 @@ static int benchmark( int argc, char *argv[], mbedtls_platform_context* ctx )
903919
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
904920
unsigned char malloc_buf[HEAP_SIZE] = { 0 };
905921
#endif
906-
// The call below is used to avoid the "unused parameter" warning.
907-
// The context itself can be used by cryptographic calls which require it.
908-
// Please refer to https://github.com/ARMmbed/mbedtls/issues/1200 for more information.
909-
(void)ctx;
922+
910923
if( argc <= 1 )
911924
{
912925
memset( &todo, 1, sizeof( todo ) );
@@ -980,10 +993,10 @@ static int benchmark( int argc, char *argv[], mbedtls_platform_context* ctx )
980993
#endif
981994
memset( buf, 0xAA, sizeof( buf ) );
982995

983-
test_md( & todo );
984-
test_crypt( &todo );
985-
test_rng( &todo );
986-
test_pk( &todo );
996+
test_md( &todo, ctx );
997+
test_crypt( &todo, ctx );
998+
test_rng( &todo, ctx );
999+
test_pk( &todo, ctx );
9871000

9881001
mbedtls_printf("\r\nDONE\r\n");
9891002

0 commit comments

Comments
 (0)