First crack at merging beecrypt-2.3.0 changes.

CVS patchset: 5484
CVS date: 2002/06/14 20:31:05
This commit is contained in:
jbj 2002-06-14 20:31:05 +00:00
parent 243ff70d72
commit 609f6ba9c8
85 changed files with 5698 additions and 682 deletions

View File

@ -6,6 +6,7 @@ Doxyfile
Makefile
Makefile.in
apidocs
autom4te-*.cache
beecrypt.spec
beecrypt-*.tar.gz
config.h

View File

@ -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
Note: since this operation is where servers really hurt (i.e. in SSL), it pays to make this operation as fast as possible.
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.
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
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.
Block cipher encryption (more is better)
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
AES (10 rounds) ECB:
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.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 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

View File

@ -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.

View File

@ -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.
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.

View File

@ -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_audio_m Entropy sources: /dev/audio
*/
/** \defgroup ES_dsp_m Entropy sources: /dev/dsp
/*! \defgroup ES_dsp_m Entropy sources: /dev/dsp
*/
/** \defgroup ES_random_m Entropy sources: /dev/random
/*! \defgroup ES_random_m Entropy sources: /dev/random
*/
/** \defgroup ES_urandom_m Entropy sources: /dev/urandom
/*! \defgroup ES_urandom_m Entropy sources: /dev/urandom
*/
/** \defgroup ES_tty_m Entropy sources: /dev/tty
/*! \defgroup ES_tty_m Entropy sources: /dev/tty
*/
/** \defgroup PRNG_m Pseudo-Random Number Generators
/*! \defgroup PRNG_m Pseudo-Random Number Generators
*/
/** \defgroup PRNG_fips186_m Pseudo-Random Number Generator: FIPS-186
/*! \defgroup PRNG_fips186_m Pseudo-Random Number Generators: FIPS-186
*/
/** \defgroup HASH_m Hash Functions
/*! \defgroup HASH_m Hash Functions
*/
/** \defgroup HASH_md5_m Hash Functions: md5
/*! \defgroup HASH_md5_m Hash Functions: MD5
*/
/** \defgroup HASH_sha1_m Hash Functions: sha1
/*! \defgroup HASH_sha1_m Hash Functions: SHA-1
*/
/** \defgroup HASH_sha256_m Hash Functions: sha256
/*! \defgroup HASH_sha256_m Hash Functions: SHA-256
*/
/** \defgroup HMAC_m Keyed Hash Functions, a.k.a. Message Authentication Codes
/*! \defgroup HMAC_m Keyed Hash Functions, a.k.a. Message Authentication Codes
*/
/** \defgroup HMAC_md5_m Keyed Hash Functions: md5
/*! \defgroup HMAC_md5_m Keyed Hash Functions: HMAC-MD5
*/
/** \defgroup HMAC_sha1_m Keyed Hash Functions: sha1
/*! \defgroup HMAC_sha1_m Keyed Hash Functions: HMAC-SHA-1
*/
/** \defgroup HMAC_sha256_m Keyed Hash Functions: sha256
/*! \defgroup HMAC_sha256_m Keyed Hash Functions: HMAC-SHA-256
*/
/** \defgroup BC_m Block ciphers
/*! \defgroup BC_m Block ciphers
*/
/** \defgroup BC_blowfish_m Block ciphers: Blowfish
/*! \defgroup BC_aes_m Block ciphers: AES
*/
/** \defgroup RSA_m RSA Encryption/Signature Primitives
/*! \defgroup BC_blowfish_m Block ciphers: Blowfish
*/
/** \defgroup DSA_m DSA Encryption/Signature Primitives
/*! \defgroup DL_m Discrete Logarithm Primitives
*/
/** \defgroup ELGAMAL_m ElGamal Signature Primitives
/*! \defgroup DH_m Diffie-Hellman Primitives
*/
/** \defgroup DH_m Diffie-Hellman Encryption
/*! \defgroup DSA_m DSA Encryption/Signature Primitives
*/
/** \defgroup DL_m Discrete Logartithms
/*! \defgroup RSA_m RSA Encryption/Signature Primitives
*/
/** \defgroup MP_m Multiple Precision Integer Arithmetic
/*! \defgroup ELGAMAL_m ElGamal Signature Primitives
*/
/** \defgroup JAVA_m Java API
/*! \defgroup MP32_m Multiple Precision Integer Arithmetic (32 bit)
*/
/*! \defgroup MP64_m Multiple Precision Integer Arithmetic (64 bit)
*/
/*! \defgroup JAVA_m Java API
*/

