X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/7f38dc76ee0809207e67be7b2a2ddc600aba54d5..c51a597d1b79460a4225d42c6a76112b12c91a00:/rand.c diff --git a/rand.c b/rand.c index d57795a..add56c9 100644 --- a/rand.c +++ b/rand.c @@ -27,14 +27,17 @@ /*----- Header files ------------------------------------------------------*/ #include "catacomb-python.h" +PUBLIC_SYMBOLS; #include "algorithms.h" +PRIVATE_SYMBOLS; /*----- Main code ---------------------------------------------------------*/ -PyTypeObject *grand_pytype, *truerand_pytype; -PyTypeObject *lcrand_pytype, *fibrand_pytype; -PyTypeObject *dsarand_pytype, *bbs_pytype, *bbspriv_pytype; -PyTypeObject *sslprf_pytype, *tlsdx_pytype, *tlsprf_pytype; +PyTypeObject *grand_pytype; +static PyTypeObject *truerand_pytype; +static PyTypeObject *lcrand_pytype, *fibrand_pytype; +static PyTypeObject *dsarand_pytype, *bbs_pytype, *bbspriv_pytype; +static PyTypeObject *sslprf_pytype, *tlsdx_pytype, *tlsprf_pytype; PyObject *rand_pyobj; static PyObject *gccrands_dict; @@ -54,14 +57,14 @@ PyObject *grand_pywrap(grand *r, unsigned f) PyTypeObject *ty = grand_pytype; PyObject *ob; - if (strcmp(r->ops->name, "rand") == 0) ty = truerand_pytype; - else if (strcmp(r->ops->name, "lcrand") == 0) ty = lcrand_pytype; - else if (strcmp(r->ops->name, "fibrand") == 0) ty = fibrand_pytype; - else if (strcmp(r->ops->name, "dsarand") == 0) ty = dsarand_pytype; - else if (strcmp(r->ops->name, "bbs") == 0) ty = bbs_pytype; - else if (strcmp(r->ops->name, "sslprf") == 0) ty = sslprf_pytype; - else if (strcmp(r->ops->name, "tlsdx") == 0) ty = tlsdx_pytype; - else if (strcmp(r->ops->name, "tlsprf") == 0) ty = tlsprf_pytype; + if (STRCMP(r->ops->name, ==, "rand")) ty = truerand_pytype; + else if (STRCMP(r->ops->name, ==, "lcrand")) ty = lcrand_pytype; + else if (STRCMP(r->ops->name, ==, "fibrand")) ty = fibrand_pytype; + else if (STRCMP(r->ops->name, ==, "dsarand")) ty = dsarand_pytype; + else if (STRCMP(r->ops->name, ==, "bbs")) ty = bbs_pytype; + else if (STRCMP(r->ops->name, ==, "sslprf")) ty = sslprf_pytype; + else if (STRCMP(r->ops->name, ==, "tlsdx")) ty = tlsdx_pytype; + else if (STRCMP(r->ops->name, ==, "tlsprf")) ty = tlsprf_pytype; else if ((ob = PyDict_GetItemString(gccrands_dict, r->ops->name)) != 0) ty = (PyTypeObject *)ob; return (grand_dopywrap(ty, r, f)); @@ -938,7 +941,7 @@ static PyTypeObject gclatinrand_pytype_skel = { static PyObject *sslprf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) { char *k, *s; - int ksz, ssz; + Py_ssize_t ksz, ssz; const gchash *hco = &md5, *hci = &sha; PyObject *rc = 0; static const char *const kwlist[] = { "key", "seed", "ohash", "ihash", 0 }; @@ -955,7 +958,7 @@ end: static PyObject *tlsdx_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) { char *k, *s; - int ksz, ssz; + Py_ssize_t ksz, ssz; const gcmac *mc = &sha_hmac; PyObject *rc = 0; static const char *const kwlist[] = { "key", "seed", "mac", 0 }; @@ -972,7 +975,7 @@ end: static PyObject *tlsprf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) { char *k, *s; - int ksz, ssz; + Py_ssize_t ksz, ssz; const gcmac *mcl = &md5_hmac, *mcr = &sha_hmac; PyObject *rc = 0; static const char *const kwlist[] = { "key", "seed", "lmac", "rmac", 0 }; @@ -1138,7 +1141,7 @@ static PyTypeObject tlsprf_pytype_skel = { static PyObject *dsarand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) { char *p; - int sz; + Py_ssize_t sz; PyObject *rc = 0; static const char *const kwlist[] = { "seed", 0 }; @@ -1483,7 +1486,7 @@ static PyTypeObject bbspriv_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"BBSPriv(..., seed = 2]): Blum-Blum-Shub, with private key.\n\ +"BBSPriv(..., [seed = 2]): Blum-Blum-Shub, with private key.\n\ Keywords: n, p, q; must provide at least two", 0, /* @tp_traverse@ */