diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-30 14:09:09 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-30 14:46:34 +0100 |
commit | 5bc5fd9fbb450c43e01ef6ea27560e1a26ac7ed2 (patch) | |
tree | e46b70c42ca3b60da84e0a9f2fbad245a409f25a /src/crypto | |
parent | 10cff9459c1fc863f4961341eaf5aca772948c43 (diff) |
chacha20poly1305: use existing rol32 function
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto')
-rw-r--r-- | src/crypto/chacha20poly1305.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/crypto/chacha20poly1305.c b/src/crypto/chacha20poly1305.c index 89cf055..a231b0f 100644 --- a/src/crypto/chacha20poly1305.c +++ b/src/crypto/chacha20poly1305.c @@ -111,24 +111,19 @@ static inline u64 le64_to_cpuvp(const void *p) return le64_to_cpup(p); } -static inline u32 rotl32(u32 v, u8 n) -{ - return (v << n) | (v >> (sizeof(v) * 8 - n)); -} - struct chacha20_ctx { u32 state[CHACHA20_BLOCK_SIZE / sizeof(u32)]; } __aligned(32); #define QUARTER_ROUND(x, a, b, c, d) ( \ x[a] += x[b], \ - x[d] = rotl32((x[d] ^ x[a]), 16), \ + x[d] = rol32((x[d] ^ x[a]), 16), \ x[c] += x[d], \ - x[b] = rotl32((x[b] ^ x[c]), 12), \ + x[b] = rol32((x[b] ^ x[c]), 12), \ x[a] += x[b], \ - x[d] = rotl32((x[d] ^ x[a]), 8), \ + x[d] = rol32((x[d] ^ x[a]), 8), \ x[c] += x[d], \ - x[b] = rotl32((x[b] ^ x[c]), 7) \ + x[b] = rol32((x[b] ^ x[c]), 7) \ ) #define C(i, j) (i * 4 + j) |