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));
}
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);
}
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;
PyObject *rc = 0;
if (EC_ATINF(ECPT_P(me))) VALERR("point at infinity");
getecptout(&p, me);
- if (mp_tolong_checked(p.x, &l)) goto end;
- rc = PyInt_FromLong(l);
+ if (!mp_tolong_checked(p.x, &l, 0)) rc = PyInt_FromLong(l);
+ else rc = mp_topylong(p.x);
end:
EC_DESTROY(&p);
return (rc);
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));
static PyObject *meth__ECPtCurve_fromraw(PyObject *me, PyObject *arg)
{
char *p;
- int len;
+ Py_ssize_t len;
buf b;
PyObject *rc = 0;
ec_curve *cc;
PyObject *arg, PyObject *kw)
{
char *p;
- int len;
+ Py_ssize_t len;
buf b;
PyObject *rc = 0;
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))
{
buf b;
char *p;
- int sz;
+ Py_ssize_t sz;
PyObject *rc = 0;
ec pp = EC_INIT;