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