diff options
-rw-r--r-- | crypto/sha512_generic.c | 13 | ||||
-rw-r--r-- | include/linux/bitops.h | 20 |
2 files changed, 24 insertions, 9 deletions
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c index 9ed9f60316e5..20df86f51406 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c | |||
@@ -33,11 +33,6 @@ static inline u64 Maj(u64 x, u64 y, u64 z) | |||
33 | return (x & y) | (z & (x | y)); | 33 | return (x & y) | (z & (x | y)); |
34 | } | 34 | } |
35 | 35 | ||
36 | static inline u64 RORu64(u64 x, u64 y) | ||
37 | { | ||
38 | return (x >> y) | (x << (64 - y)); | ||
39 | } | ||
40 | |||
41 | static const u64 sha512_K[80] = { | 36 | static const u64 sha512_K[80] = { |
42 | 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, | 37 | 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, |
43 | 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, | 38 | 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, |
@@ -68,10 +63,10 @@ static const u64 sha512_K[80] = { | |||
68 | 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL, | 63 | 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL, |
69 | }; | 64 | }; |
70 | 65 | ||
71 | #define e0(x) (RORu64(x,28) ^ RORu64(x,34) ^ RORu64(x,39)) | 66 | #define e0(x) (ror64(x,28) ^ ror64(x,34) ^ ror64(x,39)) |
72 | #define e1(x) (RORu64(x,14) ^ RORu64(x,18) ^ RORu64(x,41)) | 67 | #define e1(x) (ror64(x,14) ^ ror64(x,18) ^ ror64(x,41)) |
73 | #define s0(x) (RORu64(x, 1) ^ RORu64(x, 8) ^ (x >> 7)) | 68 | #define s0(x) (ror64(x, 1) ^ ror64(x, 8) ^ (x >> 7)) |
74 | #define s1(x) (RORu64(x,19) ^ RORu64(x,61) ^ (x >> 6)) | 69 | #define s1(x) (ror64(x,19) ^ ror64(x,61) ^ (x >> 6)) |
75 | 70 | ||
76 | static inline void LOAD_OP(int I, u64 *W, const u8 *input) | 71 | static inline void LOAD_OP(int I, u64 *W, const u8 *input) |
77 | { | 72 | { |
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 3c1063acb2ab..94300fe46cce 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -56,6 +56,26 @@ static inline unsigned long hweight_long(unsigned long w) | |||
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * rol64 - rotate a 64-bit value left | ||
60 | * @word: value to rotate | ||
61 | * @shift: bits to roll | ||
62 | */ | ||
63 | static inline __u64 rol64(__u64 word, unsigned int shift) | ||
64 | { | ||
65 | return (word << shift) | (word >> (64 - shift)); | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * ror64 - rotate a 64-bit value right | ||
70 | * @word: value to rotate | ||
71 | * @shift: bits to roll | ||
72 | */ | ||
73 | static inline __u64 ror64(__u64 word, unsigned int shift) | ||
74 | { | ||
75 | return (word >> shift) | (word << (64 - shift)); | ||
76 | } | ||
77 | |||
78 | /** | ||
59 | * rol32 - rotate a 32-bit value left | 79 | * rol32 - rotate a 32-bit value left |
60 | * @word: value to rotate | 80 | * @word: value to rotate |
61 | * @shift: bits to roll | 81 | * @shift: bits to roll |