summaryrefslogtreecommitdiff
path: root/src/XOR.c
diff options
context:
space:
mode:
authorakuchling <akuchling@rivest.dlitz.net>2002-05-16 20:34:12 -0700
committerakuchling <akuchling@rivest.dlitz.net>2002-05-16 20:34:12 -0700
commit3d252026e00cd8b83941cb6014b428648ac33e1e (patch)
tree6f1c287cd0f4c13ff78f16026c1246d4e4796695 /src/XOR.c
parent24f4f15f76c82bb996e40e395ca6cf0d2d1ad957 (diff)
downloadpycrypto-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/XOR.c')
-rw-r--r--src/XOR.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/XOR.c b/src/XOR.c
index 57af911..f2c74af 100644
--- a/src/XOR.c
+++ b/src/XOR.c
@@ -16,37 +16,37 @@
typedef struct
{
- unsigned char key[32];
- int keylen, last_pos;
+ unsigned char key[32];
+ int keylen, last_pos;
} stream_state;
static void
stream_init(stream_state *self, unsigned char *key, int len)
{
- int i;
+ int i;
- if (32 <= len) len=32;
- self->keylen = len;
- self->last_pos = 0;
+ if (32 <= len) len=32;
+ self->keylen = len;
+ self->last_pos = 0;
- for(i=0; i<len; i++)
- {
- self->key[i] = key[i];
- }
+ for(i=0; i<len; i++)
+ {
+ self->key[i] = key[i];
+ }
}
/* Encryption and decryption are symmetric */
#define stream_decrypt stream_encrypt
static void stream_encrypt(stream_state *self, unsigned char *block,
- int len)
+ int len)
{
- int i, j = self->last_pos;
- for(i=0; i<len; i++, j=(j+1) % self->keylen)
- {
- block[i] ^= self->key[j];
- }
- self->last_pos = j;
+ int i, j = self->last_pos;
+ for(i=0; i<len; i++, j=(j+1) % self->keylen)
+ {
+ block[i] ^= self->key[j];
+ }
+ self->last_pos = j;
}
#include "stream_template.c"