return (rc);
}
+static PyObject *rbmeth_os2ecp(PyObject *me, PyObject *arg, PyObject *kw)
+{
+ PyObject *cobj;
+ ec pt = EC_INIT;
+ unsigned f = EC_XONLY | EC_LSB | EC_SORT | EC_EXPLY;
+ PyObject *rc = 0;
+ static const char *const kwlist[] = { "curve", "flags", 0 };
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O&:os2ecp", KWLIST,
+ eccurve_pytype, &cobj, convuint, &f))
+ goto end;
+ if (ec_os2ecp(ECCURVE_C(cobj), f, BUF_B(me), &pt)) VALERR("bad point");
+ rc = ecpt_pywrapout(cobj, &pt);
+end:
+ return (rc);
+}
+
static PyObject *rbmeth_getge(PyObject *me, PyObject *arg)
{
PyObject *gobj;
NAMETH(getgf, "RBUF.getgf() -> X")
KWMETH(getecpt, "RBUF.getecpt([curve = None]) -> P")
METH (getecptraw, "RBUF.getecptraw(CURVE) -> P")
+ KWMETH(os2ecp, "RBUF.os2ecp(CURVE, [flags = ...]) -> P")
METH (getge, "RBUF.getge(GROUP) -> X")
METH (getgeraw, "RBUF.getgeraw(GROUP) -> X")
#undef METHNAME
static PyObject *wbmeth_putecptraw(PyObject *me, PyObject *arg)
{
PyObject *ptobj;
+ ec_curve *cc;
ec pt = EC_INIT;
if (!PyArg_ParseTuple(arg, "O!:putecptraw", ecptcurve_pytype, &ptobj))
return (0);
- EC_OUT(ECPT_C(ptobj), &pt, ECPT_P(ptobj));
- if (ensurebuf(me, ECPT_C(ptobj)->f->noctets * 2 + 1)) return (0);
- ec_putraw(ECPT_C(ptobj), BUF_B(me), &pt); assert(BOK(BUF_B(me)));
+ cc = ECPT_C(ptobj);
+ EC_OUT(cc, &pt, ECPT_P(ptobj));
+ if (ensurebuf(me, 2*cc->f->noctets + 1)) return (0);
+ ec_putraw(cc, BUF_B(me), &pt); assert(BOK(BUF_B(me)));
EC_DESTROY(&pt);
RETURN_ME;
}
+static PyObject *wbmeth_ec2osp(PyObject *me, PyObject *arg, PyObject *kw)
+{
+ PyTypeObject *ptobj;
+ ec_curve *cc;
+ ec pt = EC_INIT;
+ unsigned f = EC_EXPLY;
+ static const char *const kwlist[] = { "point", "flags", 0 };
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O&:os2ecp", KWLIST,
+ ecptcurve_pytype, &ptobj, convuint, &f))
+ goto end;
+ cc = ECPT_C(ptobj);
+ EC_OUT(cc, &pt, ECPT_P(ptobj));
+ if (ensurebuf(me, 2*cc->f->noctets + 1)) return (0);
+ if (ec_ec2osp(cc, f, BUF_B(me), &pt)) VALERR("invalid flags");
+ RETURN_ME;
+end:
+ return (0);
+}
+
static PyObject *wbmeth_putge(PyObject *me, PyObject *arg)
{
PyObject *geobj;
METH (putgf, "WBUF.putgf(X)")
METH (putecpt, "WBUF.putecpt(P)")
METH (putecptraw, "WBUF.putecptraw(P)")
+ KWMETH(ec2osp, "WBUF.ec2osp(P, [flags = EC_EXPLY])")
METH (putge, "WBUF.putge(X)")
METH (putgeraw, "WBUF.putgeraw(X)")
#undef METHNAME