chiark / gitweb /
pwsafe: Get the master passphrase before the new password.
[catacomb-python] / ec.c
diff --git a/ec.c b/ec.c
index fcbb8c253cc6ee160f97276b065b95451e11c061..21aa352990ebdaaa0bfc6a23b3dc5317810d7c3b 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -1,13 +1,11 @@
 /* -*-c-*-
- *
- * $Id$
  *
  * Elliptic curves
  *
  * (c) 2004 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of the Python interface to Catacomb.
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * Catacomb/Python is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with Catacomb/Python; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -233,7 +231,8 @@ end:
 static PyObject *epmeth_oncurvep(PyObject *me, PyObject *arg)
 {
   if (!PyArg_ParseTuple(arg, ":oncurvep")) return (0);
-  return (getbool(!ec_check(ECPT_C(me), ECPT_P(me))));
+  return (getbool(EC_ATINF(ECPT_P(me)) ||
+                 !EC_CHECK(ECPT_C(me), ECPT_P(me))));
 }
 
 static PyObject *epmeth_dbl(PyObject *me, PyObject *arg)
@@ -773,10 +772,10 @@ static int ecmmul_fill(void *pp, PyObject *me, PyObject *x, PyObject *m)
 {
   ec_mulfactor *f = pp;
 
+  EC_CREATE(&f->base);
   if (getecpt(ECCURVE_C(me), &f->base, x) ||
       (f->exp = getmp(m)) == 0)
     return (-1);
-  f->base = *ECPT_P(x);
   return (0);
 }
 
@@ -984,7 +983,7 @@ static PyObject *ecget_name(PyObject *me, void *hunoz)
 static PyObject *ecget_a(PyObject *me, void *hunoz)
   { return (fe_pywrap(ECCURVE_FOBJ(me), MP_COPY(ECCURVE_C(me)->a))); }
 
-static PyObject *ecget_b(PyObject *me, void *hunoz) 
+static PyObject *ecget_b(PyObject *me, void *hunoz)
   { return (fe_pywrap(ECCURVE_FOBJ(me), MP_COPY(ECCURVE_C(me)->b))); }
 
 static PyObject *ecget_field(PyObject *me, void *hunoz)
@@ -1002,7 +1001,7 @@ static PyGetSetDef eccurve_pygetset[] = {
   GET  (inf,           "E.inf -> point at infinity of this curve")
 #undef GETSETNAME
   { 0 }
-};  
+};
 
 static PyMethodDef eccurve_pymethods[] = {
 #define METHNAME(name) ecmeth_##name
@@ -1487,12 +1486,12 @@ static PyTypeObject ecinfo_pytype_skel = {
 
 static PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
-  METH (_ECPt_frombuf,         "frombuf(E, STR) -> (P, REST)")
-  METH (_ECPtCurve_fromraw,    "fromraw(E, STR) -> (P, REST)")
-  METH (_ECPt_parse,           "parse(E, STR) -> (P, REST)")
-  METH (_ECCurve_parse,        "parse(STR) -> (E, REST)")
-  METH (_ECInfo_parse,         "parse(STR) -> (I, REST)")
-  METH (_ECInfo__curven,       "_curven(N) -> I")
+  METH (_ECPt_frombuf,         "frombuf(E, STR) -> (P, REST)")
+  METH (_ECPtCurve_fromraw,    "fromraw(E, STR) -> (P, REST)")
+  METH (_ECPt_parse,           "parse(E, STR) -> (P, REST)")
+  METH (_ECCurve_parse,        "parse(STR) -> (E, REST)")
+  METH (_ECInfo_parse,         "parse(STR) -> (I, REST)")
+  METH (_ECInfo__curven,       "_curven(N) -> I")
 #undef METHNAME
   { 0 }
 };
@@ -1528,7 +1527,7 @@ static PyObject *namedcurves(void)
     }
     c = PyInt_FromLong(i);
   found:
-    PyDict_SetItemString(d, (/*unconst*/ char *)ectab[i].name, c);
+    PyDict_SetItemString(d, (/*unconst*/ char *)p, c);
     Py_DECREF(c);
   }
   ncurves = i;