summaryrefslogtreecommitdiff
path: root/arcfour.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2022-08-07 20:34:12 +0200
committerNiels Möller <nisse@lysator.liu.se>2022-08-07 20:34:12 +0200
commit73bdcbe9d3b55c97f54820c1174ef8666c83be45 (patch)
tree13f0305ab9f5e3563efc744f4678f82285deb100 /arcfour.c
parent693820e1bad41f640159d8556b171e9a4f282c5e (diff)
downloadnettle-delete-arcfour-asm.tar.gz
Delete all arcfour assembly codedelete-arcfour-asm
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;
+}