summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--beecrypt/.cvsignore1
-rw-r--r--beecrypt/BENCHMARKS256
-rw-r--r--beecrypt/BUGS34
-rw-r--r--beecrypt/CONTRIBUTORS7
-rw-r--r--beecrypt/Doxyheader113
-rw-r--r--beecrypt/Makefile.am12
-rw-r--r--beecrypt/Makefile.in22
-rw-r--r--beecrypt/Makefile.mak49
-rw-r--r--beecrypt/NEWS32
-rw-r--r--beecrypt/README123
-rw-r--r--beecrypt/README.DARWIN13
-rw-r--r--beecrypt/aes.c1306
-rw-r--r--beecrypt/aes.h66
-rw-r--r--beecrypt/aesopt.h70
-rw-r--r--beecrypt/beecrypt.api.h49
-rw-r--r--beecrypt/beecrypt.c6
-rw-r--r--beecrypt/beecrypt.def17
-rw-r--r--beecrypt/beecrypt.gas.h (renamed from beecrypt/config.gas.h)64
-rw-r--r--beecrypt/beecrypt.gnu.h.in197
-rw-r--r--beecrypt/beecrypt.mcpbin75718 -> 0 bytes
-rw-r--r--beecrypt/beecrypt.win.h (renamed from beecrypt/config.win.h)5
-rw-r--r--beecrypt/blowfishopt.h8
-rw-r--r--beecrypt/config.h2
-rw-r--r--beecrypt/configure.in32
-rw-r--r--beecrypt/dsa.c163
-rw-r--r--beecrypt/endianness.c24
-rw-r--r--beecrypt/endianness.h6
-rw-r--r--beecrypt/entropy.c2
-rw-r--r--beecrypt/fips186.c24
-rw-r--r--beecrypt/fips186.h6
-rw-r--r--beecrypt/gas/Makefile.am4
-rw-r--r--beecrypt/gas/Makefile.in4
-rw-r--r--beecrypt/gas/aesopt.i586.S688
-rw-r--r--beecrypt/gas/aesopt.powerpc.S683
-rw-r--r--beecrypt/gas/blowfishopt.i586.S8
-rw-r--r--beecrypt/gas/fips180opt.ia64.S2
-rw-r--r--beecrypt/gas/fips180opt.powerpc.S2
-rw-r--r--beecrypt/gas/mp32opt.arm.S46
-rw-r--r--beecrypt/gas/mp32opt.i386.S2
-rw-r--r--beecrypt/gas/mp32opt.ia64.S2
-rw-r--r--beecrypt/gas/mp32opt.powerpc.S91
-rw-r--r--beecrypt/gas/mp32opt.sparcv8.S71
-rw-r--r--beecrypt/gas/mp32opt.sparcv9.S67
-rw-r--r--beecrypt/gas/mp64opt.ia64.S2
-rw-r--r--beecrypt/gas/sha1opt.i586.S (renamed from beecrypt/gas/fips180opt.i586.S)29
-rw-r--r--beecrypt/hmac.c92
-rw-r--r--beecrypt/hmac.h6
-rw-r--r--beecrypt/hmacmd5.c8
-rw-r--r--beecrypt/hmacmd5.h7
-rw-r--r--beecrypt/hmacsha1.c10
-rw-r--r--beecrypt/hmacsha1.h9
-rw-r--r--beecrypt/hmacsha256.c10
-rw-r--r--beecrypt/hmacsha256.h7
-rwxr-xr-xbeecrypt/installgen.sh6
-rw-r--r--beecrypt/masm/Makefile.am4
-rw-r--r--beecrypt/masm/Makefile.in4
-rw-r--r--beecrypt/masm/aesopt.i586.asm661
-rw-r--r--beecrypt/masm/sha1opt.i586.asm (renamed from beecrypt/masm/fips180opt.i586.asm)2
-rw-r--r--beecrypt/mp32.c94
-rw-r--r--beecrypt/mp32.h14
-rw-r--r--beecrypt/mp32barrett.c12
-rw-r--r--beecrypt/mp32opt.h1
-rw-r--r--beecrypt/mp32prime.c2
-rw-r--r--beecrypt/mtprng.c24
-rw-r--r--beecrypt/mtprng.h4
-rw-r--r--beecrypt/mwerks/Makefile.am2
-rw-r--r--beecrypt/mwerks/Makefile.in2
-rw-r--r--beecrypt/mwerks/sha1opt.i586.asm (renamed from beecrypt/mwerks/fips180opt.i586.asm)2
-rw-r--r--beecrypt/rsa.c69
-rw-r--r--beecrypt/sha1.c (renamed from beecrypt/fips180.c)4
-rw-r--r--beecrypt/sha1.h (renamed from beecrypt/fips180.h)8
-rw-r--r--beecrypt/sha1opt.h (renamed from beecrypt/fips180opt.h)8
-rw-r--r--beecrypt/system.h4
-rw-r--r--beecrypt/tests/.cvsignore7
-rw-r--r--beecrypt/tests/Makefile.am27
-rw-r--r--beecrypt/tests/Makefile.in185
-rw-r--r--beecrypt/tests/beetest.c114
-rw-r--r--beecrypt/tests/testdldp.c66
-rw-r--r--beecrypt/tests/testdsa.c144
-rw-r--r--beecrypt/tests/testhmacmd5.c83
-rw-r--r--beecrypt/tests/testhmacsha1.c84
-rw-r--r--beecrypt/tests/testmd5.c76
-rw-r--r--beecrypt/tests/testsha1.c66
-rw-r--r--beecrypt/tests/testsha256.c66
-rw-r--r--beecrypt/timestamp.c2
85 files changed, 5711 insertions, 695 deletions
diff --git a/beecrypt/.cvsignore b/beecrypt/.cvsignore
index 9bcac96b0..367bf34ae 100644
--- a/beecrypt/.cvsignore
+++ b/beecrypt/.cvsignore
@@ -6,6 +6,7 @@ Doxyfile
Makefile
Makefile.in
apidocs
+autom4te-*.cache
beecrypt.spec
beecrypt-*.tar.gz
config.h
diff --git a/beecrypt/BENCHMARKS b/beecrypt/BENCHMARKS
index 978ff9a08..83d1e184d 100644
--- a/beecrypt/BENCHMARKS
+++ b/beecrypt/BENCHMARKS
@@ -1,67 +1,219 @@
Note: timings are average values and may vary under different conditions, i.e. the amount of free memory, swapped memory, amount of cpu cache, etc. I've tried to make them as accurate as possible, within limits.
-Note: for block ciphers and hash functions, the test data will almost never completely fit completely in the processor cache, which give a better estimate of real world performance.
+Note: for block ciphers and hash functions, the test data will almost never completely fit completely in the processor cache, which gives a better estimate of real world performance.
-Note: on Solaris 2.7, the compiler used was the WorkShop Compiler C 4.2
-Note: on RedHat Linux 6.2, the compiler used was egcs-2.91.66
-Note: on YellowDog Linux 1.2, the compiler used was gcc-2.95.2
-Note: on Windows, the compiler used was Metrowerks CodeWarrior Pro 5
+Note: the Alpha, IA-64 and ARM systems were provided by Compaq's testdrive program; many thanks to them for giving us access to their systems. The timings on these systems are not guaranteed to be accurate; they should be treated as such.
The tests:
Modular exponentiations, (1024 bits ^ 1024 bits) mod 1024 bits, 100 times, sorted according to speed (less is better)
-BeeCrypt 0.9.5/RedHat Linux 6.2 /Pentium III 450/128 MB: 7.5 sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 450/128 MB: 7.5 sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 350/128 MB: 9.5 sec
-Java 1.2.2 /RedHat Linux 6.2 /Pentium III 450/128 MB: 11.6 sec
-BeeCrypt 1.0.0/RedHat Linux 6.1 /Pentium Pro 200/128 MB: 16.6 sec
-BeeCrypt 1.0.0/Windows NT 4.0 /Pentium Pro 200/128 MB: 17.0 sec
-Java 1.2.2 /Windows 2000 /Pentium III 450/128 MB: 22.0 sec
-Java 1.3 /Windows 2000 /Pentium III 450/128 MB: 23.5 sec
-Java 1.2.2 /Windows NT 4.0 /Pentium II 333/128 MB: 29.8 sec
-Java 1.2.2 /Windows 98 /Pentium II 333/ 64 MB: 32.7 sec
-Java 1.2.2 /Windows NT 4.0 /Pentium Pro 200/128 MB: 48.8 sec
-Java 1.2.2 /Solaris 2.7 /UltraSparc 143/128 MB: 51.1 sec
-BeeCrypt 0.9.4/Solaris 2.7 /UltraSparc 143/128 MB: 56.5 sec
-BeeCrypt 0.9.5/Yellow Dog Linux 1.2/PowerPC 601 90/ 40 MB: 88.9 sec
-
-Remarks: both on Solaris and Linux, beecrypt is least 4 times faster for this operation than a commercial product we at one time considered using.
-
-Conclusions:
-1) the assembler-optimized code in beecrypt works pretty efficient on a pentium pro and higher
-2) Sun did an excellent job on optimizing the BigInteger native library; beecrypt still needs some tuning on UltraSparc to catch up.
+Note: since this operation is where servers really hurt (i.e. in SSL), it pays to make this operation as fast as possible.
+
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 128 MB: 1.7 sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows Millenium | Athlon 1000 | 128 MB: 1.9 sec
+BeeCrypt 2.1.0 | Compaq C 6.3-025 | Tru64 Unix 5.1 | Alpha EV6.7 667 | 2 GB: 2.3 sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Pentium III 1000 | 512 MB: 2.5 sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | PIII Mobile 850 | 128 MB: 3.0 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC 7450 | : 3.3 sec
+BeeCrypt 2.0.0 | gcc-2.95.3 | Mandrake Linux 7.1 | Pentium III 800 | 4 GB: 3.3 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 3.4 sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Pentium III 600 | 256 MB: 4.3 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 4.8 sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.1 | Pentium III 450 | 128 MB: 5.7 sec
+BeeCrypt 2.0.0 | gcc-2.95.2 | Solaris 8 | Pentium III 450 | 128 MB: 5.9 sec
+BeeCrypt 2.0.0 | Forte C 6.0 | Solaris 8 | Pentium III 450 | 128 MB: 5.9 sec
+BeeCrypt 2.1.0 | gcc-2.9-ia64-000717 | Linux64 | Itanium 733 | 2 GB: 8.4 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC G3 400 | 512 MB: 8.5 sec
+BeeCrypt 2.1.0 | gcc-2.95.1 | Debian Linux 2.1 | StrongARM 110 222 | : 9.5 sec
+BeeCrypt 2.0.0 | gcc-2.9-ia64-000216 | Linux64 | Itanium 666 | 2 GB: 9.7 sec
+Java 1.4.0 | Sun Server VM | Windows 2000 | Pentium III 600 | 256 MB: 10.2 sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | LinuxPPC 2000Q4 | PowerPC 604 166 | 80 MB: 10.4 sec
+Java 1.2.2 | | RedHat Linux 6.2 | Pentium III 450 | 128 MB: 11.6 sec
+Java 1.3 | Sun Server VM | Windows 2000 | Pentium III 450 | 128 MB: 11.7 sec
+BeeCrypt 2.1.0 | gcc-2.95.2 | Solaris 8 | UltraSparc II 450 | : 12.8 sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Pentium Pro 200 | 128 MB: 13.1 sec
+BeeCrypt 2.1.0 | egcs-2.91.66 | RedHat Linux 6.2 | Pentium Pro 200 | 128 MB: 13.4 sec
+Java 1.3.1 | HotSpot Client VM | MacOS X 10.1 | PowerPC G4 | MB: 13.7 sec
+Java 1.3 | Sun Server VM | Solaris 8 | Pentium III 450 | 128 MB: 17.1 sec
+Java 1.4.0 | Sun Client VM | Windows 2000 | Pentium III 600 | 256 MB: 19.7 sec
+Java 1.2.2 | Sun Classic VM | Windows 2000 | Pentium III 450 | 128 MB: 22.0 sec
+Java 1.3 | Sun Client VM | Windows 2000 | Pentium III 450 | 128 MB: 23.5 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | SuSE Linux S/390 | IBM zSeries 633 | 128 MB: 26.5 sec
+Java 1.2.2 | Sun Classic VM | Windows NT 4.0 | Pentium II 333 | 128 MB: 29.8 sec
+Java 1.2.2 | Sun Classic VM | Windows 98 | Pentium II 333 | 64 MB: 32.7 sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (64) | Solaris 8 | UltraSparc I 143 | 128 MB: 40.7 sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | Solaris 8 | UltraSparc I 143 | 128 MB: 41.0 sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (32) | Solaris 8 | UltraSparc I 143 | 128 MB: 42.2 sec
+Java 1.2.2 | Sun Classic VM | Windows NT 4.0 | Pentium Pro 200 | 128 MB: 48.8 sec
+Java 1.2.2 | Sun Classic VM | Solaris 7 | UltraSparc I 143 | 128 MB: 51.1 sec
+Java 1.3 | Blackdown Client VM | RedHat Linux 6.2 | Pentium Pro 200 | 128 MB: 60.0 sec
+Java 1.3.1 | Sun Server VM | Solaris 8 | UltraSparc I 143 | 128 MB: 83.4 sec
+Java 1.3.1 | HotSpot Client VM | MacOS X 10.1 | PowerPC G3 400 | 512 MB: 84.6 sec
+Java 1.3 | Sun Server VM | Solaris 7 | UltraSparc I 143 | 128 MB:100.0 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2r3 | Sparc v8 70 | 64 MB:106.1 sec
+Java 1.3 | Sun Client VM | Solaris 7 | UltraSparc I 143 | 128 MB:150.0 sec
+Java 1.3 | Blackdown Client VM | YellowDog Linux 2.0 | PowerPC G3 400 | 512 MB:630.0 sec
+
+Remarks: both on Solaris and Linux, beecrypt is least 5 times faster for this operation than a commercial product we at one time considered using.
+
+Some conclusions when comparing indivual processors:
+- the assembler optimization for the Pentium family works pretty efficient; the Athlon, however, is unbeatable in this class.
+- the Alpha processor is very fast even without assembler-optimized code.
+- the ARM processor is incredibly fast with respect to its clock speed.
+- the PowerPC 604 processor is an excellent multi-precision integer cruncher with respect to its clock speed; the G3 apparently doesn't continue that line; the G4 seems faster than the G3, but slower than the 604.
+
+Some conclusions when comparing compilers:
+- Compaq's Alpha compilers produce extremely fast output for multi-precision integers; much better than gcc.
+- Microsoft Visual C++ 6 seems to be the best compiler for BeeCrypt for the PC platform, even when compared Intel's C++ compiler.
+- until the time that we have compilers better suited to Itanium's VLIW architecture, comparison of this CPU will be skewed. Better software-pipelined 64-bit routines, which will make this platform scream in comparison with the current results, is being worked on. These improvements should place Itanium at the top of the list.
+
+Some conclusions when comparing BeeCrypt's multiprecision integers to Java:
+- as of version 1.0.1 BeeCrypt now beats Java on every platform, including UltraSparc. Depending on the version of Java, BeeCrypt is from twice to four times faster.
+- with the release of the Java 1.3 client VM on Sparc, Sun has really shot themselves in the foot with the performance of modular exponentations: over three times slower than the previous version. On MacOS 10.1, modular exponentiation seems to be ten times slower than in BeeCrypt. I have no clue what Blackdown's latest Java on PowerPC is doing, but it takes about 80 times longer than BeeCrypt.
+
+It's also about time to re-implement this test, because on the fastest systems the timing is becoming inaccurate. Fixed period timing looks like the way to go (e.g. see how many we can do in one minute).
+
+RSA Signing operation (1024 bits), 100 times
+BeeCrypt 2.2.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 768 MB: 0.55 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 1.07 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Pentium III 600 | 512 MB: 1.48 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 1.51 sec
+
+RSA Verify operation (1024 bits), 100 times
+BeeCrypt 2.2.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 768 MB: 0.04 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 0.077 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Pentium III 600 | 512 MB: 0.100 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 0.110 sec
+
+DSA Signing operation (1024 bits), 100 times
+BeeCrypt 2.2.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 768 MB: 0.27 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC 7450 | : 0.55 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 0.56 sec
+BeeCrypt 2.2.0 | Visual C 6.0 | Windows 2000 | Pentium III 600 | 256 MB: 0.70 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 0.80 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC G3 400 | 512 MB: 1.39 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Solaris 8 | UltraSparc II 450 | : 2.10 sec
+BeeCrypt 2.2.0 | gcc-2.95.3 | Solaris 8 | UltraSparc I 143 | 128 MB: 6.60 sec
+
+DSA Verify operation (1024 bits), 100 times
+BeeCrypt 2.2.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 768 MB: 0.53 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC 7450 | : 1.09 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 1.11 sec
+BeeCrypt 2.2.0 | Visual C 6.0 | Windows 2000 | Pentium III 600 | 256 MB: 1.38 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 1.58 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC G3 400 | 512 MB: 3.75 sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Solaris 8 | UltraSparc II 450 | : 4.16 sec
+BeeCrypt 2.2.0 | gcc-2.95.3 | Solaris 8 | UltraSparc I 143 | 128 MB: 13.20 sec
+
Block cipher encryption (more is better)
+AES (10 rounds) ECB:
+
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 23.15 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Pentium III 600 | 512 MB: 18.18 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 16.00 MB/sec
+
+AES (12 rounds) ECB:
+
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 20.34 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Pentium III 600 | 512 MB: 15.68 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 13.56 MB/sec
+
+AES (14 rounds) ECB:
+
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Alpha EV6.7 667 | 2 GB: 18.15 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Pentium III 600 | 512 MB: 13.97 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 11.94 MB/sec
+
Blowfish ECB:
-BeeCrypt 1.0.0/Windows 2000 /Pentium III 600/256 MB: 19.70 MB/sec
-BeeCrypt 0.9.5/RedHat Linux 6.2 /Pentium III 450/128 MB: 15.10 MB/sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 450/128 MB: 14.50 MB/sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 350/128 MB: 11.25 MB/sec
-BeeCrypt 1.0.0/RedHat Linux 6.1 /Pentium Pro 200/128 MB: 6.77 MB/sec
-BeeCrypt 1.0.0/Windows NT 4.0 /Pentium Pro 200/128 MB: 6.71 MB/sec
-BeeCrypt 0.9.5/Solaris 2.7 /UltraSparc 143/128 MB: 4.37 MB/sec
-BeeCrypt 0.9.5/Yellow Dog Linux 1.2/PowerPC 601 90/ 40 MB: 2.38 MB/sec
-
-Blowfish CBC:
-BeeCrypt 1.0.0/Windows 2000 /Pentium III 600/256 MB: 19.70 MB/sec
-BeeCrypt 0.9.5/RedHat Linux 6.2 /Pentium III 450/128 MB: 14.63 MB/sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 450/128 MB: 14.50 MB/sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 350/128 MB: 11.25 MB/sec
-BeeCrypt 1.0.0/RedHat Linux 6.1 /Pentium Pro 200/128 MB: 6.72 MB/sec
-BeeCrypt 1.0.0/Windows NT 4.0 /Pentium Pro 200/128 MB: 6.71 MB/sec
-BeeCrypt 0.9.5/Solaris 2.7 /UltraSparc 143/128 MB: 4.26 MB/sec
-BeeCrypt 0.9.5/Yellow Dog Linux 1.2/PowerPC 601 90/ 40 MB: 2.19 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 128 MB: 42.00 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows Millenium | Athlon 1000 | 128 MB: 36.36 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Pentium III 1000 | 512 MB: 28.47 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.3 | Mandrake Linux 7.1 | Pentium III 800 | 4 GB: 25.00 MB/sec
+BeeCrypt 2.1.0 | Compaq C 6.3-025 | Tru64 Unix 5.1 | Alpha EV6.7 667 | 2 GB: 21.82 MB/sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.0 | Alpha EV6.7 667 | 2 GB: 18.25 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.2 | FreeBSD 4.1 | Alpha EV6 667 | 2 GB: 18.18 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | Pentium III 600 | 512 MB: 18.18 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 16.85 MB/sec
+BeeCrypt 2.1.0 | Compaq C 6.3-126 | Tru64 Unix 5.1 | Alpha EV6 500 | 2 GB: 15.48 MB/sec
+BeeCrypt 2.0.0 | Visual C 6.0 | Windows 2000 | Pentium III 450 | 128 MB: 14.60 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.2 | Solaris 8 | UltraSparc II 450 | : 12.90 MB/sec
+BeeCrypt 2.0.0 | gcc-2.9-ia64-00216 | Linux64 | Itanium 666 | 2 GB: 12.00 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | LinuxPPC 2000Q4 | PowerPC 604 166 | 80 MB: 6.25 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (32) | Solaris 8 | UltraSparc I 143 | 128 MB: 4.97 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (64) | Solaris 8 | UltraSparc I 143 | 128 MB: 3.57 MB/sec
Hash functions (more is better)
+MD5:
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 128 MB: 96.00 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows Millenium | Athlon 1000 | 128 MB: 85.00 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Pentium III 1000 | 512 MB: 73.00 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.3 | Mandrake Linux 7.1 | Pentium III 800 | 4 GB: 66.67 MB/sec
+BeeCrypt 2.0.0 | egcs-2.91.66 | RedHat Linux 6.2 | Alpha EV6.7 667 | 2 GB: 52.50 MB/sec
+BeeCrypt 2.1.0 | Compaq C 6.3-025 | Tru64 Unix 5.1 | Alpha EV6.7 667 | 2 GB: 51.90 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.2 | FreeBSD 4.1 | Alpha EV6 667 | 2 GB: 48.00 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC 7450 | : 47.00 MB/sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.0 | Alpha EV6.7 667 | 2 GB: 42.47 MB/sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.1 | Pentium III 450 | 128 MB: 39.00 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.2 | Solaris 8 | Pentium III 450 | 128 MB: 31.00 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 30.19 MB/sec
+BeeCrypt 2.0.0 | Forte C 6.0 | Solaris 8 | Pentium III 450 | 128 MB: 29.60 MB/sec
+BeeCrypt 2.1.0 | gcc-2.9-ia64-000717 | Linux64 | Itanium 733 | 2 GB: 28.67 MB/sec
+BeeCrypt 2.0.0 | gcc-2.9-ia64-000216 | Linux64 | Itanium 666 | 2 GB: 22.70 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.2 | Solaris 8 | UltraSparc II 450 | : 21.92 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.1 | Debian Linux 2.1 | StrongARM 110 222 | ?: 18.60 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | LinuxPPC 2000Q4 | PowerPC 604 166 | 80 MB: 13.91 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (64) | Solaris 8 | UltraSparc I 143 | 128 MB: 7.62 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | Solaris 8 | UltraSparc I 143 | 128 MB: 7.54 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (32) | Solaris 8 | UltraSparc I 143 | 128 MB: 7.00 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2r3 | Sparc v8 70 | 64 MB: 2.87 MB/sec
+
SHA-1:
-BeeCrypt 1.0.0/Windows 2000 /Pentium III 600/256 MB: 26.66 MB/sec
-BeeCrypt 1.0.0/RedHat Linux 6.2 /Pentium III 450/128 MB: 21.33 MB/sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 450/128 MB: 19.50 MB/sec
-BeeCrypt 1.0.0/Windows 98 /Pentium III 350/128 MB: 15.30 MB/sec
-BeeCrypt 0.9.5/RedHat Linux 6.2 /Pentium III 450/128 MB: 12.97 MB/sec
-BeeCrypt 1.0.0/RedHat Linux 6.1 /Pentium Pro 200/128 MB: 9.38 MB/sec
-BeeCrypt 1.0.0/Windows NT 4.0 /Pentium Pro 200/128 MB: 9.24 MB/sec
-BeeCrypt 0.9.5/Solaris 2.7 /UltraSparc 143/128 MB: 4.70 MB/sec
-BeeCrypt 0.9.5/Yellow Dog Linux 1.2/PowerPC 601 90/ 40 MB: 2.67 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 128 MB: 72.00 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows Millenium | Athlon 1000 | 128 MB: 62.00 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Pentium III 1000 | 512 MB: 40.50 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.3 | Mandrake Linux 7.1 | Pentium III 800 | 4 GB: 39.00 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC 7450 | : 34.80 MB/sec
+BeeCrypt 2.1.0 | Compaq C 6.3-025 | Tru64 Unix 5.1 | Alpha EV6.7 667 | 2 GB: 28.24 MB/sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.0 | Alpha EV6.7 667 | 2 GB: 27.25 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.2 | FreeBSD 4.1 | Alpha EV6 667 | 2 GB: 24.80 MB/sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.1 | Pentium III 450 | 128 MB: 22.22 MB/sec
+BeeCrypt 2.1.0 | Compaq C 6.3-126 | Tru64 Unix 5.1 | Alpha EV6 500 | 2 GB: 21.10 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 20.78 MB/sec
+BeeCrypt 2.0.0 | Visual C 6.0 | Windows 2000 | Pentium III 450 | 128 MB: 20.15 MB/sec
+BeeCrypt 2.0.0 | Forte C 6.0 | Solaris 8 | Pentium III 450 | 128 MB: 19.50 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.2 | Solaris 8 | Pentium III 450 | 128 MB: 19.50 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.2 | Solaris 8 | UltraSparc II 450 | : 16.00 MB/sec
+BeeCrypt 2.1.0 | gcc-2.9-ia64-000717 | Linux64 | Itanium 733 | 2 GB: 10.32 MB/sec
+BeeCrypt 2.0.0 | gcc-2.9-ia64-000216 | Linux64 | Itanium 666 | 2 GB: 9.60 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | LinuxPPC 2000Q4 | PowerPC 604 166 | 80 MB: 9.35 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.1 | Debian Linux 2.1 | StrongARM 110 222 | ?: 8.74 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (64) | Solaris 8 | UltraSparc I 143 | 128 MB: 5.75 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (32) | Solaris 8 | UltraSparc I 143 | 128 MB: 5.71 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | Solaris 8 | UltraSparc I 143 | 128 MB: 5.09 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2r3 | Sparc v8 70 | 64 MB: 1.47 MB/sec
+
+SHA-256:
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Athlon 1200 | 128 MB: 32.50 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | MacOS X 10.1 | PowerPC 7450 | : 28.50 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows Millenium | Athlon 1000 | 128 MB: 28.00 MB/sec
+BeeCrypt 2.1.0 | Visual C 6.0 | Windows 2000 | Pentium III 1000 | 512 MB: 23.27 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.3 | Mandrake Linux 7.1 | Pentium III 800 | 4 GB: 18.60 MB/sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.0 | Alpha EV6.7 667 | 2 GB: 18.00 MB/sec
+BeeCrypt 2.1.0 | Compaq C 6.3-025 | Tru64 Unix 5.1 | Alpha EV6.7 667 | 2 GB: 17.30 MB/sec
+BeeCrypt 2.0.0 | gcc-2.95.2 | FreeBSD 4.1 | Alpha EV6 667 | 2 GB: 17.20 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2 | PowerPC 604ev 375 | 768 MB: 14.28 MB/sec
+BeeCrypt 2.0.0 | Visual C 6.0 | Windows 2000 | Pentium III 450 | 128 MB: 10.90 MB/sec
+BeeCrypt 2.1.0 | gcc-2.96 | RedHat Linux 7.1 | Pentium III 450 | 128 MB: 10.49 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.2 | Solaris 8 | UltraSparc II 450 | : 10.00 MB/sec
+BeeCrypt 2.1.0 | gcc-2.9-ia64-000717 | Linux64 | Itanium 733 | 2 GB: 9.04 MB/sec
+BeeCrypt 2.0.0 | Forte C 6.0 | Solaris 8 | Pentium III 450 | 128 MB: 7.66 MB/sec
+BeeCrypt 2.0.0 | gcc-2.9-ia64-000216 | Linux64 | Itanium 666 | 2 GB: 7.12 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | LinuxPPC 2000Q4 | PowerPC 604 166 | 80 MB: 6.44 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.1 | Debian Linux 2.1 | StrongARM 110 222 | ?: 5.41 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (32) | Solaris 8 | UltraSparc I 143 | 128 MB: 3.66 MB/sec
+BeeCrypt 2.0.0 | Forte C++ 6.1 (64) | Solaris 8 | UltraSparc I 143 | 128 MB: 3.39 MB/sec
+BeeCrypt 2.1.0 | gcc-2.95.3 | Solaris 8 | UltraSparc I 143 | 128 MB: 3.01 MB/sec
+BeeCrypt 2.2.0 | gcc-2.95.2 | Debian Linux 2.2r3 | Sparc v8 70 | 64 MB: 0.98 MB/sec
diff --git a/beecrypt/BUGS b/beecrypt/BUGS
index 6f0370d25..e69297448 100644
--- a/beecrypt/BUGS
+++ b/beecrypt/BUGS
@@ -1,2 +1,34 @@
+Legend:
+ - = open bug
+ * = fixed bug
+
+2.2.0:
+ * bug in certain instances of computing modular inverse.
+ * incorrectly translated intel-style assembler version of x86 mp32odd and mp32even routines into gnu assembler format.
+ * base64 decoding of '+' and '/' characters is wrong.
+ * incorrect testing of the result of the gcd operation in mp32prndconone.
+ * Chinese Remainer Theorem for RSA private key operation doesn't work
+
+2.1.0:
+ * Entropy gathering from /dev/dsp contained error; size in words of entropy data to gather was overwritten with audio sample size - which resulted in much less entropy.
+
+2.0.0:
+ - Chinese Remainder Theorem for RSA private key operation doesn't work; it needs fixing.
+
+1.1.2:
+ * SHA-1 i586 assembler code uses local variables below the current stack frame.
+
+1.1.1:
+ * discrete logarithm domain parameter generator calculations contains bugs - was detected in this release but present since the first release.
+
+1.1.0:
+ * The javaglue produces a NullPointerException when initializing with a null IV; this should be treated correctly, i.e. as an all zero IV.
+
+1.0.2:
+
+1.0.1:
+ * The Windows 2000 bug is still around
+
1.0.0:
- - On Windows 2000, the entropy system gets error WAVERR_BADFORMAT in waveInOpen; So far I've been unable to determine why the system does this for format WAVE_FORMAT_PCM. Suggestions to fix this problem are more than welcome.
+ * On Windows 2000, the entropy system gets error WAVERR_BADFORMAT in waveInOpen; So far I've been unable to determine why the system does this for format WAVE_FORMAT_PCM. Suggestions to fix this problem are more than welcome.
+ * The assembler code for SHA-1 in gnu/fips180opt.gas.i586.s contains bugs.
diff --git a/beecrypt/CONTRIBUTORS b/beecrypt/CONTRIBUTORS
index 8f759edf5..250bd530c 100644
--- a/beecrypt/CONTRIBUTORS
+++ b/beecrypt/CONTRIBUTORS
@@ -5,8 +5,9 @@ I would like to thank the following contributors to BeeCrypt:
- SourceForge, for their excellent open source development platform, including their compile farm.
- Luca Filipozzi, for packaging BeeCrypt for the Debian GNU/Linux distribution.
-And last but not least:
+Active developers on SourceForge:
+- Jan-Rudolph Bührmann
+And last but not least:
- Jon Sturgeon, bug hunter extraordinaire.
-
-
+- Jeff Johnson, author of the RedHat Package Manager.
diff --git a/beecrypt/Doxyheader b/beecrypt/Doxyheader
index efc2e1034..62ca15fba 100644
--- a/beecrypt/Doxyheader
+++ b/beecrypt/Doxyheader
@@ -1,109 +1,112 @@
-/*! \mainpage beecrypt API Documentation.
-The structures in the library are geared towards exchange with Java
-and its security and cryptography classes. This library can also be
-accessed from Java by installing BeeCrypt for Java, a JCE 1.2 crypto
-provider and the counterpart of this library.
-
+/*! \mainpage BeeCrypt API Documentation.
Included in the library are:
- entropy sources for initializing pseudo-random generators
- pseudo-random generators: FIPS-186, Mersenne Twister
- - block ciphers: Blowfish
+ - block ciphers: AES, Blowfish
- hash functions: MD5, SHA-1, SHA-256
- - keyed hash functions: MD5/HMAC, SHA-1/HMAC, SHA-256/HMAC
+ - keyed hash functions: HMAC-MD5, HMAC-SHA-1, HMAC-SHA-256
- multi-precision integer library, with assembler-optimized routines
- for several processors
+ for several processors
- probabilistic primality testing, with optimized small prime trial
- division
+ division
- discrete logarithm parameter generation over a prime field
- Diffie-Hellman key agreement
+ - DSA signature scheme
- ElGamal signature scheme (two variants)
- - RSA keypair generation with chinese remainder theorem variables
- - RSA public & private key operations
- - DHAES encryption scheme
+ - RSA keypair generation with chinese remainder theorem variables
+ - RSA public & private key operations
+ - DHAES encryption scheme
Planned for the near future are:
+ - mp64 library for operation on 64-bit computers (and possibly also
+ on certain 32-bit platforms)
- compliance with and compliance statements for IEEE P1363
- - DSA (i.e. the rest of FIPS-186)
- - more blockciphers (Rijndael a.k.a AES, Twofish, ... )
- - more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger)
- - Elliptic Curves (ECDSA, ... )
+ - more blockciphers (Twofish, ... )
+ - more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger)
+ - RSA signatures as specified by RFC-2440.
+ - Elliptic Curves (ECDSA, ... )
+ - more blockcipher modes (OFB, ... )
The library has been tested on the following platforms:
- FreeBSD 4.0 alpha
- FreeBSD 4.0, 4.2 x86
- - includes assembler optimization (tuned for Pentium and higher)
+ - includes assembler optimization (tuned for Pentium and higher)
- Linux glibc 2.x alpha
- Linux glibc 2.x arm
- - includes assembler optimization
+ - includes assembler optimization
- Linux glibc 2.x ppc
- - includes assembler optimization (for generic 32-bit PowerPC)
- - Linux glibc 2.x sparc
- - includes assembler optimization for sparc v8
+ - includes assembler optimization for 32-bit PowerPC
+ - Linux glibc 2.x sparc
+ - includes assembler optimization for Sparc v8
- Linux glibc 2.x x86
- - includes assembler optimization (tuned for Pentium and higher)
+ - includes assembler optimization (tuned for Pentium and higher)
- Solaris 2.6/2.7/2.8 sparc (with Forte or gnu compilers)
- - includes assembler optimization for sparc v8, v8plus and v9
+ - includes assembler optimization for Sparc v8, v8plus and v9
- Solaris 2.7/2.8 x86 (with Forte or gnu compilers)
- - includes assembler optimization (tuned for Pentium and higher)
+ - includes assembler optimization (tuned for Pentium and higher)
- Tru64 Unix alpha
- Win32 (Windows 95, 98, NT 4.0, 2000)
- - includes assembler optimization (tuned for Pentium and higher)
+ - includes assembler optimization (tuned for Pentium and higher)
The library is currently in the process of being ported to:
- - Cygwin (the DLL builds now, but needs to be tested)
- - Darwin (Darwin 1.2 doesn't seem to run on our PowerMac 7300/166,
- and 1.0.2 was flaky, so any volunteer effort would be appreciated)
- - QNX (I currently don't have a testing system anymore)
+ - Darwin (apparently Apple has decided to change the PPC assembler format;
+ this will need a fix)
+ - Cygwin (the DLL builds now, but needs to be tested)
+
*/
-/** \defgroup ES_m Entropy sources
+/*! \defgroup ES_m Entropy sources
+ */
+/*! \defgroup ES_audio_m Entropy sources: /dev/audio
+ */
+/*! \defgroup ES_dsp_m Entropy sources: /dev/dsp
*/
-/** \defgroup ES_audio_m Entropy sources: /dev/audio
+/*! \defgroup ES_random_m Entropy sources: /dev/random
*/
-/** \defgroup ES_dsp_m Entropy sources: /dev/dsp
+/*! \defgroup ES_urandom_m Entropy sources: /dev/urandom
*/
-/** \defgroup ES_random_m Entropy sources: /dev/random
+/*! \defgroup ES_tty_m Entropy sources: /dev/tty
*/
-/** \defgroup ES_urandom_m Entropy sources: /dev/urandom
+/*! \defgroup PRNG_m Pseudo-Random Number Generators
*/
-/** \defgroup ES_tty_m Entropy sources: /dev/tty
+/*! \defgroup PRNG_fips186_m Pseudo-Random Number Generators: FIPS-186
*/
-/** \defgroup PRNG_m Pseudo-Random Number Generators
+/*! \defgroup HASH_m Hash Functions
*/
-/** \defgroup PRNG_fips186_m Pseudo-Random Number Generator: FIPS-186
+/*! \defgroup HASH_md5_m Hash Functions: MD5
*/
-/** \defgroup HASH_m Hash Functions
+/*! \defgroup HASH_sha1_m Hash Functions: SHA-1
*/
-/** \defgroup HASH_md5_m Hash Functions: md5
+/*! \defgroup HASH_sha256_m Hash Functions: SHA-256
*/
-/** \defgroup HASH_sha1_m Hash Functions: sha1
+/*! \defgroup HMAC_m Keyed Hash Functions, a.k.a. Message Authentication Codes
*/
-/** \defgroup HASH_sha256_m Hash Functions: sha256
+/*! \defgroup HMAC_md5_m Keyed Hash Functions: HMAC-MD5
*/
-/** \defgroup HMAC_m Keyed Hash Functions, a.k.a. Message Authentication Codes
+/*! \defgroup HMAC_sha1_m Keyed Hash Functions: HMAC-SHA-1
*/
-/** \defgroup HMAC_md5_m Keyed Hash Functions: md5
+/*! \defgroup HMAC_sha256_m Keyed Hash Functions: HMAC-SHA-256
*/
-/** \defgroup HMAC_sha1_m Keyed Hash Functions: sha1
+/*! \defgroup BC_m Block ciphers
*/
-/** \defgroup HMAC_sha256_m Keyed Hash Functions: sha256
+/*! \defgroup BC_aes_m Block ciphers: AES
*/
-/** \defgroup BC_m Block ciphers
+/*! \defgroup BC_blowfish_m Block ciphers: Blowfish
*/
-/** \defgroup BC_blowfish_m Block ciphers: Blowfish
+/*! \defgroup DL_m Discrete Logarithm Primitives
*/
-/** \defgroup RSA_m RSA Encryption/Signature Primitives
+/*! \defgroup DH_m Diffie-Hellman Primitives
*/
-/** \defgroup DSA_m DSA Encryption/Signature Primitives
+/*! \defgroup DSA_m DSA Encryption/Signature Primitives
*/
-/** \defgroup ELGAMAL_m ElGamal Signature Primitives
+/*! \defgroup RSA_m RSA Encryption/Signature Primitives
*/
-/** \defgroup DH_m Diffie-Hellman Encryption
+/*! \defgroup ELGAMAL_m ElGamal Signature Primitives
*/
-/** \defgroup DL_m Discrete Logartithms
+/*! \defgroup MP32_m Multiple Precision Integer Arithmetic (32 bit)
*/
-/** \defgroup MP_m Multiple Precision Integer Arithmetic
+/*! \defgroup MP64_m Multiple Precision Integer Arithmetic (64 bit)
*/
-/** \defgroup JAVA_m Java API
+/*! \defgroup JAVA_m Java API
*/
diff --git a/beecrypt/Makefile.am b/beecrypt/Makefile.am
index b57115cc6..66443c780 100644
--- a/beecrypt/Makefile.am
+++ b/beecrypt/Makefile.am
@@ -1,7 +1,7 @@
#
# Makefile.am contains the top-level automake definitions
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -40,23 +40,23 @@ SUFFIXES = .S
.S.lo:
$(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
-BEECRYPT_OBJECTS = base64.lo beecrypt.lo blockmode.lo blockpad.lo blowfish.lo blowfishopt.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo fips180.lo fips180opt.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo md5.lo memchunk.lo mp32.lo mp32barrett.lo mp32number.lo mp32opt.lo mp32prime.lo mtprng.lo rsa.lo rsakp.lo rsapk.lo sha256.lo timestamp.lo
+BEECRYPT_OBJECTS = aes.lo aesopt.lo base64.lo beecrypt.lo blockmode.lo blockpad.lo blowfish.lo blowfishopt.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo md5.lo memchunk.lo mp32.lo mp32barrett.lo mp32number.lo mp32opt.lo mp32prime.lo mtprng.lo rsa.lo rsakp.lo rsapk.lo sha1.lo sha1opt.lo sha256.lo timestamp.lo
BEECRYPT_JAVA_OBJECTS = javaglue.lo
lib_LTLIBRARIES = libbeecrypt.la
-libbeecrypt_la_SOURCES = base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips180.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c javaglue.c md5.c memchunk.c mp32.c mp32barrett.c mp32number.c mp32prime.c mtprng.c rsa.c rsakp.c rsapk.c sha256.c timestamp.c
+libbeecrypt_la_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c javaglue.c md5.c memchunk.c mp32.c mp32barrett.c mp32number.c mp32prime.c mtprng.c rsa.c rsakp.c rsapk.c sha1.c sha256.c timestamp.c
libbeecrypt_la_DEPENDENCIES = $(BEECRYPT_OBJECTS) $(BEECRYPT_JAVA_OBJECTS)
-libbeecrypt_la_LIBADD = blowfishopt.lo fips180opt.lo mp32opt.lo
+libbeecrypt_la_LIBADD = aesopt.lo blowfishopt.lo mp32opt.lo sha1opt.lo
libbeecrypt_la_LDFLAGS = -version-info $(LIBBEECRYPT_LT_CURRENT):$(LIBBEECRYPT_LT_REVISION):$(LIBBEECRYPT_LT_AGE)
-pkginclude_HEADERS = base64.h beecrypt.h blockmode.h blockpad.h blowfish.h blowfishopt.h dhaes.h dldp.h dlkp.h dlpk.h dlsvdp-dh.h dsa.h elgamal.h endianness.h entropy.h fips180.h fips180opt.h fips186.h hmac.h hmacmd5.h hmacsha1.h hmacsha256.h md5.h memchunk.h mp32.h mp32barrett.h mp32number.h mp32opt.h mp32prime.h mtprng.h rsa.h rsakp.h rsapk.h sha256.h timestamp.h
+pkginclude_HEADERS = aes.h aesopt.h base64.h beecrypt.h beecrypt.api.h beecrypt.win.h blockmode.h blockpad.h blowfish.h blowfishopt.h dhaes.h dldp.h dlkp.h dlpk.h dlsvdp-dh.h dsa.h elgamal.h endianness.h entropy.h fips186.h hmac.h hmacmd5.h hmacsha1.h hmacsha256.h md5.h memchunk.h mp32.h mp32barrett.h mp32number.h mp32opt.h mp32prime.h mtprng.h rsa.h rsakp.h rsapk.h sha1.h sha1opt.h sha256.h timestamp.h
-EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS Doxyfile.in Doxyheader README.DLL README.WIN32 beecrypt.def beecrypt.mcp beecrypt.rc beecrypt.spec types.h config.gas.h config.win.h javaglue.h
+EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS Doxyfile.in Doxyheader README README.DARWIN README.DLL README.WIN32 beecrypt.def beecrypt.rc beecrypt.spec types.h javaglue.h installgen.sh
noinst_HEADERS = debug.h system.h
diff --git a/beecrypt/Makefile.in b/beecrypt/Makefile.in
index 9fd8e3efc..0cfa9fb6f 100644
--- a/beecrypt/Makefile.in
+++ b/beecrypt/Makefile.in
@@ -17,7 +17,7 @@
#
# Makefile.am contains the top-level automake definitions
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -143,23 +143,23 @@ SUBDIRS = docs gas masm mwerks tests
SUFFIXES = .S
-BEECRYPT_OBJECTS = base64.lo beecrypt.lo blockmode.lo blockpad.lo blowfish.lo blowfishopt.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo fips180.lo fips180opt.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo md5.lo memchunk.lo mp32.lo mp32barrett.lo mp32number.lo mp32opt.lo mp32prime.lo mtprng.lo rsa.lo rsakp.lo rsapk.lo sha256.lo timestamp.lo
+BEECRYPT_OBJECTS = aes.lo aesopt.lo base64.lo beecrypt.lo blockmode.lo blockpad.lo blowfish.lo blowfishopt.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo md5.lo memchunk.lo mp32.lo mp32barrett.lo mp32number.lo mp32opt.lo mp32prime.lo mtprng.lo rsa.lo rsakp.lo rsapk.lo sha1.lo sha1opt.lo sha256.lo timestamp.lo
BEECRYPT_JAVA_OBJECTS = javaglue.lo
lib_LTLIBRARIES = libbeecrypt.la
-libbeecrypt_la_SOURCES = base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips180.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c javaglue.c md5.c memchunk.c mp32.c mp32barrett.c mp32number.c mp32prime.c mtprng.c rsa.c rsakp.c rsapk.c sha256.c timestamp.c
+libbeecrypt_la_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c javaglue.c md5.c memchunk.c mp32.c mp32barrett.c mp32number.c mp32prime.c mtprng.c rsa.c rsakp.c rsapk.c sha1.c sha256.c timestamp.c
libbeecrypt_la_DEPENDENCIES = $(BEECRYPT_OBJECTS) $(BEECRYPT_JAVA_OBJECTS)
-libbeecrypt_la_LIBADD = blowfishopt.lo fips180opt.lo mp32opt.lo
+libbeecrypt_la_LIBADD = aesopt.lo blowfishopt.lo mp32opt.lo sha1opt.lo
libbeecrypt_la_LDFLAGS = -version-info $(LIBBEECRYPT_LT_CURRENT):$(LIBBEECRYPT_LT_REVISION):$(LIBBEECRYPT_LT_AGE)
-pkginclude_HEADERS = base64.h beecrypt.h blockmode.h blockpad.h blowfish.h blowfishopt.h dhaes.h dldp.h dlkp.h dlpk.h dlsvdp-dh.h dsa.h elgamal.h endianness.h entropy.h fips180.h fips180opt.h fips186.h hmac.h hmacmd5.h hmacsha1.h hmacsha256.h md5.h memchunk.h mp32.h mp32barrett.h mp32number.h mp32opt.h mp32prime.h mtprng.h rsa.h rsakp.h rsapk.h sha256.h timestamp.h
+pkginclude_HEADERS = aes.h aesopt.h base64.h beecrypt.h beecrypt.api.h beecrypt.win.h blockmode.h blockpad.h blowfish.h blowfishopt.h dhaes.h dldp.h dlkp.h dlpk.h dlsvdp-dh.h dsa.h elgamal.h endianness.h entropy.h fips186.h hmac.h hmacmd5.h hmacsha1.h hmacsha256.h md5.h memchunk.h mp32.h mp32barrett.h mp32number.h mp32opt.h mp32prime.h mtprng.h rsa.h rsakp.h rsapk.h sha1.h sha1opt.h sha256.h timestamp.h
-EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS Doxyfile.in Doxyheader README.DLL README.WIN32 beecrypt.def beecrypt.mcp beecrypt.rc beecrypt.spec types.h config.gas.h config.win.h javaglue.h
+EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS Doxyfile.in Doxyheader README README.DARWIN README.DLL README.WIN32 beecrypt.def beecrypt.rc beecrypt.spec types.h javaglue.h installgen.sh
noinst_HEADERS = debug.h system.h
@@ -171,13 +171,13 @@ CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = Doxyfile beecrypt.spec types.h
LTLIBRARIES = $(lib_LTLIBRARIES)
-am_libbeecrypt_la_OBJECTS = base64.lo beecrypt.lo blockmode.lo \
+am_libbeecrypt_la_OBJECTS = aes.lo base64.lo beecrypt.lo blockmode.lo \
blockpad.lo blowfish.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo \
dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo \
- fips180.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo \
- hmacsha256.lo javaglue.lo md5.lo memchunk.lo mp32.lo \
- mp32barrett.lo mp32number.lo mp32prime.lo mtprng.lo rsa.lo \
- rsakp.lo rsapk.lo sha256.lo timestamp.lo
+ fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo \
+ javaglue.lo md5.lo memchunk.lo mp32.lo mp32barrett.lo \
+ mp32number.lo mp32prime.lo mtprng.lo rsa.lo rsakp.lo rsapk.lo \
+ sha1.lo sha256.lo timestamp.lo
libbeecrypt_la_OBJECTS = $(am_libbeecrypt_la_OBJECTS)
DEFS = @DEFS@
diff --git a/beecrypt/Makefile.mak b/beecrypt/Makefile.mak
index 5ba22e6ad..fe238cae8 100644
--- a/beecrypt/Makefile.mak
+++ b/beecrypt/Makefile.mak
@@ -4,7 +4,7 @@
# To be used with Microsoft's nmake utility;
# Will need the Visual C Processor Pack installed.
#
-# Copyright (c) 2000, 2001 Virtual Unlimited B.V.
+# Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -28,9 +28,6 @@ CC=cl.exe
LD=link.exe
RC=rc.exe
-DEFS= \
- win32/beecrypt.def
-
LIBS= \
advapi32.lib \
gdi32.lib \
@@ -39,17 +36,19 @@ LIBS= \
winmm.lib
LIBPATH="C:\Program Files\Microsoft Visual Studio\VC98\Lib"
-JAVAPATH="C:\jdk1.3\include"
+JAVAPATH="C:\j2sdk1.4.0\include"
ASFLAGS=/nologo /c /coff /Gd
-CFLAGS=/nologo /TC /MT /GD /Ox /G5 /DHAVE_CONFIG_H /I.
-LDFLAGS=/nologo /machine:IX86 /libpath:$(LIBPATH) $(LIBS)
+CFLAGS=/nologo /TC /MT /GD /GM /Ox /G5 /I. # /ZI
+LDFLAGS=/nologo /machine:IX86 /libpath:$(LIBPATH) $(LIBS) # /DEBUG
RCFLAGS=/r /L 0x409 /FObeecrypt.res
JAVAFLAGS=/DJAVAGLUE=1 /I$(JAVAPATH) /I$(JAVAPATH)\win32
OBJECTS= \
- base64.obj \
+ aes.obj \
+ aesopt.obj \
+ base64.obj \
beecrypt.obj \
blockmode.obj \
blockpad.obj \
@@ -60,11 +59,10 @@ OBJECTS= \
dlkp.obj \
dlpk.obj \
dlsvdp-dh.obj \
+ dsa.obj \
elgamal.obj \
endianness.obj \
entropy.obj \
- fips180.obj \
- fips180opt.obj \
fips186.obj \
hmac.obj \
hmacmd5.obj \
@@ -72,6 +70,7 @@ OBJECTS= \
hmacsha256.obj \
javaglue.obj \
md5.obj \
+ memchunk.obj \
mp32.obj \
mp32opt.obj \
mp32barrett.obj \
@@ -81,37 +80,41 @@ OBJECTS= \
rsa.obj \
rsakp.obj \
rsapk.obj \
+ sha1.obj \
+ sha1opt.obj \
sha256.obj \
timestamp.obj \
- beecrypt.dll.obj \
beecrypt.res
all: .\beecrypt.dll .\beetest.exe
beecrypt.dll: $(OBJECTS)
- $(LD) $(LDFLAGS) $(OBJECTS) /dll /def:$(DEFS) /out:beecrypt.dll /implib:beecrypt.lib
+ $(LD) $(LDFLAGS) $(OBJECTS) /dll /def:beecrypt.def /out:beecrypt.dll /implib:beecrypt.lib
+
+beetest.obj: tests\beetest.c
+ $(CC) $(CFLAGS) /Fobeetest.obj /c tests\beetest.c
beetest.exe: beecrypt.lib beetest.obj
$(LD) $(LDFLAGS) beetest.obj beecrypt.lib
-beecrypt.dll.obj: win32/beecrypt.dll.c
- $(CC) $(CFLAGS) /c win32/beecrypt.dll.c
-
-beecrypt.res: win32/beecrypt.rc
- $(RC) $(RCFLAGS) win32/beecrypt.rc
+beecrypt.res: beecrypt.rc
+ $(RC) $(RCFLAGS) beecrypt.rc
javaglue.obj: javaglue.c
$(CC) $(CFLAGS) $(JAVAFLAGS) /c javaglue.c
-blowfishopt.obj: win32/masm/blowfishopt.i586.asm
- $(AS) $(ASFLAGS) /Foblowfishopt.obj /c win32/masm/blowfishopt.i586.asm
+aesopt.obj: masm\aesopt.i586.asm
+ $(AS) $(ASFLAGS) /Foaesopt.obj /c masm\aesopt.i586.asm
+
+blowfishopt.obj: masm\blowfishopt.i586.asm
+ $(AS) $(ASFLAGS) /Foblowfishopt.obj /c masm\blowfishopt.i586.asm
-fips180opt.obj: win32/masm/fips180opt.i586.asm
- $(AS) $(ASFLAGS) /Fofips180opt.obj /c win32/masm/fips180opt.i586.asm
+sha1opt.obj: masm\sha1opt.i586.asm
+ $(AS) $(ASFLAGS) /Fosha1opt.obj /c masm\sha1opt.i586.asm
-mp32opt.obj: win32/masm/mp32opt.i386.asm
- $(AS) $(ASFLAGS) /Fomp32opt.obj /c win32/masm/mp32opt.i386.asm
+mp32opt.obj: masm\mp32opt.i386.asm
+ $(AS) $(ASFLAGS) /Fomp32opt.obj /c masm\mp32opt.i386.asm
clean:
del *.obj
diff --git a/beecrypt/NEWS b/beecrypt/NEWS
index 3bcd562e6..a6ba3b17f 100644
--- a/beecrypt/NEWS
+++ b/beecrypt/NEWS
@@ -1,3 +1,31 @@
+2.2.0:
+ - Modified the header files so that the library now uses self-contained autoconf-generated configuration files; a program employing BeeCrypt can now use the symbols already tested and defined instead of having to regenerate them (thus also eliminating the risk of inconsistencies).
+ - Added the AES algorithm, with assembler routines for i586 and powerpc.
+ - Added the DSA signature algorithm.
+ - Added powerpc assembler routines for blowfish.
+ - Fixed the RSA CRT algorithm.
+ - Fixed the gas/i386 mp32even and mp32odd routines.
+ - Fixed a bug in modular inverse computation; thanks to Jeff Johnson of RedHat for pointing this out.
+ - Fixed a bug in testing the result of a gcd operation in the mp32prndconone routine.
+ - Fixed an ugly bug in base64 decoding.
+ - Fixed compatibility with the latest automake & autoconf versions.
+
+2.1.0:
+ - Added support for automake, autoheader and libtool, which should make compiling the library even easier.
+ - Changed DHAES API to conform to IEEE P.1363 submission and to allow for uneven key splitting.
+ - Improved PKCS#5 padding routines.
+ - Added a hash reset to the hashFunctionContextInit function. This was pointed out by Marko Kreen.
+ - Fixed problem with configuring on i486-pc-linux-gnu. This was pointed out Steve O'Neill.
+ - Fixed problem in the C version of mp32sub where carry would sometimes be missed. This was pointed out by Jon Sturgeon.
+ - Revised entropy gathering system to do timeouts & asynchronous I/O where possible, to avoid hangs in case there's no noise on the audio device (i.e. digital silence), or when no data is available on devices such as /dev/random.
+ - Changed mp32opt i386 assembler routines for slight performance improvement.
+ - Changed mp32opt powerpc assembler routines for slight performance improvement.
+ - Changed mp32opt sparcv9 assembler routines for slight performance improvement.
+ - Added sparcv8 assembler routines for multi-precision integer multiplication.
+ - Added arm assembler routines for multi-precision integer multiplication.
+ - Added prototype 64-bit ia64 assembler routines for multi-precision integer operations.
+ - Started writing the long-awaited documentation.
+
2.0.0:
- Changed mp32barrett struct and operations to be multithread-safe; this required a change in API.
- Changed hashFunction struct to incorporate internal block size parameter.
@@ -9,7 +37,7 @@
- Added RSA keypair generation.
- Added RSA private & public key operations.
- Added SHA-256 hash function.
- - Added HMAC/MD5 and HMAC/SHA-256 keyed hash functions.
+ - Added HMAC-MD5 and HMAC-SHA-256 keyed hash functions.
- Added PKCS#5 padding.
- Added DHAES encryption scheme.
- Added Microsoft Visual C support, added Makefile.mak for this purpose.
@@ -28,7 +56,7 @@
1.1.1:
- Changed autoconfig script for easier porting.
- Changed sources for easier compilation on Microsoft Visual C++; no assembler-optimization on this platform yet.
- _ Fixed bug in javaglue when passing null IV to blockcipher.
+ - Fixed bug in javaglue when passing null IV to blockcipher.
- Shared library is now linked dynamically, with shared object name and version.
- Tested on Alpha Linux.
- Tested on Alpha FreeBSD.
diff --git a/beecrypt/README b/beecrypt/README
index 835bf9cd2..12221f103 100644
--- a/beecrypt/README
+++ b/beecrypt/README
@@ -1,6 +1,6 @@
Welcome to the BeeCrypt crypto library!
-Copyright (c) 1997-2000 Virtual Unlimited B.V.
+Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
Author: Bob Deblier <bob@virtualunlimited.com>
@@ -18,26 +18,37 @@ You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-For the specifics of this license, see file 'LICENSE', included in this
-distribution.
+For the specifics of this license, see file 'COPYING.LIB', included in
+this distribution.
+
+
+
+Welcome to version 2.2.0 of BeeCrypt:
+
+AES support has been added, and the library has been thoroughly debugged,
+with the addition of unit tests. Once you've built the library, you can
+verify the correct functioning with 'make check'.
+
+As usual, your comments are welcome.
About BeeCrypt:
-This library is an ongoing project of Virtual Unlimited B.V. Its goal is to
-provide strong and fast cryptography for use by our products, but we're
-not limiting the use to that. We're releasing it under the LGPL license,
-because we feel that cryptography should be open to inspection by everybody,
-and available for use by everybody to safeguard privacy.
+This library is an ongoing project of Virtual Unlimited B.V. Its goal is
+to provide strong and fast cryptography for use by our products, but
+we're not limiting the use to that. We're releasing it under the LGPL
+license, because we feel that cryptography should be open to inspection
+by everybody, and available for use by everybody to safeguard privacy.
+
+Note that depending on where you are, the use of cryptography may be
+limited or forbidden by law. Before using this library, make sure you
+are legally entitled to do so.
-Note that depending on where you are, the use of cryptography may be limited
-or forbidden by law. Before using this library, make sure you are legally
-entitled to do so.
-For more on Virtual Unlimited B.V. and our products please consult our website:
+For more on Virtual Unlimited B.V. and our products please consult our
+website: http://www.virtualunlimited.com/
-http://www.virtualunlimited.com
<plug>
Most of the algorithms are implemented from reliable sources such as:
@@ -50,60 +61,82 @@ Most of the algorithms are implemented from reliable sources such as:
Bruce Schneier
Wiley
+
For crypto enthusiasts these books are invaluable background material.
-IEEE P1363 "Standard Specifications for Public Key Cryptography" is a very
-interesting draft standard, which we will try to comply with.
+IEEE P1363 "Standard Specifications for Public Key Cryptography" is a
+very interesting draft standard, which we will try to comply with.
</plug>
The structures in the library are geared towards exchange with Java
-and its security and cryptography classes. We already have quite a number
-of cryptographic classes developed in Java, which will be released in the
-future in another open source project.
+and its security and cryptography classes. This library can also be
+accessed from Java by installing BeeCrypt for Java, a JCE 1.2 crypto
+provider and the counterpart of this library.
+
Included in the library are:
- entropy sources for initializing pseudo-random generators
- pseudo-random generators: FIPS-186, Mersenne Twister
- - block ciphers: Blowfish
- - hash functions: SHA-1
- - keyed hash functions: SHA-1/HMAC
+ - block ciphers: AES, Blowfish
+ - hash functions: MD5, SHA-1, SHA-256
+ - keyed hash functions: HMAC-MD5, HMAC-SHA-1, HMAC-SHA-256
- multi-precision integer library, with assembler-optimized routines
- - probabilistic primality testing, with optimized small prime trial division
+ for several processors
+ - probabilistic primality testing, with optimized small prime trial
+ division
- discrete logarithm parameter generation over a prime field
- Diffie-Hellman key agreement
+ - DSA signature scheme
- ElGamal signature scheme (two variants)
+ - RSA keypair generation with chinese remainder theorem variables
+ - RSA public & private key operations
+ - DHAES encryption scheme
Planned for the near future are:
+ - mp64 library for operation on 64-bit computers (and possibly also
+ on certain 32-bit platforms)
- compliance with and compliance statements for IEEE P1363
- - DHAES
- - DSA (i.e. the rest of FIPS-186)
- - more blockciphers (Twofish, Rijndael, ... )
- - more hash functions (RIPEMD-160, HAVAL, ... )
+ - more blockciphers (Twofish, ... )
+ - more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger)
+ - RSA signatures as specified by RFC-2440.
- Elliptic Curves (ECDSA, ... )
+ - more blockcipher modes (OFB, ... )
The library has been tested on the following platforms:
- - Solaris 2.6 Sparc, Solaris 2.7 Sparc
- - includes assembler optimization for ultrasparc
- - Linux glibc 2.x x86
- - includes assembler optimization (tuned for Pentium Pro and higher)
+ - FreeBSD 4.0 alpha
+ - FreeBSD 4.0, 4.2 x86
+ - includes assembler optimization (tuned for Pentium and higher)
+ - Linux glibc 2.x alpha
+ - Linux glibc 2.x arm
+ - includes assembler optimization
- Linux glibc 2.x ppc
- - includes assembler optimization (generic 32-bit PowerPC)
- - Win32 (Windows 95, 98, NT 4.0)
- - includes assembler optimization (tuned for Pentium Pro and higher)
- - once the entropy provider bug is fixed (see BUGS), the library should
- work fine on Windows 2000.
-Planned platforms for the near future are:
- - Solaris Intel
- - FreeBSD x86
-
-Consult file 'DOCUMENTATION' on how to use the library. There is also a program
-called 'beetest.c' included which gives an example of how to use the API. You
-can also use it to test whether your compiled library works.
+ - includes assembler optimization for 32-bit PowerPC
+ - Linux glibc 2.x sparc
+ - includes assembler optimization for Sparc v8
+ - Linux glibc 2.x x86
+ - includes assembler optimization (tuned for Pentium and higher)
+ - Solaris 2.6/2.7/2.8 sparc (with Forte or gnu compilers)
+ - includes assembler optimization for Sparc v8, v8plus and v9
+ - Solaris 2.7/2.8 x86 (with Forte or gnu compilers)
+ - includes assembler optimization (tuned for Pentium and higher)
+ - Tru64 Unix alpha
+ - Win32 (Windows 95, 98, NT 4.0, 2000)
+ - includes assembler optimization (tuned for Pentium and higher)
+
+The library is currently in the process of being ported to:
+ - Darwin (apparently Apple has decided to change the PPC assembler format;
+ this will need a fix)
+ - Cygwin (Can't seem to get the DLL to build properly with the current version of the autotools)
+
+For more information, refer to the HTML documentation in the docs directory.
If you want to report bugs, make suggestions, contribute fixes or
-enhancements, please see our website: http://beecrypt.virtualunlimited.com
-or contact me at beecrypt@virtualunlimited.com
+enhancements, please see the beecrypt-specific website:
+
+http://beecrypt.virtualunlimited.com/
+
+or contact me at mailto:beecrypt@virtualunlimited.com
-Sincerely
+Sincerely,
Bob Deblier
diff --git a/beecrypt/README.DARWIN b/beecrypt/README.DARWIN
new file mode 100644
index 000000000..aea52ca51
--- /dev/null
+++ b/beecrypt/README.DARWIN
@@ -0,0 +1,13 @@
+To succesfully compile BeeCrypt on Apple's MacOS X 10.1/Darwin:
+
+Use the --disable-optimized option in configure; Apple has changed the assembler format to something incompatible with GNU as; e.g. use ./configure --disable-optimized
+
+If anybody knows of a tool to convert one format to another, please let me know.
+
+Edit the libtool script generated by this process and search for the following line:
+
+ allow_undefined_flag="-undefined warning"
+
+and change it to:
+
+ allow_undefined_flag="-undefined error"
diff --git a/beecrypt/aes.c b/beecrypt/aes.c
new file mode 100644
index 000000000..c54305f90
--- /dev/null
+++ b/beecrypt/aes.c
@@ -0,0 +1,1306 @@
+/*
+ * aes.c
+ *
+ * AES cipher, code
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#define BEECRYPT_DLL_EXPORT
+
+#include "aes.h"
+#include "endianness.h"
+#include "mp32.h"
+
+#include <string.h>
+
+const uint32 _ae0[256] = {
+ 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d,
+ 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
+ 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d,
+ 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a,
+ 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87,
+ 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b,
+ 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea,
+ 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b,
+ 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a,
+ 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f,
+ 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108,
+ 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f,
+ 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e,
+ 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5,
+ 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d,
+ 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f,
+ 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e,
+ 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb,
+ 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce,
+ 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497,
+ 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c,
+ 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed,
+ 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b,
+ 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a,
+ 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16,
+ 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594,
+ 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81,
+ 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3,
+ 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a,
+ 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504,
+ 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163,
+ 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d,
+ 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f,
+ 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739,
+ 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47,
+ 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395,
+ 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f,
+ 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883,
+ 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c,
+ 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76,
+ 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e,
+ 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4,
+ 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6,
+ 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b,
+ 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7,
+ 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0,
+ 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25,
+ 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818,
+ 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72,
+ 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651,
+ 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21,
+ 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85,
+ 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa,
+ 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12,
+ 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0,
+ 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9,
+ 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133,
+ 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7,
+ 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920,
+ 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a,
+ 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17,
+ 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8,
+ 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11,
+ 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a
+};
+
+const uint32 _ae1[256] = {
+ 0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b,
+ 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5,
+ 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b,
+ 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676,
+ 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d,
+ 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0,
+ 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf,
+ 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0,
+ 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626,
+ 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc,
+ 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1,
+ 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515,
+ 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3,
+ 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a,
+ 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2,
+ 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575,
+ 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a,
+ 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0,
+ 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3,
+ 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484,
+ 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded,
+ 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b,
+ 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939,
+ 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf,
+ 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb,
+ 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585,
+ 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f,
+ 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8,
+ 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f,
+ 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5,
+ 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121,
+ 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2,
+ 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec,
+ 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717,
+ 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d,
+ 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373,
+ 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc,
+ 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888,
+ 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414,
+ 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb,
+ 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a,
+ 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c,
+ 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262,
+ 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979,
+ 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d,
+ 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9,
+ 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea,
+ 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808,
+ 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e,
+ 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6,
+ 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f,
+ 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a,
+ 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666,
+ 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e,
+ 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9,
+ 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e,
+ 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111,
+ 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494,
+ 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9,
+ 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf,
+ 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d,
+ 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868,
+ 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f,
+ 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616
+};
+
+const uint32 _ae2[256] = {
+ 0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b,
+ 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5,
+ 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b,
+ 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76,
+ 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d,
+ 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0,
+ 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af,
+ 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0,
+ 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26,
+ 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc,
+ 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1,
+ 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15,
+ 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3,
+ 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a,
+ 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2,
+ 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75,
+ 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a,
+ 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0,
+ 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3,
+ 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384,
+ 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed,
+ 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b,
+ 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239,
+ 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf,
+ 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb,
+ 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185,
+ 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f,
+ 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8,
+ 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f,
+ 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5,
+ 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221,
+ 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2,
+ 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec,
+ 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17,
+ 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d,
+ 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673,
+ 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc,
+ 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88,
+ 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814,
+ 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb,
+ 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a,
+ 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c,
+ 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462,
+ 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279,
+ 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d,
+ 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9,
+ 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea,
+ 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008,
+ 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e,
+ 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6,
+ 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f,
+ 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a,
+ 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66,
+ 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e,
+ 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9,
+ 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e,
+ 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211,
+ 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394,
+ 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9,
+ 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df,
+ 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d,
+ 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068,
+ 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f,
+ 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16
+};
+
+const uint32 _ae3[256] = {
+ 0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6,
+ 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491,
+ 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56,
+ 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec,
+ 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa,
+ 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb,
+ 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45,
+ 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b,
+ 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c,
+ 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83,
+ 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9,
+ 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a,
+ 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d,
+ 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f,
+ 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf,
+ 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea,
+ 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34,
+ 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b,
+ 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d,
+ 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713,
+ 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1,
+ 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6,
+ 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72,
+ 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85,
+ 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed,
+ 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411,
+ 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe,
+ 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b,
+ 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05,
+ 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1,
+ 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342,
+ 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf,
+ 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3,
+ 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e,
+ 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a,
+ 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6,
+ 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3,
+ 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b,
+ 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28,
+ 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad,
+ 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14,
+ 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8,
+ 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4,
+ 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2,
+ 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da,
+ 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049,
+ 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf,
+ 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810,
+ 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c,
+ 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197,
+ 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e,
+ 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f,
+ 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc,
+ 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c,
+ 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069,
+ 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927,
+ 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322,
+ 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733,
+ 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9,
+ 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5,
+ 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a,
+ 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0,
+ 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e,
+ 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c
+};
+
+const uint32 _ae4[256] = {
+ 0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b,
+ 0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5,
+ 0x30303030, 0x01010101, 0x67676767, 0x2b2b2b2b,
+ 0xfefefefe, 0xd7d7d7d7, 0xabababab, 0x76767676,
+ 0xcacacaca, 0x82828282, 0xc9c9c9c9, 0x7d7d7d7d,
+ 0xfafafafa, 0x59595959, 0x47474747, 0xf0f0f0f0,
+ 0xadadadad, 0xd4d4d4d4, 0xa2a2a2a2, 0xafafafaf,
+ 0x9c9c9c9c, 0xa4a4a4a4, 0x72727272, 0xc0c0c0c0,
+ 0xb7b7b7b7, 0xfdfdfdfd, 0x93939393, 0x26262626,
+ 0x36363636, 0x3f3f3f3f, 0xf7f7f7f7, 0xcccccccc,
+ 0x34343434, 0xa5a5a5a5, 0xe5e5e5e5, 0xf1f1f1f1,
+ 0x71717171, 0xd8d8d8d8, 0x31313131, 0x15151515,
+ 0x04040404, 0xc7c7c7c7, 0x23232323, 0xc3c3c3c3,
+ 0x18181818, 0x96969696, 0x05050505, 0x9a9a9a9a,
+ 0x07070707, 0x12121212, 0x80808080, 0xe2e2e2e2,
+ 0xebebebeb, 0x27272727, 0xb2b2b2b2, 0x75757575,
+ 0x09090909, 0x83838383, 0x2c2c2c2c, 0x1a1a1a1a,
+ 0x1b1b1b1b, 0x6e6e6e6e, 0x5a5a5a5a, 0xa0a0a0a0,
+ 0x52525252, 0x3b3b3b3b, 0xd6d6d6d6, 0xb3b3b3b3,
+ 0x29292929, 0xe3e3e3e3, 0x2f2f2f2f, 0x84848484,
+ 0x53535353, 0xd1d1d1d1, 0x00000000, 0xedededed,
+ 0x20202020, 0xfcfcfcfc, 0xb1b1b1b1, 0x5b5b5b5b,
+ 0x6a6a6a6a, 0xcbcbcbcb, 0xbebebebe, 0x39393939,
+ 0x4a4a4a4a, 0x4c4c4c4c, 0x58585858, 0xcfcfcfcf,
+ 0xd0d0d0d0, 0xefefefef, 0xaaaaaaaa, 0xfbfbfbfb,
+ 0x43434343, 0x4d4d4d4d, 0x33333333, 0x85858585,
+ 0x45454545, 0xf9f9f9f9, 0x02020202, 0x7f7f7f7f,
+ 0x50505050, 0x3c3c3c3c, 0x9f9f9f9f, 0xa8a8a8a8,
+ 0x51515151, 0xa3a3a3a3, 0x40404040, 0x8f8f8f8f,
+ 0x92929292, 0x9d9d9d9d, 0x38383838, 0xf5f5f5f5,
+ 0xbcbcbcbc, 0xb6b6b6b6, 0xdadadada, 0x21212121,
+ 0x10101010, 0xffffffff, 0xf3f3f3f3, 0xd2d2d2d2,
+ 0xcdcdcdcd, 0x0c0c0c0c, 0x13131313, 0xecececec,
+ 0x5f5f5f5f, 0x97979797, 0x44444444, 0x17171717,
+ 0xc4c4c4c4, 0xa7a7a7a7, 0x7e7e7e7e, 0x3d3d3d3d,
+ 0x64646464, 0x5d5d5d5d, 0x19191919, 0x73737373,
+ 0x60606060, 0x81818181, 0x4f4f4f4f, 0xdcdcdcdc,
+ 0x22222222, 0x2a2a2a2a, 0x90909090, 0x88888888,
+ 0x46464646, 0xeeeeeeee, 0xb8b8b8b8, 0x14141414,
+ 0xdededede, 0x5e5e5e5e, 0x0b0b0b0b, 0xdbdbdbdb,
+ 0xe0e0e0e0, 0x32323232, 0x3a3a3a3a, 0x0a0a0a0a,
+ 0x49494949, 0x06060606, 0x24242424, 0x5c5c5c5c,
+ 0xc2c2c2c2, 0xd3d3d3d3, 0xacacacac, 0x62626262,
+ 0x91919191, 0x95959595, 0xe4e4e4e4, 0x79797979,
+ 0xe7e7e7e7, 0xc8c8c8c8, 0x37373737, 0x6d6d6d6d,
+ 0x8d8d8d8d, 0xd5d5d5d5, 0x4e4e4e4e, 0xa9a9a9a9,
+ 0x6c6c6c6c, 0x56565656, 0xf4f4f4f4, 0xeaeaeaea,
+ 0x65656565, 0x7a7a7a7a, 0xaeaeaeae, 0x08080808,
+ 0xbabababa, 0x78787878, 0x25252525, 0x2e2e2e2e,
+ 0x1c1c1c1c, 0xa6a6a6a6, 0xb4b4b4b4, 0xc6c6c6c6,
+ 0xe8e8e8e8, 0xdddddddd, 0x74747474, 0x1f1f1f1f,
+ 0x4b4b4b4b, 0xbdbdbdbd, 0x8b8b8b8b, 0x8a8a8a8a,
+ 0x70707070, 0x3e3e3e3e, 0xb5b5b5b5, 0x66666666,
+ 0x48484848, 0x03030303, 0xf6f6f6f6, 0x0e0e0e0e,
+ 0x61616161, 0x35353535, 0x57575757, 0xb9b9b9b9,
+ 0x86868686, 0xc1c1c1c1, 0x1d1d1d1d, 0x9e9e9e9e,
+ 0xe1e1e1e1, 0xf8f8f8f8, 0x98989898, 0x11111111,
+ 0x69696969, 0xd9d9d9d9, 0x8e8e8e8e, 0x94949494,
+ 0x9b9b9b9b, 0x1e1e1e1e, 0x87878787, 0xe9e9e9e9,
+ 0xcececece, 0x55555555, 0x28282828, 0xdfdfdfdf,
+ 0x8c8c8c8c, 0xa1a1a1a1, 0x89898989, 0x0d0d0d0d,
+ 0xbfbfbfbf, 0xe6e6e6e6, 0x42424242, 0x68686868,
+ 0x41414141, 0x99999999, 0x2d2d2d2d, 0x0f0f0f0f,
+ 0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616
+};
+
+const uint32 _ad0[256] = {
+ 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96,
+ 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
+ 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25,
+ 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f,
+ 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1,
+ 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6,
+ 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da,
+ 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844,
+ 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd,
+ 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4,
+ 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45,
+ 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94,
+ 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7,
+ 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a,
+ 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5,
+ 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c,
+ 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1,
+ 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a,
+ 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75,
+ 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051,
+ 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46,
+ 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff,
+ 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77,
+ 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb,
+ 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000,
+ 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e,
+ 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927,
+ 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a,
+ 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e,
+ 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16,
+ 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d,
+ 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8,
+ 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd,
+ 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34,
+ 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163,
+ 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120,
+ 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d,
+ 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0,
+ 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422,
+ 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef,
+ 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36,
+ 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4,
+ 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662,
+ 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5,
+ 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3,
+ 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b,
+ 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8,
+ 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6,
+ 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6,
+ 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0,
+ 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815,
+ 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f,
+ 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df,
+ 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f,
+ 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e,
+ 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713,
+ 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89,
+ 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c,
+ 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf,
+ 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86,
+ 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f,
+ 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541,
+ 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190,
+ 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742
+};
+
+const uint32 _ad1[256] = {
+ 0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e,
+ 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303,
+ 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c,
+ 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3,
+ 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0,
+ 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9,
+ 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259,
+ 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8,
+ 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971,
+ 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a,
+ 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f,
+ 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b,
+ 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8,
+ 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab,
+ 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708,
+ 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682,
+ 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2,
+ 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe,
+ 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb,
+ 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10,
+ 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd,
+ 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015,
+ 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e,
+ 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee,
+ 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000,
+ 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72,
+ 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39,
+ 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e,
+ 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91,
+ 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a,
+ 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17,
+ 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9,
+ 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60,
+ 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e,
+ 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1,
+ 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611,
+ 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1,
+ 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3,
+ 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964,
+ 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390,
+ 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b,
+ 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf,
+ 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46,
+ 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af,
+ 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512,
+ 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb,
+ 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a,
+ 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8,
+ 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c,
+ 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266,
+ 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8,
+ 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6,
+ 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604,
+ 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551,
+ 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41,
+ 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647,
+ 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c,
+ 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1,
+ 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737,
+ 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db,
+ 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340,
+ 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95,
+ 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1,
+ 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857
+};
+
+const uint32 _ad2[256] = {
+ 0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27,
+ 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3,
+ 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502,
+ 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562,
+ 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe,
+ 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3,
+ 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552,
+ 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9,
+ 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9,
+ 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce,
+ 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253,
+ 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908,
+ 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b,
+ 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655,
+ 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337,
+ 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16,
+ 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69,
+ 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6,
+ 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6,
+ 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e,
+ 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6,
+ 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050,
+ 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9,
+ 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8,
+ 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000,
+ 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a,
+ 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d,
+ 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436,
+ 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b,
+ 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12,
+ 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b,
+ 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e,
+ 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f,
+ 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb,
+ 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4,
+ 0xdccad731, 0x85104263, 0x22401397, 0x112084c6,
+ 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729,
+ 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1,
+ 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9,
+ 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233,
+ 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4,
+ 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad,
+ 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e,
+ 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3,
+ 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25,
+ 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b,
+ 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f,
+ 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15,
+ 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0,
+ 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2,
+ 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7,
+ 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791,
+ 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496,
+ 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665,
+ 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b,
+ 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6,
+ 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13,
+ 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47,
+ 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7,
+ 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844,
+ 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3,
+ 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d,
+ 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456,
+ 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8
+};
+
+const uint32 _ad3[256] = {
+ 0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a,
+ 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b,
+ 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5,
+ 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5,
+ 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d,
+ 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b,
+ 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95,
+ 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e,
+ 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27,
+ 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d,
+ 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562,
+ 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9,
+ 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752,
+ 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66,
+ 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3,
+ 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced,
+ 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e,
+ 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4,
+ 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4,
+ 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd,
+ 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d,
+ 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60,
+ 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767,
+ 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79,
+ 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000,
+ 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c,
+ 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736,
+ 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24,
+ 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b,
+ 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c,
+ 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12,
+ 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814,
+ 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3,
+ 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b,
+ 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8,
+ 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084,
+ 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7,
+ 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077,
+ 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247,
+ 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22,
+ 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698,
+ 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f,
+ 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254,
+ 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582,
+ 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf,
+ 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb,
+ 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883,
+ 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef,
+ 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629,
+ 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035,
+ 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533,
+ 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17,
+ 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4,
+ 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46,
+ 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb,
+ 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d,
+ 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb,
+ 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a,
+ 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73,
+ 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678,
+ 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2,
+ 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff,
+ 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064,
+ 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0
+};
+
+const uint32 _ad4[256] = {
+ 0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5,
+ 0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838,
+ 0xbfbfbfbf, 0x40404040, 0xa3a3a3a3, 0x9e9e9e9e,
+ 0x81818181, 0xf3f3f3f3, 0xd7d7d7d7, 0xfbfbfbfb,
+ 0x7c7c7c7c, 0xe3e3e3e3, 0x39393939, 0x82828282,
+ 0x9b9b9b9b, 0x2f2f2f2f, 0xffffffff, 0x87878787,
+ 0x34343434, 0x8e8e8e8e, 0x43434343, 0x44444444,
+ 0xc4c4c4c4, 0xdededede, 0xe9e9e9e9, 0xcbcbcbcb,
+ 0x54545454, 0x7b7b7b7b, 0x94949494, 0x32323232,
+ 0xa6a6a6a6, 0xc2c2c2c2, 0x23232323, 0x3d3d3d3d,
+ 0xeeeeeeee, 0x4c4c4c4c, 0x95959595, 0x0b0b0b0b,
+ 0x42424242, 0xfafafafa, 0xc3c3c3c3, 0x4e4e4e4e,
+ 0x08080808, 0x2e2e2e2e, 0xa1a1a1a1, 0x66666666,
+ 0x28282828, 0xd9d9d9d9, 0x24242424, 0xb2b2b2b2,
+ 0x76767676, 0x5b5b5b5b, 0xa2a2a2a2, 0x49494949,
+ 0x6d6d6d6d, 0x8b8b8b8b, 0xd1d1d1d1, 0x25252525,
+ 0x72727272, 0xf8f8f8f8, 0xf6f6f6f6, 0x64646464,
+ 0x86868686, 0x68686868, 0x98989898, 0x16161616,
+ 0xd4d4d4d4, 0xa4a4a4a4, 0x5c5c5c5c, 0xcccccccc,
+ 0x5d5d5d5d, 0x65656565, 0xb6b6b6b6, 0x92929292,
+ 0x6c6c6c6c, 0x70707070, 0x48484848, 0x50505050,
+ 0xfdfdfdfd, 0xedededed, 0xb9b9b9b9, 0xdadadada,
+ 0x5e5e5e5e, 0x15151515, 0x46464646, 0x57575757,
+ 0xa7a7a7a7, 0x8d8d8d8d, 0x9d9d9d9d, 0x84848484,
+ 0x90909090, 0xd8d8d8d8, 0xabababab, 0x00000000,
+ 0x8c8c8c8c, 0xbcbcbcbc, 0xd3d3d3d3, 0x0a0a0a0a,
+ 0xf7f7f7f7, 0xe4e4e4e4, 0x58585858, 0x05050505,
+ 0xb8b8b8b8, 0xb3b3b3b3, 0x45454545, 0x06060606,
+ 0xd0d0d0d0, 0x2c2c2c2c, 0x1e1e1e1e, 0x8f8f8f8f,
+ 0xcacacaca, 0x3f3f3f3f, 0x0f0f0f0f, 0x02020202,
+ 0xc1c1c1c1, 0xafafafaf, 0xbdbdbdbd, 0x03030303,
+ 0x01010101, 0x13131313, 0x8a8a8a8a, 0x6b6b6b6b,
+ 0x3a3a3a3a, 0x91919191, 0x11111111, 0x41414141,
+ 0x4f4f4f4f, 0x67676767, 0xdcdcdcdc, 0xeaeaeaea,
+ 0x97979797, 0xf2f2f2f2, 0xcfcfcfcf, 0xcececece,
+ 0xf0f0f0f0, 0xb4b4b4b4, 0xe6e6e6e6, 0x73737373,
+ 0x96969696, 0xacacacac, 0x74747474, 0x22222222,
+ 0xe7e7e7e7, 0xadadadad, 0x35353535, 0x85858585,
+ 0xe2e2e2e2, 0xf9f9f9f9, 0x37373737, 0xe8e8e8e8,
+ 0x1c1c1c1c, 0x75757575, 0xdfdfdfdf, 0x6e6e6e6e,
+ 0x47474747, 0xf1f1f1f1, 0x1a1a1a1a, 0x71717171,
+ 0x1d1d1d1d, 0x29292929, 0xc5c5c5c5, 0x89898989,
+ 0x6f6f6f6f, 0xb7b7b7b7, 0x62626262, 0x0e0e0e0e,
+ 0xaaaaaaaa, 0x18181818, 0xbebebebe, 0x1b1b1b1b,
+ 0xfcfcfcfc, 0x56565656, 0x3e3e3e3e, 0x4b4b4b4b,
+ 0xc6c6c6c6, 0xd2d2d2d2, 0x79797979, 0x20202020,
+ 0x9a9a9a9a, 0xdbdbdbdb, 0xc0c0c0c0, 0xfefefefe,
+ 0x78787878, 0xcdcdcdcd, 0x5a5a5a5a, 0xf4f4f4f4,
+ 0x1f1f1f1f, 0xdddddddd, 0xa8a8a8a8, 0x33333333,
+ 0x88888888, 0x07070707, 0xc7c7c7c7, 0x31313131,
+ 0xb1b1b1b1, 0x12121212, 0x10101010, 0x59595959,
+ 0x27272727, 0x80808080, 0xecececec, 0x5f5f5f5f,
+ 0x60606060, 0x51515151, 0x7f7f7f7f, 0xa9a9a9a9,
+ 0x19191919, 0xb5b5b5b5, 0x4a4a4a4a, 0x0d0d0d0d,
+ 0x2d2d2d2d, 0xe5e5e5e5, 0x7a7a7a7a, 0x9f9f9f9f,
+ 0x93939393, 0xc9c9c9c9, 0x9c9c9c9c, 0xefefefef,
+ 0xa0a0a0a0, 0xe0e0e0e0, 0x3b3b3b3b, 0x4d4d4d4d,
+ 0xaeaeaeae, 0x2a2a2a2a, 0xf5f5f5f5, 0xb0b0b0b0,
+ 0xc8c8c8c8, 0xebebebeb, 0xbbbbbbbb, 0x3c3c3c3c,
+ 0x83838383, 0x53535353, 0x99999999, 0x61616161,
+ 0x17171717, 0x2b2b2b2b, 0x04040404, 0x7e7e7e7e,
+ 0xbabababa, 0x77777777, 0xd6d6d6d6, 0x26262626,
+ 0xe1e1e1e1, 0x69696969, 0x14141414, 0x63636363,
+ 0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d
+};
+
+static const uint32 _arc[] = {
+ 0x01000000, 0x02000000, 0x04000000, 0x08000000,
+ 0x10000000, 0x20000000, 0x40000000, 0x80000000,
+ 0x1B000000, 0x36000000
+};
+
+static const blockMode aesModes[2] =
+{
+ { /* ECB */ (blockModeEncrypt) aesECBEncrypt, (blockModeDecrypt) aesECBDecrypt },
+ { /* CBC */ (blockModeEncrypt) aesCBCEncrypt, (blockModeDecrypt) aesCBCDecrypt }
+};
+
+const blockCipher aes = { "AES", sizeof(aesParam), 16, 128, 256, 64, (blockCipherSetup) aesSetup, (blockCipherSetIV) aesSetIV, (blockCipherEncrypt) aesEncrypt, (blockCipherDecrypt) aesDecrypt, aesModes };
+
+int aesSetup(aesParam* ap, const uint32* key, int keybits, cipherOperation op)
+{
+ if (((keybits & 63) == 0) && (keybits >= 128) && (keybits <= 256))
+ {
+ register uint32* rk, t, i, j;
+
+ /* clear fdback/iv */
+ ap->fdback[0] = 0;
+ ap->fdback[1] = 0;
+ ap->fdback[2] = 0;
+ ap->fdback[3] = 0;
+
+ ap->nr = 6 + (keybits >> 5);
+
+ mp32copy((keybits >> 5), rk = ap->k, key);
+
+ i = 0;
+
+ if (keybits == 128)
+ {
+ while (1)
+ {
+ t = rk[3];
+ rk[4] = rk[0] ^
+ (_ae4[(t >> 16) & 0xff] & 0xff000000) ^
+ (_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^
+ (_ae4[(t ) & 0xff] & 0x0000ff00) ^
+ (_ae4[(t >> 24) ] & 0x000000ff) ^
+ _arc[i];
+ rk[5] = rk[1] ^ rk[4];
+ rk[6] = rk[2] ^ rk[5];
+ rk[7] = rk[3] ^ rk[6];
+ if (++i == 10)
+ break;
+ rk += 4;
+ }
+ }
+ else if (keybits == 192)
+ {
+ while (1)
+ {
+ t = rk[5];
+ rk[ 6] = rk[0] ^
+ (_ae4[(t >> 16) & 0xff] & 0xff000000) ^
+ (_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^
+ (_ae4[(t ) & 0xff] & 0x0000ff00) ^
+ (_ae4[(t >> 24) ] & 0x000000ff) ^
+ _arc[i];
+ rk[ 7] = rk[1] ^ rk[ 6];
+ rk[ 8] = rk[2] ^ rk[ 7];
+ rk[ 9] = rk[3] ^ rk[ 8];
+ if (++i == 8)
+ break;
+ rk[10] = rk[4] ^ rk[ 9];
+ rk[11] = rk[5] ^ rk[10];
+ rk += 6;
+ }
+ }
+ else if (keybits == 256)
+ {
+ while (1)
+ {
+ t = rk[7];
+ rk[8] = rk[0] ^
+ (_ae4[(t >> 16) & 0xff] & 0xff000000) ^
+ (_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^
+ (_ae4[(t ) & 0xff] & 0x0000ff00) ^
+ (_ae4[(t >> 24) ] & 0x000000ff) ^
+ _arc[i];
+ rk[ 9] = rk[1] ^ rk[ 8];
+ rk[10] = rk[2] ^ rk[ 9];
+ rk[11] = rk[3] ^ rk[10];
+ if (++i == 7)
+ break;
+ t = rk[7];
+ rk[12] = rk[4] ^
+ (_ae4[(t >> 16) & 0xff] & 0xff000000) ^
+ (_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^
+ (_ae4[(t ) & 0xff] & 0x0000ff00) ^
+ (_ae4[(t >> 24) ] & 0x000000ff);
+ rk[13] = rk[5] ^ rk[12];
+ rk[14] = rk[6] ^ rk[13];
+ rk[15] = rk[7] ^ rk[14];
+ rk += 8;
+ }
+ }
+
+ if (op == DECRYPT)
+ {
+ rk = ap->k;
+
+ for (i = 0, j = (ap->nr << 2); i < j; i += 4, j -= 4)
+ {
+ t = rk[i ]; rk[i ] = rk[j ]; rk[j ] = t;
+ t = rk[i+1]; rk[i+1] = rk[j+1]; rk[j+1] = t;
+ t = rk[i+2]; rk[i+2] = rk[j+2]; rk[j+2] = t;
+ t = rk[i+3]; rk[i+3] = rk[j+3]; rk[j+3] = t;
+ }
+ for (i = 1; i < ap->nr; i++)
+ {
+ rk += 4;
+ rk[0] =
+ _ad0[_ae4[(rk[0] >> 24) ] & 0xff] ^
+ _ad1[_ae4[(rk[0] >> 16) & 0xff] & 0xff] ^
+ _ad2[_ae4[(rk[0] >> 8) & 0xff] & 0xff] ^
+ _ad3[_ae4[(rk[0] ) & 0xff] & 0xff];
+ rk[1] =
+ _ad0[_ae4[(rk[1] >> 24) ] & 0xff] ^
+ _ad1[_ae4[(rk[1] >> 16) & 0xff] & 0xff] ^
+ _ad2[_ae4[(rk[1] >> 8) & 0xff] & 0xff] ^
+ _ad3[_ae4[(rk[1] ) & 0xff] & 0xff];
+ rk[2] =
+ _ad0[_ae4[(rk[2] >> 24) ] & 0xff] ^
+ _ad1[_ae4[(rk[2] >> 16) & 0xff] & 0xff] ^
+ _ad2[_ae4[(rk[2] >> 8) & 0xff] & 0xff] ^
+ _ad3[_ae4[(rk[2] ) & 0xff] & 0xff];
+ rk[3] =
+ _ad0[_ae4[(rk[3] >> 24) ] & 0xff] ^
+ _ad1[_ae4[(rk[3] >> 16) & 0xff] & 0xff] ^
+ _ad2[_ae4[(rk[3] >> 8) & 0xff] & 0xff] ^
+ _ad3[_ae4[(rk[3] ) & 0xff] & 0xff];
+ }
+ }
+ return 0;
+ }
+ return -1;
+}
+
+#ifndef ASM_AESSETIV
+int aesSetIV(aesParam* ap, const uint32* iv)
+{
+ if (iv)
+ {
+ ap->fdback[0] = iv[0];
+ ap->fdback[1] = iv[1];
+ ap->fdback[2] = iv[2];
+ ap->fdback[3] = iv[3];
+ }
+ else
+ {
+ ap->fdback[0] = 0;
+ ap->fdback[1] = 0;
+ ap->fdback[2] = 0;
+ ap->fdback[3] = 0;
+ }
+
+ return 0;
+}
+#endif
+
+#define etfs(i) \
+ t0 = \
+ _ae0[(s0 >> 24) ] ^ \
+ _ae1[(s1 >> 16) & 0xff] ^ \
+ _ae2[(s2 >> 8) & 0xff] ^ \
+ _ae3[(s3 ) & 0xff] ^ \
+ rk[i+0]; \
+ t1 = \
+ _ae0[(s1 >> 24) ] ^ \
+ _ae1[(s2 >> 16) & 0xff] ^ \
+ _ae2[(s3 >> 8) & 0xff] ^ \
+ _ae3[(s0 ) & 0xff] ^ \
+ rk[i+1]; \
+ t2 = \
+ _ae0[(s2 >> 24) ] ^ \
+ _ae1[(s3 >> 16) & 0xff] ^ \
+ _ae2[(s0 >> 8) & 0xff] ^ \
+ _ae3[(s1 ) & 0xff] ^ \
+ rk[i+2]; \
+ t3 = \
+ _ae0[(s3 >> 24) ] ^ \
+ _ae1[(s0 >> 16) & 0xff] ^ \
+ _ae2[(s1 >> 8) & 0xff] ^ \
+ _ae3[(s2 ) & 0xff] ^ \
+ rk[i+3];
+
+#define esft(i) \
+ s0 = \
+ _ae0[(t0 >> 24) ] ^ \
+ _ae1[(t1 >> 16) & 0xff] ^ \
+ _ae2[(t2 >> 8) & 0xff] ^ \
+ _ae3[(t3 ) & 0xff] ^ \
+ rk[i+0]; \
+ s1 = \
+ _ae0[(t1 >> 24) ] ^ \
+ _ae1[(t2 >> 16) & 0xff] ^ \
+ _ae2[(t3 >> 8) & 0xff] ^ \
+ _ae3[(t0 ) & 0xff] ^ \
+ rk[i+1]; \
+ s2 = \
+ _ae0[(t2 >> 24) ] ^ \
+ _ae1[(t3 >> 16) & 0xff] ^ \
+ _ae2[(t0 >> 8) & 0xff] ^ \
+ _ae3[(t1 ) & 0xff] ^ \
+ rk[i+2]; \
+ s3 = \
+ _ae0[(t3 >> 24) ] ^ \
+ _ae1[(t0 >> 16) & 0xff] ^ \
+ _ae2[(t1 >> 8) & 0xff] ^ \
+ _ae3[(t2 ) & 0xff] ^ \
+ rk[i+3];
+
+#define elr() \
+ s0 = \
+ (_ae4[(t0 >> 24) ] & 0xff000000) ^ \
+ (_ae4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ae4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ae4[(t3 ) & 0xff] & 0x000000ff) ^ \
+ rk[0]; \
+ s1 = \
+ (_ae4[(t1 >> 24) ] & 0xff000000) ^ \
+ (_ae4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ae4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ae4[(t0 ) & 0xff] & 0x000000ff) ^ \
+ rk[1]; \
+ s2 = \
+ (_ae4[(t2 >> 24) ] & 0xff000000) ^ \
+ (_ae4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ae4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ae4[(t1 ) & 0xff] & 0x000000ff) ^ \
+ rk[2]; \
+ s3 = \
+ (_ae4[(t3 >> 24) ] & 0xff000000) ^ \
+ (_ae4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ae4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ae4[(t2 ) & 0xff] & 0x000000ff) ^ \
+ rk[3];
+
+#ifndef ASM_AESENCRYPT
+int aesEncrypt(aesParam* ap, uint32* dst, const uint32* src)
+{
+ register uint32 s0, s1, s2, s3;
+ register uint32 t0, t1, t2, t3;
+ register uint32* rk = ap->k;
+
+ #if WORDS_BIGENDIAN
+ s0 = src[0] ^ rk[0];
+ s1 = src[1] ^ rk[1];
+ s2 = src[2] ^ rk[2];
+ s3 = src[3] ^ rk[3];
+ #else
+ s0 = swapu32(src[0]) ^ rk[0];
+ s1 = swapu32(src[1]) ^ rk[1];
+ s2 = swapu32(src[2]) ^ rk[2];
+ s3 = swapu32(src[3]) ^ rk[3];
+ #endif
+
+ etfs(4); /* round 1 */
+ esft(8); /* round 2 */
+ etfs(12); /* round 3 */
+ esft(16); /* round 4 */
+ etfs(20); /* round 5 */
+ esft(24); /* round 6 */
+ etfs(28); /* round 7 */
+ esft(32); /* round 8 */
+ etfs(36); /* round 9 */
+
+ if (ap->nr > 10)
+ {
+ esft(40); /* round 10 */
+ etfs(44); /* round 11 */
+ if (ap->nr > 12)
+ {
+ esft(48); /* round 12 */
+ etfs(52); /* round 13 */
+ }
+ }
+
+ rk += (ap->nr << 2);
+
+ elr(); /* last round */
+
+ #if WORDS_BIGENDIAN
+ dst[0] = s0;
+ dst[1] = s1;
+ dst[2] = s2;
+ dst[3] = s3;
+ #else
+ dst[0] = swapu32(s0);
+ dst[1] = swapu32(s1);
+ dst[2] = swapu32(s2);
+ dst[3] = swapu32(s3);
+ #endif
+
+ return 0;
+}
+#endif
+
+#define dtfs(i) \
+ t0 = \
+ _ad0[(s0 >> 24) ] ^ \
+ _ad1[(s3 >> 16) & 0xff] ^ \
+ _ad2[(s2 >> 8) & 0xff] ^ \
+ _ad3[(s1 ) & 0xff] ^ \
+ rk[i+0]; \
+ t1 = \
+ _ad0[(s1 >> 24) ] ^ \
+ _ad1[(s0 >> 16) & 0xff] ^ \
+ _ad2[(s3 >> 8) & 0xff] ^ \
+ _ad3[(s2 ) & 0xff] ^ \
+ rk[i+1]; \
+ t2 = \
+ _ad0[(s2 >> 24) ] ^ \
+ _ad1[(s1 >> 16) & 0xff] ^ \
+ _ad2[(s0 >> 8) & 0xff] ^ \
+ _ad3[(s3 ) & 0xff] ^ \
+ rk[i+2]; \
+ t3 = \
+ _ad0[(s3 >> 24) ] ^ \
+ _ad1[(s2 >> 16) & 0xff] ^ \
+ _ad2[(s1 >> 8) & 0xff] ^ \
+ _ad3[(s0 ) & 0xff] ^ \
+ rk[i+3];
+
+#define dsft(i) \
+ s0 = \
+ _ad0[(t0 >> 24) ] ^ \
+ _ad1[(t3 >> 16) & 0xff] ^ \
+ _ad2[(t2 >> 8) & 0xff] ^ \
+ _ad3[(t1 ) & 0xff] ^ \
+ rk[i+0]; \
+ s1 = \
+ _ad0[(t1 >> 24) ] ^ \
+ _ad1[(t0 >> 16) & 0xff] ^ \
+ _ad2[(t3 >> 8) & 0xff] ^ \
+ _ad3[(t2 ) & 0xff] ^ \
+ rk[i+1]; \
+ s2 = \
+ _ad0[(t2 >> 24) ] ^ \
+ _ad1[(t1 >> 16) & 0xff] ^ \
+ _ad2[(t0 >> 8) & 0xff] ^ \
+ _ad3[(t3 ) & 0xff] ^ \
+ rk[i+2]; \
+ s3 = \
+ _ad0[(t3 >> 24) ] ^ \
+ _ad1[(t2 >> 16) & 0xff] ^ \
+ _ad2[(t1 >> 8) & 0xff] ^ \
+ _ad3[(t0 ) & 0xff] ^ \
+ rk[i+3];
+
+#define dlr() \
+ s0 = \
+ (_ad4[(t0 >> 24) ] & 0xff000000) ^ \
+ (_ad4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ad4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ad4[(t1 ) & 0xff] & 0x000000ff) ^ \
+ rk[0]; \
+ s1 = \
+ (_ad4[(t1 >> 24) ] & 0xff000000) ^ \
+ (_ad4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ad4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ad4[(t2 ) & 0xff] & 0x000000ff) ^ \
+ rk[1]; \
+ s2 = \
+ (_ad4[(t2 >> 24) ] & 0xff000000) ^ \
+ (_ad4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ad4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ad4[(t3 ) & 0xff] & 0x000000ff) ^ \
+ rk[2]; \
+ s3 = \
+ (_ad4[(t3 >> 24) ] & 0xff000000) ^ \
+ (_ad4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \
+ (_ad4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ \
+ (_ad4[(t0 ) & 0xff] & 0x000000ff) ^ \
+ rk[3];
+
+#ifndef ASM_AESDECRYPT
+int aesDecrypt(aesParam* ap, uint32* dst, const uint32* src)
+{
+ register uint32 s0, s1, s2, s3;
+ register uint32 t0, t1, t2, t3;
+ register uint32* rk = ap->k;
+
+ #if WORDS_BIGENDIAN
+ s0 = src[0] ^ rk[0];
+ s1 = src[1] ^ rk[1];
+ s2 = src[2] ^ rk[2];
+ s3 = src[3] ^ rk[3];
+ #else
+ s0 = swapu32(src[0]) ^ rk[0];
+ s1 = swapu32(src[1]) ^ rk[1];
+ s2 = swapu32(src[2]) ^ rk[2];
+ s3 = swapu32(src[3]) ^ rk[3];
+ #endif
+
+ dtfs(4); /* round 1 */
+ dsft(8); /* round 2 */
+ dtfs(12); /* round 3 */
+ dsft(16); /* round 4 */
+ dtfs(20); /* round 5 */
+ dsft(24); /* round 6 */
+ dtfs(28); /* round 7 */
+ dsft(32); /* round 8 */
+ dtfs(36); /* round 9 */
+
+ if (ap->nr > 10)
+ {
+ dsft(40); /* round 10 */
+ dtfs(44); /* round 11 */
+ if (ap->nr > 12)
+ {
+ dsft(48); /* round 12 */
+ dtfs(52); /* round 13 */
+ }
+ }
+
+ rk += (ap->nr << 2);
+
+ dlr(); /* last round */
+
+ #if WORDS_BIGENDIAN
+ dst[0] = s0;
+ dst[1] = s1;
+ dst[2] = s2;
+ dst[3] = s3;
+ #else
+ dst[0] = swapu32(s0);
+ dst[1] = swapu32(s1);
+ dst[2] = swapu32(s2);
+ dst[3] = swapu32(s3);
+ #endif
+
+ return 0;
+}
+#endif
+
+#ifndef ASM_AESECBENCRYPT
+int aesECBEncrypt(aesParam* ap, int count, uint32* dst, const uint32* src)
+{
+ while (count > 0)
+ {
+ aesEncrypt(ap, dst, src);
+
+ dst += 4;
+ src += 4;
+
+ count--;
+ }
+ return 0;
+}
+#endif
+
+#ifndef ASM_AESECBDECRYPT
+int aesECBDecrypt(aesParam* ap, int count, uint32* dst, const uint32* src)
+{
+ while (count > 0)
+ {
+ aesDecrypt(ap, dst, src);
+
+ dst += 4;
+ src += 4;
+
+ count--;
+ }
+ return 0;
+}
+#endif
+
+#ifndef ASM_AESCBCENCRYPT
+int aesCBCEncrypt(aesParam* ap, int count, uint32* dst, const uint32* src)
+{
+ if (count > 0)
+ {
+ dst[0] = src[0] ^ ap->fdback[0];
+ dst[1] = src[1] ^ ap->fdback[1];
+ dst[2] = src[2] ^ ap->fdback[2];
+ dst[3] = src[3] ^ ap->fdback[3];
+
+ aesEncrypt(ap, dst, dst);
+
+ dst += 4;
+ src += 4;
+
+ count--;
+
+ while (count > 0)
+ {
+ dst[0] = src[0] ^ dst[-4];
+ dst[1] = src[1] ^ dst[-3];
+ dst[2] = src[2] ^ dst[-2];
+ dst[3] = src[3] ^ dst[-1];
+
+ aesEncrypt(ap, dst, dst);
+
+ dst += 4;
+ src += 4;
+
+ count--;
+ }
+
+ ap->fdback[0] = dst[-4];
+ ap->fdback[1] = dst[-3];
+ ap->fdback[2] = dst[-2];
+ ap->fdback[3] = dst[-1];
+ }
+ return 0;
+}
+#endif
+
+#ifndef ASM_AESCBCDECRYPT
+int aesCBCDecrypt(aesParam* ap, int count, uint32* dst, const uint32* src)
+{
+ if (count > 0)
+ {
+ if (src == dst)
+ {
+ register uint32 fb0 = src[0];
+ register uint32 fb1 = src[1];
+ register uint32 fb2 = src[2];
+ register uint32 fb3 = src[3];
+
+ aesDecrypt(ap, dst, src);
+
+ dst[0] ^= ap->fdback[0];
+ dst[1] ^= ap->fdback[1];
+ dst[2] ^= ap->fdback[2];
+ dst[3] ^= ap->fdback[3];
+
+ dst += 4;
+ src += 4;
+
+ count--;
+
+ while (count > 0)
+ {
+ register int src0 = src[0];
+ register int src1 = src[1];
+ register int src2 = src[2];
+ register int src3 = src[3];
+
+ aesDecrypt(ap, dst, src);
+
+ dst[0] ^= fb0;
+ dst[1] ^= fb1;
+ dst[2] ^= fb2;
+ dst[3] ^= fb3;
+
+ fb0 = src0;
+ fb1 = src1;
+ fb2 = src2;
+ fb3 = src3;
+
+ dst += 4;
+ src += 4;
+
+ count--;
+ }
+
+ ap->fdback[0] = fb0;
+ ap->fdback[1] = fb1;
+ ap->fdback[2] = fb2;
+ ap->fdback[3] = fb3;
+ }
+ else
+ {
+ aesDecrypt(ap, dst, src);
+
+ dst[0] ^= ap->fdback[0];
+ dst[1] ^= ap->fdback[1];
+ dst[0] ^= ap->fdback[0];
+ dst[1] ^= ap->fdback[1];
+
+ dst += 4;
+ src += 4;
+
+ count--;
+
+ while (count > 0)
+ {
+ aesDecrypt(ap, dst, src);
+
+ dst[0] ^= src[-4];
+ dst[1] ^= src[-3];
+ dst[2] ^= src[-2];
+ dst[3] ^= src[-1];
+
+ dst += 4;
+ src += 4;
+
+ count--;
+ }
+
+ ap->fdback[0] = src[-4];
+ ap->fdback[1] = src[-3];
+ ap->fdback[2] = src[-2];
+ ap->fdback[3] = src[-1];
+ }
+ }
+ return 0;
+}
+#endif
diff --git a/beecrypt/aes.h b/beecrypt/aes.h
new file mode 100644
index 000000000..3e6fa12c9
--- /dev/null
+++ b/beecrypt/aes.h
@@ -0,0 +1,66 @@
+/*
+ * aes.h
+ *
+ * AES block cipher, header
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _AES_H
+#define _AES_H
+
+#include "beecrypt.h"
+#include "aesopt.h"
+
+typedef struct
+{
+ uint32 k[64];
+ uint32 nr;
+ uint32 fdback[4];
+} aesParam;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const BEECRYPTAPI blockCipher aes;
+
+BEECRYPTAPI
+int aesSetup (aesParam*, const uint32*, int, cipherOperation);
+BEECRYPTAPI
+int aesSetIV (aesParam*, const uint32*);
+BEECRYPTAPI
+int aesEncrypt(aesParam*, uint32*, const uint32*);
+BEECRYPTAPI
+int aesDecrypt(aesParam*, uint32*, const uint32*);
+
+BEECRYPTAPI
+int aesECBEncrypt(aesParam*, int, uint32*, const uint32*);
+BEECRYPTAPI
+int aesECBDecrypt(aesParam*, int, uint32*, const uint32*);
+
+BEECRYPTAPI
+int aesCBCEncrypt(aesParam*, int, uint32*, const uint32*);
+BEECRYPTAPI
+int aesCBCDecrypt(aesParam*, int, uint32*, const uint32*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/beecrypt/aesopt.h b/beecrypt/aesopt.h
new file mode 100644
index 000000000..6f9c1e5ca
--- /dev/null
+++ b/beecrypt/aesopt.h
@@ -0,0 +1,70 @@
+/*
+ * aesopt.h
+ *
+ * AES block cipher assembler-optimized routines, header
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _AESOPT_H
+#define _AESOPT_H
+
+#include "beecrypt.h"
+#include "aes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if WIN32
+# if defined(_MSC_VER) && defined(_M_IX86)
+# define ASM_AESENCRYPT
+# define ASM_AESDECRYPT
+# elif __INTEL__ && __MWERKS__
+# undef ASM_AESENCRYPT
+# undef ASM_AESDECRYPT
+# endif
+#endif
+
+#if defined(__GNUC__)
+# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
+# define ASM_AESENCRYPT
+# define ASM_AESDECRYPT
+# define ASM_AESECBENCRYPT
+# define ASM_AESECBDECRYPT
+# endif
+# if defined(OPTIMIZE_POWERPC)
+# define ASM_AESENCRYPT
+# define ASM_AESDECRYPT
+# define ASM_AESECBENCRYPT
+# define ASM_AESECBDECRYPT
+# endif
+#endif
+
+#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+#if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
+#define ASM_AESENCRYPT
+#define ASM_AESDECRYPT
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/beecrypt/beecrypt.api.h b/beecrypt/beecrypt.api.h
new file mode 100644
index 000000000..5ab7d266f
--- /dev/null
+++ b/beecrypt/beecrypt.api.h
@@ -0,0 +1,49 @@
+#ifndef _BEECRYPT_API_H
+#define _BEECRYPT_API_H
+
+#if defined(_WIN32) && !defined(WIN32)
+# define WIN32 1
+#endif
+
+#if WIN32 && !__CYGWIN32__
+# include "beecrypt.win.h"
+# ifdef BEECRYPT_DLL_EXPORT
+# define BEECRYPTAPI __declspec(dllexport)
+# else
+# define BEECRYPTAPI __declspec(dllimport)
+# endif
+/*typedef UINT8_TYPE byte;*/
+#else
+# include "beecrypt.gnu.h"
+# define BEECRYPTAPI
+typedef UINT8_TYPE byte;
+#endif
+
+#ifndef ROTL32
+# define ROTL32(x, s) (((x) << (s)) | ((x) >> (32 - (s))))
+#endif
+#ifndef ROTR32
+# define ROTR32(x, s) (((x) >> (s)) | ((x) << (32 - (s))))
+#endif
+
+typedef INT8_TYPE int8;
+typedef INT16_TYPE int16;
+typedef INT32_TYPE int32;
+typedef INT64_TYPE int64;
+
+typedef UINT8_TYPE uint8;
+typedef UINT16_TYPE uint16;
+typedef UINT32_TYPE uint32;
+typedef UINT64_TYPE uint64;
+
+typedef INT8_TYPE javabyte;
+typedef INT16_TYPE javashort;
+typedef INT32_TYPE javaint;
+typedef INT64_TYPE javalong;
+
+typedef UINT16_TYPE javachar;
+
+typedef FLOAT4_TYPE javafloat;
+typedef DOUBLE8_TYPE javadouble;
+
+#endif
diff --git a/beecrypt/beecrypt.c b/beecrypt/beecrypt.c
index e614f1b24..0cdf39e3e 100644
--- a/beecrypt/beecrypt.c
+++ b/beecrypt/beecrypt.c
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (c) 1999, 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -41,7 +41,6 @@ typedef struct
#include "endianness.h"
#include "entropy.h"
-#include "fips180.h"
#include "fips186.h"
#include "hmacmd5.h"
#include "hmacsha1.h"
@@ -49,8 +48,10 @@ typedef struct
#include "md5.h"
#include "mp32.h"
#include "mtprng.h"
+#include "sha1.h"
#include "sha256.h"
+#include "aes.h"
#include "blowfish.h"
#include "blockmode.h"
@@ -707,6 +708,7 @@ int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext* ctxt, const mp
/*@observer@*/ /*@unchecked@*/
static const blockCipher* blockCipherList[] =
{
+ &aes,
&blowfish
};
/*@=type@*/
diff --git a/beecrypt/beecrypt.def b/beecrypt/beecrypt.def
index 3a8af13d5..51640c0b6 100644
--- a/beecrypt/beecrypt.def
+++ b/beecrypt/beecrypt.def
@@ -3,7 +3,7 @@
;
; BeeCrypt DLL exports
;
-; Copyright (c) 2000, 2001 Virtual Unlimited B.V.
+; Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V.
;
; Author: Bob Deblier <bob@virtualunlimited.com>
;
@@ -26,6 +26,14 @@ LIBRARY beecrypt
EXPORTS
DllMain
+ aes data
+ aesCBCDecrypt
+ aesCBCEncrypt
+ aesDecrypt
+ aesECBDecrypt
+ aesECBEncrypt
+ aesEncrypt
+ aesSetup
b64enc
b64dec
blockCipherContextFree
@@ -39,11 +47,11 @@ EXPORTS
blockEncrypt
blockDecrypt
blowfish data
- blowfishCBCEncrypt
blowfishCBCDecrypt
+ blowfishCBCEncrypt
blowfishDecrypt
- blowfishECBEncrypt
blowfishECBDecrypt
+ blowfishECBEncrypt
blowfishEncrypt
blowfishSetup
decodeByte
@@ -88,6 +96,8 @@ EXPORTS
dlpk_pgoqValidate
dlpk_pgonValidate
dlsvdp_pDHSecret
+ dsasign
+ dsavrfy
elgv1sign
elgv1vrfy
elgv3sign
@@ -282,6 +292,7 @@ EXPORTS
randomGeneratorDefault
randomGeneratorContextInit
randomGeneratorContextFree
+ randomGeneratorContextNext
rsapri
rsapricrt
rsavrfy
diff --git a/beecrypt/config.gas.h b/beecrypt/beecrypt.gas.h
index f27de3f9e..00957c3e0 100644
--- a/beecrypt/config.gas.h
+++ b/beecrypt/beecrypt.gas.h
@@ -1,17 +1,17 @@
-#ifndef _CONFIG_GAS_H
-#define _CONFIG_GAS_H
+#ifndef _BEECRYPT_GAS_H
+#define _BEECRYPT_GAS_H
#include "config.h"
-#ifndef C_FUNCTION_NAME
+#ifndef SYMBOL_NAME
# if LEADING_UNDERSCORE
# ifdef __STDC__
-# define C_FUNCTION_NAME(name) _##name
+# define SYMBOL_NAME(name) _##name
# else
-# define C_FUNCTION_NAME(name) _/**/name
+# define SYMBOL_NAME(name) _/**/name
# endif
# else
-# define C_FUNCTION_NAME(name) name
+# define SYMBOL_NAME(name) name
# endif
#endif
@@ -31,7 +31,7 @@
# define ALIGNMENT 8
#endif
-#define LABEL(name) C_FUNCTION_NAME(name):
+#define LABEL(name) SYMBOL_NAME(name):
#if DARWIN
# define LOCAL(name) L##name
#else
@@ -45,8 +45,8 @@
#if CYGWIN
# define C_FUNCTION_BEGIN(name) \
.align ALIGNMENT; \
- .globl C_FUNCTION_NAME(name); \
- .def C_FUNCTION_NAME(name); \
+ .globl SYMBOL_NAME(name); \
+ .def SYMBOL_NAME(name); \
.scl 2; \
.type 32; \
.endef
@@ -61,7 +61,7 @@
# endif
# if DARWIN
# define C_FUNCTION_BEGIN(name) \
- .globl C_FUNCTION_NAME(name)
+ .globl SYMBOL_NAME(name)
# define C_FUNCTION_END(name, label)
# elif defined(OPTIMIZE_IA64)
# define C_FUNCTION_BEGIN(name) \
@@ -73,9 +73,49 @@
# else
# define C_FUNCTION_BEGIN(name) \
.align ALIGNMENT; \
- .global C_FUNCTION_NAME(name)
+ .global SYMBOL_NAME(name)
# define C_FUNCTION_END(name, label) \
- label: .size C_FUNCTION_NAME(name), label - C_FUNCTION_NAME(name);
+ label: .size SYMBOL_NAME(name), label - SYMBOL_NAME(name);
+# endif
+#endif
+
+#if defined(OPTIMIZE_POWERPC)
+# if DARWIN
+# define LOAD_ADDRESS(reg,var) lis reg,ha16(var); la reg,lo16(var)(reg)
+# else
+# define LOAD_ADDRESS(reg,var) lis reg,var@ha; la reg,var@l(reg)
+# define r0 %r0
+# define r1 %r1
+# define r2 %r2
+# define r3 %r3
+# define r4 %r4
+# define r5 %r5
+# define r6 %r6
+# define r7 %r7
+# define r8 %r8
+# define r9 %r9
+# define r10 %r10
+# define r11 %r11
+# define r12 %r12
+# define r13 %r13
+# define r14 %r14
+# define r15 %r15
+# define r16 %r16
+# define r17 %r17
+# define r18 %r18
+# define r19 %r19
+# define r20 %r20
+# define r21 %r21
+# define r22 %r22
+# define r23 %r23
+# define r24 %r24
+# define r25 %r25
+# define r26 %r26
+# define r27 %r27
+# define r28 %r28
+# define r29 %r29
+# define r30 %r30
+# define r31 %r31
# endif
#endif
diff --git a/beecrypt/beecrypt.gnu.h.in b/beecrypt/beecrypt.gnu.h.in
new file mode 100644
index 000000000..56ae774cd
--- /dev/null
+++ b/beecrypt/beecrypt.gnu.h.in
@@ -0,0 +1,197 @@
+/* beecrypt.gnu.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define as __inline if that's what the C compiler calls it. */
+#undef inline
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+#undef size_t
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if your processor stores words with the most significant
+ byte first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
+#define AIX 0
+#define BEOS 0
+#define CYGWIN 0
+#define DARWIN 0
+#define FREEBSD 0
+#define HPUX 0
+#define LINUX 0
+#define MACOSX 0
+#define NETBSD 0
+#define OPENBSD 0
+#define OSF 0
+#define QNX 0
+#define SCO_UNIX 0
+#define SOLARIS 0
+#ifndef WIN32
+# define WIN32 0
+#endif
+
+#define LEADING_UNDERSCORE 0
+#define NO_UNDERSCORES 0
+
+#define JAVAGLUE 0
+
+#undef ENABLE_THREADS
+#undef HAVE_THREAD_H
+#undef HAVE_PTHREAD_H
+#undef HAVE_SYNCH_H
+#undef HAVE_SEMAPHORE_H
+
+#undef ENABLE_AIO
+#undef HAVE_AIO_H
+
+#undef HAVE_GETTIMEOFDAY
+#undef HAVE_GETHRTIME
+
+#undef HAVE_DEV_DSP
+#undef HAVE_DEV_AUDIO
+#undef HAVE_DEV_RANDOM
+#undef HAVE_DEV_URANDOM
+#undef HAVE_DEV_TTY
+
+#undef HAVE_LONG_LONG
+#undef HAVE_UNSIGNED_LONG_LONG
+
+#undef INT8_TYPE
+#undef INT16_TYPE
+#undef INT32_TYPE
+#undef INT64_TYPE
+
+#undef UINT8_TYPE
+#undef UINT16_TYPE
+#undef UINT32_TYPE
+#undef UINT64_TYPE
+
+#undef FLOAT4_TYPE
+#undef DOUBLE8_TYPE
+
+#if LINUX
+#define _LIBC_REENTRANT
+#endif
+
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* The number of bytes in a char. */
+#undef SIZEOF_CHAR
+
+/* The number of bytes in a double. */
+#undef SIZEOF_DOUBLE
+
+/* The number of bytes in a float. */
+#undef SIZEOF_FLOAT
+
+/* The number of bytes in a int. */
+#undef SIZEOF_INT
+
+/* The number of bytes in a long. */
+#undef SIZEOF_LONG
+
+/* The number of bytes in a long long. */
+#undef SIZEOF_LONG_LONG
+
+/* The number of bytes in a short. */
+#undef SIZEOF_SHORT
+
+/* The number of bytes in a unsigned char. */
+#undef SIZEOF_UNSIGNED_CHAR
+
+/* The number of bytes in a unsigned int. */
+#undef SIZEOF_UNSIGNED_INT
+
+/* The number of bytes in a unsigned long. */
+#undef SIZEOF_UNSIGNED_LONG
+
+/* The number of bytes in a unsigned long long. */
+#undef SIZEOF_UNSIGNED_LONG_LONG
+
+/* The number of bytes in a unsigned short. */
+#undef SIZEOF_UNSIGNED_SHORT
+
+/* Define if you have the <aio.h> header file. */
+#undef HAVE_AIO_H
+
+/* Define if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
+/* Define if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define if you have the <mtmalloc.h> header file. */
+#undef HAVE_MTMALLOC_H
+
+/* Define if you have the <pthread.h> header file. */
+#undef HAVE_PTHREAD_H
+
+/* Define if you have the <semaphore.h> header file. */
+#undef HAVE_SEMAPHORE_H
+
+/* Define if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <synch.h> header file. */
+#undef HAVE_SYNCH_H
+
+/* Define if you have the <sys/audioio.h> header file. */
+#undef HAVE_SYS_AUDIOIO_H
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define if you have the <sys/soundcard.h> header file. */
+#undef HAVE_SYS_SOUNDCARD_H
+
+/* Define if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Define if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
+/* Define if you have the <thread.h> header file. */
+#undef HAVE_THREAD_H
+
+/* Define if you have the <time.h> header file. */
+#undef HAVE_TIME_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the mtmalloc library (-lmtmalloc). */
+#undef HAVE_LIBMTMALLOC
+
+/* Define if you have the pthread library (-lpthread). */
+#undef HAVE_LIBPTHREAD
+
+/* Define if you have the thread library (-lthread). */
+#undef HAVE_LIBTHREAD
+
+/* Name of package */
+#undef PACKAGE
+
+/* Version number of package */
+#undef VERSION
+
diff --git a/beecrypt/beecrypt.mcp b/beecrypt/beecrypt.mcp
deleted file mode 100644
index 805bcbc62..000000000
--- a/beecrypt/beecrypt.mcp
+++ /dev/null
Binary files differ
diff --git a/beecrypt/config.win.h b/beecrypt/beecrypt.win.h
index 5107b4bb2..1c0a679ce 100644
--- a/beecrypt/config.win.h
+++ b/beecrypt/beecrypt.win.h
@@ -61,7 +61,6 @@
#define HAVE_TIME_H 1
#define HAVE_SYS_TYPES_H 0
-#define HAVE_SYS_STAT_H 0
#define HAVE_SYS_TIME_H 0
#define HAVE_THREAD_H 0
@@ -92,6 +91,8 @@
#define HAVE_UNISTD_H 1
#define HAVE_MALLOC_H 1
+#define HAVE_SYS_STAT_H 0
+
#define HAVE_LONG_LONG 1
#define INT8_TYPE char
@@ -109,6 +110,8 @@
#define HAVE_UNISTD_H 0
#define HAVE_MALLOC_H 1
+#define HAVE_SYS_STAT_H 1
+
#define HAVE_LONG_LONG 0
#define INT8_TYPE __int8
diff --git a/beecrypt/blowfishopt.h b/beecrypt/blowfishopt.h
index 23280c43f..1ae2c5b81 100644
--- a/beecrypt/blowfishopt.h
+++ b/beecrypt/blowfishopt.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2000 Virtual Unlimited B.V.
+ * Copyright (c) 2000, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -50,6 +50,12 @@ extern "C" {
# define ASM_BLOWFISHENCRYPT
# define ASM_BLOWFISHDECRYPT
# endif
+# if defined(OPTIMIZE_POWERPC)
+# define ASM_BLOWFISHENCRYPT
+# define ASM_BLOWFISHDECRYPT
+# define ASM_BLOWFISHECBENCRYPT
+# define ASM_BLOWFISHECBDECRYPT
+# endif
#endif
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
diff --git a/beecrypt/config.h b/beecrypt/config.h
index e7d3b2631..395f05f49 100644
--- a/beecrypt/config.h
+++ b/beecrypt/config.h
@@ -50,7 +50,7 @@
#define LEADING_UNDERSCORE 0
#define NO_UNDERSCORES 1
-#define JAVAGLUE 0
+#define JAVAGLUE 1
#define HAVE_ERRNO_H 1
#define HAVE_STRING_H 1
diff --git a/beecrypt/configure.in b/beecrypt/configure.in
index 8a74c2e63..f71ab13c3 100644
--- a/beecrypt/configure.in
+++ b/beecrypt/configure.in
@@ -736,9 +736,10 @@ case $target_os in
esac
dnl Generate the assembler optimizations
+rm -f $srcdir/aesopt.c $srcdir/aesopt.S
rm -f $srcdir/blowfishopt.c $srcdir/blowfishopt.S
-rm -f $srcdir/fips180opt.c $srcdir/fips180opt.S
rm -f $srcdir/mp32opt.c $srcdir/mp32opt.S
+rm -f $srcdir/sha1opt.c $srcdir/sha1opt.S
if test "$ac_enable_optimized" = yes; then
case $target_cpu in
arm*)
@@ -752,15 +753,18 @@ EOF
EOF
;;
i[[56]]86)
+ cat > $srcdir/aesopt.S << EOF
+#include "gas/aesopt.i586.S"
+EOF
cat > $srcdir/blowfishopt.S << EOF
#include "gas/blowfishopt.i586.S"
EOF
- cat > $srcdir/fips180opt.S << EOF
-#include "gas/fips180opt.i586.S"
-EOF
cat > $srcdir/mp32opt.S << EOF
#include "gas/mp32opt.i386.S"
EOF
+ cat > $srcdir/sha1opt.S << EOF
+#include "gas/sha1opt.i586.S"
+EOF
;;
ia64)
cat > $srcdir/mp32opt.S << EOF
@@ -768,11 +772,17 @@ EOF
EOF
;;
powerpc)
+ cat > $srcdir/aesopt.S << EOF
+#include "gas/aesopt.powerpc.S"
+EOF
+ cat > $srcdir/blowfishopt.S << EOF
+#include "gas/blowfishopt.powerpc.S"
+EOF
cat > $srcdir/mp32opt.S << EOF
#include "gas/mp32opt.powerpc.S"
EOF
;;
- sparcv8)
+ sparcv8)
cat > $srcdir/mp32opt.S << EOF
#include "gas/mp32opt.sparcv8.S"
EOF
@@ -784,18 +794,22 @@ EOF
;;
esac
fi
-if test ! -r $srcdir/blowfishopt.S; then
- cat > $srcdir/blowfishopt.c << EOF
+if test ! -r $srcdir/aesopt.S; then
+ cat > $srcdir/aesopt.c << EOF
EOF
fi
-if test ! -r $srcdir/fips180opt.S; then
- cat > $srcdir/fips180opt.c << EOF
+if test ! -r $srcdir/blowfishopt.S; then
+ cat > $srcdir/blowfishopt.c << EOF
EOF
fi
if test ! -r $srcdir/mp32opt.S; then
cat > $srcdir/mp32opt.c << EOF
EOF
fi
+if test ! -r $srcdir/sha1opt.S; then
+ cat > $srcdir/sha1opt.c << EOF
+EOF
+fi
dnl Output
AC_OUTPUT([ Doxyfile Makefile beecrypt.spec types.h
diff --git a/beecrypt/dsa.c b/beecrypt/dsa.c
index f006300db..dc2212b04 100644
--- a/beecrypt/dsa.c
+++ b/beecrypt/dsa.c
@@ -54,66 +54,66 @@ int dsasign(const mp32barrett* p, const mp32barrett* q, const mp32number* g, ran
{
register uint32 psize = p->size;
register uint32 qsize = q->size;
- /* k + inv(k) = 2 * qsize */
- /* g^k mod p = psize+4*psize+2 */
register uint32* ptemp;
register uint32* qtemp;
+
+ register uint32* pwksp;
+ register uint32* qwksp;
+
register int rc = -1; /* assume failure */
ptemp = (uint32*) malloc((5*psize+2) * sizeof(*ptemp));
if (ptemp == NULL)
return rc;
- qtemp = (uint32*) malloc((9*qsize+6) * sizeof(*qtemp));
+ qtemp = (uint32*) malloc((14*qsize+11) * sizeof(*qtemp));
if (qtemp == NULL) {
free(ptemp);
return rc;
}
- {
- register uint32* pwksp = ptemp+psize;
- register uint32* qwksp = qtemp+3*qsize;
+ pwksp = ptemp+psize;
+ qwksp = qtemp+3*qsize;
- /* allocate r */
- mp32nfree(r);
- mp32nsize(r, qsize);
+ /* allocate r */
+ mp32nfree(r);
+ mp32nsize(r, qsize);
- /* get a random k, invertible modulo q */
- mp32brndinv_w(q, rgc, qtemp, qtemp+qsize, qwksp);
+ /* get a random k, invertible modulo q */
+ mp32brndinv_w(q, rgc, qtemp, qtemp+qsize, qwksp);
-#if 0
-/* FIPS 186 test vectors for k, http://www.itl.nist.gov/fipspubs/186chg-1.htm */
- qtemp[0] = 0x358dad57;
- qtemp[1] = 0x1462710f;
- qtemp[2] = 0x50e254cf;
- qtemp[3] = 0x1a376b2b;
- qtemp[4] = 0xdeaadfbf;
+/* FIPS 186 test vectors
+ qtemp[0] = 0x358dad57;
+ qtemp[1] = 0x1462710f;
+ qtemp[2] = 0x50e254cf;
+ qtemp[3] = 0x1a376b2b;
+ qtemp[4] = 0xdeaadfbf;
- mp32binv_w(q, qsize, qtemp, qtemp+qsize, qwksp);
-#endif
+ mp32binv_w(q, qsize, qtemp, qtemp+qsize, qwksp);
+*/
- /* g^k mod p */
- mp32bpowmod_w(p, g->size, g->data, qsize, qtemp, ptemp, pwksp);
+ /* g^k mod p */
+ mp32bpowmod_w(p, g->size, g->data, qsize, qtemp, ptemp, pwksp);
- /* (g^k mod p) mod q - simple modulo */
- mp32nmod(qtemp+2*qsize, psize, ptemp, qsize, q->modl, pwksp);
- mp32copy(qsize, r->data, qtemp+psize+qsize);
+ /* (g^k mod p) mod q - simple modulo */
+ mp32nmod(qtemp+2*qsize, psize, ptemp, qsize, q->modl, pwksp);
+ mp32copy(qsize, r->data, qtemp+psize+qsize);
- /* allocate s */
- mp32nfree(s);
- mp32nsize(s, qsize);
+ /* allocate s */
+ mp32nfree(s);
+ mp32nsize(s, qsize);
- /* x*r mod q */
- mp32bmulmod_w(q, x->size, x->data, r->size, r->data, qtemp, qwksp);
+ /* x*r mod q */
+ mp32bmulmod_w(q, x->size, x->data, r->size, r->data, qtemp, qwksp);
- /* add h(m) mod q */
- mp32baddmod_w(q, qsize, qtemp, hm->size, hm->data, qtemp+2*qsize, qwksp);
+ /* add h(m) mod q */
+ mp32baddmod_w(q, qsize, qtemp, hm->size, hm->data, qtemp+2*qsize, qwksp);
- /* multiply inv(k) mod q */
- mp32bmulmod_w(q, qsize, qtemp+qsize, qsize, qtemp+2*qsize, s->data, qwksp);
- rc = 0;
+ /* multiply inv(k) mod q */
+ mp32bmulmod_w(q, qsize, qtemp+qsize, qsize, qtemp+2*qsize, s->data, qwksp);
+
+ rc = 0;
- }
free(qtemp);
free(ptemp);
@@ -124,8 +124,13 @@ int dsavrfy(const mp32barrett* p, const mp32barrett* q, const mp32number* g, con
{
register uint32 psize = p->size;
register uint32 qsize = q->size;
+
register uint32* ptemp;
register uint32* qtemp;
+
+ register uint32* pwksp;
+ register uint32* qwksp;
+
register int rc = 0; /* XXX shouldn't this be -1 ?*/
if (mp32z(r->size, r->data))
@@ -150,69 +155,31 @@ int dsavrfy(const mp32barrett* p, const mp32barrett* q, const mp32number* g, con
return rc;
}
+ pwksp = ptemp+2*psize;
+ qwksp = qtemp+2*qsize;
+
+ /* compute w = inv(s) mod q */
+ if (mp32binv_w(q, s->size, s->data, qtemp, qwksp))
{
- register uint32* pwksp = ptemp+2*psize;
- register uint32* qwksp = qtemp+2*qsize;
-
-if (_debug) {
-/*@-modfilesys@*/
-fprintf(stderr, "\t q: "), mp32println(stderr, q->size, q->modl);
-fprintf(stderr, "\t hm: "), mp32println(stderr, hm->size, hm->data);
-fprintf(stderr, "\t r: "), mp32println(stderr, r->size, r->data);
-fprintf(stderr, "\t s: "), mp32println(stderr, s->size, s->data);
-/*@=modfilesys@*/
-}
- /* compute w = inv(s) mod q */
- if (mp32binv_w(q, s->size, s->data, qtemp, qwksp))
- {
-/*@-modfilesys@*/
-if (_debug)
-fprintf(stderr, "\t w = inv(s) mod q: "), mp32println(stderr, qsize, qtemp);
-/*@=modfilesys@*/
- /* compute u1 = h(m)*w mod q */
- mp32bmulmod_w(q, hm->size, hm->data, qsize, qtemp, qtemp+qsize, qwksp);
-/*@-modfilesys@*/
-if (_debug)
-fprintf(stderr, "\tu1 = h(m)*w mod q: "), mp32println(stderr, qsize, qtemp+qsize);
-/*@=modfilesys@*/
-
- /* compute u2 = r*w mod q */
- mp32bmulmod_w(q, r->size, r->data, qsize, qtemp, qtemp, qwksp);
-/*@-modfilesys@*/
-if (_debug)
-fprintf(stderr, "\tu2 = r*w mod q : "), mp32println(stderr, qsize, qtemp);
-/*@=modfilesys@*/
-
- /* compute g^u1 mod p */
- mp32bpowmod_w(p, g->size, g->data, qsize, qtemp+qsize, ptemp, pwksp);
-/*@-modfilesys@*/
-if (_debug)
-fprintf(stderr, "\t g^u1 mod p: "), mp32println(stderr, psize, ptemp);
-/*@=modfilesys@*/
-
- /* compute y^u2 mod p */
- mp32bpowmod_w(p, y->size, y->data, qsize, qtemp, ptemp+psize, pwksp);
-/*@-modfilesys@*/
-if (_debug)
-fprintf(stderr, "\t y^u2 mod p: "), mp32println(stderr, psize, ptemp+psize);
-/*@=modfilesys@*/
-
- /* multiply mod p */
- mp32bmulmod_w(p, psize, ptemp, psize, ptemp+psize, ptemp, pwksp);
-/*@-modfilesys@*/
-if (_debug)
-fprintf(stderr, "\t multiply mod p: "), mp32println(stderr, psize, ptemp);
-/*@=modfilesys@*/
-
- /* modulo q */
- mp32nmod(ptemp+psize, psize, ptemp, qsize, q->modl, pwksp);
-/*@-modfilesys@*/
-if (_debug)
-fprintf(stderr, "\tr' mod q : "), mp32println(stderr, psize, ptemp+psize);
-/*@=modfilesys@*/
-
- rc = mp32eqx(r->size, r->data, psize, ptemp+psize);
- }
+ /* compute u1 = h(m)*w mod q */
+ mp32bmulmod_w(q, hm->size, hm->data, qsize, qtemp, qtemp+qsize, qwksp);
+
+ /* compute u2 = r*w mod q */
+ mp32bmulmod_w(q, r->size, r->data, qsize, qtemp, qtemp, qwksp);
+
+ /* compute g^u1 mod p */
+ mp32bpowmod_w(p, g->size, g->data, qsize, qtemp+qsize, ptemp, pwksp);
+
+ /* compute y^u2 mod p */
+ mp32bpowmod_w(p, y->size, y->data, qsize, qtemp, ptemp+psize, pwksp);
+
+ /* multiply mod p */
+ mp32bmulmod_w(p, psize, ptemp, psize, ptemp+psize, ptemp, pwksp);
+
+ /* modulo q */
+ mp32nmod(ptemp+psize, psize, ptemp, qsize, q->modl, pwksp);
+
+ rc = mp32eqx(r->size, r->data, psize, ptemp+psize);
}
free(qtemp);
diff --git a/beecrypt/endianness.c b/beecrypt/endianness.c
index d54db9098..84a929460 100644
--- a/beecrypt/endianness.c
+++ b/beecrypt/endianness.c
@@ -184,6 +184,30 @@ int encodeIntsPartial(const javaint* i, byte* data, int bytecount)
return rc;
}
+int encodeIntsPartialPad(const javaint* i, byte* data, int bytecount, byte padvalue)
+{
+ register int rc = bytecount;
+
+ #if (WORDS_BIGENDIAN)
+ memcpy(data, i, rc);
+ if (rc & 0x3)
+ memset(data+rc, padvalue, 4 -(rc & 0x3));
+ #else
+ javaint tmp;
+
+ while (bytecount > 0)
+ {
+ tmp = swap32(*(i++));
+ memcpy(data, &tmp, (bytecount > 4) ? 4 : bytecount);
+ data += 4;
+ bytecount -= 4;
+ }
+ if (bytecount)
+ memset(data+bytecount, padvalue, -bytecount);
+ #endif
+ return rc;
+}
+
int encodeChars(const javachar* c, byte* data, int count)
{
register int rc = ((uint32)count) << 1;
diff --git a/beecrypt/endianness.h b/beecrypt/endianness.h
index 4f59bafb7..9235613e8 100644
--- a/beecrypt/endianness.h
+++ b/beecrypt/endianness.h
@@ -187,6 +187,12 @@ int encodeIntsPartial(const javaint* i, /*@out@*/ byte* data, int bytecount)
/**
*/
BEECRYPTAPI /*@unused@*/
+int encodeIntsPartialPad(const javaint* i, byte* data, int bytecount, byte padvalue)
+ /*@modifies data */;
+
+/**
+ */
+BEECRYPTAPI /*@unused@*/
int encodeChars(const javachar* c, /*@out@*/ byte* data, int count)
/*@modifies data */;
diff --git a/beecrypt/entropy.c b/beecrypt/entropy.c
index 62d90f0e5..1291176d6 100644
--- a/beecrypt/entropy.c
+++ b/beecrypt/entropy.c
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 1998, 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
diff --git a/beecrypt/fips186.c b/beecrypt/fips186.c
index 72fae95a6..9acf6c5e9 100644
--- a/beecrypt/fips186.c
+++ b/beecrypt/fips186.c
@@ -58,10 +58,10 @@ int fips186Setup(fips186Param* fp)
if (!(fp->lock = CreateMutex(NULL, FALSE, NULL)))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_init(&fp->lock, USYNC_THREAD, (void *) 0))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-nullpass@*/
/*@-moduncon@*/
if (pthread_mutex_init(&fp->lock, (pthread_mutexattr_t *) 0))
@@ -88,10 +88,10 @@ int fips186Seed(fips186Param* fp, const uint32* data, int size)
if (WaitForSingleObject(fp->lock, INFINITE) != WAIT_OBJECT_0)
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_lock(&fp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_lock(&fp->lock))
return -1;
@@ -106,10 +106,10 @@ int fips186Seed(fips186Param* fp, const uint32* data, int size)
if (!ReleaseMutex(fp->lock))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_unlock(&fp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_unlock(&fp->lock))
return -1;
@@ -131,10 +131,10 @@ int fips186Next(fips186Param* fp, uint32* data, int size)
if (WaitForSingleObject(fp->lock, INFINITE) != WAIT_OBJECT_0)
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_lock(&fp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_lock(&fp->lock))
return -1;
@@ -171,10 +171,10 @@ int fips186Next(fips186Param* fp, uint32* data, int size)
if (!ReleaseMutex(fp->lock))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_unlock(&fp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_unlock(&fp->lock))
return -1;
@@ -196,10 +196,10 @@ int fips186Cleanup(fips186Param* fp)
if (!CloseHandle(fp->lock))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_destroy(&fp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_destroy(&fp->lock))
return -1;
diff --git a/beecrypt/fips186.h b/beecrypt/fips186.h
index 99e09d9b4..18a0b3a75 100644
--- a/beecrypt/fips186.h
+++ b/beecrypt/fips186.h
@@ -35,7 +35,7 @@
# include <windows.h>
# include <winbase.h>
# else
-# if HAVE_SYNCH_H
+# if HAVE_THREAD_H && HAVE_SYNCH_H
# include <synch.h>
# elif HAVE_PTHREAD_H
# include <pthread.h>
@@ -46,7 +46,7 @@
#endif
#include "beecrypt.h"
-#include "fips180.h"
+#include "sha1.h"
#define FIPS186_STATE_SIZE 16
@@ -58,7 +58,7 @@ typedef struct
# if WIN32
HANDLE lock;
# else
- # if HAVE_SYNCH_H
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
mutex_t lock;
# elif HAVE_PTHREAD_H
pthread_mutex_t lock;
diff --git a/beecrypt/gas/Makefile.am b/beecrypt/gas/Makefile.am
index 829dda62a..4a65cbbe0 100644
--- a/beecrypt/gas/Makefile.am
+++ b/beecrypt/gas/Makefile.am
@@ -1,7 +1,7 @@
#
# Makefile.am's purpose is to add the GNU Assembler sources to the dist
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -22,4 +22,4 @@
AUTOMAKE_OPTIONS = gnu no-dependencies
-SOURCES = blowfishopt.i586.S fips180opt.i586.S mp32opt.arm.S mp32opt.i386.S mp32opt.ia64.S mp32opt.powerpc.S mp32opt.sparcv8.S mp32opt.sparcv9.S mp64opt.ia64.S
+EXTRA_DIST = aesopt.i586.S aesopt.powerpc.S blowfishopt.i586.S blowfishopt.powerpc.S sha1opt.i586.S mp32opt.arm.S mp32opt.i386.S mp32opt.ia64.S mp32opt.powerpc.S mp32opt.sparcv8.S mp32opt.sparcv9.S mp64opt.ia64.S
diff --git a/beecrypt/gas/Makefile.in b/beecrypt/gas/Makefile.in
index 2f827f331..bac50e090 100644
--- a/beecrypt/gas/Makefile.in
+++ b/beecrypt/gas/Makefile.in
@@ -17,7 +17,7 @@
#
# Makefile.am's purpose is to add the GNU Assembler sources to the dist
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -127,7 +127,7 @@ uint8_type = @uint8_type@
AUTOMAKE_OPTIONS = gnu no-dependencies
-EXTRA_DIST = blowfishopt.i586.S fips180opt.i586.S mp32opt.arm.S mp32opt.i386.S mp32opt.ia64.S mp32opt.powerpc.S mp32opt.sparcv8.S mp32opt.sparcv9.S mp64opt.ia64.S
+EXTRA_DIST = aesopt.i586.S aesopt.powerpc.S blowfishopt.i586.S blowfishopt.powerpc.S sha1opt.i586.S mp32opt.arm.S mp32opt.i386.S mp32opt.ia64.S mp32opt.powerpc.S mp32opt.sparcv8.S mp32opt.sparcv9.S mp64opt.ia64.S
subdir = gas
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
diff --git a/beecrypt/gas/aesopt.i586.S b/beecrypt/gas/aesopt.i586.S
new file mode 100644
index 000000000..deb0853b7
--- /dev/null
+++ b/beecrypt/gas/aesopt.i586.S
@@ -0,0 +1,688 @@
+/*
+ * aesopt.i586.asm
+ *
+ * Assembler optimized AES routines for Intel Pentium processors
+ *
+ * Compile target is GNU Assembler
+ *
+ * Copyright (c) 2002 Bob Deblier <bob@virtualunlimited.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "beecrypt.gas.h"
+
+ .file "aesopt.i586.S"
+
+ .text
+
+ .macro sxrk
+ movl (%esi),%eax
+ movl 4(%esi),%ebx
+ movl 8(%esi),%ecx
+ movl 12(%esi),%edx
+ bswap %eax
+ bswap %ebx
+ bswap %ecx
+ bswap %edx
+ xorl (%ebp),%eax
+ xorl 4(%ebp),%ebx
+ xorl 8(%ebp),%ecx
+ xorl 12(%ebp),%edx
+ movl %eax, (%esp)
+ movl %ebx, 4(%esp)
+ movl %ecx, 8(%esp)
+ movl %edx,12(%esp)
+ .endm
+
+ .macro etfs offset
+ movl \offset+ 0(%ebp),%ecx
+ movl \offset+ 4(%ebp),%edx
+
+ movzbl 3(%esp),%eax
+ movzbl 7(%esp),%ebx
+ xorl SYMBOL_NAME(_ae0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae0)(,%ebx,4),%edx
+
+ movzbl 6(%esp),%eax
+ movzbl 10(%esp),%ebx
+ xorl SYMBOL_NAME(_ae1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae1)(,%ebx,4),%edx
+
+ movzbl 9(%esp),%eax
+ movzbl 13(%esp),%ebx
+ xorl SYMBOL_NAME(_ae2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae2)(,%ebx,4),%edx
+
+ movzbl 12(%esp),%eax
+ movzbl (%esp),%ebx
+ xorl SYMBOL_NAME(_ae3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae3)(,%ebx,4),%edx
+
+ movl %ecx,16(%esp)
+ movl %edx,20(%esp)
+
+ movl \offset+ 8(%ebp),%ecx
+ movl \offset+12(%ebp),%edx
+
+ movzbl 11(%esp),%eax
+ movzbl 15(%esp),%ebx
+ xorl SYMBOL_NAME(_ae0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae0)(,%ebx,4),%edx
+
+ movzbl 14(%esp),%eax
+ movzbl 2(%esp),%ebx
+ xorl SYMBOL_NAME(_ae1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae1)(,%ebx,4),%edx
+
+ movzbl 1(%esp),%eax
+ movzbl 5(%esp),%ebx
+ xorl SYMBOL_NAME(_ae2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae2)(,%ebx,4),%edx
+
+ movzbl 4(%esp),%eax
+ movzbl 8(%esp),%ebx
+ xorl SYMBOL_NAME(_ae3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae3)(,%ebx,4),%edx
+
+ movl %ecx,24(%esp)
+ movl %edx,28(%esp)
+ .endm
+
+ .macro esft offset
+ movl \offset+ 0(%ebp),%ecx
+ movl \offset+ 4(%ebp),%edx
+
+ movzbl 19(%esp),%eax
+ movzbl 23(%esp),%ebx
+ xorl SYMBOL_NAME(_ae0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae0)(,%ebx,4),%edx
+
+ movzbl 22(%esp),%eax
+ movzbl 26(%esp),%ebx
+ xorl SYMBOL_NAME(_ae1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae1)(,%ebx,4),%edx
+
+ movzbl 25(%esp),%eax
+ movzbl 29(%esp),%ebx
+ xorl SYMBOL_NAME(_ae2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae2)(,%ebx,4),%edx
+
+ movzbl 28(%esp),%eax
+ movzbl 16(%esp),%ebx
+ xorl SYMBOL_NAME(_ae3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae3)(,%ebx,4),%edx
+
+ movl %ecx, (%esp)
+ movl %edx, 4(%esp)
+
+ movl \offset+ 8(%ebp),%ecx
+ movl \offset+12(%ebp),%edx
+
+ movzbl 27(%esp),%eax
+ movzbl 31(%esp),%ebx
+ xorl SYMBOL_NAME(_ae0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae0)(,%ebx,4),%edx
+
+ movzbl 30(%esp),%eax
+ movzbl 18(%esp),%ebx
+ xorl SYMBOL_NAME(_ae1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae1)(,%ebx,4),%edx
+
+ movzbl 17(%esp),%eax
+ movzbl 21(%esp),%ebx
+ xorl SYMBOL_NAME(_ae2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae2)(,%ebx,4),%edx
+
+ movzbl 20(%esp),%eax
+ movzbl 24(%esp),%ebx
+ xorl SYMBOL_NAME(_ae3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ae3)(,%ebx,4),%edx
+
+ movl %ecx, 8(%esp)
+ movl %edx,12(%esp)
+ .endm
+
+ .macro elr
+ movl 0(%ebp),%ecx
+ movl 4(%ebp),%edx
+
+ movzbl 19(%esp),%eax
+ movzbl 23(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff000000,%eax
+ andl $0xff000000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 22(%esp),%eax
+ movzbl 26(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff0000,%eax
+ andl $0xff0000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 25(%esp),%eax
+ movzbl 29(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff00,%eax
+ andl $0xff00,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 28(%esp),%eax
+ movzbl 16(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff,%eax
+ andl $0xff,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movl %ecx, (%esp)
+ movl %edx, 4(%esp)
+
+ movl 8(%ebp),%ecx
+ movl 12(%ebp),%edx
+
+ movzbl 27(%esp),%eax
+ movzbl 31(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff000000,%eax
+ andl $0xff000000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 30(%esp),%eax
+ movzbl 18(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff0000,%eax
+ andl $0xff0000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 17(%esp),%eax
+ movzbl 21(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff00,%eax
+ andl $0xff00,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 20(%esp),%eax
+ movzbl 24(%esp),%ebx
+ movl SYMBOL_NAME(_ae4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ae4)(,%ebx,4),%ebx
+ andl $0xff,%eax
+ andl $0xff,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movl %ecx, 8(%esp)
+ movl %edx,12(%esp)
+ .endm
+
+ .macro eblock label
+ sxrk
+
+ etfs 16
+ esft 32
+ etfs 48
+ esft 64
+ etfs 80
+ esft 96
+ etfs 112
+ esft 128
+ etfs 144
+
+ movl 256(%ebp),%eax
+ cmp $10,%eax
+ je \label
+
+ esft 160
+ etfs 176
+
+ movl 256(%ebp),%eax
+ cmp $12,%eax
+ je \label
+
+ esft 192
+ etfs 208
+
+ movl 256(%ebp),%eax
+
+ .align 4
+\label:
+ sall $4,%eax
+ addl %eax,%ebp
+
+ elr
+ .endm
+
+ .macro dtfs offset
+ movl \offset+0(%ebp),%ecx
+ movl \offset+4(%ebp),%edx
+
+ movzbl 3(%esp),%eax
+ movzbl 7(%esp),%ebx
+ xorl SYMBOL_NAME(_ad0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad0)(,%ebx,4),%edx
+
+ movzbl 14(%esp),%eax
+ movzbl 2(%esp),%ebx
+ xorl SYMBOL_NAME(_ad1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad1)(,%ebx,4),%edx
+
+ movzbl 9(%esp),%eax
+ movzbl 13(%esp),%ebx
+ xorl SYMBOL_NAME(_ad2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad2)(,%ebx,4),%edx
+
+ movzbl 4(%esp),%eax
+ movzbl 8(%esp),%ebx
+ xorl SYMBOL_NAME(_ad3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad3)(,%ebx,4),%edx
+
+ movl %ecx,16(%esp)
+ movl %edx,20(%esp)
+
+ movl \offset+ 8(%ebp),%ecx
+ movl \offset+12(%ebp),%edx
+
+ movzbl 11(%esp),%eax
+ movzbl 15(%esp),%ebx
+ xorl SYMBOL_NAME(_ad0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad0)(,%ebx,4),%edx
+
+ movzbl 6(%esp),%eax
+ movzbl 10(%esp),%ebx
+ xorl SYMBOL_NAME(_ad1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad1)(,%ebx,4),%edx
+
+ movzbl 1(%esp),%eax
+ movzbl 5(%esp),%ebx
+ xorl SYMBOL_NAME(_ad2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad2)(,%ebx,4),%edx
+
+ movzbl 12(%esp),%eax
+ movzbl (%esp),%ebx
+ xorl SYMBOL_NAME(_ad3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad3)(,%ebx,4),%edx
+
+ movl %ecx,24(%esp)
+ movl %edx,28(%esp)
+ .endm
+
+ .macro dsft offset
+ movl \offset+ 0(%ebp),%ecx
+ movl \offset+ 4(%ebp),%edx
+
+ movzbl 19(%esp),%eax
+ movzbl 23(%esp),%ebx
+ xorl SYMBOL_NAME(_ad0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad0)(,%ebx,4),%edx
+
+ movzbl 30(%esp),%eax
+ movzbl 18(%esp),%ebx
+ xorl SYMBOL_NAME(_ad1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad1)(,%ebx,4),%edx
+
+ movzbl 25(%esp),%eax
+ movzbl 29(%esp),%ebx
+ xorl SYMBOL_NAME(_ad2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad2)(,%ebx,4),%edx
+
+ movzbl 20(%esp),%eax
+ movzbl 24(%esp),%ebx
+ xorl SYMBOL_NAME(_ad3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad3)(,%ebx,4),%edx
+
+ movl %ecx, (%esp)
+ movl %edx, 4(%esp)
+
+ movl \offset+ 8(%ebp),%ecx
+ movl \offset+12(%ebp),%edx
+
+ movzbl 27(%esp),%eax
+ movzbl 31(%esp),%ebx
+ xorl SYMBOL_NAME(_ad0)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad0)(,%ebx,4),%edx
+
+ movzbl 22(%esp),%eax
+ movzbl 26(%esp),%ebx
+ xorl SYMBOL_NAME(_ad1)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad1)(,%ebx,4),%edx
+
+ movzbl 17(%esp),%eax
+ movzbl 21(%esp),%ebx
+ xorl SYMBOL_NAME(_ad2)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad2)(,%ebx,4),%edx
+
+ movzbl 28(%esp),%eax
+ movzbl 16(%esp),%ebx
+ xorl SYMBOL_NAME(_ad3)(,%eax,4),%ecx
+ xorl SYMBOL_NAME(_ad3)(,%ebx,4),%edx
+
+ movl %ecx, 8(%esp)
+ movl %edx,12(%esp)
+ .endm
+
+ .macro dlr
+ movl 0(%ebp),%ecx
+ movl 4(%ebp),%edx
+
+ movzbl 19(%esp),%eax
+ movzbl 23(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff000000,%eax
+ andl $0xff000000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 30(%esp),%eax
+ movzbl 18(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff0000,%eax
+ andl $0xff0000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 25(%esp),%eax
+ movzbl 29(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff00,%eax
+ andl $0xff00,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 20(%esp),%eax
+ movzbl 24(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff,%eax
+ andl $0xff,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movl %ecx, (%esp)
+ movl %edx, 4(%esp)
+
+ movl 8(%ebp),%ecx
+ movl 12(%ebp),%edx
+
+ movzbl 27(%esp),%eax
+ movzbl 31(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff000000,%eax
+ andl $0xff000000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 22(%esp),%eax
+ movzbl 26(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff0000,%eax
+ andl $0xff0000,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 17(%esp),%eax
+ movzbl 21(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff00,%eax
+ andl $0xff00,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movzbl 28(%esp),%eax
+ movzbl 16(%esp),%ebx
+ movl SYMBOL_NAME(_ad4)(,%eax,4),%eax
+ movl SYMBOL_NAME(_ad4)(,%ebx,4),%ebx
+ andl $0xff,%eax
+ andl $0xff,%ebx
+ xorl %eax,%ecx
+ xorl %ebx,%edx
+
+ movl %ecx, 8(%esp)
+ movl %edx,12(%esp)
+ .endm
+
+ .macro dblock label
+ sxrk
+
+ dtfs 16
+ dsft 32
+ dtfs 48
+ dsft 64
+ dtfs 80
+ dsft 96
+ dtfs 112
+ dsft 128
+ dtfs 144
+
+ movl 256(%ebp),%eax
+ cmp $10,%eax
+ je \label
+
+ dsft 160
+ dtfs 176
+
+ movl 256(%ebp),%eax
+ cmp $12,%eax
+ je \label
+
+ dsft 192
+ dtfs 208
+
+ movl 256(%ebp),%eax
+
+ .align 4
+\label:
+ sall $4,%eax
+ addl %eax,%ebp
+
+ dlr
+ .endm
+
+C_FUNCTION_BEGIN(aesEncrypt)
+LABEL(aesEncrypt)
+ pushl %edi
+ pushl %esi
+ pushl %ebp
+ pushl %ebx
+
+ movl 20(%esp),%ebp
+ movl 24(%esp),%edi
+ movl 28(%esp),%esi
+
+ subl $32,%esp
+
+ eblock LOCAL(00)
+
+ movl (%esp),%eax
+ movl 4(%esp),%ebx
+ movl 8(%esp),%ecx
+ movl 12(%esp),%edx
+ bswap %eax
+ bswap %ebx
+ bswap %ecx
+ bswap %edx
+ movl %eax, (%edi)
+ movl %ebx, 4(%edi)
+ movl %ecx, 8(%edi)
+ movl %edx,12(%edi)
+
+ addl $32,%esp
+
+ xorl %eax,%eax
+
+ popl %ebx
+ popl %ebp
+ popl %esi
+ popl %edi
+ ret
+C_FUNCTION_END(aesEncrypt, LOCAL(aesEncrypt_size))
+
+
+C_FUNCTION_BEGIN(aesDecrypt)
+LABEL(aesDecrypt)
+ pushl %edi
+ pushl %esi
+ pushl %ebp
+ pushl %ebx
+
+ movl 20(%esp),%ebp
+ movl 24(%esp),%edi
+ movl 28(%esp),%esi
+
+ subl $32,%esp
+
+ dblock LOCAL(01)
+
+ movl (%esp),%eax
+ movl 4(%esp),%ebx
+ movl 8(%esp),%ecx
+ movl 12(%esp),%edx
+ bswap %eax
+ bswap %ebx
+ bswap %ecx
+ bswap %edx
+ movl %eax, (%edi)
+ movl %ebx, 4(%edi)
+ movl %ecx, 8(%edi)
+ movl %edx,12(%edi)
+
+ addl $32,%esp
+
+ xorl %eax,%eax
+
+ popl %ebx
+ popl %ebp
+ popl %esi
+ popl %edi
+ ret
+C_FUNCTION_END(aesDecrypt, LOCAL(aesDecrypt_size))
+
+
+C_FUNCTION_BEGIN(aesECBEncrypt)
+LABEL(aesECBEncrypt)
+ pushl %edi
+ pushl %esi
+ pushl %ebp
+ pushl %ebx
+
+ movl 28(%esp),%edi
+ movl 32(%esp),%esi
+
+ subl $32,%esp
+
+ .align 4
+LOCAL(02):
+ movl 52(%esp),%ebp
+
+ eblock LOCAL(03)
+
+ movl (%esp),%eax
+ movl 4(%esp),%ebx
+ movl 8(%esp),%ecx
+ movl 12(%esp),%edx
+ bswap %eax
+ bswap %ebx
+ bswap %ecx
+ bswap %edx
+ movl %eax, (%edi)
+ movl %ebx, 4(%edi)
+ movl %ecx, 8(%edi)
+ movl %edx,12(%edi)
+
+ addl $16,%esi
+ addl $16,%edi
+
+ decl 56(%esp)
+ jnz LOCAL(02)
+
+ addl $32,%esp
+
+ xorl %eax,%eax
+
+ popl %ebx
+ popl %ebp
+ popl %esi
+ popl %edi
+ ret
+C_FUNCTION_END(aesECBEncrypt, LOCAL(aesECBEncrypt_size))
+
+
+C_FUNCTION_BEGIN(aesECBDecrypt)
+LABEL(aesECBDecrypt)
+ pushl %edi
+ pushl %esi
+ pushl %ebp
+ pushl %ebx
+
+ movl 28(%esp),%edi
+ movl 32(%esp),%esi
+
+ subl $32,%esp
+
+ .align 4
+LOCAL(04):
+ movl 52(%esp),%ebp
+
+ dblock LOCAL(05)
+
+ movl (%esp),%eax
+ movl 4(%esp),%ebx
+ movl 8(%esp),%ecx
+ movl 12(%esp),%edx
+ bswap %eax
+ bswap %ebx
+ bswap %ecx
+ bswap %edx
+ movl %eax, (%edi)
+ movl %ebx, 4(%edi)
+ movl %ecx, 8(%edi)
+ movl %edx,12(%edi)
+
+ addl $16,%esi
+ addl $16,%edi
+
+ decl 56(%esp)
+ jnz LOCAL(04)
+
+ addl $32,%esp
+
+ xorl %eax,%eax
+
+ popl %ebx
+ popl %ebp
+ popl %esi
+ popl %edi
+ ret
+C_FUNCTION_END(aesECBDecrypt, LOCAL(aesECBDecrypt_size))
diff --git a/beecrypt/gas/aesopt.powerpc.S b/beecrypt/gas/aesopt.powerpc.S
new file mode 100644
index 000000000..17e36dc41
--- /dev/null
+++ b/beecrypt/gas/aesopt.powerpc.S
@@ -0,0 +1,683 @@
+/*
+ * aesopt.powerpc.asm
+ *
+ * Assembler optimized AES routines for PowerPC processors
+ *
+ * Compile target is GNU Assembler
+ *
+ * Copyright (c) 2002 Bob Deblier <bob@virtualunlimited.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "beecrypt.gas.h"
+
+ .file "aesopt.powerpc.S"
+
+ .text
+
+/*
+ * ae0 in r11
+ * r7 thru r10 scratch
+ * four registers for s: r24 r25 r26 r27
+ * four registers for t: r28 r29 r30 r31
+ */
+
+#define s0 r24
+#define s1 r25
+#define s2 r26
+#define s3 r27
+#define t0 r28
+#define t1 r29
+#define t2 r30
+#define t3 r31
+
+ .macro sxrk rk src
+ #if WORDS_BIGENDIAN
+ lwz s0, 0(\src)
+ lwz s1, 4(\src)
+ lwz s2, 8(\src)
+ lwz s3,12(\src)
+ lwz r7, 0(\rk)
+ lwz r8, 4(\rk)
+ lwz r9, 8(\rk)
+ lwz r10,12(\rk)
+ #else
+ # error ppc little-endian not implemented
+ #endif
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+ .endm
+
+ .macro etfs rk offset
+ lwz t0,\offset+ 0(\rk)
+ lwz t1,\offset+ 4(\rk)
+ lwz t2,\offset+ 8(\rk)
+ lwz t3,\offset+12(\rk)
+
+ rlwinm r7,s0,10,22,29 /* ((s0 >> 24) & 0xff) * 4 */
+ rlwinm r8,s1,10,22,29 /* ((s1 >> 24) & 0xff) * 4 */
+ rlwinm r9,s2,10,22,29 /* ((s2 >> 24) & 0xff) * 4 */
+ rlwinm r10,s3,10,22,29 /* ((s3 >> 24) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,s1,18,22,29 /* ((s1 >> 16) & 0xff) * 4 */
+ rlwinm r8,s2,18,22,29 /* ((s2 >> 16) & 0xff) * 4 */
+ rlwinm r9,s3,18,22,29 /* ((s3 >> 16) & 0xff) * 4 */
+ rlwinm r10,s0,18,22,29 /* ((s0 >> 16) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,s2,26,22,29 /* ((s2 >> 8) & 0xff) * 4 */
+ rlwinm r8,s3,26,22,29 /* ((s3 >> 8) & 0xff) * 4 */
+ rlwinm r9,s0,26,22,29 /* ((s0 >> 8) & 0xff) * 4 */
+ rlwinm r10,s1,26,22,29 /* ((s1 >> 8) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,s3,2,22,29 /* ((s3 >> 0) & 0xff) * 4 */
+ rlwinm r8,s0,2,22,29 /* ((s0 >> 0) & 0xff) * 4 */
+ rlwinm r9,s1,2,22,29 /* ((s1 >> 0) & 0xff) * 4 */
+ rlwinm r10,s2,2,22,29 /* ((s2 >> 0) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,-3072(r12)
+ .endm
+
+ .macro esft rk offset
+ lwz s0,\offset+ 0(\rk)
+ lwz s1,\offset+ 4(\rk)
+ lwz s2,\offset+ 8(\rk)
+ lwz s3,\offset+12(\rk)
+
+ rlwinm r7,t0,10,22,29 /* ((t0 >> 24) & 0xff) * 4 */
+ rlwinm r8,t1,10,22,29 /* ((t1 >> 24) & 0xff) * 4 */
+ rlwinm r9,t2,10,22,29 /* ((t2 >> 24) & 0xff) * 4 */
+ rlwinm r10,t3,10,22,29 /* ((s3 >> 24) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,t1,18,22,29 /* ((t1 >> 16) & 0xff) * 4 */
+ rlwinm r8,t2,18,22,29 /* ((t2 >> 16) & 0xff) * 4 */
+ rlwinm r9,t3,18,22,29 /* ((t3 >> 16) & 0xff) * 4 */
+ rlwinm r10,t0,18,22,29 /* ((t0 >> 16) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,t2,26,22,29 /* ((t2 >> 8) & 0xff) * 4 */
+ rlwinm r8,t3,26,22,29 /* ((t3 >> 8) & 0xff) * 4 */
+ rlwinm r9,t0,26,22,29 /* ((t0 >> 8) & 0xff) * 4 */
+ rlwinm r10,t1,26,22,29 /* ((t1 >> 8) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,t3,2,22,29 /* ((t3 >> 0) & 0xff) * 4 */
+ rlwinm r8,t0,2,22,29 /* ((t0 >> 0) & 0xff) * 4 */
+ rlwinm r9,t1,2,22,29 /* ((t1 >> 0) & 0xff) * 4 */
+ rlwinm r10,t2,2,22,29 /* ((t2 >> 0) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,-3072(r12)
+ .endm
+
+ .macro elr rk
+ lwz s0, 0(\rk)
+ lwz s1, 4(\rk)
+ lwz s2, 8(\rk)
+ lwz s3,12(\rk)
+
+ la r12,4096(r12)
+
+ rlwinm r7,t0,10,22,29 /* ((t0 >> 24) & 0xff) * 4 */
+ rlwinm r8,t1,10,22,29 /* ((t1 >> 24) & 0xff) * 4 */
+ rlwinm r9,t2,10,22,29 /* ((t2 >> 24) & 0xff) * 4 */
+ rlwinm r10,t3,10,22,29 /* ((t3 >> 24) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,0,7 /* & 0xff000000 */
+ rlwinm r8,r8,0,0,7 /* & 0xff000000 */
+ rlwinm r9,r9,0,0,7 /* & 0xff000000 */
+ rlwinm r10,r10,0,0,7 /* & 0xff000000 */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ rlwinm r7,t1,18,22,29 /* ((t1 >> 16) & 0xff) * 4 */
+ rlwinm r8,t2,18,22,29 /* ((t2 >> 16) & 0xff) * 4 */
+ rlwinm r9,t3,18,22,29 /* ((t3 >> 16) & 0xff) * 4 */
+ rlwinm r10,t0,18,22,29 /* ((t0 >> 16) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,8,15 /* & 0xff0000 */
+ rlwinm r8,r8,0,8,15 /* & 0xff0000 */
+ rlwinm r9,r9,0,8,15 /* & 0xff0000 */
+ rlwinm r10,r10,0,8,15 /* & 0xff0000 */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ rlwinm r7,t2,26,22,29 /* ((t2 >> 8) & 0xff) * 4 */
+ rlwinm r8,t3,26,22,29 /* ((t3 >> 8) & 0xff) * 4 */
+ rlwinm r9,t0,26,22,29 /* ((t0 >> 8) & 0xff) * 4 */
+ rlwinm r10,t1,26,22,29 /* ((t1 >> 8) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,16,23 /* & 0xff00 */
+ rlwinm r8,r8,0,16,23 /* & 0xff00 */
+ rlwinm r9,r9,0,16,23 /* & 0xff00 */
+ rlwinm r10,r10,0,16,23 /* & 0xff00 */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ rlwinm r7,t3,2,22,29 /* ((t3 >> 0) & 0xff) * 4 */
+ rlwinm r8,t0,2,22,29 /* ((t0 >> 0) & 0xff) * 4 */
+ rlwinm r9,t1,2,22,29 /* ((t1 >> 0) & 0xff) * 4 */
+ rlwinm r10,t2,2,22,29 /* ((t2 >> 0) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,24,31 /* & 0xff */
+ rlwinm r8,r8,0,24,31 /* & 0xff */
+ rlwinm r9,r9,0,24,31 /* & 0xff */
+ rlwinm r10,r10,0,24,31 /* & 0xff */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,-4096(r12)
+ .endm
+
+ .macro eblock rk src label
+ sxrk \rk \src
+
+ etfs \rk 16
+ esft \rk 32
+ etfs \rk 48
+ esft \rk 64
+ etfs \rk 80
+ esft \rk 96
+ etfs \rk 112
+ esft \rk 128
+ etfs \rk 144
+
+ lwz r11,256(\rk)
+ cmpwi r11,10
+ beq \label
+
+ esft \rk 160
+ etfs \rk 176
+
+ cmpwi r11,12
+ beq \label
+
+ esft \rk 192
+ etfs \rk 208
+
+\label:
+ slwi r11,r11,4
+ add \rk,\rk,r11
+
+ elr \rk
+ .endm
+
+ .macro dtfs rk offset
+ lwz t0,\offset+ 0(\rk)
+ lwz t1,\offset+ 4(\rk)
+ lwz t2,\offset+ 8(\rk)
+ lwz t3,\offset+12(\rk)
+
+ rlwinm r7,s0,10,22,29 /* ((s0 >> 24) & 0xff) * 4 */
+ rlwinm r8,s1,10,22,29 /* ((s1 >> 24) & 0xff) * 4 */
+ rlwinm r9,s2,10,22,29 /* ((s2 >> 24) & 0xff) * 4 */
+ rlwinm r10,s3,10,22,29 /* ((s3 >> 24) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,s3,18,22,29 /* ((s3 >> 16) & 0xff) * 4 */
+ rlwinm r8,s0,18,22,29 /* ((s0 >> 16) & 0xff) * 4 */
+ rlwinm r9,s1,18,22,29 /* ((s1 >> 16) & 0xff) * 4 */
+ rlwinm r10,s2,18,22,29 /* ((s2 >> 16) & 0xff) * 4 */
+
+/* start here */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,s2,26,22,29 /* ((s2 >> 8) & 0xff) * 4 */
+ rlwinm r8,s3,26,22,29 /* ((s3 >> 8) & 0xff) * 4 */
+ rlwinm r9,s0,26,22,29 /* ((s0 >> 8) & 0xff) * 4 */
+ rlwinm r10,s1,26,22,29 /* ((s1 >> 8) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,s1,2,22,29 /* ((s1 >> 0) & 0xff) * 4 */
+ rlwinm r8,s2,2,22,29 /* ((s2 >> 0) & 0xff) * 4 */
+ rlwinm r9,s3,2,22,29 /* ((s3 >> 0) & 0xff) * 4 */
+ rlwinm r10,s0,2,22,29 /* ((s0 >> 0) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor t0,t0,r7
+ xor t1,t1,r8
+ xor t2,t2,r9
+ xor t3,t3,r10
+
+ la r12,-3072(r12)
+ .endm
+
+ .macro dsft rk offset
+ lwz s0,\offset+ 0(\rk)
+ lwz s1,\offset+ 4(\rk)
+ lwz s2,\offset+ 8(\rk)
+ lwz s3,\offset+12(\rk)
+
+ rlwinm r7,t0,10,22,29 /* ((t0 >> 24) & 0xff) * 4 */
+ rlwinm r8,t1,10,22,29 /* ((t1 >> 24) & 0xff) * 4 */
+ rlwinm r9,t2,10,22,29 /* ((t2 >> 24) & 0xff) * 4 */
+ rlwinm r10,t3,10,22,29 /* ((s3 >> 24) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,t3,18,22,29 /* ((t3 >> 16) & 0xff) * 4 */
+ rlwinm r8,t0,18,22,29 /* ((t0 >> 16) & 0xff) * 4 */
+ rlwinm r9,t1,18,22,29 /* ((t1 >> 16) & 0xff) * 4 */
+ rlwinm r10,t2,18,22,29 /* ((t2 >> 16) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,t2,26,22,29 /* ((t2 >> 8) & 0xff) * 4 */
+ rlwinm r8,t3,26,22,29 /* ((t3 >> 8) & 0xff) * 4 */
+ rlwinm r9,t0,26,22,29 /* ((t0 >> 8) & 0xff) * 4 */
+ rlwinm r10,t1,26,22,29 /* ((t1 >> 8) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,1024(r12)
+
+ rlwinm r7,t1,2,22,29 /* ((t1 >> 0) & 0xff) * 4 */
+ rlwinm r8,t2,2,22,29 /* ((t2 >> 0) & 0xff) * 4 */
+ rlwinm r9,t3,2,22,29 /* ((t3 >> 0) & 0xff) * 4 */
+ rlwinm r10,t0,2,22,29 /* ((t0 >> 0) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,-3072(r12)
+ .endm
+
+ .macro dlr rk
+ lwz s0, 0(\rk)
+ lwz s1, 4(\rk)
+ lwz s2, 8(\rk)
+ lwz s3,12(\rk)
+
+ la r12,4096(r12)
+
+ rlwinm r7,t0,10,22,29 /* ((t0 >> 24) & 0xff) * 4 */
+ rlwinm r8,t1,10,22,29 /* ((t1 >> 24) & 0xff) * 4 */
+ rlwinm r9,t2,10,22,29 /* ((t2 >> 24) & 0xff) * 4 */
+ rlwinm r10,t3,10,22,29 /* ((t3 >> 24) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,0,7 /* & 0xff000000 */
+ rlwinm r8,r8,0,0,7 /* & 0xff000000 */
+ rlwinm r9,r9,0,0,7 /* & 0xff000000 */
+ rlwinm r10,r10,0,0,7 /* & 0xff000000 */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ rlwinm r7,t3,18,22,29 /* ((t3 >> 16) & 0xff) * 4 */
+ rlwinm r8,t0,18,22,29 /* ((t0 >> 16) & 0xff) * 4 */
+ rlwinm r9,t1,18,22,29 /* ((t1 >> 16) & 0xff) * 4 */
+ rlwinm r10,t2,18,22,29 /* ((t2 >> 16) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,8,15 /* & 0xff0000 */
+ rlwinm r8,r8,0,8,15 /* & 0xff0000 */
+ rlwinm r9,r9,0,8,15 /* & 0xff0000 */
+ rlwinm r10,r10,0,8,15 /* & 0xff0000 */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ rlwinm r7,t2,26,22,29 /* ((t2 >> 8) & 0xff) * 4 */
+ rlwinm r8,t3,26,22,29 /* ((t3 >> 8) & 0xff) * 4 */
+ rlwinm r9,t0,26,22,29 /* ((t0 >> 8) & 0xff) * 4 */
+ rlwinm r10,t1,26,22,29 /* ((t1 >> 8) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,16,23 /* & 0xff00 */
+ rlwinm r8,r8,0,16,23 /* & 0xff00 */
+ rlwinm r9,r9,0,16,23 /* & 0xff00 */
+ rlwinm r10,r10,0,16,23 /* & 0xff00 */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ rlwinm r7,t1,2,22,29 /* ((t1 >> 0) & 0xff) * 4 */
+ rlwinm r8,t2,2,22,29 /* ((t2 >> 0) & 0xff) * 4 */
+ rlwinm r9,t3,2,22,29 /* ((t3 >> 0) & 0xff) * 4 */
+ rlwinm r10,t0,2,22,29 /* ((t0 >> 0) & 0xff) * 4 */
+ lwzx r7,r7,r12
+ lwzx r8,r8,r12
+ lwzx r9,r9,r12
+ lwzx r10,r10,r12
+ rlwinm r7,r7,0,24,31 /* & 0xff */
+ rlwinm r8,r8,0,24,31 /* & 0xff */
+ rlwinm r9,r9,0,24,31 /* & 0xff */
+ rlwinm r10,r10,0,24,31 /* & 0xff */
+ xor s0,s0,r7
+ xor s1,s1,r8
+ xor s2,s2,r9
+ xor s3,s3,r10
+
+ la r12,-4096(r12)
+ .endm
+
+ .macro dblock rk src label
+ sxrk \rk \src
+
+ dtfs \rk 16
+ dsft \rk 32
+ dtfs \rk 48
+ dsft \rk 64
+ dtfs \rk 80
+ dsft \rk 96
+ dtfs \rk 112
+ dsft \rk 128
+ dtfs \rk 144
+
+ lwz r11,256(\rk)
+ cmpwi r11,10
+ beq \label
+
+ dsft \rk 160
+ dtfs \rk 176
+
+ cmpwi r11,12
+ beq \label
+
+ dsft \rk 192
+ dtfs \rk 208
+
+\label:
+ slwi r11,r11,4
+ add \rk,\rk,r11
+
+ dlr \rk
+ .endm
+
+C_FUNCTION_BEGIN(aesEncrypt)
+LABEL(aesEncrypt)
+ subi r1,r1,32
+ stmw r24,0(r1)
+
+ lis r12,_ae0@ha
+ la r12,_ae0@l(r12)
+
+ eblock rk=r3 src=r5 label=LOCAL(00)
+
+ #if WORDS_BIGENDIAN
+ stw s0, 0(r4)
+ stw s1, 4(r4)
+ stw s2, 8(r4)
+ stw s3,12(r4)
+ #else
+ # error ppc little-endian mode not supported
+ #endif
+
+ li r3,0
+ lmw r24,0(r1)
+ addi r1,r1,32
+ blr
+C_FUNCTION_END(aesEncrypt, LOCAL(aesEncrypt_size))
+
+
+C_FUNCTION_BEGIN(aesDecrypt)
+LABEL(aesDecrypt)
+ subi r1,r1,32
+ stmw r24,0(r1)
+
+ lis r12,_ad0@ha
+ la r12,_ad0@l(r12)
+
+ dblock rk=r3 src=r5 label=LOCAL(01)
+
+ #if WORDS_BIGENDIAN
+ stw s0, 0(r4)
+ stw s1, 4(r4)
+ stw s2, 8(r4)
+ stw s3,12(r4)
+ #else
+ # error ppc little-endian mode not supported
+ #endif
+
+ li r3,0
+ lmw r24,0(r1)
+ addi r1,r1,32
+ blr
+C_FUNCTION_END(aesDecrypt, LOCAL(aesDecrypt_size))
+
+C_FUNCTION_BEGIN(aesECBEncrypt)
+LABEL(aesECBEncrypt)
+ subi r1,r1,32
+ stmw r24,0(r1)
+
+ mtctr r4
+
+ lis r12,_ae0@ha
+ la r12,_ae0@l(r12)
+
+LOCAL(02):
+ /* copy r3 into r4 */
+ mr r4,r3
+
+ eblock rk=r4 src=r6 label=LOCAL(03)
+
+ #if WORDS_BIGENDIAN
+ stw s0, 0(r5)
+ stw s1, 4(r5)
+ stw s2, 8(r5)
+ stw s3,12(r5)
+ #else
+ # error ppc little-endian mode not supported
+ #endif
+
+ addi r5,r5,16
+ addi r6,r6,16
+
+ bdnz LOCAL(02)
+
+ li r3,0
+ lmw r24,0(r1)
+ addi r1,r1,32
+ blr
+C_FUNCTION_END(aesECBEncrypt, LOCAL(aesECBEncrypt_size))
+
+
+C_FUNCTION_BEGIN(aesECBDecrypt)
+LABEL(aesECBDecrypt)
+ subi r1,r1,32
+ stmw r24,0(r1)
+
+ mtctr r4
+
+ lis r12,_ad0@ha
+ la r12,_ad0@l(r12)
+
+LOCAL(04):
+ /* copy r3 into r4 */
+ mr r4,r3
+
+ dblock rk=r4 src=r6 label=LOCAL(05)
+
+ #if WORDS_BIGENDIAN
+ stw s0, 0(r5)
+ stw s1, 4(r5)
+ stw s2, 8(r5)
+ stw s3,12(r5)
+ #else
+ # error ppc little-endian mode not supported
+ #endif
+
+ addi r5,r5,16
+ addi r6,r6,16
+
+ bdnz LOCAL(04)
+
+ li r3,0
+ lmw r24,0(r1)
+ addi r1,r1,32
+ blr
+C_FUNCTION_END(aesECBDecrypt, LOCAL(aesECBDecrypt_size))
diff --git a/beecrypt/gas/blowfishopt.i586.S b/beecrypt/gas/blowfishopt.i586.S
index dea677247..69b89bb72 100644
--- a/beecrypt/gas/blowfishopt.i586.S
+++ b/beecrypt/gas/blowfishopt.i586.S
@@ -25,7 +25,7 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "blowfishopt.i586.S"
@@ -86,6 +86,7 @@
.endm
C_FUNCTION_BEGIN(blowfishEncrypt)
+LABEL(blowfishEncrypt)
/* parameter one is the blowfish parameters; need to extract bp and set it up in esi */
pushl %edi
pushl %esi
@@ -127,10 +128,11 @@ C_FUNCTION_BEGIN(blowfishEncrypt)
popl %esi
popl %edi
ret
-C_FUNCTION_END(blowfishEncrypt, .LblowfishEncrypt_size)
+C_FUNCTION_END(blowfishEncrypt, LOCAL(blowfishEncrypt_size))
C_FUNCTION_BEGIN(blowfishDecrypt)
+LABEL(blowfishDecrypt)
/* parameter one is the blowfish parameters; need to extract bp and set it up in ebp */
pushl %edi
pushl %esi
@@ -173,4 +175,4 @@ C_FUNCTION_BEGIN(blowfishDecrypt)
popl %esi
popl %edi
ret
-C_FUNCTION_END(blowfishDecrypt, .LblowfishDecrypt_size)
+C_FUNCTION_END(blowfishDecrypt, LOCAL(blowfishDecrypt_size))
diff --git a/beecrypt/gas/fips180opt.ia64.S b/beecrypt/gas/fips180opt.ia64.S
index a9c6edaa8..0b057c70d 100644
--- a/beecrypt/gas/fips180opt.ia64.S
+++ b/beecrypt/gas/fips180opt.ia64.S
@@ -27,7 +27,7 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
#define saved_pfs r14
#define saved_lc r15
diff --git a/beecrypt/gas/fips180opt.powerpc.S b/beecrypt/gas/fips180opt.powerpc.S
index 770790236..db6314980 100644
--- a/beecrypt/gas/fips180opt.powerpc.S
+++ b/beecrypt/gas/fips180opt.powerpc.S
@@ -27,7 +27,7 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "fips180opt.powerpc.S"
diff --git a/beecrypt/gas/mp32opt.arm.S b/beecrypt/gas/mp32opt.arm.S
index 0f3916828..5908047ba 100644
--- a/beecrypt/gas/mp32opt.arm.S
+++ b/beecrypt/gas/mp32opt.arm.S
@@ -5,7 +5,7 @@
*
* Compile target is GNU Assembler
*
- * Copyright (c) 2001 Virtual Unlimited B.V.
+ * Copyright (c) 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -25,7 +25,7 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "mp32opt.arm.S"
@@ -35,40 +35,43 @@
#if 0
C_FUNCTION_BEGIN(mp32addw)
+LABEL(mp32addw)
/* r0 is xsize and must be at least one, r1 = xdata, r2 = y */
stmfd sp!, {r4, lr}
add r1, r1, r0, asl #2
mov r3, #0
-.Lmp32addw_loop:
+LOCAL(mp32addw_loop):
ldr r4, [r1, #-4]
adds r4, r4, r2
adc r2, r3, r3
str r4, [r1, #-4]!
subs r0, r0, #1
- bne .Lmp32addw_loop
+ bne LOCAL(mp32addw_loop)
mov r0, r2
ldmfd sp!, {r4, pc}
-C_FUNCTION_END(mp32addw, .Lmp32addw_size)
+C_FUNCTION_END(mp32addw, LOCAL(mp32addw_size))
C_FUNCTION_BEGIN(mp32subw)
+LABEL(mp32subw)
/* r0 is xsize and must be at least one, r1 = xdata, r2 = y */
stmfd sp!, {r4, lr}
add r1, r1, r0, asl #2
mov r3, #0
-.Lmp32subw_loop:
+LOCAL(mp32subw_loop):
ldr r4, [r1, #-4]
subs r4, r4, r2
adc r2, r3, r3
str r4, [r1, #-4]!
subs r0, r0, #1
- bne .Lmp32subw_loop
+ bne LOCAL(mp32subw_loop)
mov r0, r2
ldmfd sp!, {r4, pc}
-C_FUNCTION_END(mp32subw, .Lmp32subw_size)
+C_FUNCTION_END(mp32subw, LOCAL(mp32subw_size))
C_FUNCTION_BEGIN(mp32add)
+LABEL(mp32add)
/* r0 is size, r1 = xdata, r2 = ydata */
stmfd sp!, {r4, r5, lr}
/* copy cpsr to r5 and clear the carry bit */
@@ -77,7 +80,7 @@ C_FUNCTION_BEGIN(mp32add)
/* adjust the addresses */
add r1, r1, r0, asl #2
add r2, r2, r0, asl #2
-.Lmp32add_loop:
+LOCAL(mp32add_loop):
/* restore the carry bit */
msr cpsr_c, r5
ldr r3, [r1, #-4]!
@@ -87,7 +90,7 @@ C_FUNCTION_BEGIN(mp32add)
/* save the carry bit */
mrs r5, cpsr
subs r0, r0, #1
- bne .Lmp32add_loop
+ bne LOCAL(mp32add_loop)
/* restore the carry bit */
msr cpsr_c, r5
@@ -95,39 +98,41 @@ C_FUNCTION_BEGIN(mp32add)
/* set the result to the proper value */
adc r0, r0, r0
ldmfd sp!, {r4, r5, pc}
-C_FUNCTION_END(mp32add, .Lmp32add_size)
+C_FUNCTION_END(mp32add, LOCAL(mp32add_size))
#endif
C_FUNCTION_BEGIN(mp32setmul)
+LABEL(mp32setmul)
stmfd sp!, {r4, r5, lr}
/* adjust the addresses */
add r1, r1, r0, asl #2
add r2, r2, r0, asl #2
/* r3 is the multiplicand; r4 load from memory, r5 is scratch, ip is carry */
mov ip, #0
-.Lmp32setmul_loop:
+LOCAL(mp32setmul_loop):
ldr r4, [r2, #-4]!
mov r5, #0
umlal ip, r5, r3, r4
str ip, [r1, #-4]!
mov ip, r5
subs r0, r0, #1
- bne .Lmp32setmul_loop
+ bne LOCAL(mp32setmul_loop)
/* return carry */
mov r0, ip
ldmfd sp!, {r4, r5, pc}
-C_FUNCTION_END(mp32setmul, .Lmp32setmul_size)
+C_FUNCTION_END(mp32setmul, LOCAL(mp32setmul_size))
C_FUNCTION_BEGIN(mp32addmul)
+LABEL(mp32addmul)
stmfd sp!, {r4, r5, r6, lr}
/* adjust the addresses */
add r1, r1, r0, asl #2
add r2, r2, r0, asl #2
/* r3 is the multiplicand; r4 & r5 load from memory, r6 is scratch, ip is carry */
mov ip, #0
-.Lmp32addmul_loop:
+LOCAL(mp32addmul_loop):
ldr r4, [r2, #-4]!
ldr r5, [r1, #-4]
mov r6, #0
@@ -136,17 +141,18 @@ C_FUNCTION_BEGIN(mp32addmul)
adc ip, r6, #0
str r5, [r1, #-4]!
subs r0, r0, #1
- bne .Lmp32addmul_loop
+ bne LOCAL(mp32addmul_loop)
/* return carry */
mov r0, ip
ldmfd sp!, {r4, r5, r6, pc}
-C_FUNCTION_END(mp32addmul, .Lmp32addmul_size)
+C_FUNCTION_END(mp32addmul, LOCAL(mp32addmul_size))
#if 0
/* this routine needs fixing; it causes a core dump for some reason */
/* unfortunately the system I test this on has no debugger */
C_FUNCTION_BEGIN(mp32addsqrtrc)
+LABEL(mp32addsqrtrc):
stmfd sp!, {r4, r5, r6, lr}
/* adjust the addresses */
add r1, r1, r0, asl #2
@@ -154,7 +160,7 @@ C_FUNCTION_BEGIN(mp32addsqrtrc)
/* r3 is a zero register, ip is the carry */
mov r3, #0
mov ip, #0
-.Lmp32addsqrtrc_loop:
+LOCAL(mp32addsqrtrc_loop):
ldr r4, [r2, #-4]!
mov r6, #0
umlal ip, r6, r4, r4
@@ -166,9 +172,9 @@ C_FUNCTION_BEGIN(mp32addsqrtrc)
str r4, [r1, #-8]!
adc ip, r3, #0 /* set carry */
subs r0, r0, #1
- bne .Lmp32addsqrtrc_loop
+ bne LOCAL(mp32addsqrtrc_loop)
/* return carry */
mov r0, ip
ldmfd sp!, {r4, r5, r6, pc}
-C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size)
+C_FUNCTION_END(mp32addsqrtrc, LOCAL(mp32addsqrtrc_size))
#endif
diff --git a/beecrypt/gas/mp32opt.i386.S b/beecrypt/gas/mp32opt.i386.S
index 4c49d4750..b95ac6bf8 100644
--- a/beecrypt/gas/mp32opt.i386.S
+++ b/beecrypt/gas/mp32opt.i386.S
@@ -25,7 +25,7 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "mp32opt.i386.S"
diff --git a/beecrypt/gas/mp32opt.ia64.S b/beecrypt/gas/mp32opt.ia64.S
index 87ff58161..06448e4a8 100644
--- a/beecrypt/gas/mp32opt.ia64.S
+++ b/beecrypt/gas/mp32opt.ia64.S
@@ -33,7 +33,7 @@
* floating point registers, which should shave off a lot of cycles.
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
#define saved_pfs r14
#define saved_lc r15
diff --git a/beecrypt/gas/mp32opt.powerpc.S b/beecrypt/gas/mp32opt.powerpc.S
index 3e07e95d3..f51d14bc4 100644
--- a/beecrypt/gas/mp32opt.powerpc.S
+++ b/beecrypt/gas/mp32opt.powerpc.S
@@ -25,27 +25,15 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "mp32opt.powerpc.S"
.text
-#if !DARWIN
-# define r0 %r0
-# define r3 %r3
-# define r4 %r4
-# define r5 %r5
-# define r6 %r6
-# define r7 %r7
-# define r8 %r8
-# define r9 %r9
-# define r10 %r10
-# define r11 %r11
-# define r12 %r12
-#endif
C_FUNCTION_BEGIN(mp32addw)
+LABEL(mp32addw)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
@@ -53,20 +41,21 @@ C_FUNCTION_BEGIN(mp32addw)
lwzu r6,-4(r4)
addc r6,r6,r5
stw r6,0(r4)
- bdz .Lmp32addw_skip
-.Lmp32addw_loop:
+ bdz LOCAL(mp32addw_skip)
+LOCAL(mp32addw_loop):
lwzu r6,-4(r4)
adde r6,r0,r6
stw r6,0(r4)
- bdnz .Lmp32addw_loop
-.Lmp32addw_skip:
+ bdnz LOCAL(mp32addw_loop)
+LOCAL(mp32addw_skip):
/* return the carry */
addze r3,r0
blr
-C_FUNCTION_END(mp32addw, .Lmp32addw_size)
+C_FUNCTION_END(mp32addw, LOCAL(mp32addw_size))
C_FUNCTION_BEGIN(mp32subw)
+LABEL(mp32subw)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
@@ -74,21 +63,22 @@ C_FUNCTION_BEGIN(mp32subw)
lwz r6,-4(r4)
subfc r6,r5,r6
stwu r6,-4(r4)
- bdz .Lmp32subw_skip
-.Lmp32subw_loop:
+ bdz LOCAL(mp32subw_skip)
+LOCAL(mp32subw_loop):
lwz r6,-4(r4)
subfe r6,r0,r6
stwu r6, -4(r4)
- bdnz .Lmp32subw_loop
-.Lmp32subw_skip:
+ bdnz LOCAL(mp32subw_loop)
+LOCAL(mp32subw_skip):
/* return the carry */
subfe r3,r0,r0
neg r3,r3
blr
-C_FUNCTION_END(mp32subw, .Lmp32subw_size)
+C_FUNCTION_END(mp32subw, LOCAL(mp32subw_size))
C_FUNCTION_BEGIN(mp32add)
+LABEL(mp32add)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
@@ -98,21 +88,22 @@ C_FUNCTION_BEGIN(mp32add)
lwzu r7,-4(r5)
addc r6,r7,r6
stwu r6,-4(r4)
- bdz .Lmp32add_skip
-.Lmp32add_loop:
+ bdz LOCAL(mp32add_skip)
+LOCAL(mp32add_loop):
lwz r6,-4(r4)
lwzu r7,-4(r5)
adde r6,r7,r6
stwu r6,-4(r4)
- bdnz .Lmp32add_loop
-.Lmp32add_skip:
+ bdnz LOCAL(mp32add_loop)
+LOCAL(mp32add_skip):
/* return the carry */
addze r3,r0
blr
-C_FUNCTION_END(mp32add, .Lmp32add_size)
+C_FUNCTION_END(mp32add, LOCAL(mp32add_size))
C_FUNCTION_BEGIN(mp32sub)
+LABEL(mp32sub)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
@@ -122,22 +113,23 @@ C_FUNCTION_BEGIN(mp32sub)
lwzu r7,-4(r5)
subfc r6,r7,r6
stwu r6,-4(r4)
- bdz .Lmp32sub_skip
-.Lmp32sub_loop:
+ bdz LOCAL(mp32sub_skip)
+LOCAL(mp32sub_loop):
lwz r6,-4(r4)
lwzu r7,-4(r5)
subfe r6,r7,r6
stwu r6,-4(r4)
- bdnz .Lmp32sub_loop
-.Lmp32sub_skip:
+ bdnz LOCAL(mp32sub_loop)
+LOCAL(mp32sub_skip):
/* return the carry */
subfe r3,r0,r0
neg r3,r3
blr
-C_FUNCTION_END(mp32sub, .Lmp32sub_size)
+C_FUNCTION_END(mp32sub, LOCAL(mp32sub_size))
C_FUNCTION_BEGIN(mp32multwo)
+LABEL(mp32multwo)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
@@ -145,44 +137,46 @@ C_FUNCTION_BEGIN(mp32multwo)
lwz r6,-4(r4)
addc r6,r6,r6
stwu r6,-4(r4)
- bdz .Lmp32multwo_skip
-.Lmp32multwo_loop:
+ bdz LOCAL(mp32multwo_skip)
+LOCAL(mp32multwo_loop):
lwz r6,-4(r4)
adde r6,r6,r6
stwu r6,-4(r4)
- bdnz .Lmp32multwo_loop
-.Lmp32multwo_skip:
+ bdnz LOCAL(mp32multwo_loop)
+LOCAL(mp32multwo_skip):
/* return the carry */
addze r3,r0
blr
-C_FUNCTION_END(mp32multwo, .Lmp32multwo_size)
+C_FUNCTION_END(mp32multwo, LOCAL(mp32multwo_size))
C_FUNCTION_BEGIN(mp32setmul)
+LABEL(mp32setmul)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
add r5,r5,r0
li r3,0
-.Lmp32setmul_loop:
+LOCAL(mp32setmul_loop):
lwzu r7,-4(r5)
mullw r8,r7,r6
addc r8,r8,r3
mulhwu r9,r7,r6
addze r3,r9
stwu r8,-4(r4)
- bdnz .Lmp32setmul_loop
+ bdnz LOCAL(mp32setmul_loop)
blr
-C_FUNCTION_END(mp32setmul, .Lmp32setmul_size)
+C_FUNCTION_END(mp32setmul, LOCAL(mp32setmul_size))
C_FUNCTION_BEGIN(mp32addmul)
+LABEL(mp32addmul)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
add r5,r5,r0
li r3,0
-.Lmp32addmul_loop:
+LOCAL(mp32addmul_loop):
lwzu r8,-4(r5)
lwzu r7,-4(r4)
mullw r9,r8,r6
@@ -192,19 +186,20 @@ C_FUNCTION_BEGIN(mp32addmul)
addc r9,r9,r7
addze r3,r3
stw r9,0(r4)
- bdnz .Lmp32addmul_loop
+ bdnz LOCAL(mp32addmul_loop)
blr
-C_FUNCTION_END(mp32addmul, .Lmp32addmul_size)
+C_FUNCTION_END(mp32addmul, LOCAL(mp32addmul_size))
C_FUNCTION_BEGIN(mp32addsqrtrc)
+LABEL(mp32addsqrtrc)
mtctr r3
slwi r0,r3,2
add r4,r4,r0
add r5,r5,r0
add r4,r4,r0
li r3,0
-.Lmp32addsqrtrc_loop:
+LOCAL(mp32addsqrtrc_loop):
lwzu r0,-4(r5)
lwz r6,-8(r4)
lwz r7,-4(r4)
@@ -218,6 +213,6 @@ C_FUNCTION_BEGIN(mp32addsqrtrc)
addze r3,r3
stw r7,-4(r4)
stwu r6,-8(r4)
- bdnz .Lmp32addsqrtrc_loop
+ bdnz LOCAL(mp32addsqrtrc_loop)
blr
-C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size)
+C_FUNCTION_END(mp32addsqrtrc, LOCAL(mp32addsqrtrc_size))
diff --git a/beecrypt/gas/mp32opt.sparcv8.S b/beecrypt/gas/mp32opt.sparcv8.S
index aa9660d09..b89d58224 100644
--- a/beecrypt/gas/mp32opt.sparcv8.S
+++ b/beecrypt/gas/mp32opt.sparcv8.S
@@ -25,37 +25,45 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "mp32opt.sparcv8.S"
.text
C_FUNCTION_BEGIN(mp32setmul)
+LABEL(mp32setmul)
+
+ .register %g2,#scratch
+
sll %o0,2,%g1
dec 4,%o2
clr %o0
-.Lmp32setmul_loop:
+LOCAL(mp32setmul_loop):
ld [%o2+%g1],%g2
umul %o3,%g2,%g2
rd %y,%g3
addcc %o0,%g2,%g2
addx %g0,%g3,%o0
deccc 4,%g1
- bnz .Lmp32setmul_loop
+ bnz LOCAL(mp32setmul_loop)
st %g2,[%o1+%g1]
retl
nop
-C_FUNCTION_END(mp32setmul, .Lmp32setmul_size)
+C_FUNCTION_END(mp32setmul, LOCAL(mp32setmul_size))
C_FUNCTION_BEGIN(mp32addmul)
+LABEL(mp32addmul)
+
+ .register %g2,#scratch
+
sll %o0,2,%g1
mov %o1,%o4
dec 4,%o1
dec 4,%o2
clr %o0
-.Lmp32addmul_loop:
+LOCAL(mp32addmul_loop):
ld [%o2+%g1],%g2
ld [%o1+%g1],%g3
umul %o3,%g2,%g2
@@ -65,29 +73,42 @@ C_FUNCTION_BEGIN(mp32addmul)
addcc %g2,%g3,%g2
addx %g0,%g4,%o0
deccc 4,%g1
- bnz .Lmp32addmul_loop
+ bnz LOCAL(mp32addmul_loop)
st %g2,[%o4+%g1]
retl
nop
-C_FUNCTION_END(mp32addmul, .Lmp32addmul_size)
+C_FUNCTION_END(mp32addmul, LOCAL(mp32addmul_size))
-#if 0
C_FUNCTION_BEGIN(mp32addsqrtrc)
- sll %o0,2,%g1
- dec 4,%o1
- dec 4,%o2
- sub %o3,%o2,4
- clr %o0
-.Lmp32addsqrtrc_loop:
- ld [%o2+%g1],%g2
- ld [%o1+%g1],%g3
- ld [%o3+%g1],%g4
- umul %g2,%g2,%g2
- rd %y,%o4
- addcc %g3,%g2,%g3
- addx %g4,%o4,%g4
- /* carry from first addition */
- addx %g0,%g0,%o4
-C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size)
-#endif
+LABEL(mp32addsqrtrc)
+
+ .register %g2,#scratch
+ .register %g3,#scratch
+
+ sll %o0,2,%g1
+ add %o1,%g1,%o1
+ dec 4,%o2
+ add %o1,%g1,%o1
+ dec 8,%o1
+ clr %o0
+LOCAL(mp32addsqrtrc_loop):
+ ld [%o2+%g1],%g2
+ ldd [%o1],%o4
+ umul %g2,%g2,%g3
+ rd %y,%g2
+ /* first addition */
+ addcc %o5,%g3,%o5
+ addxcc %o4,%g2,%o4
+ addx %g0,%g0,%o3
+ /* second addition */
+ addcc %o5,%o0,%o5
+ addxcc %o4,%g0,%o4
+ addx %o3,%g0,%o0
+ std %o4,[%o1]
+ deccc 4,%g1
+ bnz LOCAL(mp32addsqrtrc_loop)
+ sub %o1,8,%o1
+ retl
+ nop
+C_FUNCTION_END(mp32addsqrtrc, LOCAL(mp32addsqrtrc_size))
diff --git a/beecrypt/gas/mp32opt.sparcv9.S b/beecrypt/gas/mp32opt.sparcv9.S
index 1af4c396e..c060eb613 100644
--- a/beecrypt/gas/mp32opt.sparcv9.S
+++ b/beecrypt/gas/mp32opt.sparcv9.S
@@ -25,13 +25,14 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "mp32opt.sparcv9.S"
.text
C_FUNCTION_BEGIN(mp32addw)
+LABEL(mp32addw)
.register %g2,#scratch
@@ -41,22 +42,22 @@ C_FUNCTION_BEGIN(mp32addw)
lduw [%o1+%g1],%g2
addcc %g2,%o2,%g2
stw %g2,[%o1+%g1]
- brz,pn %g1,.Lmp32addw_skip
+ brz,pn %g1,LOCAL(mp32addw_skip)
dec 4,%g1
-.Lmp32addw_loop:
+LOCAL(mp32addw_loop):
lduw [%o1+%g1],%g2
addccc %g2,%g0,%g2
stw %g2,[%o1+%g1]
- brnz,pt %g1,.Lmp32addw_loop
+ brnz,pt %g1,LOCAL(mp32addw_loop)
dec 4,%g1
-.Lmp32addw_skip:
+LOCAL(mp32addw_skip):
retl
movcs %icc,1,%o0
-.Lend_addw:
-C_FUNCTION_END(mp32addw, .Lmp32addw_size)
+C_FUNCTION_END(mp32addw, LOCAL(mp32addw_size))
C_FUNCTION_BEGIN(mp32subw)
+LABEL(mp32subw)
.register %g2,#scratch
@@ -66,21 +67,22 @@ C_FUNCTION_BEGIN(mp32subw)
lduw [%o1+%g1],%g2
subcc %g2,%o2,%g2
stw %g2,[%o1+%g1]
- brz,pn %g1,.Lmp32subw_skip
+ brz,pn %g1,LOCAL(mp32subw_skip)
dec 4,%g1
-.Lmp32subw_loop:
+LOCAL(mp32subw_loop):
lduw [%o1+%g1],%g2
subccc %g2,%g0,%g2
stw %g2,[%o1+%g1]
- brnz,pt %g1,.Lmp32subw_loop
+ brnz,pt %g1,LOCAL(mp32subw_loop)
dec 4,%g1
-.Lmp32subw_skip:
+LOCAL(mp32subw_skip):
retl
movcs %icc,1,%o0
-C_FUNCTION_END(mp32subw, .Lmp32subw_size)
+C_FUNCTION_END(mp32subw, LOCAL(mp32subw_size))
C_FUNCTION_BEGIN(mp32add)
+LABEL(mp32add)
.register %g2,#scratch
.register %g3,#scratch
@@ -88,19 +90,20 @@ C_FUNCTION_BEGIN(mp32add)
sll %o0,2,%g1
dec 4,%g1
addcc %g0,%g0,%o0
-.Lmp32add_loop:
+LOCAL(mp32add_loop):
lduw [%o1+%g1],%g2
lduw [%o2+%g1],%g3
addccc %g2,%g3,%g4
stw %g4,[%o1+%g1]
- brnz,pt %g1,.Lmp32add_loop
+ brnz,pt %g1,LOCAL(mp32add_loop)
dec 4,%g1
retl
movcs %icc,1,%o0
-C_FUNCTION_END(mp32add, .Lmp32add_size)
+C_FUNCTION_END(mp32add, LOCAL(mp32add_size))
C_FUNCTION_BEGIN(mp32sub)
+LABEL(mp32sub)
.register %g2,#scratch
.register %g3,#scratch
@@ -108,19 +111,20 @@ C_FUNCTION_BEGIN(mp32sub)
sll %o0,2,%g1
dec 4,%g1
addcc %g0,%g0,%o0
-.Lmp32sub_loop:
+LOCAL(mp32sub_loop):
lduw [%o1+%g1],%g2
lduw [%o2+%g1],%g3
subccc %g2,%g3,%g4
stw %g4,[%o1+%g1]
- brnz,pt %g1,.Lmp32sub_loop
+ brnz,pt %g1,LOCAL(mp32sub_loop)
dec 4,%g1
retl
movcs %icc,1,%o0
-C_FUNCTION_END(mp32sub, .Lmp32sub_size)
+C_FUNCTION_END(mp32sub, LOCAL(mp32sub_size))
C_FUNCTION_BEGIN(mp32multwo)
+LABEL(mp32multwo)
.register %g2,#scratch
.register %g3,#scratch
@@ -128,18 +132,19 @@ C_FUNCTION_BEGIN(mp32multwo)
sll %o0,2,%g1
dec 4,%g1
addcc %g0,%g0,%o0
-.Lmp32multwo_loop:
+LOCAL(mp32multwo_loop):
lduw [%o1+%g1],%g2
addccc %g2,%g2,%g3
stw %g3,[%o1+%g1]
- brnz,pt %g1,.Lmp32multwo_loop
+ brnz,pt %g1,LOCAL(mp32multwo_loop)
dec 4,%g1
retl
movcs %icc,1,%o0
-C_FUNCTION_END(mp32multwo, .Lmp32multwo_size)
+C_FUNCTION_END(mp32multwo, LOCAL(mp32multwo_size))
C_FUNCTION_BEGIN(mp32setmul)
+LABEL(mp32setmul)
.register %g2,#scratch
.register %g3,#scratch
@@ -147,20 +152,21 @@ C_FUNCTION_BEGIN(mp32setmul)
sll %o0,2,%g1
dec 4,%g1
clr %o0
-.Lmp32setmul_loop:
+LOCAL(mp32setmul_loop):
lduw [%o2+%g1],%g2
srlx %o0,32,%o0
mulx %o3,%g2,%g3
add %o0,%g3,%o0
stw %o0,[%o1+%g1]
- brnz,pt %g1,.Lmp32setmul_loop
+ brnz,pt %g1,LOCAL(mp32setmul_loop)
dec 4,%g1
retl
srlx %o0,32,%o0
-C_FUNCTION_END(mp32setmul, .Lmp32setmul_size)
+C_FUNCTION_END(mp32setmul, LOCAL(mp32setmul_size))
C_FUNCTION_BEGIN(mp32addmul)
+LABEL(mp32addmul)
.register %g2,#scratch
.register %g3,#scratch
@@ -168,7 +174,7 @@ C_FUNCTION_BEGIN(mp32addmul)
sll %o0,2,%g1
dec 4,%g1
clr %o0
-.Lmp32addmul_loop:
+LOCAL(mp32addmul_loop):
lduw [%o2+%g1],%g2
lduw [%o1+%g1],%g4
srlx %o0,32,%o0
@@ -176,14 +182,15 @@ C_FUNCTION_BEGIN(mp32addmul)
add %o0,%g3,%o0
add %o0,%g4,%o0
stw %o0,[%o1+%g1]
- brnz,pt %g1,.Lmp32addmul_loop
+ brnz,pt %g1,LOCAL(mp32addmul_loop)
dec 4,%g1
retl
srlx %o0,32,%o0
-C_FUNCTION_END(mp32addmul, .Lmp32addmul_size)
+C_FUNCTION_END(mp32addmul, LOCAL(mp32addmul_size))
C_FUNCTION_BEGIN(mp32addsqrtrc)
+LABEL(mp32addsqrtrc)
.register %g2,#scratch
.register %g3,#scratch
@@ -193,7 +200,7 @@ C_FUNCTION_BEGIN(mp32addsqrtrc)
add %o1,%g1,%o1
add %o1,%g1,%o1
clr %o0
-.Lmp32addsqrtrc_loop:
+LOCAL(mp32addsqrtrc_loop):
/* load from o1 into g4 as xuint; simulate xuint carry by doing an xuint comparison; carry if result smaller than initial value */
lduw [%o2+%g1],%g2
ldx [%o1],%g4
@@ -205,8 +212,8 @@ C_FUNCTION_BEGIN(mp32addsqrtrc)
movgu %xcc,1,%o0
stx %g3,[%o1]
sub %o1,8,%o1
- brnz,pt %g1,.Lmp32addsqrtrc_loop
+ brnz,pt %g1,LOCAL(mp32addsqrtrc_loop)
dec 4,%g1
retl
nop
-C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size)
+C_FUNCTION_END(mp32addsqrtrc, LOCAL(mp32addsqrtrc_size))
diff --git a/beecrypt/gas/mp64opt.ia64.S b/beecrypt/gas/mp64opt.ia64.S
index 5be6911bd..581bf4d30 100644
--- a/beecrypt/gas/mp64opt.ia64.S
+++ b/beecrypt/gas/mp64opt.ia64.S
@@ -25,7 +25,7 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
#define saved_pfs r14
#define saved_lc r15
diff --git a/beecrypt/gas/fips180opt.i586.S b/beecrypt/gas/sha1opt.i586.S
index aeeef5133..55c0ce0ad 100644
--- a/beecrypt/gas/fips180opt.i586.S
+++ b/beecrypt/gas/sha1opt.i586.S
@@ -25,7 +25,7 @@
*
*/
-#include "config.gas.h"
+#include "beecrypt.gas.h"
.file "fips180opt.i586.S"
@@ -105,6 +105,7 @@
.endm
C_FUNCTION_BEGIN(sha1Process)
+LABEL(sha1Process)
pushl %edi
pushl %esi
pushl %ebx
@@ -116,28 +117,28 @@ C_FUNCTION_BEGIN(sha1Process)
movl %esp,%ebp
movl $4,%ecx
-.L0:
+LOCAL(0):
movl (%esi,%ecx,4),%edx
movl %edx,(%ebp,%ecx,4)
decl %ecx
- jns .L0
+ jns LOCAL(0)
movl $15,%ecx
xorl %eax,%eax
.p2align 2
-.L1:
+LOCAL(1):
movl (%edi,%ecx,4),%edx
bswap %edx
mov %edx,(%edi,%ecx,4)
decl %ecx
- jns .L1
+ jns LOCAL(1)
leal PARAM_DATA(%esi),%edi
movl $16,%ecx
.p2align 2
-.L2:
+LOCAL(2):
movl 52(%edi),%eax
movl 56(%edi),%ebx
xorl 32(%edi),%eax
@@ -164,12 +165,12 @@ C_FUNCTION_BEGIN(sha1Process)
movl %ebx,76(%edi)
addl $16,%edi
decl %ecx
- jnz .L2
+ jnz LOCAL(2)
movl $PARAM_DATA,%edi
movl (%ebp),%eax
-.L01_20:
+LOCAL(01_20):
subround1 4(%ebp), 8(%ebp), 12(%ebp), 16(%ebp), 0
subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
@@ -195,7 +196,7 @@ C_FUNCTION_BEGIN(sha1Process)
subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
-.L21_40:
+LOCAL(21_40):
subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
@@ -221,7 +222,7 @@ C_FUNCTION_BEGIN(sha1Process)
subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
-.L41_60:
+LOCAL(41_60):
subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
@@ -247,7 +248,7 @@ C_FUNCTION_BEGIN(sha1Process)
subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
-.L61_80:
+LOCAL(61_80):
subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
@@ -276,11 +277,11 @@ C_FUNCTION_BEGIN(sha1Process)
movl $4,%ecx
.p2align 2
-.L3:
+LOCAL(3):
movl (%ebp,%ecx,4),%eax
addl %eax,(%esi,%ecx,4)
decl %ecx
- jns .L3
+ jns LOCAL(3)
addl $20,%esp
popl %ebp
@@ -288,4 +289,4 @@ C_FUNCTION_BEGIN(sha1Process)
popl %esi
popl %edi
ret
-C_FUNCTION_END(sha1Process, .Lsha1Process_size)
+C_FUNCTION_END(sha1Process, LOCAL(sha1Process_size))
diff --git a/beecrypt/hmac.c b/beecrypt/hmac.c
index 2554a1f37..0d3bd50ce 100644
--- a/beecrypt/hmac.c
+++ b/beecrypt/hmac.c
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 1999, 2000 Virtual Unlimited B.V.
+ * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -27,44 +27,76 @@
#include "system.h"
#include "hmac.h"
+#include "mp32.h"
#include "endianness.h"
#include "debug.h"
-#define HMAC_IPAD 0x36363636
-#define HMAC_OPAD 0x5c5c5c5c
+#define HMAC_IPAD 0x36
+#define HMAC_OPAD 0x5c
int hmacSetup(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param, const uint32* key, int keybits)
{
- int keywords = (((uint32)keybits) >> 5);
+ register int i, rc;
+ int keywords = (((uint32)keybits + 31) >> 5); /* rounded up */
+ int keybytes = (((uint32)keybits ) >> 3);
- if (keywords <= 16)
+ /* if the key is too large, hash it first */
+ if (keybytes > 64)
{
- register int i;
-
- if (keywords > 0)
- {
- (void) encodeInts((const javaint*) key, (byte*) hp->kxi, keywords);
- (void) encodeInts((const javaint*) key, (byte*) hp->kxo, keywords);
-
- for (i = 0; i < keywords; i++)
- {
- hp->kxi[i] ^= HMAC_IPAD;
- hp->kxo[i] ^= HMAC_OPAD;
- }
- }
-
- for (i = keywords; i < 16; i++)
- {
- hp->kxi[i] = HMAC_IPAD;
- hp->kxo[i] = HMAC_OPAD;
- }
-
- return hmacReset(hp, hash, param);
+ uint32 keydigest[16];
+ byte* tmp;
+
+ /* if the hash digest is too large, this doesn't help */
+ if (hash->digestsize > 64)
+ return -1;
+
+ if (hash->reset(param))
+ return -1;
+
+ tmp = (byte*) malloc(keybytes);
+
+ if (tmp == (byte*) 0)
+ return -1;
+
+ /* before we can hash the key, we need to encode it! */
+ encodeIntsPartial(key, tmp, keybytes);
+
+ rc = hash->update(param, tmp, keybytes);
+ free(tmp);
+
+ if (rc)
+ return -1;
+
+ if (hash->digest(param, keydigest))
+ return -1;
+
+ keywords = hash->digestsize >> 2;
+ keybytes = hash->digestsize;
+
+ encodeInts(keydigest, hp->kxi, keybytes);
+ encodeInts(keydigest, hp->kxo, keybytes);
+ }
+ else if (keybytes > 0)
+ {
+ encodeIntsPartial(key, hp->kxi, keybytes);
+ encodeIntsPartial(key, hp->kxo, keybytes);
}
+ else
+ return -1;
- /* key too long */
+ for (i = 0; i < keybytes; i++)
+ {
+ hp->kxi[i] ^= HMAC_IPAD;
+ hp->kxo[i] ^= HMAC_OPAD;
+ }
+
+ for (i = keybytes; i < 64; i++)
+ {
+ hp->kxi[i] = HMAC_IPAD;
+ hp->kxo[i] = HMAC_OPAD;
+ }
- return -1;
+ return hmacReset(hp, hash, param);
}
int hmacReset(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param)
@@ -72,7 +104,7 @@ int hmacReset(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param)
if (hash->reset(param))
return -1;
- if (hash->update(param, (const byte*) hp->kxi, 64))
+ if (hash->update(param, hp->kxi, 64))
return -1;
return 0;
@@ -88,7 +120,7 @@ int hmacDigest(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param
if (hash->digest(param, data))
return -1;
- if (hash->update(param, (const byte*) hp->kxo, 64))
+ if (hash->update(param, hp->kxo, 64))
return -1;
/* digestsize is in bytes; divide by 4 to get the number of words */
diff --git a/beecrypt/hmac.h b/beecrypt/hmac.h
index 32d94e18d..2152665eb 100644
--- a/beecrypt/hmac.h
+++ b/beecrypt/hmac.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 1999, 2000 Virtual Unlimited B.V.
+ * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -34,8 +34,8 @@
*/
typedef struct
{
- uint32 kxi[16];
- uint32 kxo[16];
+ byte kxi[64];
+ byte kxo[64];
} hmacParam;
#ifdef __cplusplus
diff --git a/beecrypt/hmacmd5.c b/beecrypt/hmacmd5.c
index 42754bdd1..cb979e60c 100644
--- a/beecrypt/hmacmd5.c
+++ b/beecrypt/hmacmd5.c
@@ -36,21 +36,21 @@ const keyedHashFunction hmacmd5 = { "HMAC-MD5", sizeof(hmacmd5Param), 64, 4 * si
/*@-type@*/
int hmacmd5Setup (hmacmd5Param* sp, const uint32* key, int keybits)
{
- return hmacSetup((hmacParam*) sp, &md5, &sp->param, key, keybits);
+ return hmacSetup(&sp->hparam, &md5, &sp->mparam, key, keybits);
}
int hmacmd5Reset (hmacmd5Param* sp)
{
- return hmacReset((hmacParam*) sp, &md5, &sp->param);
+ return hmacReset(&sp->hparam, &md5, &sp->mparam);
}
int hmacmd5Update(hmacmd5Param* sp, const byte* data, int size)
{
- return hmacUpdate((hmacParam*) sp, &md5, &sp->param, data, size);
+ return hmacUpdate(&sp->hparam, &md5, &sp->mparam, data, size);
}
int hmacmd5Digest(hmacmd5Param* sp, uint32* data)
{
- return hmacDigest((hmacParam*) sp, &md5, &sp->param, data);
+ return hmacDigest(&sp->hparam, &md5, &sp->mparam, data);
}
/*@=type@*/
diff --git a/beecrypt/hmacmd5.h b/beecrypt/hmacmd5.h
index 69be69f50..da61a38f9 100644
--- a/beecrypt/hmacmd5.h
+++ b/beecrypt/hmacmd5.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -35,9 +35,8 @@
*/
typedef struct
{
-/*@unused@*/ byte kxi[64];
-/*@unused@*/ byte kxo[64];
- md5Param param;
+ hmacParam hparam;
+ md5Param mparam;
} hmacmd5Param;
#ifdef __cplusplus
diff --git a/beecrypt/hmacsha1.c b/beecrypt/hmacsha1.c
index 0c490707b..6fbf8ca88 100644
--- a/beecrypt/hmacsha1.c
+++ b/beecrypt/hmacsha1.c
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 1999, 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -36,21 +36,21 @@ const keyedHashFunction hmacsha1 = { "HMAC-SHA-1", sizeof(hmacsha1Param), 64, 5
/*@-type@*/
int hmacsha1Setup (hmacsha1Param* sp, const uint32* key, int keybits)
{
- return hmacSetup((hmacParam*) sp, &sha1, &sp->param, key, keybits);
+ return hmacSetup(&sp->hparam, &sha1, &sp->sparam, key, keybits);
}
int hmacsha1Reset (hmacsha1Param* sp)
{
- return hmacReset((hmacParam*) sp, &sha1, &sp->param);
+ return hmacReset(&sp->hparam, &sha1, &sp->sparam);
}
int hmacsha1Update(hmacsha1Param* sp, const byte* data, int size)
{
- return hmacUpdate((hmacParam*) sp, &sha1, &sp->param, data, size);
+ return hmacUpdate(&sp->hparam, &sha1, &sp->sparam, data, size);
}
int hmacsha1Digest(hmacsha1Param* sp, uint32* data)
{
- return hmacDigest((hmacParam*) sp, &sha1, &sp->param, data);
+ return hmacDigest(&sp->hparam, &sha1, &sp->sparam, data);
}
/*@=type@*/
diff --git a/beecrypt/hmacsha1.h b/beecrypt/hmacsha1.h
index a89cc085e..e6d46bb25 100644
--- a/beecrypt/hmacsha1.h
+++ b/beecrypt/hmacsha1.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 1999, 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -29,15 +29,14 @@
#define _HMACSHA1_H
#include "hmac.h"
-#include "fips180.h"
+#include "sha1.h"
/** \ingroup HMAC_sha1_m
*/
typedef struct
{
-/*@unused@*/ byte kxi[64];
-/*@unused@*/ byte kxo[64];
- sha1Param param;
+ hmacParam hparam;
+ sha1Param sparam;
} hmacsha1Param;
#ifdef __cplusplus
diff --git a/beecrypt/hmacsha256.c b/beecrypt/hmacsha256.c
index 317b2cc00..403bd265b 100644
--- a/beecrypt/hmacsha256.c
+++ b/beecrypt/hmacsha256.c
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -36,21 +36,21 @@ const keyedHashFunction hmacsha256 = { "HMAC-SHA-256", sizeof(hmacsha256Param),
/*@-type@*/
int hmacsha256Setup (hmacsha256Param* sp, const uint32* key, int keybits)
{
- return hmacSetup((hmacParam*) sp, &sha256, &sp->param, key, keybits);
+ return hmacSetup(&sp->hparam, &sha256, &sp->sparam, key, keybits);
}
int hmacsha256Reset (hmacsha256Param* sp)
{
- return hmacReset((hmacParam*) sp, &sha256, &sp->param);
+ return hmacReset(&sp->hparam, &sha256, &sp->sparam);
}
int hmacsha256Update(hmacsha256Param* sp, const byte* data, int size)
{
- return hmacUpdate((hmacParam*) sp, &sha256, &sp->param, data, size);
+ return hmacUpdate(&sp->hparam, &sha256, &sp->sparam, data, size);
}
int hmacsha256Digest(hmacsha256Param* sp, uint32* data)
{
- return hmacDigest((hmacParam*) sp, &sha256, &sp->param, data);
+ return hmacDigest(&sp->hparam, &sha256, &sp->sparam, data);
}
/*@=type@*/
diff --git a/beecrypt/hmacsha256.h b/beecrypt/hmacsha256.h
index ba57f6d12..a214ae390 100644
--- a/beecrypt/hmacsha256.h
+++ b/beecrypt/hmacsha256.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -35,9 +35,8 @@
*/
typedef struct
{
-/*@unused@*/ byte kxi[64];
-/*@unused@*/ byte kxo[64];
- sha256Param param;
+ hmacParam hparam;
+ sha256Param sparam;
} hmacsha256Param;
#ifdef __cplusplus
diff --git a/beecrypt/installgen.sh b/beecrypt/installgen.sh
new file mode 100755
index 000000000..8475dee7c
--- /dev/null
+++ b/beecrypt/installgen.sh
@@ -0,0 +1,6 @@
+#! /bin/sh
+rm -f ltconfig ltmain.sh
+aclocal
+autoheader
+automake -a
+autoconf
diff --git a/beecrypt/masm/Makefile.am b/beecrypt/masm/Makefile.am
index 990ff8fb9..6c5bff09f 100644
--- a/beecrypt/masm/Makefile.am
+++ b/beecrypt/masm/Makefile.am
@@ -1,7 +1,7 @@
#
# Makefile.am's purpose is to add the Microsoft assembler files to the dist
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -22,4 +22,4 @@
AUTOMAKE_OPTIONS = gnu no-dependencies
-EXTRA_DIST = blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm
+EXTRA_DIST = aesopt.i586.asm blowfishopt.i586.asm mp32opt.i386.asm sha1opt.i586.asm
diff --git a/beecrypt/masm/Makefile.in b/beecrypt/masm/Makefile.in
index 273e92c87..a90e1d368 100644
--- a/beecrypt/masm/Makefile.in
+++ b/beecrypt/masm/Makefile.in
@@ -17,7 +17,7 @@
#
# Makefile.am's purpose is to add the Microsoft assembler files to the dist
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -127,7 +127,7 @@ uint8_type = @uint8_type@
AUTOMAKE_OPTIONS = gnu no-dependencies
-EXTRA_DIST = blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm
+EXTRA_DIST = aesopt.i586.asm blowfishopt.i586.asm mp32opt.i386.asm sha1opt.i586.asm
subdir = masm
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
diff --git a/beecrypt/masm/aesopt.i586.asm b/beecrypt/masm/aesopt.i586.asm
new file mode 100644
index 000000000..8cfc32918
--- /dev/null
+++ b/beecrypt/masm/aesopt.i586.asm
@@ -0,0 +1,661 @@
+;
+; aesopt.i586.asm
+;
+; Assembler optimized AES routines for Intel Pentium processors
+;
+; Compile target is Microsoft Macro Assembler
+;
+; Copyright (c) 2002 Bob Deblier <bob@virtualunlimited.com>
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Lesser General Public
+; License as published by the Free Software Foundation; either
+; version 2.1 of the License, or (at your option) any later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+;
+
+ .586
+ .model flat,C
+
+EXTRN _ae0:DWORD
+EXTRN _ae1:DWORD
+EXTRN _ae2:DWORD
+EXTRN _ae3:DWORD
+EXTRN _ae4:DWORD
+
+EXTRN _ad0:DWORD
+EXTRN _ad1:DWORD
+EXTRN _ad2:DWORD
+EXTRN _ad3:DWORD
+EXTRN _ad4:DWORD
+
+ .code
+
+; esp points to s and t (on stack; 32 bytes altogether)
+; ebp points to rk
+; edi points to dst
+; esi points to src
+
+sxrk macro
+ ; compute swap(src) xor rk
+ mov eax,dword ptr [esi ]
+ mov ebx,dword ptr [esi+ 4]
+ mov ecx,dword ptr [esi+ 8]
+ mov edx,dword ptr [esi+12]
+ bswap eax
+ bswap ebx
+ bswap ecx
+ bswap edx
+ xor eax,dword ptr [ebp ]
+ xor ebx,dword ptr [ebp+ 4]
+ xor ecx,dword ptr [ebp+ 8]
+ xor edx,dword ptr [ebp+12]
+ mov dword ptr [esp ],eax
+ mov dword ptr [esp+ 4],ebx
+ mov dword ptr [esp+ 8],ecx
+ mov dword ptr [esp+12],edx
+ endm
+
+etfs macro offset
+ ; compute t0 and t1
+ mov ecx,[ebp+offset ]
+ mov edx,[ebp+offset+4]
+
+ movzx eax,byte ptr [esp+ 3]
+ movzx ebx,byte ptr [esp+ 7]
+ xor ecx,dword ptr [eax*4+_ae0]
+ xor edx,dword ptr [ebx*4+_ae0]
+
+ movzx eax,byte ptr [esp+ 6]
+ movzx ebx,byte ptr [esp+10]
+ xor ecx,dword ptr [eax*4+_ae1]
+ xor edx,dword ptr [ebx*4+_ae1]
+
+ movzx eax,byte ptr [esp+ 9]
+ movzx ebx,byte ptr [esp+13]
+ xor ecx,dword ptr [eax*4+_ae2]
+ xor edx,dword ptr [ebx*4+_ae2]
+
+ movzx eax,byte ptr [esp+12]
+ movzx ebx,byte ptr [esp ]
+ xor ecx,dword ptr [eax*4+_ae3]
+ xor edx,dword ptr [ebx*4+_ae3]
+
+ mov dword ptr [esp+16],ecx
+ mov dword ptr [esp+20],edx
+
+ ; compute t2 and t3
+ mov ecx,dword ptr [ebp+offset+ 8]
+ mov edx,dword ptr [ebp+offset+12]
+
+ movzx eax,byte ptr [esp+11]
+ movzx ebx,byte ptr [esp+15]
+ xor ecx,dword ptr [eax*4+_ae0]
+ xor edx,dword ptr [ebx*4+_ae0]
+
+ movzx eax,byte ptr [esp+14]
+ movzx ebx,byte ptr [esp+ 2]
+ xor ecx,dword ptr [eax*4+_ae1]
+ xor edx,dword ptr [ebx*4+_ae1]
+
+ movzx eax,byte ptr [esp+ 1]
+ movzx ebx,byte ptr [esp+ 5]
+ xor ecx,dword ptr [eax*4+_ae2]
+ xor edx,dword ptr [ebx*4+_ae2]
+
+ movzx eax,byte ptr [esp+ 4]
+ movzx ebx,byte ptr [esp+ 8]
+ xor ecx,dword ptr [eax*4+_ae3]
+ xor edx,dword ptr [ebx*4+_ae3]
+
+ mov dword ptr [esp+24],ecx
+ mov dword ptr [esp+28],edx
+ endm
+
+esft macro offset
+ ; compute s0 and s1
+ mov ecx,[ebp+offset ]
+ mov edx,[ebp+offset+4]
+
+ movzx eax,byte ptr [esp+19]
+ movzx ebx,byte ptr [esp+23]
+ xor ecx,dword ptr [eax*4+_ae0]
+ xor edx,dword ptr [ebx*4+_ae0]
+
+ movzx eax,byte ptr [esp+22]
+ movzx ebx,byte ptr [esp+26]
+ xor ecx,dword ptr [eax*4+_ae1]
+ xor edx,dword ptr [ebx*4+_ae1]
+
+ movzx eax,byte ptr [esp+25]
+ movzx ebx,byte ptr [esp+29]
+ xor ecx,dword ptr [eax*4+_ae2]
+ xor edx,dword ptr [ebx*4+_ae2]
+
+ movzx eax,byte ptr [esp+28]
+ movzx ebx,byte ptr [esp+16]
+ xor ecx,dword ptr [eax*4+_ae3]
+ xor edx,dword ptr [ebx*4+_ae3]
+
+ mov dword ptr [esp ],ecx
+ mov dword ptr [esp+ 4],edx
+
+ ; compute s2 and s3
+ mov ecx,dword ptr [ebp+offset+ 8]
+ mov edx,dword ptr [ebp+offset+12]
+
+ movzx eax,byte ptr [esp+27]
+ movzx ebx,byte ptr [esp+31]
+ xor ecx,dword ptr [eax*4+_ae0]
+ xor edx,dword ptr [ebx*4+_ae0]
+
+ movzx eax,byte ptr [esp+30]
+ movzx ebx,byte ptr [esp+18]
+ xor ecx,dword ptr [eax*4+_ae1]
+ xor edx,dword ptr [ebx*4+_ae1]
+
+ movzx eax,byte ptr [esp+17]
+ movzx ebx,byte ptr [esp+21]
+ xor ecx,dword ptr [eax*4+_ae2]
+ xor edx,dword ptr [ebx*4+_ae2]
+
+ movzx eax,byte ptr [esp+20]
+ movzx ebx,byte ptr [esp+24]
+ xor ecx,dword ptr [eax*4+_ae3]
+ xor edx,dword ptr [ebx*4+_ae3]
+
+ mov dword ptr [esp+ 8],ecx
+ mov dword ptr [esp+12],edx
+ endm
+
+elr macro
+ mov ecx,dword ptr [ebp+ 0]
+ mov edx,dword ptr [ebp+ 4]
+
+ movzx eax,byte ptr [esp+19]
+ movzx ebx,byte ptr [esp+23]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ff000000h
+ and ebx,0ff000000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+22]
+ movzx ebx,byte ptr [esp+26]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ff0000h
+ and ebx,0ff0000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+25]
+ movzx ebx,byte ptr [esp+29]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ff00h
+ and ebx,0ff00h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+28]
+ movzx ebx,byte ptr [esp+16]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ffh
+ and ebx,0ffh
+ xor ecx,eax
+ xor edx,ebx
+
+ mov dword ptr [esp+ 0],ecx
+ mov dword ptr [esp+ 4],edx
+
+ mov ecx,dword ptr [ebp+ 8]
+ mov edx,dword ptr [ebp+12]
+
+ movzx eax,byte ptr [esp+27]
+ movzx ebx,byte ptr [esp+31]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ff000000h
+ and ebx,0ff000000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+30]
+ movzx ebx,byte ptr [esp+18]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ff0000h
+ and ebx,0ff0000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+17]
+ movzx ebx,byte ptr [esp+21]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ff00h
+ and ebx,0ff00h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+20]
+ movzx ebx,byte ptr [esp+24]
+ mov eax,dword ptr [eax*4+_ae4]
+ mov ebx,dword ptr [ebx*4+_ae4]
+ and eax,0ffh
+ and ebx,0ffh
+ xor ecx,eax
+ xor edx,ebx
+
+ mov dword ptr [esp+ 8],ecx
+ mov dword ptr [esp+12],edx
+ endm
+
+eblock macro label
+ ; load initial values for s0 thru s3
+ sxrk
+
+ ; do 9 rounds
+ etfs 16
+ esft 32
+ etfs 48
+ esft 64
+ etfs 80
+ esft 96
+ etfs 112
+ esft 128
+ etfs 144
+ ; test if we had to do 10 rounds, if yes jump to last round
+ mov eax,dword ptr [ebp+256]
+ cmp eax,10
+ je @label
+ ; do two more rounds
+ esft 160
+ etfs 176
+ ; test if we had to do 12 rounds, if yes jump to last round
+ mov eax,dword ptr [ebp+256]
+ cmp eax,12
+ je @label
+ ; do two more rounds
+ esft 192
+ etfs 208
+ ; prepare for last round
+ mov eax,dword ptr [ebp+256]
+@label:
+ ; add 16 times the number of rounds to ebp
+ sal eax,4
+ add ebp,eax
+ ; do last round
+ elr
+ endm
+
+eblockc macro label
+ ; encrypt block in cbc mode
+ sxrfxrk
+
+ ; do 9 rounds
+ etfs 16
+ esft 32
+ etfs 48
+ esft 64
+ etfs 80
+ esft 96
+ etfs 112
+ esft 128
+ etfs 144
+ ; test if we had to do 10 rounds, if yes jump to last round
+ mov eax,dword ptr [ebp+256]
+ cmp eax,10
+ je @label
+ ; do two more rounds
+ esft 160
+ etfs 176
+ ; test if we had to do 12 rounds, if yes jump to last round
+ mov eax,dword ptr [ebp+256]
+ cmp eax,12
+ je @label
+ ; do two more rounds
+ esft 192
+ etfs 208
+ ; prepare for last round
+ mov eax,dword ptr [ebp+256]
+@label:
+ ; add 16 times the number of rounds to ebp
+ sal eax,4
+ add ebp,eax
+ ; do last round
+ elr
+ endm
+
+dtfs macro offset
+ ; compute t0 and t1
+ mov ecx,[ebp+offset ]
+ mov edx,[ebp+offset+4]
+
+ movzx eax,byte ptr [esp+ 3]
+ movzx ebx,byte ptr [esp+ 7]
+ xor ecx,dword ptr [eax*4+_ad0]
+ xor edx,dword ptr [ebx*4+_ad0]
+
+ movzx eax,byte ptr [esp+14]
+ movzx ebx,byte ptr [esp+ 2]
+ xor ecx,dword ptr [eax*4+_ad1]
+ xor edx,dword ptr [ebx*4+_ad1]
+
+ movzx eax,byte ptr [esp+ 9]
+ movzx ebx,byte ptr [esp+13]
+ xor ecx,dword ptr [eax*4+_ad2]
+ xor edx,dword ptr [ebx*4+_ad2]
+
+ movzx eax,byte ptr [esp+ 4]
+ movzx ebx,byte ptr [esp+ 8]
+ xor ecx,dword ptr [eax*4+_ad3]
+ xor edx,dword ptr [ebx*4+_ad3]
+
+ mov dword ptr [esp+16],ecx
+ mov dword ptr [esp+20],edx
+
+ ; compute t2 and t3
+ mov ecx,dword ptr [ebp+offset+ 8]
+ mov edx,dword ptr [ebp+offset+12]
+
+ movzx eax,byte ptr [esp+11]
+ movzx ebx,byte ptr [esp+15]
+ xor ecx,dword ptr [eax*4+_ad0]
+ xor edx,dword ptr [ebx*4+_ad0]
+
+ movzx eax,byte ptr [esp+ 6]
+ movzx ebx,byte ptr [esp+10]
+ xor ecx,dword ptr [eax*4+_ad1]
+ xor edx,dword ptr [ebx*4+_ad1]
+
+ movzx eax,byte ptr [esp+ 1]
+ movzx ebx,byte ptr [esp+ 5]
+ xor ecx,dword ptr [eax*4+_ad2]
+ xor edx,dword ptr [ebx*4+_ad2]
+
+ movzx eax,byte ptr [esp+12]
+ movzx ebx,byte ptr [esp ]
+ xor ecx,dword ptr [eax*4+_ad3]
+ xor edx,dword ptr [ebx*4+_ad3]
+
+ mov dword ptr [esp+24],ecx
+ mov dword ptr [esp+28],edx
+ endm
+
+dsft macro offset
+ ; compute s0 and s1
+ mov ecx,[ebp+offset ]
+ mov edx,[ebp+offset+4]
+
+ movzx eax,byte ptr [esp+19]
+ movzx ebx,byte ptr [esp+23]
+ xor ecx,dword ptr [eax*4+_ad0]
+ xor edx,dword ptr [ebx*4+_ad0]
+
+ movzx eax,byte ptr [esp+30]
+ movzx ebx,byte ptr [esp+18]
+ xor ecx,dword ptr [eax*4+_ad1]
+ xor edx,dword ptr [ebx*4+_ad1]
+
+ movzx eax,byte ptr [esp+25]
+ movzx ebx,byte ptr [esp+29]
+ xor ecx,dword ptr [eax*4+_ad2]
+ xor edx,dword ptr [ebx*4+_ad2]
+
+ movzx eax,byte ptr [esp+20]
+ movzx ebx,byte ptr [esp+24]
+ xor ecx,dword ptr [eax*4+_ad3]
+ xor edx,dword ptr [ebx*4+_ad3]
+
+ mov dword ptr [esp ],ecx
+ mov dword ptr [esp+ 4],edx
+
+ ; compute s2 and s3
+ mov ecx,dword ptr [ebp+offset+ 8]
+ mov edx,dword ptr [ebp+offset+12]
+
+ movzx eax,byte ptr [esp+27]
+ movzx ebx,byte ptr [esp+31]
+ xor ecx,dword ptr [eax*4+_ad0]
+ xor edx,dword ptr [ebx*4+_ad0]
+
+ movzx eax,byte ptr [esp+22]
+ movzx ebx,byte ptr [esp+26]
+ xor ecx,dword ptr [eax*4+_ad1]
+ xor edx,dword ptr [ebx*4+_ad1]
+
+ movzx eax,byte ptr [esp+17]
+ movzx ebx,byte ptr [esp+21]
+ xor ecx,dword ptr [eax*4+_ad2]
+ xor edx,dword ptr [ebx*4+_ad2]
+
+ movzx eax,byte ptr [esp+28]
+ movzx ebx,byte ptr [esp+16]
+ xor ecx,dword ptr [eax*4+_ad3]
+ xor edx,dword ptr [ebx*4+_ad3]
+
+ mov dword ptr [esp+ 8],ecx
+ mov dword ptr [esp+12],edx
+ endm
+
+dlr macro
+ mov ecx,dword ptr [ebp+ 0]
+ mov edx,dword ptr [ebp+ 4]
+
+ movzx eax,byte ptr [esp+19]
+ movzx ebx,byte ptr [esp+23]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ff000000h
+ and ebx,0ff000000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+30]
+ movzx ebx,byte ptr [esp+18]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ff0000h
+ and ebx,0ff0000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+25]
+ movzx ebx,byte ptr [esp+29]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ff00h
+ and ebx,0ff00h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+20]
+ movzx ebx,byte ptr [esp+24]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ffh
+ and ebx,0ffh
+ xor ecx,eax
+ xor edx,ebx
+
+ mov dword ptr [esp+ 0],ecx
+ mov dword ptr [esp+ 4],edx
+
+ mov ecx,dword ptr [ebp+ 8]
+ mov edx,dword ptr [ebp+12]
+
+ movzx eax,byte ptr [esp+27]
+ movzx ebx,byte ptr [esp+31]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ff000000h
+ and ebx,0ff000000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+22]
+ movzx ebx,byte ptr [esp+26]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ff0000h
+ and ebx,0ff0000h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+17]
+ movzx ebx,byte ptr [esp+21]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ff00h
+ and ebx,0ff00h
+ xor ecx,eax
+ xor edx,ebx
+
+ movzx eax,byte ptr [esp+28]
+ movzx ebx,byte ptr [esp+16]
+ mov eax,dword ptr [eax*4+_ad4]
+ mov ebx,dword ptr [ebx*4+_ad4]
+ and eax,0ffh
+ and ebx,0ffh
+ xor ecx,eax
+ xor edx,ebx
+
+ mov dword ptr [esp+ 8],ecx
+ mov dword ptr [esp+12],edx
+ endm
+
+dblock macro label
+ ; load initial values for s0 thru s3
+ sxrk
+
+ ; do 9 rounds
+ dtfs 16
+ dsft 32
+ dtfs 48
+ dsft 64
+ dtfs 80
+ dsft 96
+ dtfs 112
+ dsft 128
+ dtfs 144
+ ; test if we had to do 10 rounds, if yes jump to last round
+ mov eax,dword ptr [ebp+256]
+ cmp eax,10
+ je @label
+ ; do two more rounds
+ dsft 160
+ dtfs 176
+ ; test if we had to do 12 rounds, if yes jump to last round
+ mov eax,dword ptr [ebp+256]
+ cmp eax,12
+ je @label
+ ; do two more rounds
+ dsft 192
+ dtfs 208
+ ; prepare for last round
+ mov eax,dword ptr [ebp+256]
+@label:
+ ; add 16 times the number of rounds to ebp
+ sal eax,4
+ add ebp,eax
+ ; do last round
+ dlr
+ endm
+
+aesEncrypt proc
+ push edi
+ push esi
+ push ebp
+ push ebx
+
+ ; set pointers
+ mov ebp,dword ptr [esp+20] ; rk
+ mov edi,dword ptr [esp+24] ; dst
+ mov esi,dword ptr [esp+28] ; src
+
+ ; add local storage for s and t variables, 32 bytes total
+ sub esp,32
+
+ eblock e
+
+ ; save stuff back
+ mov eax,dword ptr [esp+ 0]
+ mov ebx,dword ptr [esp+ 4]
+ mov ecx,dword ptr [esp+ 8]
+ mov edx,dword ptr [esp+12]
+ bswap eax
+ bswap ebx
+ bswap ecx
+ bswap edx
+ mov dword ptr [edi ],eax
+ mov dword ptr [edi+ 4],ebx
+ mov dword ptr [edi+ 8],ecx
+ mov dword ptr [edi+12],edx
+
+ ; remove local storage
+ add esp,32
+
+ xor eax,eax
+
+ pop ebx
+ pop ebp
+ pop esi
+ pop edi
+ ret
+aesEncrypt endp
+
+aesDecrypt proc
+ push edi
+ push esi
+ push ebp
+ push ebx
+
+ ; set pointers
+ mov ebp,dword ptr [esp+20] ; rk
+ mov edi,dword ptr [esp+24] ; dst
+ mov esi,dword ptr [esp+28] ; src
+
+ ; add local storage for s and t variables, 32 bytes total
+ sub esp,32
+
+ dblock d
+
+ ; save stuff back
+ mov eax,dword ptr [esp+ 0]
+ mov ebx,dword ptr [esp+ 4]
+ mov ecx,dword ptr [esp+ 8]
+ mov edx,dword ptr [esp+12]
+ bswap eax
+ bswap ebx
+ bswap ecx
+ bswap edx
+ mov dword ptr [edi ],eax
+ mov dword ptr [edi+ 4],ebx
+ mov dword ptr [edi+ 8],ecx
+ mov dword ptr [edi+12],edx
+
+ ; remove local storage
+ add esp,32
+
+ xor eax,eax
+
+ pop ebx
+ pop ebp
+ pop esi
+ pop edi
+ ret
+aesDecrypt endp
+
+ end
diff --git a/beecrypt/masm/fips180opt.i586.asm b/beecrypt/masm/sha1opt.i586.asm
index 7c5eadac7..c020464db 100644
--- a/beecrypt/masm/fips180opt.i586.asm
+++ b/beecrypt/masm/sha1opt.i586.asm
@@ -1,5 +1,5 @@
;
-; fips180opt.i586.asm
+; sha1.i586.asm
;
; Assembler optimized SHA-1 routines for Intel Pentium processors
;
diff --git a/beecrypt/mp32.c b/beecrypt/mp32.c
index 190d31bbe..0afdd246b 100644
--- a/beecrypt/mp32.c
+++ b/beecrypt/mp32.c
@@ -726,11 +726,10 @@ uint32 mp32norm(register uint32 xsize, register uint32* xdata)
#endif
#ifndef ASM_MP32DIVPOWTWO
+/* need to eliminate this function, as it is not aptly named */
uint32 mp32divpowtwo(register uint32 xsize, register uint32* xdata)
{
- register uint32 shift = mp32lszcnt(xsize, xdata);
- mp32rshift(xsize, xdata, shift);
- return shift;
+ return mp32rshiftlsz(xsize, xdata);
}
#endif
@@ -894,6 +893,63 @@ void mp32rshift(register uint32 xsize, register uint32* xdata, uint32 count)
}
#endif
+#ifndef ASM_MP32RSHIFTLSZ
+/* x must be != 0 */
+uint32 mp32rshiftlsz(register uint32 xsize, register uint32* xdata)
+{
+ register uint32* slide = xdata+xsize-1;
+ register uint32 zwords = 0; /* counter for 'all zero bit' words */
+ register uint32 lbits, rbits = 0; /* counter for 'least significant zero' bits */
+ register uint32 temp, carry = 0;
+
+ xdata = slide;
+
+ /* count 'all zero' words and move src pointer */
+ while (xsize--)
+ {
+ /* test if we a non-zero word */
+ if ((carry = *(slide--)))
+ {
+ /* count 'least signification zero bits and set zbits counter */
+ while (!(carry & 0x1))
+ {
+ carry >>= 1;
+ rbits++;
+ }
+ break;
+ }
+ zwords++;
+ }
+
+ /* shouldn't happen, but let's test anyway */
+ if (xsize == 0)
+ return 0;
+
+ /* prepare right-shifting of data */
+ lbits = 32-rbits;
+
+ /* shift data */
+ while (xsize--)
+ {
+ temp = *(slide--);
+ *(xdata--) = (temp << lbits) | carry;
+ carry = (temp >> rbits);
+ }
+
+ /* store the final carry */
+ *(xdata--) = carry;
+
+ /* store the return value in temp */
+ temp = (zwords << 5) + rbits;
+
+ /* zero the (zwords) most significant words */
+ while (zwords--)
+ *(xdata--) = 0;
+
+ return temp;
+}
+#endif
+
/* try an alternate version here, with descending sizes */
/* also integrate lszcnt and rshift properly into one function */
#ifndef ASM_MP32GCD_W
@@ -917,33 +973,41 @@ void mp32gcd_w(uint32 size, const uint32* xdata, const uint32* ydata, uint32* re
mp32copy(size, result, xdata);
}
- /* start with doing mp32divpowtwo on both workspace and result, and store the returned values */
/* get the smallest returned values, and set shift to that */
- if ((temp = mp32lszcnt(size, wksp)))
- mp32rshift(size, wksp, temp);
-
- shift = temp;
+ shift = mp32rshiftlsz(size, wksp);
- if ((temp = mp32lszcnt(size, result)))
- mp32rshift(size, result, temp);
+ temp = mp32rshiftlsz(size, result);
if (shift > temp)
shift = temp;
while (mp32nz(size, wksp))
{
- if ((temp = mp32lszcnt(size, wksp)))
- mp32rshift(size, wksp, temp);
-
- if ((temp = mp32lszcnt(size, result)))
- mp32rshift(size, result, temp);
+ mp32rshiftlsz(size, wksp);
+ mp32rshiftlsz(size, result);
if (mp32ge(size, wksp, result))
(void) mp32sub(size, wksp, result);
else
(void) mp32sub(size, result, wksp);
+
+ /* slide past zero words in both operands by increasing pointers and decreasing size */
+ if ((*wksp == 0) && (*result == 0))
+ {
+ size--;
+ wksp++;
+ result++;
+ }
}
+
+ /* figure out if we need to slide the result pointer back */
+ if ((temp = shift >> 5))
+ {
+ size += temp;
+ result -= temp;
+ }
+
mp32lshift(size, result, shift);
}
#endif
diff --git a/beecrypt/mp32.h b/beecrypt/mp32.h
index 1adb4b249..f9f47ae8c 100644
--- a/beecrypt/mp32.h
+++ b/beecrypt/mp32.h
@@ -48,9 +48,9 @@ void mp32copy(uint32 size, /*@out@*/ uint32* dst, const uint32* src)
/*@modifies dst @*/;
#ifndef ASM_MP32COPY
#ifdef __LCLINT__
-#define mp32copy(size, dst, src) memmove(dst, src, ((unsigned)(size)) << 2)
+# define mp32copy(size, dst, src) memmove(dst, src, ((unsigned)(size)) << 2)
#else
-#define mp32copy(size, dst, src) memcpy(dst, src, (size) << 2)
+# define mp32copy(size, dst, src) memcpy(dst, src, (size) << 2)
#endif
#endif
@@ -61,9 +61,9 @@ void mp32move(uint32 size, /*@out@*/ uint32* dst, const uint32* src)
/*@modifies dst @*/;
#ifndef ASM_MP32MOVE
#ifdef __LCLINT__
-#define mp32move(size, dst, src) memmove(dst, src, ((unsigned)(size)) << 2)
+# define mp32move(size, dst, src) memmove(dst, src, ((unsigned)(size)) << 2)
#else
-#define mp32move(size, dst, src) memmove(dst, src, (size) << 2)
+# define mp32move(size, dst, src) memmove(dst, src, (size) << 2)
#endif
#endif
@@ -354,6 +354,12 @@ void mp32rshift(uint32 xsize, uint32* xdata, uint32 count)
/**
*/
BEECRYPTAPI
+uint32 mp32rshiftlsz(uint32 xsize, uint32* xdata)
+ /*@modifies xdata @*/;
+
+/**
+ */
+BEECRYPTAPI
uint32 mp32norm(uint32 xsize, uint32* xdata)
/*@modifies xdata @*/;
diff --git a/beecrypt/mp32barrett.c b/beecrypt/mp32barrett.c
index bada4a887..c0c9e6ab8 100644
--- a/beecrypt/mp32barrett.c
+++ b/beecrypt/mp32barrett.c
@@ -777,7 +777,7 @@ int mp32binv_w(const mp32barrett* b, uint32 xsize, const uint32* xdata, uint32*
mp32zero(size+1, bdata);
mp32setw(size+1, ddata, 1);
- if (mp32odd(size, b->modl) && mp32even(xsize, xdata))
+ if (mp32odd(size, b->modl))
{
/* use simplified binary extended gcd algorithm */
@@ -821,7 +821,10 @@ int mp32binv_w(const mp32barrett* b, uint32 xsize, const uint32* xdata, uint32*
mp32setx(size, result, size+1, ddata);
/*@-usedef@*/
if (*ddata & 0x80000000)
- (void) mp32add(size, result, b->modl);
+ {
+ /* keep adding the modulus until we get a carry */
+ while (!mp32add(size, result, b->modl));
+ }
/*@=usedef@*/
}
return 1;
@@ -886,7 +889,10 @@ int mp32binv_w(const mp32barrett* b, uint32 xsize, const uint32* xdata, uint32*
mp32setx(size, result, size+1, ddata);
/*@-usedef@*/
if (*ddata & 0x80000000)
- (void) mp32add(size, result, b->modl);
+ {
+ /* keep adding the modulus until we get a carry */
+ while (!mp32add(size, result, b->modl));
+ }
/*@=usedef@*/
}
return 1;
diff --git a/beecrypt/mp32opt.h b/beecrypt/mp32opt.h
index d49aa79f1..eea4246ef 100644
--- a/beecrypt/mp32opt.h
+++ b/beecrypt/mp32opt.h
@@ -105,6 +105,7 @@ extern "C" {
# if defined(OPTIMIZE_SPARCV8)
# define ASM_MP32SETMUL
# define ASM_MP32ADDMUL
+# define ASM_MP32ADDSQRTRC
# endif
# if defined(OPTIMIZE_SPARCV8PLUS) || defined(OPTIMIZE_SPARCV9)
# define ASM_MP32ADDW
diff --git a/beecrypt/mp32prime.c b/beecrypt/mp32prime.c
index c7955e748..ee1b9d6ad 100644
--- a/beecrypt/mp32prime.c
+++ b/beecrypt/mp32prime.c
@@ -1186,7 +1186,7 @@ int mp32pmilrab_w(const mp32barrett* p, randomGeneratorContext* rc, int t, uint3
(void) mp32subw(size, ndata, 1);
mp32copy(size, rdata, ndata);
- s = mp32divpowtwo(size, rdata); /* we've split p-1 into (2^s)*r */
+ s = mp32rshiftlsz(size, rdata); /* we've split p-1 into (2^s)*r */
/* should do an assert that s != 0 */
diff --git a/beecrypt/mtprng.c b/beecrypt/mtprng.c
index 6e4db6638..b46c14a3d 100644
--- a/beecrypt/mtprng.c
+++ b/beecrypt/mtprng.c
@@ -80,10 +80,10 @@ int mtprngSetup(mtprngParam* mp)
if (!(mp->lock = CreateMutex(NULL, FALSE, NULL)))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_init(&mp->lock, USYNC_THREAD, (void *) 0))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-nullpass@*/
/*@-moduncon@*/
if (pthread_mutex_init(&mp->lock, (pthread_mutexattr_t *) 0))
@@ -113,10 +113,10 @@ int mtprngSeed(mtprngParam* mp, const uint32* data, int size)
if (WaitForSingleObject(mp->lock, INFINITE) != WAIT_OBJECT_0)
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_lock(&mp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_lock(&mp->lock))
return -1;
@@ -136,10 +136,10 @@ int mtprngSeed(mtprngParam* mp, const uint32* data, int size)
if (!ReleaseMutex(mp->lock))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_unlock(&mp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_unlock(&mp->lock))
return -1;
@@ -163,10 +163,10 @@ int mtprngNext(mtprngParam* mp, uint32* data, int size)
if (WaitForSingleObject(mp->lock, INFINITE) != WAIT_OBJECT_0)
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_lock(&mp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_lock(&mp->lock))
return -1;
@@ -194,10 +194,10 @@ int mtprngNext(mtprngParam* mp, uint32* data, int size)
if (!ReleaseMutex(mp->lock))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_unlock(&mp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_unlock(&mp->lock))
return -1;
@@ -219,10 +219,10 @@ int mtprngCleanup(mtprngParam* mp)
if (!CloseHandle(mp->lock))
return -1;
# else
- # if defined(HAVE_SYNCH_H)
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
if (mutex_destroy(&mp->lock))
return -1;
- # elif defined(HAVE_PTHREAD_H)
+ # elif HAVE_PTHREAD_H
/*@-moduncon@*/
if (pthread_mutex_destroy(&mp->lock))
return -1;
diff --git a/beecrypt/mtprng.h b/beecrypt/mtprng.h
index 906b50510..eef49911d 100644
--- a/beecrypt/mtprng.h
+++ b/beecrypt/mtprng.h
@@ -34,7 +34,7 @@
# include <windows.h>
# include <winbase.h>
#else
-# if HAVE_SYNCH_H
+# if HAVE_THREAD_H && HAVE_SYNCH_H
# include <synch.h>
# elif HAVE_PTHREAD_H
# include <pthread.h>
@@ -55,7 +55,7 @@ typedef struct
# if WIN32
HANDLE lock;
# else
- # if HAVE_SYNCH_H
+ # if HAVE_THREAD_H && HAVE_SYNCH_H
mutex_t lock;
# elif HAVE_PTHREAD_H
pthread_mutex_t lock;
diff --git a/beecrypt/mwerks/Makefile.am b/beecrypt/mwerks/Makefile.am
index b1e006fab..be826af64 100644
--- a/beecrypt/mwerks/Makefile.am
+++ b/beecrypt/mwerks/Makefile.am
@@ -22,4 +22,4 @@
AUTOMAKE_OPTIONS = gnu no-dependencies
-EXTRA_DIST = beecrypt.pch blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm
+EXTRA_DIST = beecrypt.pch blowfishopt.i586.asm mp32opt.i386.asm sha1opt.i586.asm
diff --git a/beecrypt/mwerks/Makefile.in b/beecrypt/mwerks/Makefile.in
index 108aa771a..2ff4d6b9f 100644
--- a/beecrypt/mwerks/Makefile.in
+++ b/beecrypt/mwerks/Makefile.in
@@ -127,7 +127,7 @@ uint8_type = @uint8_type@
AUTOMAKE_OPTIONS = gnu no-dependencies
-EXTRA_DIST = beecrypt.pch blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm
+EXTRA_DIST = beecrypt.pch blowfishopt.i586.asm mp32opt.i386.asm sha1opt.i586.asm
subdir = mwerks
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
diff --git a/beecrypt/mwerks/fips180opt.i586.asm b/beecrypt/mwerks/sha1opt.i586.asm
index 61149b46e..d4d64a6f0 100644
--- a/beecrypt/mwerks/fips180opt.i586.asm
+++ b/beecrypt/mwerks/sha1opt.i586.asm
@@ -1,5 +1,5 @@
#
-# fips180opt.i586.asm
+# sha1opt.i586.asm
#
# Assembler optimized SHA-1 routines for Intel Pentium processors
#
diff --git a/beecrypt/rsa.c b/beecrypt/rsa.c
index 6628c6d3e..4766ce16f 100644
--- a/beecrypt/rsa.c
+++ b/beecrypt/rsa.c
@@ -47,60 +47,61 @@ int rsapri(const rsakp* kp, const mp32number* m, mp32number* c)
return -1;
}
-/*@-nullpass -nullptrarith @*/ /* temp may be NULL */
-/* this routine doesn't work yet: needs debugging! */
+
int rsapricrt(const rsakp* kp, const mp32number* m, mp32number* c)
{
register uint32 nsize = kp->n.size;
register uint32 psize = kp->p.size;
register uint32 qsize = kp->q.size;
- register uint32* temp = (uint32*) malloc((psize+qsize+(5*nsize+6))*sizeof(*temp));
- register uint32* wksp = temp+psize+qsize+nsize;
- /* compute j1 = m^d1 mod p */
- if (mp32gex(psize, kp->p.modl, m->size, m->data))
- {
- mp32setx(nsize, temp+psize+qsize, m->size, m->data);
- /*@-compdef@*/ /* LCL: temp+psize+qsize */
- mp32bmod_w(&kp->p, temp+psize+qsize, temp, wksp);
- /*@=compdef@*/
- }
- else
- mp32setx(psize, temp, m->size, m->data);
+ register uint32* ptemp;
+ register uint32* qtemp;
- mp32bpowmod_w(&kp->p, psize, temp, kp->d1.size, kp->d1.data, temp, wksp);
-
- /* compute j2 = m^d2 mod q */
- if (mp32gex(qsize, kp->q.modl, m->size, m->data))
+ ptemp = (uint32*) malloc((6*psize+2)*sizeof(uint32));
+ if (ptemp == (uint32*) 0)
+ return -1;
+
+ qtemp = (uint32*) malloc((6*qsize+2)*sizeof(uint32));
+ if (qtemp == (uint32*) 0)
{
- mp32setx(nsize, temp+psize+qsize, m->size, m->data);
- /*@-compdef@*/ /* LCL: temp+psize+qsize */
- mp32bmod_w(&kp->q, temp+psize+qsize, temp+psize, wksp);
- /*@=compdef@*/
+ free(ptemp);
+ return -1;
}
- else
- mp32setx(qsize, temp+psize, m->size, m->data);
- mp32bpowmod_w(&kp->q, qsize, temp+psize, kp->d2.size, kp->d2.data, temp+psize, wksp);
+ /* m must be small enough to be exponentiated modulo p and q */
+ if (m->size > psize || m->size > qsize)
+ return -1;
+
+ /* resize m for powmod p */
+ mp32setx(psize, ptemp+psize, m->size, m->data);
- /* compute j1-j2 */
- (void) mp32subx(psize, temp, qsize, temp+psize);
+ /* compute j1 = m^d1 mod p, store @ ptemp */
+ mp32bpowmod_w(&kp->p, psize, ptemp+psize, kp->d1.size, kp->d1.data, ptemp, ptemp+2*psize);
- /* compute h = c*(j1-j2) mod p */
- mp32bmulmod_w(&kp->p, psize, temp, psize, kp->c.data, temp, wksp);
+ /* resize m for powmod p */
+ mp32setx(qsize, qtemp+psize, m->size, m->data);
+
+ /* compute j2 = m^d2 mod q, store @ qtemp */
+ mp32bpowmod_w(&kp->q, qsize, qtemp+psize, kp->d2.size, kp->d2.data, qtemp, qtemp+2*qsize);
+
+ /* compute j1-j2 mod p, store @ ptemp */
+ mp32bsubmod_w(&kp->p, psize, ptemp, qsize, qtemp, ptemp, ptemp+2*psize);
+
+ /* compute h = c*(j1-j2) mod p, store @ ptemp */
+ mp32bmulmod_w(&kp->p, psize, ptemp, psize, kp->c.data, ptemp, ptemp+2*psize);
/* make sure the signature gets the proper size */
mp32nsize(c, nsize);
/* compute s = h*q + j2 */
- mp32mul(c->data, psize, temp, qsize, kp->q.modl);
- (void) mp32addx(nsize, c->data, qsize, temp+psize);
+ mp32mul(c->data, psize, ptemp, qsize, kp->q.modl);
+ mp32addx(nsize, c->data, qsize, qtemp);
- free(temp);
+ free(ptemp);
+ free(qtemp);
- return -1;
+ return 0;
}
-/*@=nullpass =nullptrarith @*/
/**
* @return 1 if signature verifies, 0 otherwise (can also indicate errors)
diff --git a/beecrypt/fips180.c b/beecrypt/sha1.c
index 1ded34d64..2aff03427 100644
--- a/beecrypt/fips180.c
+++ b/beecrypt/sha1.c
@@ -1,5 +1,5 @@
/** \ingroup HASH_sha1_m HASH_m
- * \file fips180.c
+ * \file sha1.c
*
* SHA-1 hash function, code.
*
@@ -29,7 +29,7 @@
*/
#include "system.h"
-#include "fips180.h"
+#include "sha1.h"
#include "mp32.h"
#include "endianness.h"
#include "debug.h"
diff --git a/beecrypt/fips180.h b/beecrypt/sha1.h
index 72a9db775..0d554fc3d 100644
--- a/beecrypt/fips180.h
+++ b/beecrypt/sha1.h
@@ -1,5 +1,5 @@
/** \ingroup HASH_sha1_m HASH_m
- * \file fips180.h
+ * \file sha1.h
*
* SHA-1 hash function, header.
*/
@@ -25,11 +25,11 @@
*
*/
-#ifndef _FIPS180_H
-#define _FIPS180_H
+#ifndef _SHA1_H
+#define _SHA1_H
#include "beecrypt.h"
-#include "fips180opt.h"
+#include "sha1opt.h"
/** \ingroup HASH_sha1_m
*/
diff --git a/beecrypt/fips180opt.h b/beecrypt/sha1opt.h
index ff955701a..96a9954a8 100644
--- a/beecrypt/fips180opt.h
+++ b/beecrypt/sha1opt.h
@@ -1,5 +1,5 @@
/** \ingroup HASH_sha1_m HASH_m
- * \file fips180opt.h
+ * \file sha1opt.h
*
* SHA-1 assembler-optimized routines, header.
*/
@@ -25,11 +25,11 @@
*
*/
-#ifndef _FIPS180OPT_H
-#define _FIPS180OPT_H
+#ifndef _SHA1OPT_H
+#define _SHA1OPT_H
#include "beecrypt.h"
-#include "fips180.h"
+#include "sha1.h"
#ifdef __cplusplus
extern "C" {
diff --git a/beecrypt/system.h b/beecrypt/system.h
index 58426c180..c17753e74 100644
--- a/beecrypt/system.h
+++ b/beecrypt/system.h
@@ -43,6 +43,10 @@
# endif
#endif
+#if HAVE_TIME_H
+# include <time.h>
+#endif
+
#ifdef HAVE_STRING_H
# include <string.h>
#endif
diff --git a/beecrypt/tests/.cvsignore b/beecrypt/tests/.cvsignore
index ff2327bd5..5b9e531d4 100644
--- a/beecrypt/tests/.cvsignore
+++ b/beecrypt/tests/.cvsignore
@@ -20,3 +20,10 @@ stamp-h.in
beetest
base64bug
openpgp
+testdldp
+testdsa
+testhmacmd5
+testhmacsha1
+testmd5
+testsha1
+testsha256
diff --git a/beecrypt/tests/Makefile.am b/beecrypt/tests/Makefile.am
index 7acdbd18f..f9c8732e4 100644
--- a/beecrypt/tests/Makefile.am
+++ b/beecrypt/tests/Makefile.am
@@ -1,7 +1,7 @@
#
-# Makefile.am's purpose is to build the beetest test program.
+# Makefile.am's purpose is to build the beetest_ test_ program.
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -25,9 +25,24 @@ AUTOMAKE_OPTIONS = gnu no-dependencies
INCLUDES = -I$(top_srcdir)
LDADD = $(top_builddir)/libbeecrypt.la
-EXTRA_PROGRAMS = beetest openpgp
+TESTS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testdldp testdsa
+
+check_PROGRAMS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testdldp testdsa
+
+testmd5_SOURCES = testmd5.c
+
+testsha1_SOURCES = testsha1.c
+
+testsha256_SOURCES = testsha256.c
+
+testhmacmd5_SOURCES = testhmacmd5.c
+
+testhmacsha1_SOURCES = testhmacsha1.c
+
+testdldp_SOURCES = testdldp.c
+
+testdsa_SOURCES = testdsa.c
+
+EXTRA_PROGRAMS = beetest
beetest_SOURCES = beetest.c
-beetest_LDFLAGS = -all-static
-
-openpgp_SOURCES = openpgp.c
diff --git a/beecrypt/tests/Makefile.in b/beecrypt/tests/Makefile.in
index 25b645b9b..d2bcde2a7 100644
--- a/beecrypt/tests/Makefile.in
+++ b/beecrypt/tests/Makefile.in
@@ -15,9 +15,9 @@
@SET_MAKE@
#
-# Makefile.am's purpose is to build the beetest test program.
+# Makefile.am's purpose is to build the beetest_ test_ program.
#
-# Copyright (c) 2001 Virtual Unlimited B.V.
+# Copyright (c) 2001, 2002 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
@@ -130,26 +130,75 @@ AUTOMAKE_OPTIONS = gnu no-dependencies
INCLUDES = -I$(top_srcdir)
LDADD = $(top_builddir)/libbeecrypt.la
-EXTRA_PROGRAMS = beetest openpgp
+TESTS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testdldp testdsa
-beetest_SOURCES = beetest.c
-beetest_LDFLAGS = -all-static
+check_PROGRAMS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testdldp testdsa
+
+testmd5_SOURCES = testmd5.c
+
+testsha1_SOURCES = testsha1.c
+
+testsha256_SOURCES = testsha256.c
+
+testhmacmd5_SOURCES = testhmacmd5.c
+
+testhmacsha1_SOURCES = testhmacsha1.c
+
+testdldp_SOURCES = testdldp.c
+
+testdsa_SOURCES = testdsa.c
+
+EXTRA_PROGRAMS = beetest
-openpgp_SOURCES = openpgp.c
+beetest_SOURCES = beetest.c
subdir = tests
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
-EXTRA_PROGRAMS = beetest$(EXEEXT) openpgp$(EXEEXT)
+EXTRA_PROGRAMS = beetest$(EXEEXT)
+check_PROGRAMS = testmd5$(EXEEXT) testsha1$(EXEEXT) testsha256$(EXEEXT) \
+ testhmacmd5$(EXEEXT) testhmacsha1$(EXEEXT) testdldp$(EXEEXT) \
+ testdsa$(EXEEXT)
am_beetest_OBJECTS = beetest.$(OBJEXT)
beetest_OBJECTS = $(am_beetest_OBJECTS)
beetest_LDADD = $(LDADD)
beetest_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
-am_openpgp_OBJECTS = openpgp.$(OBJEXT)
-openpgp_OBJECTS = $(am_openpgp_OBJECTS)
-openpgp_LDADD = $(LDADD)
-openpgp_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
-openpgp_LDFLAGS =
+beetest_LDFLAGS =
+am_testdldp_OBJECTS = testdldp.$(OBJEXT)
+testdldp_OBJECTS = $(am_testdldp_OBJECTS)
+testdldp_LDADD = $(LDADD)
+testdldp_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
+testdldp_LDFLAGS =
+am_testdsa_OBJECTS = testdsa.$(OBJEXT)
+testdsa_OBJECTS = $(am_testdsa_OBJECTS)
+testdsa_LDADD = $(LDADD)
+testdsa_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
+testdsa_LDFLAGS =
+am_testhmacmd5_OBJECTS = testhmacmd5.$(OBJEXT)
+testhmacmd5_OBJECTS = $(am_testhmacmd5_OBJECTS)
+testhmacmd5_LDADD = $(LDADD)
+testhmacmd5_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
+testhmacmd5_LDFLAGS =
+am_testhmacsha1_OBJECTS = testhmacsha1.$(OBJEXT)
+testhmacsha1_OBJECTS = $(am_testhmacsha1_OBJECTS)
+testhmacsha1_LDADD = $(LDADD)
+testhmacsha1_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
+testhmacsha1_LDFLAGS =
+am_testmd5_OBJECTS = testmd5.$(OBJEXT)
+testmd5_OBJECTS = $(am_testmd5_OBJECTS)
+testmd5_LDADD = $(LDADD)
+testmd5_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
+testmd5_LDFLAGS =
+am_testsha1_OBJECTS = testsha1.$(OBJEXT)
+testsha1_OBJECTS = $(am_testsha1_OBJECTS)
+testsha1_LDADD = $(LDADD)
+testsha1_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
+testsha1_LDFLAGS =
+am_testsha256_OBJECTS = testsha256.$(OBJEXT)
+testsha256_OBJECTS = $(am_testsha256_OBJECTS)
+testsha256_LDADD = $(LDADD)
+testsha256_DEPENDENCIES = $(top_builddir)/libbeecrypt.la
+testsha256_LDFLAGS =
DEFS = @DEFS@
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -166,9 +215,11 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
-DIST_SOURCES = $(beetest_SOURCES) $(openpgp_SOURCES)
+DIST_SOURCES = $(beetest_SOURCES) $(testdldp_SOURCES) $(testdsa_SOURCES) \
+ $(testhmacmd5_SOURCES) $(testhmacsha1_SOURCES) \
+ $(testmd5_SOURCES) $(testsha1_SOURCES) $(testsha256_SOURCES)
DIST_COMMON = Makefile.am Makefile.in
-SOURCES = $(beetest_SOURCES) $(openpgp_SOURCES)
+SOURCES = $(beetest_SOURCES) $(testdldp_SOURCES) $(testdsa_SOURCES) $(testhmacmd5_SOURCES) $(testhmacsha1_SOURCES) $(testmd5_SOURCES) $(testsha1_SOURCES) $(testsha256_SOURCES)
all: all-am
@@ -179,12 +230,33 @@ $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
$(AUTOMAKE) --gnu tests/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+
+clean-checkPROGRAMS:
+ -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
beetest$(EXEEXT): $(beetest_OBJECTS) $(beetest_DEPENDENCIES)
@rm -f beetest$(EXEEXT)
$(LINK) $(beetest_LDFLAGS) $(beetest_OBJECTS) $(beetest_LDADD) $(LIBS)
-openpgp$(EXEEXT): $(openpgp_OBJECTS) $(openpgp_DEPENDENCIES)
- @rm -f openpgp$(EXEEXT)
- $(LINK) $(openpgp_LDFLAGS) $(openpgp_OBJECTS) $(openpgp_LDADD) $(LIBS)
+testdldp$(EXEEXT): $(testdldp_OBJECTS) $(testdldp_DEPENDENCIES)
+ @rm -f testdldp$(EXEEXT)
+ $(LINK) $(testdldp_LDFLAGS) $(testdldp_OBJECTS) $(testdldp_LDADD) $(LIBS)
+testdsa$(EXEEXT): $(testdsa_OBJECTS) $(testdsa_DEPENDENCIES)
+ @rm -f testdsa$(EXEEXT)
+ $(LINK) $(testdsa_LDFLAGS) $(testdsa_OBJECTS) $(testdsa_LDADD) $(LIBS)
+testhmacmd5$(EXEEXT): $(testhmacmd5_OBJECTS) $(testhmacmd5_DEPENDENCIES)
+ @rm -f testhmacmd5$(EXEEXT)
+ $(LINK) $(testhmacmd5_LDFLAGS) $(testhmacmd5_OBJECTS) $(testhmacmd5_LDADD) $(LIBS)
+testhmacsha1$(EXEEXT): $(testhmacsha1_OBJECTS) $(testhmacsha1_DEPENDENCIES)
+ @rm -f testhmacsha1$(EXEEXT)
+ $(LINK) $(testhmacsha1_LDFLAGS) $(testhmacsha1_OBJECTS) $(testhmacsha1_LDADD) $(LIBS)
+testmd5$(EXEEXT): $(testmd5_OBJECTS) $(testmd5_DEPENDENCIES)
+ @rm -f testmd5$(EXEEXT)
+ $(LINK) $(testmd5_LDFLAGS) $(testmd5_OBJECTS) $(testmd5_LDADD) $(LIBS)
+testsha1$(EXEEXT): $(testsha1_OBJECTS) $(testsha1_DEPENDENCIES)
+ @rm -f testsha1$(EXEEXT)
+ $(LINK) $(testsha1_LDFLAGS) $(testsha1_OBJECTS) $(testsha1_LDADD) $(LIBS)
+testsha256$(EXEEXT): $(testsha256_OBJECTS) $(testsha256_DEPENDENCIES)
+ @rm -f testsha256$(EXEEXT)
+ $(LINK) $(testsha256_LDFLAGS) $(testsha256_OBJECTS) $(testsha256_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT) core *.core
@@ -246,6 +318,61 @@ GTAGS:
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list='$(TESTS)'; \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *" $$tst "*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ echo "XPASS: $$tst"; \
+ ;; \
+ *) \
+ echo "PASS: $$tst"; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *" $$tst "*) \
+ xfail=`expr $$xfail + 1`; \
+ echo "XFAIL: $$tst"; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ ;; \
+ esac; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all tests failed"; \
+ else \
+ banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+ fi; \
+ fi; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0; \
+ else :; fi
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
@@ -273,6 +400,8 @@ distdir: $(DISTFILES)
fi; \
done
check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile
@@ -304,7 +433,7 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
@@ -340,16 +469,16 @@ mostlyclean-am: mostlyclean-compile mostlyclean-generic \
uninstall-am: uninstall-info-am
-.PHONY: GTAGS all all-am check check-am clean clean-generic \
- clean-libtool distclean distclean-compile distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am info \
- info-am install install-am install-data install-data-am \
- install-exec install-exec-am install-info install-info-am \
- install-man install-strip installcheck installcheck-am \
- installdirs maintainer-clean maintainer-clean-generic \
- mostlyclean mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool tags uninstall uninstall-am \
- uninstall-info-am
+.PHONY: GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libtool distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am info info-am install \
+ install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ tags uninstall uninstall-am uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/beecrypt/tests/beetest.c b/beecrypt/tests/beetest.c
index 56b03546a..ad4172b95 100644
--- a/beecrypt/tests/beetest.c
+++ b/beecrypt/tests/beetest.c
@@ -3,7 +3,7 @@
*
* BeeCrypt test and benchmark application
*
- * Copyright (c) 1999, 2000, 2001 Virtual Unlimited B.V.
+ * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
@@ -23,35 +23,25 @@
*
*/
+#include "system.h"
+
#include "beecrypt.h"
#include "blockmode.h"
+#include "aes.h"
#include "blowfish.h"
#include "mp32barrett.h"
#include "dhaes.h"
#include "dlkp.h"
#include "dsa.h"
#include "elgamal.h"
-#include "fips180.h"
#include "hmacmd5.h"
#include "md5.h"
#include "rsa.h"
+#include "sha1.h"
#include "sha256.h"
#include "mp32.h"
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-#if HAVE_ERRNO_H
-# include <errno.h>
-#endif
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#include <stdio.h>
+#include "debug.h"
/*@unused@*/ /*@observer@*/
static const char* dsa_p = "8df2a494492276aa3d25759bb06869cbeac0d83afb8d0cf7cbb8324f0d7882e5d0762fc5b7210eafc2e9adac32ab7aac49693dfbf83724c2ec0736ee31c80291";
@@ -682,7 +672,7 @@ static void testExpMods(void)
#endif
fprintf(stdout, "Timing modular exponentiations\n");
- fprintf(stdout, " (512 bits ^ 512 bits) mod 512 bits:");
+ fprintf(stdout, " (%4d bits ^ %4d bits) mod %4d bits:", 512, 512, 512);
mp32nsethex(&tmp, p_512);
mp32bset(&p, tmp.size, tmp.data);
mp32nsize(&g, p.size);
@@ -699,7 +689,7 @@ static void testExpMods(void)
ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC;
fprintf(stdout, " 100x in %.3f seconds\n", ttime);
#endif
- fprintf(stdout, " (768 bits ^ 768 bits) mod 768 bits:");
+ fprintf(stdout, " (%4d bits ^ %4d bits) mod %4d bits:", 768, 768, 768);
mp32nsethex(&tmp, p_768);
mp32bset(&p, tmp.size, tmp.data);
mp32nsize(&g, p.size);
@@ -716,7 +706,7 @@ static void testExpMods(void)
ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC;
fprintf(stdout, " 100x in %.3f seconds\n", ttime);
#endif
- fprintf(stdout, " (1024 bits ^ 1024 bits) mod 1024 bits:");
+ fprintf(stdout, " (%4d bits ^ %4d bits) mod %4d bits:", 1024, 1024, 1024);
mp32nsethex(&tmp, p_1024);
mp32bset(&p, tmp.size, tmp.data);
mp32nsize(&g, p.size);
@@ -738,7 +728,7 @@ static void testExpMods(void)
/*@-noeffectuncon@*/ /* LCL: ??? */
(void) rngc.rng->next(rngc.param, x.data, x.size);
/*@=noeffectuncon@*/
- fprintf(stdout, " (1024 bits ^ 160 bits) mod 1024 bits:");
+ fprintf(stdout, " (%4d bits ^ %4d bits) mod %4d bits:", 1024, 160, 1024);
#if HAVE_TIME_H
tstart = clock();
#endif
@@ -763,6 +753,83 @@ static void testExpMods(void)
fprintf(stdout, "random generator setup problem\n");
}
+#ifdef NOTYET
+static void testRSA(void)
+ /*@globals fileSystem, internalState */
+ /*@modifies fileSystem, internalState */
+{
+ randomGeneratorContext rngc;
+ mp32number hm, s;
+ rsakp kp;
+
+ memset(&rngc, 0, sizeof(randomGeneratorContext));
+ mp32nzero(&hm);
+ mp32nzero(&s);
+
+ fprintf(stdout, "Timing RSA:\n");
+
+ rsakpInit(&kp);
+
+ /*@-nullpass -modobserver @*/
+ if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
+ /*@=nullpass =modobserver @*/
+ {
+ int i;
+
+ #if HAVE_TIME_H
+ double ttime;
+ clock_t tstart, tstop;
+ #endif
+
+ fprintf(stdout, " generating 1024 bit crt keypair\n");
+
+ #if HAVE_TIME_H
+ tstart = clock();
+ #endif
+ rsakpMake(&kp, &rngc, (1024 >> 5));
+ #if HAVE_TIME_H
+ tstop = clock();
+ ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC;
+ fprintf(stdout, " done in %.3f seconds\n", ttime);
+ #endif
+
+ mp32nsize(&hm, 4);
+ rngc.rng->next(rngc.param, hm.data, hm.size);
+
+ fprintf(stdout, " RSA sign:");
+ #if HAVE_TIME_H
+ tstart = clock();
+ #endif
+ for (i = 0; i < 100; i++)
+ {
+ rsapricrt(&kp, &hm, &s);
+ }
+ #if HAVE_TIME_H
+ tstop = clock();
+ ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC;
+ fprintf(stdout, " 100x in %.3f seconds\n", ttime);
+ #endif
+
+ fprintf(stdout, " RSA verify:");
+ #if HAVE_TIME_H
+ tstart = clock();
+ #endif
+ for (i = 0; i < 1000; i++)
+ {
+ rsavrfy((rsapk*) &kp, &hm, &s);
+ }
+ #if HAVE_TIME_H
+ tstop = clock();
+ ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC;
+ fprintf(stdout, " 1000x in %.3f seconds\n", ttime);
+ #endif
+
+ rsakpFree(&kp);
+ randomGeneratorContextFree(&rngc);
+ }
+}
+#endif /* NOTYET */
+
static void testDLAlgorithms(void)
/*@globals fileSystem, internalState */
/*@modifies fileSystem, internalState */
@@ -783,6 +850,8 @@ static void testDLAlgorithms(void)
(void) dldp_pInit(&dp);
(void) dlkp_pInit(&kp);
+ fprintf(stdout, "Timing Discrete Logarithm algorithms:\n");
+
/*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
/*@=nullpass =modobserver @*/
@@ -972,7 +1041,7 @@ int main(/*@unused@*/int argc, /*@unused@*/char *argv[])
fprintf(stdout, " %d random generator%s:\n", randomGeneratorCount(), randomGeneratorCount() == 1 ? "" : "s");
for (i = 0; i < randomGeneratorCount(); i++)
{
- const randomGenerator* tmp = randomGeneratorGet(i);
+ const randomGenerator* tmp = randomGeneratorGet(i);
if (tmp)
fprintf(stdout, " %s\n", tmp->name);
else
@@ -1019,6 +1088,9 @@ int main(/*@unused@*/int argc, /*@unused@*/char *argv[])
testBlockCiphers();
testHashFunctions();
testExpMods();
+#ifdef NOTYET
+ testRSA();
+#endif
testDLAlgorithms();
/*@=modnomods@*/
diff --git a/beecrypt/tests/testdldp.c b/beecrypt/tests/testdldp.c
new file mode 100644
index 000000000..72848ffce
--- /dev/null
+++ b/beecrypt/tests/testdldp.c
@@ -0,0 +1,66 @@
+/*
+ * testdldp.c
+ *
+ * Unit test program for discrete logarithm domain parameters (over a prime field),
+ * as specified by IEEE P.1363.
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "beecrypt.h"
+#include "dldp.h"
+
+int main()
+{
+ int failures = 0;
+
+ dldp_p params;
+ randomGeneratorContext rngc;
+
+ memset(&params, 0, sizeof(dldp_p));
+ memset(&rngc, 0, sizeof(rngc));
+
+ if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
+ {
+ mp32number gq;
+
+ mp32nzero(&gq);
+
+ /* make parameters with p = 512 bits, q = 160 bits, g of order (q) */
+ dldp_pgoqMake(&params, &rngc, 512 >> 5, 160 >> 5, 1);
+
+ /* we have the parameters, now see if g^q == 1 */
+ mp32bnpowmod(&params.p, &params.g, (mp32number*) &params.q, &gq);
+ if (mp32isone(gq.size, gq.data))
+ printf("ok\n");
+ else
+ failures++;
+
+ mp32nfree(&gq);
+
+ dldp_pFree(&params);
+
+ randomGeneratorContextFree(&rngc);
+ }
+ else
+ return -1;
+
+ return failures;
+}
diff --git a/beecrypt/tests/testdsa.c b/beecrypt/tests/testdsa.c
new file mode 100644
index 000000000..319ea64c4
--- /dev/null
+++ b/beecrypt/tests/testdsa.c
@@ -0,0 +1,144 @@
+/*
+ * testdsa.c
+ *
+ * Unit test program for DSA.
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "beecrypt.h"
+#include "dlkp.h"
+#include "dsa.h"
+
+static const char* dsa_p = "8df2a494492276aa3d25759bb06869cbeac0d83afb8d0cf7cbb8324f0d7882e5d0762fc5b7210eafc2e9adac32ab7aac49693dfbf83724c2ec0736ee31c80291";
+static const char* dsa_q = "c773218c737ec8ee993b4f2ded30f48edace915f";
+static const char* dsa_g = "626d027839ea0a13413163a55b4cb500299d5522956cefcb3bff10f399ce2c2e71cb9de5fa24babf58e5b79521925c9cc42e9f6f464b088cc572af53e6d78802";
+static const char* dsa_x = "2070b3223dba372fde1c0ffc7b2e3b498b260614";
+static const char* dsa_y = "19131871d75b1612a819f29d78d1b0d7346f7aa77bb62a859bfd6c5675da9d212d3a36ef1672ef660b8c7c255cc0ec74858fba33f44c06699630a76b030ee333";
+
+static const char* dsa_k = "358dad571462710f50e254cf1a376b2bdeaadfbf";
+
+static const char* dsa_hm = "a9993e364706816aba3e25717850c26c9cd0d89d";
+
+static const uint32 expect_r[5] = { 0x8bac1ab6, 0x6410435c, 0xb7181f95, 0xb16ab97c, 0x92b341c0 };
+static const uint32 expect_s[5] = { 0x41e2345f, 0x1f56df24, 0x58f426d1, 0x55b4ba2d, 0xb6dcd8c8 };
+
+/* we need to fake a random generator to pass k into the signing algorithm */
+
+int fake_setup(randomGeneratorParam* p)
+{
+ return 0;
+}
+
+int fake_seed(randomGeneratorParam* p, const uint32* data, int size)
+{
+ return 0;
+}
+
+int fake_next(randomGeneratorParam* p, uint32* data, int size)
+{
+ mp32number tmp;
+
+ mp32nzero(&tmp);
+ mp32nsethex(&tmp, dsa_k);
+
+ mp32setx(size, data, tmp.size, tmp.data);
+
+ mp32nfree(&tmp);
+
+ return 0;
+}
+
+int fake_cleanup(randomGeneratorParam* p)
+{
+ return 0;
+}
+
+const randomGenerator fakeprng = { "fake", 4, fake_setup, fake_seed, fake_next, fake_cleanup };
+
+int main()
+{
+ int failures = 0;
+
+ dlkp_p keypair;
+ mp32number hm, r, s;
+ randomGeneratorContext rngc;
+
+ memset(&rngc, 0, sizeof(rngc));
+
+ dlkp_pInit(&keypair);
+
+ mp32bsethex(&keypair.param.p, dsa_p);
+ mp32bsethex(&keypair.param.q, dsa_q);
+ mp32nsethex(&keypair.param.g, dsa_g);
+ mp32nsethex(&keypair.y, dsa_y);
+ mp32nsethex(&keypair.x, dsa_x);
+
+ mp32nzero(&hm);
+ mp32nsethex(&hm, dsa_hm);
+
+ /* first test, from NIST FIPS 186-1 */
+ mp32nzero(&r);
+ mp32nzero(&s);
+
+ if (randomGeneratorContextInit(&rngc, &fakeprng))
+ return -1;
+
+ if (dsasign(&keypair.param.p, &keypair.param.q, &keypair.param.g, &rngc, &hm, &keypair.x, &r, &s))
+ return -1;
+
+ if (mp32eqx(5, expect_r, r.size, r.data) && mp32eqx(5, expect_s, s.size, s.data))
+ printf("ok\n");
+ else
+ failures++;
+
+ if (randomGeneratorContextFree(&rngc))
+ return -1;
+
+ mp32nfree(&s);
+ mp32nfree(&r);
+
+ /* second test, sign a hash and verify the signature */
+ mp32nzero(&s);
+ mp32nzero(&r);
+
+ if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()))
+ return -1;
+
+ if (dsasign(&keypair.param.p, &keypair.param.q, &keypair.param.g, &rngc, &hm, &keypair.x, &r, &s))
+ return -1;
+
+ if (dsavrfy(&keypair.param.p, &keypair.param.q, &keypair.param.g, &hm, &keypair.y, &r, &s))
+ printf("ok\n");
+ else
+ failures++;
+
+ if (randomGeneratorContextFree(&rngc))
+ return -1;
+
+ mp32nfree(&s);
+ mp32nfree(&r);
+
+ mp32nfree(&hm);
+
+ dlkp_pFree(&keypair);
+
+ return failures;
+}
diff --git a/beecrypt/tests/testhmacmd5.c b/beecrypt/tests/testhmacmd5.c
new file mode 100644
index 000000000..2ea7b6e5c
--- /dev/null
+++ b/beecrypt/tests/testhmacmd5.c
@@ -0,0 +1,83 @@
+/*
+ * testhmacmd5.c
+ *
+ * Unit test program for HMAC-MD5; it tests all vectors specified by RFC 2202.
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "hmacmd5.h"
+
+struct key_input_expect
+{
+ unsigned char* key;
+ unsigned char* input;
+ uint32 expect[4];
+};
+
+struct key_input_expect table[7] =
+{
+ { "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", "Hi There",
+ { 0x9294727a, 0x3638bb1c, 0x13f48ef8, 0x158bfc9d } },
+ { "Jefe", "what do ya want for nothing?",
+ { 0x750c783e, 0x6ab0b503, 0xeaa86e31, 0x0a5db738 } },
+ { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ { 0x56be3452, 0x1d144c88, 0xdbb8c733, 0xf0e8b3f6 } },
+ { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ { 0x697eaf0a, 0xca3a3aea, 0x3a751647, 0x46ffaa79 } },
+ { "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", "Test With Truncation",
+ { 0x56461ef2, 0x342edc00, 0xf9bab995, 0x690efd4c } },
+ { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "Test Using Larger Than Block-Size Key - Hash Key First",
+ { 0x6b1ab7fe, 0x4bd7bf8f, 0x0b62e6ce, 0x61b9d0cd } },
+ { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
+ { 0x6f630fad, 0x67cda0ee, 0x1fb1f562, 0xdb3aa53e} }
+};
+
+int main()
+{
+ int i, failures = 0;
+ hmacmd5Param param;
+ uint32 digest[4];
+ uint32 key[64];
+
+ for (i = 0; i < 7; i++)
+ {
+ /* set the key up properly, removing endian-ness */
+ decodeIntsPartial(key, table[i].key, strlen(table[i].key));
+
+ if (hmacmd5Setup(&param, key, strlen(table[i].key) << 3))
+ return -1;
+
+ if (hmacmd5Update(&param, table[i].input, strlen(table[i].input)))
+ return -1;
+ if (hmacmd5Digest(&param, digest))
+ return -1;
+
+ if (mp32ne(4, digest, table[i].expect))
+ {
+ printf("failed\n");
+ failures++;
+ }
+ else
+ printf("ok\n");
+ }
+
+ return failures;
+}
diff --git a/beecrypt/tests/testhmacsha1.c b/beecrypt/tests/testhmacsha1.c
new file mode 100644
index 000000000..49b987344
--- /dev/null
+++ b/beecrypt/tests/testhmacsha1.c
@@ -0,0 +1,84 @@
+/*
+ * testhmacsha1.c
+ *
+ * Unit test program for HMAC-SHA1; it tests all vectors specified by RFC 2202.
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "hmacsha1.h"
+
+struct key_input_expect
+{
+ unsigned char* key;
+ unsigned char* input;
+ uint32 expect[5];
+};
+
+struct key_input_expect table[7] =
+{
+ { "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", "Hi There",
+ { 0xb6173186, 0x55057264, 0xe28bc0b6, 0xfb378c8e, 0xf146be00 } },
+ { "Jefe", "what do ya want for nothing?",
+ { 0xeffcdf6a, 0xe5eb2fa2, 0xd27416d5, 0xf184df9c, 0x259a7c79 } },
+ { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ { 0x125d7342, 0xb9ac11cd, 0x91a39af4, 0x8aa17b4f, 0x63f175d3 } },
+ { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ { 0x4c9007f4, 0x026250c6, 0xbc8414f9, 0xbf50c86c, 0x2d7235da } },
+ { "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", "Test With Truncation",
+ { 0x4c1a0342, 0x4b55e07f, 0xe7f27be1, 0xd58bb932, 0x4a9a5a04 } },
+ { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "Test Using Larger Than Block-Size Key - Hash Key First",
+ { 0xaa4ae5e1, 0x5272d00e, 0x95705637, 0xce8a3b55, 0xed402112 } },
+ { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
+ { 0xe8e99d0f, 0x45237d78, 0x6d6bbaa7, 0x965c7808, 0xbbff1a91 } }
+};
+
+int main()
+{
+ int i, failures = 0;
+ uint32 digest[5];
+ uint32 key[64];
+ hmacsha1Param param;
+
+ for (i = 0; i < 7; i++)
+ {
+ /* set the key up properly, removing endian-ness */
+ decodeIntsPartial(key, table[i].key, strlen(table[i].key));
+
+ if (hmacsha1Setup(&param, key, strlen(table[i].key) << 3))
+ return -1;
+ if (hmacsha1Update(&param, table[i].input, strlen(table[i].input)))
+ return -1;
+ if (hmacsha1Digest(&param, digest))
+ return -1;
+
+ if (mp32ne(5, digest, table[i].expect))
+ {
+ printf("failed\n");
+ mp32println(5, table[i].expect);
+ mp32println(5, digest);
+ failures++;
+ }
+ else
+ printf("ok\n");
+ }
+
+ return failures;
+}
diff --git a/beecrypt/tests/testmd5.c b/beecrypt/tests/testmd5.c
new file mode 100644
index 000000000..5cb1fa64e
--- /dev/null
+++ b/beecrypt/tests/testmd5.c
@@ -0,0 +1,76 @@
+/*
+ * testmd5.c
+ *
+ * Unit test program for MD5; it tests all vectors specified by RFC 1321.
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "md5.h"
+
+struct input_expect
+{
+ unsigned char* input;
+ uint32 expect[4];
+};
+
+
+struct input_expect table[7] = {
+ { "",
+ { 0xd41d8cd9, 0x8f00b204, 0xe9800998, 0xecf8427e } },
+ { "a",
+ { 0x0cc175b9, 0xc0f1b6a8, 0x31c399e2, 0x69772661 } },
+ { "abc",
+ { 0x90015098, 0x3cd24fb0, 0xd6963f7d, 0x28e17f72 } },
+ { "message digest",
+ { 0xf96b697d, 0x7cb7938d, 0x525a2f31, 0xaaf161d0 } },
+ { "abcdefghijklmnopqrstuvwxyz",
+ { 0xc3fcd3d7, 0x6192e400, 0x7dfb496c, 0xca67e13b } },
+ { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ { 0xd174ab98, 0xd277d9f5, 0xa5611c2c, 0x9f419d9f } },
+ { "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ { 0x57edf4a2, 0x2be3c955, 0xac49da2e, 0x2107b67a } }
+};
+
+int main()
+{
+ int i, failures = 0;
+ md5Param param;
+ uint32 digest[4];
+
+ for (i = 0; i < 7; i++)
+ {
+ if (md5Reset(&param))
+ return -1;
+ if (md5Update(&param, table[i].input, strlen(table[i].input)))
+ return -1;
+ if (md5Digest(&param, digest))
+ return -1;
+
+ if (mp32ne(4, digest, table[i].expect))
+ {
+ printf("failed\n");
+ failures++;
+ }
+ else
+ printf("ok\n");
+ }
+ return failures;
+}
diff --git a/beecrypt/tests/testsha1.c b/beecrypt/tests/testsha1.c
new file mode 100644
index 000000000..83c8b1fc9
--- /dev/null
+++ b/beecrypt/tests/testsha1.c
@@ -0,0 +1,66 @@
+/*
+ * testsha1.c
+ *
+ * Unit test program for SHA-1; it tests all but one of vectors specified by FIPS PUB 180-1.
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "sha1.h"
+
+struct input_expect
+{
+ unsigned char* input;
+ uint32 expect[5];
+};
+
+
+struct input_expect table[2] = {
+ { "abc",
+ { 0xA9993E36, 0x4706816A, 0xBA3E2571, 0x7850C26C, 0x9CD0D89D } },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ { 0x84983E44, 0x1C3BD26E, 0xBAAE4AA1, 0xF95129E5, 0xE54670F1 } }
+};
+
+int main()
+{
+ int i, failures = 0;
+ sha1Param param;
+ uint32 digest[5];
+
+ for (i = 0; i < 2; i++)
+ {
+ if (sha1Reset(&param))
+ return -1;
+ if (sha1Update(&param, table[i].input, strlen(table[i].input)))
+ return -1;
+ if (sha1Digest(&param, digest))
+ return -1;
+
+ if (mp32ne(5, digest, table[i].expect))
+ {
+ printf("failed\n");
+ failures++;
+ }
+ else
+ printf("ok\n");
+ }
+ return failures;
+}
diff --git a/beecrypt/tests/testsha256.c b/beecrypt/tests/testsha256.c
new file mode 100644
index 000000000..4ec0917ca
--- /dev/null
+++ b/beecrypt/tests/testsha256.c
@@ -0,0 +1,66 @@
+/*
+ * testsha256.c
+ *
+ * Unit test program for SHA-256; it implements the test vectors from the draft FIPS document.
+ *
+ * Copyright (c) 2002 Bob Deblier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "sha256.h"
+
+struct input_expect
+{
+ unsigned char* input;
+ uint32 expect[8];
+};
+
+
+struct input_expect table[2] = {
+ { "abc",
+ { 0xba7816bf, 0x8f01cfea, 0x414140de, 0x5dae2223, 0xb00361a3, 0x96177a9c, 0xb410ff61, 0xf20015ad } },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ { 0x248d6a61, 0xd20638b8, 0xe5c02693, 0x0c3e6039, 0xa33ce459, 0x64ff2167, 0xf6ecedd4, 0x19db06c1} }
+};
+
+int main()
+{
+ int i, failures = 0;
+ sha256Param param;
+ uint32 digest[8];
+
+ for (i = 0; i < 2; i++)
+ {
+ if (sha256Reset(&param))
+ return -1;
+ if (sha256Update(&param, table[i].input, strlen(table[i].input)))
+ return -1;
+ if (sha256Digest(&param, digest))
+ return -1;
+
+ if (mp32ne(8, digest, table[i].expect))
+ {
+ printf("failed\n");
+ failures++;
+ }
+ else
+ printf("ok\n");
+ }
+ return failures;
+}
diff --git a/beecrypt/timestamp.c b/beecrypt/timestamp.c
index 54f5d927d..50339c2f8 100644
--- a/beecrypt/timestamp.c
+++ b/beecrypt/timestamp.c
@@ -3,7 +3,7 @@
*
* Java compatible 64-bit timestamp, code
*
- * Copyright (c) 1999, 2000 Virtual Unlimited B.V.
+ * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*