/* -*-c-*-
- *
- * $Id$
*
* Symmetric cryptography
*
0 /* @tp_is_gc@ */
};
+#define KSZCONVOP(op) \
+ static PyObject *meth__KeySZ_##op(PyObject *me, PyObject *arg) \
+ { \
+ double x, y; \
+ if (!PyArg_ParseTuple(arg, "Od:" #op, &me, &x)) return (0); \
+ y = keysz_##op(x); \
+ return (PyFloat_FromDouble(y)); \
+ }
+KSZCONVOP(fromdl)
+KSZCONVOP(fromschnorr)
+KSZCONVOP(fromif)
+KSZCONVOP(fromec)
+KSZCONVOP(todl)
+KSZCONVOP(toschnorr)
+KSZCONVOP(toif)
+KSZCONVOP(toec)
+#undef KSZCONVOP
+
/*----- Symmetric encryption ----------------------------------------------*/
PyTypeObject *gccipher_pytype, *gcipher_pytype;
/*----- Main code ---------------------------------------------------------*/
+static PyMethodDef methods[] = {
+#define METHNAME(func) meth_##func
+ METH (_KeySZ_fromdl, "\
+fromdl(N) -> M: convert integer discrete log field size to work factor")
+ METH (_KeySZ_fromschnorr, "\
+fromschnorr(N) -> M: convert Schnorr group order to work factor")
+ METH (_KeySZ_fromif, "\
+fromif(N) -> M: convert integer factorization problem size to work factor")
+ METH (_KeySZ_fromec, "\
+fromec(N) -> M: convert elliptic curve group order to work factor")
+ METH (_KeySZ_todl, "\
+todl(N) -> M: convert work factor to integer discrete log field size")
+ METH (_KeySZ_toschnorr, "\
+toschnorr(N) -> M: convert work factor to Schnorr group order")
+ METH (_KeySZ_toif, "\
+toif(N) -> M: convert work factor to integer factorization problem size")
+ METH (_KeySZ_toec, "\
+toec(N) -> M: convert work factor to elliptic curve group order")
+#undef METHNAME
+ { 0 }
+};
+
void algorithms_pyinit(void)
{
INITTYPE(keysz, root);
INITTYPE(gmhash, ghash);
INITTYPE(gcprp, type);
INITTYPE(gprp, root);
+ addmethods(methods);
}
GEN(gcciphers, cipher)