From: Mark Wooding Date: Thu, 26 May 2016 08:26:09 +0000 (+0100) Subject: algorithms.c: Fix Poly1305 `hashu...' and `hashbuf...' methods. X-Git-Tag: 1.2.0~42 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/commitdiff_plain/0c87e818de23f9bdc1bcef0d19b628aed814cc3a?hp=bfb450ccb248489a622c7dcb51ed5e150eb8f3b6 algorithms.c: Fix Poly1305 `hashu...' and `hashbuf...' methods. Hash the input number or length, not the size of the field. --- diff --git a/algorithms.c b/algorithms.c index 3f9d4b7..2dc2dda 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: \