aboutsummaryrefslogtreecommitdiffstats
path: root/hsiphash.c
blob: 7c2263c8427316cb51cc2286e37a0cae5e9f2a73 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <linux/kernel.h>

#define HSIPROUND \
	do { \
	s[0] += s[1]; s[1] = rol32(s[1], 5); s[1] ^= s[0]; s[0] = rol32(s[0], 16); \
	s[2] += s[3]; s[3] = rol32(s[3], 8); s[3] ^= s[2]; \
	s[0] += s[3]; s[3] = rol32(s[3], 7); s[3] ^= s[0]; \
	s[2] += s[1]; s[1] = rol32(s[1], 13); s[1] ^= s[2]; s[2] = rol32(s[2], 16); \
	} while (0)

void mix_hsiphash(u32 s[4], const u32 v[4])
{
	size_t i;

	for (i = 0; i < 4; ++i) {
		s[3] ^= v[i];
		HSIPROUND;
		s[0] ^= v[i];
	}
}