LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
rc4.c
Go to the documentation of this file.
1//#include "stdafx.h"
2#include "rc4.h"
3
4
5void rc4_init(unsigned char *state, unsigned char *key, int len)
6{
7 //FYI state = unsigned char rc4[0x100];
8
9 int i, j=0, t;
10
11 for (i=0; i < 256; ++i)
12 state[i] = i;
13
14 for (i=0; i < 256; ++i) {
15 j = (j + state[i] + key[i % len]) % 256;
16 t = state[i];
17 state[i] = state[j];
18 state[j] = t;
19 }
20}
21
22void rc4_crypt(unsigned char *state, unsigned char *data, int len)
23{
24 //FYI state = unsigned char rc4[0x100];
25
26 int i=0,j=0,x,t;
27
28 for (x=0; x < len; ++x) {
29 i = (i + 1) % 256;
30 j = (j + state[i]) % 256;
31 t = state[i];
32 state[i] = state[j];
33 state[j] = t;
34 *data++ ^= state[(state[i] + state[j]) % 256];
35 }
36}
37
void rc4_init(unsigned char *state, unsigned char *key, int len)
Definition: rc4.c:5
void rc4_crypt(unsigned char *state, unsigned char *data, int len)
Definition: rc4.c:22
union @15 data
u8 j
Definition: xenos_edid.h:10