0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 #include <crypto/twofish.h>
0042 #include <linux/crypto.h>
0043 #include <linux/init.h>
0044 #include <linux/module.h>
0045 #include <linux/types.h>
0046
0047 asmlinkage void twofish_enc_blk(struct twofish_ctx *ctx, u8 *dst,
0048 const u8 *src);
0049 EXPORT_SYMBOL_GPL(twofish_enc_blk);
0050 asmlinkage void twofish_dec_blk(struct twofish_ctx *ctx, u8 *dst,
0051 const u8 *src);
0052 EXPORT_SYMBOL_GPL(twofish_dec_blk);
0053
0054 static void twofish_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
0055 {
0056 twofish_enc_blk(crypto_tfm_ctx(tfm), dst, src);
0057 }
0058
0059 static void twofish_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
0060 {
0061 twofish_dec_blk(crypto_tfm_ctx(tfm), dst, src);
0062 }
0063
0064 static struct crypto_alg alg = {
0065 .cra_name = "twofish",
0066 .cra_driver_name = "twofish-asm",
0067 .cra_priority = 200,
0068 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
0069 .cra_blocksize = TF_BLOCK_SIZE,
0070 .cra_ctxsize = sizeof(struct twofish_ctx),
0071 .cra_alignmask = 0,
0072 .cra_module = THIS_MODULE,
0073 .cra_u = {
0074 .cipher = {
0075 .cia_min_keysize = TF_MIN_KEY_SIZE,
0076 .cia_max_keysize = TF_MAX_KEY_SIZE,
0077 .cia_setkey = twofish_setkey,
0078 .cia_encrypt = twofish_encrypt,
0079 .cia_decrypt = twofish_decrypt
0080 }
0081 }
0082 };
0083
0084 static int __init twofish_glue_init(void)
0085 {
0086 return crypto_register_alg(&alg);
0087 }
0088
0089 static void __exit twofish_glue_fini(void)
0090 {
0091 crypto_unregister_alg(&alg);
0092 }
0093
0094 module_init(twofish_glue_init);
0095 module_exit(twofish_glue_fini);
0096
0097 MODULE_LICENSE("GPL");
0098 MODULE_DESCRIPTION ("Twofish Cipher Algorithm, asm optimized");
0099 MODULE_ALIAS_CRYPTO("twofish");
0100 MODULE_ALIAS_CRYPTO("twofish-asm");