+ BIN_SETLEN(rc, BLEN(&b));
+ return (rc);
+}
+
+static PyObject *epmeth_ec2osp(PyObject *me, PyObject *arg, PyObject *kw)
+{
+ buf b;
+ PyObject *rc;
+ char *p;
+ ec_curve *c = ECPT_C(me);
+ ec pp = EC_INIT;
+ unsigned f = EC_EXPLY;
+ int len;
+ static const char *const kwlist[] = { "flags", 0 };
+
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:ec2osp", KWLIST,
+ convuint, &f))
+ return (0);
+ len = c->f->noctets * 2 + 1;
+ rc = bytestring_pywrap(0, len);
+ p = BIN_PTR(rc);
+ buf_init(&b, p, len);
+ EC_OUT(c, &pp, ECPT_P(me));
+ if (ec_ec2osp(c, f, &b, &pp)) {
+ Py_DECREF(rc); rc = 0;
+ VALERR("invalid flags");
+ }
+ EC_DESTROY(&pp);
+ BIN_SETLEN(rc, BLEN(&b));
+end:
+ return (rc);
+}
+
+static PyObject *epmeth_frombuf(PyObject *me, PyObject *arg)
+{
+ struct bin in;
+ buf b;
+ PyObject *rc = 0;
+ ec pp = EC_INIT;
+
+ 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));
+end:
+ return (rc);
+}
+
+static PyObject *epmeth_parse(PyObject *me, PyObject *arg)
+{
+ char *p;
+ qd_parse qd;
+ PyObject *rc = 0;
+ int paren;
+ ec pp = EC_INIT;
+
+ if (!PyArg_ParseTuple(arg, "s:parse", &p)) goto end;
+ qd.p = p; qd.e = 0;
+ qd_skipspc(&qd); paren = qd_delim(&qd, '(');
+ if (!ec_ptparse(&qd, &pp)) VALERR(qd.e);
+ qd_skipspc(&qd); if (paren && !qd_delim(&qd, ')'))
+ { EC_DESTROY(&pp); VALERR("missing `)'"); }
+ rc = Py_BuildValue("(Ns)", ecpt_pywrapout(me, &pp), qd.p);
+end: