From 213331903e891dd50d8e9703d008681d669987f7 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 28 Apr 2016 12:37:38 +0200 Subject: [PATCH] cubehash_impl: fix cubehash implementation mistake Well, there's a reason for that test vectors are published on wikipedia. Although this looks scary (like writing past array bounds), cubehash B parameter is in all cases smaller than 63 (which is the first B value where this would write behind the array), so no harm is done. For similar reason, the "misimplemented" cubehash was cryptographically correct (i.e. without cryptographic weakness), only implemented differently and producing different results than those prescribed by the standard. Practical implications of changing the hash functions are: - everyone gets a new KeyID - FMTSeq keys that used cubehash are invalid now, users are forced to generate new ones --- src/cubehash_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cubehash_impl.h b/src/cubehash_impl.h index a9aab46..8480372 100644 --- a/src/cubehash_impl.h +++ b/src/cubehash_impl.h @@ -113,8 +113,8 @@ public: for (; i < n; ++i) X[i / 4] ^= ( (uint32_t) (data[i])) << ( (i % 4) * 8); - i++; - X[i / 2] ^= ( (uint32_t) 0x80) << ( (i % 4) * 8); + //i==n, n<128 (!) + X[i / 4] ^= ( (uint32_t) 0x80) << ( (i % 4) * 8); rounds (R);