svn commit: lorikeet r707 - in trunk/heimdal/lib/des/imath: .

lha at samba.org lha at samba.org
Thu Jan 11 04:01:04 GMT 2007


Author: lha
Date: 2007-01-11 04:01:04 +0000 (Thu, 11 Jan 2007)
New Revision: 707

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=lorikeet&rev=707

Log:
(s_udiv): allocate one more for q, remove debug printfs
Modified:
   trunk/heimdal/lib/des/imath/imath.c


Changeset:
Modified: trunk/heimdal/lib/des/imath/imath.c
===================================================================
--- trunk/heimdal/lib/des/imath/imath.c	2007-01-11 02:11:34 UTC (rev 706)
+++ trunk/heimdal/lib/des/imath/imath.c	2007-01-11 04:01:04 UTC (rev 707)
@@ -2,7 +2,7 @@
   Name:     imath.c
   Purpose:  Arbitrary precision integer arithmetic routines.
   Author:   M. J. Fromberger <http://www.dartmouth.edu/~sting/>
-  Info:     $Id: imath.c,v 1.6 2007/01/08 10:17:31 lha Exp $
+  Info:     $Id: imath.c,v 1.9 2007/01/11 03:59:34 lha Exp $
 
   Copyright (C) 2002 Michael J. Fromberger, All Rights Reserved.
 
@@ -284,7 +284,7 @@
 static int       s_reduce(mp_int x, mp_int m, mp_int mu, mp_int q1, mp_int q2);
 
 /* Modular exponentiation, using Barrett reduction */
-mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c);
+static mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c);
 
 /* Unsigned magnitude division.  Assumes |a| > |b|.  Allocates
    temporaries; overwrites a with quotient, b with remainder. */
@@ -2900,7 +2900,7 @@
 
 /* Perform modular exponentiation using Barrett's method, where mu is
    the reduction constant for m.  Assumes a < m, b > 0. */
-mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
+static mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
 {
   mp_digit  *db, *dbt, umu, d;
   mpz_t     temp[3]; 
@@ -2994,7 +2994,7 @@
   k = s_norm(a, b);
 
   ua = MP_USED(a); ub = MP_USED(b); btop = b->digits[ub - 1];
-  if((res = mp_int_init_size(&q, ua)) != MP_OK) return res;
+  if((res = mp_int_init_size(&q, ua + 1)) != MP_OK) return res;
   if((res = mp_int_init_size(&t, ua + 1)) != MP_OK) goto CLEANUP;
 
   da = MP_DIGITS(a);
@@ -3006,16 +3006,7 @@
 
   /* Solve for quotient digits, store in q.digits in reverse order */
   while(r.digits >= da) {
-    if (qpos > q.alloc) {
-      char buf[1024];
-      printf("qpos = %d q.alloc = %d da = %d ua = %d\n",
-	     (int)qpos, (int)q.alloc, (int)da, (int)ua);
-      mp_int_to_string(a, 10, buf, sizeof(buf));
-      printf("a = %s\n", buf);
-      mp_int_to_string(b, 10, buf, sizeof(buf));
-      printf("b = %s\n", buf);
-      assert(qpos <= q.alloc);
-    }	
+    assert(qpos <= q.alloc);
 
     if(s_ucmp(b, &r) > 0) {
       r.digits -= 1;



More information about the samba-cvs mailing list