Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_unix/sys/src/libsec/port/chachablock.c – Rev 33

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
26 7u83 1
#include "os.h"
2
 
3
#define ROTATE(v,c) ((u32int)((v) << (c)) | ((v) >> (32 - (c))))
4
 
5
#define QUARTERROUND(ia,ib,ic,id) { \
6
	u32int a, b, c, d, t; \
7
	a = x[ia]; b = x[ib]; c = x[ic]; d = x[id]; \
8
	a += b; t = d^a; d = ROTATE(t,16); \
9
	c += d; t = b^c; b = ROTATE(t,12); \
10
	a += b; t = d^a; d = ROTATE(t, 8); \
11
	c += d; t = b^c; b = ROTATE(t, 7); \
12
	x[ia] = a; x[ib] = b; x[ic] = c; x[id] = d; \
13
}
14
 
15
void
16
_chachablock(u32int x[16], int rounds)
17
{
18
	for(; rounds > 0; rounds -= 2) {
19
		QUARTERROUND(0, 4, 8,12)
20
		QUARTERROUND(1, 5, 9,13)
21
		QUARTERROUND(2, 6,10,14)
22
		QUARTERROUND(3, 7,11,15)
23
 
24
		QUARTERROUND(0, 5,10,15)
25
		QUARTERROUND(1, 6,11,12)
26
		QUARTERROUND(2, 7, 8,13)
27
		QUARTERROUND(3, 4, 9,14)
28
	}
29
}