Skip to content

Commit 4582a93

Browse files
Ron EldorRon Eldor
Ron Eldor
authored and
Ron Eldor
committed
Some minor modifications after refactoring
1. update copyright year. 2. Enable ecdsa. 3. Change `hlen` parameter in the ecdsa test to byte size, as this is what the API expects. 4. Remove unused variables.
1 parent a198d9b commit 4582a93

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

benchmark/main.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Benchmark demonstration program
33
*
4-
* Copyright (C) 2006-2016, Arm Limited, All Rights Reserved
4+
* Copyright (C) 2006-2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -145,7 +145,7 @@
145145
/*
146146
* Uncomment this line to enable ECDSA benchmark.
147147
*/
148-
//#define ENABLE_ECDSA
148+
#define ENABLE_ECDSA
149149

150150
/*
151151
* For heap usage estimates, we need an estimate of the overhead per allocated
@@ -758,7 +758,7 @@ static void test_pk( const todo_list * todo )
758758
mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s",
759759
curve_info->name );
760760
TIME_PUBLIC( title, "sign",
761-
ret = mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->bit_size,
761+
ret = mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, ( curve_info->bit_size + 7 ) / 8,
762762
tmp, &sig_len, myrand, NULL ) );
763763

764764
mbedtls_ecdsa_free( &ecdsa );
@@ -771,7 +771,7 @@ static void test_pk( const todo_list * todo )
771771
mbedtls_ecdsa_init( &ecdsa );
772772

773773
if( mbedtls_ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 ||
774-
mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->bit_size,
774+
mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, ( curve_info->bit_size + 7 ) / 8,
775775
tmp, &sig_len, myrand, NULL ) != 0 )
776776
{
777777
mbedtls_exit( 1 );
@@ -781,7 +781,7 @@ static void test_pk( const todo_list * todo )
781781
mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s",
782782
curve_info->name );
783783
TIME_PUBLIC( title, "verify",
784-
ret = mbedtls_ecdsa_read_signature( &ecdsa, buf, curve_info->bit_size,
784+
ret = mbedtls_ecdsa_read_signature( &ecdsa, buf, ( curve_info->bit_size + 7 ) / 8,
785785
tmp, sig_len ) );
786786

787787
mbedtls_ecdsa_free( &ecdsa );
@@ -899,8 +899,6 @@ static void test_pk( const todo_list * todo )
899899
static int benchmark( int argc, char *argv[], mbedtls_platform_context* ctx )
900900
{
901901
int i;
902-
unsigned char tmp[200];
903-
char title[TITLE_LEN];
904902
todo_list todo;
905903
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
906904
unsigned char malloc_buf[HEAP_SIZE] = { 0 };

0 commit comments

Comments
 (0)