projects
/
u
/
mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f4535c6
)
Error return for Rabin-Miller context creation.
author
mdw
<mdw>
Thu, 11 Nov 2004 00:56:25 +0000
(
00:56
+0000)
committer
mdw
<mdw>
Thu, 11 Nov 2004 00:56:25 +0000
(
00:56
+0000)
rabin.c
patch
|
blob
|
blame
|
history
rabin.h
patch
|
blob
|
blame
|
history
diff --git
a/rabin.c
b/rabin.c
index
729ecce
..
4c08f87
100644
(file)
--- a/
rabin.c
+++ b/
rabin.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id
: rabin.c,v 1.9 2004/04/08 01:36:15 mdw Exp
$
+ * $Id$
*
* Miller-Rabin primality test
*
*
* Miller-Rabin primality test
*
@@
-42,19
+42,23
@@
* Arguments: @rabin *r@ = pointer to Rabin-Miller context
* @mp *m@ = pointer to number to test
*
* Arguments: @rabin *r@ = pointer to Rabin-Miller context
* @mp *m@ = pointer to number to test
*
- * Returns:
---
+ * Returns:
Zero on success, nonzero on failure.
*
* Use: Precomputes some useful values for performing the
* Miller-Rabin probabilistic primality test.
*/
*
* Use: Precomputes some useful values for performing the
* Miller-Rabin probabilistic primality test.
*/
-
void
rabin_create(rabin *r, mp *m)
+
int
rabin_create(rabin *r, mp *m)
{
mp *m1 = mp_sub(MP_NEW, m, MP_ONE);
{
mp *m1 = mp_sub(MP_NEW, m, MP_ONE);
- mpmont_create(&r->mm, m);
+ if (mpmont_create(&r->mm, m)) {
+ MP_DROP(m1);
+ return (-1);
+ }
r->r = mp_odd(MP_NEW, m1, &r->s);
r->m1 = mp_sub(MP_NEW, m, r->mm.r);
mp_drop(m1);
r->r = mp_odd(MP_NEW, m1, &r->s);
r->m1 = mp_sub(MP_NEW, m, r->mm.r);
mp_drop(m1);
+ return (0);
}
/* --- @rabin_destroy@ --- *
}
/* --- @rabin_destroy@ --- *
diff --git
a/rabin.h
b/rabin.h
index
7fe4965
..
9bc0eb6
100644
(file)
--- a/
rabin.h
+++ b/
rabin.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id
: rabin.h,v 1.7 2004/04/08 01:36:15 mdw Exp
$
+ * $Id$
*
* Miller-Rabin primality test
*
*
* Miller-Rabin primality test
*
@@
-64,13
+64,13
@@
typedef struct rabin {
* Arguments: @rabin *r@ = pointer to Rabin-Miller context
* @mp *m@ = pointer to number to test
*
* Arguments: @rabin *r@ = pointer to Rabin-Miller context
* @mp *m@ = pointer to number to test
*
- * Returns:
---
+ * Returns:
Zero on success, nonzero for failure.
*
* Use: Precomputes some useful values for performing the
* Miller-Rabin probabilistic primality test.
*/
*
* Use: Precomputes some useful values for performing the
* Miller-Rabin probabilistic primality test.
*/
-extern
void
rabin_create(rabin */*r*/, mp */*m*/);
+extern
int
rabin_create(rabin */*r*/, mp */*m*/);
/* --- @rabin_destroy@ --- *
*
/* --- @rabin_destroy@ --- *
*