1
1
/*
2
2
* Benchmark demonstration program
3
3
*
4
- * Copyright (C) 2006-2016 , Arm Limited, All Rights Reserved
4
+ * Copyright (C) 2006-2018 , Arm Limited, All Rights Reserved
5
5
* SPDX-License-Identifier: Apache-2.0
6
6
*
7
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may
145
145
/*
146
146
* Uncomment this line to enable ECDSA benchmark.
147
147
*/
148
- // #define ENABLE_ECDSA
148
+ #define ENABLE_ECDSA
149
149
150
150
/*
151
151
* 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 )
758
758
mbedtls_snprintf ( title, sizeof ( title ), " ECDSA-%s" ,
759
759
curve_info->name );
760
760
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 ,
762
762
tmp, &sig_len, myrand, NULL ) );
763
763
764
764
mbedtls_ecdsa_free ( &ecdsa );
@@ -771,7 +771,7 @@ static void test_pk( const todo_list * todo )
771
771
mbedtls_ecdsa_init ( &ecdsa );
772
772
773
773
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 ,
775
775
tmp, &sig_len, myrand, NULL ) != 0 )
776
776
{
777
777
mbedtls_exit ( 1 );
@@ -781,7 +781,7 @@ static void test_pk( const todo_list * todo )
781
781
mbedtls_snprintf ( title, sizeof ( title ), " ECDSA-%s" ,
782
782
curve_info->name );
783
783
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 ,
785
785
tmp, sig_len ) );
786
786
787
787
mbedtls_ecdsa_free ( &ecdsa );
@@ -899,8 +899,6 @@ static void test_pk( const todo_list * todo )
899
899
static int benchmark ( int argc, char *argv[], mbedtls_platform_context* ctx )
900
900
{
901
901
int i;
902
- unsigned char tmp[200 ];
903
- char title[TITLE_LEN];
904
902
todo_list todo;
905
903
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
906
904
unsigned char malloc_buf[HEAP_SIZE] = { 0 };
0 commit comments