1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * ARC4 Cipher Algorithm
7 * Jon Oberheide <jon@oberheide.org>
10 #include <linux/module.h>
13 MODULE_LICENSE("GPL");
15 int cifs_arc4_setkey(struct arc4_ctx *ctx, const u8 *in_key, unsigned int key_len)
22 for (i = 0; i < 256; i++)
25 for (i = 0; i < 256; i++) {
28 j = (j + in_key[k] + a) & 0xff;
29 ctx->S[i] = ctx->S[j];
37 EXPORT_SYMBOL_GPL(cifs_arc4_setkey);
39 void cifs_arc4_crypt(struct arc4_ctx *ctx, u8 *out, const u8 *in, unsigned int len)
41 u32 *const S = ctx->S;
63 *out++ = *in++ ^ S[a];
74 EXPORT_SYMBOL_GPL(cifs_arc4_crypt);