static PyObject *epmeth_frombuf(PyObject *me, PyObject *arg)
{
+ struct bin in;
buf b;
- char *p;
- Py_ssize_t sz;
PyObject *rc = 0;
ec pp = EC_INIT;
- if (!PyArg_ParseTuple(arg, "s#:frombuf", &p, &sz)) goto end;
- buf_init(&b, p, sz);
+ if (!PyArg_ParseTuple(arg, "O&:frombuf", convbin, &in)) goto end;
+ buf_init(&b, (/*unconst*/ void *)in.p, in.sz);
if (buf_getec(&b, &pp)) VALERR("malformed data");
rc = Py_BuildValue("(NN)", ecpt_pywrapout(me, &pp),
bytestring_pywrapbuf(&b));
static PyObject *epmeth_fromraw(PyObject *me, PyObject *arg)
{
- char *p;
- Py_ssize_t len;
+ struct bin in;
buf b;
PyObject *rc = 0;
ec_curve *cc;
ec pp = EC_INIT;
- if (!PyArg_ParseTuple(arg, "s#:fromraw", &me, &p, &len)) return (0);
- buf_init(&b, p, len);
+ if (!PyArg_ParseTuple(arg, "O&:fromraw", convbin, &in)) return (0);
+ buf_init(&b, (/*unconst*/ void *)in.p, in.sz);
cc = ECCURVE_C(me);
if (ec_getraw(cc, &b, &pp))
VALERR("bad point");
static PyObject *epmeth_os2ecp(PyObject *me, PyObject *arg, PyObject *kw)
{
- char *p;
- Py_ssize_t len;
+ struct bin in;
buf b;
PyObject *rc = 0;
ec_curve *cc;
ec pp = EC_INIT;
static const char *const kwlist[] = { "buf", "flags", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:os2ecp", KWLIST,
- &p, &len, convuint, &f))
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:os2ecp", KWLIST,
+ convbin, &in, convuint, &f))
return (0);
- buf_init(&b, p, len);
+ buf_init(&b, (/*unconst*/ void *)in.p, in.sz);
cc = ECCURVE_C(me);
if (ec_os2ecp(cc, f, &b, &pp)) VALERR("bad point");
EC_IN(cc, &pp, &pp);
int rc = -1;
PyObject *y = 0, *z = 0, *t = 0;
mp *xx = 0;
- const void *q;
int n;
qd_parse qd;
getecptout(p, x);
goto fix;
} else if (PyString_Check(x)) {
- if (PyObject_AsReadBuffer(x, &q, &n))
- goto end;
- qd.p = q;
+ qd.p = PyString_AS_STRING(x);
qd.e = 0;
if (!ec_ptparse(&qd, p))
VALERR(qd.e);