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