X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/6d4db0bf4b67e65708637466d4f0d306ed1dfe53..963a61481edc7a83698b18b518bf20cd93d268a6:/algorithms.c diff --git a/algorithms.c b/algorithms.c index 2113cc5..cd7a04d 100644 --- a/algorithms.c +++ b/algorithms.c @@ -262,7 +262,7 @@ static PyTypeObject keysz_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ keysz_pymembers, /* @tp_members@ */ 0, /* @tp_getset@ */ @@ -310,7 +310,7 @@ static PyTypeObject keyszany_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ keyszany_pygetset, /* @tp_getset@ */ @@ -359,7 +359,7 @@ sizes, and requires the key length to be a multiple of some value.", 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ keyszrange_pymembers, /* @tp_members@ */ 0, /* @tp_getset@ */ @@ -408,7 +408,7 @@ few listed sizes.", 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ keyszset_pymembers, /* @tp_members@ */ keyszset_pygetset, /* @tp_getset@ */ @@ -621,7 +621,7 @@ static PyTypeObject gccipher_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ gccipher_pygetset, /* @tp_getset@ */ @@ -669,7 +669,7 @@ static PyTypeObject gcipher_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ gcipher_pymethods, /* @tp_methods@ */ 0, /* @tp_members@ */ 0, /* @tp_getset@ */ @@ -777,9 +777,48 @@ static PyGetSetDef gchash_pygetset[] = { { 0 } }; +#define GHMETH_HASHU_(n, W, w) \ + static PyObject *ghmeth_hashu##w(PyObject *me, PyObject *arg) \ + { \ + uint##n x; \ + if (!PyArg_ParseTuple(arg, "O&:hashu" #w, convu##n, &x)) goto end; \ + GH_HASHU##W(GHASH_H(me), x); \ + RETURN_ME; \ + end: \ + return (0); \ + } +DOUINTCONV(GHMETH_HASHU_) + +#define GHMETH_HASHBUF_(n, W, w) \ + static PyObject *ghmeth_hashbuf##w(PyObject *me, PyObject *arg) \ + { \ + char *p; \ + int sz; \ + if (!PyArg_ParseTuple(arg, "s#:hashbuf" #w, &p, &sz)) goto end; \ + if (sz > MASK##n) TYERR("string too long"); \ + GH_HASHBUF##W(GHASH_H(me), p, sz); \ + RETURN_ME; \ + end: \ + return (0); \ + } +DOUINTCONV(GHMETH_HASHBUF_) + +static PyObject *ghmeth_hashstrz(PyObject *me, PyObject *arg) +{ + char *p; + if (!PyArg_ParseTuple(arg, "s:hashstrz", &p)) return (0); + GH_HASHSTRZ(GHASH_H(me), p); + RETURN_ME; +} + static PyMethodDef ghash_pymethods[] = { #define METHNAME(name) ghmeth_##name METH (hash, "H.hash(M)") +#define METHU_(n, W, w) METH(hashu##w, "H.hashu" #w "(WORD)") + DOUINTCONV(METHU_) +#define METHBUF_(n, W, w) METH(hashbuf##w, "H.hashbuf" #w "(BYTES)") + DOUINTCONV(METHBUF_) + METH (hashstrz, "H.hashstrz(STRING)") METH (done, "H.done() -> HASH") #undef METHNAME { 0 } @@ -817,7 +856,7 @@ static PyTypeObject gchash_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ gchash_pygetset, /* @tp_getset@ */ @@ -865,7 +904,7 @@ static PyTypeObject ghash_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ ghash_pymethods, /* @tp_methods@ */ 0, /* @tp_members@ */ 0, /* @tp_getset@ */ @@ -1015,7 +1054,7 @@ static PyTypeObject gcmac_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ gcmac_pygetset, /* @tp_getset@ */ @@ -1063,7 +1102,7 @@ static PyTypeObject gmac_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ 0, /* @tp_getset@ */ @@ -1111,7 +1150,7 @@ static PyTypeObject gmhash_pytype_skel = { 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ 0, /* @tp_getset@ */