diff -Nru linux-2.4.0-test9-plain/Documentation/Configure.help linux-2.4.0-test9-int/Documentation/Configure.help --- linux-2.4.0-test9-plain/Documentation/Configure.help Sat Sep 23 02:11:37 2000 +++ linux-2.4.0-test9-int/Documentation/Configure.help Sun Oct 15 12:20:50 2000 @@ -326,6 +326,18 @@ Most users will answer N here. +General encryption support (EXPERIMENTAL)' +CONFIG_BLK_DEV_LOOP_GEN + [2000-07-06] + If you answer yes to this option, the loop-driver will support all + crypto algorithms selected in the crypto library (see the 'Crypto' + menu entry in the main menu). + + This loop module will use the ciphers in CBC-mode which is more + secure than ECB-mode. This module will also initialize the CBC-mode + of the cipher with the block-number of the block being encrypted. + + Network Block Device support CONFIG_BLK_DEV_NBD Saying Y here will allow your computer to be a client for network diff -Nru linux-2.4.0-test9-plain/Documentation/crypto/ChangeLog linux-2.4.0-test9-int/Documentation/crypto/ChangeLog --- linux-2.4.0-test9-plain/Documentation/crypto/ChangeLog Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/Documentation/crypto/ChangeLog Sun Oct 15 12:20:50 2000 @@ -0,0 +1,498 @@ +2000-07-06 Alexander Kjeldaas + + * International kernel patch 2.4.0-test2.1 released. + + * Ported the crypto API and loop_gen.c from international kernel + patch 2.2.16.5 to 2.4.0-test2. Ciphers will follow.. + +2000-07-03 Alexander Kjeldaas + + * International kernel patch 2.2.16.5 released. + + * Removed {un,}lock_cipher, {un,}lock_digest functions. Use + {digest,cipher}_implementation->{un,}lock() directly instead. + + * Stopped using linux/lists.h which is depreciated. + + * Merged crypto/cipherapi.c and crypto/digestapi.c into single + interface cryptoapi.c, saving 4k. Cipher- and digest algorithms + are now subclasses of a "transform". The old interface is still + supported for the most part. + + * Changed encrypt/decrypt interfaces to use byte-pointers instead + of int32-pointers. This means that the ciphers should start being + endian-aware. + +2000-06-27 Alexander Kjeldaas + + * International kernel patch 2.2.16.4 released. + * Fixed build bug that prevented digestapi.c from being built for + kernels with modules disabled. Fix by + Andreas Steinmetz + +2000-06-19 Alexander Kjeldaas + + * International kernel patch 2.2.16.3 released. + * Changed generic_rotl and generic_rotr to be macros instead of + inline functions. Gcc uses an extra register with the inline + functions (noted by Gisle Sælensminde). + * Fixed bug in Makefile for SHA1 digest (noted by Walter Hofmann + ). + +2000-06-19 Gisle Sælensminde + + * Further serpent implementation optimization. + +2000-06-14 Alexander Kjeldaas + + * International kernel patch 2.2.16.2 released. + * Fixed bug in md5c.c:Decode for big-endian machines. Noted by + David Kuestler . + +2000-06-14 Gisle Sælensminde + + * Faster serpent implementation based on optimized pentium-sboxes + made by Dag Arne Osvik. + +2000-06-14 Hauke Johannknecht + + * Documentation updates (replay.com -> zedz.com) + * Added util-linux-2.10m.int.patch + +2000-06-14 Alexander Kjeldaas + + * International kernel patch 2.2.16.1 released. + * International kernel patch 2.2.15.1 released. + +2000-02-18 Alexander Kjeldaas + + * International kernel patch 2.2.14.1 released. + +1999-11-23 Alexander Kjeldaas + + * International kernel patch 2.2.13.3 released. + + * Minor tweak to make sure the FreeSWAN 1.1 release patches cleanly. + +1999-11-23 Andrew McDonald + + * SHA1 implementation for the digest API added (based on the + public domain code by Steve Reid and the md5glue code). + + * Added a digest algorithm test program in linux/crypto/testing/ + + * FIX: The blowfish module claimed to have a 128-bit (16 byte) + blocksize and IV. The correct number is of course 64-bit. + + * FIX: The working size for MD5 was wrong (too little memory was + allocated). + +1999-10-25 Alexander Kjeldaas + + * International kernel patch 2.2.13.2 released. + + * Compile fix for MD5 by Hermann Schichl + +1999-10-20 Alexander Kjeldaas + + * International kernel patch 2.2.13.1 released. + + * New upstream kernel release. + +1999-09-15 Alexander Kjeldaas + + * International kernel patch 2.2.12.2 released. + + * Digest API mirroring the cipher API added. Contributed by Alan + Smithee. + + * MD5 digest algorithm added. + +1999-09-08 Alexander Kjeldaas + + * International kernel patch 2.2.12.1 released. + +1999-09-06 Alexander Kjeldaas + + * Updated util-linux patch in Documentation/crypto and removed + some patches that nobody uses. + +1999-08-12 Alexander Kjeldaas + + * International kernel patch 2.2.11.2 released. + + * CIPE can only be built as a module, the make config indicated + otherwise. + + * Upgraded to CIPE 1.3.0 + + * International kernel patch 2.2.11.1 released. + + * New upstream kernel release. + +1999-06-24 Alexander Kjeldaas + + * International kernel patch 2.2.10.4 released. + + * Added new config option for using relative block numbers instead + of absolute ones when calling the loop block device's transfer + function. This should fix the #1 issue with using loopback crypto + filesystems. + + * Updated Documentation/Configure.help which had erroneous + CONFIG_XX variables listed for various ciphers [Thanks to Andrew + Pam for spotting this]. + + * Added LO_CRYPT_RIJNDAEL and LO_CRYPT_RC5 variables to + include/linux/loop.h. + + * Updated the faq to mention rijndael and rc5, as well as how to + convert from the old absolute block number stuff to the new + relative one. + +1999-06-24 Alexander Kjeldaas + + * International kernel patch 2.2.10.3 released. + +1999-06-24 Andrew Pam + + * Updated util-linux patch to cover 2.9s + +1999-06-23 Alexander Kjeldaas + + * International kernel patch 2.2.10.2 released. + * Stuff in linux/crypto/testing didn't compile. + +1999-06-19 Pekka Riikonen + + * Added RC5 cipher. + +1999-06-18 Alexander Kjeldaas + + * International kernel patch 2.2.10.1 released. + * ENskip support didn't compile. + +1999-05-21 Alexander Kjeldaas + + * International kernel patch 2.2.9.1 released. + +1998-12-18 Patrice Lacroix + + * Updates to the faq (Documentation/crypto/faq.txt) + +1999-04-15 Alexander Kjeldaas + + * International kernel patch 2.2.5.1 released. + * Merged with kernel 2.2.5 + * New documentation for loopback crypto in + Documentation/crypto/faq.txt + +1999-03-25 Alexander Kjeldaas + + * International kernel patch 2.2.4.1 released. + * Merged with kernel 2.2.4 + +1999-01-29 Alexander Kjeldaas + + * International kernel patch 2.2.1.1 released. + +1998-01-29 Patrice Lacroix + + * /proc/crypto support. + +1999-01-27 Alexander Kjeldaas + + * International kernel patch 2.2.0.2 released. + + * missing #endif in net/ipv4/ip_output.c in latest patch + fixed. Missing #include fixed in crypto.h + +1999-01-26 Alexander Kjeldaas + + * International kernel patch 2.2.0.1 released. + + * Merged Frank Bernard's latest ENskip patches. + +1999-01-18 Alexander Kjeldaas + + * International kernel patch 2.2.0-pre7.4 released. + + * Added cbc-mode to cast256 cipher. + + * Removed spam on unload from crypto modules. + + * Added updated ENskip patches from Frank Bernard's web site: + http://www.linux-firewall.de/enskip/ + + * International kernel patch 2.2.0-pre7.3 released. + + * Added missing cleanup_module to DES, Blowfish and IDEA ciphers. + + * International kernel patch 2.2.0-pre7.2 released. + + * Cleanup in drivers/block/Config.in. It was possible to create + an invalid .config file. + + * Minor crypto/api.c cleanup. + +1999-01-17 Alexander Kjeldaas + + * International kernel patch 2.2.0-pre7.1 released. + + * Added testcip.c - a general purpose cipher test program. Added + test-vector scripts for Blowfish, DES, Mars, and Serpent. + + * Naming error left users unable to compile loop_gen unless it was + compiled as a module. + + * Updated Serpent implementation. Sam Simpson has been running a + background task on a cluster of high performance servers. After a + search involving around 1000 machine hours improved sboxes were + found. + + * Updated RC6 implementation. Supposedly faster. + + * Updated MARS implementation. Fixes a bug in mars_set_key. + +1999-01-07 Alexander Kjeldaas + + * International kernel patch 2.2.0-pre5.1 released. + * Merged with vanilla 2.2.0-pre5 + +1999-01-05 Herbert Valerio Riedel + + * APX fixes. + +1999-01-04 Alexander Kjeldaas + + * International kernel patch 2.2.0-pre4.1 released. + + * Removed obsolete loop_idea.c and loop_blow.c since IDEA and + blowfish algorithms have been added to the crypto library. + + * drivers/block/ll_rw_blk.c: Added loop_gen_init. loop_gen only + worked as a module. + +1998-12-30 Alexander Kjeldaas + + * crypto/testing/speed.c: i386-specific timer-code removed. + + * crypto configuration added for all architectures (previously + only i386 was supported). However, 64-bit and endian issues needs + to be ironed out for a lot of platforms (maybe even i386). + +1998-12-29 Alexander Kjeldaas + + * International kernel patch 2.2.0-pre1.1 released. + * International kernel patch 2.1.131.8 released. + * DES/IDEA compile fixes. + +1998-12-29 Raimar Falke + + * DES cipher added. crypto/testing/speed.c fixes. + +1998-12-18 Alexander Kjeldaas + + * International kernel patch 2.1.131.7 released. + +1998-12-18 Raimar Falke + + * include-fixes for IDEA cipher. + +1998-12-18 Alexander Kjeldaas + + * International kernel patch 2.1.131.6 released. + +1998-12-18 Raimar Falke + + * IDEA cipher added. + +1998-12-18 Patrice Lacroix + + * My latest patch for modular loop encryption. I think everything + is in there. Ciphers are only requested on LOOP_SET_STATUS. Module + count is always right (for what I have tested) and unloading now + works. + +1998-12-17 Alexander Kjeldaas + + * International kernel patch 2.1.131.5 released. + +1998-12-17 Raimar Falke + + * Extracted the blowfish code from loop_blow and made a + cipher-module of it. + +1998-12-17 Alexander Kjeldaas + + * Removed loop_serpent, loop_mars, loop_dfc and loop_rc6 since + their funcionality is available through loop_gen. + +1998-12-16 Alexander Kjeldaas + + * Removed loop_idea from the configuration menus. It hasn't been + converted to the new API. + +1998-12-14 Alexander Kjeldaas + + * Fixes to the rijndael cipher. It builds, but isn't working + properly so it it disabled for the moment. The cipher is from + Dr. Brian Gladman AES + reimplementation project. More information on rijndael: + http://www.esat.kuleuven.ac.be/~rijmen/rijndael/ Rijndael is free. + +1998-12-14 Patrice Lacroix + + * More modular ciphers/loop patches. Cipher locking fixes. + Autoloading of ciphers. More loop and loop_gen integration. + +1998-12-14 Alexander Kjeldaas + + * International kernel patch 2.1.131.4 released. + + * Added util-linux-2.9e patch to Documentation/crypto that makes + all the loopback ciphers available to the losetup utility. + +1998-12-12 Alexander Kjeldaas + + * International kernel patch 2.1.131.3 released. + + * Added the popular CIPE (crypto IP encapsulation) made by + Olaf Titz + + * Previous patch wouldn't build. International kernel patch + 2.1.131.2 released. + +1998-12-11 Alexander Kjeldaas + + * International kernel patch 2.1.131.1 released. + + * Clear sensitive memory before kfree in generel loop module. New + upstream kernel. + +1998-12-11 Patrice Lacroix + + * Modular ciphers + +1998-11-30 Alexander Kjeldaas + + * International kernel patch 2.1.130.1 released. + + * loop-devices other than loop_gen updated to use new interface. + However, the block-number isn't used for anything yet. + + * loop_gen.c: Now we use the ciphers in cbc-mode only. Also, the + IV of the cipher is initialized based on block-number. + + * Added general cbc-mode that is simply #included into the + ciphers. cbc-mode thus added to serpent, mars, rc6 and dfc. + + * Added ivsize to struct cipher_implementation. + + * Added for_each_cipher function + + * Added X11-like license for the crypto-directory. The code might + be useable for other projects as well in the future. [And GPL is + arguable the wrong license for crypto]. + +1998-11-25 Alexander Kjeldaas + + * The crypto api is useable from modules. + + * Fixed a bunch of bugs in loop_gen. I think the oopses are gone. + +1998-11-23 Alexander Kjeldaas + + * International kernel patch 2.1.129.4 released. + + * Added crypto/testing/speed.c to test the speed of the different + crypto algorithms. + + * cast256, crypton, rijndael, safer, and twofish added, but they + are not yet completely ported to the crypto-library. + + * Updated implementations of MARS, DFC, RC6 and SERPENT. + +1998-11-22 Alexander Kjeldaas + + * International kernel patch 2.1.129.3 released. + + * "loop_gen" - skeleton of general loop crypto driver added + + * Made loop-modules for DFC, MARS, and RC6 + + * Added DFC, MARS, and RC6 to crypto library + + * International kernel patch 2.1.129.2 released. + + * Updated documentation to show which loopback modules are ECB + and which are CBC. + + * Kernel crypto library on its way. Serpent is the first member. + + * Changed memcpy to memset in loop_blow.c to close a possible + plaintext leak. + +1998-11-20 Alexander Kjeldaas + + * New upstream kernel release 2.1.129 + +1998-11-13 Alexander Kjeldaas + + * New upstream kernel release 2.1.128 + +1998-11-09 Alexander Kjeldaas + + * New upstream kernel release 2.1.127 + +1998-10-12 Alexander Kjeldaas + + * drivers/block/loop_serpent.c: Made wrapper-module for the + serpent cipher. + + * crypto/serpent.c crypto/serpent_f_box.h}: Added serpent + implementation from Dr. B R Gladman + AES reimplementation project. + + * drivers/block/Config.in: Loopback crypto flagged experimental + +1998-10-09 Alexander Kjeldaas + + * International kernel patch 2.1.125.1 released. + + * New upstream kernel release 2.1.125 + +1998-10-08 Alexander Kjeldaas + + * International kernel patch 2.1.124.2 released. + + * Added Andi Kleene's loop fixes. Updated twofish, blowfish and + cast128 modules to use the new lock/unlock interface. + +1998-10-07 Alexander Kjeldaas + + * Ported loop_cast.c to the new loopback API interface. + + * Blowfish and Twofish can be compiled in instead of being + modules. + + * Added cast and idea to the config-system. + + * Wrote Configure.help entries for the loop crypto patches. + +1998-10-05 Alexander Kjeldaas + + * International kernel patch 2.1.124.1 released. + + * Added cast128 and idea loopback modules from Andrew E. Mileski's + loop-13.tar.gz package. + + * Added latest ENskip patches from Bob Tracy + +1998-10-05 Ingo Rohloff + + * Fixed bug in loop.c regarding handling of calls to + loop_release_xfer() + + * Added modules for blowfish and twofish to the loopback + filesystem diff -Nru linux-2.4.0-test9-plain/Documentation/crypto/faq.txt linux-2.4.0-test9-int/Documentation/crypto/faq.txt --- linux-2.4.0-test9-plain/Documentation/crypto/faq.txt Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/Documentation/crypto/faq.txt Sun Oct 15 12:20:50 2000 @@ -0,0 +1,159 @@ +Questions and answers concerning crypto and looppack device +By Patrice Lacroix +Last update: 1999-05-21 + +1) What is the crypto API? + +It allow other parts of the kernel to use crypto in a generic way, +most notably the loopback device driver (loop_gen.c). + + +2) What is loop_gen? + +First, you should already be familiar with basic loopback device. See +losetup(1) for more info. + +Loop_gen is the generic encryption layer for the loopback driver. +It uses the crypto API to do encryption. It works with every ciphers +supported by the crypto API. Not all ciphers in the crypto library +support the API yet. + +Loop_gen (and the crypto api) will eventually replace all other loopback +encryption modules. + +Loop_gen use all supported ciphers in CBC mode. + + +3) What can I do with loop_gen? + +The basic loopback device driver allow you to use a file as a block +device. With loop_gen, data in the file associated with the loopback +block device can be encrypted with strong crypto. + +You can use the result as any other block device. If you create a file +system and mount it, then every file in the file system will be +automaticly encrypted. + + +4) Can I use all this as modules? + +Sure! In make menuconfig (or whatever), under Crypto options, say M to +Crypto ciphers and to the ciphers you want. Under Block Device, say M to +loopback device and to General Encryption Support. Don't select any other +encryption modules unless you can't live without them and they are +no longer suported by the crypto API. + +Build your kernel and modules, make modules_install, reboot, depmod -a + +In /etc/conf.modules, add: + +alias loop-xfer-gen-0 loop_gen +alias loop-xfer-gen-10 loop_gen +alias cipher-2 des +alias cipher-4 blowfish +alias cipher-6 idea +alias cipher-7 serp6f +alias cipher-8 mars6 +alias cipher-11 rc62 +alias cipher-15 dfc2 +alias cipher-16 rijndael +alias cipher-17 rc5 + + +5) Why all those funny numbers? + +In short, the kernel know ciphers only by number. If you really want to know +how it works, you can grep request_module in linux/crypto/api.c and +linux/drivers/block/loop.c. + + +6) I get "Unsupported encryption type" when I use losetup or mount. What's + wrong? + +You need a version of losetup and mount that understand new encryption +types. To get it, you probably have to apply the util-linux patch you can +find in linux/Documentation/crypto and rebuild mount and losetup. + + +7) Can I stack loop devices and encryption? + +Yes! + + +6) I can't access the content of my encrypted file system since I + moved the backing file to a new partition. Why? + +This is because when a block of data is encrypted with loop_gen, +its IV for CBC encryption is set to the real block where the +file is located on the block device underneath it. So when the +encrypted file system is physically moved on a block device, the +IV used for encryption and decryption change, and data can't be +decrypted correctly. + +As of patch-int-2.2.10.4, you should answer 'Y' to the question 'Use +relative block numbers as basis for transfer functions (RECOMMENDED)' +to avoid this problem. + +Another solution is to losetup your file once without using crypto and +then losetup again the first loopback block device to add +encryption. Since the encryption will always be from block 0 (inside +the first loopback device), the IV for CBC encryption will be the same +no matter where the original file is located. + +Ex: + +# losetup /dev/loop0 encfs.loop +# losetup -e blowfish /dev/loop1 /dev/loop0 +Password: (not shown) +# mount /dev/loop1 /mnt + +(here you can access the fs under /mnt...) + +(and to destroy loopback devices...) + +# umount /mnt +# losetup -d /dev/loop1 +# losetup -d /dev/loop0 + +With this solution, you can do backup of your encrypted data +(which is a good thing) but it's more complexe and it's probably +less secure (which is a bad thing). + + +7) Since patch-int-2.2.10.4 I can't access my encrypted device. + +As of patch-int-2.2.10.4, the encrypted files will be incompatible +with older files if you answer 'Y' to the question 'Use relative block +numbers as basis for transfer functions (RECOMMENDED)'. To be able to +back up your encrypted files in the future, you should convert to the +new layout [which uses relative block numbers as IV to the cipher +instead of absolute ones]. This can be accomplished by doing +something like the following: + + +# losetup -e mypreferredcipher /dev/loop0 /myfile + +# dd if=/dev/loop0 of=tmpfile +# losetup -d /dev/loop0 + + +# losetup -e mypreferredcipher /dev/loop0 /myfile + +# dd if=tmpfile of=/dev/loop0 +# dd if=/dev/zero of=tmpfile bs=1k count= +or you could download some of the special software used for wiping +magnetic media such as wipe from +http://gsu.linux.org.tr/wipe/ + +8) I made an encrypted filesystem on my hard-disk and tried to burn it + on a CD. Now I can't get the CD to work properly. + +This is a current limitation in the loop device code. The block size +(the smalles number of bytes that can be read) of a hard-disk is +smaller than the block size of a CD-ROM. This causes problems since +the block size dictates how many bytes are encrypted as a block. + +There is no solution to this problem at this time, but it isn't hard +to fix. Contact me (Alexander Kjeldaas ) if you're +willing to work on this problem. + diff -Nru linux-2.4.0-test9-plain/Documentation/crypto/util-linux-2.10m.int.patch linux-2.4.0-test9-int/Documentation/crypto/util-linux-2.10m.int.patch --- linux-2.4.0-test9-plain/Documentation/crypto/util-linux-2.10m.int.patch Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/Documentation/crypto/util-linux-2.10m.int.patch Sun Oct 15 12:20:50 2000 @@ -0,0 +1,633 @@ +diff -uNr util-linux-2.10m/MCONFIG util-linux-2.10m.int/MCONFIG +--- util-linux-2.10m/MCONFIG Mon May 15 00:23:49 2000 ++++ util-linux-2.10m.int/MCONFIG Mon May 22 20:06:41 2000 +@@ -16,7 +16,7 @@ + # If HAVE_PAM is set to "yes", then login, chfn, chsh, and newgrp + # will use PAM for authentication. Additionally, passwd will not be + # installed as it is not PAM aware. +-HAVE_PAM=no ++HAVE_PAM=yes + + # If HAVE_SHADOW is set to "yes", then login, chfn, chsh, newgrp, passwd, + # and vipw will not be built or installed from the login-utils +diff -uNr util-linux-2.10m/mount/Makefile util-linux-2.10m.int/mount/Makefile +--- util-linux-2.10m/mount/Makefile Wed Apr 19 00:51:27 2000 ++++ util-linux-2.10m.int/mount/Makefile Mon May 22 20:07:45 2000 +@@ -30,7 +30,7 @@ + GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c + + # comment these out if you are not compiling in loop support +-LO_OBJS=lomount.o ++LO_OBJS=lomount.o rmd160.o + + all: $(PROGS) + +@@ -62,7 +62,7 @@ + $(COMPILE) -DMAIN lomount.c + mv lomount.o losetup.o + +-losetup: losetup.o ++losetup: losetup.o rmd160.o + $(LINK) $^ -o $@ + + mount.o umount.o nfsmount.o losetup.o fstab.o realpath.o sundries.o: sundries.h +diff -uNr util-linux-2.10m/mount/lomount.c util-linux-2.10m.int/mount/lomount.c +--- util-linux-2.10m/mount/lomount.c Tue Apr 18 23:48:34 2000 ++++ util-linux-2.10m.int/mount/lomount.c Mon May 22 20:35:29 2000 +@@ -27,6 +27,7 @@ + + #include "loop.h" + #include "lomount.h" ++#include "rmd160.h" + #include "nls.h" + + extern int verbose; +@@ -42,6 +43,14 @@ + { LO_CRYPT_NONE, "none" }, + { LO_CRYPT_XOR, "xor" }, + { LO_CRYPT_DES, "DES" }, ++ { LO_CRYPT_FISH2, "twofish" }, ++ { LO_CRYPT_BLOW, "blowfish"}, ++ { LO_CRYPT_CAST128, "cast128"}, ++ { LO_CRYPT_SERPENT, "serpent"}, ++ { LO_CRYPT_MARS, "mars" }, ++ { LO_CRYPT_RC6, "rc6" }, ++ { LO_CRYPT_DFC, "dfc" }, ++ { LO_CRYPT_IDEA, "idea"}, + { -1, NULL } + }; + +@@ -218,6 +227,7 @@ + loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key); + break; + case LO_CRYPT_DES: ++ printf(_("WARNING: Use of DES is depreciated.\n")); + pass = getpass (_("Password: ")); + strncpy (loopinfo.lo_encrypt_key, pass, 8); + loopinfo.lo_encrypt_key[8] = 0; +@@ -234,6 +244,22 @@ + return 1; + } + break; ++ case LO_CRYPT_FISH2: ++ case LO_CRYPT_BLOW: ++ pass = getpass("Password :"); ++ MDcalc((byte *)loopinfo.lo_encrypt_key,pass,strlen(pass)); ++ loopinfo.lo_encrypt_key_size=20; /* 160 Bit key */ ++ break; ++ case LO_CRYPT_IDEA: ++ case LO_CRYPT_CAST128: ++ case LO_CRYPT_SERPENT: ++ case LO_CRYPT_MARS: ++ case LO_CRYPT_RC6: ++ case LO_CRYPT_DFC: ++ pass = getpass("Password :"); ++ MDcalc((byte *)loopinfo.lo_encrypt_key,pass,strlen(pass)); ++ loopinfo.lo_encrypt_key_size=16; /* 128 Bit key */ ++ break; + default: + fprintf (stderr, + _("Don't know how to get key for encryption system %d\n"), +@@ -318,11 +344,18 @@ + + static void + usage(void) { ++ struct crypt_type_struct *c; + fprintf(stderr, _("usage:\n\ + %s loop_device # give info\n\ + %s -d loop_device # delete\n\ + %s [ -e encryption ] [ -o offset ] loop_device file # setup\n"), + progname, progname, progname); ++ fprintf(stderr, " where encryption is one of:\n"); ++ c = &crypt_type_tbl[0]; ++ while(c->name) { ++ fprintf(stderr, " %s\n", c->name); ++ c++; ++ } + exit(1); + } + +diff -uNr util-linux-2.10m/mount/losetup.8 util-linux-2.10m.int/mount/losetup.8 +--- util-linux-2.10m/mount/losetup.8 Fri Jul 9 04:56:39 1999 ++++ util-linux-2.10m.int/mount/losetup.8 Mon May 22 20:14:18 2000 +@@ -36,11 +36,47 @@ + .PD 0 + .IP \fBXOR\fP + use a simple XOR encryption. ++.IP \fBBlowfish\fP ++use Blowfish encryption. Blowfish encryption is only available if you ++are using the international kernel and Blowfish encryption has been ++enabled in the Crypto API. ++.IP \fBTwofish\fP ++use Twofish encryption. Twofish encryption is only available if you ++are using the international kernel and Twofish encryption has been ++enabled in the Crypto API. ++.IP \fBCAST\fP ++use CAST encryption. CAST encryption is only available if you ++are using the international kernel and CAST encryption has been ++enabled in the Crypto API. + .IP \fBDES\fP + use DES encryption. DES encryption is only available if the optional + DES package has been added to the kernel. DES encryption uses an additional + start value that is used to protect passwords against dictionary +-attacks. ++attacks. Use of DES is deprecated. ++.IP \fBDFC\fP ++use DFC encryption. DFC encryption is only available if you ++are using the international kernel and DFC encryption has been ++enabled in the Crypto API. ++.IP \fBIDEA\fP ++use IDEA encryption. IDEA encryption is only available if you ++are using the international kernel and IDEA encryption has been ++enabled in the Crypto API. ++.IP \fBMARS\fP ++use MARS encryption. MARS encryption is only available if you ++are using the international kernel and MARS encryption has been ++enabled in the Crypto API. ++.IP \fBRC5\fP ++use RC5 encryption. RC5 encryption is only available if you ++are using the international kernel and RC5 encryption has been ++enabled in the Crypto API. ++.IP \fBRC6\fP ++use RC6 encryption. RC6 encryption is only available if you ++are using the international kernel and RC6 encryption has been ++enabled in the Crypto API. ++.IP \fBSerpent\fP ++use Serpent encryption. Serpent encryption is only available if you ++are using the international kernel and Serpent encryption has been ++enabled in the Crypto API. + .PD + .RE + .IP "\fB\-o \fIoffset\fP" +@@ -49,6 +85,7 @@ + .SH FILES + .nf + /dev/loop0,/dev/loop1,... loop devices (major=7) ++/proc/cipher/* available ciphers + .fi + .SH EXAMPLE + If you are using the loadable module you must have the module loaded +@@ -60,9 +97,8 @@ + .nf + .IP + dd if=/dev/zero of=/file bs=1k count=100 +-losetup -e des /dev/loop0 /file +-Password: +-Init (up to 16 hex digits): ++losetup -e blowfish /dev/loop0 /file ++Password : + mkfs -t ext2 /dev/loop0 100 + mount -t ext2 /dev/loop0 /mnt + ... +@@ -76,8 +112,12 @@ + # rmmod loop + .LP + .fi +-.SH RESTRICTION +-DES encryption is painfully slow. On the other hand, XOR is terribly weak. ++.SH RESTRICTIONS ++DES encryption is painfully slow. On the other hand, XOR is terribly ++weak. Both are insecure nowadays. Some ciphers require a licence for ++you to be allowed to use them. ++.SH BUGS ++CAST, DES, RC5 and Twofish are currently broken and cannot be used. + .SH AUTHORS + .nf + Original version: Theodore Ts'o +diff -uNr util-linux-2.10m/mount/rmd160.c util-linux-2.10m.int/mount/rmd160.c +--- util-linux-2.10m/mount/rmd160.c Thu Jan 1 01:00:00 1970 ++++ util-linux-2.10m.int/mount/rmd160.c Mon May 22 20:35:44 2000 +@@ -0,0 +1,371 @@ ++/********************************************************************\ ++ * ++ * FILE: rmd160.c ++ * ++ * CONTENTS: A sample C-implementation of the RIPEMD-160 ++ * hash-function. ++ * TARGET: any computer with an ANSI C compiler ++ * ++ * AUTHOR: Antoon Bosselaers, ESAT-COSIC ++ * DATE: 1 March 1996 ++ * VERSION: 1.0 ++ * ++ * Copyright (c) Katholieke Universiteit Leuven ++ * 1996, All Rights Reserved ++ * ++\********************************************************************/ ++ ++/* header files */ ++#include ++#include ++#include ++#include "rmd160.h" ++ ++/********************************************************************/ ++ ++/* macro definitions */ ++ ++/* collect four bytes into one word: */ ++#define BYTES_TO_DWORD(strptr) \ ++ (((dword) *((strptr)+3) << 24) | \ ++ ((dword) *((strptr)+2) << 16) | \ ++ ((dword) *((strptr)+1) << 8) | \ ++ ((dword) *(strptr))) ++ ++/* ROL(x, n) cyclically rotates x over n bits to the left */ ++/* x must be of an unsigned 32 bits type and 0 <= n < 32. */ ++#define ROL(x, n) (((x) << (n)) | ((x) >> (32-(n)))) ++ ++/* the five basic functions F(), G() and H() */ ++#define F(x, y, z) ((x) ^ (y) ^ (z)) ++#define G(x, y, z) (((x) & (y)) | (~(x) & (z))) ++#define H(x, y, z) (((x) | ~(y)) ^ (z)) ++#define I(x, y, z) (((x) & (z)) | ((y) & ~(z))) ++#define J(x, y, z) ((x) ^ ((y) | ~(z))) ++ ++/* the ten basic operations FF() through III() */ ++#define FF(a, b, c, d, e, x, s) {\ ++ (a) += F((b), (c), (d)) + (x);\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define GG(a, b, c, d, e, x, s) {\ ++ (a) += G((b), (c), (d)) + (x) + 0x5a827999UL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define HH(a, b, c, d, e, x, s) {\ ++ (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1UL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define II(a, b, c, d, e, x, s) {\ ++ (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcUL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define JJ(a, b, c, d, e, x, s) {\ ++ (a) += J((b), (c), (d)) + (x) + 0xa953fd4eUL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define FFF(a, b, c, d, e, x, s) {\ ++ (a) += F((b), (c), (d)) + (x);\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define GGG(a, b, c, d, e, x, s) {\ ++ (a) += G((b), (c), (d)) + (x) + 0x7a6d76e9UL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define HHH(a, b, c, d, e, x, s) {\ ++ (a) += H((b), (c), (d)) + (x) + 0x6d703ef3UL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define III(a, b, c, d, e, x, s) {\ ++ (a) += I((b), (c), (d)) + (x) + 0x5c4dd124UL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++#define JJJ(a, b, c, d, e, x, s) {\ ++ (a) += J((b), (c), (d)) + (x) + 0x50a28be6UL;\ ++ (a) = ROL((a), (s)) + (e);\ ++ (c) = ROL((c), 10);\ ++ } ++ ++ ++/********************************************************************/ ++ ++void MDinit(dword *MDbuf) ++{ ++ MDbuf[0] = 0x67452301UL; ++ MDbuf[1] = 0xefcdab89UL; ++ MDbuf[2] = 0x98badcfeUL; ++ MDbuf[3] = 0x10325476UL; ++ MDbuf[4] = 0xc3d2e1f0UL; ++ ++ return; ++} ++ ++/********************************************************************/ ++ ++void compress(dword *MDbuf, dword *X) ++{ ++ dword aa = MDbuf[0], bb = MDbuf[1], cc = MDbuf[2], ++ dd = MDbuf[3], ee = MDbuf[4]; ++ dword aaa = MDbuf[0], bbb = MDbuf[1], ccc = MDbuf[2], ++ ddd = MDbuf[3], eee = MDbuf[4]; ++ ++ /* round 1 */ ++ FF(aa, bb, cc, dd, ee, X[ 0], 11); ++ FF(ee, aa, bb, cc, dd, X[ 1], 14); ++ FF(dd, ee, aa, bb, cc, X[ 2], 15); ++ FF(cc, dd, ee, aa, bb, X[ 3], 12); ++ FF(bb, cc, dd, ee, aa, X[ 4], 5); ++ FF(aa, bb, cc, dd, ee, X[ 5], 8); ++ FF(ee, aa, bb, cc, dd, X[ 6], 7); ++ FF(dd, ee, aa, bb, cc, X[ 7], 9); ++ FF(cc, dd, ee, aa, bb, X[ 8], 11); ++ FF(bb, cc, dd, ee, aa, X[ 9], 13); ++ FF(aa, bb, cc, dd, ee, X[10], 14); ++ FF(ee, aa, bb, cc, dd, X[11], 15); ++ FF(dd, ee, aa, bb, cc, X[12], 6); ++ FF(cc, dd, ee, aa, bb, X[13], 7); ++ FF(bb, cc, dd, ee, aa, X[14], 9); ++ FF(aa, bb, cc, dd, ee, X[15], 8); ++ ++ /* round 2 */ ++ GG(ee, aa, bb, cc, dd, X[ 7], 7); ++ GG(dd, ee, aa, bb, cc, X[ 4], 6); ++ GG(cc, dd, ee, aa, bb, X[13], 8); ++ GG(bb, cc, dd, ee, aa, X[ 1], 13); ++ GG(aa, bb, cc, dd, ee, X[10], 11); ++ GG(ee, aa, bb, cc, dd, X[ 6], 9); ++ GG(dd, ee, aa, bb, cc, X[15], 7); ++ GG(cc, dd, ee, aa, bb, X[ 3], 15); ++ GG(bb, cc, dd, ee, aa, X[12], 7); ++ GG(aa, bb, cc, dd, ee, X[ 0], 12); ++ GG(ee, aa, bb, cc, dd, X[ 9], 15); ++ GG(dd, ee, aa, bb, cc, X[ 5], 9); ++ GG(cc, dd, ee, aa, bb, X[ 2], 11); ++ GG(bb, cc, dd, ee, aa, X[14], 7); ++ GG(aa, bb, cc, dd, ee, X[11], 13); ++ GG(ee, aa, bb, cc, dd, X[ 8], 12); ++ ++ /* round 3 */ ++ HH(dd, ee, aa, bb, cc, X[ 3], 11); ++ HH(cc, dd, ee, aa, bb, X[10], 13); ++ HH(bb, cc, dd, ee, aa, X[14], 6); ++ HH(aa, bb, cc, dd, ee, X[ 4], 7); ++ HH(ee, aa, bb, cc, dd, X[ 9], 14); ++ HH(dd, ee, aa, bb, cc, X[15], 9); ++ HH(cc, dd, ee, aa, bb, X[ 8], 13); ++ HH(bb, cc, dd, ee, aa, X[ 1], 15); ++ HH(aa, bb, cc, dd, ee, X[ 2], 14); ++ HH(ee, aa, bb, cc, dd, X[ 7], 8); ++ HH(dd, ee, aa, bb, cc, X[ 0], 13); ++ HH(cc, dd, ee, aa, bb, X[ 6], 6); ++ HH(bb, cc, dd, ee, aa, X[13], 5); ++ HH(aa, bb, cc, dd, ee, X[11], 12); ++ HH(ee, aa, bb, cc, dd, X[ 5], 7); ++ HH(dd, ee, aa, bb, cc, X[12], 5); ++ ++ /* round 4 */ ++ II(cc, dd, ee, aa, bb, X[ 1], 11); ++ II(bb, cc, dd, ee, aa, X[ 9], 12); ++ II(aa, bb, cc, dd, ee, X[11], 14); ++ II(ee, aa, bb, cc, dd, X[10], 15); ++ II(dd, ee, aa, bb, cc, X[ 0], 14); ++ II(cc, dd, ee, aa, bb, X[ 8], 15); ++ II(bb, cc, dd, ee, aa, X[12], 9); ++ II(aa, bb, cc, dd, ee, X[ 4], 8); ++ II(ee, aa, bb, cc, dd, X[13], 9); ++ II(dd, ee, aa, bb, cc, X[ 3], 14); ++ II(cc, dd, ee, aa, bb, X[ 7], 5); ++ II(bb, cc, dd, ee, aa, X[15], 6); ++ II(aa, bb, cc, dd, ee, X[14], 8); ++ II(ee, aa, bb, cc, dd, X[ 5], 6); ++ II(dd, ee, aa, bb, cc, X[ 6], 5); ++ II(cc, dd, ee, aa, bb, X[ 2], 12); ++ ++ /* round 5 */ ++ JJ(bb, cc, dd, ee, aa, X[ 4], 9); ++ JJ(aa, bb, cc, dd, ee, X[ 0], 15); ++ JJ(ee, aa, bb, cc, dd, X[ 5], 5); ++ JJ(dd, ee, aa, bb, cc, X[ 9], 11); ++ JJ(cc, dd, ee, aa, bb, X[ 7], 6); ++ JJ(bb, cc, dd, ee, aa, X[12], 8); ++ JJ(aa, bb, cc, dd, ee, X[ 2], 13); ++ JJ(ee, aa, bb, cc, dd, X[10], 12); ++ JJ(dd, ee, aa, bb, cc, X[14], 5); ++ JJ(cc, dd, ee, aa, bb, X[ 1], 12); ++ JJ(bb, cc, dd, ee, aa, X[ 3], 13); ++ JJ(aa, bb, cc, dd, ee, X[ 8], 14); ++ JJ(ee, aa, bb, cc, dd, X[11], 11); ++ JJ(dd, ee, aa, bb, cc, X[ 6], 8); ++ JJ(cc, dd, ee, aa, bb, X[15], 5); ++ JJ(bb, cc, dd, ee, aa, X[13], 6); ++ ++ /* parallel round 1 */ ++ JJJ(aaa, bbb, ccc, ddd, eee, X[ 5], 8); ++ JJJ(eee, aaa, bbb, ccc, ddd, X[14], 9); ++ JJJ(ddd, eee, aaa, bbb, ccc, X[ 7], 9); ++ JJJ(ccc, ddd, eee, aaa, bbb, X[ 0], 11); ++ JJJ(bbb, ccc, ddd, eee, aaa, X[ 9], 13); ++ JJJ(aaa, bbb, ccc, ddd, eee, X[ 2], 15); ++ JJJ(eee, aaa, bbb, ccc, ddd, X[11], 15); ++ JJJ(ddd, eee, aaa, bbb, ccc, X[ 4], 5); ++ JJJ(ccc, ddd, eee, aaa, bbb, X[13], 7); ++ JJJ(bbb, ccc, ddd, eee, aaa, X[ 6], 7); ++ JJJ(aaa, bbb, ccc, ddd, eee, X[15], 8); ++ JJJ(eee, aaa, bbb, ccc, ddd, X[ 8], 11); ++ JJJ(ddd, eee, aaa, bbb, ccc, X[ 1], 14); ++ JJJ(ccc, ddd, eee, aaa, bbb, X[10], 14); ++ JJJ(bbb, ccc, ddd, eee, aaa, X[ 3], 12); ++ JJJ(aaa, bbb, ccc, ddd, eee, X[12], 6); ++ ++ /* parallel round 2 */ ++ III(eee, aaa, bbb, ccc, ddd, X[ 6], 9); ++ III(ddd, eee, aaa, bbb, ccc, X[11], 13); ++ III(ccc, ddd, eee, aaa, bbb, X[ 3], 15); ++ III(bbb, ccc, ddd, eee, aaa, X[ 7], 7); ++ III(aaa, bbb, ccc, ddd, eee, X[ 0], 12); ++ III(eee, aaa, bbb, ccc, ddd, X[13], 8); ++ III(ddd, eee, aaa, bbb, ccc, X[ 5], 9); ++ III(ccc, ddd, eee, aaa, bbb, X[10], 11); ++ III(bbb, ccc, ddd, eee, aaa, X[14], 7); ++ III(aaa, bbb, ccc, ddd, eee, X[15], 7); ++ III(eee, aaa, bbb, ccc, ddd, X[ 8], 12); ++ III(ddd, eee, aaa, bbb, ccc, X[12], 7); ++ III(ccc, ddd, eee, aaa, bbb, X[ 4], 6); ++ III(bbb, ccc, ddd, eee, aaa, X[ 9], 15); ++ III(aaa, bbb, ccc, ddd, eee, X[ 1], 13); ++ III(eee, aaa, bbb, ccc, ddd, X[ 2], 11); ++ ++ /* parallel round 3 */ ++ HHH(ddd, eee, aaa, bbb, ccc, X[15], 9); ++ HHH(ccc, ddd, eee, aaa, bbb, X[ 5], 7); ++ HHH(bbb, ccc, ddd, eee, aaa, X[ 1], 15); ++ HHH(aaa, bbb, ccc, ddd, eee, X[ 3], 11); ++ HHH(eee, aaa, bbb, ccc, ddd, X[ 7], 8); ++ HHH(ddd, eee, aaa, bbb, ccc, X[14], 6); ++ HHH(ccc, ddd, eee, aaa, bbb, X[ 6], 6); ++ HHH(bbb, ccc, ddd, eee, aaa, X[ 9], 14); ++ HHH(aaa, bbb, ccc, ddd, eee, X[11], 12); ++ HHH(eee, aaa, bbb, ccc, ddd, X[ 8], 13); ++ HHH(ddd, eee, aaa, bbb, ccc, X[12], 5); ++ HHH(ccc, ddd, eee, aaa, bbb, X[ 2], 14); ++ HHH(bbb, ccc, ddd, eee, aaa, X[10], 13); ++ HHH(aaa, bbb, ccc, ddd, eee, X[ 0], 13); ++ HHH(eee, aaa, bbb, ccc, ddd, X[ 4], 7); ++ HHH(ddd, eee, aaa, bbb, ccc, X[13], 5); ++ ++ /* parallel round 4 */ ++ GGG(ccc, ddd, eee, aaa, bbb, X[ 8], 15); ++ GGG(bbb, ccc, ddd, eee, aaa, X[ 6], 5); ++ GGG(aaa, bbb, ccc, ddd, eee, X[ 4], 8); ++ GGG(eee, aaa, bbb, ccc, ddd, X[ 1], 11); ++ GGG(ddd, eee, aaa, bbb, ccc, X[ 3], 14); ++ GGG(ccc, ddd, eee, aaa, bbb, X[11], 14); ++ GGG(bbb, ccc, ddd, eee, aaa, X[15], 6); ++ GGG(aaa, bbb, ccc, ddd, eee, X[ 0], 14); ++ GGG(eee, aaa, bbb, ccc, ddd, X[ 5], 6); ++ GGG(ddd, eee, aaa, bbb, ccc, X[12], 9); ++ GGG(ccc, ddd, eee, aaa, bbb, X[ 2], 12); ++ GGG(bbb, ccc, ddd, eee, aaa, X[13], 9); ++ GGG(aaa, bbb, ccc, ddd, eee, X[ 9], 12); ++ GGG(eee, aaa, bbb, ccc, ddd, X[ 7], 5); ++ GGG(ddd, eee, aaa, bbb, ccc, X[10], 15); ++ GGG(ccc, ddd, eee, aaa, bbb, X[14], 8); ++ ++ /* parallel round 5 */ ++ FFF(bbb, ccc, ddd, eee, aaa, X[12] , 8); ++ FFF(aaa, bbb, ccc, ddd, eee, X[15] , 5); ++ FFF(eee, aaa, bbb, ccc, ddd, X[10] , 12); ++ FFF(ddd, eee, aaa, bbb, ccc, X[ 4] , 9); ++ FFF(ccc, ddd, eee, aaa, bbb, X[ 1] , 12); ++ FFF(bbb, ccc, ddd, eee, aaa, X[ 5] , 5); ++ FFF(aaa, bbb, ccc, ddd, eee, X[ 8] , 14); ++ FFF(eee, aaa, bbb, ccc, ddd, X[ 7] , 6); ++ FFF(ddd, eee, aaa, bbb, ccc, X[ 6] , 8); ++ FFF(ccc, ddd, eee, aaa, bbb, X[ 2] , 13); ++ FFF(bbb, ccc, ddd, eee, aaa, X[13] , 6); ++ FFF(aaa, bbb, ccc, ddd, eee, X[14] , 5); ++ FFF(eee, aaa, bbb, ccc, ddd, X[ 0] , 15); ++ FFF(ddd, eee, aaa, bbb, ccc, X[ 3] , 13); ++ FFF(ccc, ddd, eee, aaa, bbb, X[ 9] , 11); ++ FFF(bbb, ccc, ddd, eee, aaa, X[11] , 11); ++ ++ /* combine results */ ++ ddd += cc + MDbuf[1]; /* final result for MDbuf[0] */ ++ MDbuf[1] = MDbuf[2] + dd + eee; ++ MDbuf[2] = MDbuf[3] + ee + aaa; ++ MDbuf[3] = MDbuf[4] + aa + bbb; ++ MDbuf[4] = MDbuf[0] + bb + ccc; ++ MDbuf[0] = ddd; ++ ++ return; ++} ++ ++/********************************************************************/ ++ ++void MDfinish(dword *MDbuf, byte *strptr, dword lswlen, dword mswlen) ++{ ++ unsigned int i; /* counter */ ++ dword X[16]; /* message words */ ++ ++ memset(X, 0, 16*sizeof(dword)); ++ ++ /* put bytes from strptr into X */ ++ for (i=0; i<(lswlen&63); i++) { ++ /* byte i goes into word X[i div 4] at pos. 8*(i mod 4) */ ++ X[i>>2] ^= (dword) *strptr++ << (8 * (i&3)); ++ } ++ ++ /* append "1" bit to the message. Be careful : ++ message = "" -> "10000000" = 128 */ ++ X[(lswlen>>2)&15] ^= (dword)1 << (8*(lswlen&3)+7); ++ ++ if ((lswlen & 63) > 55) { ++ /* length goes to next block */ ++ compress(MDbuf, X); ++ memset(X, 0, 16*sizeof(dword)); ++ } ++ ++ /* append length in bits*/ ++ X[14] = lswlen << 3; ++ X[15] = (lswlen >> 29) | (mswlen << 3); ++ compress(MDbuf, X); ++ ++ return; ++} ++ ++void MDcalc(byte *MD,byte *sp,dword sl) ++{ dword X[16]; ++ dword MDbuf[5]; ++ int i,j; ++ ++ MDinit(MDbuf); ++ ++ while (sl >= 64) ++ { ++ memset(X,0,16*sizeof(dword)); ++ ++ for (i=0; i<64; i++) ++ X[i>>2] |= ((dword)(*sp++)) << (8 * (i&3)); ++ ++ sl-=64; ++ compress(MDbuf,X); ++ ++ }; ++ MDfinish(MDbuf,sp,sl,0); ++ ++ for (i=0;i<5;i++) ++ for (j=0;j<4;j++) ++ *MD++=(byte)((MDbuf[i]>>(j*8))&0xFF); ++} ++ ++/************************ end of file rmd160.c **********************/ ++ +diff -uNr util-linux-2.10m/mount/rmd160.h util-linux-2.10m.int/mount/rmd160.h +--- util-linux-2.10m/mount/rmd160.h Thu Jan 1 01:00:00 1970 ++++ util-linux-2.10m.int/mount/rmd160.h Mon May 22 20:35:44 2000 +@@ -0,0 +1,58 @@ ++/********************************************************************\ ++ * ++ * FILE: rmd160.h ++ * ++ * CONTENTS: Header file for a sample C-implementation of the ++ * RIPEMD-160 hash-function. ++ * TARGET: any computer with an ANSI C compiler ++ * ++ * AUTHOR: Antoon Bosselaers, ESAT-COSIC ++ * DATE: 1 March 1996 ++ * VERSION: 1.0 ++ * ++ * Copyright (c) Katholieke Universiteit Leuven ++ * 1996, All Rights Reserved ++ * ++\********************************************************************/ ++ ++#ifndef RMD160H /* make sure this file is read only once */ ++#define RMD160H ++ ++/********************************************************************/ ++ ++/* typedef 8 and 32 bit types, resp. */ ++/* adapt these, if necessary, ++ for your operating system and compiler */ ++ ++typedef unsigned char byte; ++typedef unsigned long dword; ++ ++/********************************************************************/ ++ ++/* function prototypes */ ++ ++void MDinit(dword *MDbuf); ++/* ++ * initializes MDbuffer to "magic constants" ++ */ ++ ++void compress(dword *MDbuf, dword *X); ++/* ++ * the compression function. ++ * transforms MDbuf using message bytes X[0] through X[15] ++ */ ++ ++void MDfinish(dword *MDbuf, byte *strptr, dword lswlen, dword mswlen); ++/* ++ * puts bytes from strptr into X and pad out; appends length ++ * and finally, compresses the last block(s) ++ * note: length in bits == 8 * (lswlen + 2^32 mswlen). ++ * note: there are (lswlen mod 64) bytes left in strptr. ++ */ ++ ++void MDcalc(byte *MDbuf,byte *sp,dword sl); ++ ++#endif /* RMD160H */ ++ ++/*********************** end of file rmd160.h ***********************/ ++ diff -Nru linux-2.4.0-test9-plain/MAINTAINERS linux-2.4.0-test9-int/MAINTAINERS --- linux-2.4.0-test9-plain/MAINTAINERS Mon Oct 2 04:46:22 2000 +++ linux-2.4.0-test9-int/MAINTAINERS Sun Oct 15 12:20:50 2000 @@ -274,6 +274,12 @@ M: jam@acm.org S: Maintained +CRYPTO API +P: Alexander Kjeldaas +M: astor@fast.no +W: http://www.kerneli.org/ +S: Maintained + CYBERPRO FB DRIVER P: Russell King M: linux@arm.linux.org.uk diff -Nru linux-2.4.0-test9-plain/Makefile linux-2.4.0-test9-int/Makefile --- linux-2.4.0-test9-plain/Makefile Mon Oct 2 23:22:59 2000 +++ linux-2.4.0-test9-int/Makefile Sun Oct 15 12:49:55 2000 @@ -15,7 +15,7 @@ HPATH = $(TOPDIR)/include FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net -HOSTCC = gcc +HOSTCC = kgcc HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer CROSS_COMPILE = @@ -26,7 +26,7 @@ AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld -CC = $(CROSS_COMPILE)gcc +CC = $(CROSS_COMPILE)kgcc CPP = $(CC) -E AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm @@ -120,13 +120,14 @@ CORE_FILES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o NETWORKS =net/network.o DRIVERS =drivers/block/block.o \ + crypto/crypto.o \ drivers/char/char.o \ drivers/misc/misc.o \ drivers/net/net.o \ drivers/media/media.o \ drivers/parport/parport.a LIBS =$(TOPDIR)/lib/lib.a -SUBDIRS =kernel drivers mm fs net ipc lib +SUBDIRS =kernel drivers mm fs net ipc lib crypto DRIVERS-n := DRIVERS-y := diff -Nru linux-2.4.0-test9-plain/arch/alpha/config.in linux-2.4.0-test9-int/arch/alpha/config.in --- linux-2.4.0-test9-plain/arch/alpha/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/alpha/config.in Sun Oct 15 12:20:50 2000 @@ -245,6 +245,8 @@ source net/Config.in fi +source crypto/Config.in + mainmenu_option next_comment comment 'ATA/IDE/MFM/RLL support' diff -Nru linux-2.4.0-test9-plain/arch/arm/config.in linux-2.4.0-test9-int/arch/arm/config.in --- linux-2.4.0-test9-plain/arch/arm/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/arm/config.in Sun Oct 15 12:20:50 2000 @@ -324,6 +324,8 @@ source net/irda/Config.in fi +source crypto/Config.in + mainmenu_option next_comment comment 'ATA/IDE/MFM/RLL support' diff -Nru linux-2.4.0-test9-plain/arch/i386/config.in linux-2.4.0-test9-int/arch/i386/config.in --- linux-2.4.0-test9-plain/arch/i386/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/i386/config.in Sun Oct 15 12:20:50 2000 @@ -255,6 +255,8 @@ source net/Config.in fi +source crypto/Config.in + source drivers/telephony/Config.in mainmenu_option next_comment diff -Nru linux-2.4.0-test9-plain/arch/ia64/config.in linux-2.4.0-test9-int/arch/ia64/config.in --- linux-2.4.0-test9-plain/arch/ia64/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/ia64/config.in Sun Oct 15 12:20:50 2000 @@ -101,6 +101,8 @@ source drivers/i2o/Config.in source drivers/md/Config.in +source crypto/Config.in + mainmenu_option next_comment comment 'ATA/IDE/MFM/RLL support' diff -Nru linux-2.4.0-test9-plain/arch/m68k/config.in linux-2.4.0-test9-int/arch/m68k/config.in --- linux-2.4.0-test9-plain/arch/m68k/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/m68k/config.in Sun Oct 15 12:20:50 2000 @@ -155,6 +155,8 @@ source net/Config.in fi +source crypto/Config.in + mainmenu_option next_comment comment 'ATA/IDE/MFM/RLL support' diff -Nru linux-2.4.0-test9-plain/arch/mips/config.in linux-2.4.0-test9-int/arch/mips/config.in --- linux-2.4.0-test9-plain/arch/mips/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/mips/config.in Sun Oct 15 12:24:54 2000 @@ -195,6 +195,8 @@ source net/Config.in fi +source crypto/Config.in + if [ "$CONFIG_DECSTATION" != "y" -a \ "$CONFIG_SGI_IP22" != "y" ]; then source drivers/telephony/Config.in diff -Nru linux-2.4.0-test9-plain/arch/mips64/config.in linux-2.4.0-test9-int/arch/mips64/config.in --- linux-2.4.0-test9-plain/arch/mips64/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/mips64/config.in Sun Oct 15 12:20:50 2000 @@ -135,6 +135,8 @@ source net/Config.in fi +source crypto/Config.in + source drivers/telephony/Config.in mainmenu_option next_comment diff -Nru linux-2.4.0-test9-plain/arch/ppc/config.in linux-2.4.0-test9-int/arch/ppc/config.in --- linux-2.4.0-test9-plain/arch/ppc/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/ppc/config.in Sun Oct 15 12:20:50 2000 @@ -188,6 +188,8 @@ source net/Config.in fi +source crypto/Config.in + mainmenu_option next_comment comment 'ATA/IDE/MFM/RLL support' diff -Nru linux-2.4.0-test9-plain/arch/s390/config.in linux-2.4.0-test9-int/arch/s390/config.in --- linux-2.4.0-test9-plain/arch/s390/config.in Tue Aug 22 20:29:02 2000 +++ linux-2.4.0-test9-int/arch/s390/config.in Sun Oct 15 12:20:50 2000 @@ -55,6 +55,8 @@ source net/Config.in fi +source crypto/Config.in + source fs/Config.in # source drivers/char/Config.in diff -Nru linux-2.4.0-test9-plain/arch/sh/config.in linux-2.4.0-test9-int/arch/sh/config.in --- linux-2.4.0-test9-plain/arch/sh/config.in Tue Sep 19 19:57:30 2000 +++ linux-2.4.0-test9-int/arch/sh/config.in Sun Oct 15 12:20:50 2000 @@ -129,6 +129,8 @@ source net/Config.in fi +source crypto/Config.in + mainmenu_option next_comment comment 'ATA/IDE/MFM/RLL support' diff -Nru linux-2.4.0-test9-plain/arch/sparc/config.in linux-2.4.0-test9-int/arch/sparc/config.in --- linux-2.4.0-test9-plain/arch/sparc/config.in Tue Sep 19 19:59:52 2000 +++ linux-2.4.0-test9-int/arch/sparc/config.in Sun Oct 15 12:20:50 2000 @@ -108,6 +108,8 @@ source net/Config.in fi +source crypto/Config.in + # Don't frighten a common SBus user if [ "$CONFIG_PCI" = "y" ]; then diff -Nru linux-2.4.0-test9-plain/arch/sparc64/config.in linux-2.4.0-test9-int/arch/sparc64/config.in --- linux-2.4.0-test9-plain/arch/sparc64/config.in Tue Sep 19 19:59:52 2000 +++ linux-2.4.0-test9-int/arch/sparc64/config.in Sun Oct 15 12:20:50 2000 @@ -108,6 +108,8 @@ source net/Config.in fi +source crypto/Config.in + mainmenu_option next_comment comment 'ATA/IDE/MFM/RLL support' diff -Nru linux-2.4.0-test9-plain/crypto/2fish_tables.h linux-2.4.0-test9-int/crypto/2fish_tables.h --- linux-2.4.0-test9-plain/crypto/2fish_tables.h Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/crypto/2fish_tables.h Sun Oct 15 14:40:16 2000 @@ -0,0 +1,427 @@ +/* The large precomputed tables for the Twofish cipher (twofish.c) + * Taken from the same source as twofish.c + * Marc Mutz + */ + +/* These two tables are the q0 and q1 permutations, exactly as described in + * the Twofish paper. */ + +#ifndef _2FISH_TABLES_H +#define _2FISH_TABLES_H + +#include + +static const u8 q0[256] = { + 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78, + 0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, + 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30, + 0x84, 0x54, 0xDF, 0x23, 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82, + 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, 0xA6, 0xEB, 0xA5, 0xBE, + 0x16, 0x0C, 0xE3, 0x61, 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B, + 0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, 0xE1, 0xE6, 0xBD, 0x45, + 0xE2, 0xF4, 0xB6, 0x66, 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7, + 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, 0xEA, 0x77, 0x39, 0xAF, + 0x33, 0xC9, 0x62, 0x71, 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8, + 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, 0xA1, 0x1D, 0xAA, 0xED, + 0x06, 0x70, 0xB2, 0xD2, 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90, + 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, 0x9E, 0x9C, 0x52, 0x1B, + 0x5F, 0x93, 0x0A, 0xEF, 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B, + 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, 0x2A, 0xCE, 0xCB, 0x2F, + 0xFC, 0x97, 0x05, 0x7A, 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A, + 0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, 0xB8, 0xDA, 0xB0, 0x17, + 0x55, 0x1F, 0x8A, 0x7D, 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72, + 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, 0x6E, 0x50, 0xDE, 0x68, + 0x65, 0xBC, 0xDB, 0xF8, 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4, + 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42, + 0x4A, 0x5E, 0xC1, 0xE0 +}; + +static const u8 q1[256] = { + 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B, + 0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, + 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B, + 0x8A, 0x00, 0xBC, 0x9D, 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5, + 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, 0xB2, 0x73, 0x4C, 0x54, + 0x92, 0x74, 0x36, 0x51, 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96, + 0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, 0x13, 0x95, 0x9C, 0xC7, + 0x24, 0x46, 0x3B, 0x70, 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8, + 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, 0x03, 0x6F, 0x08, 0xBF, + 0x40, 0xE7, 0x2B, 0xE2, 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9, + 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, 0x66, 0x94, 0xA1, 0x1D, + 0x3D, 0xF0, 0xDE, 0xB3, 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E, + 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, 0x81, 0x88, 0xEE, 0x21, + 0xC4, 0x1A, 0xEB, 0xD9, 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01, + 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, 0x4F, 0xF2, 0x65, 0x8E, + 0x78, 0x5C, 0x58, 0x19, 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64, + 0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, 0xCE, 0xE9, 0x68, 0x44, + 0xE0, 0x4D, 0x43, 0x69, 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E, + 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, 0x22, 0xC9, 0xC0, 0x9B, + 0x89, 0xD4, 0xED, 0xAB, 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9, + 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56, + 0x55, 0x09, 0xBE, 0x91 +}; + +/* These MDS tables are actually tables of MDS composed with q0 and q1, + * because it is only ever used that way and we can save some time by + * precomputing. Of course the main saving comes from precomputing the + * GF(2^8) multiplication involved in the MDS matrix multiply; by looking + * things up in these tables we reduce the matrix multiply to four lookups + * and three XORs. Semi-formally, the definition of these tables is: + * mds[0][i] = MDS (q1[i] 0 0 0)^T mds[1][i] = MDS (0 q0[i] 0 0)^T + * mds[2][i] = MDS (0 0 q1[i] 0)^T mds[3][i] = MDS (0 0 0 q0[i])^T + * where ^T means "transpose", the matrix multiply is performed in GF(2^8) + * represented as GF(2)[x]/v(x) where v(x)=x^8+x^6+x^5+x^3+1 as described + * by Schneier et al, and I'm casually glossing over the byte/word + * conversion issues. */ + +static const u32 mds[4][256] = { + {0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, + 0xE2E22BFB, 0x9E9EFAC8, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, + 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0x3C3C57D6, 0x93938A32, + 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1, + 0x24243C30, 0x5151E20F, 0xBABAC6F8, 0x4A4AF31B, 0xBFBF4887, 0x0D0D70FA, + 0xB0B0B306, 0x7575DE3F, 0xD2D2FD5E, 0x7D7D20BA, 0x666631AE, 0x3A3AA35B, + 0x59591C8A, 0x00000000, 0xCDCD93BC, 0x1A1AE09D, 0xAEAE2C6D, 0x7F7FABC1, + 0x2B2BC7B1, 0xBEBEB90E, 0xE0E0A080, 0x8A8A105D, 0x3B3B52D2, 0x6464BAD5, + 0xD8D888A0, 0xE7E7A584, 0x5F5FE807, 0x1B1B1114, 0x2C2CC2B5, 0xFCFCB490, + 0x3131272C, 0x808065A3, 0x73732AB2, 0x0C0C8173, 0x79795F4C, 0x6B6B4154, + 0x4B4B0292, 0x53536974, 0x94948F36, 0x83831F51, 0x2A2A3638, 0xC4C49CB0, + 0x2222C8BD, 0xD5D5F85A, 0xBDBDC3FC, 0x48487860, 0xFFFFCE62, 0x4C4C0796, + 0x4141776C, 0xC7C7E642, 0xEBEB24F7, 0x1C1C1410, 0x5D5D637C, 0x36362228, + 0x6767C027, 0xE9E9AF8C, 0x4444F913, 0x1414EA95, 0xF5F5BB9C, 0xCFCF18C7, + 0x3F3F2D24, 0xC0C0E346, 0x7272DB3B, 0x54546C70, 0x29294CCA, 0xF0F035E3, + 0x0808FE85, 0xC6C617CB, 0xF3F34F11, 0x8C8CE4D0, 0xA4A45993, 0xCACA96B8, + 0x68683BA6, 0xB8B84D83, 0x38382820, 0xE5E52EFF, 0xADAD569F, 0x0B0B8477, + 0xC8C81DC3, 0x9999FFCC, 0x5858ED03, 0x19199A6F, 0x0E0E0A08, 0x95957EBF, + 0x70705040, 0xF7F730E7, 0x6E6ECF2B, 0x1F1F6EE2, 0xB5B53D79, 0x09090F0C, + 0x616134AA, 0x57571682, 0x9F9F0B41, 0x9D9D803A, 0x111164EA, 0x2525CDB9, + 0xAFAFDDE4, 0x4545089A, 0xDFDF8DA4, 0xA3A35C97, 0xEAEAD57E, 0x353558DA, + 0xEDEDD07A, 0x4343FC17, 0xF8F8CB66, 0xFBFBB194, 0x3737D3A1, 0xFAFA401D, + 0xC2C2683D, 0xB4B4CCF0, 0x32325DDE, 0x9C9C71B3, 0x5656E70B, 0xE3E3DA72, + 0x878760A7, 0x15151B1C, 0xF9F93AEF, 0x6363BFD1, 0x3434A953, 0x9A9A853E, + 0xB1B1428F, 0x7C7CD133, 0x88889B26, 0x3D3DA65F, 0xA1A1D7EC, 0xE4E4DF76, + 0x8181942A, 0x91910149, 0x0F0FFB81, 0xEEEEAA88, 0x161661EE, 0xD7D77321, + 0x9797F5C4, 0xA5A5A81A, 0xFEFE3FEB, 0x6D6DB5D9, 0x7878AEC5, 0xC5C56D39, + 0x1D1DE599, 0x7676A4CD, 0x3E3EDCAD, 0xCBCB6731, 0xB6B6478B, 0xEFEF5B01, + 0x12121E18, 0x6060C523, 0x6A6AB0DD, 0x4D4DF61F, 0xCECEE94E, 0xDEDE7C2D, + 0x55559DF9, 0x7E7E5A48, 0x2121B24F, 0x03037AF2, 0xA0A02665, 0x5E5E198E, + 0x5A5A6678, 0x65654B5C, 0x62624E58, 0xFDFD4519, 0x0606F48D, 0x404086E5, + 0xF2F2BE98, 0x3333AC57, 0x17179067, 0x05058E7F, 0xE8E85E05, 0x4F4F7D64, + 0x89896AAF, 0x10109563, 0x74742FB6, 0x0A0A75FE, 0x5C5C92F5, 0x9B9B74B7, + 0x2D2D333C, 0x3030D6A5, 0x2E2E49CE, 0x494989E9, 0x46467268, 0x77775544, + 0xA8A8D8E0, 0x9696044D, 0x2828BD43, 0xA9A92969, 0xD9D97929, 0x8686912E, + 0xD1D187AC, 0xF4F44A15, 0x8D8D1559, 0xD6D682A8, 0xB9B9BC0A, 0x42420D9E, + 0xF6F6C16E, 0x2F2FB847, 0xDDDD06DF, 0x23233934, 0xCCCC6235, 0xF1F1C46A, + 0xC1C112CF, 0x8585EBDC, 0x8F8F9E22, 0x7171A1C9, 0x9090F0C0, 0xAAAA539B, + 0x0101F189, 0x8B8BE1D4, 0x4E4E8CED, 0x8E8E6FAB, 0xABABA212, 0x6F6F3EA2, + 0xE6E6540D, 0xDBDBF252, 0x92927BBB, 0xB7B7B602, 0x6969CA2F, 0x3939D9A9, + 0xD3D30CD7, 0xA7A72361, 0xA2A2AD1E, 0xC3C399B4, 0x6C6C4450, 0x07070504, + 0x04047FF6, 0x272746C2, 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756, + 0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91}, + + {0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, + 0xA3658080, 0x76DFE4E4, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, + 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x0D54E6E6, 0xC6432020, + 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141, + 0x43BD2828, 0x7532BCBC, 0x37D47B7B, 0x269B8888, 0xFA700D0D, 0x13F94444, + 0x94B1FBFB, 0x485A7E7E, 0xF27A0303, 0xD0E48C8C, 0x8B47B6B6, 0x303C2424, + 0x84A5E7E7, 0x54416B6B, 0xDF06DDDD, 0x23C56060, 0x1945FDFD, 0x5BA33A3A, + 0x3D68C2C2, 0x59158D8D, 0xF321ECEC, 0xAE316666, 0xA23E6F6F, 0x82165757, + 0x63951010, 0x015BEFEF, 0x834DB8B8, 0x2E918686, 0xD9B56D6D, 0x511F8383, + 0x9B53AAAA, 0x7C635D5D, 0xA63B6868, 0xEB3FFEFE, 0xA5D63030, 0xBE257A7A, + 0x16A7ACAC, 0x0C0F0909, 0xE335F0F0, 0x6123A7A7, 0xC0F09090, 0x8CAFE9E9, + 0x3A809D9D, 0xF5925C5C, 0x73810C0C, 0x2C273131, 0x2576D0D0, 0x0BE75656, + 0xBB7B9292, 0x4EE9CECE, 0x89F10101, 0x6B9F1E1E, 0x53A93434, 0x6AC4F1F1, + 0xB499C3C3, 0xF1975B5B, 0xE1834747, 0xE66B1818, 0xBDC82222, 0x450E9898, + 0xE26E1F1F, 0xF4C9B3B3, 0xB62F7474, 0x66CBF8F8, 0xCCFF9999, 0x95EA1414, + 0x03ED5858, 0x56F7DCDC, 0xD4E18B8B, 0x1C1B1515, 0x1EADA2A2, 0xD70CD3D3, + 0xFB2BE2E2, 0xC31DC8C8, 0x8E195E5E, 0xB5C22C2C, 0xE9894949, 0xCF12C1C1, + 0xBF7E9595, 0xBA207D7D, 0xEA641111, 0x77840B0B, 0x396DC5C5, 0xAF6A8989, + 0x33D17C7C, 0xC9A17171, 0x62CEFFFF, 0x7137BBBB, 0x81FB0F0F, 0x793DB5B5, + 0x0951E1E1, 0xADDC3E3E, 0x242D3F3F, 0xCDA47676, 0xF99D5555, 0xD8EE8282, + 0xE5864040, 0xC5AE7878, 0xB9CD2525, 0x4D049696, 0x44557777, 0x080A0E0E, + 0x86135050, 0xE730F7F7, 0xA1D33737, 0x1D40FAFA, 0xAA346161, 0xED8C4E4E, + 0x06B3B0B0, 0x706C5454, 0xB22A7373, 0xD2523B3B, 0x410B9F9F, 0x7B8B0202, + 0xA088D8D8, 0x114FF3F3, 0x3167CBCB, 0xC2462727, 0x27C06767, 0x90B4FCFC, + 0x20283838, 0xF67F0404, 0x60784848, 0xFF2EE5E5, 0x96074C4C, 0x5C4B6565, + 0xB1C72B2B, 0xAB6F8E8E, 0x9E0D4242, 0x9CBBF5F5, 0x52F2DBDB, 0x1BF34A4A, + 0x5FA63D3D, 0x9359A4A4, 0x0ABCB9B9, 0xEF3AF9F9, 0x91EF1313, 0x85FE0808, + 0x49019191, 0xEE611616, 0x2D7CDEDE, 0x4FB22121, 0x8F42B1B1, 0x3BDB7272, + 0x47B82F2F, 0x8748BFBF, 0x6D2CAEAE, 0x46E3C0C0, 0xD6573C3C, 0x3E859A9A, + 0x6929A9A9, 0x647D4F4F, 0x2A948181, 0xCE492E2E, 0xCB17C6C6, 0x2FCA6969, + 0xFCC3BDBD, 0x975CA3A3, 0x055EE8E8, 0x7AD0EDED, 0xAC87D1D1, 0x7F8E0505, + 0xD5BA6464, 0x1AA8A5A5, 0x4BB72626, 0x0EB9BEBE, 0xA7608787, 0x5AF8D5D5, + 0x28223636, 0x14111B1B, 0x3FDE7575, 0x2979D9D9, 0x88AAEEEE, 0x3C332D2D, + 0x4C5F7979, 0x02B6B7B7, 0xB896CACA, 0xDA583535, 0xB09CC4C4, 0x17FC4343, + 0x551A8484, 0x1FF64D4D, 0x8A1C5959, 0x7D38B2B2, 0x57AC3333, 0xC718CFCF, + 0x8DF40606, 0x74695353, 0xB7749B9B, 0xC4F59797, 0x9F56ADAD, 0x72DAE3E3, + 0x7ED5EAEA, 0x154AF4F4, 0x229E8F8F, 0x12A2ABAB, 0x584E6262, 0x07E85F5F, + 0x99E51D1D, 0x34392323, 0x6EC1F6F6, 0x50446C6C, 0xDE5D3232, 0x68724646, + 0x6526A0A0, 0xBC93CDCD, 0xDB03DADA, 0xF8C6BABA, 0xC8FA9E9E, 0xA882D6D6, + 0x2BCF6E6E, 0x40507070, 0xDCEB8585, 0xFE750A0A, 0x328A9393, 0xA48DDFDF, + 0xCA4C2929, 0x10141C1C, 0x2173D7D7, 0xF0CCB4B4, 0xD309D4D4, 0x5D108A8A, + 0x0FE25151, 0x00000000, 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7, + 0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8}, + + {0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, + 0xE2FBE22B, 0x9EC89EFA, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, + 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0x3CD63C57, 0x9332938A, + 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783, + 0x2430243C, 0x510F51E2, 0xBAF8BAC6, 0x4A1B4AF3, 0xBF87BF48, 0x0DFA0D70, + 0xB006B0B3, 0x753F75DE, 0xD25ED2FD, 0x7DBA7D20, 0x66AE6631, 0x3A5B3AA3, + 0x598A591C, 0x00000000, 0xCDBCCD93, 0x1A9D1AE0, 0xAE6DAE2C, 0x7FC17FAB, + 0x2BB12BC7, 0xBE0EBEB9, 0xE080E0A0, 0x8A5D8A10, 0x3BD23B52, 0x64D564BA, + 0xD8A0D888, 0xE784E7A5, 0x5F075FE8, 0x1B141B11, 0x2CB52CC2, 0xFC90FCB4, + 0x312C3127, 0x80A38065, 0x73B2732A, 0x0C730C81, 0x794C795F, 0x6B546B41, + 0x4B924B02, 0x53745369, 0x9436948F, 0x8351831F, 0x2A382A36, 0xC4B0C49C, + 0x22BD22C8, 0xD55AD5F8, 0xBDFCBDC3, 0x48604878, 0xFF62FFCE, 0x4C964C07, + 0x416C4177, 0xC742C7E6, 0xEBF7EB24, 0x1C101C14, 0x5D7C5D63, 0x36283622, + 0x672767C0, 0xE98CE9AF, 0x441344F9, 0x149514EA, 0xF59CF5BB, 0xCFC7CF18, + 0x3F243F2D, 0xC046C0E3, 0x723B72DB, 0x5470546C, 0x29CA294C, 0xF0E3F035, + 0x088508FE, 0xC6CBC617, 0xF311F34F, 0x8CD08CE4, 0xA493A459, 0xCAB8CA96, + 0x68A6683B, 0xB883B84D, 0x38203828, 0xE5FFE52E, 0xAD9FAD56, 0x0B770B84, + 0xC8C3C81D, 0x99CC99FF, 0x580358ED, 0x196F199A, 0x0E080E0A, 0x95BF957E, + 0x70407050, 0xF7E7F730, 0x6E2B6ECF, 0x1FE21F6E, 0xB579B53D, 0x090C090F, + 0x61AA6134, 0x57825716, 0x9F419F0B, 0x9D3A9D80, 0x11EA1164, 0x25B925CD, + 0xAFE4AFDD, 0x459A4508, 0xDFA4DF8D, 0xA397A35C, 0xEA7EEAD5, 0x35DA3558, + 0xED7AEDD0, 0x431743FC, 0xF866F8CB, 0xFB94FBB1, 0x37A137D3, 0xFA1DFA40, + 0xC23DC268, 0xB4F0B4CC, 0x32DE325D, 0x9CB39C71, 0x560B56E7, 0xE372E3DA, + 0x87A78760, 0x151C151B, 0xF9EFF93A, 0x63D163BF, 0x345334A9, 0x9A3E9A85, + 0xB18FB142, 0x7C337CD1, 0x8826889B, 0x3D5F3DA6, 0xA1ECA1D7, 0xE476E4DF, + 0x812A8194, 0x91499101, 0x0F810FFB, 0xEE88EEAA, 0x16EE1661, 0xD721D773, + 0x97C497F5, 0xA51AA5A8, 0xFEEBFE3F, 0x6DD96DB5, 0x78C578AE, 0xC539C56D, + 0x1D991DE5, 0x76CD76A4, 0x3EAD3EDC, 0xCB31CB67, 0xB68BB647, 0xEF01EF5B, + 0x1218121E, 0x602360C5, 0x6ADD6AB0, 0x4D1F4DF6, 0xCE4ECEE9, 0xDE2DDE7C, + 0x55F9559D, 0x7E487E5A, 0x214F21B2, 0x03F2037A, 0xA065A026, 0x5E8E5E19, + 0x5A785A66, 0x655C654B, 0x6258624E, 0xFD19FD45, 0x068D06F4, 0x40E54086, + 0xF298F2BE, 0x335733AC, 0x17671790, 0x057F058E, 0xE805E85E, 0x4F644F7D, + 0x89AF896A, 0x10631095, 0x74B6742F, 0x0AFE0A75, 0x5CF55C92, 0x9BB79B74, + 0x2D3C2D33, 0x30A530D6, 0x2ECE2E49, 0x49E94989, 0x46684672, 0x77447755, + 0xA8E0A8D8, 0x964D9604, 0x284328BD, 0xA969A929, 0xD929D979, 0x862E8691, + 0xD1ACD187, 0xF415F44A, 0x8D598D15, 0xD6A8D682, 0xB90AB9BC, 0x429E420D, + 0xF66EF6C1, 0x2F472FB8, 0xDDDFDD06, 0x23342339, 0xCC35CC62, 0xF16AF1C4, + 0xC1CFC112, 0x85DC85EB, 0x8F228F9E, 0x71C971A1, 0x90C090F0, 0xAA9BAA53, + 0x018901F1, 0x8BD48BE1, 0x4EED4E8C, 0x8EAB8E6F, 0xAB12ABA2, 0x6FA26F3E, + 0xE60DE654, 0xDB52DBF2, 0x92BB927B, 0xB702B7B6, 0x692F69CA, 0x39A939D9, + 0xD3D7D30C, 0xA761A723, 0xA21EA2AD, 0xC3B4C399, 0x6C506C44, 0x07040705, + 0x04F6047F, 0x27C22746, 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7, + 0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF}, + + {0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, + 0x6580A365, 0xDFE476DF, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, + 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x54E60D54, 0x4320C643, + 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77, + 0xBD2843BD, 0x32BC7532, 0xD47B37D4, 0x9B88269B, 0x700DFA70, 0xF94413F9, + 0xB1FB94B1, 0x5A7E485A, 0x7A03F27A, 0xE48CD0E4, 0x47B68B47, 0x3C24303C, + 0xA5E784A5, 0x416B5441, 0x06DDDF06, 0xC56023C5, 0x45FD1945, 0xA33A5BA3, + 0x68C23D68, 0x158D5915, 0x21ECF321, 0x3166AE31, 0x3E6FA23E, 0x16578216, + 0x95106395, 0x5BEF015B, 0x4DB8834D, 0x91862E91, 0xB56DD9B5, 0x1F83511F, + 0x53AA9B53, 0x635D7C63, 0x3B68A63B, 0x3FFEEB3F, 0xD630A5D6, 0x257ABE25, + 0xA7AC16A7, 0x0F090C0F, 0x35F0E335, 0x23A76123, 0xF090C0F0, 0xAFE98CAF, + 0x809D3A80, 0x925CF592, 0x810C7381, 0x27312C27, 0x76D02576, 0xE7560BE7, + 0x7B92BB7B, 0xE9CE4EE9, 0xF10189F1, 0x9F1E6B9F, 0xA93453A9, 0xC4F16AC4, + 0x99C3B499, 0x975BF197, 0x8347E183, 0x6B18E66B, 0xC822BDC8, 0x0E98450E, + 0x6E1FE26E, 0xC9B3F4C9, 0x2F74B62F, 0xCBF866CB, 0xFF99CCFF, 0xEA1495EA, + 0xED5803ED, 0xF7DC56F7, 0xE18BD4E1, 0x1B151C1B, 0xADA21EAD, 0x0CD3D70C, + 0x2BE2FB2B, 0x1DC8C31D, 0x195E8E19, 0xC22CB5C2, 0x8949E989, 0x12C1CF12, + 0x7E95BF7E, 0x207DBA20, 0x6411EA64, 0x840B7784, 0x6DC5396D, 0x6A89AF6A, + 0xD17C33D1, 0xA171C9A1, 0xCEFF62CE, 0x37BB7137, 0xFB0F81FB, 0x3DB5793D, + 0x51E10951, 0xDC3EADDC, 0x2D3F242D, 0xA476CDA4, 0x9D55F99D, 0xEE82D8EE, + 0x8640E586, 0xAE78C5AE, 0xCD25B9CD, 0x04964D04, 0x55774455, 0x0A0E080A, + 0x13508613, 0x30F7E730, 0xD337A1D3, 0x40FA1D40, 0x3461AA34, 0x8C4EED8C, + 0xB3B006B3, 0x6C54706C, 0x2A73B22A, 0x523BD252, 0x0B9F410B, 0x8B027B8B, + 0x88D8A088, 0x4FF3114F, 0x67CB3167, 0x4627C246, 0xC06727C0, 0xB4FC90B4, + 0x28382028, 0x7F04F67F, 0x78486078, 0x2EE5FF2E, 0x074C9607, 0x4B655C4B, + 0xC72BB1C7, 0x6F8EAB6F, 0x0D429E0D, 0xBBF59CBB, 0xF2DB52F2, 0xF34A1BF3, + 0xA63D5FA6, 0x59A49359, 0xBCB90ABC, 0x3AF9EF3A, 0xEF1391EF, 0xFE0885FE, + 0x01914901, 0x6116EE61, 0x7CDE2D7C, 0xB2214FB2, 0x42B18F42, 0xDB723BDB, + 0xB82F47B8, 0x48BF8748, 0x2CAE6D2C, 0xE3C046E3, 0x573CD657, 0x859A3E85, + 0x29A96929, 0x7D4F647D, 0x94812A94, 0x492ECE49, 0x17C6CB17, 0xCA692FCA, + 0xC3BDFCC3, 0x5CA3975C, 0x5EE8055E, 0xD0ED7AD0, 0x87D1AC87, 0x8E057F8E, + 0xBA64D5BA, 0xA8A51AA8, 0xB7264BB7, 0xB9BE0EB9, 0x6087A760, 0xF8D55AF8, + 0x22362822, 0x111B1411, 0xDE753FDE, 0x79D92979, 0xAAEE88AA, 0x332D3C33, + 0x5F794C5F, 0xB6B702B6, 0x96CAB896, 0x5835DA58, 0x9CC4B09C, 0xFC4317FC, + 0x1A84551A, 0xF64D1FF6, 0x1C598A1C, 0x38B27D38, 0xAC3357AC, 0x18CFC718, + 0xF4068DF4, 0x69537469, 0x749BB774, 0xF597C4F5, 0x56AD9F56, 0xDAE372DA, + 0xD5EA7ED5, 0x4AF4154A, 0x9E8F229E, 0xA2AB12A2, 0x4E62584E, 0xE85F07E8, + 0xE51D99E5, 0x39233439, 0xC1F66EC1, 0x446C5044, 0x5D32DE5D, 0x72466872, + 0x26A06526, 0x93CDBC93, 0x03DADB03, 0xC6BAF8C6, 0xFA9EC8FA, 0x82D6A882, + 0xCF6E2BCF, 0x50704050, 0xEB85DCEB, 0x750AFE75, 0x8A93328A, 0x8DDFA48D, + 0x4C29CA4C, 0x141C1014, 0x73D72173, 0xCCB4F0CC, 0x09D4D309, 0x108A5D10, + 0xE2510FE2, 0x00000000, 0x9A196F9A, 0xE01A9DE0, 0x8F94368F, 0xE6C742E6, + 0xECC94AEC, 0xFDD25EFD, 0xAB7FC1AB, 0xD8A8E0D8} +}; + +/* The exp_to_poly and poly_to_exp tables are used to perform efficient + * operations in GF(2^8) represented as GF(2)[x]/w(x) where + * w(x)=x^8+x^6+x^3+x^2+1. We care about doing that because it's part of the + * definition of the RS matrix in the key schedule. Elements of that field + * are polynomials of degree not greater than 7 and all coefficients 0 or 1, + * which can be represented naturally by bytes (just substitute x=2). In that + * form, GF(2^8) addition is the same as bitwise XOR, but GF(2^8) + * multiplication is inefficient without hardware support. To multiply + * faster, I make use of the fact x is a generator for the nonzero elements, + * so that every element p of GF(2)[x]/w(x) is either 0 or equal to (x)^n for + * some n in 0..254. Note that that caret is exponentiation in GF(2^8), + * *not* polynomial notation. So if I want to compute pq where p and q are + * in GF(2^8), I can just say: + * 1. if p=0 or q=0 then pq=0 + * 2. otherwise, find m and n such that p=x^m and q=x^n + * 3. pq=(x^m)(x^n)=x^(m+n), so add m and n and find pq + * The translations in steps 2 and 3 are looked up in the tables + * poly_to_exp (for step 2) and exp_to_poly (for step 3). To see this + * in action, look at the CALC_S macro. As additional wrinkles, note that + * one of my operands is always a constant, so the poly_to_exp lookup on it + * is done in advance; I included the original values in the comments so + * readers can have some chance of recognizing that this *is* the RS matrix + * from the Twofish paper. I've only included the table entries I actually + * need; I never do a lookup on a variable input of zero and the biggest + * exponents I'll ever see are 254 (variable) and 237 (constant), so they'll + * never sum to more than 491. I'm repeating part of the exp_to_poly table + * so that I don't have to do mod-255 reduction in the exponent arithmetic. + * Since I know my constant operands are never zero, I only have to worry + * about zero values in the variable operand, and I do it with a simple + * conditional branch. I know conditionals are expensive, but I couldn't + * see a non-horrible way of avoiding them, and I did manage to group the + * statements so that each if covers four group multiplications. */ + +static const u8 poly_to_exp[255] = { + 0x00, 0x01, 0x17, 0x02, 0x2E, 0x18, 0x53, 0x03, 0x6A, 0x2F, 0x93, 0x19, + 0x34, 0x54, 0x45, 0x04, 0x5C, 0x6B, 0xB6, 0x30, 0xA6, 0x94, 0x4B, 0x1A, + 0x8C, 0x35, 0x81, 0x55, 0xAA, 0x46, 0x0D, 0x05, 0x24, 0x5D, 0x87, 0x6C, + 0x9B, 0xB7, 0xC1, 0x31, 0x2B, 0xA7, 0xA3, 0x95, 0x98, 0x4C, 0xCA, 0x1B, + 0xE6, 0x8D, 0x73, 0x36, 0xCD, 0x82, 0x12, 0x56, 0x62, 0xAB, 0xF0, 0x47, + 0x4F, 0x0E, 0xBD, 0x06, 0xD4, 0x25, 0xD2, 0x5E, 0x27, 0x88, 0x66, 0x6D, + 0xD6, 0x9C, 0x79, 0xB8, 0x08, 0xC2, 0xDF, 0x32, 0x68, 0x2C, 0xFD, 0xA8, + 0x8A, 0xA4, 0x5A, 0x96, 0x29, 0x99, 0x22, 0x4D, 0x60, 0xCB, 0xE4, 0x1C, + 0x7B, 0xE7, 0x3B, 0x8E, 0x9E, 0x74, 0xF4, 0x37, 0xD8, 0xCE, 0xF9, 0x83, + 0x6F, 0x13, 0xB2, 0x57, 0xE1, 0x63, 0xDC, 0xAC, 0xC4, 0xF1, 0xAF, 0x48, + 0x0A, 0x50, 0x42, 0x0F, 0xBA, 0xBE, 0xC7, 0x07, 0xDE, 0xD5, 0x78, 0x26, + 0x65, 0xD3, 0xD1, 0x5F, 0xE3, 0x28, 0x21, 0x89, 0x59, 0x67, 0xFC, 0x6E, + 0xB1, 0xD7, 0xF8, 0x9D, 0xF3, 0x7A, 0x3A, 0xB9, 0xC6, 0x09, 0x41, 0xC3, + 0xAE, 0xE0, 0xDB, 0x33, 0x44, 0x69, 0x92, 0x2D, 0x52, 0xFE, 0x16, 0xA9, + 0x0C, 0x8B, 0x80, 0xA5, 0x4A, 0x5B, 0xB5, 0x97, 0xC9, 0x2A, 0xA2, 0x9A, + 0xC0, 0x23, 0x86, 0x4E, 0xBC, 0x61, 0xEF, 0xCC, 0x11, 0xE5, 0x72, 0x1D, + 0x3D, 0x7C, 0xEB, 0xE8, 0xE9, 0x3C, 0xEA, 0x8F, 0x7D, 0x9F, 0xEC, 0x75, + 0x1E, 0xF5, 0x3E, 0x38, 0xF6, 0xD9, 0x3F, 0xCF, 0x76, 0xFA, 0x1F, 0x84, + 0xA0, 0x70, 0xED, 0x14, 0x90, 0xB3, 0x7E, 0x58, 0xFB, 0xE2, 0x20, 0x64, + 0xD0, 0xDD, 0x77, 0xAD, 0xDA, 0xC5, 0x40, 0xF2, 0x39, 0xB0, 0xF7, 0x49, + 0xB4, 0x0B, 0x7F, 0x51, 0x15, 0x43, 0x91, 0x10, 0x71, 0xBB, 0xEE, 0xBF, + 0x85, 0xC8, 0xA1 +}; + +static const u8 exp_to_poly[492] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D, 0x9A, 0x79, 0xF2, + 0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC, 0xF5, 0xA7, 0x03, + 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3, 0x8B, 0x5B, 0xB6, + 0x21, 0x42, 0x84, 0x45, 0x8A, 0x59, 0xB2, 0x29, 0x52, 0xA4, 0x05, 0x0A, + 0x14, 0x28, 0x50, 0xA0, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xED, 0x97, 0x63, + 0xC6, 0xC1, 0xCF, 0xD3, 0xEB, 0x9B, 0x7B, 0xF6, 0xA1, 0x0F, 0x1E, 0x3C, + 0x78, 0xF0, 0xAD, 0x17, 0x2E, 0x5C, 0xB8, 0x3D, 0x7A, 0xF4, 0xA5, 0x07, + 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0x8D, 0x57, 0xAE, 0x11, 0x22, 0x44, 0x88, + 0x5D, 0xBA, 0x39, 0x72, 0xE4, 0x85, 0x47, 0x8E, 0x51, 0xA2, 0x09, 0x12, + 0x24, 0x48, 0x90, 0x6D, 0xDA, 0xF9, 0xBF, 0x33, 0x66, 0xCC, 0xD5, 0xE7, + 0x83, 0x4B, 0x96, 0x61, 0xC2, 0xC9, 0xDF, 0xF3, 0xAB, 0x1B, 0x36, 0x6C, + 0xD8, 0xFD, 0xB7, 0x23, 0x46, 0x8C, 0x55, 0xAA, 0x19, 0x32, 0x64, 0xC8, + 0xDD, 0xF7, 0xA3, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x2D, 0x5A, 0xB4, 0x25, + 0x4A, 0x94, 0x65, 0xCA, 0xD9, 0xFF, 0xB3, 0x2B, 0x56, 0xAC, 0x15, 0x2A, + 0x54, 0xA8, 0x1D, 0x3A, 0x74, 0xE8, 0x9D, 0x77, 0xEE, 0x91, 0x6F, 0xDE, + 0xF1, 0xAF, 0x13, 0x26, 0x4C, 0x98, 0x7D, 0xFA, 0xB9, 0x3F, 0x7E, 0xFC, + 0xB5, 0x27, 0x4E, 0x9C, 0x75, 0xEA, 0x99, 0x7F, 0xFE, 0xB1, 0x2F, 0x5E, + 0xBC, 0x35, 0x6A, 0xD4, 0xE5, 0x87, 0x43, 0x86, 0x41, 0x82, 0x49, 0x92, + 0x69, 0xD2, 0xE9, 0x9F, 0x73, 0xE6, 0x81, 0x4F, 0x9E, 0x71, 0xE2, 0x89, + 0x5F, 0xBE, 0x31, 0x62, 0xC4, 0xC5, 0xC7, 0xC3, 0xCB, 0xDB, 0xFB, 0xBB, + 0x3B, 0x76, 0xEC, 0x95, 0x67, 0xCE, 0xD1, 0xEF, 0x93, 0x6B, 0xD6, 0xE1, + 0x8F, 0x53, 0xA6, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D, + 0x9A, 0x79, 0xF2, 0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC, + 0xF5, 0xA7, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3, + 0x8B, 0x5B, 0xB6, 0x21, 0x42, 0x84, 0x45, 0x8A, 0x59, 0xB2, 0x29, 0x52, + 0xA4, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x0D, 0x1A, 0x34, 0x68, 0xD0, + 0xED, 0x97, 0x63, 0xC6, 0xC1, 0xCF, 0xD3, 0xEB, 0x9B, 0x7B, 0xF6, 0xA1, + 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0xAD, 0x17, 0x2E, 0x5C, 0xB8, 0x3D, 0x7A, + 0xF4, 0xA5, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0x8D, 0x57, 0xAE, 0x11, + 0x22, 0x44, 0x88, 0x5D, 0xBA, 0x39, 0x72, 0xE4, 0x85, 0x47, 0x8E, 0x51, + 0xA2, 0x09, 0x12, 0x24, 0x48, 0x90, 0x6D, 0xDA, 0xF9, 0xBF, 0x33, 0x66, + 0xCC, 0xD5, 0xE7, 0x83, 0x4B, 0x96, 0x61, 0xC2, 0xC9, 0xDF, 0xF3, 0xAB, + 0x1B, 0x36, 0x6C, 0xD8, 0xFD, 0xB7, 0x23, 0x46, 0x8C, 0x55, 0xAA, 0x19, + 0x32, 0x64, 0xC8, 0xDD, 0xF7, 0xA3, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x2D, + 0x5A, 0xB4, 0x25, 0x4A, 0x94, 0x65, 0xCA, 0xD9, 0xFF, 0xB3, 0x2B, 0x56, + 0xAC, 0x15, 0x2A, 0x54, 0xA8, 0x1D, 0x3A, 0x74, 0xE8, 0x9D, 0x77, 0xEE, + 0x91, 0x6F, 0xDE, 0xF1, 0xAF, 0x13, 0x26, 0x4C, 0x98, 0x7D, 0xFA, 0xB9, + 0x3F, 0x7E, 0xFC, 0xB5, 0x27, 0x4E, 0x9C, 0x75, 0xEA, 0x99, 0x7F, 0xFE, + 0xB1, 0x2F, 0x5E, 0xBC, 0x35, 0x6A, 0xD4, 0xE5, 0x87, 0x43, 0x86, 0x41, + 0x82, 0x49, 0x92, 0x69, 0xD2, 0xE9, 0x9F, 0x73, 0xE6, 0x81, 0x4F, 0x9E, + 0x71, 0xE2, 0x89, 0x5F, 0xBE, 0x31, 0x62, 0xC4, 0xC5, 0xC7, 0xC3, 0xCB +}; + + +/* The table constants are indices of + * S-box entries, preprocessed through q0 and q1. */ +static u8 calc_sb_tbl[512] = { + 0xA9, 0x75, 0x67, 0xF3, 0xB3, 0xC6, 0xE8, 0xF4, + 0x04, 0xDB, 0xFD, 0x7B, 0xA3, 0xFB, 0x76, 0xC8, + 0x9A, 0x4A, 0x92, 0xD3, 0x80, 0xE6, 0x78, 0x6B, + 0xE4, 0x45, 0xDD, 0x7D, 0xD1, 0xE8, 0x38, 0x4B, + 0x0D, 0xD6, 0xC6, 0x32, 0x35, 0xD8, 0x98, 0xFD, + 0x18, 0x37, 0xF7, 0x71, 0xEC, 0xF1, 0x6C, 0xE1, + 0x43, 0x30, 0x75, 0x0F, 0x37, 0xF8, 0x26, 0x1B, + 0xFA, 0x87, 0x13, 0xFA, 0x94, 0x06, 0x48, 0x3F, + 0xF2, 0x5E, 0xD0, 0xBA, 0x8B, 0xAE, 0x30, 0x5B, + 0x84, 0x8A, 0x54, 0x00, 0xDF, 0xBC, 0x23, 0x9D, + 0x19, 0x6D, 0x5B, 0xC1, 0x3D, 0xB1, 0x59, 0x0E, + 0xF3, 0x80, 0xAE, 0x5D, 0xA2, 0xD2, 0x82, 0xD5, + 0x63, 0xA0, 0x01, 0x84, 0x83, 0x07, 0x2E, 0x14, + 0xD9, 0xB5, 0x51, 0x90, 0x9B, 0x2C, 0x7C, 0xA3, + 0xA6, 0xB2, 0xEB, 0x73, 0xA5, 0x4C, 0xBE, 0x54, + 0x16, 0x92, 0x0C, 0x74, 0xE3, 0x36, 0x61, 0x51, + 0xC0, 0x38, 0x8C, 0xB0, 0x3A, 0xBD, 0xF5, 0x5A, + 0x73, 0xFC, 0x2C, 0x60, 0x25, 0x62, 0x0B, 0x96, + 0xBB, 0x6C, 0x4E, 0x42, 0x89, 0xF7, 0x6B, 0x10, + 0x53, 0x7C, 0x6A, 0x28, 0xB4, 0x27, 0xF1, 0x8C, + 0xE1, 0x13, 0xE6, 0x95, 0xBD, 0x9C, 0x45, 0xC7, + 0xE2, 0x24, 0xF4, 0x46, 0xB6, 0x3B, 0x66, 0x70, + 0xCC, 0xCA, 0x95, 0xE3, 0x03, 0x85, 0x56, 0xCB, + 0xD4, 0x11, 0x1C, 0xD0, 0x1E, 0x93, 0xD7, 0xB8, + 0xFB, 0xA6, 0xC3, 0x83, 0x8E, 0x20, 0xB5, 0xFF, + 0xE9, 0x9F, 0xCF, 0x77, 0xBF, 0xC3, 0xBA, 0xCC, + 0xEA, 0x03, 0x77, 0x6F, 0x39, 0x08, 0xAF, 0xBF, + 0x33, 0x40, 0xC9, 0xE7, 0x62, 0x2B, 0x71, 0xE2, + 0x81, 0x79, 0x79, 0x0C, 0x09, 0xAA, 0xAD, 0x82, + 0x24, 0x41, 0xCD, 0x3A, 0xF9, 0xEA, 0xD8, 0xB9, + 0xE5, 0xE4, 0xC5, 0x9A, 0xB9, 0xA4, 0x4D, 0x97, + 0x44, 0x7E, 0x08, 0xDA, 0x86, 0x7A, 0xE7, 0x17, + 0xA1, 0x66, 0x1D, 0x94, 0xAA, 0xA1, 0xED, 0x1D, + 0x06, 0x3D, 0x70, 0xF0, 0xB2, 0xDE, 0xD2, 0xB3, + 0x41, 0x0B, 0x7B, 0x72, 0xA0, 0xA7, 0x11, 0x1C, + 0x31, 0xEF, 0xC2, 0xD1, 0x27, 0x53, 0x90, 0x3E, + 0x20, 0x8F, 0xF6, 0x33, 0x60, 0x26, 0xFF, 0x5F, + 0x96, 0xEC, 0x5C, 0x76, 0xB1, 0x2A, 0xAB, 0x49, + 0x9E, 0x81, 0x9C, 0x88, 0x52, 0xEE, 0x1B, 0x21, + 0x5F, 0xC4, 0x93, 0x1A, 0x0A, 0xEB, 0xEF, 0xD9, + 0x91, 0xC5, 0x85, 0x39, 0x49, 0x99, 0xEE, 0xCD, + 0x2D, 0xAD, 0x4F, 0x31, 0x8F, 0x8B, 0x3B, 0x01, + 0x47, 0x18, 0x87, 0x23, 0x6D, 0xDD, 0x46, 0x1F, + 0xD6, 0x4E, 0x3E, 0x2D, 0x69, 0xF9, 0x64, 0x48, + 0x2A, 0x4F, 0xCE, 0xF2, 0xCB, 0x65, 0x2F, 0x8E, + 0xFC, 0x78, 0x97, 0x5C, 0x05, 0x58, 0x7A, 0x19, + 0xAC, 0x8D, 0x7F, 0xE5, 0xD5, 0x98, 0x1A, 0x57, + 0x4B, 0x67, 0x0E, 0x7F, 0xA7, 0x05, 0x5A, 0x64, + 0x28, 0xAF, 0x14, 0x63, 0x3F, 0xB6, 0x29, 0xFE, + 0x88, 0xF5, 0x3C, 0xB7, 0x4C, 0x3C, 0x02, 0xA5, + 0xB8, 0xCE, 0xDA, 0xE9, 0xB0, 0x68, 0x17, 0x44, + 0x55, 0xE0, 0x1F, 0x4D, 0x8A, 0x43, 0x7D, 0x69, + 0x57, 0x29, 0xC7, 0x2E, 0x8D, 0xAC, 0x74, 0x15, + 0xB7, 0x59, 0xC4, 0xA8, 0x9F, 0x0A, 0x72, 0x9E, + 0x7E, 0x6E, 0x15, 0x47, 0x22, 0xDF, 0x12, 0x34, + 0x58, 0x35, 0x07, 0x6A, 0x99, 0xCF, 0x34, 0xDC, + 0x6E, 0x22, 0x50, 0xC9, 0xDE, 0xC0, 0x68, 0x9B, + 0x65, 0x89, 0xBC, 0xD4, 0xDB, 0xED, 0xF8, 0xAB, + 0xC8, 0x12, 0xA8, 0xA2, 0x2B, 0x0D, 0x40, 0x52, + 0xDC, 0xBB, 0xFE, 0x02, 0x32, 0x2F, 0xA4, 0xA9, + 0xCA, 0xD7, 0x10, 0x61, 0x21, 0x1E, 0xF0, 0xB4, + 0xD3, 0x50, 0x5D, 0x04, 0x0F, 0xF6, 0x00, 0xC2, + 0x6F, 0x16, 0x9D, 0x25, 0x36, 0x86, 0x42, 0x56, + 0x4A, 0x55, 0x5E, 0x09, 0xC1, 0xBE, 0xE0, 0x91 +}; + +#endif /* _2FISH_TABLES_H */ diff -Nru linux-2.4.0-test9-plain/crypto/Config.in linux-2.4.0-test9-int/crypto/Config.in --- linux-2.4.0-test9-plain/crypto/Config.in Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/crypto/Config.in Sun Oct 15 12:20:50 2000 @@ -0,0 +1,25 @@ +# +# Network configuration +# +mainmenu_option next_comment +comment 'Crypto options' +bool 'Crypto support' CONFIG_CRYPTO +dep_tristate 'Crypto ciphers' CONFIG_CIPHERS $CONFIG_CRYPTO +if [ "$CONFIG_CIPHERS" != "n" ]; then + dep_tristate 'Blowfish cipher (EXPERIMENTAL)' CONFIG_CIPHER_BLOWFISH $CONFIG_CIPHERS + dep_tristate 'DES cipher (EXPERIMENTAL)' CONFIG_CIPHER_DES $CONFIG_CIPHERS + dep_tristate 'DFC cipher (EXPERIMENTAL)' CONFIG_CIPHER_DFC $CONFIG_CIPHERS + dep_tristate 'IDEA cipher (EXPERIMENTAL)' CONFIG_CIPHER_IDEA $CONFIG_CIPHERS + dep_tristate 'MARS cipher (EXPERIMENTAL)' CONFIG_CIPHER_MARS $CONFIG_CIPHERS + dep_tristate 'RC5 cipher (EXPERIMENTAL)' CONFIG_CIPHER_RC5 $CONFIG_CIPHERS + dep_tristate 'RC6 cipher (EXPERIMENTAL)' CONFIG_CIPHER_RC6 $CONFIG_CIPHERS +# Rijndael isn't working +# dep_tristate 'Rijndael cipher (EXPERIMENTAL)' CONFIG_CIPHER_RIJNDAEL $CONFIG_CIPHERS + dep_tristate 'Serpent cipher (EXPERIMENTAL)' CONFIG_CIPHER_SERPENT $CONFIG_CIPHERS +fi +dep_tristate 'Digest algorithms' CONFIG_DIGEST $CONFIG_CRYPTO +if [ "$CONFIG_DIGEST" != "n" ]; then + dep_tristate 'MD5 digest (EXPERIMENTAL)' CONFIG_DIGEST_MD5 $CONFIG_DIGEST + dep_tristate 'SHA1 digest (EXPERIMENTAL)' CONFIG_DIGEST_SHA1 $CONFIG_DIGEST +fi +endmenu diff -Nru linux-2.4.0-test9-plain/crypto/Makefile linux-2.4.0-test9-int/crypto/Makefile --- linux-2.4.0-test9-plain/crypto/Makefile Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/crypto/Makefile Sun Oct 15 15:27:46 2000 @@ -0,0 +1,110 @@ +# +# Makefile for the Linux kernel crypto library. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (not a .c file). +# +# Note 2! The CFLAGS definitions are now in the main makefile. + +O_TARGET := crypto.o +O_OBJS := +OX_OBJS := + +ifeq ($(CONFIG_CRYPTO),y) + OX_OBJS += cryptoapi.o +else + ifeq ($(CONFIG_CRYPTO),m) + M_OBJS += cryptoapi.o + endif +endif + +ifeq ($(CONFIG_CIPHER_SERPENT),y) + O_OBJS += serp6f.o +else + ifeq ($(CONFIG_CIPHER_SERPENT),m) + M_OBJS += serp6f.o + endif +endif + +ifeq ($(CONFIG_CIPHER_MARS),y) + O_OBJS += mars6.o +else + ifeq ($(CONFIG_CIPHER_MARS),m) + M_OBJS += mars6.o + endif +endif + +ifeq ($(CONFIG_CIPHER_RC5),y) + O_OBJS += rc5.o +else + ifeq ($(CONFIG_CIPHER_RC5),m) + M_OBJS += rc5.o + endif +endif + +ifeq ($(CONFIG_CIPHER_RC6),y) + O_OBJS += rc62.o +else + ifeq ($(CONFIG_CIPHER_RC6),m) + M_OBJS += rc62.o + endif +endif + +ifeq ($(CONFIG_CIPHER_DFC),y) + O_OBJS += dfc2.o +else + ifeq ($(CONFIG_CIPHER_DFC),m) + M_OBJS += dfc2.o + endif +endif + +ifeq ($(CONFIG_CIPHER_RIJNDAEL),y) + O_OBJS += rijndael3.o +else + ifeq ($(CONFIG_CIPHER_RIJNDAEL),m) + M_OBJS += rijndael3.o + endif +endif + +ifeq ($(CONFIG_CIPHER_BLOWFISH),y) + O_OBJS += blowfish.o +else + ifeq ($(CONFIG_CIPHER_BLOWFISH),m) + M_OBJS += blowfish.o + endif +endif + +ifeq ($(CONFIG_CIPHER_IDEA),y) + O_OBJS += idea.o +else + ifeq ($(CONFIG_CIPHER_IDEA),m) + M_OBJS += idea.o + endif +endif + +ifeq ($(CONFIG_CIPHER_DES),y) + O_OBJS += des.o +else + ifeq ($(CONFIG_CIPHER_DES),m) + M_OBJS += des.o + endif +endif + +ifeq ($(CONFIG_DIGEST_MD5),y) + O_OBJS += md5glue.o +else + ifeq ($(CONFIG_DIGEST_MD5),m) + M_OBJS += md5glue.o + endif +endif + +ifeq ($(CONFIG_DIGEST_SHA1),y) + O_OBJS += sha1glue.o +else + ifeq ($(CONFIG_DIGEST_SHA1),m) + M_OBJS += sha1glue.o + endif +endif + +include $(TOPDIR)/Rules.make diff -Nru linux-2.4.0-test9-plain/crypto/blowfish.c linux-2.4.0-test9-int/crypto/blowfish.c --- linux-2.4.0-test9-plain/crypto/blowfish.c Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/crypto/blowfish.c Sun Oct 15 15:09:17 2000 @@ -0,0 +1,511 @@ +#include +#include +#include +#include +#include + +#define Bswap(x) __le32_to_cpu(x) + +static u32 bf_pbox[16 + 2] = +{ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x9216d5d9, 0x8979fb1b, +}; + +static u32 bf_sbox[256 * 4] = +{ + 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, + 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, + 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, + 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, + 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, + 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, + 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, + 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, + 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, + 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, + 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, + 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, + 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, + 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, + 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, + 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, + 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, + 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, + 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, + 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, + 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, + 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, + 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, + 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, + 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, + 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, + 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, + 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, + 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, + 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, + 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, + 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, + 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, + 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, + 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, + 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, + 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, + 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, + 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, + 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, + 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, + 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, + 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, + 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, + 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, + 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, + 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, + 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, + 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, + 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, + 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, + 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, + 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, + 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, + 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, + 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, + 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, + 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, + 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, + 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, + 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, + 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, + 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, + 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, + 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, + 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, + 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, + 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, + 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, + 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, + 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, + 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, + 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, + 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, + 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, + 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, + 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, + 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, + 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, + 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, + 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, + 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, + 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, + 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, + 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, + 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, + 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, + 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, + 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, + 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, + 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, + 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, + 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, + 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, + 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, + 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, + 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, + 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, + 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, + 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, + 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, + 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, + 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, + 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, + 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, + 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, + 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, + 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, + 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, + 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, + 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, + 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, + 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, + 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, + 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, + 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, + 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, + 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, + 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, + 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, + 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, + 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, + 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, + 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, + 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, + 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, + 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, + 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, + 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, + 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, + 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, + 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, + 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, + 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, + 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, + 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, + 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, + 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, + 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, + 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, + 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, + 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, + 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, + 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, + 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, + 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, + 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, + 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, + 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, + 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, + 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, + 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, + 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, + 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, + 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, + 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, + 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, + 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, + 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, + 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, + 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, + 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, + 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, + 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, + 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, + 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, + 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, + 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, + 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, + 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, + 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, + 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, + 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, + 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, + 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, + 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, + 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, + 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, + 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, + 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, + 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, + 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, + 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, + 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, + 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, + 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, + 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, + 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, + 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, + 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, + 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, + 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, + 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, + 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, + 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, + 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, + 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, + 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, + 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, + 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, + 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, + 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, + 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, + 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, + 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, + 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, + 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, + 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, + 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, + 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, + 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, + 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, + 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, + 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, + 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, + 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, + 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, + 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, + 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, + 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, + 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, + 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, + 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, + 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, + 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, + 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, + 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, + 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, + 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, + 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, + 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, + 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, + 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, + 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, + 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, + 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, + 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, + 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, + 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, + 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, + 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, + 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, + 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, + 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, + 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, + 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, + 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, + 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, + 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, + 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, + 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, + 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, + 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, + 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, + 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, + 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6, +}; + +typedef struct blow_key +{ + u32 P[18]; + u32 S[1024]; +} +blow_key; + +/* + * Round loop unrolling macros, S is a pointer to a S-Box array + * organized in 4 unsigned longs at a row. + */ + +#define GET32_3(x) (((x) & 0xff)) +#define GET32_2(x) (((x) >> (8)) & (0xff)) +#define GET32_1(x) (((x) >> (16)) & (0xff)) +#define GET32_0(x) (((x) >> (24)) & (0xff)) + +#define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \ + S[512 + GET32_2(x)]) + S[768 + GET32_3(x)]) + +#define ROUND(a, b, n) b^=P[n];a ^= bf_F(b) + +/* + * The blowfish encipher, processes 64-bit blocks. + * NOTE: This function MUSTN'T respect endianess + */ + +int blowfish_encrypt(struct cipher_context *cx, + const u8 *in8, u8 *out8, int size) +{ + blow_key *key=(blow_key *)cx->keyinfo; + u32 *in_blk = (u32 *)in8; + u32 *out_blk = (u32 *)out8; + + u32 yl,yr; + + u32 *P = key->P; + u32 *S = key->S; + + for (; size >= 8; size -= 8) + { + yl = *(in_blk++); + yr = *(in_blk++); + + ROUND(yr, yl, 0); + ROUND(yl, yr, 1); + ROUND(yr, yl, 2); + ROUND(yl, yr, 3); + ROUND(yr, yl, 4); + ROUND(yl, yr, 5); + ROUND(yr, yl, 6); + ROUND(yl, yr, 7); + ROUND(yr, yl, 8); + ROUND(yl, yr, 9); + ROUND(yr, yl, 10); + ROUND(yl, yr, 11); + ROUND(yr, yl, 12); + ROUND(yl, yr, 13); + ROUND(yr, yl, 14); + ROUND(yl, yr, 15); + + /* yl and yr are switched */ + yl ^= P[16]; + yr ^= P[17]; + + *(out_blk++) = yr; + *(out_blk++) = yl; + } + return 0; +} + +int blowfish_decrypt(struct cipher_context *cx, + const u8 *in8, u8 *out8, int size) +{ + blow_key *key=(blow_key *)cx->keyinfo; + u32 *in_blk = (u32 *)in8; + u32 *out_blk = (u32 *)out8; + + u32 yl,yr; + + u32 *P = key->P; + u32 *S = key->S; + + for (; size >= 8; size -= 8) + { + yl = *(in_blk++); + yr = *(in_blk++); + + ROUND(yr, yl, 17); + ROUND(yl, yr, 16); + ROUND(yr, yl, 15); + ROUND(yl, yr, 14); + ROUND(yr, yl, 13); + ROUND(yl, yr, 12); + ROUND(yr, yl, 11); + ROUND(yl, yr, 10); + ROUND(yr, yl, 9); + ROUND(yl, yr, 8); + ROUND(yr, yl, 7); + ROUND(yl, yr, 6); + ROUND(yr, yl, 5); + ROUND(yl, yr, 4); + ROUND(yr, yl, 3); + ROUND(yl, yr, 2); + + /* yl and yr are switched */ + yl ^= P[1]; + yr ^= P[0]; + + *(out_blk++) = yr; + *(out_blk++) = yl; + } + return 0; +} + +/* Sets the blowfish S and P boxes for encryption and decryption. */ + +int blowfish_set_key(struct cipher_context *cx, + unsigned char *key, int keybytes) +{ + blow_key *key2=(blow_key *)cx->keyinfo; + short i; + short j; + short count; + u32 data[2]; + u32 temp; + u32 *P = key2->P; + u32 *S = key2->S; + + /* Copy the initialization s-boxes */ + + for (i = 0, count = 0; i < 256; i++) + for (j = 0; j < 4; j++, count++) + S[count] = bf_sbox[count]; + + /* Set the p-boxes */ + + for (i = 0; i < 16 + 2; i++) + P[i] = bf_pbox[i]; + + /* Actual subkey generation */ + + for (j = 0, i = 0; i < 16 + 2; i++) + { + temp = (((u32) key[j] << 24) | + ((u32) key[(j + 1) % keybytes] << 16) | + ((u32) key[(j + 2) % keybytes] << 8) | + ((u32) key[(j + 3) % keybytes] )); + + P[i] = P[i] ^ temp; + j = (j + 4) % keybytes; + } + + data[0] = 0x00000000; + data[1] = 0x00000000; + + for (i = 0; i < 16 + 2; i += 2) + { + blowfish_encrypt(cx, (u8 *)data, (u8 *)data, 8); + + P[i] = data[0]; + P[i + 1] = data[1]; + } + + for (i = 0; i < 4; i++) + { + for (j = 0, count = i * 256; j < 256; j += 2, count += 2) + { + blowfish_encrypt(cx, (u8 *)data, (u8 *)data, 8); + + S[count] = data[0]; + S[count + 1] = data[1]; + } + } + return 0; +} + +static void blowfish_lock(void) +{ + MOD_INC_USE_COUNT; +} + +static void blowfish_unlock(void) +{ + MOD_DEC_USE_COUNT; +} + +#define CIPHER_BITS_64 +#define CIPHER_NAME(x) blowfish##x +#include "gen-cbc.h" +#include "gen-ecb.h" + +static struct cipher_implementation blowfish = { + {{NULL,NULL},CIPHER_BLOWFISH, "blowfish"}, + blocksize: 8, + ivsize: 0, + key_schedule_size: BLOWFISH_KEY_SCHEDULE_SIZE, + key_size_mask: CIPHER_KEYSIZE_128 | CIPHER_KEYSIZE_192 | + CIPHER_KEYSIZE_256, + INIT_CIPHER_BLKOPS(blowfish_ecb), + INIT_CIPHER_OPS(blowfish) +}; + +static struct cipher_implementation blowfish_cbc = { + {{NULL,NULL},CIPHER_BLOWFISH | CIPHER_CBC, "blowfish-cbc"}, + blocksize: 8, + ivsize: 8, + key_schedule_size: BLOWFISH_KEY_SCHEDULE_SIZE, + key_size_mask: CIPHER_KEYSIZE_128 | CIPHER_KEYSIZE_192 | + CIPHER_KEYSIZE_256, + INIT_CIPHER_BLKOPS(blowfish_cbc), + INIT_CIPHER_OPS(blowfish) +}; + +int __init init_blowfish(void) +{ + if (register_cipher(&blowfish)) + printk(KERN_WARNING "Couldn't register blowfish encryption\n"); + if (register_cipher(&blowfish_cbc)) + printk(KERN_WARNING "Couldn't register blowfish-cbc encryption\n"); + + return 0; +} + +void cleanup_blowfish(void) +{ + if (unregister_cipher(&blowfish)) + printk(KERN_WARNING "Couldn't unregister blowfish encryption\n"); + if (unregister_cipher(&blowfish_cbc)) + printk(KERN_WARNING "Couldn't unregister blowfish-cbc encryption\n"); +} + +module_init(init_blowfish); +module_exit(cleanup_blowfish); diff -Nru linux-2.4.0-test9-plain/crypto/cast0.c linux-2.4.0-test9-int/crypto/cast0.c --- linux-2.4.0-test9-plain/crypto/cast0.c Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/crypto/cast0.c Sun Oct 15 15:10:19 2000 @@ -0,0 +1,430 @@ +/* NOTE: This implementation has been changed from the original + source. See ChangeLog for more information. + Maintained by Alexander Kjeldaas + */ + +/* This is an independent implementation of the CAST-256 encryption */ +/* algorithm designed by Carlisle Adams of Entrust and offered as a */ +/* candidate algorithm for the US NIST Advanced Encryption Standard */ +/* (AES) effort. */ +/* */ +/* Copyright in this implementation is held by Dr B R Gladman but */ +/* I hereby give permission for its free direct or derivative use */ +/* subject to acknowledgment of its origin and compliance with any */ +/* conditions that the originators of CAST-256 place on its use. */ +/* */ +/* Dr Brian Gladman (gladman@seven77.demon.co.uk) 19th October 1998 */ +/* */ +/* Timing data: + +Algorithm: cast256 (cast0.c) +128 bit key: +Key Setup: 4279 cycles +Encrypt: 659 cycles = 38.9 mbits/sec +Decrypt: 667 cycles = 38.4 mbits/sec +Mean: 663 cycles = 38.6 mbits/sec +192 bit key: +Key Setup: 4337 cycles +Encrypt: 663 cycles = 38.6 mbits/sec +Decrypt: 672 cycles = 38.1 mbits/sec +Mean: 668 cycles = 38.4 mbits/sec +256 bit key: +Key Setup: 4304 cycles +Encrypt: 655 cycles = 39.1 mbits/sec +Decrypt: 663 cycles = 38.6 mbits/sec +Mean: 659 cycles = 38.8 mbits/sec + +*/ + +#include +#include +#include +#include +#include + +#if 0 +#define rotl rotl32 +#define rotr rotr32 +#else +#define rotl generic_rotl32 +#define rotr generic_rotr32 +#endif + +u4byte s_box[4][256] = +{ { + 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9C004dd3, + 0x6003e540, 0xcf9fc949, 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, + 0x6e63a0e0, 0x15c361d2, 0xc2e7661d, 0x22d4ff8e, 0x28683b6f, 0xc07fd059, + 0xff2379c8, 0x775f50e2, 0x43c340d3, 0xdf2f8656, 0x887ca41a, 0xa2d2bd2d, + 0xa1c9e0d6, 0x346c4819, 0x61b76d87, 0x22540f2f, 0x2abe32e1, 0xaa54166b, + 0x22568e3a, 0xa2d341d0, 0x66db40c8, 0xa784392f, 0x004dff2f, 0x2db9d2de, + 0x97943fac, 0x4a97c1d8, 0x527644b7, 0xb5f437a7, 0xb82cbaef, 0xd751d159, + 0x6ff7f0ed, 0x5a097a1f, 0x827b68d0, 0x90ecf52e, 0x22b0c054, 0xbc8e5935, + 0x4b6d2f7f, 0x50bb64a2, 0xd2664910, 0xbee5812d, 0xb7332290, 0xe93b159f, + 0xb48ee411, 0x4bff345d, 0xfd45c240, 0xad31973f, 0xc4f6d02e, 0x55fc8165, + 0xd5b1caad, 0xa1ac2dae, 0xa2d4b76d, 0xc19b0C50, 0x882240f2, 0x0c6e4f38, + 0xa4e4bfd7, 0x4f5ba272, 0x564c1d2f, 0xc59c5319, 0xb949e354, 0xb04669fe, + 0xb1b6ab8a, 0xc71358dd, 0x6385c545, 0x110f935d, 0x57538ad5, 0x6a390493, + 0xe63d37e0, 0x2a54f6b3, 0x3a787d5f, 0x6276a0b5, 0x19a6fcdf, 0x7a42206a, + 0x29f9d4d5, 0xf61b1891, 0xbb72275e, 0xaa508167, 0x38901091, 0xc6b505eb, + 0x84c7cb8c, 0x2ad75a0f, 0x874a1427, 0xa2d1936b, 0x2ad286af, 0xaa56d291, + 0xd7894360, 0x425c750d, 0x93b39e26, 0x187184c9, 0x6c00b32d, 0x73e2bb14, + 0xa0bebc3c, 0x54623779, 0x64459eab, 0x3f328b82, 0x7718cf82, 0x59a2cea6, + 0x04ee002e, 0x89fe78e6, 0x3fab0950, 0x325ff6C2, 0x81383f05, 0x6963c5c8, + 0x76cb5ad6, 0xd49974c9, 0xca180dcf, 0x380782d5, 0xc7fa5cf6, 0x8ac31511, + 0x35e79e13, 0x47da91d0, 0xf40f9086, 0xa7e2419e, 0x31366241, 0x051ef495, + 0xaa573b04, 0x4a805d8d, 0x548300d0, 0x00322a3c, 0xbf64cddf, 0xba57a68e, + 0x75c6372b, 0x50afd341, 0xa7c13275, 0x915a0bf5, 0x6b54bfab, 0x2b0b1426, + 0xab4cc9d7, 0x449ccd82, 0xf7fbf265, 0xab85c5f3, 0x1b55db94, 0xaad4e324, + 0xcfa4bd3f, 0x2deaa3e2, 0x9e204d02, 0xc8bd25ac, 0xeadf55b3, 0xd5bd9e98, + 0xe31231b2, 0x2ad5ad6c, 0x954329de, 0xadbe4528, 0xd8710f69, 0xaa51c90f, + 0xaa786bf6, 0x22513f1e, 0xaa51a79b, 0x2ad344cc, 0x7b5a41f0, 0xd37cfbad, + 0x1b069505, 0x41ece491, 0xb4c332e6, 0x032268d4, 0xc9600acc, 0xce387e6d, + 0xbf6bb16c, 0x6a70fb78, 0x0d03d9c9, 0xd4df39de, 0xe01063da, 0x4736f464, + 0x5ad328d8, 0xb347cc96, 0x75bb0fc3, 0x98511bfb, 0x4ffbcc35, 0xb58bcf6a, + 0xe11f0abc, 0xbfc5fe4a, 0xa70aec10, 0xac39570a, 0x3f04442f, 0x6188b153, + 0xe0397a2e, 0x5727cb79, 0x9ceb418f, 0x1cacd68d, 0x2ad37c96, 0x0175cb9d, + 0xc69dff09, 0xc75b65f0, 0xd9db40d8, 0xec0e7779, 0x4744ead4, 0xb11c3274, + 0xdd24cb9e, 0x7e1c54bd, 0xf01144f9, 0xd2240eb1, 0x9675b3fd, 0xa3ac3755, + 0xd47c27af, 0x51c85f4d, 0x56907596, 0xa5bb15e6, 0x580304f0, 0xca042cf1, + 0x011a37ea, 0x8dbfaadb, 0x35ba3e4a, 0x3526ffa0, 0xc37b4d09, 0xbc306ed9, + 0x98a52666, 0x5648f725, 0xff5e569d, 0x0ced63d0, 0x7c63b2cf, 0x700b45e1, + 0xd5ea50f1, 0x85a92872, 0xaf1fbda7, 0xd4234870, 0xa7870bf3, 0x2d3b4d79, + 0x42e04198, 0x0cd0ede7, 0x26470db8, 0xf881814C, 0x474d6ad7, 0x7c0c5e5c, + 0xd1231959, 0x381b7298, 0xf5d2f4db, 0xab838653, 0x6e2f1e23, 0x83719c9e, + 0xbd91e046, 0x9a56456e, 0xdc39200c, 0x20c8c571, 0x962bda1c, 0xe1e696ff, + 0xb141ab08, 0x7cca89b9, 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, + 0x427b169c, 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf + }, + { + 0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, + 0x55889c94, 0x72fc0651, 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, + 0x99c430ef, 0x5f0c0794, 0x18dcdb7d, 0xa1d6eff3, 0xa0b52f7b, 0x59e83605, + 0xee15b094, 0xe9ffd909, 0xdc440086, 0xef944459, 0xba83ccb3, 0xe0c3cdfb, + 0xd1da4181, 0x3b092ab1, 0xf997f1c1, 0xa5e6cf7b, 0x01420ddb, 0xe4e7ef5b, + 0x25a1ff41, 0xe180f806, 0x1fc41080, 0x179bee7a, 0xd37ac6a9, 0xfe5830a4, + 0x98de8b7f, 0x77e83f4e, 0x79929269, 0x24fa9f7b, 0xe113c85b, 0xacc40083, + 0xd7503525, 0xf7ea615f, 0x62143154, 0x0d554b63, 0x5d681121, 0xc866c359, + 0x3d63cf73, 0xcee234c0, 0xd4d87e87, 0x5c672b21, 0x071f6181, 0x39f7627f, + 0x361e3084, 0xe4eb573b, 0x602f64a4, 0xd63acd9c, 0x1bbc4635, 0x9e81032d, + 0x2701f50c, 0x99847ab4, 0xa0e3df79, 0xba6cf38c, 0x10843094, 0x2537a95e, + 0xf46f6ffe, 0xa1ff3b1f, 0x208cfb6a, 0x8f458c74, 0xd9e0a227, 0x4ec73a34, + 0xfc884f69, 0x3e4de8df, 0xef0e0088, 0x3559648d, 0x8a45388c, 0x1d804366, + 0x721d9bfd, 0xa58684bb, 0xe8256333, 0x844e8212, 0x128d8098, 0xfed33fb4, + 0xce280ae1, 0x27e19ba5, 0xd5a6c252, 0xe49754bd, 0xc5d655dd, 0xeb667064, + 0x77840b4d, 0xa1b6a801, 0x84db26a9, 0xe0b56714, 0x21f043b7, 0xe5d05860, + 0x54f03084, 0x066ff472, 0xa31aa153, 0xdadc4755, 0xb5625dbf, 0x68561be6, + 0x83ca6b94, 0x2d6ed23b, 0xeccf01db, 0xa6d3d0ba, 0xb6803d5c, 0xaf77a709, + 0x33b4a34c, 0x397bc8d6, 0x5ee22b95, 0x5f0e5304, 0x81ed6f61, 0x20e74364, + 0xb45e1378, 0xde18639b, 0x881ca122, 0xb96726d1, 0x8049a7e8, 0x22b7da7b, + 0x5e552d25, 0x5272d237, 0x79d2951c, 0xc60d894c, 0x488cb402, 0x1ba4fe5b, + 0xa4b09f6b, 0x1ca815cf, 0xa20c3005, 0x8871df63, 0xb9de2fcb, 0x0cc6c9e9, + 0x0beeff53, 0xe3214517, 0xb4542835, 0x9f63293c, 0xee41e729, 0x6e1d2d7c, + 0x50045286, 0x1e6685f3, 0xf33401c6, 0x30a22c95, 0x31a70850, 0x60930f13, + 0x73f98417, 0xa1269859, 0xec645c44, 0x52c877a9, 0xcdff33a6, 0xa02b1741, + 0x7cbad9a2, 0x2180036f, 0x50d99c08, 0xcb3f4861, 0xc26bd765, 0x64a3f6ab, + 0x80342676, 0x25a75e7b, 0xe4e6d1fc, 0x20c710e6, 0xcdf0b680, 0x17844d3b, + 0x31eef84d, 0x7e0824e4, 0x2ccb49eb, 0x846a3bae, 0x8ff77888, 0xee5d60f6, + 0x7af75673, 0x2fdd5cdb, 0xa11631c1, 0x30f66f43, 0xb3faec54, 0x157fd7fa, + 0xef8579cc, 0xd152de58, 0xdb2ffd5e, 0x8f32ce19, 0x306af97a, 0x02f03ef8, + 0x99319ad5, 0xc242fa0f, 0xa7e3ebb0, 0xc68e4906, 0xb8da230c, 0x80823028, + 0xdcdef3c8, 0xd35fb171, 0x088a1bc8, 0xbec0c560, 0x61a3c9e8, 0xbca8f54d, + 0xc72feffa, 0x22822e99, 0x82c570b4, 0xd8d94e89, 0x8b1c34bc, 0x301e16e6, + 0x273be979, 0xb0ffeaa6, 0x61d9b8c6, 0x00b24869, 0xb7ffce3f, 0x08dc283b, + 0x43daf65a, 0xf7e19798, 0x7619b72f, 0x8f1c9ba4, 0xdc8637a0, 0x16a7d3b1, + 0x9fc393b7, 0xa7136eeb, 0xc6bcc63e, 0x1a513742, 0xef6828bc, 0x520365d6, + 0x2d6a77ab, 0x3527ed4b, 0x821fd216, 0x095c6e2e, 0xdb92f2fb, 0x5eea29cb, + 0x145892f5, 0x91584f7f, 0x5483697b, 0x2667a8cc, 0x85196048, 0x8c4bacea, + 0x833860d4, 0x0d23e0f9, 0x6c387e8a, 0x0ae6d249, 0xb284600c, 0xd835731d, + 0xdcb1c647, 0xac4c56ea, 0x3ebd81b3, 0x230eabb0, 0x6438bc87, 0xf0b5b1fa, + 0x8f5ea2b3, 0xfc184642, 0x0a036b7a, 0x4fb089bd, 0x649da589, 0xa345415e, + 0x5c038323, 0x3e5d3bb9, 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, + 0x7160a539, 0x73bfbe70, 0x83877605, 0x4523ecf1 + }, + { + 0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, + 0x8c1fc644, 0xaececa90, 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, + 0x920e8806, 0xf0ad0548, 0xe13c8d83, 0x927010d5, 0x11107d9f, 0x07647db9, + 0xb2e3e4d4, 0x3d4f285e, 0xb9afa820, 0xfade82e0, 0xa067268b, 0x8272792e, + 0x553fb2c0, 0x489ae22b, 0xd4ef9794, 0x125e3fbc, 0x21fffcee, 0x825b1bfd, + 0x9255c5ed, 0x1257a240, 0x4e1a8302, 0xbae07fff, 0x528246e7, 0x8e57140e, + 0x3373f7bf, 0x8c9f8188, 0xa6fc4ee8, 0xc982b5a5, 0xa8c01db7, 0x579fc264, + 0x67094f31, 0xf2bd3f5f, 0x40fff7c1, 0x1fb78dfc, 0x8e6bd2c1, 0x437be59b, + 0x99b03dbf, 0xb5dbc64b, 0x638dc0e6, 0x55819d99, 0xa197c81c, 0x4a012d6e, + 0xc5884a28, 0xccc36f71, 0xb843c213, 0x6c0743f1, 0x8309893c, 0x0feddd5f, + 0x2f7fe850, 0xd7c07f7e, 0x02507fbf, 0x5afb9a04, 0xa747d2d0, 0x1651192e, + 0xaf70bf3e, 0x58c31380, 0x5f98302e, 0x727cc3c4, 0x0a0fb402, 0x0f7fef82, + 0x8c96fdad, 0x5d2c2aae, 0x8ee99a49, 0x50da88b8, 0x8427f4a0, 0x1eac5790, + 0x796fb449, 0x8252dc15, 0xefbd7d9b, 0xa672597d, 0xada840d8, 0x45f54504, + 0xfa5d7403, 0xe83ec305, 0x4f91751a, 0x925669c2, 0x23efe941, 0xa903f12e, + 0x60270df2, 0x0276e4b6, 0x94fd6574, 0x927985b2, 0x8276dbcb, 0x02778176, + 0xf8af918d, 0x4e48f79e, 0x8f616ddf, 0xe29d840e, 0x842f7d83, 0x340ce5c8, + 0x96bbb682, 0x93b4b148, 0xef303cab, 0x984faf28, 0x779faf9b, 0x92dc560d, + 0x224d1e20, 0x8437aa88, 0x7d29dc96, 0x2756d3dc, 0x8b907cee, 0xb51fd240, + 0xe7c07ce3, 0xe566b4a1, 0xc3e9615e, 0x3cf8209d, 0x6094d1e3, 0xcd9ca341, + 0x5c76460e, 0x00ea983b, 0xd4d67881, 0xfd47572c, 0xf76cedd9, 0xbda8229c, + 0x127dadaa, 0x438a074e, 0x1f97c090, 0x081bdb8a, 0x93a07ebe, 0xb938ca15, + 0x97b03cff, 0x3dc2c0f8, 0x8d1ab2ec, 0x64380e51, 0x68cc7bfb, 0xd90f2788, + 0x12490181, 0x5de5ffd4, 0xdd7ef86a, 0x76a2e214, 0xb9a40368, 0x925d958f, + 0x4b39fffa, 0xba39aee9, 0xa4ffd30b, 0xfaf7933b, 0x6d498623, 0x193cbcfa, + 0x27627545, 0x825cf47a, 0x61bd8ba0, 0xd11e42d1, 0xcead04f4, 0x127ea392, + 0x10428db7, 0x8272a972, 0x9270c4a8, 0x127de50b, 0x285ba1c8, 0x3c62f44f, + 0x35c0eaa5, 0xe805d231, 0x428929fb, 0xb4fcdf82, 0x4fb66a53, 0x0e7dc15b, + 0x1f081fab, 0x108618ae, 0xfcfd086d, 0xf9ff2889, 0x694bcc11, 0x236a5cae, + 0x12deca4d, 0x2c3f8cc5, 0xd2d02dfe, 0xf8ef5896, 0xe4cf52da, 0x95155b67, + 0x494a488c, 0xb9b6a80c, 0x5c8f82bc, 0x89d36b45, 0x3a609437, 0xec00c9a9, + 0x44715253, 0x0a874b49, 0xd773bc40, 0x7c34671c, 0x02717ef6, 0x4feb5536, + 0xa2d02fff, 0xd2bf60c4, 0xd43f03c0, 0x50b4ef6d, 0x07478cd1, 0x006e1888, + 0xa2e53f55, 0xb9e6d4bc, 0xa2048016, 0x97573833, 0xd7207d67, 0xde0f8f3d, + 0x72f87b33, 0xabcc4f33, 0x7688c55d, 0x7b00a6b0, 0x947b0001, 0x570075d2, + 0xf9bb88f8, 0x8942019e, 0x4264a5ff, 0x856302e0, 0x72dbd92b, 0xee971b69, + 0x6ea22fde, 0x5f08ae2b, 0xaf7a616d, 0xe5c98767, 0xcf1febd2, 0x61efc8c2, + 0xf1ac2571, 0xcc8239c2, 0x67214cb8, 0xb1e583d1, 0xb7dc3e62, 0x7f10bdce, + 0xf90a5c38, 0x0ff0443d, 0x606e6dc6, 0x60543a49, 0x5727c148, 0x2be98a1d, + 0x8ab41738, 0x20e1be24, 0xaf96da0f, 0x68458425, 0x99833be5, 0x600d457d, + 0x282f9350, 0x8334b362, 0xd91d1120, 0x2b6d8da0, 0x642b1e31, 0x9c305a00, + 0x52bce688, 0x1b03588a, 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, + 0xdfef4636, 0xa133c501, 0xe9d3531c, 0xee353783 + }, + { + 0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, + 0x85510443, 0xfa020ed1, 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, + 0xfd059d43, 0x6497b7b1, 0xf3641f63, 0x241e4adf, 0x28147f5f, 0x4fa2b8cd, + 0xc9430040, 0x0cc32220, 0xfdd30b30, 0xc0a5374f, 0x1d2d00d9, 0x24147b15, + 0xee4d111a, 0x0fca5167, 0x71ff904c, 0x2d195ffe, 0x1a05645f, 0x0c13fefe, + 0x081b08ca, 0x05170121, 0x80530100, 0xe83e5efe, 0xac9af4f8, 0x7fe72701, + 0xd2b8ee5f, 0x06df4261, 0xbb9e9b8a, 0x7293ea25, 0xce84ffdf, 0xf5718801, + 0x3dd64b04, 0xa26f263b, 0x7ed48400, 0x547eebe6, 0x446d4ca0, 0x6cf3d6f5, + 0x2649abdf, 0xaea0c7f5, 0x36338cc1, 0x503f7e93, 0xd3772061, 0x11b638e1, + 0x72500e03, 0xf80eb2bb, 0xabe0502e, 0xec8d77de, 0x57971e81, 0xe14f6746, + 0xc9335400, 0x6920318f, 0x081dbb99, 0xffc304a5, 0x4d351805, 0x7f3d5ce3, + 0xa6c866c6, 0x5d5bcca9, 0xdaec6fea, 0x9f926f91, 0x9f46222f, 0x3991467d, + 0xa5bf6d8e, 0x1143c44f, 0x43958302, 0xd0214eeb, 0x022083b8, 0x3fb6180c, + 0x18f8931e, 0x281658e6, 0x26486e3e, 0x8bd78a70, 0x7477e4c1, 0xb506e07c, + 0xf32d0a25, 0x79098b02, 0xe4eabb81, 0x28123b23, 0x69dead38, 0x1574ca16, + 0xdf871b62, 0x211c40b7, 0xa51a9ef9, 0x0014377b, 0x041e8ac8, 0x09114003, + 0xbd59e4d2, 0xe3d156d5, 0x4fe876d5, 0x2f91a340, 0x557be8de, 0x00eae4a7, + 0x0ce5c2ec, 0x4db4bba6, 0xe756bdff, 0xdd3369ac, 0xec17b035, 0x06572327, + 0x99afc8b0, 0x56c8c391, 0x6b65811c, 0x5e146119, 0x6e85cb75, 0xbe07c002, + 0xc2325577, 0x893ff4ec, 0x5bbfc92d, 0xd0ec3b25, 0xb7801ab7, 0x8d6d3b24, + 0x20c763ef, 0xc366a5fc, 0x9c382880, 0x0ace3205, 0xaac9548a, 0xeca1d7c7, + 0x041afa32, 0x1d16625a, 0x6701902c, 0x9b757a54, 0x31d477f7, 0x9126b031, + 0x36cc6fdb, 0xc70b8b46, 0xd9e66a48, 0x56e55a79, 0x026a4ceb, 0x52437eff, + 0x2f8f76b4, 0x0df980a5, 0x8674cde3, 0xedda04eb, 0x17a9be04, 0x2c18f4df, + 0xb7747f9d, 0xab2af7b4, 0xefc34d20, 0x2e096b7c, 0x1741a254, 0xe5b6a035, + 0x213d42f6, 0x2c1c7c26, 0x61c2f50f, 0x6552daf9, 0xd2c231f8, 0x25130f69, + 0xd8167fa2, 0x0418f2c8, 0x001a96a6, 0x0d1526ab, 0x63315c21, 0x5e0a72ec, + 0x49bafefd, 0x187908d9, 0x8d0dbd86, 0x311170a7, 0x3e9b640c, 0xcc3e10d7, + 0xd5cad3b6, 0x0caec388, 0xf73001e1, 0x6c728aff, 0x71eae2a1, 0x1f9af36e, + 0xcfcbd12f, 0xc1de8417, 0xac07be6b, 0xcb44a1d8, 0x8b9b0f56, 0x013988c3, + 0xb1c52fca, 0xb4be31cd, 0xd8782806, 0x12a3a4e2, 0x6f7de532, 0x58fd7eb6, + 0xd01ee900, 0x24adffc2, 0xf4990fc5, 0x9711aac5, 0x001d7b95, 0x82e5e7d2, + 0x109873f6, 0x00613096, 0xc32d9521, 0xada121ff, 0x29908415, 0x7fbb977f, + 0xaf9eb3db, 0x29c9ed2a, 0x5ce2a465, 0xa730f32c, 0xd0aa3fe8, 0x8a5cc091, + 0xd49e2ce7, 0x0ce454a9, 0xd60acd86, 0x015f1919, 0x77079103, 0xdea03af6, + 0x78a8565e, 0xdee356df, 0x21f05cbe, 0x8b75e387, 0xb3c50651, 0xb8a5c3ef, + 0xd8eeb6d2, 0xe523be77, 0xc2154529, 0x2f69efdf, 0xafe67afb, 0xf470c4b2, + 0xf3e0eb5b, 0xd6cc9876, 0x39e4460c, 0x1fda8538, 0x1987832f, 0xca007367, + 0xa99144f8, 0x296b299e, 0x492fc295, 0x9266beab, 0xb5676e69, 0x9bd3ddda, + 0xdf7e052f, 0xdb25701c, 0x1b5e51ee, 0xf65324e6, 0x6afce36c, 0x0316cc04, + 0x8644213e, 0xb7dc59d0, 0x7965291f, 0xccd6fd43, 0x41823979, 0x932bcdf6, + 0xb657c34d, 0x4edfd282, 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, + 0x13ecf0b0, 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2 + } +}; + +#define f1(y,x,kr,km) \ + t = rotl(km + x, kr); \ + u = s_box[0][byte(t,3)]; \ + u ^= s_box[1][byte(t,2)]; \ + u -= s_box[2][byte(t,1)]; \ + u += s_box[3][byte(t,0)]; \ + y ^= u + +#define f2(y,x,kr,km) \ + t = rotl(km ^ x, kr); \ + u = s_box[0][byte(t,3)]; \ + u -= s_box[1][byte(t,2)]; \ + u += s_box[2][byte(t,1)]; \ + u ^= s_box[3][byte(t,0)]; \ + y ^= u + +#define f3(y,x,kr,km) \ + t = rotl(km - x, kr); \ + u = s_box[0][byte(t,3)]; \ + u += s_box[1][byte(t,2)]; \ + u ^= s_box[2][byte(t,1)]; \ + u -= s_box[3][byte(t,0)]; \ + y ^= u + +#define f_rnd(x,n) \ + f1(x[2],x[3],l_key[n], l_key[n + 4]); \ + f2(x[1],x[2],l_key[n + 1],l_key[n + 5]); \ + f3(x[0],x[1],l_key[n + 2],l_key[n + 6]); \ + f1(x[3],x[0],l_key[n + 3],l_key[n + 7]) + +#define i_rnd(x, n) \ + f1(x[3],x[0],l_key[n + 3],l_key[n + 7]); \ + f3(x[0],x[1],l_key[n + 2],l_key[n + 6]); \ + f2(x[1],x[2],l_key[n + 1],l_key[n + 5]); \ + f1(x[2],x[3],l_key[n], l_key[n + 4]) + +#define k_rnd(k,tr,tm) \ + f1(k[6],k[7],tr[0],tm[0]); \ + f2(k[5],k[6],tr[1],tm[1]); \ + f3(k[4],k[5],tr[2],tm[2]); \ + f1(k[3],k[4],tr[3],tm[3]); \ + f2(k[2],k[3],tr[4],tm[4]); \ + f3(k[1],k[2],tr[5],tm[5]); \ + f1(k[0],k[1],tr[6],tm[6]); \ + f2(k[7],k[0],tr[7],tm[7]) + +/* initialise the key schedule from the user supplied key */ + +int cast256_set_key(struct cipher_context *cx, unsigned char *key, int key_len) +{ u4byte *key_blk = (u4byte *)key; + /* l_key - storage for the key schedule */ + u4byte *l_key = cx->keyinfo; + u4byte i, j, t, u, cm, cr, lk[8], tm[8], tr[8]; + key_len *= 8; + + for(i = 0; i < key_len / 32; ++i) + + lk[i] = bswap(in_key[i]); + + for(; i < 8; ++i) + + lk[i] = 0; + + cm = 0x5a827999; cr = 19; + + for(i = 0; i < 96; i += 8) + { + for(j = 0; j < 8; ++j) + { + tm[j] = cm; cm += 0x6ed9eba1; + tr[j] = cr; cr += 17; + } + + k_rnd(lk, tr, tm); + + for(j = 0; j < 8; ++j) + { + tm[j] = cm; cm += 0x6ed9eba1; + tr[j] = cr; cr += 17; + } + + k_rnd(lk, tr, tm); + + l_key[i + 0] = lk[0]; l_key[i + 1] = lk[2]; + l_key[i + 2] = lk[4]; l_key[i + 3] = lk[6]; + l_key[i + 4] = lk[7]; l_key[i + 5] = lk[5]; + l_key[i + 6] = lk[3]; l_key[i + 7] = lk[1]; + } + + return 0; +}; + +/* encrypt a block of text */ + +int cast256_encrypt(struct cipher_context *cx, const u8 *in, u8 *out, int size) +{ u4byte *l_key = cx->keyinfo; + u4byte *in_blk = (u4byte *)in; + u4byte *out_blk = (u4byte *)out; + u4byte t, u, blk[4]; + + blk[0] = bswap(in_blk[0]); blk[1] = bswap(in_blk[1]); + blk[2] = bswap(in_blk[2]); blk[3] = bswap(in_blk[3]); + + f_rnd(blk, 0); f_rnd(blk, 8); + f_rnd(blk, 16); f_rnd(blk, 24); + f_rnd(blk, 32); f_rnd(blk, 40); + i_rnd(blk, 48); i_rnd(blk, 56); + i_rnd(blk, 64); i_rnd(blk, 72); + i_rnd(blk, 80); i_rnd(blk, 88); + + out_blk[0] = bswap(blk[0]); out_blk[1] = bswap(blk[1]); + out_blk[2] = bswap(blk[2]); out_blk[3] = bswap(blk[3]); + return 0; +}; + +/* decrypt a block of text */ + +int cast256_decrypt(struct cipher_context *cx, const u8 *in, u8 *out, int size) +{ u4byte *l_key = cx->keyinfo; + u4byte *in_blk = (u4byte *)in; + u4byte *out_blk = (u4byte *)out; + u4byte t, u, blk[4]; + + blk[0] = bswap(in_blk[0]); blk[1] = bswap(in_blk[1]); + blk[2] = bswap(in_blk[2]); blk[3] = bswap(in_blk[3]); + + f_rnd(blk, 88); f_rnd(blk, 80); + f_rnd(blk, 72); f_rnd(blk, 64); + f_rnd(blk, 56); f_rnd(blk, 48); + i_rnd(blk, 40); i_rnd(blk, 32); + i_rnd(blk, 24); i_rnd(blk, 16); + i_rnd(blk, 8); i_rnd(blk, 0); + + out_blk[0] = bswap(blk[0]); out_blk[1] = bswap(blk[1]); + out_blk[2] = bswap(blk[2]); out_blk[3] = bswap(blk[3]); + return 0; +}; + +static void cast256_lock() +{ + MOD_INC_USE_COUNT; +} + +static void cast256_unlock() +{ + MOD_DEC_USE_COUNT; +} + +#define CIPHER_BITS_128 +#define CIPHER_NAME(x) cast256##x +#include "gen-cbc.h" +#include "gen-ecb.h" + +static struct cipher_implementation cast256 = { + {{NULL,NULL},CIPHER_CAST256, "cast256"}, + blocksize: 8, + ivsize: 0, + key_schedule_size: CAST256_KEY_SCHEDULE_SIZE, + key_size_mask: CIPHER_KEYSIZE_128 | CIPHER_KEYSIZE_192 | + CIPHER_KEYSIZE_256, + INIT_CIPHER_BLKOPS(cast256_ecb), + INIT_CIPHER_OPS(cast256) +}; + +static struct cipher_implementation cast256_cbc = { + {{NULL,NULL},CIPHER_CAST256 | CIPHER_CBC, "cast256-cbc"}, + blocksize: 8, + ivsize: 8, + key_schedule_size: CAST256_KEY_SCHEDULE_SIZE, + key_size_mask: CIPHER_KEYSIZE_128 | CIPHER_KEYSIZE_192 | + CIPHER_KEYSIZE_256, + INIT_CIPHER_BLKOPS(cast256_cbc), + INIT_CIPHER_OPS(cast256) +}; + + +int __init init_cast256(void) +{ + if (register_cipher(&cast256)) + printk(KERN_WARNING "Couldn't register cast256 encryption\n"); + if (register_cipher(&cast256_cbc)) + printk(KERN_WARNING "Couldn't register cast256-cbc encryption\n"); + return 0; +} + +void cleanup_cast256(void) +{ + if (unregister_cipher(&cast256)) + printk(KERN_WARNING "Couldn't unregister cast256 encryption\n"); + if (unregister_cipher(&cast256_cbc)) + printk(KERN_WARNING "Couldn't unregister cast256-cbc encryption\n"); +} + +module_init(init_cast256); +module_exit(cleanup_cast256); diff -Nru linux-2.4.0-test9-plain/crypto/cryptoapi.c linux-2.4.0-test9-int/crypto/cryptoapi.c --- linux-2.4.0-test9-plain/crypto/cryptoapi.c Thu Jan 1 01:00:00 1970 +++ linux-2.4.0-test9-int/crypto/cryptoapi.c Sun Oct 15 18:43:10 2000 @@ -0,0 +1,336 @@ +/* + * crypto/cryptoapi.c + * + * Written by Alexander Kjeldaas 1998-11-15 + * + * 2000-10-15 Harald Welte + * - ported to Linux 2.4 + * + * Copyright 1998 by Alexander Kjeldaas. Redistribution of this file + * is permitted under the GNU Public License. + */ + +#include + +#ifdef CONFIG_KMOD +#include +#endif + +#include +#include +#include +#include +#include + + +static struct proc_dir_entry *proc_crypto; + +#ifdef CONFIG_PROC_FS +static int cipher_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data); +static int digest_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data); +#endif + +LIST_HEAD(ciphers); +LIST_HEAD(digests); + +static struct transform_group transforms[MAX_TRANSFORM] = { + /* digest */ + { TRANSFORM_DIGEST, "digest", SPIN_LOCK_UNLOCKED, &digests, +#ifdef CONFIG_PROC_FS + NULL, &digest_read_proc +#endif + }, + /* cipher */ + { TRANSFORM_CIPHER, "cipher", SPIN_LOCK_UNLOCKED, &ciphers, +#ifdef CONFIG_PROC_FS + NULL, &cipher_read_proc +#endif + } +}; + +/** + * find_transform_by_id - Find transform implementation + * @id: The identifier for the transform. + * @tgroup: The identifier for the transform group the transform belongs to. + * + * Returns a ptr to the transform on success, NULL on failure. + * Valid tgroup values are: + * + * %TRANSFORM_CIPHER - When looking for ciphers + * + * %TRANSFORM_DIGEST - When looking for digests + * + * You might want to use the wrapper-functions find_cipher_by_id(int + * id), and find_digest_by_id(int id) instead of this one. + */ +struct transform_implementation * +find_transform_by_id(int id, int tgroup) +{ + struct list_head *tmp; + struct transform_group *tg; +#ifdef CONFIG_KMOD + int mod_try = 0; +retry: +#endif + if (tgroup >= MAX_TRANSFORM) + return NULL; + tg = &transforms[tgroup]; + read_lock(&tg->tg_lock); + for (tmp = tg->tg_head->next; tmp != tg->tg_head; tmp = tmp->next) { + struct transform_implementation *t; + t = list_entry(tmp, struct transform_implementation, t_list); + if (t->t_id == id) { + read_unlock(&tg->tg_lock); + return t; + } + } + read_unlock(&tg->tg_lock); +#ifdef CONFIG_KMOD + if (!mod_try) { + char module_name[50]; + mod_try = 1; + sprintf(module_name, "%s-%d", tg->tg_name, id & (~CIPHER_CBC)); + request_module(module_name); + goto retry; + } +#endif + return NULL; +} + + +/** + * find_transform_by_name - Find transform implementation + * @name: The name of the transform. + * @tgroup: The identifier for the transform group the transform belongs to. + * + * Returns a ptr to the transform on success, NULL on failure. + * Valid tgroup values are: + * + * %TRANSFORM_CIPHER - When looking for ciphers + * + * %TRANSFORM_DIGEST - When looking for digests + * + * You might want to use the wrapper-functions + * find_cipher_by_name(const char *name), and + * find_digest_by_name(const char *name) instead of this one. + */ +struct transform_implementation * +find_transform_by_name(const char *name, int tgroup) +{ + struct list_head *tmp; + struct transform_group *tg; + + if (tgroup >= MAX_TRANSFORM) + return NULL; + tg = &transforms[tgroup]; + + read_lock(&tg->tg_lock); + for (tmp = tg->tg_head->next; tmp != tg->tg_head; tmp = tmp->next) { + struct transform_implementation *t; + t = list_entry(tmp, struct transform_implementation, t_list); + if (strcmp(t->t_name, name) == 0) { + read_unlock(&tg->tg_lock); + return t; + } + } + read_unlock(&tg->tg_lock); + return NULL; +} + +/** + * register_transform - Register new transform. + * @ti: Initialized transform implementation struct. + * @tgroup: The identifier for the transform group the transform should belong to. + * + * Adds a transform from the crypto API. ti->t_group is set to point + * to the correct transform group according to tgroup, the transform + * is added to the group's transform-list, and a /proc files are + * created if CONFIG_PROC_FS=y Returns 0 on success. Valid tgroup + * values are: + * + * %TRANSFORM_CIPHER - When adding ciphers + * + * %TRANSFORM_DIGEST - When adding digests + * + */ +int register_transform(struct transform_implementation *ti, int tgroup) +{ + int err = 0; + struct transform_group *tg; + + if (tgroup >= MAX_TRANSFORM) { + return -1; + } + INIT_LIST_HEAD(&ti->t_list); + tg = ti->t_group = &transforms[tgroup]; + write_lock(&ti->t_group->tg_lock); + list_add(&ti->t_list, ti->t_group->tg_head); + write_unlock(&ti->t_group->tg_lock); + if (!err) { + char buf[200]; + sprintf(buf, "Registered %s (%d)\n", + ti->t_name, ti->t_id); + printk(buf); + + ti->t_proc = create_proc_read_entry(ti->t_name, + S_IFREG|S_IRUGO, + tg->tg_proc_parent_dir, + tg->read_proc, (void *)ti); + } + return err; +} + +/** + * unregister_transform - Unregister new transform. + * @ti: Initialized transform implementation struct. + * + * Removes a transform from the crypto API. Returns 0 on success, + * non-zero on failure to remove /proc entry. + * + */ +int unregister_transform(struct transform_implementation *ti) +{ + int ret = 0; + + if (!list_empty(&ti->t_list)) { + write_lock(&ti->t_group->tg_lock); + list_del(&ti->t_list); + write_unlock(&ti->t_group->tg_lock); + ret = 0; + } +#ifdef CONFIG_PROC_FS + if (ti->t_proc) { + ti->t_proc = NULL; + remove_proc_entry(ti->t_name, ti->t_group->tg_proc_parent_dir); + } +#endif + return ret; +} + +#ifdef CONFIG_PROC_FS +static int cipher_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct cipher_implementation *ci; + int len = 0; + + ci = (struct cipher_implementation *)data; + + len = sprintf(page, "cipher_id: %d\n" + "cipher_name: %s\n" + "blocksize: %d\n" + "keysize_mask: 0x%08x\n" + "ivsize: %d\n" + "key