Gisle S{lensminde wrote: > > On Wed, 27 Sep 2000, Marc Mutz wrote: > > > Hi Alex! > > > > As you know, I've ported the Twofish implementation of GnuPG > > (http://www.gnupg.org) to the cipherapi of the kerneli patch > > (http://www.kerneli.org/). You need to patch include/linux/crypto.h and > > util-linux to use a cipher id you like. I don't want to mess around with > > the loop_fish2.c driver. If you find this implementation worth of being > > able to replace the other twofish, then it can take its number. 192 bits > > mode is not working for this twofish.c, but not hard to obtain. > > > > This patch assumes my changes to loop_gen.c, so no need to patch that > > file. Please consider applying: > > The patch seems not to be complete. It does at least miss the definitions > in linux/include/linux/crypto.h. Since I'm too lazy to scan the code to > find the exact size of the key schedule, I would prefere an updated > patch. > <snip> You're right, of course. The sent patch was relative to stuff I sent to Alex earlier, before this ml was established. The included patch adds the necessary definitions to include/linux/cryto.h and contains the changes I made to drivers/block/loop_gen.c. The driver has been assigned id 9 temporarily. It will not stay there. Alex should choose number for it when he decides what will become of the loop_2fish.c driver. Patching lomount.c involves only changing the static list of ciphers and to add LO_CRYPT_TWOFISH to the 128 bit case in lomount.c:set_loop()'s switch statement. As you see, I don't want people to deploy this on a large basis, because the ID is not assigned yet and there will be _questions_ if it changes :-) Hi out there! Anyone using Twofish from patch-int-2.2.17.3 or earlier? Please contact me! It may well vanish in the future and the cipherapi implementation might not be compatible then. Marc -- Marc Mutz <Marc@xxxxxxxx> http://marc.mutz.com/Encryption-HOWTO/ University of Bielefeld, Dep. of Mathematics / Dep. of Physics PGP-keyID's: 0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)
--- i5/drivers/block/loop_gen.c Mon Sep 25 16:50:54 2000 +++ i5-raidA0-raid1rb15.B2-ext0.0.3a//drivers/block/loop_gen.c Mon Sep 25 17:48:47 2000 @@ -56,6 +56,7 @@ static int loop_gen_init2(struct loop_device *lo, struct loop_info *info) { int cipher,err = -EINVAL; + int mode = CIPHER_CBC; struct cipher_implementation *ci; struct cipher_context *cx; @@ -64,19 +65,7 @@ case LO_CRYPT_XOR: cipher = CIPHER_XOR; break; case LO_CRYPT_DES: cipher = CIPHER_cbc_DES; break; case LO_CRYPT_FISH2: cipher = CIPHER_cbc_FISH2; break; - case LO_CRYPT_BLOW: cipher = CIPHER_cbc_BLOWFISH; break; - case LO_CRYPT_CAST128: cipher = CIPHER_cbc_CAST128; break; - case LO_CRYPT_IDEA: cipher = CIPHER_cbc_IDEA; break; - case LO_CRYPT_SERPENT: cipher = CIPHER_cbc_SERPENT; break; - case LO_CRYPT_MARS: cipher = CIPHER_cbc_MARS; break; - case LO_CRYPT_SKIPJACK: cipher = CIPHER_cbc_SKIPJACK; break; - case LO_CRYPT_RC5: cipher = CIPHER_cbc_RC5; break; - case LO_CRYPT_RC6: cipher = CIPHER_cbc_RC6; break; - case LO_CRYPT_DES_EDE3: cipher = CIPHER_cbc_DES_EDE3; break; - case LO_CRYPT_E2: cipher = CIPHER_cbc_E2; break; - case LO_CRYPT_CAST256: cipher = CIPHER_cbc_CAST256; break; - case LO_CRYPT_DFC: cipher = CIPHER_cbc_DFC; break; - default: goto out; + default: cipher = info->lo_encrypt_type | mode; break; } ci = find_cipher_by_id(cipher); @@ -85,7 +74,7 @@ if (ci->trans.t_id != cipher) { printk("find_cipher_by_id gave me the wrong cipher!\n"); - goto out_ci; + goto out; } ci->lock(); --- i5/include/linux/crypto.h Mon Sep 25 16:50:54 2000 +++ i5-raidA0-raid1rb15.B2-ext0.0.3a//include/linux/crypto.h Mon Sep 25 17:39:33 2000 @@ -20,6 +20,7 @@ #define CIPHER_IDEA 6 #define CIPHER_SERPENT 7 #define CIPHER_MARS 8 +#define CIPHER_TWOFISH 9 #define CIPHER_SKIPJACK 10 #define CIPHER_RC6 11 @@ -39,6 +40,8 @@ #define CIPHER_cbc_IDEA (CIPHER_IDEA | CIPHER_CBC) #define CIPHER_cbc_SERPENT (CIPHER_SERPENT | CIPHER_CBC) #define CIPHER_cbc_MARS (CIPHER_MARS | CIPHER_CBC) +#define CIPHER_cbc_TWOFISH (CIPHER_TWOFISH | CIPHER_CBC) + #define CIPHER_cbc_SKIPJACK (CIPHER_SKIPJACK | CIPHER_CBC) #define CIPHER_cbc_RC5 (CIPHER_RC5 | CIPHER_CBC) #define CIPHER_cbc_RC6 (CIPHER_RC6 | CIPHER_CBC) @@ -257,6 +260,16 @@ const u8 *in, u8 *out, int size); extern int blowfish_decrypt(struct cipher_context *cx, const u8 *in, u8 *out, int size); + +extern int init_twofish(void); +#define TWOFISH_KEY_SCHEDULE_SIZE ((4*256+8+32)*sizeof(u32)) +extern int twofish_set_key(struct cipher_context *cx, + unsigned char *key, int key_len); +extern int twofish_encrypt(struct cipher_context *cx, + const u8 *in, u8 *out, int size); +extern int twofish_decrypt(struct cipher_context *cx, + const u8 *in, u8 *out, int size); + extern int init_idea(void); #define IDEA_KEY_SCHEDULE_SIZE (104*2) extern int idea_set_key(struct cipher_context *cx, unsigned char *key,