~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ignore more generated files.
[catacomb]
/
mpbarrett-exp.c
diff --git
a/mpbarrett-exp.c
b/mpbarrett-exp.c
index
56e7c76
..
9885e2f
100644
(file)
--- a/
mpbarrett-exp.c
+++ b/
mpbarrett-exp.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id
: mpbarrett-exp.c,v 1.2 2004/04/08 01:36:15 mdw Exp
$
+ * $Id$
*
* Modular exponentiation using Barrett reduction
*
*
* Modular exponentiation using Barrett reduction
*
@@
-52,14
+52,16
@@
mp *mpbarrett_exp(mpbarrett *mb, mp *d, mp *a, mp *e)
MP_COPY(a);
MP_SHRINK(e);
MP_COPY(a);
MP_SHRINK(e);
- if (e->f & MP_NEG)
- a = mp_modinv(a, a, mb->m);
- if (!MP_LEN(e))
+ if (MP_ZEROP(e))
;
;
- else if (MP_LEN(e) < EXP_THRESH)
- EXP_SIMPLE(x, a, e);
- else
- EXP_WINDOW(x, a, e);
+ else {
+ if (MP_NEGP(e))
+ a = mp_modinv(a, a, mb->m);
+ if (MP_LEN(e) < EXP_THRESH)
+ EXP_SIMPLE(x, a, e);
+ else
+ EXP_WINDOW(x, a, e);
+ }
mp_drop(d);
mp_drop(spare);
mp_drop(a);
mp_drop(d);
mp_drop(spare);
mp_drop(a);