diff options
author | David S. Miller <davem@davemloft.net> | 2014-10-02 02:52:37 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-10-02 02:52:37 -0400 |
commit | be34c4ef693ff5c10f55606dbd656ddf0b4a8340 (patch) | |
tree | aa8bb25553507ac3cd5454b4c627ab9a5120d3ce /crypto | |
parent | 5cfed7b3351ce33b60c4a1d02ffd712cdf4f49cd (diff) |
crypto: sha - Handle unaligned input data in generic sha256 and sha512.
Like SHA1, use get_unaligned_be*() on the raw input data.
Reported-by: Bob Picco <bob.picco@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/sha256_generic.c | 3 | ||||
-rw-r--r-- | crypto/sha512_generic.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c index 543366779524..0bb558344699 100644 --- a/crypto/sha256_generic.c +++ b/crypto/sha256_generic.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <crypto/sha.h> | 25 | #include <crypto/sha.h> |
26 | #include <asm/byteorder.h> | 26 | #include <asm/byteorder.h> |
27 | #include <asm/unaligned.h> | ||
27 | 28 | ||
28 | static inline u32 Ch(u32 x, u32 y, u32 z) | 29 | static inline u32 Ch(u32 x, u32 y, u32 z) |
29 | { | 30 | { |
@@ -42,7 +43,7 @@ static inline u32 Maj(u32 x, u32 y, u32 z) | |||
42 | 43 | ||
43 | static inline void LOAD_OP(int I, u32 *W, const u8 *input) | 44 | static inline void LOAD_OP(int I, u32 *W, const u8 *input) |
44 | { | 45 | { |
45 | W[I] = __be32_to_cpu( ((__be32*)(input))[I] ); | 46 | W[I] = get_unaligned_be32((__u32 *)input + I); |
46 | } | 47 | } |
47 | 48 | ||
48 | static inline void BLEND_OP(int I, u32 *W) | 49 | static inline void BLEND_OP(int I, u32 *W) |
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c index 6ed124f3ea0f..6dde57dc511b 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <crypto/sha.h> | 20 | #include <crypto/sha.h> |
21 | #include <linux/percpu.h> | 21 | #include <linux/percpu.h> |
22 | #include <asm/byteorder.h> | 22 | #include <asm/byteorder.h> |
23 | #include <asm/unaligned.h> | ||
23 | 24 | ||
24 | static inline u64 Ch(u64 x, u64 y, u64 z) | 25 | static inline u64 Ch(u64 x, u64 y, u64 z) |
25 | { | 26 | { |
@@ -68,7 +69,7 @@ static const u64 sha512_K[80] = { | |||
68 | 69 | ||
69 | static inline void LOAD_OP(int I, u64 *W, const u8 *input) | 70 | static inline void LOAD_OP(int I, u64 *W, const u8 *input) |
70 | { | 71 | { |
71 | W[I] = __be64_to_cpu( ((__be64*)(input))[I] ); | 72 | W[I] = get_unaligned_be64((__u64 *)input + I); |
72 | } | 73 | } |
73 | 74 | ||
74 | static inline void BLEND_OP(int I, u64 *W) | 75 | static inline void BLEND_OP(int I, u64 *W) |