projects
/
GitHub
/
mt8127
/
android_kernel_alcatel_ttab.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
51fc6dc
)
crypto: sha512 - Use binary and instead of modulus
author
Herbert Xu
<herbert@gondor.apana.org.au>
Thu, 26 Jan 2012 04:03:16 +0000
(15:03 +1100)
committer
Herbert Xu
<herbert@gondor.apana.org.au>
Thu, 26 Jan 2012 04:03:16 +0000
(15:03 +1100)
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>
crypto/sha512_generic.c
patch
|
blob
|
blame
|
history
diff --git
a/crypto/sha512_generic.c
b/crypto/sha512_generic.c
index 88f160b77b1fec95ed6315c65566a30f611f5642..3edebfd4dbec26645a1dc455f7f6d826615e3041 100644
(file)
--- 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