summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_mp_exteuclid.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-13 19:07:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-13 19:07:13 (GMT)
commit505f963287b050bd46871d4659cebc65986ca5ac (patch)
tree853ad3262ab07f7c5755e76b8154f36f24608014 /libtommath/bn_mp_exteuclid.c
parent689987ea924a8fded1801777c1a14ab1205fa826 (diff)
downloadtcl-505f963287b050bd46871d4659cebc65986ca5ac.zip
tcl-505f963287b050bd46871d4659cebc65986ca5ac.tar.gz
tcl-505f963287b050bd46871d4659cebc65986ca5ac.tar.bz2
Update to latest libtommath's "develop" branch. On the way to 1.2.0
Diffstat (limited to 'libtommath/bn_mp_exteuclid.c')
-rw-r--r--libtommath/bn_mp_exteuclid.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/libtommath/bn_mp_exteuclid.c b/libtommath/bn_mp_exteuclid.c
index c23a6c1..3af7467 100644
--- a/libtommath/bn_mp_exteuclid.c
+++ b/libtommath/bn_mp_exteuclid.c
@@ -1,24 +1,15 @@
#include "tommath_private.h"
#ifdef BN_MP_EXTEUCLID_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * SPDX-License-Identifier: Unlicense
- */
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
/* Extended euclidean algorithm of (a, b) produces
a*u1 + b*u2 = u3
*/
-int mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
+mp_err mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
{
mp_int u1, u2, u3, v1, v2, v3, t1, t2, t3, q, tmp;
- int err;
+ mp_err err;
if ((err = mp_init_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL)) != MP_OKAY) {
return err;
@@ -37,7 +28,7 @@ int mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp_in
}
/* loop while v3 != 0 */
- while (mp_iszero(&v3) == MP_NO) {
+ while (!MP_IS_ZERO(&v3)) {
/* q = u3/v3 */
if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) {
goto LBL_ERR;
@@ -116,7 +107,3 @@ LBL_ERR:
return err;
}
#endif
-
-/* ref: $Format:%D$ */
-/* git commit: $Format:%H$ */
-/* commit time: $Format:%ai$ */