projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pgen_safetest: Use a separate witness for each test.
[u/mdw/catacomb]
/
mpmont.c
diff --git
a/mpmont.c
b/mpmont.c
index
39f51ed
..
e62678d
100644
(file)
--- a/
mpmont.c
+++ b/
mpmont.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id
: mpmont.c,v 1.19 2004/04/08 01:36:15 mdw Exp
$
+ * $Id$
*
* Montgomery reduction
*
*
* Montgomery reduction
*
@@
-49,7
+49,7
@@
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
* @mp *m@ = modulus to use
*
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
* @mp *m@ = modulus to use
*
- * Returns:
---
+ * Returns:
Zero on success, nonzero on error.
*
* Use: Initializes a Montgomery reduction context ready for use.
* The argument @m@ must be a positive odd integer.
*
* Use: Initializes a Montgomery reduction context ready for use.
* The argument @m@ must be a positive odd integer.
@@
-57,18
+57,19
@@
#ifdef MPMONT_DISABLE
#ifdef MPMONT_DISABLE
-
void
mpmont_create(mpmont *mm, mp *m)
+
int
mpmont_create(mpmont *mm, mp *m)
{
mp_shrink(m);
mm->m = MP_COPY(m);
mm->r = MP_ONE;
mm->r2 = MP_ONE;
mm->mi = MP_ONE;
{
mp_shrink(m);
mm->m = MP_COPY(m);
mm->r = MP_ONE;
mm->r2 = MP_ONE;
mm->mi = MP_ONE;
+ return (0);
}
#else
}
#else
-
void
mpmont_create(mpmont *mm, mp *m)
+
int
mpmont_create(mpmont *mm, mp *m)
{
size_t n = MP_LEN(m);
mp *r2 = mp_new(2 * n + 1, 0);
{
size_t n = MP_LEN(m);
mp *r2 = mp_new(2 * n + 1, 0);
@@
-76,7
+77,8
@@
void mpmont_create(mpmont *mm, mp *m)
/* --- Take a copy of the modulus --- */
/* --- Take a copy of the modulus --- */
- assert(MP_ISPOS(m) && MP_ISODD(m));
+ if (!MP_POSP(m) || !MP_ODDP(m))
+ return (-1);
mm->m = MP_COPY(m);
/* --- Determine %$R^2$% --- */
mm->m = MP_COPY(m);
/* --- Determine %$R^2$% --- */
@@
-97,6
+99,7
@@
void mpmont_create(mpmont *mm, mp *m)
mp_div(0, &mm->r2, r2, m);
mm->r = mpmont_reduce(mm, MP_NEW, mm->r2);
MP_DROP(r2);
mp_div(0, &mm->r2, r2, m);
mm->r = mpmont_reduce(mm, MP_NEW, mm->r2);
MP_DROP(r2);
+ return (0);
}
#endif
}
#endif