View File

@ -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

View File

@ -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@

View File

@ -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
fips180opt.obj: win32/masm/fips180opt.i586.asm
$(AS) $(ASFLAGS) /Fofips180opt.obj /c win32/masm/fips180opt.i586.asm
blowfishopt.obj: masm\blowfishopt.i586.asm
$(AS) $(ASFLAGS) /Foblowfishopt.obj /c masm\blowfishopt.i586.asm
mp32opt.obj: win32/masm/mp32opt.i386.asm
$(AS) $(ASFLAGS) /Fomp32opt.obj /c win32/masm/mp32opt.i386.asm
sha1opt.obj: masm\sha1opt.i586.asm
$(AS) $(ASFLAGS) /Fosha1opt.obj /c masm\sha1opt.i586.asm
mp32opt.obj: masm\mp32opt.i386.asm
$(AS) $(ASFLAGS) /Fomp32opt.obj /c masm\mp32opt.i386.asm
clean:
del *.obj

View File

@ -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.

View File

@ -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:
http://www.virtualunlimited.com
For more on Virtual Unlimited B.V. and our products please consult our
website: 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
- 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)
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.
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:
Sincerely
http://beecrypt.virtualunlimited.com/
or contact me at mailto:beecrypt@virtualunlimited.com
Sincerely,
Bob Deblier

13
beecrypt/README.DARWIN Normal file
View File

@ -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"

1306
beecrypt/aes.c Normal file

File diff suppressed because it is too large Load Diff

66
beecrypt/aes.h Normal file
View File

@ -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

70
beecrypt/aesopt.h Normal file
View File

@ -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

49
beecrypt/beecrypt.api.h Normal file
View File

@ -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

View File

@ -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@*/

View File

@ -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

View File

@ -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

197
beecrypt/beecrypt.gnu.h.in Normal file
View File

@ -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

Binary file not shown.

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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,14 +753,17 @@ 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)
@ -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/aesopt.S; then
cat > $srcdir/aesopt.c << EOF
EOF
fi
if test ! -r $srcdir/blowfishopt.S; then
cat > $srcdir/blowfishopt.c << EOF
EOF
fi
if test ! -r $srcdir/fips180opt.S; then
cat > $srcdir/fips180opt.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

View File

@ -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;
/* compute u1 = h(m)*w mod q */
mp32bmulmod_w(q, hm->size, hm->data, qsize, qtemp, qtemp+qsize, qwksp);
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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
}
rc = mp32eqx(r->size, r->data, psize, ptemp+psize);
}
free(qtemp);

View File

@ -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;

View File

@ -184,6 +184,12 @@ BEECRYPTAPI /*@unused@*/
int encodeIntsPartial(const javaint* i, /*@out@*/ byte* data, int bytecount)
/*@modifies data */;
/**
*/
BEECRYPTAPI /*@unused@*/
int encodeIntsPartialPad(const javaint* i, byte* data, int bytecount, byte padvalue)
/*@modifies data */;
/**
*/
BEECRYPTAPI /*@unused@*/

View File

@ -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>
*

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

688
beecrypt/gas/aesopt.i586.S Normal file
View File

@ -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))

View File

@ -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))

View File

@ -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))

View File

@ -27,7 +27,7 @@
*
*/
#include "config.gas.h"
#include "beecrypt.gas.h"
#define saved_pfs r14
#define saved_lc r15

View File

@ -27,7 +27,7 @@
*
*/
#include "config.gas.h"
#include "beecrypt.gas.h"
.file "fips180opt.powerpc.S"

View File

@ -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

View File

@ -25,7 +25,7 @@
*
*/
#include "config.gas.h"
#include "beecrypt.gas.h"
.file "mp32opt.i386.S"

