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/trunk/sys/src/libsec/port/aesOFB.c – Rev 26

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
#include <libsec.h>
3
 
4
typedef ulong u32;
5
 
6
void
7
aesOFBencrypt(uchar *p, int len, AESstate *s)
8
{
9
	u32 o = s->offset;
10
 
11
	while(len > 0){
12
		if(o % 16){
13
		Odd:
14
			*p++ ^= s->ivec[o++ % 16], len--;
15
			continue;
16
		}
17
		aes_encrypt(s->ekey, s->rounds, s->ivec, s->ivec);
18
		if(len < 16 || ((p-(uchar*)0) & 3) != 0)
19
			goto Odd;
20
		((u32*)p)[0] ^= ((u32*)s->ivec)[0];
21
		((u32*)p)[1] ^= ((u32*)s->ivec)[1];
22
		((u32*)p)[2] ^= ((u32*)s->ivec)[2];
23
		((u32*)p)[3] ^= ((u32*)s->ivec)[3];
24
		o += 16, p += 16, len -= 16;
25
	}
26
	s->offset = o;
27
}
28