X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/6b54260d1f5312a3ec58be3ee1eb168ddf9cf2e2..eb8aa4ec8ea84c76dcf06d1647fce1b237cec313:/algorithms.c diff --git a/algorithms.c b/algorithms.c index 3f9d4b7..cb594ca 100644 --- a/algorithms.c +++ b/algorithms.c @@ -1297,7 +1297,7 @@ static PyObject *polymeth_hash(PyObject *me, PyObject *arg) uint##n x; \ octet b[SZ_##W]; \ if (!PyArg_ParseTuple(arg, "O&:hashu" #w, convu##n, &x)) goto end; \ - STORE##W(b, n); poly1305_hash(P1305_CTX(me), b, sizeof(b)); \ + STORE##W(b, x); poly1305_hash(P1305_CTX(me), b, sizeof(b)); \ RETURN_ME; \ end: \ return (0); \ @@ -1312,7 +1312,7 @@ DOUINTCONV(POLYMETH_HASHU_) octet b[SZ_##W]; \ if (!PyArg_ParseTuple(arg, "s#:hashbuf" #w, &p, &sz)) goto end; \ if (sz > MASK##n) TYERR("string too long"); \ - STORE##W(b, n); poly1305_hash(P1305_CTX(me), b, sizeof(b)); \ + STORE##W(b, sz); poly1305_hash(P1305_CTX(me), b, sizeof(b)); \ poly1305_hash(P1305_CTX(me), p, sz); \ RETURN_ME; \ end: \ @@ -1335,6 +1335,13 @@ static PyObject *polymeth_flush(PyObject *me, PyObject *arg) RETURN_ME; } +static PyObject *polymeth_flushzero(PyObject *me, PyObject *arg) +{ + if (!PyArg_ParseTuple(arg, ":flushzero")) return (0); + poly1305_flushzero(P1305_CTX(me)); + RETURN_ME; +} + static PyObject *polymeth_concat(PyObject *me, PyObject *arg) { PyObject *pre, *suff; @@ -1385,6 +1392,7 @@ static PyMethodDef poly1305hash_pymethods[] = { #undef METHBUF_ METH (hashstrz, "P.hashstrz(STRING)") METH (flush, "P.flush()") + METH (flushzero, "P.flushzero()") METH (concat, "P.concat(PREFIX, SUFFIX)") METH (done, "P.done() -> TAG") #undef METHNAME