diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2012-01-26 15:03:16 +1100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-04 09:49:20 -0800 |
commit | 3e15b23883776bb8c42bd5e5ee6e439ab4bd60df (patch) | |
tree | 64f7b8939b6d71b5ce4f7fa63ab64af4ef1053ac | |
parent | 7422fb39e4b06b7f375a088c5bad8b0134f5a3a0 (diff) | |
download | lwn-3e15b23883776bb8c42bd5e5ee6e439ab4bd60df.tar.gz lwn-3e15b23883776bb8c42bd5e5ee6e439ab4bd60df.zip |
crypto: sha512 - Use binary and instead of modulus
commit 58d7d18b5268febb8b1391c6dffc8e2aaa751fcd upstream.
The previous patch used the modulus operator over a power of 2
unnecessarily which may produce suboptimal binary code. This
patch changes changes them to binary ands instead.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | crypto/sha512_generic.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c index 88f160b77b1f..3edebfd4dbec 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c @@ -78,7 +78,7 @@ static inline void LOAD_OP(int I, u64 *W, const u8 *input) static inline void BLEND_OP(int I, u64 *W) { - W[I % 16] += s1(W[(I-2) % 16]) + W[(I-7) % 16] + s0(W[(I-15) % 16]); + W[I & 15] += s1(W[(I-2) & 15]) + W[(I-7) & 15] + s0(W[(I-15) & 15]); } static void @@ -105,7 +105,7 @@ sha512_transform(u64 *state, const u8 *input) #define SHA512_16_79(i, a, b, c, d, e, f, g, h) \ BLEND_OP(i, W); \ - t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)%16]; \ + t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)&15]; \ t2 = e0(a) + Maj(a, b, c); \ d += t1; \ h = t1 + t2 |