@@ -43,54 +43,60 @@ int mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
43
43
GO_ON :
44
44
#endif
45
45
46
+ #ifdef BN_S_MP_FFT_MUL_C
47
+ if ((MP_MIN (a -> used , b -> used ) >= FFT_MUL_LOWER_CO ) && (MP_MAX (a -> used , b -> used ) < FFT_MUL_UPPER_CO )) {
48
+ res = s_mp_fft_mul (a , b , c );
49
+ } else
50
+ #endif
51
+
46
52
#ifdef BN_S_MP_TOOM_COOK_5_MUL_C
47
53
48
- if (MP_MIN (a -> used , b -> used ) >= TOOM_COOK_5_MUL_CO ) {
49
- res = s_mp_toom_cook_5_mul (a , b , c );
50
- } else
54
+ if (MP_MIN (a -> used , b -> used ) >= TOOM_COOK_5_MUL_CO ) {
55
+ res = s_mp_toom_cook_5_mul (a , b , c );
56
+ } else
51
57
#endif
52
58
53
59
#ifdef BN_S_MP_TOOM_COOK_4_MUL_C
54
- if (MP_MIN (a -> used , b -> used ) >= TOOM_COOK_4_MUL_CO ) {
55
- res = s_mp_toom_cook_4_mul (a , b , c );
56
- } else
60
+ if (MP_MIN (a -> used , b -> used ) >= TOOM_COOK_4_MUL_CO ) {
61
+ res = s_mp_toom_cook_4_mul (a , b , c );
62
+ } else
57
63
#endif
58
- /* use Toom-Cook? */
64
+ /* use Toom-Cook? */
59
65
#ifdef BN_S_MP_TOOM_MUL_C
60
- if (MP_MIN (a -> used , b -> used ) >= TOOM_MUL_CUTOFF ) {
61
- res = s_mp_toom_mul (a , b , c );
62
- } else
66
+ if (MP_MIN (a -> used , b -> used ) >= TOOM_MUL_CUTOFF ) {
67
+ res = s_mp_toom_mul (a , b , c );
68
+ } else
63
69
#endif
64
70
#ifdef BN_S_MP_KARATSUBA_MUL_C
65
- /* use Karatsuba? */
66
- if (MP_MIN (a -> used , b -> used ) >= KARATSUBA_MUL_CUTOFF ) {
67
- res = s_mp_karatsuba_mul (a , b , c );
68
- } else
71
+ /* use Karatsuba? */
72
+ if (MP_MIN (a -> used , b -> used ) >= KARATSUBA_MUL_CUTOFF ) {
73
+ res = s_mp_karatsuba_mul (a , b , c );
74
+ } else
69
75
#endif
70
- {
71
- /* can we use the fast multiplier?
72
- *
73
- * The fast multiplier can be used if the output will
74
- * have less than MP_WARRAY digits and the number of
75
- * digits won't affect carry propagation
76
- */
77
- int digs = a -> used + b -> used + 1 ;
76
+ {
77
+ /* can we use the fast multiplier?
78
+ *
79
+ * The fast multiplier can be used if the output will
80
+ * have less than MP_WARRAY digits and the number of
81
+ * digits won't affect carry propagation
82
+ */
83
+ int digs = a -> used + b -> used + 1 ;
78
84
79
85
#ifdef BN_S_MP_MUL_DIGS_FAST_C
80
- if ((digs < (int )MP_WARRAY ) &&
81
- (MP_MIN (a -> used , b -> used ) <=
82
- (int )(1u << ((CHAR_BIT * sizeof (mp_word )) - (2u * (size_t )DIGIT_BIT ))))) {
83
- res = s_mp_mul_digs_fast (a , b , c , digs );
84
- } else
86
+ if ((digs < (int )MP_WARRAY ) &&
87
+ (MP_MIN (a -> used , b -> used ) <=
88
+ (int )(1u << ((CHAR_BIT * sizeof (mp_word )) - (2u * (size_t )MP_DIGIT_BIT ))))) {
89
+ res = s_mp_mul_digs_fast (a , b , c , digs );
90
+ } else
85
91
#endif
86
- {
92
+ {
87
93
#ifdef BN_S_MP_MUL_DIGS_C
88
- res = s_mp_mul_digs (a , b , c , a -> used + b -> used + 1 );
94
+ res = s_mp_mul_digs (a , b , c , a -> used + b -> used + 1 );
89
95
#else
90
- res = MP_VAL ;
96
+ res = MP_VAL ;
91
97
#endif
98
+ }
92
99
}
93
- }
94
100
END :
95
101
c -> sign = (c -> used > 0 ) ? neg : MP_ZPOS ;
96
102
return res ;
0 commit comments