summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_mp_karatsuba_sqr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtommath/bn_mp_karatsuba_sqr.c')
-rw-r--r--libtommath/bn_mp_karatsuba_sqr.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libtommath/bn_mp_karatsuba_sqr.c b/libtommath/bn_mp_karatsuba_sqr.c
index 315ceab..3bfe157 100644
--- a/libtommath/bn_mp_karatsuba_sqr.c
+++ b/libtommath/bn_mp_karatsuba_sqr.c
@@ -80,8 +80,8 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
if (mp_sqr (&x1, &x1x1) != MP_OKAY)
goto X1X1; /* x1x1 = x1*x1 */
- /* now calc (x1-x0)**2 */
- if (mp_sub (&x1, &x0, &t1) != MP_OKAY)
+ /* now calc (x1+x0)**2 */
+ if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
goto X1X1; /* t1 = x1 - x0 */
if (mp_sqr (&t1, &t1) != MP_OKAY)
goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */
@@ -89,8 +89,8 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
/* add x0y0 */
if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY)
goto X1X1; /* t2 = x0x0 + x1x1 */
- if (mp_sub (&t2, &t1, &t1) != MP_OKAY)
- goto X1X1; /* t1 = x0x0 + x1x1 - (x1-x0)*(x1-x0) */
+ if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY)
+ goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */
/* shift by B */
if (mp_lshd (&t1, B) != MP_OKAY)
@@ -115,3 +115,7 @@ ERR:
return err;
}
#endif
+
+/* $Source: /root/tcl/repos-to-convert/tcl/libtommath/bn_mp_karatsuba_sqr.c,v $ */
+/* $Revision: 1.1.1.2 $ */
+/* $Date: 2005/09/26 16:31:56 $ */