arm64: dts: qcom: sm8550: add TRNG node
[linux-modified.git] / crypto / arc4.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Cryptographic API
4  *
5  * ARC4 Cipher Algorithm
6  *
7  * Jon Oberheide <jon@oberheide.org>
8  */
9
10 #include <crypto/arc4.h>
11 #include <crypto/internal/skcipher.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/sched.h>
16
17 static int crypto_arc4_setkey(struct crypto_lskcipher *tfm, const u8 *in_key,
18                               unsigned int key_len)
19 {
20         struct arc4_ctx *ctx = crypto_lskcipher_ctx(tfm);
21
22         return arc4_setkey(ctx, in_key, key_len);
23 }
24
25 static int crypto_arc4_crypt(struct crypto_lskcipher *tfm, const u8 *src,
26                              u8 *dst, unsigned nbytes, u8 *iv, bool final)
27 {
28         struct arc4_ctx *ctx = crypto_lskcipher_ctx(tfm);
29
30         arc4_crypt(ctx, dst, src, nbytes);
31         return 0;
32 }
33
34 static int crypto_arc4_init(struct crypto_lskcipher *tfm)
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
42 static 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,
55 };
56
57 static int __init arc4_init(void)
58 {
59         return crypto_register_lskcipher(&arc4_alg);
60 }
61
62 static void __exit arc4_exit(void)
63 {
64         crypto_unregister_lskcipher(&arc4_alg);
65 }
66
67 subsys_initcall(arc4_init);
68 module_exit(arc4_exit);
69
70 MODULE_LICENSE("GPL");
71 MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
72 MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>");
73 MODULE_ALIAS_CRYPTO("ecb(arc4)");