/*----- Main code ---------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(AEADF_PCHSZ), CONST(AEADF_PCMSZ), CONST(AEADF_PCTSZ),
+ CONST(AEADF_AADNDEP), CONST(AEADF_AADFIRST), CONST(AEADF_NOAAD),
+ { 0 }
+};
+
static const PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
#define METH_HDANCE(hdance, HDance) METH(hdance##_prf, \
INSERT("GCPRP", gcprp_pytype);
INSERT("GPRP", gprp_pytype);
INSERT("gcprps", gcprps());
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Main code ---------------------------------------------------------*/
-static const struct nameval consts[] = {
-#define CF(f, x) { #x, f, x }
-#define C(x) { #x, 0, x }
- C(FTY_PRIME), C(FTY_BINARY),
- C(PGEN_PASS), C(PGEN_FAIL), C(PGEN_BEGIN), C(PGEN_TRY), C(PGEN_DONE),
- C(PGEN_ABORT),
- C(MPW_MAX),
- C(RAND_IBITS),
- C(PMODE_READ), C(PMODE_VERIFY),
- C(KOPEN_READ), C(KOPEN_WRITE), C(KOPEN_NOFILE),
- C(KEXP_FOREVER), C(KEXP_EXPIRE),
- C(KF_ENCMASK), C(KENC_BINARY), C(KENC_MP), C(KENC_STRUCT),
- C(KENC_ENCRYPT), C(KENC_STRING), C(KENC_EC),
- C(KF_CATMASK), C(KCAT_SYMM), C(KCAT_PRIV), C(KCAT_PUB), C(KCAT_SHARE),
- C(KF_NONSECRET),
- C(KF_BURN), C(KF_OPT),
- C(EC_XONLY), C(EC_YBIT), C(EC_LSB), C(EC_CMPR), C(EC_EXPLY), C(EC_SORT),
- C(X25519_KEYSZ), C(X25519_PUBSZ), C(X25519_OUTSZ),
- C(X448_KEYSZ), C(X448_PUBSZ), C(X448_OUTSZ),
- C(ED25519_KEYSZ), C(ED25519_PUBSZ), C(ED25519_SIGSZ),
- C(ED25519_MAXPERSOSZ),
- C(ED448_KEYSZ), C(ED448_PUBSZ), C(ED448_SIGSZ), C(ED448_MAXPERSOSZ),
- C(AEADF_PCHSZ), C(AEADF_PCMSZ), C(AEADF_PCTSZ),
- C(AEADF_AADNDEP), C(AEADF_AADFIRST), C(AEADF_NOAAD),
-#define ENTRY(tag, val, str) CF(CF_SIGNED, KERR_##tag),
- KEY_ERRORS(ENTRY)
-#undef ENTRY
-#undef C
-#undef CF
- { 0 }
-};
-
PyObject *mexp_common(PyObject *me, PyObject *arg,
size_t efsz,
PyObject *(*id)(PyObject *),
mod = Py_InitModule("catacomb._base", donemethods());
INSERT_MODULES;
INSERT("smallprimes", smallprimes());
- setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Setup -------------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(EC_XONLY), CONST(EC_YBIT), CONST(EC_LSB),
+ CONST(EC_CMPR), CONST(EC_EXPLY), CONST(EC_SORT),
+ { 0 }
+};
+
void ec_pyinit(void)
{
INITTYPE(ecpt, root);
INSERT("ECBinProjCurve", ecbinprojcurve_pytype);
INSERT("ECInfo", ecinfo_pytype);
INSERT("_eccurves", namedcurves());
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Setup -------------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(FTY_PRIME), CONST(FTY_BINARY),
+ { 0 }
+};
+
void field_pyinit(void)
{
INITTYPE(fe, root);
INSERT("BinField", binfield_pytype);
INSERT("BinPolyField", binpolyfield_pytype);
INSERT("BinNormField", binnormfield_pytype);
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Initialization ----------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(KOPEN_READ), CONST(KOPEN_WRITE), CONST(KOPEN_NOFILE),
+ CONST(KEXP_FOREVER), CONST(KEXP_EXPIRE),
+ CONST(KF_ENCMASK), CONST(KENC_BINARY), CONST(KENC_MP), CONST(KENC_STRUCT),
+ CONST(KENC_ENCRYPT), CONST(KENC_STRING), CONST(KENC_EC),
+ CONST(KF_CATMASK), CONST(KCAT_SYMM), CONST(KCAT_PRIV), CONST(KCAT_PUB),
+ CONST(KCAT_SHARE),
+ CONST(KF_NONSECRET),
+ CONST(KF_BURN), CONST(KF_OPT),
+#define ENTRY(tag, val, str) CONSTFLAG(CF_SIGNED, KERR_##tag),
+ KEY_ERRORS(ENTRY)
+#undef ENTRY
+ { 0 }
+};
+
void key_pyinit(void)
{
INITTYPE(keyfile, root);
INSERT("KeyDataString", keydatastr_pytype);
INSERT("KeyDataStructured", keydatastruct_pytype);
INSERT("SubKeyIter", subkeyiter_pytype);
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Glue --------------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(MPW_MAX),
+ { 0 }
+};
+
void mp_pyinit(void)
{
INITTYPE(mp, root);
INSERT("GF", gf_pytype);
INSERT("GFReduce", gfreduce_pytype);
INSERT("GFN", gfn_pytype);
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Main code ---------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(PMODE_READ), CONST(PMODE_VERIFY),
+ { 0 }
+};
+
static PyObject *meth_ppread(PyObject *me, PyObject *arg, PyObject *kw)
{
char *tag;
void passphrase_pyinsert(PyObject *mod)
{
INSERT("Pixie", pixie_pytype);
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Global stuff ------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(PGEN_PASS), CONST(PGEN_FAIL), CONST(PGEN_BEGIN), CONST(PGEN_TRY),
+ CONST(PGEN_DONE), CONST(PGEN_ABORT),
+ { 0 }
+};
+
static const PyMethodDef methods[] = {
#define METHNAME(name) meth_##name
KWMETH(pgen,
INSERT("pgen_stdev", pgev_stdev(pgen_ev));
INSERT("pgen_spinev", pgev_stdev(pgen_evspin));
INSERT("pgen_subev", pgev_stdev(pgen_subev));
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
/*----- Global stuff ------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(X25519_KEYSZ), CONST(X25519_PUBSZ), CONST(X25519_OUTSZ),
+ CONST(X448_KEYSZ), CONST(X448_PUBSZ), CONST(X448_OUTSZ),
+ CONST(ED25519_KEYSZ), CONST(ED25519_PUBSZ), CONST(ED25519_SIGSZ),
+ CONST(ED25519_MAXPERSOSZ),
+ CONST(ED448_KEYSZ), CONST(ED448_PUBSZ), CONST(ED448_SIGSZ),
+ CONST(ED448_MAXPERSOSZ),
+ { 0 }
+};
+
static const PyMethodDef methods[] = {
#define METHNAME(name) meth_##name
KWMETH(_p1crypt_encode, 0)
INSERT("KCDSAPriv", kcdsapriv_pytype);
INSERT("RSAPub", rsapub_pytype);
INSERT("RSAPriv", rsapriv_pytype);
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/
struct nameval { const char *name; unsigned f; unsigned long value; };
#define CF_SIGNED 1u
extern void setconstants(PyObject *, const struct nameval *);
+#define CONST(x) { #x, 0, x }
+#define CONSTFLAG(f, x) { #x, f, x }
#define INSEXC(name, var, base, meth) \
INSERT(name, var = mkexc(mod, base, name, meth))
/*----- Global stuff ------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(RAND_IBITS),
+ { 0 }
+};
+
void rand_pyinit(void)
{
INITTYPE(grand, root);
gccrands_dict = gccrands(); Py_INCREF(gccrands_dict);
INSERT("gccrands", gccrands_dict);
INSERT("rand", rand_pyobj);
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/