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

TOMOYO Linux Cross Reference
Linux/arch/x86/crypto/twofish_glue.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Glue Code for assembler optimized version of TWOFISH
  3  *
  4  * Originally Twofish for GPG
  5  * By Matthew Skala <mskala@ansuz.sooke.bc.ca>, July 26, 1998
  6  * 256-bit key length added March 20, 1999
  7  * Some modifications to reduce the text size by Werner Koch, April, 1998
  8  * Ported to the kerneli patch by Marc Mutz <Marc@Mutz.com>
  9  * Ported to CryptoAPI by Colin Slater <hoho@tacomeat.net>
 10  *
 11  * The original author has disclaimed all copyright interest in this
 12  * code and thus put it in the public domain. The subsequent authors
 13  * have put this under the GNU General Public License.
 14  *
 15  * This program is free software; you can redistribute it and/or modify
 16  * it under the terms of the GNU General Public License as published by
 17  * the Free Software Foundation; either version 2 of the License, or
 18  * (at your option) any later version.
 19  *
 20  * This program is distributed in the hope that it will be useful,
 21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 23  * GNU General Public License for more details.
 24  *
 25  * You should have received a copy of the GNU General Public License
 26  * along with this program; if not, write to the Free Software
 27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 28  * USA
 29  *
 30  * This code is a "clean room" implementation, written from the paper
 31  * _Twofish: A 128-Bit Block Cipher_ by Bruce Schneier, John Kelsey,
 32  * Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson, available
 33  * through http://www.counterpane.com/twofish.html
 34  *
 35  * For background information on multiplication in finite fields, used for
 36  * the matrix operations in the key schedule, see the book _Contemporary
 37  * Abstract Algebra_ by Joseph A. Gallian, especially chapter 22 in the
 38  * Third Edition.
 39  */
 40 
 41 #include <crypto/algapi.h>
 42 #include <crypto/twofish.h>
 43 #include <linux/init.h>
 44 #include <linux/module.h>
 45 #include <linux/types.h>
 46 
 47 asmlinkage void twofish_enc_blk(struct twofish_ctx *ctx, u8 *dst,
 48                                 const u8 *src);
 49 EXPORT_SYMBOL_GPL(twofish_enc_blk);
 50 asmlinkage void twofish_dec_blk(struct twofish_ctx *ctx, u8 *dst,
 51                                 const u8 *src);
 52 EXPORT_SYMBOL_GPL(twofish_dec_blk);
 53 
 54 static void twofish_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 55 {
 56         twofish_enc_blk(crypto_tfm_ctx(tfm), dst, src);
 57 }
 58 
 59 static void twofish_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 60 {
 61         twofish_dec_blk(crypto_tfm_ctx(tfm), dst, src);
 62 }
 63 
 64 static struct crypto_alg alg = {
 65         .cra_name               =       "twofish",
 66         .cra_driver_name        =       "twofish-asm",
 67         .cra_priority           =       200,
 68         .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
 69         .cra_blocksize          =       TF_BLOCK_SIZE,
 70         .cra_ctxsize            =       sizeof(struct twofish_ctx),
 71         .cra_alignmask          =       0,
 72         .cra_module             =       THIS_MODULE,
 73         .cra_u                  =       {
 74                 .cipher = {
 75                         .cia_min_keysize        =       TF_MIN_KEY_SIZE,
 76                         .cia_max_keysize        =       TF_MAX_KEY_SIZE,
 77                         .cia_setkey             =       twofish_setkey,
 78                         .cia_encrypt            =       twofish_encrypt,
 79                         .cia_decrypt            =       twofish_decrypt
 80                 }
 81         }
 82 };
 83 
 84 static int __init twofish_glue_init(void)
 85 {
 86         return crypto_register_alg(&alg);
 87 }
 88 
 89 static void __exit twofish_glue_fini(void)
 90 {
 91         crypto_unregister_alg(&alg);
 92 }
 93 
 94 module_init(twofish_glue_init);
 95 module_exit(twofish_glue_fini);
 96 
 97 MODULE_LICENSE("GPL");
 98 MODULE_DESCRIPTION ("Twofish Cipher Algorithm, asm optimized");
 99 MODULE_ALIAS_CRYPTO("twofish");
100 MODULE_ALIAS_CRYPTO("twofish-asm");
101 

~ [ 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