1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * ARC4 Cipher Algorithm
7 * Jon Oberheide <jon@oberheide.org>
10 #include <crypto/arc4.h>
11 #include <linux/module.h>
13 int arc4_setkey(struct arc4_ctx *ctx, const u8 *in_key, unsigned int key_len)
20 for (i = 0; i < 256; i++)
23 for (i = 0; i < 256; i++) {
26 j = (j + in_key[k] + a) & 0xff;
27 ctx->S[i] = ctx->S[j];
35 EXPORT_SYMBOL(arc4_setkey);
37 void arc4_crypt(struct arc4_ctx *ctx, u8 *out, const u8 *in, unsigned int len)
39 u32 *const S = ctx->S;
61 *out++ = *in++ ^ S[a];
72 EXPORT_SYMBOL(arc4_crypt);
74 MODULE_LICENSE("GPL");