X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/blobdiff_plain/1bcbe4ff20bfc18eaafc7ec305ea6ebf12d729aa..41e8ab3d28e0a10a55150f86bdf29df276a0a8d2:/catacomb.c diff --git a/catacomb.c b/catacomb.c index 3aebea3..49d0f40 100644 --- a/catacomb.c +++ b/catacomb.c @@ -44,6 +44,7 @@ static const struct nameval consts[] = { 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), #define ENTRY(tag, val, str) C(KERR_##tag), KEY_ERRORS(ENTRY) #undef ENTRY @@ -144,11 +145,27 @@ static PyMethodDef methods[] = { { 0 } }; +static void init_random(void) +{ +#if PY_MAJOR_VERSION >= 3 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 6) + char *seed; + uint32 r; + + if (!Py_HashRandomizationFlag) return; + seed = getenv("PYTHONHASHSEED"); + if (!seed || strcmp(seed, "random") == 0) r = GR_WORD(&rand_global); + else r = strtoul(seed, 0, 0); + if (!r) r = 0xe011f220; /* zero doesn't work well */ + unihash_setkey(&unihash_global, r); +#endif +} + void init_base(void) { PyObject *mod; addmethods(methods); INIT_MODULES; + init_random(); mod = Py_InitModule("catacomb._base", donemethods()); INSERT_MODULES; INSERT("smallprimes", smallprimes());