1 // SPDX-License-Identifier: GPL-2.0-or-later 1 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 #define ARC4_ALIGN __alignof__(struct arc4_ctx 18 19 static int crypto_arc4_setkey(struct crypto_ls 20 unsigned int key 21 { 22 struct arc4_ctx *ctx = crypto_lskciphe 23 24 return arc4_setkey(ctx, in_key, key_le 25 } 26 27 static int crypto_arc4_crypt(struct crypto_lsk 28 u8 *dst, unsigned 29 { 30 struct arc4_ctx *ctx = crypto_lskciphe 31 32 if (!(flags & CRYPTO_LSKCIPHER_FLAG_CO 33 memcpy(siv, ctx, sizeof(*ctx)) 34 35 ctx = (struct arc4_ctx *)siv; 36 37 arc4_crypt(ctx, dst, src, nbytes); 38 return 0; 39 } 40 41 static int crypto_arc4_init(struct crypto_lskc 42 { 43 pr_warn_ratelimited("\"%s\" (%ld) uses 44 current->comm, (un 45 46 return 0; 47 } 48 49 static struct lskcipher_alg arc4_alg = { 50 .co.base.cra_name = 51 .co.base.cra_driver_name = 52 .co.base.cra_priority = 53 .co.base.cra_blocksize = 54 .co.base.cra_ctxsize = 55 .co.base.cra_alignmask = 56 .co.base.cra_module = 57 .co.min_keysize = 58 .co.max_keysize = 59 .co.statesize = 60 .setkey = 61 .encrypt = 62 .decrypt = 63 .init = 64 }; 65 66 static int __init arc4_init(void) 67 { 68 return crypto_register_lskcipher(&arc4 69 } 70 71 static void __exit arc4_exit(void) 72 { 73 crypto_unregister_lskcipher(&arc4_alg) 74 } 75 76 subsys_initcall(arc4_init); 77 module_exit(arc4_exit); 78 79 MODULE_LICENSE("GPL"); 80 MODULE_DESCRIPTION("ARC4 Cipher Algorithm"); 81 MODULE_AUTHOR("Jon Oberheide <jon@oberheide.or 82 MODULE_ALIAS_CRYPTO("ecb(arc4)"); 83
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.