/* -*-c-*-
*
- * $Id: ec-bin.c,v 1.7 2004/04/01 21:28:41 mdw Exp $
+ * $Id: ec-bin.c,v 1.8 2004/04/03 03:32:05 mdw Exp $
*
* Arithmetic for elliptic curves over binary fields
*
/*----- Revision history --------------------------------------------------*
*
* $Log: ec-bin.c,v $
+ * Revision 1.8 2004/04/03 03:32:05 mdw
+ * General robustification.
+ *
* Revision 1.7 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
d->z = dz;
MP_DROP(u);
MP_DROP(v);
- assert(!(d->x->f & MP_DESTROYED));
- assert(!(d->y->f & MP_DESTROYED));
- assert(!(d->z->f & MP_DESTROYED));
}
return (d);
}
* Arguments: @field *f@ = the underlying field for this elliptic curve
* @mp *a, *b@ = the coefficients for this curve
*
- * Returns: A pointer to the curve.
+ * Returns: A pointer to the curve, or null.
*
* Use: Creates a curve structure for an elliptic curve defined over
* a binary field. The @binproj@ variant uses projective
cc->c.a = F_IN(f, MP_NEW, a);
cc->c.b = F_IN(f, MP_NEW, b);
cc->bb = F_SQRT(f, MP_NEW, cc->c.b);
- cc->bb = F_SQRT(f, cc->bb, cc->bb);
+ if (cc->bb)
+ cc->bb = F_SQRT(f, cc->bb, cc->bb);
+ if (!cc->bb) {
+ MP_DROP(cc->c.a);
+ MP_DROP(cc->c.b);
+ DESTROY(cc);
+ return (0);
+ }
return (&cc->c);
}