1212 #define PRI64 "ll"
1313#endif
1414
15+ #ifdef TFM_DESC
16+ #include <tfm.h>
17+ #endif
1518
1619#define DO (x ) do{ \
1720 int err; \
@@ -672,6 +675,18 @@ static void time_prng(void)
672675 }
673676}
674677
678+ static int check_tfm_limit (unsigned long x )
679+ {
680+ #ifdef TFM_DESC
681+ if (strcasecmp (ltc_mp .name , "tomsfastmath" ) == 0 ) {
682+ if (x * 2 > FP_MAX_SIZE ) return 1 ;
683+ }
684+ #else
685+ LTC_UNUSED_PARAM (x );
686+ #endif
687+ return 0 ;
688+ }
689+
675690#if defined(LTC_MDSA )
676691/* time various DSA operations */
677692static void time_dsa (void )
@@ -689,15 +704,14 @@ static void time_dsa(void)
689704 { 20 , 128 },
690705 { 24 , 192 },
691706 { 28 , 256 },
692- #ifndef TFM_DESC
693707 { 32 , 512 },
694- #endif
695708 };
696709
697710 if (ltc_mp .name == NULL ) return ;
698711
699712 print_csv_header ("group" , "modulus" );
700713 for (x = 0 ; x < (sizeof (groups ) / sizeof (groups [0 ])); x ++ ) {
714+ if (check_tfm_limit (groups [x ].modulus * 8 )) break ;
701715 t2 = 0 ;
702716 for (y = 0 ; y < 4 ; y ++ ) {
703717 t_start ();
@@ -733,7 +747,6 @@ static void time_dsa(void)
733747static void time_dsa (void ) { fprintf (stderr , "NO DSA\n" ); }
734748#endif
735749
736-
737750#if defined(LTC_MRSA )
738751/* time various RSA operations */
739752static void time_rsa (void )
@@ -749,6 +762,7 @@ static void time_rsa(void)
749762
750763 print_csv_header ("keysize" , NULL );
751764 for (x = 2048 ; x <= 8192 ; x <<= 1 ) {
765+ if (check_tfm_limit (x )) break ;
752766
753767#ifndef TIMING_DONT_MAKE_KEY
754768 t2 = 0 ;
@@ -859,16 +873,15 @@ static void time_dh(void)
859873 ulong64 t1 , t2 ;
860874 unsigned long i , x , y ;
861875 static unsigned long sizes [] = {768 /8 , 1024 /8 , 1536 /8 , 2048 /8 ,
862- #ifndef TFM_DESC
863876 3072 /8 , 4096 /8 , 6144 /8 , 8192 /8 ,
864- #endif
865877 100000
866878 };
867879
868880 if (ltc_mp .name == NULL ) return ;
869881
870882 print_csv_header ("keysize" , NULL );
871883 for (x = sizes [i = 0 ]; x < 100000 ; x = sizes [++ i ]) {
884+ if (check_tfm_limit (x )) break ;
872885 t2 = 0 ;
873886 for (y = 0 ; y < 16 ; y ++ ) {
874887 DO (dh_set_pg_groupsize (x , & key ));
@@ -930,6 +943,7 @@ static void time_ecc(void)
930943
931944 print_csv_header ("keysize" , NULL );
932945 for (x = ecc_key_sizes [i = 0 ]; x < 100000 ; x = ecc_key_sizes [++ i ]) {
946+ if (check_tfm_limit (x )) break ;
933947
934948#ifndef TIMING_DONT_MAKE_KEY
935949 t2 = 0 ;
0 commit comments