summaryrefslogtreecommitdiff
path: root/arcfour.c
diff options
context:
space:
mode:
Diffstat (limited to 'arcfour.c')
-rw-r--r--arcfour.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/arcfour.c b/arcfour.c
index 87f4959f..795a2d77 100644
--- a/arcfour.c
+++ b/arcfour.c
@@ -69,3 +69,24 @@ arcfour128_set_key(struct arcfour_ctx *ctx, const uint8_t *key)
{
arcfour_set_key (ctx, ARCFOUR128_KEY_SIZE, key);
}
+
+void
+arcfour_crypt(struct arcfour_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src)
+{
+ register uint8_t i, j;
+ register int si, sj;
+
+ i = ctx->i; j = ctx->j;
+ while(length--)
+ {
+ i++; i &= 0xff;
+ si = ctx->S[i];
+ j += si; j &= 0xff;
+ sj = ctx->S[i] = ctx->S[j];
+ ctx->S[j] = si;
+ *dst++ = *src++ ^ ctx->S[ (si + sj) & 0xff ];
+ }
+ ctx->i = i; ctx->j = j;
+}