From 375b38554e7d8b8a2da8571eede97f3e52b57906 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 29 Jul 2018 12:11:45 -0400 Subject: [PATCH] Use 64-bit multiply for Rabbit --- rabbit.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rabbit.cpp b/rabbit.cpp index 2c32f4f0..8bc4a499 100644 --- a/rabbit.cpp +++ b/rabbit.cpp @@ -15,10 +15,12 @@ ANONYMOUS_NAMESPACE_BEGIN using CryptoPP::word32; +using CryptoPP::word64; using CryptoPP::rotlConstant; word32 G_func(word32 x) { +#if 0 /* Temporary variables */ word32 a, b, h, l; @@ -32,6 +34,12 @@ word32 G_func(word32 x) /* Return high XOR low */ return static_cast(h^l); +#endif + + // Thanks to Jack Lloyd for suggesting the 64-bit multiply. + word64 z = x; + z *= x; + return static_cast((z >> 32) ^ z); } word32 NextState(word32 c[8], word32 x[8], word32 carry)