aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2012-01-25 23:03:16 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2012-01-25 23:03:16 -0500
commit58d7d18b5268febb8b1391c6dffc8e2aaa751fcd (patch)
tree18add451538ba5454656c09c35f4047d29f2869e /crypto
parent51fc6dc8f948047364f7d42a4ed89b416c6cc0a3 (diff)
crypto: sha512 - Use binary and instead of modulus
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>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/sha512_generic.c4
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)
78 78
79static inline void BLEND_OP(int I, u64 *W) 79static inline void BLEND_OP(int I, u64 *W)
80{ 80{
81 W[I % 16] += s1(W[(I-2) % 16]) + W[(I-7) % 16] + s0(W[(I-15) % 16]); 81 W[I & 15] += s1(W[(I-2) & 15]) + W[(I-7) & 15] + s0(W[(I-15) & 15]);
82} 82}
83 83
84static void 84static void
@@ -105,7 +105,7 @@ sha512_transform(u64 *state, const u8 *input)
105 105
106#define SHA512_16_79(i, a, b, c, d, e, f, g, h) \ 106#define SHA512_16_79(i, a, b, c, d, e, f, g, h) \
107 BLEND_OP(i, W); \ 107 BLEND_OP(i, W); \
108 t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)%16]; \ 108 t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)&15]; \
109 t2 = e0(a) + Maj(a, b, c); \ 109 t2 = e0(a) + Maj(a, b, c); \
110 d += t1; \ 110 d += t1; \
111 h = t1 + t2 111 h = t1 + t2