From 0c87e818de23f9bdc1bcef0d19b628aed814cc3a Mon Sep 17 00:00:00 2001 Message-Id: <0c87e818de23f9bdc1bcef0d19b628aed814cc3a.1746686998.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 26 May 2016 09:26:09 +0100 Subject: [PATCH] algorithms.c: Fix Poly1305 `hashu...' and `hashbuf...' methods. Organization: Straylight/Edgeware From: Mark Wooding Hash the input number or length, not the size of the field. --- algorithms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: \ -- [mdw]