projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
General robustification.
[u/mdw/catacomb]
/
f-prime.c
diff --git
a/f-prime.c
b/f-prime.c
index
088032b
..
43d6da3
100644
(file)
--- a/
f-prime.c
+++ b/
f-prime.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: f-prime.c,v 1.
9 2004/04/01 21:28:41
mdw Exp $
+ * $Id: f-prime.c,v 1.
11 2004/04/03 03:32:05
mdw Exp $
*
* Prime fields with Montgomery arithmetic
*
*
* Prime fields with Montgomery arithmetic
*
@@
-30,6
+30,12
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: f-prime.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: f-prime.c,v $
+ * Revision 1.11 2004/04/03 03:32:05 mdw
+ * General robustification.
+ *
+ * Revision 1.10 2004/04/02 01:03:49 mdw
+ * Miscellaneous constification.
+ *
* Revision 1.9 2004/04/01 21:28:41 mdw
* Normal basis support (translates to poly basis internally). Rewrite
* EC and prime group table generators in awk, so that they can reuse data
* Revision 1.9 2004/04/01 21:28:41 mdw
* Normal basis support (translates to poly basis internally). Rewrite
* EC and prime group table generators in awk, so that they can reuse data
@@
-175,7
+181,7
@@
static mp *fhlv(field *ff, mp *d, mp *x) {
/* --- Field operations table --- */
/* --- Field operations table --- */
-static field_ops fops = {
+static
const
field_ops fops = {
FTY_PRIME, "prime",
fdestroy, frand, field_stdsamep,
fin, fout,
FTY_PRIME, "prime",
fdestroy, frand, field_stdsamep,
fin, fout,
@@
-188,7
+194,7
@@
static field_ops fops = {
*
* Arguments: @mp *p@ = the characteristic of the field
*
*
* Arguments: @mp *p@ = the characteristic of the field
*
- * Returns: A pointer to the field.
+ * Returns: A pointer to the field
or null
.
*
* Use: Creates a field structure for a prime field of size %$p$%,
* using Montgomery reduction for arithmetic.
*
* Use: Creates a field structure for a prime field of size %$p$%,
* using Montgomery reduction for arithmetic.
@@
-196,7
+202,11
@@
static field_ops fops = {
field *field_prime(mp *p)
{
field *field_prime(mp *p)
{
- fctx *f = CREATE(fctx);
+ fctx *f;
+
+ if (!MP_ISPOS(p) || !MP_ISODD(p))
+ return (0);
+ f = CREATE(fctx);
f->f.ops = &fops;
mpmont_create(&f->mm, p);
f->f.zero = MP_ZERO;
f->f.ops = &fops;
mpmont_create(&f->mm, p);
f->f.zero = MP_ZERO;