View File

@ -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

View File

@ -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))

View File

@ -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))

View File

@ -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))

View File

@ -25,7 +25,7 @@
*
*/
#include "config.gas.h"
#include "beecrypt.gas.h"
#define saved_pfs r14
#define saved_lc r15

View File

@ -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))

View File

@ -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;
uint32 keydigest[16];
byte* tmp;
if (keywords > 0)
{
(void) encodeInts((const javaint*) key, (byte*) hp->kxi, keywords);
(void) encodeInts((const javaint*) key, (byte*) hp->kxo, keywords);
/* if the hash digest is too large, this doesn't help */
if (hash->digestsize > 64)
return -1;
for (i = 0; i < keywords; i++)
{
hp->kxi[i] ^= HMAC_IPAD;
hp->kxo[i] ^= HMAC_OPAD;
}
}
if (hash->reset(param))
return -1;
for (i = keywords; i < 16; i++)
{
hp->kxi[i] = HMAC_IPAD;
hp->kxo[i] = HMAC_OPAD;
}
tmp = (byte*) malloc(keybytes);
return hmacReset(hp, hash, param);
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;
for (i = 0; i < keybytes; i++)
{
hp->kxi[i] ^= HMAC_IPAD;
hp->kxo[i] ^= HMAC_OPAD;
}
/* key too long */
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 */

View File

@ -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

View File

@ -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@*/

View File

@ -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

View File

@ -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@*/

View File

@ -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

View File

@ -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@*/

View File

@ -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

6
beecrypt/installgen.sh Executable file
View File

@ -0,0 +1,6 @@
#! /bin/sh
rm -f ltconfig ltmain.sh
aclocal
autoheader
automake -a
autoconf

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,5 @@
;
; fips180opt.i586.asm
; sha1.i586.asm
;
; Assembler optimized SHA-1 routines for Intel Pentium processors
;

View File

@ -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 = mp32rshiftlsz(size, wksp);
shift = temp;
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

View File

@ -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
@ -351,6 +351,12 @@ BEECRYPTAPI
void mp32rshift(uint32 xsize, uint32* xdata, uint32 count)
/*@modifies xdata @*/;
/**
*/
BEECRYPTAPI
uint32 mp32rshiftlsz(uint32 xsize, uint32* xdata)
/*@modifies xdata @*/;
/**
*/
BEECRYPTAPI

View File

@ -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;

View File

@ -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

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,5 @@
#
# fips180opt.i586.asm
# sha1opt.i586.asm
#
# Assembler optimized SHA-1 routines for Intel Pentium processors
#

View File

@ -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))
register uint32* ptemp;
register uint32* qtemp;
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->p, temp+psize+qsize, temp, wksp);
/*@=compdef@*/
free(ptemp);
return -1;
}
else
mp32setx(psize, temp, m->size, m->data);
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))
{
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@*/
}
else
mp32setx(qsize, temp+psize, m->size, m->data);
/* m must be small enough to be exponentiated modulo p and q */
if (m->size > psize || m->size > qsize)
return -1;
mp32bpowmod_w(&kp->q, qsize, temp+psize, kp->d2.size, kp->d2.data, temp+psize, wksp);
/* 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)

View File

@ -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"

View File

@ -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
*/

View File

@ -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" {

View File

@ -43,6 +43,10 @@
# endif
#endif
#if HAVE_TIME_H
# include <time.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif

View File

@ -20,3 +20,10 @@ stamp-h.in
beetest
base64bug
openpgp
testdldp
testdsa
testhmacmd5
testhmacsha1
testmd5
testsha1
testsha256

View File

@ -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

View File

@ -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
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
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.

View File

@ -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@*/

66
beecrypt/tests/testdldp.c Normal file
View File

@ -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;
}

144
beecrypt/tests/testdsa.c Normal file
View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

76
beecrypt/tests/testmd5.c Normal file
View File

@ -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;
}

66
beecrypt/tests/testsha1.c Normal file
View File

@ -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;
}

View File

@ -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;
}

View File

@ -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>
*