X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/5f959e502e3ceea40fb3c44593e090417fa11fc9..6140fbf7f12db17b61312571192eccc7d103e22b:/ec.c diff --git a/ec.c b/ec.c index dab6dfe..9946205 100644 --- a/ec.c +++ b/ec.c @@ -7,7 +7,7 @@ * (c) 2004 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the Python interface to Catacomb. * @@ -15,12 +15,12 @@ * 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 +233,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 +774,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); } @@ -903,17 +904,17 @@ static PyObject *eccurve_dopywrap(PyTypeObject *ty, eccurve_pyobj *cobj = newtype(ty, 0, c->ops->name); cobj->c = c; cobj->fobj = fobj; - cobj->ty.type.tp_basicsize = sizeof(ecpt_pyobj); - cobj->ty.type.tp_base = ecptcurve_pytype; + cobj->ty.ht_type.tp_basicsize = sizeof(ecpt_pyobj); + cobj->ty.ht_type.tp_base = ecptcurve_pytype; Py_INCREF(ecptcurve_pytype); - cobj->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_HEAPTYPE); - cobj->ty.type.tp_alloc = PyType_GenericAlloc; - cobj->ty.type.tp_free = 0; - cobj->ty.type.tp_new = ecpt_pynew; - PyType_Ready(&cobj->ty.type); + cobj->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_HEAPTYPE); + cobj->ty.ht_type.tp_alloc = PyType_GenericAlloc; + cobj->ty.ht_type.tp_free = 0; + cobj->ty.ht_type.tp_new = ecpt_pynew; + PyType_Ready(&cobj->ty.ht_type); return ((PyObject *)cobj); } @@ -984,7 +985,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 +1003,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 @@ -1327,7 +1328,7 @@ static PyObject *ecinfo_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) TYERR("point not from this curve"); ei.c = ECCURVE_C(e); EC_CREATE(&ei.g); - EC_COPY(&ei.g, ECPT_P(g)); + EC_OUT(ei.c, &ei.g, ECPT_P(g)); rc = (ecinfo_pyobj *)ty->tp_alloc(ty, 0); rc->ei = ei; rc->cobj = e; @@ -1487,12 +1488,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 } };