summaryrefslogtreecommitdiff
path: root/other/burneye/src/stub/cipher-glfsr-c.c
blob: 28d55df8a30ce2e8dd0bb81b3a61be21db13f498 (plain)
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
30
31
32
33


void
glfsr_crypt (unsigned char *dst, unsigned char *src,
	unsigned int len, unsigned int key)
{
	int			n;
	unsigned long int	state = key,
				fillup;

	while (len--) {
		for (n = 0 ; n < 8 ; ++n) {
			fillup = 0;

			if (state & 0x1) {
				state >>= 1;
				fillup |= 0x80000000;
			} else {
				state >>= 1;
				state ^= 0xc0000057;
			}
			fillup >>= 1;
		}
		fillup >>= 24;
		fillup &= 0x000000ff;

		*dst++ = *src++ ^ fillup;
	}

	return;
}