1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <linux/kernel.h>
#define R(x, y, k) (x = ror64(x, 8), x += y, x ^= k, y = rol64(y, 3), y ^= x)
#define ROUNDS 32
static inline void speck(u64 ct[2], const u64 pt[2], const u64 key[2])
{
u64 y = pt[0], x = pt[1], b = key[0], a = key[1];
int i;
R(x, y, b);
for (i = 0; i < ROUNDS - 1; ++i) {
R(a, b, i);
R(x, y, b);
}
ct[0] = y;
ct[1] = x;
}
void mix_speck(u32 h[4], const u32 v[4])
{
u32 n[4];
speck((u64 *)n, (u64 *)h, (const u64 *)v);
h[0] ^= n[0];
h[1] ^= n[1];
h[2] ^= n[2];
h[3] ^= n[3];
}
|