1818 #define PRI64 "ll"
1919#endif
2020
21+ #ifdef TFM_DESC
22+ #include <tfm.h>
23+ #endif
2124
2225#define DO (x ) do{ \
2326 int err; \
@@ -674,6 +677,18 @@ static void time_prng(void)
674677 }
675678}
676679
680+ static int check_tfm_limit (unsigned long x )
681+ {
682+ #ifdef TFM_DESC
683+ if (strcasecmp (ltc_mp .name , "tomsfastmath" ) == 0 ) {
684+ if (x * 2 > FP_MAX_SIZE ) return 1 ;
685+ }
686+ #else
687+ LTC_UNUSED_PARAM (x );
688+ #endif
689+ return 0 ;
690+ }
691+
677692#if defined(LTC_MDSA )
678693/* time various DSA operations */
679694static void time_dsa (void )
@@ -691,15 +706,14 @@ static void time_dsa(void)
691706 { 20 , 128 },
692707 { 24 , 192 },
693708 { 28 , 256 },
694- #ifndef TFM_DESC
695709 { 32 , 512 },
696- #endif
697710 };
698711
699712 if (ltc_mp .name == NULL ) return ;
700713
701714 print_csv_header ("group" , "modulus" );
702715 for (x = 0 ; x < (sizeof (groups ) / sizeof (groups [0 ])); x ++ ) {
716+ if (check_tfm_limit (groups [x ].modulus * 8 )) break ;
703717 t2 = 0 ;
704718 for (y = 0 ; y < 4 ; y ++ ) {
705719 t_start ();
@@ -735,7 +749,6 @@ static void time_dsa(void)
735749static void time_dsa (void ) { fprintf (stderr , "NO DSA\n" ); }
736750#endif
737751
738-
739752#if defined(LTC_MRSA )
740753/* time various RSA operations */
741754static void time_rsa (void )
@@ -751,6 +764,7 @@ static void time_rsa(void)
751764
752765 print_csv_header ("keysize" , NULL );
753766 for (x = 2048 ; x <= 8192 ; x <<= 1 ) {
767+ if (check_tfm_limit (x )) break ;
754768
755769#ifndef TIMING_DONT_MAKE_KEY
756770 t2 = 0 ;
@@ -861,16 +875,15 @@ static void time_dh(void)
861875 ulong64 t1 , t2 ;
862876 unsigned long i , x , y ;
863877 static unsigned long sizes [] = {768 /8 , 1024 /8 , 1536 /8 , 2048 /8 ,
864- #ifndef TFM_DESC
865878 3072 /8 , 4096 /8 , 6144 /8 , 8192 /8 ,
866- #endif
867879 100000
868880 };
869881
870882 if (ltc_mp .name == NULL ) return ;
871883
872884 print_csv_header ("keysize" , NULL );
873885 for (x = sizes [i = 0 ]; x < 100000 ; x = sizes [++ i ]) {
886+ if (check_tfm_limit (x )) break ;
874887 t2 = 0 ;
875888 for (y = 0 ; y < 16 ; y ++ ) {
876889 DO (dh_set_pg_groupsize (x , & key ));
@@ -932,6 +945,7 @@ static void time_ecc(void)
932945
933946 print_csv_header ("keysize" , NULL );
934947 for (x = ecc_key_sizes [i = 0 ]; x < 100000 ; x = ecc_key_sizes [++ i ]) {
948+ if (check_tfm_limit (x )) break ;
935949
936950#ifndef TIMING_DONT_MAKE_KEY
937951 t2 = 0 ;
0 commit comments