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_DESCRIPTION("ARC4 Cipher Algorithm");
14 MODULE_LICENSE("GPL");
16 int cifs_arc4_setkey(struct arc4_ctx
*ctx
, const u8
*in_key
, unsigned int key_len
)
23 for (i
= 0; i
< 256; i
++)
26 for (i
= 0; i
< 256; i
++) {
29 j
= (j
+ in_key
[k
] + a
) & 0xff;
30 ctx
->S
[i
] = ctx
->S
[j
];
38 EXPORT_SYMBOL_GPL(cifs_arc4_setkey
);
40 void cifs_arc4_crypt(struct arc4_ctx
*ctx
, u8
*out
, const u8
*in
, unsigned int len
)
42 u32
*const S
= ctx
->S
;
64 *out
++ = *in
++ ^ S
[a
];
75 EXPORT_SYMBOL_GPL(cifs_arc4_crypt
);