From: Solomon Peachy Date: Sat, 16 Mar 2013 10:01:03 +0000 (+0200) Subject: libtommath: Condition fast_s_mp_mul_digs() on LTM_FAST X-Git-Tag: aosp-kk-from-upstream~457 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de718493b408a30ee3c11f8ce0c226ec14389643;p=thirdparty%2Fhostap.git libtommath: Condition fast_s_mp_mul_digs() on LTM_FAST This function uses ~1.7kB of stack, and since there's a slower alternative, wrap it with LTM_FAST. Signed-off-by: Solomon Peachy --- diff --git a/src/tls/libtommath.c b/src/tls/libtommath.c index 741b442ca..821d7546f 100644 --- a/src/tls/libtommath.c +++ b/src/tls/libtommath.c @@ -42,6 +42,9 @@ /* Include faster sqr at the cost of about 0.5 kB in code */ #define BN_FAST_S_MP_SQR_C +/* About 0.25 kB of code, but ~1.7kB of stack space! */ +#define BN_FAST_S_MP_MUL_DIGS_C + #else /* LTM_FAST */ #define BN_MP_DIV_SMALL @@ -139,7 +142,9 @@ static int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs); static int s_mp_sqr(mp_int * a, mp_int * b); static int s_mp_mul_high_digs(mp_int * a, mp_int * b, mp_int * c, int digs); +#ifdef BN_FAST_S_MP_MUL_DIGS_C static int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs); +#endif #ifdef BN_MP_INIT_MULTI_C static int mp_init_multi(mp_int *mp, ...); @@ -2339,12 +2344,14 @@ static int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) mp_word r; mp_digit tmpx, *tmpt, *tmpy; +#ifdef BN_FAST_S_MP_MUL_DIGS_C /* can we use the fast multiplier? */ if (((digs) < MP_WARRAY) && MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { return fast_s_mp_mul_digs (a, b, c, digs); } +#endif if ((res = mp_init_size (&t, digs)) != MP_OKAY) { return res; @@ -2397,6 +2404,7 @@ static int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) } +#ifdef BN_FAST_S_MP_MUL_DIGS_C /* Fast (comba) multiplier * * This is the fast column-array [comba] multiplier. It is @@ -2482,6 +2490,7 @@ static int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) mp_clamp (c); return MP_OKAY; } +#endif /* BN_FAST_S_MP_MUL_DIGS_C */ /* init an mp_init for a given size */