18
18
#define PRI64 "ll"
19
19
#endif
20
20
21
+ #ifdef TFM_DESC
22
+ #include <tfm.h>
23
+ #endif
21
24
22
25
#define DO (x ) do{ \
23
26
int err; \
@@ -674,6 +677,16 @@ static void time_prng(void)
674
677
}
675
678
}
676
679
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
+ #endif
687
+ return 0 ;
688
+ }
689
+
677
690
#if defined(LTC_MDSA )
678
691
/* time various DSA operations */
679
692
static void time_dsa (void )
@@ -691,15 +704,14 @@ static void time_dsa(void)
691
704
{ 20 , 128 },
692
705
{ 24 , 192 },
693
706
{ 28 , 256 },
694
- #ifndef TFM_DESC
695
707
{ 32 , 512 },
696
- #endif
697
708
};
698
709
699
710
if (ltc_mp .name == NULL ) return ;
700
711
701
712
print_csv_header ("group" , "modulus" );
702
713
for (x = 0 ; x < (sizeof (groups ) / sizeof (groups [0 ])); x ++ ) {
714
+ if (check_tfm_limit (groups [x ].modulus * 8 )) break ;
703
715
t2 = 0 ;
704
716
for (y = 0 ; y < 4 ; y ++ ) {
705
717
t_start ();
@@ -735,7 +747,6 @@ static void time_dsa(void)
735
747
static void time_dsa (void ) { fprintf (stderr , "NO DSA\n" ); }
736
748
#endif
737
749
738
-
739
750
#if defined(LTC_MRSA )
740
751
/* time various RSA operations */
741
752
static void time_rsa (void )
@@ -751,6 +762,7 @@ static void time_rsa(void)
751
762
752
763
print_csv_header ("keysize" , NULL );
753
764
for (x = 2048 ; x <= 8192 ; x <<= 1 ) {
765
+ if (check_tfm_limit (x )) break ;
754
766
755
767
#ifndef TIMING_DONT_MAKE_KEY
756
768
t2 = 0 ;
@@ -861,16 +873,15 @@ static void time_dh(void)
861
873
ulong64 t1 , t2 ;
862
874
unsigned long i , x , y ;
863
875
static unsigned long sizes [] = {768 /8 , 1024 /8 , 1536 /8 , 2048 /8 ,
864
- #ifndef TFM_DESC
865
876
3072 /8 , 4096 /8 , 6144 /8 , 8192 /8 ,
866
- #endif
867
877
100000
868
878
};
869
879
870
880
if (ltc_mp .name == NULL ) return ;
871
881
872
882
print_csv_header ("keysize" , NULL );
873
883
for (x = sizes [i = 0 ]; x < 100000 ; x = sizes [++ i ]) {
884
+ if (check_tfm_limit (x )) break ;
874
885
t2 = 0 ;
875
886
for (y = 0 ; y < 16 ; y ++ ) {
876
887
DO (dh_set_pg_groupsize (x , & key ));
@@ -932,6 +943,7 @@ static void time_ecc(void)
932
943
933
944
print_csv_header ("keysize" , NULL );
934
945
for (x = ecc_key_sizes [i = 0 ]; x < 100000 ; x = ecc_key_sizes [++ i ]) {
946
+ if (check_tfm_limit (x )) break ;
935
947
936
948
#ifndef TIMING_DONT_MAKE_KEY
937
949
t2 = 0 ;
0 commit comments