diff options
author | akuchling <akuchling@rivest.dlitz.net> | 2002-05-16 20:34:12 -0700 |
---|---|---|
committer | akuchling <akuchling@rivest.dlitz.net> | 2002-05-16 20:34:12 -0700 |
commit | 3d252026e00cd8b83941cb6014b428648ac33e1e (patch) | |
tree | 6f1c287cd0f4c13ff78f16026c1246d4e4796695 /src/ARC4.c | |
parent | 24f4f15f76c82bb996e40e395ca6cf0d2d1ad957 (diff) | |
download | pycrypto-3d252026e00cd8b83941cb6014b428648ac33e1e.tar.gz |
[project @ akuchling-20020517033412-ac0b409d6970cddc]
[project @ 2002-05-16 20:34:11 by akuchling]
Re-indent into Python C style; no other changes
Diffstat (limited to 'src/ARC4.c')
-rw-r--r-- | src/ARC4.c | 68 |
1 files changed, 34 insertions, 34 deletions
@@ -16,8 +16,8 @@ typedef struct { - unsigned char state[256]; - unsigned char x,y; + unsigned char state[256]; + unsigned char x,y; } stream_state; /* Encryption and decryption are symmetric */ @@ -26,45 +26,45 @@ typedef struct static void stream_encrypt(stream_state *self, unsigned char *block, int len) { - register int i, x=self->x, y=self->y; + register int i, x=self->x, y=self->y; - for (i=0; i<len; i++) - { - x = (x + 1) % 256; - y = (y + self->state[x]) % 256; - { - register int t; /* Exchange state[x] and state[y] */ - t = self->state[x]; - self->state[x] = self->state[y]; - self->state[y] = t; - } - { - register int xorIndex; /* XOR the data with the stream data */ - xorIndex=(self->state[x]+self->state[y]) % 256; - block[i] ^= self->state[xorIndex]; - } - } - self->x=x; - self->y=y; + for (i=0; i<len; i++) + { + x = (x + 1) % 256; + y = (y + self->state[x]) % 256; + { + register int t; /* Exchange state[x] and state[y] */ + t = self->state[x]; + self->state[x] = self->state[y]; + self->state[y] = t; + } + { + register int xorIndex; /* XOR the data with the stream data */ + xorIndex=(self->state[x]+self->state[y]) % 256; + block[i] ^= self->state[xorIndex]; + } + } + self->x=x; + self->y=y; } static void stream_init(stream_state *self, unsigned char *key, int keylen) { - register int i, index1, index2; + register int i, index1, index2; - for(i=0; i<256; i++) self->state[i]=i; - self->x=0; self->y=0; - index1=0; index2=0; - for(i=0; i<256; i++) - { - register int t; - index2 = ( key[index1] + self->state[i] + index2) % 256; - t = self->state[i]; - self->state[i] = self->state[index2]; - self->state[index2] = t; - index1 = (index1 + 1) % keylen; - } + for(i=0; i<256; i++) self->state[i]=i; + self->x=0; self->y=0; + index1=0; index2=0; + for(i=0; i<256; i++) + { + register int t; + index2 = ( key[index1] + self->state[i] + index2) % 256; + t = self->state[i]; + self->state[i] = self->state[index2]; + self->state[index2] = t; + index1 = (index1 + 1) % keylen; + } } #include "stream_template.c" |