@@ -1971,6 +1971,7 @@ static int numBlocks = NUM_BLOCKS;
19711971static word32 bench_size = BENCH_SIZE ;
19721972static int base2 = 1 ;
19731973static int digest_stream = 1 ;
1974+ static int encrypt_only = 0 ;
19741975
19751976#ifdef MULTI_VALUE_STATISTICS
19761977static int minimum_runs = 0 ;
@@ -5820,27 +5821,54 @@ void bench_chacha(void)
58205821 XMEMSET (enc , 0 , sizeof (ChaCha ));
58215822 wc_Chacha_SetKey (enc , bench_key , 16 );
58225823
5823- bench_stats_start (& count , & start );
5824- do {
5825- for (i = 0 ; i < numBlocks ; i ++ ) {
5826- ret = wc_Chacha_SetIV (enc , bench_iv , 0 );
5827- if (ret < 0 ) {
5828- printf ("wc_Chacha_SetIV error: %d\n" , ret );
5829- goto exit ;
5824+ if (encrypt_only ) {
5825+ ret = wc_Chacha_SetIV (enc , bench_iv , 0 );
5826+ if (ret < 0 ) {
5827+ printf ("wc_Chacha_SetIV error: %d\n" , ret );
5828+ goto exit ;
5829+ }
5830+ bench_stats_start (& count , & start );
5831+ do {
5832+ for (i = 0 ; i < numBlocks ; i ++ ) {
5833+ ret = wc_Chacha_Process (enc , bench_cipher , bench_plain ,
5834+ bench_size );
5835+ if (ret < 0 ) {
5836+ printf ("wc_Chacha_Process error: %d\n" , ret );
5837+ goto exit ;
5838+ }
5839+ RECORD_MULTI_VALUE_STATS ();
58305840 }
5831- ret = wc_Chacha_Process (enc , bench_cipher , bench_plain , bench_size );
5832- if (ret < 0 ) {
5833- printf ("wc_Chacha_Process error: %d\n" , ret );
5834- goto exit ;
5841+ count += i ;
5842+ } while (bench_stats_check (start )
5843+ #ifdef MULTI_VALUE_STATISTICS
5844+ || runs < minimum_runs
5845+ #endif
5846+ );
5847+ }
5848+ else {
5849+ bench_stats_start (& count , & start );
5850+ do {
5851+ for (i = 0 ; i < numBlocks ; i ++ ) {
5852+ ret = wc_Chacha_SetIV (enc , bench_iv , 0 );
5853+ if (ret < 0 ) {
5854+ printf ("wc_Chacha_SetIV error: %d\n" , ret );
5855+ goto exit ;
5856+ }
5857+ ret = wc_Chacha_Process (enc , bench_cipher , bench_plain ,
5858+ bench_size );
5859+ if (ret < 0 ) {
5860+ printf ("wc_Chacha_Process error: %d\n" , ret );
5861+ goto exit ;
5862+ }
5863+ RECORD_MULTI_VALUE_STATS ();
58355864 }
5836- RECORD_MULTI_VALUE_STATS ();
5837- }
5838- count += i ;
5839- } while (bench_stats_check (start )
5840- #ifdef MULTI_VALUE_STATISTICS
5841- || runs < minimum_runs
5842- #endif
5843- );
5865+ count += i ;
5866+ } while (bench_stats_check (start )
5867+ #ifdef MULTI_VALUE_STATISTICS
5868+ || runs < minimum_runs
5869+ #endif
5870+ );
5871+ }
58445872
58455873 bench_stats_sym_finish ("CHACHA" , 0 , count , bench_size , start , 0 );
58465874#ifdef MULTI_VALUE_STATISTICS
@@ -13470,6 +13498,8 @@ int wolfcrypt_benchmark_main(int argc, char** argv)
1347013498#endif
1347113499 else if (string_matches (argv [1 ], "- dgst_full "))
1347213500 digest_stream = 0 ;
13501+ else if (string_matches (argv [1 ], "- enc_only "))
13502+ encrypt_only = 1 ;
1347313503#ifndef NO_RSA
1347413504 else if (string_matches (argv [1 ], "- rsa_sign "))
1347513505 rsa_sign_verify = 1 ;
0 commit comments