/*1* Glue Code for assembler optimized version of TWOFISH2*3* Originally Twofish for GPG4* By Matthew Skala <[email protected]>, July 26, 19985* 256-bit key length added March 20, 19996* Some modifications to reduce the text size by Werner Koch, April, 19987* Ported to the kerneli patch by Marc Mutz <[email protected]>8* Ported to CryptoAPI by Colin Slater <[email protected]>9*10* The original author has disclaimed all copyright interest in this11* code and thus put it in the public domain. The subsequent authors12* have put this under the GNU General Public License.13*14* This program is free software; you can redistribute it and/or modify15* it under the terms of the GNU General Public License as published by16* the Free Software Foundation; either version 2 of the License, or17* (at your option) any later version.18*19* This program is distributed in the hope that it will be useful,20* but WITHOUT ANY WARRANTY; without even the implied warranty of21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22* GNU General Public License for more details.23*24* You should have received a copy of the GNU General Public License25* along with this program; if not, write to the Free Software26* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-130727* USA28*29* This code is a "clean room" implementation, written from the paper30* _Twofish: A 128-Bit Block Cipher_ by Bruce Schneier, John Kelsey,31* Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson, available32* through http://www.counterpane.com/twofish.html33*34* For background information on multiplication in finite fields, used for35* the matrix operations in the key schedule, see the book _Contemporary36* Abstract Algebra_ by Joseph A. Gallian, especially chapter 22 in the37* Third Edition.38*/3940#include <crypto/twofish.h>41#include <linux/crypto.h>42#include <linux/init.h>43#include <linux/module.h>44#include <linux/types.h>4546asmlinkage void twofish_enc_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src);47asmlinkage void twofish_dec_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src);4849static void twofish_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)50{51twofish_enc_blk(tfm, dst, src);52}5354static void twofish_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)55{56twofish_dec_blk(tfm, dst, src);57}5859static struct crypto_alg alg = {60.cra_name = "twofish",61.cra_driver_name = "twofish-asm",62.cra_priority = 200,63.cra_flags = CRYPTO_ALG_TYPE_CIPHER,64.cra_blocksize = TF_BLOCK_SIZE,65.cra_ctxsize = sizeof(struct twofish_ctx),66.cra_alignmask = 3,67.cra_module = THIS_MODULE,68.cra_list = LIST_HEAD_INIT(alg.cra_list),69.cra_u = {70.cipher = {71.cia_min_keysize = TF_MIN_KEY_SIZE,72.cia_max_keysize = TF_MAX_KEY_SIZE,73.cia_setkey = twofish_setkey,74.cia_encrypt = twofish_encrypt,75.cia_decrypt = twofish_decrypt76}77}78};7980static int __init init(void)81{82return crypto_register_alg(&alg);83}8485static void __exit fini(void)86{87crypto_unregister_alg(&alg);88}8990module_init(init);91module_exit(fini);9293MODULE_LICENSE("GPL");94MODULE_DESCRIPTION ("Twofish Cipher Algorithm, asm optimized");95MODULE_ALIAS("twofish");96MODULE_ALIAS("twofish-asm");979899