]> git.ipfire.org Git - thirdparty/linux.git/blame - crypto/arc4.c
pinctrl: tegra: Display pin function in pinconf-groups
[thirdparty/linux.git] / crypto / arc4.c
CommitLineData
2874c5fd 1// SPDX-License-Identifier: GPL-2.0-or-later
cfa2b54e 2/*
1da177e4
LT
3 * Cryptographic API
4 *
5 * ARC4 Cipher Algorithm
6 *
7 * Jon Oberheide <jon@oberheide.org>
1da177e4 8 */
ce6dd368 9
bd30cf53 10#include <crypto/arc4.h>
426bcb50
EB
11#include <crypto/internal/skcipher.h>
12#include <linux/init.h>
9ace6771 13#include <linux/kernel.h>
426bcb50 14#include <linux/module.h>
9ace6771 15#include <linux/sched.h>
1da177e4 16
9a91792d 17static int crypto_arc4_setkey(struct crypto_lskcipher *tfm, const u8 *in_key,
611a23c2 18 unsigned int key_len)
426bcb50 19{
9a91792d 20 struct arc4_ctx *ctx = crypto_lskcipher_ctx(tfm);
1da177e4 21
dc51f257 22 return arc4_setkey(ctx, in_key, key_len);
ce6dd368
JK
23}
24
9a91792d
HX
25static int crypto_arc4_crypt(struct crypto_lskcipher *tfm, const u8 *src,
26 u8 *dst, unsigned nbytes, u8 *iv, bool final)
ce6dd368 27{
9a91792d 28 struct arc4_ctx *ctx = crypto_lskcipher_ctx(tfm);
ce6dd368 29
9a91792d
HX
30 arc4_crypt(ctx, dst, src, nbytes);
31 return 0;
ce6dd368
JK
32}
33
9a91792d 34static int crypto_arc4_init(struct crypto_lskcipher *tfm)
9ace6771
AB
35{
36 pr_warn_ratelimited("\"%s\" (%ld) uses obsolete ecb(arc4) skcipher\n",
37 current->comm, (unsigned long)current->pid);
38
39 return 0;
40}
41
9a91792d
HX
42static struct lskcipher_alg arc4_alg = {
43 .co.base.cra_name = "arc4",
44 .co.base.cra_driver_name = "arc4-generic",
45 .co.base.cra_priority = 100,
46 .co.base.cra_blocksize = ARC4_BLOCK_SIZE,
47 .co.base.cra_ctxsize = sizeof(struct arc4_ctx),
48 .co.base.cra_module = THIS_MODULE,
49 .co.min_keysize = ARC4_MIN_KEY_SIZE,
50 .co.max_keysize = ARC4_MAX_KEY_SIZE,
51 .setkey = crypto_arc4_setkey,
52 .encrypt = crypto_arc4_crypt,
53 .decrypt = crypto_arc4_crypt,
54 .init = crypto_arc4_init,
426bcb50 55};
1da177e4
LT
56
57static int __init arc4_init(void)
58{
9a91792d 59 return crypto_register_lskcipher(&arc4_alg);
1da177e4
LT
60}
61
1da177e4
LT
62static void __exit arc4_exit(void)
63{
9a91792d 64 crypto_unregister_lskcipher(&arc4_alg);
1da177e4
LT
65}
66
c4741b23 67subsys_initcall(arc4_init);
1da177e4
LT
68module_exit(arc4_exit);
69
70MODULE_LICENSE("GPL");
71MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
72MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>");
611a23c2 73MODULE_ALIAS_CRYPTO("ecb(arc4)");