X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/bc243788edd0e564df8b67d0750a238d978c954b..1c6b925f0cf913ce3100c2ae3bcaed26a3f34bc1:/ec.c diff --git a/ec.c b/ec.c index 0489bc0..7fd369d 100644 --- a/ec.c +++ b/ec.c @@ -188,6 +188,7 @@ static PyObject *ecpt_pymul(PyObject *x, PyObject *y) if (ECPT_PYCHECK(x)) { PyObject *t; t = x; x = y; y = t; } if (!ECPT_PYCHECK(y) || (xx = tomp(x)) == 0) RETURN_NOTIMPL; ec_imul(ECPT_C(y), &zz, ECPT_P(y), xx); + MP_DROP(xx); return (ecpt_pywrap(ECPT_COBJ(y), &zz)); } @@ -204,8 +205,8 @@ static long ecpt_pyhash(PyObject *me) EC_OUT(ECPT_C(me), &p, ECPT_P(me)); ec_putraw(ECPT_C(me), &b, &p); EC_DESTROY(&p); - xfree(q); h = unihash_hash(&unihash_global, h, BBASE(&b), BLEN(&b)); + xfree(q); return (h % LONG_MAX); } @@ -301,7 +302,7 @@ static PyObject *epmeth_ec2osp(PyObject *me, PyObject *arg, PyObject *kw) int len; char *kwlist[] = { "flags", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "|i:ectosp", kwlist, &f)) + if (!PyArg_ParseTupleAndKeywords(arg, kw, "|i:ec2osp", kwlist, &f)) return (0); len = c->f->noctets * 2 + 1; rc = bytestring_pywrap(0, len); @@ -419,9 +420,9 @@ static int ecptxl_3(ec_curve *c, ec *p, if (!x || !y || !z) TYERR("missing argument"); if (!c) VALERR("internal form with no curve!"); - if ((p->x == coord_in(c->f, x)) == 0 || - (p->y == coord_in(c->f, y)) == 0 || - (z != Py_None && (p->z = coord_in(c->f, z))) == 0) + if ((p->x = coord_in(c->f, x)) == 0 || + (p->y = coord_in(c->f, y)) == 0 || + (z != Py_None && (p->z = coord_in(c->f, z)) == 0)) goto end; if (!p->z) p->z = MP_COPY(c->f->one); /* just in case */ rc = 0; @@ -787,10 +788,14 @@ static PyTypeObject ecptcurve_pytype_skel = { static PyObject *eccurve_pyrichcompare(PyObject *x, PyObject *y, int op) { - int b = ec_samep(ECCURVE_C(x), ECCURVE_C(y)); + int b; + + assert(ECCURVE_PYCHECK(x)); + if (!ECCURVE_PYCHECK(y)) RETURN_NOTIMPL; + b = ec_samep(ECCURVE_C(x), ECCURVE_C(y)); switch (op) { case Py_EQ: break; - case Py_NE: b = !b; + case Py_NE: b = !b; break; default: TYERR("can't order elliptic curves"); } return (getbool(b)); @@ -863,7 +868,7 @@ static PyObject *meth__ECPtCurve_os2ecp(PyObject *me, ec_curve *cc; int f = EC_XONLY | EC_LSB | EC_SORT | EC_EXPLY; ec pp = EC_INIT; - char *kwlist[] = { "buf", "flags", 0 }; + char *kwlist[] = { "class", "buf", "flags", 0 }; if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|f:os2ecp", kwlist, &me, &p, &len, &f))