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 f04af931a682..107f6f7be5e1 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c | |||
| @@ -31,11 +31,6 @@ static inline u64 Maj(u64 x, u64 y, u64 z) | |||
| 31 | return (x & y) | (z & (x | y)); | 31 | return (x & y) | (z & (x | y)); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | static inline u64 RORu64(u64 x, u64 y) | ||
| 35 | { | ||
| 36 | return (x >> y) | (x << (64 - y)); | ||
| 37 | } | ||
| 38 | |||
| 39 | static const u64 sha512_K[80] = { | 34 | static const u64 sha512_K[80] = { |
| 40 | 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, | 35 | 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, |
| 41 | 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, | 36 | 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, |
| @@ -66,10 +61,10 @@ static const u64 sha512_K[80] = { | |||
| 66 | 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL, | 61 | 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL, |
| 67 | }; | 62 | }; |
| 68 | 63 | ||
| 69 | #define e0(x) (RORu64(x,28) ^ RORu64(x,34) ^ RORu64(x,39)) | 64 | #define e0(x) (ror64(x,28) ^ ror64(x,34) ^ ror64(x,39)) |
| 70 | #define e1(x) (RORu64(x,14) ^ RORu64(x,18) ^ RORu64(x,41)) | 65 | #define e1(x) (ror64(x,14) ^ ror64(x,18) ^ ror64(x,41)) |
| 71 | #define s0(x) (RORu64(x, 1) ^ RORu64(x, 8) ^ (x >> 7)) | 66 | #define s0(x) (ror64(x, 1) ^ ror64(x, 8) ^ (x >> 7)) |
| 72 | #define s1(x) (RORu64(x,19) ^ RORu64(x,61) ^ (x >> 6)) | 67 | #define s1(x) (ror64(x,19) ^ ror64(x,61) ^ (x >> 6)) |
| 73 | 68 | ||
| 74 | static inline void LOAD_OP(int I, u64 *W, const u8 *input) | 69 | static inline void LOAD_OP(int I, u64 *W, const u8 *input) |
| 75 | { | 70 | { |
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index a3ef66a2a083..fc8a3ffce320 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
| @@ -50,6 +50,26 @@ static inline unsigned long hweight_long(unsigned long w) | |||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * rol64 - rotate a 64-bit value left | ||
| 54 | * @word: value to rotate | ||
| 55 | * @shift: bits to roll | ||
| 56 | */ | ||
| 57 | static inline __u64 rol64(__u64 word, unsigned int shift) | ||
| 58 | { | ||
| 59 | return (word << shift) | (word >> (64 - shift)); | ||
| 60 | } | ||
| 61 | |||
| 62 | /** | ||
| 63 | * ror64 - rotate a 64-bit value right | ||
| 64 | * @word: value to rotate | ||
| 65 | * @shift: bits to roll | ||
| 66 | */ | ||
| 67 | static inline __u64 ror64(__u64 word, unsigned int shift) | ||
| 68 | { | ||
| 69 | return (word >> shift) | (word << (64 - shift)); | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 53 | * rol32 - rotate a 32-bit value left | 73 | * rol32 - rotate a 32-bit value left |
| 54 | * @word: value to rotate | 74 | * @word: value to rotate |
| 55 | * @shift: bits to roll | 75 | * @shift: bits to roll |
