~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/crypto/arc4.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /crypto/arc4.c (Architecture mips) and /crypto/arc4.c (Architecture i386)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /*
  3  * Cryptographic API                                3  * Cryptographic API
  4  *                                                  4  *
  5  * ARC4 Cipher Algorithm                            5  * ARC4 Cipher Algorithm
  6  *                                                  6  *
  7  * Jon Oberheide <jon@oberheide.org>                7  * Jon Oberheide <jon@oberheide.org>
  8  */                                                 8  */
  9                                                     9 
 10 #include <crypto/arc4.h>                           10 #include <crypto/arc4.h>
 11 #include <crypto/internal/skcipher.h>              11 #include <crypto/internal/skcipher.h>
 12 #include <linux/init.h>                            12 #include <linux/init.h>
 13 #include <linux/kernel.h>                          13 #include <linux/kernel.h>
 14 #include <linux/module.h>                          14 #include <linux/module.h>
 15 #include <linux/sched.h>                           15 #include <linux/sched.h>
 16                                                    16 
 17 #define ARC4_ALIGN __alignof__(struct arc4_ctx     17 #define ARC4_ALIGN __alignof__(struct arc4_ctx)
 18                                                    18 
 19 static int crypto_arc4_setkey(struct crypto_ls     19 static int crypto_arc4_setkey(struct crypto_lskcipher *tfm, const u8 *in_key,
 20                               unsigned int key     20                               unsigned int key_len)
 21 {                                                  21 {
 22         struct arc4_ctx *ctx = crypto_lskciphe     22         struct arc4_ctx *ctx = crypto_lskcipher_ctx(tfm);
 23                                                    23 
 24         return arc4_setkey(ctx, in_key, key_le     24         return arc4_setkey(ctx, in_key, key_len);
 25 }                                                  25 }
 26                                                    26 
 27 static int crypto_arc4_crypt(struct crypto_lsk     27 static int crypto_arc4_crypt(struct crypto_lskcipher *tfm, const u8 *src,
 28                              u8 *dst, unsigned     28                              u8 *dst, unsigned nbytes, u8 *siv, u32 flags)
 29 {                                                  29 {
 30         struct arc4_ctx *ctx = crypto_lskciphe     30         struct arc4_ctx *ctx = crypto_lskcipher_ctx(tfm);
 31                                                    31 
 32         if (!(flags & CRYPTO_LSKCIPHER_FLAG_CO     32         if (!(flags & CRYPTO_LSKCIPHER_FLAG_CONT))
 33                 memcpy(siv, ctx, sizeof(*ctx))     33                 memcpy(siv, ctx, sizeof(*ctx));
 34                                                    34 
 35         ctx = (struct arc4_ctx *)siv;              35         ctx = (struct arc4_ctx *)siv;
 36                                                    36 
 37         arc4_crypt(ctx, dst, src, nbytes);         37         arc4_crypt(ctx, dst, src, nbytes);
 38         return 0;                                  38         return 0;
 39 }                                                  39 }
 40                                                    40 
 41 static int crypto_arc4_init(struct crypto_lskc     41 static int crypto_arc4_init(struct crypto_lskcipher *tfm)
 42 {                                                  42 {
 43         pr_warn_ratelimited("\"%s\" (%ld) uses     43         pr_warn_ratelimited("\"%s\" (%ld) uses obsolete ecb(arc4) skcipher\n",
 44                             current->comm, (un     44                             current->comm, (unsigned long)current->pid);
 45                                                    45 
 46         return 0;                                  46         return 0;
 47 }                                                  47 }
 48                                                    48 
 49 static struct lskcipher_alg arc4_alg = {           49 static struct lskcipher_alg arc4_alg = {
 50         .co.base.cra_name               =          50         .co.base.cra_name               =       "arc4",
 51         .co.base.cra_driver_name        =          51         .co.base.cra_driver_name        =       "arc4-generic",
 52         .co.base.cra_priority           =          52         .co.base.cra_priority           =       100,
 53         .co.base.cra_blocksize          =          53         .co.base.cra_blocksize          =       ARC4_BLOCK_SIZE,
 54         .co.base.cra_ctxsize            =          54         .co.base.cra_ctxsize            =       sizeof(struct arc4_ctx),
 55         .co.base.cra_alignmask          =          55         .co.base.cra_alignmask          =       ARC4_ALIGN - 1,
 56         .co.base.cra_module             =          56         .co.base.cra_module             =       THIS_MODULE,
 57         .co.min_keysize                 =          57         .co.min_keysize                 =       ARC4_MIN_KEY_SIZE,
 58         .co.max_keysize                 =          58         .co.max_keysize                 =       ARC4_MAX_KEY_SIZE,
 59         .co.statesize                   =          59         .co.statesize                   =       sizeof(struct arc4_ctx),
 60         .setkey                         =          60         .setkey                         =       crypto_arc4_setkey,
 61         .encrypt                        =          61         .encrypt                        =       crypto_arc4_crypt,
 62         .decrypt                        =          62         .decrypt                        =       crypto_arc4_crypt,
 63         .init                           =          63         .init                           =       crypto_arc4_init,
 64 };                                                 64 };
 65                                                    65 
 66 static int __init arc4_init(void)                  66 static int __init arc4_init(void)
 67 {                                                  67 {
 68         return crypto_register_lskcipher(&arc4     68         return crypto_register_lskcipher(&arc4_alg);
 69 }                                                  69 }
 70                                                    70 
 71 static void __exit arc4_exit(void)                 71 static void __exit arc4_exit(void)
 72 {                                                  72 {
 73         crypto_unregister_lskcipher(&arc4_alg)     73         crypto_unregister_lskcipher(&arc4_alg);
 74 }                                                  74 }
 75                                                    75 
 76 subsys_initcall(arc4_init);                        76 subsys_initcall(arc4_init);
 77 module_exit(arc4_exit);                            77 module_exit(arc4_exit);
 78                                                    78 
 79 MODULE_LICENSE("GPL");                             79 MODULE_LICENSE("GPL");
 80 MODULE_DESCRIPTION("ARC4 Cipher Algorithm");       80 MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
 81 MODULE_AUTHOR("Jon Oberheide <jon@oberheide.or     81 MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>");
 82 MODULE_ALIAS_CRYPTO("ecb(arc4)");                  82 MODULE_ALIAS_CRYPTO("ecb(arc4)");
 83                                                    83 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php