unsigned steps = 0;
dsa_seed ds;
char *k;
- int ksz;
+ Py_ssize_t ksz;
pgev evt = { 0 };
char *kwlist[] =
{ "class", "pbits", "qbits", "seed", "event", "nsteps", 0 };
if (!PyArg_ParseTuple(arg, "Os:parse", &me, &p)) goto end;
qd.p = p;
qd.e = 0;
- if (parse(&qd, &gp)) SYNERR(qd.e);
+ if (parse(&qd, &gp)) VALERR(qd.e);
rc = fginfo_pywrap(&gp, ty);
end:
return (rc);
sc.buf = PyString_AS_STRING(x);
sc.lim = sc.buf + PyString_GET_SIZE(x);
if (G_READ(g, xx, &mptext_stringops, &sc) || sc.buf < sc.lim)
- SYNERR("malformed group element string");
+ VALERR("malformed group element string");
} else
TYERR("can't convert to group element");
return (ge_pywrap((PyObject *)ty, xx));
gobj->ty.ht_type.tp_alloc = PyType_GenericAlloc;
gobj->ty.ht_type.tp_free = 0;
gobj->ty.ht_type.tp_new = ge_pynew;
- PyType_Ready(&gobj->ty.ht_type);
+ typeready(&gobj->ty.ht_type);
return ((PyObject *)gobj);
}
if ((x = G_TOINT(GE_G(me), MP_NEW, GE_X(me))) == 0)
TYERR("can't convert to integer");
- if (mp_tolong_checked(x, &l)) goto end;
- rc = PyInt_FromLong(l);
+ if (!mp_tolong_checked(x, &l, 0)) rc = PyInt_FromLong(l);
+ else rc = mp_topylong(x);
end:
mp_drop(x);
return (rc);
static PyObject *gemeth_toec(PyObject *me, PyObject *arg, PyObject *kw)
{
char *kwlist[] = { "curve", 0 };
- PyTypeObject *cty = ecpt_pytype;
+ PyTypeObject *cty = 0;
+ PyObject *rc = 0;
+ group *g;
+ ec_curve *c;
ec p = EC_INIT;
if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:toec", kwlist,
&cty)) goto end;
- if (!PyType_Check(cty) || !PyType_IsSubtype(cty, ecpt_pytype))
- TYERR("want subtype of catacomb.ECPt");
- if (G_TOEC(GE_G(me), &p, GE_X(me)))
+ g = GROUP_G(GE_GOBJ(me));
+ if (cty) {
+ if (!PyType_Check(cty) || !PyType_IsSubtype(cty, ecpt_pytype))
+ TYERR("want subtype of catacomb.ECPt");
+ Py_INCREF((PyObject *)cty);
+ } else if (strcmp(G_NAME(g), "ec") == 0) {
+ c = eccurve_copy(((gctx_ec *)g)->ei.c);
+ cty = (PyTypeObject *)eccurve_pywrap(0, c);
+ } else {
+ cty = ecpt_pytype;
+ Py_INCREF((PyObject *)cty);
+ }
+ if (G_TOEC(GE_G(me), &p, GE_X(me))) {
+ Py_DECREF((PyObject *)cty);
TYERR("can't convert to ec point");
- return (ecpt_pywrapout(cty, &p));
+ }
+ rc = ecpt_pywrapout(cty, &p);
+ Py_DECREF((PyObject *)cty);
end:
- return (0);
+ return (rc);
}
static PyObject *gemeth_tobuf(PyObject *me, PyObject *arg)
{
buf b;
char *p;
- int n;
+ Py_ssize_t n;
group *g;
ge *x = 0;
{
buf b;
char *p;
- int n;
+ Py_ssize_t n;
group *g;
ge *x = 0;
{
mptext_stringctx sc;
char *p;
- int n;
+ Py_ssize_t n;
group *g;
ge *x = 0;
g = GROUP_G(me);
x = G_CREATE(g);
if (G_READ(g, x, &mptext_stringops, &sc))
- SYNERR("bad group element string");
+ VALERR("bad group element string");
return (Py_BuildValue("(Ns#)", ge_pywrap(me, x),
- sc.buf, (int)(sc.lim - sc.buf)));
+ sc.buf, (Py_ssize_t)(sc.lim - sc.buf)));
end:
if (x) G_DESTROY(g, x);
return (0);
qd.p = p;
qd.e = 0;
if ((g = group_parse(&qd)) == 0)
- SYNERR(qd.e);
+ VALERR(qd.e);
return (group_pywrap(g));
end:
return (0);
gctx_prime *gg = (gctx_prime *)GROUP_G(me);
dp.p = MP_COPY(gg->mm.m);
dp.q = MP_COPY(gg->g.r);
- dp.g = mpmont_reduce(&gg->mm, MP_NEW, gg->gen);
+ dp.g = mpmont_reduce(&gg->mm, MP_NEW, gg->gen.x);
return (fginfo_pywrap(&dp, dhinfo_pytype));
}
gctx_bin *gg = (gctx_bin *)GROUP_G(me);
dp.p = MP_COPY(gg->r.p);
dp.q = MP_COPY(gg->g.r);
- dp.g = MP_COPY(gg->gen);
+ dp.g = MP_COPY(gg->gen.x);
return (fginfo_pywrap(&dp, bindhinfo_pytype));
}