From patchwork Tue Mar 12 15:18:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Solomon Peachy X-Patchwork-Id: 227047 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1F1802C0094 for ; Wed, 13 Mar 2013 02:19:09 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9184A9C11F; Tue, 12 Mar 2013 11:19:05 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x9A4JmmIYV0l; Tue, 12 Mar 2013 11:19:05 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D2B1A9C14B; Tue, 12 Mar 2013 11:19:00 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 77E3E9C11F for ; Tue, 12 Mar 2013 11:19:00 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VKvH+aRwbpPn for ; Tue, 12 Mar 2013 11:18:56 -0400 (EDT) Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.120]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C58719C14B for ; Tue, 12 Mar 2013 11:18:56 -0400 (EDT) X-Authority-Analysis: v=2.0 cv=cYNQXw/M c=1 sm=0 a=QKCpt3RAcCy1PgeoOVilzg==:17 a=2oGSFm5vdZwA:10 a=a-yIbLR1MzQA:10 a=649elMfuWG0A:10 a=svWV0_fRAAAA:8 a=uwAdwd_tm3sA:10 a=h8vrHELjbPVEOYcy17sA:9 a=OSKtzXyDyhAA:10 a=QKCpt3RAcCy1PgeoOVilzg==:117 X-Cloudmark-Score: 0 X-Authenticated-User: X-Originating-IP: 24.73.230.86 Received: from [24.73.230.86] ([24.73.230.86:37040] helo=stuffed.shaftnet.org) by cdptpa-oedge03.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id AD/E7-11869-F574F315; Tue, 12 Mar 2013 15:18:56 +0000 Received: from stuffed.shaftnet.org (localhost [127.0.0.1]) by stuffed.shaftnet.org (8.14.5/8.14.5) with ESMTP id r2CFIrpL014536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 Mar 2013 11:18:53 -0400 Received: (from pizza@localhost) by stuffed.shaftnet.org (8.14.5/8.14.5/Submit) id r2CFIqYh014533; Tue, 12 Mar 2013 11:18:52 -0400 From: Solomon Peachy To: hostap@lists.shmoo.com Subject: [PATCH] libtommath: condition fast_s_mp_mul_digs() on LTM_FAST Date: Tue, 12 Mar 2013 11:18:49 -0400 Message-Id: <1363101529-14451-1-git-send-email-pizza@shaftnet.org> X-Mailer: git-send-email 1.7.11.7 X-Virus-Scanned: clamav-milter 0.97.6 at stuffed.shaftnet.org X-Virus-Status: Clean Cc: Solomon Peachy X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com This function uses ~1.7kB of stack, and since there's a slower alternative, wrap it with LTM_FAST. Signed-off-by: Solomon Peachy --- src/tls/libtommath.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/tls/libtommath.c b/src/tls/libtommath.c index 741b442..89845ab 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 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 */