@@ -16,6 +16,13 @@ static prng_state yarrow_prng;
1616
1717static const char * filter_arg ;
1818
19+ static LTC_INLINE int should_skip (const char * name )
20+ {
21+ if (name && filter_arg && strstr (name , filter_arg ) == NULL )
22+ return 1 ;
23+ return 0 ;
24+ }
25+
1926static struct list {
2027 int id ;
2128 ulong64 spd1 , spd2 , avg ;
@@ -187,6 +194,9 @@ static void time_cipher_ecb(void)
187194 fprintf (stderr , "\n\nECB Time Trials for the Symmetric Ciphers:\n" );
188195 no_results = 0 ;
189196 for (x = 0 ; cipher_descriptor [x ].name != NULL ; x ++ ) {
197+ if (should_skip (cipher_descriptor [x ].name ))
198+ continue ;
199+
190200 ecb_start (x , key , cipher_descriptor [x ].min_key_length , 0 , & ecb );
191201
192202 /* sanity check on cipher */
@@ -260,6 +270,9 @@ static void time_cipher_cbc(void)
260270 fprintf (stderr , "\n\nCBC Time Trials for the Symmetric Ciphers:\n" );
261271 no_results = 0 ;
262272 for (x = 0 ; cipher_descriptor [x ].name != NULL ; x ++ ) {
273+ if (should_skip (cipher_descriptor [x ].name ))
274+ continue ;
275+
263276 cbc_start (x , pt , key , cipher_descriptor [x ].min_key_length , 0 , & cbc );
264277
265278 /* sanity check on cipher */
@@ -333,6 +346,9 @@ static void time_cipher_ctr(void)
333346 fprintf (stderr , "\n\nCTR Time Trials for the Symmetric Ciphers:\n" );
334347 no_results = 0 ;
335348 for (x = 0 ; cipher_descriptor [x ].name != NULL ; x ++ ) {
349+ if (should_skip (cipher_descriptor [x ].name ))
350+ continue ;
351+
336352 ctr_start (x , pt , key , cipher_descriptor [x ].min_key_length , 0 , CTR_COUNTER_LITTLE_ENDIAN , & ctr );
337353
338354 /* sanity check on cipher */
@@ -407,6 +423,9 @@ static void time_cipher_lrw(void)
407423 no_results = 0 ;
408424 for (x = 0 ; cipher_descriptor [x ].name != NULL ; x ++ ) {
409425 if (cipher_descriptor [x ].block_length != 16 ) continue ;
426+ if (should_skip (cipher_descriptor [x ].name ))
427+ continue ;
428+
410429 lrw_start (x , pt , key , cipher_descriptor [x ].min_key_length , key , 0 , & lrw );
411430
412431 /* sanity check on cipher */
@@ -485,8 +504,7 @@ static void time_hash(void)
485504 fprintf (stderr , "\n\nHASH Time Trials for:\n" );
486505 no_results = 0 ;
487506 for (x = 0 ; hash_descriptor [x ].name != NULL ; x ++ ) {
488-
489- if (filter_arg && strstr (hash_descriptor [x ].name , filter_arg ) == NULL )
507+ if (should_skip (hash_descriptor [x ].name ))
490508 continue ;
491509
492510 /* sanity check on hash */
@@ -601,8 +619,10 @@ static void time_prng(void)
601619 unsigned long x , y ;
602620 int err ;
603621
604- fprintf (stderr , "Timing PRNGs ( cycles/byte output, cycles add_entropy (32 bytes) :\n" );
622+ fprintf (stderr , "Timing PRNGs - cycles/byte output, cycles add_entropy (32 bytes) :\n" );
605623 for (x = 0 ; prng_descriptor [x ].name != NULL ; x ++ ) {
624+ if (should_skip (prng_descriptor [x ].name ))
625+ continue ;
606626
607627 /* sanity check on prng */
608628 if ((err = prng_descriptor [x ].test ()) != CRYPT_OK ) {
@@ -625,7 +645,7 @@ static void time_prng(void)
625645 t1 = (t_read () - t1 )>>1 ;
626646 if (t1 < t2 ) t2 = t1 ;
627647 }
628- fprintf (stderr , "%20s: %5" PRI64 "u " , prng_descriptor [x ].name , t2 >>12 );
648+ fprintf (stderr , "%20s: %5" PRI64 "u, " , prng_descriptor [x ].name , t2 >>12 );
629649#undef DO2
630650#undef DO1
631651
@@ -1381,7 +1401,7 @@ static void LTC_NORETURN die(int status)
13811401 "Run timing tests of all built-in algorithms, or only the one given in <alg>.\n\n"
13821402 "\talg\tThe algorithms to test. Use the '-l' option to check for valid values.\n"
13831403 "\tmpi\tThe MPI provider to use.\n"
1384- "\tfilter\tFilter within the algorithm class (currently only for 'hash'es).\n"
1404+ "\tfilter\tFilter within the algorithm class (currently only for 'cipher's, ' hash'es, and 'prng's ).\n"
13851405 "\t-l\tList all built-in algorithms that can be timed.\n"
13861406 "\t-h\tThe help you're looking at.\n\n"
13871407 "Examples:\n"
0 commit comments