chiark / gitweb /
algorithms.c: Fix Poly1305 `hashu...' and `hashbuf...' methods.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 17 Apr 2017 16:26:48 +0000 (17:26 +0100)
Hash the input number or length, not the size of the field.

algorithms.c

index 3f9d4b77edb97072288e0b10be5bc841cbeb0ae8..2dc2dda0673f757af5361f7621962fd78f3b32ae 100644 (file)
@@ -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:                                                                 \