@@ -1917,6 +1917,7 @@ static int numBlocks = NUM_BLOCKS;
19171917static word32 bench_size = BENCH_SIZE ;
19181918static int base2 = 1 ;
19191919static int digest_stream = 1 ;
1920+ static int encrypt_only = 0 ;
19201921
19211922#ifdef MULTI_VALUE_STATISTICS
19221923static int minimum_runs = 0 ;
@@ -5767,27 +5768,54 @@ void bench_chacha(void)
57675768 XMEMSET (enc , 0 , sizeof (ChaCha ));
57685769 wc_Chacha_SetKey (enc , bench_key , 16 );
57695770
5770- bench_stats_start (& count , & start );
5771- do {
5772- for (i = 0 ; i < numBlocks ; i ++ ) {
5773- ret = wc_Chacha_SetIV (enc , bench_iv , 0 );
5774- if (ret < 0 ) {
5775- printf ("wc_Chacha_SetIV error: %d\n" , ret );
5776- goto exit ;
5771+ if (encrypt_only ) {
5772+ ret = wc_Chacha_SetIV (enc , bench_iv , 0 );
5773+ if (ret < 0 ) {
5774+ printf ("wc_Chacha_SetIV error: %d\n" , ret );
5775+ goto exit ;
5776+ }
5777+ bench_stats_start (& count , & start );
5778+ do {
5779+ for (i = 0 ; i < numBlocks ; i ++ ) {
5780+ ret = wc_Chacha_Process (enc , bench_cipher , bench_plain ,
5781+ bench_size );
5782+ if (ret < 0 ) {
5783+ printf ("wc_Chacha_Process error: %d\n" , ret );
5784+ goto exit ;
5785+ }
5786+ RECORD_MULTI_VALUE_STATS ();
57775787 }
5778- ret = wc_Chacha_Process (enc , bench_cipher , bench_plain , bench_size );
5779- if (ret < 0 ) {
5780- printf ("wc_Chacha_Process error: %d\n" , ret );
5781- goto exit ;
5788+ count += i ;
5789+ } while (bench_stats_check (start )
5790+ #ifdef MULTI_VALUE_STATISTICS
5791+ || runs < minimum_runs
5792+ #endif
5793+ );
5794+ }
5795+ else {
5796+ bench_stats_start (& count , & start );
5797+ do {
5798+ for (i = 0 ; i < numBlocks ; i ++ ) {
5799+ ret = wc_Chacha_SetIV (enc , bench_iv , 0 );
5800+ if (ret < 0 ) {
5801+ printf ("wc_Chacha_SetIV error: %d\n" , ret );
5802+ goto exit ;
5803+ }
5804+ ret = wc_Chacha_Process (enc , bench_cipher , bench_plain ,
5805+ bench_size );
5806+ if (ret < 0 ) {
5807+ printf ("wc_Chacha_Process error: %d\n" , ret );
5808+ goto exit ;
5809+ }
5810+ RECORD_MULTI_VALUE_STATS ();
57825811 }
5783- RECORD_MULTI_VALUE_STATS ();
5784- }
5785- count += i ;
5786- } while (bench_stats_check (start )
5787- #ifdef MULTI_VALUE_STATISTICS
5788- || runs < minimum_runs
5789- #endif
5790- );
5812+ count += i ;
5813+ } while (bench_stats_check (start )
5814+ #ifdef MULTI_VALUE_STATISTICS
5815+ || runs < minimum_runs
5816+ #endif
5817+ );
5818+ }
57915819
57925820 bench_stats_sym_finish ("CHACHA" , 0 , count , bench_size , start , 0 );
57935821#ifdef MULTI_VALUE_STATISTICS
@@ -13419,6 +13447,8 @@ int wolfcrypt_benchmark_main(int argc, char** argv)
1341913447#endif
1342013448 else if (string_matches (argv [1 ], "- dgst_full "))
1342113449 digest_stream = 0 ;
13450+ else if (string_matches (argv [1 ], "- enc_only "))
13451+ encrypt_only = 1 ;
1342213452#ifndef NO_RSA
1342313453 else if (string_matches (argv [1 ], "- rsa_sign "))
1342413454 rsa_sign_verify = 1 ;
0 commit comments