23 #include <asm/processor.h>
26 #include <linux/module.h>
27 #include <linux/types.h>
29 #include <crypto/twofish.h>
60 u128_xor(&dst[1], &dst[1], &ivs[0]);
61 u128_xor(&dst[2], &dst[2], &ivs[1]);
72 u128_to_be128(&ctrblk, iv);
76 u128_xor(dst, dst, (
u128 *)&ctrblk);
91 u128_to_be128(&ctrblks[0], iv);
93 u128_to_be128(&ctrblks[1], iv);
95 u128_to_be128(&ctrblks[2], iv);
98 twofish_enc_blk_xor_3way(ctx, (
u8 *)dst, (
u8 *)ctrblks);
104 .fpu_blocks_limit = -1,
117 .fpu_blocks_limit = -1,
130 .fpu_blocks_limit = -1,
143 .fpu_blocks_limit = -1,
186 static void encrypt_callback(
void *
priv,
u8 *srcdst,
unsigned int nbytes)
192 if (nbytes == 3 * bsize) {
193 twofish_enc_blk_3way(ctx, srcdst, srcdst);
197 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
201 static void decrypt_callback(
void *priv,
u8 *srcdst,
unsigned int nbytes)
207 if (nbytes == 3 * bsize) {
212 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
238 .tbuflen =
sizeof(
buf),
242 .crypt_fn = encrypt_callback,
245 return lrw_crypt(desc, dst, src, nbytes, &req);
255 .tbuflen =
sizeof(
buf),
259 .crypt_fn = decrypt_callback,
262 return lrw_crypt(desc, dst, src, nbytes, &req);
306 .tbuflen =
sizeof(
buf),
311 .crypt_fn = encrypt_callback,
314 return xts_crypt(desc, dst, src, nbytes, &req);
324 .tbuflen =
sizeof(
buf),
329 .crypt_fn = decrypt_callback,
332 return xts_crypt(desc, dst, src, nbytes, &req);
336 .cra_name =
"ecb(twofish)",
337 .cra_driver_name =
"ecb-twofish-3way",
350 .encrypt = ecb_encrypt,
351 .decrypt = ecb_decrypt,
355 .cra_name =
"cbc(twofish)",
356 .cra_driver_name =
"cbc-twofish-3way",
370 .encrypt = cbc_encrypt,
371 .decrypt = cbc_decrypt,
375 .cra_name =
"ctr(twofish)",
376 .cra_driver_name =
"ctr-twofish-3way",
390 .encrypt = ctr_crypt,
391 .decrypt = ctr_crypt,
395 .cra_name =
"lrw(twofish)",
396 .cra_driver_name =
"lrw-twofish-3way",
411 .encrypt = lrw_encrypt,
412 .decrypt = lrw_decrypt,
416 .cra_name =
"xts(twofish)",
417 .cra_driver_name =
"xts-twofish-3way",
431 .encrypt = xts_encrypt,
432 .decrypt = xts_decrypt,
437 static bool is_blacklisted_cpu(
void)
477 if (!force && is_blacklisted_cpu()) {
479 "twofish-x86_64-3way: performance on this CPU "
480 "would be suboptimal: disabling "
481 "twofish-x86_64-3way.\n");
488 static void __exit fini(
void)