summaryrefslogtreecommitdiff
path: root/libmp/port/mpinvert.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmp/port/mpinvert.c')
-rw-r--r--libmp/port/mpinvert.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libmp/port/mpinvert.c b/libmp/port/mpinvert.c
index ee263070..45912d6b 100644
--- a/libmp/port/mpinvert.c
+++ b/libmp/port/mpinvert.c
@@ -9,13 +9,15 @@ void
mpinvert(mpint *b, mpint *m, mpint *res)
{
mpint *dc1, *dc2; // don't care
+ int r;
dc1 = mpnew(0);
dc2 = mpnew(0);
mpextendedgcd(b, m, dc1, res, dc2);
- if(mpcmp(dc1, mpone) != 0)
- abort();
- mpmod(res, m, res);
+ r = mpcmp(dc1, mpone);
mpfree(dc1);
mpfree(dc2);
+ if(r != 0)
+ sysfatal("mpinvert: no inverse");
+ mpmod(res, m, res);
}