diff -r a507882736b2 Python/pyhash.c --- a/Python/pyhash.c Wed Jan 25 22:33:43 2017 +0900 +++ b/Python/pyhash.c Wed Feb 01 18:20:50 2017 +0900 @@ -351,21 +351,19 @@ static PyHash_FuncDef PyHash_Func = {fnv # define ROTATE(x, b) (uint64_t)( ((x) << (b)) | ( (x) >> (64 - (b))) ) #endif -#define HALF_ROUND(a,b,c,d,s,t) \ - a += b; c += d; \ +#define HALF_ROUND(a,b,c,d,s,t) \ + a += b; c += d; \ b = ROTATE(b, s) ^ a; \ d = ROTATE(d, t) ^ c; \ a = ROTATE(a, 32); -#define DOUBLE_ROUND(v0,v1,v2,v3) \ - HALF_ROUND(v0,v1,v2,v3,13,16); \ - HALF_ROUND(v2,v1,v0,v3,17,21); \ - HALF_ROUND(v0,v1,v2,v3,13,16); \ +#define ROUND(v0,v1,v2,v3) \ + HALF_ROUND(v0,v1,v2,v3,13,16); \ HALF_ROUND(v2,v1,v0,v3,17,21); static Py_hash_t -siphash24(const void *src, Py_ssize_t src_sz) { +siphash13(const void *src, Py_ssize_t src_sz) { uint64_t k0 = _le64toh(_Py_HashSecret.siphash.k0); uint64_t k1 = _le64toh(_Py_HashSecret.siphash.k1); uint64_t b = (uint64_t)src_sz << 56; @@ -385,7 +383,7 @@ siphash24(const void *src, Py_ssize_t sr in += 1; src_sz -= 8; v3 ^= mi; - DOUBLE_ROUND(v0,v1,v2,v3); + ROUND(v0,v1,v2,v3); v0 ^= mi; } @@ -404,18 +402,19 @@ siphash24(const void *src, Py_ssize_t sr b |= _le64toh(t); v3 ^= b; - DOUBLE_ROUND(v0,v1,v2,v3); + ROUND(v0,v1,v2,v3); v0 ^= b; v2 ^= 0xff; - DOUBLE_ROUND(v0,v1,v2,v3); - DOUBLE_ROUND(v0,v1,v2,v3); + ROUND(v0,v1,v2,v3); + ROUND(v0,v1,v2,v3); + ROUND(v0,v1,v2,v3); /* modified */ t = (v0 ^ v1) ^ (v2 ^ v3); return (Py_hash_t)t; } -static PyHash_FuncDef PyHash_Func = {siphash24, "siphash24", 64, 128}; +static PyHash_FuncDef PyHash_Func = {siphash13, "siphash13", 64, 128}; #endif /* Py_HASH_ALGORITHM == Py_HASH_SIPHASH24 */