15 #include <linux/module.h>
20 #define ARC4_MIN_KEY_SIZE 1
21 #define ARC4_MAX_KEY_SIZE 256
22 #define ARC4_BLOCK_SIZE 1
29 static int arc4_set_key(
struct crypto_tfm *tfm,
const u8 *in_key,
38 for (i = 0; i < 256; i++)
41 for (i = 0; i < 256; i++) {
43 j = (j + in_key[
k] +
a) & 0xff;
44 ctx->
S[
i] = ctx->
S[
j];
56 u32 *
const S = ctx->
S;
78 *out++ = *in++ ^ S[
a];
90 static void arc4_crypt_one(
struct crypto_tfm *tfm,
u8 *out,
const u8 *in)
92 arc4_crypt(crypto_tfm_ctx(tfm), out, in, 1);
98 struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->
tfm);
102 blkcipher_walk_init(&walk, dst, src, nbytes);
106 while (walk.nbytes > 0) {
107 u8 *wsrc = walk.src.virt.addr;
108 u8 *wdst = walk.dst.virt.addr;
110 arc4_crypt(ctx, wdst, wsrc, walk.nbytes);
122 .cra_ctxsize =
sizeof(
struct arc4_ctx),
128 .cia_setkey = arc4_set_key,
129 .cia_encrypt = arc4_crypt_one,
130 .cia_decrypt = arc4_crypt_one,
134 .cra_name =
"ecb(arc4)",
138 .cra_ctxsize =
sizeof(
struct arc4_ctx),
146 .setkey = arc4_set_key,
147 .encrypt = ecb_arc4_crypt,
148 .decrypt = ecb_arc4_crypt,
153 static int __init arc4_init(
void)
158 static void __exit arc4_exit(
void)