From 78de87f74cc1a9cfffb9a198509f2e6697b8bca8 Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 18 Sep 2001 19:23:46 +0000 Subject: [PATCH] Initial revision CVS patchset: 5051 CVS date: 2001/09/18 19:23:46 --- beecrypt/AUTHORS | 3 + beecrypt/BENCHMARKS | 67 + beecrypt/BUGS | 2 + beecrypt/CHANGELOG | 28 + beecrypt/CONTRIBUTORS | 12 + beecrypt/COPYING | 504 ++++ beecrypt/COPYING.LIB | 504 ++++ beecrypt/ChangeLog | 0 beecrypt/DOCUMENTATION | 50 + beecrypt/INSTALL | 187 ++ beecrypt/LICENSE | 504 ++++ beecrypt/Makefile.am | 55 + beecrypt/Makefile.in | 227 ++ beecrypt/Makefile.mak | 117 + beecrypt/NEWS | 88 + beecrypt/README | 109 + beecrypt/README.DLL | 37 + beecrypt/README.WIN32 | 43 + beecrypt/acconfig.h | 118 + beecrypt/aclocal.m4 | 540 ++++ beecrypt/base64.c | 241 ++ beecrypt/base64.h | 44 + beecrypt/beecrypt.c | 319 +++ beecrypt/beecrypt.def | 325 +++ beecrypt/beecrypt.h | 591 ++++ beecrypt/beecrypt.mcp | Bin 0 -> 75718 bytes beecrypt/beecrypt.rc | 31 + beecrypt/beetest.c | 496 ++++ beecrypt/blockmode.c | 167 ++ beecrypt/blockmode.h | 44 + beecrypt/blockpad.c | 146 + beecrypt/blockpad.h | 49 + beecrypt/blowfish.c | 548 ++++ beecrypt/blowfish.h | 68 + beecrypt/blowfishopt.c | 12 + beecrypt/blowfishopt.h | 54 + beecrypt/config.gas.h | 74 + beecrypt/config.gnu.h.in | 259 ++ beecrypt/config.guess | 1012 +++++++ beecrypt/config.h | 41 + beecrypt/config.sub | 1238 +++++++++ beecrypt/config.win.h | 126 + beecrypt/configure | 2944 ++++++++++++++++++++ beecrypt/configure.in | 174 ++ beecrypt/dhaes.c | 284 ++ beecrypt/dhaes.h | 54 + beecrypt/dldp.c | 323 +++ beecrypt/dldp.h | 122 + beecrypt/dlkp.c | 54 + beecrypt/dlkp.h | 55 + beecrypt/dlpk.c | 75 + beecrypt/dlpk.h | 58 + beecrypt/dlsvdp-dh.c | 34 + beecrypt/dlsvdp-dh.h | 42 + beecrypt/docs/Makefile.am | 25 + beecrypt/docs/Makefile.in | 209 ++ beecrypt/docs/api.html | 133 + beecrypt/docs/developing.html | 13 + beecrypt/docs/index.html | 39 + beecrypt/docs/installing.html | 139 + beecrypt/docs/manual.css | 25 + beecrypt/docs/using.html | 11 + beecrypt/elgamal.c | 129 + beecrypt/elgamal.h | 50 + beecrypt/endianness.c | 477 ++++ beecrypt/endianness.h | 187 ++ beecrypt/entropy.c | 1155 ++++++++ beecrypt/entropy.h | 63 + beecrypt/fips180.c | 206 ++ beecrypt/fips180.h | 59 + beecrypt/fips180opt.c | 273 ++ beecrypt/fips180opt.h | 52 + beecrypt/fips186.c | 209 ++ beecrypt/fips186.h | 89 + beecrypt/gas/Makefile.am | 25 + beecrypt/gas/Makefile.in | 209 ++ beecrypt/gas/blowfishopt.i586.S | 176 ++ beecrypt/gas/fips180opt.i586.S | 291 ++ beecrypt/gas/mp32opt.arm.S | 174 ++ beecrypt/gas/mp32opt.i386.S | 339 +++ beecrypt/gas/mp32opt.ia64.S | 260 ++ beecrypt/gas/mp32opt.powerpc.S | 223 ++ beecrypt/gas/mp32opt.sparcv8.S | 93 + beecrypt/gas/mp32opt.sparcv9.S | 212 ++ beecrypt/gas/mp64opt.ia64.S | 322 +++ beecrypt/gnu/blowfishopt.gas.i586.S | 200 ++ beecrypt/gnu/blowfishopt.gas.i586.s | 179 ++ beecrypt/gnu/config.gas.h | 49 + beecrypt/gnu/config.gnu.h.in | 175 ++ beecrypt/gnu/fips180opt.gas.i586.S | 301 +++ beecrypt/gnu/fips180opt.gas.i586.s | 292 ++ beecrypt/gnu/mp32opt.gas.i386.S | 361 +++ beecrypt/gnu/mp32opt.gas.i386.s | 287 ++ beecrypt/gnu/mp32opt.gas.ia64.S | 242 ++ beecrypt/gnu/mp32opt.gas.powerpc.S | 259 ++ beecrypt/gnu/mp32opt.gas.powerpc.s | 210 ++ beecrypt/gnu/mp32opt.gas.sparcv9.S | 180 ++ beecrypt/gnu/mp32opt.gas.sparcv9.s | 189 ++ beecrypt/hmac.c | 102 + beecrypt/hmac.h | 56 + beecrypt/hmacmd5.c | 50 + beecrypt/hmacmd5.h | 58 + beecrypt/hmacsha1.c | 50 + beecrypt/hmacsha1.h | 58 + beecrypt/hmacsha256.c | 50 + beecrypt/hmacsha256.h | 58 + beecrypt/install-sh | 238 ++ beecrypt/javaglue.c | 710 +++++ beecrypt/javaglue.h | 277 ++ beecrypt/ltconfig | 3114 +++++++++++++++++++++ beecrypt/ltmain.sh | 4024 ++++++++++++++++++++++++++++ beecrypt/masm/Makefile.am | 25 + beecrypt/masm/Makefile.in | 209 ++ beecrypt/masm/blowfishopt.i586.asm | 180 ++ beecrypt/masm/fips180opt.i586.asm | 298 ++ beecrypt/masm/mp32opt.i386.asm | 351 +++ beecrypt/md5.c | 230 ++ beecrypt/md5.h | 59 + beecrypt/memchunk.c | 90 + beecrypt/memchunk.h | 53 + beecrypt/missing | 190 ++ beecrypt/mkinstalldirs | 40 + beecrypt/mp32.c | 1085 ++++++++ beecrypt/mp32.h | 200 ++ beecrypt/mp32barrett.c | 572 ++++ beecrypt/mp32barrett.h | 118 + beecrypt/mp32number.c | 160 ++ beecrypt/mp32number.h | 61 + beecrypt/mp32opt.c | 28 + beecrypt/mp32opt.h | 87 + beecrypt/mp32prime.c | 1217 +++++++++ beecrypt/mp32prime.h | 57 + beecrypt/mtprng.c | 232 ++ beecrypt/mtprng.h | 88 + beecrypt/mwerks/Makefile.am | 25 + beecrypt/mwerks/Makefile.in | 209 ++ beecrypt/mwerks/beecrypt.pch | 6 + beecrypt/mwerks/blowfishopt.i586.asm | 173 ++ beecrypt/mwerks/fips180opt.i586.asm | 292 ++ beecrypt/mwerks/mp32opt.i386.asm | 299 +++ beecrypt/rsa.c | 121 + beecrypt/rsa.h | 47 + beecrypt/rsakp.c | 187 ++ beecrypt/rsakp.h | 62 + beecrypt/rsapk.c | 57 + beecrypt/rsapk.h | 52 + beecrypt/sha1hmac.c | 50 + beecrypt/sha1hmac.h | 58 + beecrypt/sha256.c | 239 ++ beecrypt/sha256.h | 58 + beecrypt/stamp-h.in | 1 + beecrypt/tests/Makefile.am | 30 + beecrypt/tests/Makefile.in | 308 +++ beecrypt/tests/beetest.c | 813 ++++++ beecrypt/timestamp.c | 50 + beecrypt/timestamp.h | 47 + beecrypt/win32/beecrypt.def | 259 ++ beecrypt/win32/beecrypt.dll.c | 43 + beecrypt/win32/beecrypt.rc | 31 + beecrypt/win32/config.win.h | 162 ++ beecrypt/win32/masm/blowfishopt.i586.asm | 180 ++ beecrypt/win32/masm/fips180opt.i586.asm | 298 ++ beecrypt/win32/masm/mp32opt.i386.asm | 287 ++ beecrypt/win32/mwerks/beecrypt.pch | 5 + beecrypt/win32/mwerks/blowfishopt.i586.asm | 173 ++ beecrypt/win32/mwerks/fips180opt.i586.asm | 291 ++ beecrypt/win32/mwerks/mp32opt.i386.asm | 275 ++ 167 files changed, 41753 insertions(+) create mode 100644 beecrypt/AUTHORS create mode 100644 beecrypt/BENCHMARKS create mode 100644 beecrypt/BUGS create mode 100644 beecrypt/CHANGELOG create mode 100644 beecrypt/CONTRIBUTORS create mode 100644 beecrypt/COPYING create mode 100644 beecrypt/COPYING.LIB create mode 100644 beecrypt/ChangeLog create mode 100644 beecrypt/DOCUMENTATION create mode 100644 beecrypt/INSTALL create mode 100644 beecrypt/LICENSE create mode 100644 beecrypt/Makefile.am create mode 100644 beecrypt/Makefile.in create mode 100644 beecrypt/Makefile.mak create mode 100644 beecrypt/NEWS create mode 100644 beecrypt/README create mode 100644 beecrypt/README.DLL create mode 100644 beecrypt/README.WIN32 create mode 100644 beecrypt/acconfig.h create mode 100644 beecrypt/aclocal.m4 create mode 100644 beecrypt/base64.c create mode 100644 beecrypt/base64.h create mode 100644 beecrypt/beecrypt.c create mode 100644 beecrypt/beecrypt.def create mode 100644 beecrypt/beecrypt.h create mode 100644 beecrypt/beecrypt.mcp create mode 100644 beecrypt/beecrypt.rc create mode 100644 beecrypt/beetest.c create mode 100644 beecrypt/blockmode.c create mode 100644 beecrypt/blockmode.h create mode 100644 beecrypt/blockpad.c create mode 100644 beecrypt/blockpad.h create mode 100644 beecrypt/blowfish.c create mode 100644 beecrypt/blowfish.h create mode 100644 beecrypt/blowfishopt.c create mode 100644 beecrypt/blowfishopt.h create mode 100644 beecrypt/config.gas.h create mode 100644 beecrypt/config.gnu.h.in create mode 100755 beecrypt/config.guess create mode 100644 beecrypt/config.h create mode 100755 beecrypt/config.sub create mode 100644 beecrypt/config.win.h create mode 100755 beecrypt/configure create mode 100644 beecrypt/configure.in create mode 100644 beecrypt/dhaes.c create mode 100644 beecrypt/dhaes.h create mode 100644 beecrypt/dldp.c create mode 100644 beecrypt/dldp.h create mode 100644 beecrypt/dlkp.c create mode 100644 beecrypt/dlkp.h create mode 100644 beecrypt/dlpk.c create mode 100644 beecrypt/dlpk.h create mode 100644 beecrypt/dlsvdp-dh.c create mode 100644 beecrypt/dlsvdp-dh.h create mode 100644 beecrypt/docs/Makefile.am create mode 100644 beecrypt/docs/Makefile.in create mode 100644 beecrypt/docs/api.html create mode 100644 beecrypt/docs/developing.html create mode 100644 beecrypt/docs/index.html create mode 100644 beecrypt/docs/installing.html create mode 100644 beecrypt/docs/manual.css create mode 100644 beecrypt/docs/using.html create mode 100644 beecrypt/elgamal.c create mode 100644 beecrypt/elgamal.h create mode 100644 beecrypt/endianness.c create mode 100644 beecrypt/endianness.h create mode 100644 beecrypt/entropy.c create mode 100644 beecrypt/entropy.h create mode 100644 beecrypt/fips180.c create mode 100644 beecrypt/fips180.h create mode 100644 beecrypt/fips180opt.c create mode 100644 beecrypt/fips180opt.h create mode 100644 beecrypt/fips186.c create mode 100644 beecrypt/fips186.h create mode 100644 beecrypt/gas/Makefile.am create mode 100644 beecrypt/gas/Makefile.in create mode 100644 beecrypt/gas/blowfishopt.i586.S create mode 100644 beecrypt/gas/fips180opt.i586.S create mode 100644 beecrypt/gas/mp32opt.arm.S create mode 100644 beecrypt/gas/mp32opt.i386.S create mode 100644 beecrypt/gas/mp32opt.ia64.S create mode 100644 beecrypt/gas/mp32opt.powerpc.S create mode 100644 beecrypt/gas/mp32opt.sparcv8.S create mode 100644 beecrypt/gas/mp32opt.sparcv9.S create mode 100644 beecrypt/gas/mp64opt.ia64.S create mode 100644 beecrypt/gnu/blowfishopt.gas.i586.S create mode 100644 beecrypt/gnu/blowfishopt.gas.i586.s create mode 100644 beecrypt/gnu/config.gas.h create mode 100644 beecrypt/gnu/config.gnu.h.in create mode 100644 beecrypt/gnu/fips180opt.gas.i586.S create mode 100644 beecrypt/gnu/fips180opt.gas.i586.s create mode 100644 beecrypt/gnu/mp32opt.gas.i386.S create mode 100644 beecrypt/gnu/mp32opt.gas.i386.s create mode 100644 beecrypt/gnu/mp32opt.gas.ia64.S create mode 100644 beecrypt/gnu/mp32opt.gas.powerpc.S create mode 100644 beecrypt/gnu/mp32opt.gas.powerpc.s create mode 100644 beecrypt/gnu/mp32opt.gas.sparcv9.S create mode 100644 beecrypt/gnu/mp32opt.gas.sparcv9.s create mode 100644 beecrypt/hmac.c create mode 100644 beecrypt/hmac.h create mode 100644 beecrypt/hmacmd5.c create mode 100644 beecrypt/hmacmd5.h create mode 100644 beecrypt/hmacsha1.c create mode 100644 beecrypt/hmacsha1.h create mode 100644 beecrypt/hmacsha256.c create mode 100644 beecrypt/hmacsha256.h create mode 100755 beecrypt/install-sh create mode 100644 beecrypt/javaglue.c create mode 100644 beecrypt/javaglue.h create mode 100755 beecrypt/ltconfig create mode 100644 beecrypt/ltmain.sh create mode 100644 beecrypt/masm/Makefile.am create mode 100644 beecrypt/masm/Makefile.in create mode 100644 beecrypt/masm/blowfishopt.i586.asm create mode 100644 beecrypt/masm/fips180opt.i586.asm create mode 100644 beecrypt/masm/mp32opt.i386.asm create mode 100644 beecrypt/md5.c create mode 100644 beecrypt/md5.h create mode 100644 beecrypt/memchunk.c create mode 100644 beecrypt/memchunk.h create mode 100755 beecrypt/missing create mode 100755 beecrypt/mkinstalldirs create mode 100644 beecrypt/mp32.c create mode 100644 beecrypt/mp32.h create mode 100644 beecrypt/mp32barrett.c create mode 100644 beecrypt/mp32barrett.h create mode 100644 beecrypt/mp32number.c create mode 100644 beecrypt/mp32number.h create mode 100644 beecrypt/mp32opt.c create mode 100644 beecrypt/mp32opt.h create mode 100644 beecrypt/mp32prime.c create mode 100644 beecrypt/mp32prime.h create mode 100644 beecrypt/mtprng.c create mode 100644 beecrypt/mtprng.h create mode 100644 beecrypt/mwerks/Makefile.am create mode 100644 beecrypt/mwerks/Makefile.in create mode 100644 beecrypt/mwerks/beecrypt.pch create mode 100644 beecrypt/mwerks/blowfishopt.i586.asm create mode 100644 beecrypt/mwerks/fips180opt.i586.asm create mode 100644 beecrypt/mwerks/mp32opt.i386.asm create mode 100644 beecrypt/rsa.c create mode 100644 beecrypt/rsa.h create mode 100644 beecrypt/rsakp.c create mode 100644 beecrypt/rsakp.h create mode 100644 beecrypt/rsapk.c create mode 100644 beecrypt/rsapk.h create mode 100644 beecrypt/sha1hmac.c create mode 100644 beecrypt/sha1hmac.h create mode 100644 beecrypt/sha256.c create mode 100644 beecrypt/sha256.h create mode 100644 beecrypt/stamp-h.in create mode 100644 beecrypt/tests/Makefile.am create mode 100644 beecrypt/tests/Makefile.in create mode 100644 beecrypt/tests/beetest.c create mode 100644 beecrypt/timestamp.c create mode 100644 beecrypt/timestamp.h create mode 100644 beecrypt/win32/beecrypt.def create mode 100644 beecrypt/win32/beecrypt.dll.c create mode 100644 beecrypt/win32/beecrypt.rc create mode 100644 beecrypt/win32/config.win.h create mode 100644 beecrypt/win32/masm/blowfishopt.i586.asm create mode 100644 beecrypt/win32/masm/fips180opt.i586.asm create mode 100644 beecrypt/win32/masm/mp32opt.i386.asm create mode 100644 beecrypt/win32/mwerks/beecrypt.pch create mode 100644 beecrypt/win32/mwerks/blowfishopt.i586.asm create mode 100644 beecrypt/win32/mwerks/fips180opt.i586.asm create mode 100644 beecrypt/win32/mwerks/mp32opt.i386.asm diff --git a/beecrypt/AUTHORS b/beecrypt/AUTHORS new file mode 100644 index 0000000..623630c --- /dev/null +++ b/beecrypt/AUTHORS @@ -0,0 +1,3 @@ +BeeCrypt Cryptograpy Library: + +Bob Deblier diff --git a/beecrypt/BENCHMARKS b/beecrypt/BENCHMARKS new file mode 100644 index 0000000..978ff9a --- /dev/null +++ b/beecrypt/BENCHMARKS @@ -0,0 +1,67 @@ +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: 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 + +The tests: + +Modular exponentiations, (1024 bits ^ 1024 bits) mod 1024 bits, 100 times, sorted according to speed (less is better) + +BeeCrypt 0.9.5/RedHat Linux 6.2 /Pentium III 450/128 MB: 7.5 sec +BeeCrypt 1.0.0/Windows 98 /Pentium III 450/128 MB: 7.5 sec +BeeCrypt 1.0.0/Windows 98 /Pentium III 350/128 MB: 9.5 sec +Java 1.2.2 /RedHat Linux 6.2 /Pentium III 450/128 MB: 11.6 sec +BeeCrypt 1.0.0/RedHat Linux 6.1 /Pentium Pro 200/128 MB: 16.6 sec +BeeCrypt 1.0.0/Windows NT 4.0 /Pentium Pro 200/128 MB: 17.0 sec +Java 1.2.2 /Windows 2000 /Pentium III 450/128 MB: 22.0 sec +Java 1.3 /Windows 2000 /Pentium III 450/128 MB: 23.5 sec +Java 1.2.2 /Windows NT 4.0 /Pentium II 333/128 MB: 29.8 sec +Java 1.2.2 /Windows 98 /Pentium II 333/ 64 MB: 32.7 sec +Java 1.2.2 /Windows NT 4.0 /Pentium Pro 200/128 MB: 48.8 sec +Java 1.2.2 /Solaris 2.7 /UltraSparc 143/128 MB: 51.1 sec +BeeCrypt 0.9.4/Solaris 2.7 /UltraSparc 143/128 MB: 56.5 sec +BeeCrypt 0.9.5/Yellow Dog Linux 1.2/PowerPC 601 90/ 40 MB: 88.9 sec + +Remarks: both on Solaris and Linux, beecrypt is least 4 times faster for this operation than a commercial product we at one time considered using. + +Conclusions: +1) the assembler-optimized code in beecrypt works pretty efficient on a pentium pro and higher +2) Sun did an excellent job on optimizing the BigInteger native library; beecrypt still needs some tuning on UltraSparc to catch up. + +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 + +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 + +Hash functions (more is better) + +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 diff --git a/beecrypt/BUGS b/beecrypt/BUGS new file mode 100644 index 0000000..6f0370d --- /dev/null +++ b/beecrypt/BUGS @@ -0,0 +1,2 @@ +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. diff --git a/beecrypt/CHANGELOG b/beecrypt/CHANGELOG new file mode 100644 index 0000000..f91ef0d --- /dev/null +++ b/beecrypt/CHANGELOG @@ -0,0 +1,28 @@ +1.0.0: + - Added Win32 support; compiled as DLL with MetroWerks CodeWarrior Pro 5, it runs fine on Windows 95, 98, NT 4.0 (if you have a soundcard with a microphone port). Note that there is a know issue on Windows 2000, see BUGS. + - Global code overhaul to support Win32 + - Added more assembler routines, including SHA-1 for Pentium Pro (60% faster) + - Added cleanup function to randomGenerator + - Added missing functions in endianness.c + - Fixed bug in entropy.c where devices might stay open + - Eliminated mutex.h include file; it was more clear to do everything conditionally than to expand the macros in this file to encompass the Win32 API calls. + +0.9.5: + - Added PowerPC assembler optimization for multiprecision integers, 80% faster on our PowerMac 7200/90 + - Fixed /dev/random entropy provider + - Changed name SHA1 to SHA-1 in fips180 for consistency + +0.9.4a: + - Added missing file 'blowfishopt.o' + +0.9.4: + - Changes to configure script, to distinguish between different processors of the x86 family + - Changes to blowfish code, 586/686 assembler optimization added, 30% faster on Pentium/PentiumPro + - Changes to blowfish code, eliminated static blowfishSetupEncrypt; incorporated into regular encrypt + - Changes to Makefile to selectively use blowfish assember code, depending on cpu type + - Added missing routines 'mp32bzero' and 'mp32bnpowmod' to mp32barrett.c + - Fixed 'const register' to 'register const' in mp32.c + - Minor fixes in included header files + +0.9.3: + - Initial public release diff --git a/beecrypt/CONTRIBUTORS b/beecrypt/CONTRIBUTORS new file mode 100644 index 0000000..8f759ed --- /dev/null +++ b/beecrypt/CONTRIBUTORS @@ -0,0 +1,12 @@ +I would like to thank the following contributors to BeeCrypt: + +- ARM Ltd, for donating a copy of the "ARM Architecture Reference Manual". +- Compaq, for their testdrive program, which gave me the opportunity to test many new platforms. +- SourceForge, for their excellent open source development platform, including their compile farm. +- Luca Filipozzi, for packaging BeeCrypt for the Debian GNU/Linux distribution. + +And last but not least: + +- Jon Sturgeon, bug hunter extraordinaire. + + diff --git a/beecrypt/COPYING b/beecrypt/COPYING new file mode 100644 index 0000000..223ede7 --- /dev/null +++ b/beecrypt/COPYING @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 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 + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/beecrypt/COPYING.LIB b/beecrypt/COPYING.LIB new file mode 100644 index 0000000..223ede7 --- /dev/null +++ b/beecrypt/COPYING.LIB @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 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 + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/beecrypt/ChangeLog b/beecrypt/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/beecrypt/DOCUMENTATION b/beecrypt/DOCUMENTATION new file mode 100644 index 0000000..8b3bc1e --- /dev/null +++ b/beecrypt/DOCUMENTATION @@ -0,0 +1,50 @@ +NOTE: The documentation is incomplete, but will be improved in the near future. + +So okay, you've got the BeeCrypt source code. Now in which way can you use it to protect your data and shield it from prying eyes? You'll have to develop your own programs to do that, or you can use this library with Virtual Unlimited's Beeyond Beehive. + +A word of caution: before you attempt to write your own applications, make sure you familiarize yourself with the concepts of cryptography, read the books recommended in the 'README' file, figure out the math, find information on the internet, in newsgroups, web pages, etc. In other words: study. +Cryptography is not necessarily difficult, but an application is only as strong as its weakest part. More often then not there are unintentional security holes in applications, which result in a dramatically lower level of security than claimed and intended by the author(s). + +To start, there's an example program included called 'beetest.c', which will test and benchmark some of the library's routines after it's been installed. + +Each .h file should contain enough information on how the use the structs and functions it contains. Each .c file should contain comment to explain the tricky parts, and references to textbooks. + +Furthermore, I'll explain briefly what can be found in each file, and how to use it: + +beecrypt.h, beecrypt.c: the definitions and generic functions for accessing pseudo-random generators, hash functions, keyed hash functions, and block ciphers. + +mp32.h, mp32.c: the multiprecision integer basic routines. + +mp32opt.h mp32opt.gas..s: the platform-specific assembler optimized routines for multipreceision integer operations. + +mp32barrett.h, mp32barrett.c: the routines for Barrett Modular Reduction of multiprecision integers. + +mp32prime.h, mp32prime.c: the routines for probabilistic primality testing and generation of multiprecision integers. + +dldp.h, dldp.c: the definitions of Discrete Logarithm Domain Parameters (only prime field variant at this time), plus functions to generate and test them. Generators can be determined over the whole field, or over a prime subfield. + +dlpk.h, dlpk.c: the definitions of Discrete Logarithm Public Keys (only prime field variant at this time), plus functions to initialize and test them. + +dlkp.h, dlkp.c: the definitions of Discrete Logarithm Key Pairs (only prime field variant at this time), plus functions to initialize and generate them. + +dlsvdp-dh.h, dlsvdp-dh.c: the definitions of Diffie-Hellman key agreement (only prime field variant at this time) + +elgamal.h, elgamal.c: the ElGamal signature scheme (two variants) (only prime field variant at this time) + +blockmode.h, blockmode.c: implementation of the different modes block ciphers can operate in (ECB, CBC, etc.) + +blowfish.h, blowfish.c: the blowfish blockciper, plus the stub for hooking it into the beecrypt library. + +blowfishopt.h, blowfishopt.gas..s: the platform-specific assembler optimized routines for blowfish encryption/decryption. + +entropy.h, entropy.c: the entropy gathering system; don't use directly - only use these routines through the beecrypt generics stubs; you can modify this file if you want to add custom entropy provider(s) to the library. + +fips180.h, fips180.c: the SHA-1 hash algorithm, plus the stub for hooking it into the beecrypt library. + +fips186.h, fips186.c: the NIST FIPS-186 pseudo-random number generator, plus the stub for hooking it into the beecrypt library; in the future, the rest of FIPS-186 (the DSA algorithm) will be added. + +hmac.h, hmac.c: the base for the HMAC algorithm; combined with a hash function, it can be used as a keyed hash function. + +mtprng.h, mtprng.c: the Mersenne Twister pseudo-random number generator; it has a very high period, but needs more analysis on whether it's cryptographically strong enough. + +sha1hmac.h, sha1hmac.c: the implementation of the SHA-1/HMAC keyed hash function; uses routines from fips186 and hmac. diff --git a/beecrypt/INSTALL b/beecrypt/INSTALL new file mode 100644 index 0000000..bca44d0 --- /dev/null +++ b/beecrypt/INSTALL @@ -0,0 +1,187 @@ +Basic Installation +================== + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + If you're building GNU make on a system which does not already have + a `make', you can use the build.sh shell script to compile. Run + `sh ./build.sh'. This should compile the program in the current + directory. Then you will have a Make program that you can use for + `make install', or whatever else. + + 3. Optionally, type `./make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/beecrypt/LICENSE b/beecrypt/LICENSE new file mode 100644 index 0000000..223ede7 --- /dev/null +++ b/beecrypt/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 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 + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/beecrypt/Makefile.am b/beecrypt/Makefile.am new file mode 100644 index 0000000..c2285d3 --- /dev/null +++ b/beecrypt/Makefile.am @@ -0,0 +1,55 @@ +# +# Makefile.am contains the top-level automake definitions +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + +# +# 1. No interfaces changes (good): Increment REVISION +# +# 2. Interfaces added, none removed (good): Increment CURRENT, increment AGE and REVISION to 0. +# +# 3. Interfaces removed (bad): Increment CURRENT, set AGE and REVISION to 0. +# + +LIBBEECRYPT_LT_CURRENT = 3 +LIBBEECRYPT_LT_AGE = 1 +LIBBEECRYPT_LT_REVISION = 0 + +AUTOMAKE_OPTIONS = gnu check-news no-dependencies + +SUBDIRS = docs gas masm mwerks tests + +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 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_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 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_DEPENDENCIES = $(BEECRYPT_OBJECTS) $(BEECRYPT_JAVA_OBJECTS) + +libbeecrypt_la_LIBADD = blowfishopt.lo fips180opt.lo mp32opt.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 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 + +EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS README.DLL README.WIN32 beecrypt.def beecrypt.mcp beecrypt.rc config.h config.gas.h config.win.h javaglue.h diff --git a/beecrypt/Makefile.in b/beecrypt/Makefile.in new file mode 100644 index 0000000..8d5bd78 --- /dev/null +++ b/beecrypt/Makefile.in @@ -0,0 +1,227 @@ +# +# Makefile.in for the beecrypt library +# +# Copyright (c) 1999-2000, Virtual Unlimited B.V. +# +# Author: 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 +# + +PRODUCT=@PRODUCT@ +VERSION=@VERSION@ + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +CC = @CC@ +CFLAGS = @CFLAGS@ @DEFS@ -I${srcdir} +LDFLAGS = @LDFLAGS@ @LIBS@ + +TARGET_OS = @target_os@ +TARGET_CPU = @target_cpu@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +includedir= @includedir@ +libdir = @libdir@ + +OBJFILES = \ + base64.o \ + beecrypt.o \ + blockmode.o \ + blowfish.o \ + blowfishopt.o \ + dldp.o \ + dlkp.o \ + dlpk.o \ + dlsvdp-dh.o \ + elgamal.o \ + endianness.o \ + entropy.o \ + fips180.o \ + fips180opt.o \ + fips186.o \ + hmac.o \ + mp32.o \ + mp32barrett.o \ + mp32number.o \ + mp32opt.o \ + mp32prime.o \ + mtprng.o \ + sha1hmac.o \ + timestamp.o + +DISTFILES = \ + LICENSE README DOCUMENTATION CHANGELOG BUGS BENCHMARKS \ + config.guess config.sub install-sh \ + configure.in configure Makefile.in \ + config.h \ + base64.h base64.c \ + beecrypt.h beecrypt.c \ + blockmode.h blockmode.c \ + blowfish.h blowfish.c \ + blowfishopt.h blowfishopt.c \ + dldp.h dldp.c \ + dlkp.h dlkp.c \ + dlpk.h dlpk.c \ + dlsvdp-dh.h dlsvdp-dh.c \ + elgamal.h elgamal.c \ + endianness.h endianness.c \ + entropy.h entropy.c \ + fips180.h fips180.c \ + fips180opt.h fips180opt.c \ + fips186.h fips186.c \ + hmac.h hmac.c \ + mp32barrett.h mp32barrett.c \ + mp32.h mp32.c \ + mp32number.h mp32number.c \ + mp32opt.h mp32opt.c \ + mp32prime.h mp32prime.c \ + mtprng.h mtprng.c \ + sha1hmac.h sha1hmac.c \ + timestamp.h timestamp.c \ + gnu/config.gnu.h.in \ + gnu/blowfishopt.gas.i586.s gnu/fips180opt.gas.i586.s gnu/mp32opt.gas.i386.s \ + gnu/mp32opt.gas.powerpc.s \ + gnu/mp32opt.gas.sparcv9.s \ + beecrypt.mcp \ + win32/config.win.h \ + win32/beecrypt.dll.c win32/beecrypt.rc win32/beecrypt.def \ + win32/mwerks/blowfishopt.i586.asm win32/mwerks/fips180opt.i586.asm win32/mwerks/mp32opt.i386.asm \ + win32/mwerks/beecrypt.pch \ + beetest.c + +LIBBEECRYPT = libbeecrypt.so + +all: $(LIBBEECRYPT) + +ifeq '$(TARGET_CPU)' 'sparcv8plus' +mp32opt.o: gnu/mp32opt.gas.sparcv9.s + $(AS) -Av8plus -KPIC -o $@ gnu/mp32opt.gas.sparcv9.s +endif + +ifeq '$(TARGET_CPU)' 'sparcv9' +mp32opt.o: gnu/mp32opt.gas.sparcv9.s + $(AS) -Av9 -KPIC -o $@ gnu/mp32opt.gas.sparcv9.s +endif + +ifeq '$(TARGET_CPU)' 'i386' +mp32opt.o: gnu/mp32opt.gas.i386.s + $(AS) -o $@ gnu/mp32opt.gas.i386.s +endif + +ifeq '$(TARGET_CPU)' 'i486' +mp32opt.o: gnu/mp32opt.gas.i386.s + $(AS) -o $@ gnu/mp32opt.gas.i386.s +endif + +ifeq '$(TARGET_CPU)' 'i586' +blowfishopt.o: gnu/blowfishopt.gas.i586.s + $(AS) -o $@ gnu/blowfishopt.gas.i586.s + +fips180opt.o: gnu/fips180opt.gas.i586.s + $(AS) -o $@ gnu/fips180opt.gas.i586.s + +mp32opt.o: gnu/mp32opt.gas.i386.s + $(AS) -o $@ gnu/mp32opt.gas.i386.s +endif + +ifeq '$(TARGET_CPU)' 'i686' +blowfishopt.o: gnu/blowfishopt.gas.i586.s + $(AS) -o $@ gnu/blowfishopt.gas.i586.s + +fips180opt.o: gnu/fips180opt.gas.i586.s + $(AS) -o $@ gnu/fips180opt.gas.i586.s + +mp32opt.o: gnu/mp32opt.gas.i386.s + $(AS) -o $@ gnu/mp32opt.gas.i386.s +endif + +ifeq '$(TARGET_CPU)' 'powerpc' +mp32opt.o: gnu/mp32opt.gas.powerpc.s + $(AS) -o $@ gnu/mp32opt.gas.powerpc.s +endif + +$(LIBBEECRYPT): $(OBJFILES) + $(LD) -G -o $@ $(OBJFILES) + +install: $(LIBBEECRYPT) + $(INSTALL) -d $(libdir) + $(INSTALL) $(LIBBEECRYPT) $(libdir) + +install-headers: + $(INSTALL) -d $(includedir)/beecrypt + $(INSTALL_DATA) base64.h $(includedir)/beecrypt + $(INSTALL_DATA) beecrypt.h $(includedir)/beecrypt + $(INSTALL_DATA) blockmode.h $(includedir)/beecrypt + $(INSTALL_DATA) blowfish.h $(includedir)/beecrypt + $(INSTALL_DATA) blowfishopt.h $(includedir)/beecrypt + $(INSTALL_DATA) dldp.h $(includedir)/beecrypt + $(INSTALL_DATA) dlkp.h $(includedir)/beecrypt + $(INSTALL_DATA) dlpk.h $(includedir)/beecrypt + $(INSTALL_DATA) dlsvdp-dh.h $(includedir)/beecrypt + $(INSTALL_DATA) elgamal.h $(includedir)/beecrypt + $(INSTALL_DATA) endianness.h $(includedir)/beecrypt + $(INSTALL_DATA) entropy.h $(includedir)/beecrypt + $(INSTALL_DATA) fips180.h $(includedir)/beecrypt + $(INSTALL_DATA) fips180opt.h $(includedir)/beecrypt + $(INSTALL_DATA) fips186.h $(includedir)/beecrypt + $(INSTALL_DATA) hmac.h $(includedir)/beecrypt + $(INSTALL_DATA) mp32.h $(includedir)/beecrypt + $(INSTALL_DATA) mp32barrett.h $(includedir)/beecrypt + $(INSTALL_DATA) mp32number.h $(includedir)/beecrypt + $(INSTALL_DATA) mp32opt.h $(includedir)/beecrypt + $(INSTALL_DATA) mp32prime.h $(includedir)/beecrypt + $(INSTALL_DATA) mtprng.h $(includedir)/beecrypt + $(INSTALL_DATA) sha1hmac.h $(includedir)/beecrypt + $(INSTALL_DATA) timestamp.h $(includedir)/beecrypt + +beetest: beetest.o + $(CC) -o $@ beetest.o $(LDFLAGS) -L${libdir} -lbeecrypt + +clean: + rm -f *.so *.o beetest + +distclean: + rm -f *.so *.o beetest ${srcdir}/config.log ${srcdir}/config.cache ${srcdir}/config.status conftest.c ${srcdir}/Makefile ${srcdir}/gnu/config.gnu.h + +dist: $(DISTFILES) + @rm -rf $(PRODUCT)-$(VERSION) + @mkdir $(PRODUCT)-$(VERSION) + @chmod 777 $(PRODUCT)-$(VERSION) + @tar cf - $(DISTFILES) | (cd $(PRODUCT)-$(VERSION) && tar xf - ) + @chmod -R a+r $(PRODUCT)-$(VERSION) + @tar chozf $(PRODUCT)-$(VERSION).tar.gz $(PRODUCT)-$(VERSION) + @rm -rf $(PRODUCT)-$(VERSION) + +depend: + makedepend -I${srcdir} *.c + +${srcdir}/configure: ${srcdir}/configure.in + cd ${top_srcdir} && autoconf + +${srcdir}/config.gnu.h: ${srcdir}/config.gnu.h.in + ${srcdir}/config.status + +${srcdir}/Makefile: ${srcdir}/Makefile.in + ${srcdir}/config.status + +${srcdir}/config.status: ${srcdir}/configure + ${srcdir}/config.status --recheck + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/beecrypt/Makefile.mak b/beecrypt/Makefile.mak new file mode 100644 index 0000000..5ba22e6 --- /dev/null +++ b/beecrypt/Makefile.mak @@ -0,0 +1,117 @@ +# +# Makefile.mak for the beecrypt library +# +# To be used with Microsoft's nmake utility; +# Will need the Visual C Processor Pack installed. +# +# Copyright (c) 2000, 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + +AS=ml.exe +CC=cl.exe +LD=link.exe +RC=rc.exe + +DEFS= \ + win32/beecrypt.def + +LIBS= \ + advapi32.lib \ + gdi32.lib \ + kernel32.lib \ + user32.lib \ + winmm.lib + +LIBPATH="C:\Program Files\Microsoft Visual Studio\VC98\Lib" +JAVAPATH="C:\jdk1.3\include" + + +ASFLAGS=/nologo /c /coff /Gd +CFLAGS=/nologo /TC /MT /GD /Ox /G5 /DHAVE_CONFIG_H /I. +LDFLAGS=/nologo /machine:IX86 /libpath:$(LIBPATH) $(LIBS) +RCFLAGS=/r /L 0x409 /FObeecrypt.res +JAVAFLAGS=/DJAVAGLUE=1 /I$(JAVAPATH) /I$(JAVAPATH)\win32 + +OBJECTS= \ + base64.obj \ + beecrypt.obj \ + blockmode.obj \ + blockpad.obj \ + blowfish.obj \ + blowfishopt.obj \ + dhaes.obj \ + dldp.obj \ + dlkp.obj \ + dlpk.obj \ + dlsvdp-dh.obj \ + elgamal.obj \ + endianness.obj \ + entropy.obj \ + fips180.obj \ + fips180opt.obj \ + fips186.obj \ + hmac.obj \ + hmacmd5.obj \ + hmacsha1.obj \ + hmacsha256.obj \ + javaglue.obj \ + md5.obj \ + mp32.obj \ + mp32opt.obj \ + mp32barrett.obj \ + mp32number.obj \ + mp32prime.obj \ + mtprng.obj \ + rsa.obj \ + rsakp.obj \ + rsapk.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 + +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 + +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 + +fips180opt.obj: win32/masm/fips180opt.i586.asm + $(AS) $(ASFLAGS) /Fofips180opt.obj /c win32/masm/fips180opt.i586.asm + +mp32opt.obj: win32/masm/mp32opt.i386.asm + $(AS) $(ASFLAGS) /Fomp32opt.obj /c win32/masm/mp32opt.i386.asm + +clean: + del *.obj diff --git a/beecrypt/NEWS b/beecrypt/NEWS new file mode 100644 index 0000000..3bcd562 --- /dev/null +++ b/beecrypt/NEWS @@ -0,0 +1,88 @@ +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. + - Changed HMAC algorithm and file names to match names in RFC 2104. + - Changed SHA-1 C code for slightly faster results. + - Changed detection of entropy devices. + - Changed most void-returning functions to return int for error conditions. + - Changed beecrypt-java class names in javaglue. + - 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 PKCS#5 padding. + - Added DHAES encryption scheme. + - Added Microsoft Visual C support, added Makefile.mak for this purpose. + - Added Solaris/Sparc Forte C 64 bit support. + - Added configure --disable-optimized option (disables assembler & processor-specific optimizations). + - Fixed bug in SHA-1 assembler code for Pentium, where local variables were used below the current stack pointer; this could cause a problem if the routine was interrupted. This was pointed out by Richard Clayton. + - Fixed bug in (certain cases of) modular inverse computation. + - Fixed buffer overrun in base64 encoding. This was pointed out by Jon Sturgeon. + - Fixed various minor bugs. + - Renamed text files to match automake conventions. + +1.1.2: + - Fixed bugs in discrete logarithm domain parameter generator. The code to make a generator of order q and (p-1) was wrong. This was pointed out by Susumu Yamamoto. + - Added MD5 hash function. + +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. + - Shared library is now linked dynamically, with shared object name and version. + - Tested on Alpha Linux. + - Tested on Alpha FreeBSD. + - Added support for Compaq Alpha Tru64 Unix. + - Added initial support for QNX. + +1.1.0: + - Added glue for interfacing from BeeCrypt Java Cryptography Provider. + - Changed blockcipher struct to support interfacing with Java. + - Added better blockcipher IV handling. + - Multi-pass block processing is now possible with blockEncrypt/blockDecrypt. + - Updated config.sub and config.guess to latest version from sources.redhat.com + - Changed opening of entropy devices to blocking read-only mode instead of non-blocking read-write. + - Added win32 'wincrypt' entropy source. + - Added win32 'console' entropy source. + - Added FreeBSD support. + - Added PowerPC assembler optimized multiprecision subtraction routines. + - Added initial ia64 support. + - Added initial Darwin support (everything compiles, but the shared library doesn't build yet). + +1.0.2: + - Fixed Windows 2000 entropy bug; instead of using the first waveIn device, entropy now uses WAVE_MAPPER. + - Added sparcv9 mp32addsqrtrc GNU assembler routine. + - Added more hashFunctionContext and keyedHashFunctionContext functions. + +1.0.1: + - Added a sliding window modular exponentiation, about 30% faster than left-to-right exponentiation. + - Fixed bugs in fips180opt.gas.i586.s (Linux SHA-1 assembler code for Pentium/Pentium Pro) - the Windows/Metrowerks version was okay. + +1.0.0: + - Added Win32 support; compiled as DLL with MetroWerks CodeWarrior Pro 5, it runs fine on Windows 95, 98, NT 4.0 (if you have a soundcard with a microphone port). Note that there is a know issue on Windows 2000, see BUGS. + - Global code overhaul to support Win32 + - Added more assembler routines, including SHA-1 for Pentium Pro (60% faster) + - Added cleanup function to randomGenerator + - Added missing functions in endianness.c + - Fixed bug in entropy.c where devices might stay open + - Eliminated mutex.h include file; it was more clear to do everything conditionally than to expand the macros in this file to encompass the Win32 API calls. + +0.9.5: + - Added PowerPC assembler optimization for multiprecision integers, 80% faster on our PowerMac 7200/90 + - Fixed /dev/random entropy provider + - Changed name SHA1 to SHA-1 in fips180 for consistency + +0.9.4a: + - Added missing file 'blowfishopt.o' + +0.9.4: + - Changes to configure script, to distinguish between different processors of the x86 family + - Changes to blowfish code, 586/686 assembler optimization added, 30% faster on Pentium/PentiumPro + - Changes to blowfish code, eliminated static blowfishSetupEncrypt; incorporated into regular encrypt + - Changes to Makefile to selectively use blowfish assember code, depending on cpu type + - Added missing routines 'mp32bzero' and 'mp32bnpowmod' to mp32barrett.c + - Fixed 'const register' to 'register const' in mp32.c + - Minor fixes in included header files + +0.9.3: + - Initial public release diff --git a/beecrypt/README b/beecrypt/README new file mode 100644 index 0000000..835bf9c --- /dev/null +++ b/beecrypt/README @@ -0,0 +1,109 @@ +Welcome to the BeeCrypt crypto library! + +Copyright (c) 1997-2000 Virtual Unlimited B.V. + +Author: 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 + +For the specifics of this license, see file 'LICENSE', included in this +distribution. + + + +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. + +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 + + +Most of the algorithms are implemented from reliable sources such as: + +"Handbook of Applied Cryptography" + Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone + CRC Press + +"Applied Cryptography", second edition + 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. + + +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. + +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 + - multi-precision integer library, with assembler-optimized routines + - probabilistic primality testing, with optimized small prime trial division + - discrete logarithm parameter generation over a prime field + - Diffie-Hellman key agreement + - ElGamal signature scheme (two variants) + +Planned for the near future are: + - 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, ... ) + - Elliptic Curves (ECDSA, ... ) + +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) + - Linux glibc 2.x ppc + - includes assembler optimization (generic 32-bit PowerPC) + - Win32 (Windows 95, 98, NT 4.0) + - includes assembler optimization (tuned for Pentium Pro and higher) + - once the entropy provider bug is fixed (see BUGS), the library should + work fine on Windows 2000. +Planned platforms for the near future are: + - Solaris Intel + - FreeBSD x86 + +Consult file 'DOCUMENTATION' on how to use the library. There is also a program +called 'beetest.c' included which gives an example of how to use the API. You +can also use it to test whether your compiled library works. + +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 + +Sincerely + +Bob Deblier diff --git a/beecrypt/README.DLL b/beecrypt/README.DLL new file mode 100644 index 0000000..2131f87 --- /dev/null +++ b/beecrypt/README.DLL @@ -0,0 +1,37 @@ +File beetest.exe is a compiled version of the test program included in +the source distribution, which you can find on our website: +http://beecrypt.virtualunlimited.com/ + +To run, it needs file beecrypt.dll present in the same directory. + +For Developers: + +Files beecrypt.dll and beecrypt.lib are a pre-compiled version of the +BeeCrypt library for Pentium Pro processors. + +If you want to develop applications with this library, you'll also need +the header files, included in the source distribution (see higher). + +Please make sure you respect the term of the license under which the +BeeCrypt library is released: + +Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V. + +Author: 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 + +For the specifics of this license, see file 'COPYING', included in this +distribution. diff --git a/beecrypt/README.WIN32 b/beecrypt/README.WIN32 new file mode 100644 index 0000000..411116f --- /dev/null +++ b/beecrypt/README.WIN32 @@ -0,0 +1,43 @@ +This file contains information on how to build and use the BeeCrypt DLL on +Win32 platforms. + +The platform of preference is currently MicroSoft Visual C++ 6.0, but +Metrowerks CodeWarrior is also still supported. + +To be able to use the assembler files with Visual C++, you need to have the +Visual C++ 6.0 Processor Pack installed. It can be found at: + +http://msdn.microsoft.com/vstudio/downloads/ppack/default.asp + +To be able to use the assembler files with Metrowerks CodeWarrior, you will +need to install an unsupported (but working for the included files) assembler +plug-in, which can be found on the CodeWarrior download page. + +To build the java glue into the DLL, you should also have Sun's JDK 1.3, +including the JNI headers, installed. + +Make sure all Visual C++ tools can be found on the path, i.e.: + +cl.exe (the compiler) +ml.exe (the assembler) +link.exe (the linker) +nmake.exe (the make utility) + +For convenience, copy file 'Makefile.mak' to 'Makefile' and adjust paths as +required. The Makefile assumes you will be building in support for java. +If this is not the case, you will have to adjust the Makefile, which shouldn't +be too difficult. + +Next, run 'nmake' and the library and the test program will be built. + +Once running, you can use any of three entropy source available on this +platform, in order of preference: + +wavein (uses noise on the soundcard microphone port) +console (uses keyboard clicks with a high resolution timer) +wincrypt (uses random data generated by the Windows CryptAPI) + +To enable a specific entropy device, set variable BEECRYPT_ENTROPY to any of +these three values; if not specified, the library will use 'wavein' as default. + +In the future, additional sources of entropy on this platform will be made available. diff --git a/beecrypt/acconfig.h b/beecrypt/acconfig.h new file mode 100644 index 0000000..961cf8c --- /dev/null +++ b/beecrypt/acconfig.h @@ -0,0 +1,118 @@ +/* + * acconfig.h + * + * acconfig.h pre-announces symbols defines by configure.in + * + * Copyright (c) 2001 Virtual Unlimited B.V. + * + * Author: 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 _REENTRANT +#define _REENTRANT +#endif + +#undef PACKAGE +#undef VERSION + +#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 HAVE_ERRNO_H +#undef HAVE_STRING_H +#undef HAVE_CTYPE_H +#undef HAVE_STDLIB_H +#undef HAVE_MTMALLOC_H + +#undef HAVE_UNISTD_H +#undef HAVE_FCNTL_H + +#undef HAVE_TIME_H + +#undef HAVE_SYS_TYPES_H +#undef HAVE_SYS_STAT_H +#undef HAVE_SYS_TIME_H + +#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_TERMIO_H +#undef HAVE_TERMIOS_H + +#undef HAVE_SYS_AUDIOIO_H +#undef HAVE_SYS_IOCTL_H +#undef HAVE_SYS_SOUNDCARD_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 diff --git a/beecrypt/aclocal.m4 b/beecrypt/aclocal.m4 new file mode 100644 index 0000000..f2a44c4 --- /dev/null +++ b/beecrypt/aclocal.m4 @@ -0,0 +1,540 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4 + +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 1 + +dnl Usage: +dnl AM_INIT_AUTOMAKE(package,version, [no-define]) + +AC_DEFUN(AM_INIT_AUTOMAKE, +[AC_REQUIRE([AC_PROG_INSTALL]) +PACKAGE=[$1] +AC_SUBST(PACKAGE) +VERSION=[$2] +AC_SUBST(VERSION) +dnl test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi +ifelse([$3],, +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) +AC_REQUIRE([AM_SANITY_CHECK]) +AC_REQUIRE([AC_ARG_PROGRAM]) +dnl FIXME This is truly gross. +missing_dir=`cd $ac_aux_dir && pwd` +AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) +AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) +AC_REQUIRE([AC_PROG_MAKE_SET])]) + +# +# Check to make sure that the build environment is sane. +# + +AC_DEFUN(AM_SANITY_CHECK, +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "[$]*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "[$]*" != "X $srcdir/configure conftestfile" \ + && test "[$]*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "[$]2" = conftestfile + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +rm -f conftest* +AC_MSG_RESULT(yes)]) + +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) +dnl The program must properly implement --version. +AC_DEFUN(AM_MISSING_PROG, +[AC_MSG_CHECKING(for working $2) +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if ($2 --version) < /dev/null > /dev/null 2>&1; then + $1=$2 + AC_MSG_RESULT(found) +else + $1="$3/missing $2" + AC_MSG_RESULT(missing) +fi +AC_SUBST($1)]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +AC_DEFUN(AM_CONFIG_HEADER, +[AC_PREREQ([2.12]) +AC_CONFIG_HEADER([$1]) +dnl When config.status generates a header, we must update the stamp-h file. +dnl This file resides in the same directory as the config header +dnl that is generated. We must strip everything past the first ":", +dnl and everything past the last "/". +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, +<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<>; do + case " <<$>>CONFIG_HEADERS " in + *" <<$>>am_file "*<<)>> + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx + ;; + esac + am_indx=`expr "<<$>>am_indx" + 1` +done<<>>dnl>>) +changequote([,]))]) + + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and INCLTDL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and INCLTDL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + diff --git a/beecrypt/base64.c b/beecrypt/base64.c new file mode 100644 index 0000000..c5a9b2a --- /dev/null +++ b/beecrypt/base64.c @@ -0,0 +1,241 @@ +/* + * base64.c + * + * Base64 encoding/decoding, code + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "base64.h" + +#if HAVE_STDLIB_H +#include +#endif +#if HAVE_STRING_H +#include +#endif +#if HAVE_CTYPE_H +#include +#endif + +static const char* to_b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +/* encode 72 characters per line */ +#define CHARS_PER_LINE 72 + +char* b64enc(const memchunk* chunk) +{ + int div = chunk->size / 3; + int rem = chunk->size % 3; + int chars = div*4 + rem + 1; + int newlines = (chars + CHARS_PER_LINE - 1) / CHARS_PER_LINE; + + const byte* data = chunk->data; + char* string = (char*) malloc(chars + newlines + 1); + + if (string) + { + register char* buf = string; + + chars = 0; + + while (div > 0) + { + buf[0] = to_b64[ (data[0] >> 2) & 0x3f]; + buf[1] = to_b64[((data[0] << 4) & 0x30) + ((data[1] >> 4) & 0xf)]; + buf[2] = to_b64[((data[1] << 2) & 0x3c) + ((data[2] >> 6) & 0x3)]; + buf[3] = to_b64[ data[2] & 0x3f]; + data += 3; + buf += 4; + div--; + chars += 4; + if (chars == CHARS_PER_LINE) + { + chars = 0; + *(buf++) = '\n'; + } + } + + switch (rem) + { + case 2: + buf[0] = to_b64[ (data[0] >> 2) & 0x3f]; + buf[1] = to_b64[((data[0] << 4) & 0x30) + ((data[1] >> 4) & 0xf)]; + buf[2] = to_b64[ (data[1] << 2) & 0x3c]; + buf[3] = '='; + buf += 4; + chars += 4; + break; + case 1: + buf[0] = to_b64[ (data[0] >> 2) & 0x3f]; + buf[1] = to_b64[ (data[0] << 4) & 0x30]; + buf[2] = '='; + buf[3] = '='; + buf += 4; + chars += 4; + break; + } + + *(buf++) = '\n'; + *buf = '\0'; + } + + return string; +} + +memchunk* b64dec(const char* string) +{ + /* return a decoded memchunk, or a null pointer in case of failure */ + + memchunk* rc = 0; + + if (string) + { + register int length = strlen(string); + + /* do a format verification first */ + if (length > 0) + { + register int count = 0, rem = 0; + register const char* tmp = string; + + while (length > 0) + { + register int skip = strspn(tmp, to_b64); + count += skip; + length -= skip; + tmp += skip; + if (length > 0) + { + register int i, vrfy = strcspn(tmp, to_b64); + + for (i = 0; i < vrfy; i++) + { + if (isspace(tmp[i])) + continue; + + if (tmp[i] == '=') + { + /* we should check if we're close to the end of the string */ + rem = count % 4; + + /* rem must be either 2 or 3, otherwise no '=' should be here */ + if (rem < 2) + return 0; + + /* end-of-message recognized */ + break; + } + else + { + /* Transmission error; RFC tells us to ignore this, but: + * - the rest of the message is going to even more corrupt since we're sliding bits out of place + * If a message is corrupt, it should be dropped. Period. + */ + + return 0; + } + } + + length -= vrfy; + tmp += vrfy; + } + } + + rc = (memchunk*) malloc(sizeof(memchunk)); + + if (rc) + { + rc->size = (count / 4) * 3 + (rem ? (rem - 1) : 0); + if (count > 0) + { + rc->data = (byte*) malloc(rc->size); + + if (rc->data) + { + register int i, qw = 0, tw = 0; + register byte* data = rc->data; + + length = strlen(tmp = string); + + for (i = 0; i < length; i++) + { + register char ch = string[i]; + register byte bits; + + if (isspace(ch)) + continue; + + if ((ch >= 'A') && (ch <= 'Z')) + { + bits = (byte) (ch - 'A'); + } + else if ((ch >= 'a') && (ch <= 'z')) + { + bits = (byte) (ch - 'a' + 26); + } + else if ((ch >= '0') && (ch <= '9')) + { + bits = (byte) (ch - '0' + 52); + } + else if (ch == '=') + break; + + switch (qw++) + { + case 0: + data[tw+0] = (bits << 2) & 0xfc; + break; + case 1: + data[tw+0] |= (bits >> 4) & 0x03; + data[tw+1] = (bits << 4) & 0xf0; + break; + case 2: + data[tw+1] |= (bits >> 2) & 0x0f; + data[tw+2] = (bits << 6) & 0xc0; + break; + case 3: + data[tw+2] |= bits & 0x3f; + break; + } + + if (qw == 4) + { + qw = 0; + tw += 3; + } + } + } + else + { + free(rc); + rc = (memchunk*) 0; + } + } + else + rc->data = (byte*) 0; + } + } + } + + return rc; +} diff --git a/beecrypt/base64.h b/beecrypt/base64.h new file mode 100644 index 0000000..0566768 --- /dev/null +++ b/beecrypt/base64.h @@ -0,0 +1,44 @@ +/* + * base64.h + * + * Base64 encoding/decoding, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _BASE64_H +#define _BASE64_H + +#include "beecrypt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +char* b64enc(const memchunk*); +BEEDLLAPI +memchunk* b64dec(const char*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/beecrypt.c b/beecrypt/beecrypt.c new file mode 100644 index 0000000..524edee --- /dev/null +++ b/beecrypt/beecrypt.c @@ -0,0 +1,319 @@ +/* + * beecrypt.c + * + * BeeCrypt library hooks & stubs, code + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "beecrypt.h" + +#if HAVE_STDLIB_H +#include +#endif +#if HAVE_STRING_H +#include +#endif + +#include "entropy.h" +#include "fips180.h" +#include "fips186.h" +#include "mtprng.h" +#include "sha1hmac.h" + +#include "blowfish.h" +#include "blockmode.h" + +static entropySource entropySourceList[] = +{ +#if WIN32 + { "wavein", entropy_wavein }, +#else +# if HAVE_DEV_AUDIO + { "audio", entropy_dev_audio }, +# endif +# if HAVE_DEV_DSP + { "dsp", entropy_dev_dsp }, +# endif +# if HAVE_DEV_RANDOM + { "random", entropy_dev_random }, +# endif +# if HAVE_DEV_TTY + { "tty", entropy_dev_tty }, +# endif +#endif +}; + +#define ENTROPYSOURCES (sizeof(entropySourceList) / sizeof(entropySource)) + +int entropySourceCount() +{ + return ENTROPYSOURCES; +} + +const entropySource* entropySourceGet(int index) +{ + if ((index < 0) || (index >= ENTROPYSOURCES)) + return (const entropySource*) 0; + + return entropySourceList+index; +} + +const entropySource* entropySourceFind(const char* name) +{ + register int index; + + for (index = 0; index < ENTROPYSOURCES; index++) + { + if (strcmp(name, entropySourceList[index].name) == 0) + return entropySourceList+index; + } + return (const entropySource*) 0; +} + +const entropySource* entropySourceDefault() +{ + char* tmp = getenv("BEECRYPT_ENTROPY"); + if (tmp) + { + return entropySourceFind(tmp); + } + else if (ENTROPYSOURCES) + { + return entropySourceList+0; + } + return (const entropySource*) 0; +} + +static const randomGenerator* randomGeneratorList[] = +{ + &fips186prng, + &mtprng +}; + +#define RANDOMGENERATORS (sizeof(randomGeneratorList) / sizeof(randomGenerator*)) + +int randomGeneratorCount() +{ + return RANDOMGENERATORS; +} + +const randomGenerator* randomGeneratorGet(int index) +{ + if ((index < 0) || (index >= RANDOMGENERATORS)) + return (const randomGenerator*) 0; + + return randomGeneratorList[index]; +} + +const randomGenerator* randomGeneratorFind(const char* name) +{ + register int index; + + for (index = 0; index < RANDOMGENERATORS; index++) + { + if (strcmp(name, randomGeneratorList[index]->name) == 0) + return randomGeneratorList[index]; + } + return (const randomGenerator*) 0; +} + +const randomGenerator* randomGeneratorDefault() +{ + char* tmp = getenv("BEECRYPT_RANDOM"); + + if (tmp) + return randomGeneratorFind(tmp); + else + return &fips186prng; +} + +void randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng) +{ + ctxt->rng = rng; + ctxt->param = malloc(rng->paramsize); +} + +void randomGeneratorContextFree(randomGeneratorContext* ctxt) +{ + free(ctxt->param); +} + +static const hashFunction* hashFunctionList[] = +{ + &sha1 +}; + +#define HASHFUNCTIONS (sizeof(hashFunctionList) / sizeof(hashFunction*)) + +int hashFunctionCount() +{ + return HASHFUNCTIONS; +} + +const hashFunction* hashFunctionDefault() +{ + char* tmp = getenv("BEECRYPT_HASH"); + if (tmp) + return hashFunctionFind(tmp); + else + return &sha1; +} + +const hashFunction* hashFunctionGet(int index) +{ + if ((index < 0) || (index >= HASHFUNCTIONS)) + return (const hashFunction*) 0; + + return hashFunctionList[index]; +} + +const hashFunction* hashFunctionFind(const char* name) +{ + register int index; + + for (index = 0; index < HASHFUNCTIONS; index++) + { + if (strcmp(name, hashFunctionList[index]->name) == 0) + return hashFunctionList[index]; + } + return (const hashFunction*) 0; +} + +void hashFunctionContextInit(hashFunctionContext* ctxt, const hashFunction* hash) +{ + ctxt->hash = hash; + ctxt->param = malloc(hash->paramsize); +} + +void hashFunctionContextFree(hashFunctionContext* ctxt) +{ + free(ctxt->param); +} + + +static const keyedHashFunction* keyedHashFunctionList[] = +{ + &sha1hmac +}; + +#define KEYEDHASHFUNCTIONS (sizeof(keyedHashFunctionList) / sizeof(keyedHashFunction*)) + +int keyedHashFunctionCount() +{ + return KEYEDHASHFUNCTIONS; +} + +const keyedHashFunction* keyedHashFunctionDefault() +{ + char* tmp = getenv("BEECRYPT_KEYEDHASH"); + if (tmp) + return keyedHashFunctionFind(tmp); + else + return (const keyedHashFunction*) 0; +} + +const keyedHashFunction* keyedHashFunctionGet(int index) +{ + if ((index < 0) || (index >= KEYEDHASHFUNCTIONS)) + return (const keyedHashFunction*) 0; + + return keyedHashFunctionList[index]; +} + +const keyedHashFunction* keyedHashFunctionFind(const char* name) +{ + register int index; + + for (index = 0; index < KEYEDHASHFUNCTIONS; index++) + { + if (strcmp(name, keyedHashFunctionList[index]->name) == 0) + return keyedHashFunctionList[index]; + } + return (const keyedHashFunction*) 0; +} + +void keyedHashFunctionContextInit(keyedHashFunctionContext* ctxt, const keyedHashFunction* hash) +{ + ctxt->hash = hash; + ctxt->param = malloc(hash->paramsize); +} + +void keyedHashFunctionContextFree(keyedHashFunctionContext* ctxt) +{ + free(ctxt->param); +} + + +static const blockCipher* blockCipherList[] = +{ + &blowfish, +}; + +#define BLOCKCIPHERS (sizeof(blockCipherList) / sizeof(blockCipher*)) + +int blockCipherCount() +{ + return BLOCKCIPHERS; +} + +const blockCipher* blockCipherDefault() +{ + char* tmp = getenv("BEECRYPT_CIPHER"); + + if (tmp) + return blockCipherFind(tmp); + else + return &blowfish; +} + +const blockCipher* blockCipherGet(int index) +{ + if ((index < 0) || (index >= BLOCKCIPHERS)) + return (const blockCipher*) 0; + + return blockCipherList[index]; +} + +const blockCipher* blockCipherFind(const char* name) +{ + register int index; + + for (index = 0; index < BLOCKCIPHERS; index++) + { + if (strcmp(name, blockCipherList[index]->name) == 0) + return blockCipherList[index]; + } + + return (const blockCipher*) 0; +} + +void blockCipherContextInit(blockCipherContext* ctxt, const blockCipher* ciph) +{ + ctxt->ciph = ciph; + ctxt->param = malloc(ciph->paramsize); +} + +void blockCipherContextFree(blockCipherContext* ctxt) +{ + free(ctxt->param); +} diff --git a/beecrypt/beecrypt.def b/beecrypt/beecrypt.def new file mode 100644 index 0000000..3a8af13 --- /dev/null +++ b/beecrypt/beecrypt.def @@ -0,0 +1,325 @@ +; +; beecrypt.def +; +; BeeCrypt DLL exports +; +; Copyright (c) 2000, 2001 Virtual Unlimited B.V. +; +; Author: 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 +; + +LIBRARY beecrypt + +EXPORTS + DllMain + b64enc + b64dec + blockCipherContextFree + blockCipherContextInit + blockCipherContextSetup + blockCipherContextSetIV + blockCipherCount + blockCipherDefault + blockCipherFind + blockCipherGet + blockEncrypt + blockDecrypt + blowfish data + blowfishCBCEncrypt + blowfishCBCDecrypt + blowfishDecrypt + blowfishECBEncrypt + blowfishECBDecrypt + blowfishEncrypt + blowfishSetup + decodeByte + decodeChar + decodeChars + decodeDouble + decodeFloat + decodeInt + decodeInts + decodeLong + decodeShort + dhaes_pContextDecrypt + dhaes_pContextEncrypt + dhaes_pContextFree + dhaes_pContextInit + dhaes_pContextInitDecrypt + dhaes_pContextInitEncrypt + dhaes_pUsable + dldp_pCopy + dldp_pEqual + dldp_pFree + dldp_pInit + dldp_pPair + dldp_pPrivate + dldp_pPublic + dldp_pgonGenerator + dldp_pgonMake + dldp_pgonMakeSafe + dldp_pgonValidate + dldp_pgoqGenerator + dldp_pgoqMake + dldp_pgoqMakeSafe + dldp_pgoqValidate + dlkp_pCopy + dlkp_pFree + dlkp_pInit + dlkp_pPair + dlpk_pCopy + dlpk_pEqual + dlpk_pFree + dlpk_pInit + dlpk_pgoqValidate + dlpk_pgonValidate + dlsvdp_pDHSecret + elgv1sign + elgv1vrfy + elgv3sign + elgv3vrfy + encodeByte + encodeChar + encodeChars + encodeDouble + encodeFloat + encodeInt + encodeInts + encodeIntsPartial + encodeLong + encodeShort + entropyGatherNext + entropySourceCount + entropySourceDefault + entropySourceFind + entropySourceGet + fips186Cleanup + fips186Next + fips186Seed + fips186Setup + fips186prng data + hashFunctionContextDigest + hashFunctionContextDigestMatch + hashFunctionContextFree + hashFunctionContextInit + hashFunctionContextUpdate + hashFunctionContextUpdateMC + hashFunctionContextUpdateMP32 + hashFunctionCount + hashFunctionDefault + hashFunctionFind + hashFunctionGet + hmacDigest + hmacReset + hmacSetup + hmacUpdate + hmacmd5 data + hmacmd5Digest + hmacmd5Reset + hmacmd5Setup + hmacmd5Update + hmacsha1 data + hmacsha1Digest + hmacsha1Reset + hmacsha1Setup + hmacsha1Update + hmacsha256 data + hmacsha256Digest + hmacsha256Reset + hmacsha256Setup + hmacsha256Update + keyedHashFunctionContextDigest + keyedHashFunctionContextDigestMatch + keyedHashFunctionContextFree + keyedHashFunctionContextInit + keyedHashFunctionContextSetup + keyedHashFunctionContextUpdate + keyedHashFunctionContextUpdateMC + keyedHashFunctionContextUpdateMP32 + keyedHashFunctionCount + keyedHashFunctionDefault + keyedHashFunctionFind + keyedHashFunctionGet + md5 data + md5Process + md5Reset + md5Update + md5Digest + memchunkAlloc + memchunkFree + memchunkResize + ;mp32copy + ;mp32move + mp32zero + mp32fill + mp32odd + mp32even + mp32z + mp32nz + mp32eq + mp32ne + mp32gt + mp32lt + mp32ge + mp32le + mp32eqx + mp32nex + mp32gtx + mp32ltx + mp32gex + mp32lex + mp32isone + mp32leone + mp32eqmone + mp32msbset + mp32lsbset + mp32setmsb + mp32setlsb + mp32clrmsb + mp32clrlsb + mp32xor + mp32not + mp32setw + mp32setx + mp32addw + mp32add + mp32addx + mp32subw + mp32sub + mp32subx + mp32multwo + mp32neg + mp32size + mp32mszcnt + mp32lszcnt + mp32lshift + mp32rshift + mp32norm + mp32divpowtwo + mp32divtwo + mp32sdivtwo + mp32setmul + mp32addmul + mp32addsqrtrc + mp32mul + mp32sqr + mp32gcd_w + mp32nmodw + mp32nmod + mp32ndivmod + mp32print + mp32println + mp32bzero + mp32binit + mp32bfree + mp32bcopy + mp32bset + mp32bsethex + mp32bsubone + mp32bneg + mp32bmu_w + mp32brnd_w + mp32brndinv_w + mp32bmod_w + mp32baddmod_w + ;mp32bsubmod_w + mp32bmulmod_w + mp32bsqrmod_w + mp32bpowmod_w + mp32bpowmodsld_w + mp32btwopowmod_w + ;mp32bsm2powmod + ;mp32bsm3powmod + mp32binv_w + mp32bnrnd + mp32bnmulmod + mp32bnsqrmod + mp32bnpowmod + mp32bnpowmodsld + mp32bnsqrmod + mp32ptrials + mp32pmilrab_w + mp32bpprime_w + mp32prnd_w + ;mp32prndcon + mp32prndconone_w + mp32prndsafe_w + mp32nzero + mp32nsize + mp32ninit + mp32nfree + mp32ncopy + mp32nset + mp32nsetw + mp32nsethex + mp32nwipe + mtprng data + mtprngCleanup + mtprngNext + mtprngSeed + mtprngSetup + pkcs5Pad + pkcs5PadCopy + pkcs5Unpad + pkcs5UnpadCopy + randomGeneratorCount + randomGeneratorGet + randomGeneratorFind + randomGeneratorDefault + randomGeneratorContextInit + randomGeneratorContextFree + rsapri + rsapricrt + rsavrfy + rsakpMake + rsakpInit + rsakpFree + rsakpCopy + rsapkInit + rsapkFree + rsapkCopy + readByte + readChar + readChars + readInt + readInts + readLong + readShort + sha1 data + sha1Process + sha1Reset + sha1Update + sha1Digest + sha256 data + sha256Process + sha256Reset + sha256Update + sha256Digest + swap16 + swap32 + swap64 + swapu16 + swapu32 + ;swapu64 + timestamp + writeByte + writeChar + writeChars + writeInt + writeInts + writeLong + writeShort diff --git a/beecrypt/beecrypt.h b/beecrypt/beecrypt.h new file mode 100644 index 0000000..a139ca6 --- /dev/null +++ b/beecrypt/beecrypt.h @@ -0,0 +1,591 @@ +/* + * beecrypt.h + * + * Beecrypt library hooks & stubs, header + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 _BEECRYPT_H +#define _BEECRYPT_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +typedef struct +{ + int size; + byte* data; +} memchunk; + +/* + * Entropy Sources + */ + +typedef int (*entropyNext)(uint32*, int); + +/* + * The struct 'entropySource' holds information and pointers to code specific + * to each entropy source. Each specific entropy source MUST be written to be + * multithread-safe. + * + * The struct contains the following function(s): + * + * int (*next)(uint32* data, int size); + * + * This function will fill an array of 32-bit unsigned integers of given size + * with entropy. + * Return value is 0 on success, or -1 on failure. + */ + +typedef struct +{ + const char* name; + const entropyNext next; +} entropySource; + +/* + * You can use the following functions to find entropy sources implemented by + * the library: + * + * entropySourceCount returns the number of sources available. + * + * entropySourceGet returns the entropy source with a given index (starting + * at zero, up to entropySourceCount() - 1), or NULL if the index was out of + * bounds. + * + * entropySourceFind returns the entropy source with the given name, or NULL + * if no entropy source exists with that name. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int entropySourceCount(); +BEEDLLAPI +const entropySource* entropySourceGet(int); +BEEDLLAPI +const entropySource* entropySourceFind(const char*); +BEEDLLAPI +const entropySource* entropySourceDefault(); + +#ifdef __cplusplus +} +#endif + +/* + * Pseudo-random Number Generators + */ + +typedef void randomGeneratorParam; + +typedef int (*randomGeneratorSetup )(randomGeneratorParam*); +typedef int (*randomGeneratorSeed )(randomGeneratorParam*, const uint32*, int); +typedef int (*randomGeneratorNext )(randomGeneratorParam*, uint32*, int); +typedef int (*randomGeneratorCleanup)(randomGeneratorParam*); + +/* + * The struct 'randomGenerator' holds information and pointers to code specific + * to each random generator. Each specific random generator MUST be written to + * be multithread safe. + * + * WARNING: each randomGenerator, when used in cryptographic applications, MUST + * be guaranteed to be of suitable quality and strength (i.e. don't use the + * random() function found in most UN*X-es). + * + * Multiple instances of each randomGenerator can be used (even concurrently), + * provided they each use their own randomGeneratorParam parameters, a chunk + * of memory which must be at least as large as indicated by the paramsize + * field. + * + * The struct contains the following function(s): + * + * int (*setup)(randomGeneratorParam* param); + * + * This function will initialize the parameters for use, and seed the generator + * with entropy from the default entropy source. + * Return value is 0 on success, or -1 on failure. + * + * int (*seed)(randomGeneratorParam* param, const uint32* data, int size); + * + * This function reseeds the random generator with user-provided entropy. + * Return value is 0 on success, or -1 on failure. + * + * int (*next)(randomGeneratorParam* param, uint32* data, int size); + * + * This function will fill an array of 32-bit unsigned integers of given size + * with pseudo-random data. + * Return value is 0 on success, or -1 on failure. + * + * int (*cleanup)(randomGeneratorParam* param); + * + * This function will cleanup after the use of a generator + * Return value is 0 on success, or -1 on failure. + */ + +typedef struct +{ + const char* name; + const int paramsize; + const randomGeneratorSetup setup; + const randomGeneratorSeed seed; + const randomGeneratorNext next; + const randomGeneratorCleanup cleanup; +} randomGenerator; + +/* + * You can use the following functions to find random generators implemented by + * the library: + * + * randomGeneratorCount returns the number of generators available. + * + * randomGeneratorGet returns the random generator with a given index (starting + * at zero, up to randomGeneratorCount() - 1), or NULL if the index was out of + * bounds. + * + * randomGeneratorFind returns the random generator with the given name, or + * NULL if no random generator exists with that name. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int randomGeneratorCount(); +BEEDLLAPI +const randomGenerator* randomGeneratorGet(int); +BEEDLLAPI +const randomGenerator* randomGeneratorFind(const char*); +BEEDLLAPI +const randomGenerator* randomGeneratorDefault(); + +#ifdef __cplusplus +} +#endif + +/* + * The struct 'randomGeneratorContext' is used to contain both the functional + * part (the randomGenerator), and its parameters. + */ + +typedef struct +{ + const randomGenerator* rng; + randomGeneratorParam* param; +} randomGeneratorContext; + +/* + * The following functions can be used to initialize and free a + * randomGeneratorContext. Initializing will allocate a buffer of the size + * required by the randomGenerator, freeing will deallocate that buffer. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void randomGeneratorContextInit(randomGeneratorContext*, const randomGenerator*); +BEEDLLAPI +void randomGeneratorContextFree(randomGeneratorContext*); + +#ifdef __cplusplus +} +#endif + +/* + * Hash Functions + */ + +typedef void hashFunctionParam; + +typedef int (*hashFunctionReset )(hashFunctionParam*); +typedef int (*hashFunctionUpdate)(hashFunctionParam*, const byte*, int); +typedef int (*hashFunctionDigest)(hashFunctionParam*, uint32*); + +/* + * The struct 'hashFunction' holds information and pointers to code specific + * to each hash function. Specific hash functions MAY be written to be + * multithread-safe. + * + * The struct contains the following function(s): + * + * int (*reset)(hashFunctionParam* param); + * + * This function will re-initialize the parameters of this hash function. + * Return value is 0 on success, or -1 on failure. + * + * int (*update)(hashFunctionParam* param, const byte* data, int size); + * + * This function updates the hash function with an array of bytes. + * Return value is 0 on success, or -1 on failure. + * + * int (*digest)(hashFunctionParam* param, uint32* data); + * + * This function computes the digest of all the data passed to the hash + * function, and stores the result in data. + * Return value is 0 on success, or -1 on failure. + * NOTE: data must be at least have a bytesize of 'digestsize' as described + * in the hashFunction struct. + * NOTE: for safety reasons, after calling digest, each specific implementation + * MUST reset itself so that previous values in the parameters are erased. + */ + +typedef struct +{ + const char* name; + const int paramsize; /* in bytes */ + const int digestsize; /* in bytes */ + const hashFunctionReset reset; + const hashFunctionUpdate update; + const hashFunctionDigest digest; +} hashFunction; + +/* + * You can use the following functions to find hash functions implemented by + * the library: + * + * hashFunctionCount returns the number of hash functions available. + * + * hashFunctionGet returns the hash function with a given index (starting + * at zero, up to hashFunctionCount() - 1), or NULL if the index was out of + * bounds. + * + * hashFunctionFind returns the hash function with the given name, or + * NULL if no hash function exists with that name. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int hashFunctionCount(); +BEEDLLAPI +const hashFunction* hashFunctionGet(int); +BEEDLLAPI +const hashFunction* hashFunctionFind(const char*); +BEEDLLAPI +const hashFunction* hashFunctionDefault(); + +#ifdef __cplusplus +} +#endif + +/* + * The struct 'hashFunctionContext' is used to contain both the functional + * part (the hashFunction), and its parameters. + */ + +typedef struct +{ + const hashFunction* hash; + hashFunctionParam* param; +} hashFunctionContext; + +/* + * The following functions can be used to initialize and free a + * hashFunctionContext. Initializing will allocate a buffer of the size + * required by the hashFunction, freeing will deallocate that buffer. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void hashFunctionContextInit(hashFunctionContext*, const hashFunction*); +BEEDLLAPI +void hashFunctionContextFree(hashFunctionContext*); + +#ifdef __cplusplus +} +#endif + +/* + * Keyed Hash Functions, a.k.a. Message Authentication Codes + */ + +typedef void keyedHashFunctionParam; + +typedef int (*keyedHashFunctionSetup )(keyedHashFunctionParam*, const uint32*, int); +typedef int (*keyedHashFunctionReset )(keyedHashFunctionParam*); +typedef int (*keyedHashFunctionUpdate )(keyedHashFunctionParam*, const byte*, int); +typedef int (*keyedHashFunctionDigest )(keyedHashFunctionParam*, uint32*); + +/* + * The struct 'keyedHashFunction' holds information and pointers to code + * specific to each keyed hash function. Specific keyed hash functions MAY be + * written to be multithread-safe. + * + * The struct field 'keybitsmin' contains the minimum number of bits a key + * must contains, 'keybitsmax' the maximum number of bits a key may contain, + * 'keybitsinc', the increment in bits that may be used between min and max. + * + * The struct contains the following function(s): + * + * int (*setup)(keyedHashFunctionParam *param, const uint32* key, int keybits); + * + * This function will setup the keyed hash function parameters with the given + * secret key; it will also 'reset' the parameters. + * Return value is 0 on success, or -1 on failure. + * NOTE: after use, it is recommended to wipe the parameters by calling setup + * again with another (dummy) key. + * + * int (*reset)(keyedHashFunctionParam* param); + * + * This function will re-initialize the parameters of this keyed hash function. + * Return value is 0 on success, or -1 on failure. + * + * int (*update)(keyedHashFunctionParam* param, const byte* data, int size); + * + * This function updates the keyed hash function with an array of bytes. + * Return value is 0 on success, or -1 on failure. + * + * int (*digest)(keyedHashFunctionParam* param, uint32* data); + * + * This function computes the digest (or authentication code) of all the data + * passed to the keyed hash function, and stores the result in data. + * Return value is 0 on success, or -1 on failure. + * NOTE: data must be at least have a bytesize of 'digestsize' as described + * in the keyedHashFunction struct. + * NOTE: for safety reasons, after calling digest, each specific implementation + * MUST reset itself so that previous values in the parameters are erased. + */ + +typedef struct +{ + const char* name; + const int paramsize; /* in bytes */ + const int digestsize; /* in bytes */ + const int keybitsmin; /* in bits */ + const int keybitsmax; /* in bits */ + const int keybitsinc; /* in bits */ + const keyedHashFunctionSetup setup; + const keyedHashFunctionReset reset; + const keyedHashFunctionUpdate update; + const keyedHashFunctionDigest digest; +} keyedHashFunction; + +/* + * You can use the following functions to find keyed hash functions implemented + * by the library: + * + * keyedHashFunctionCount returns the number of keyed hash functions available. + * + * keyedHashFunctionGet returns the random generator with a given index + * (starting at zero, up to keyedHashFunctionCount() - 1), or NULL if the index + * was out of bounds. + * + * keyedHashFunctionFind returns the keyed hash function with the given name, + * or NULL if no keyed hash function exists with that name. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int keyedHashFunctionCount(); +BEEDLLAPI +const keyedHashFunction* keyedHashFunctionGet(int); +BEEDLLAPI +const keyedHashFunction* keyedHashFunctionFind(const char*); +BEEDLLAPI +const keyedHashFunction* keyedHashFunctionDefault(); + +#ifdef __cplusplus +} +#endif + +/* + * The struct 'keyedHashFunctionContext' is used to contain both the functional + * part (the keyedHashFunction), and its parameters. + */ + +typedef struct +{ + const keyedHashFunction* hash; + keyedHashFunctionParam* param; +} keyedHashFunctionContext; + +/* + * The following functions can be used to initialize and free a + * keyedHashFunctionContext. Initializing will allocate a buffer of the size + * required by the keyedHashFunction, freeing will deallocate that buffer. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void keyedHashFunctionContextInit(keyedHashFunctionContext*, const keyedHashFunction*); +BEEDLLAPI +void keyedHashFunctionContextFree(keyedHashFunctionContext*); + +#ifdef __cplusplus +} +#endif + +/* + * Block ciphers + */ + +typedef enum +{ + ENCRYPT, + DECRYPT +} cipherOperation; + +typedef enum +{ + ECB, + CBC +} cipherMode; + +typedef void blockCipherParam; + +typedef int (*blockModeEncrypt)(blockCipherParam*, int, uint32*, const uint32*, const uint32*); +typedef int (*blockModeDecrypt)(blockCipherParam*, int, uint32*, const uint32*, const uint32*); + +typedef struct +{ + const blockModeEncrypt encrypt; + const blockModeDecrypt decrypt; +} blockMode; + +typedef int (*blockCipherSetup )(blockCipherParam*, const uint32*, int, cipherOperation); +typedef int (*blockCipherEncrypt)(blockCipherParam*, uint32 *); +typedef int (*blockCipherDecrypt)(blockCipherParam*, uint32 *); + +/* + * The struct 'blockCipher' holds information and pointers to code specific + * to each blockcipher. Specific block ciphers MAY be written to be + * multithread-safe. + * + * The struct field 'keybitsmin' contains the minimum number of bits a key + * must contains, 'keybitsmax' the maximum number of bits a key may contain, + * 'keybitsinc', the increment in bits that may be used between min and max. + * + * The struct contains the following function(s): + * + * int (*setup)(blockCipherParam *param, const uint32* key, int keybits, cipherOperation); + * + * This function will setup the blockcipher parameters with the given secret + * key for either encryption or decryption; + * Return value is 0 on success, or -1 on failure. + * NOTE: after use, it is recommended to wipe the parameters by calling setup + * again with another (dummy) key. + * + * int (*encrypt)(blockCipherParam* param, uint32* block); + * + * This function will encrypt one block of data (with bit size equal to + * 'blockbits') + * Return value is 0 on success, or -1 on failure. + * NOTE: this is raw encryption, without padding, etc. + * + * int (*decrypt)(blockCipherParam* param, uint32* block); + * + * This function will decrypt one block of data (with bit size equal to + * 'blockbits') + * Return value is 0 on success, or -1 on failure. + * NOTE: this is raw decryption, without padding, etc. + */ + +typedef struct +{ + const char* name; + const int paramsize; /* in bytes */ + const int keybitsmin; /* in bits */ + const int keybitsmax; /* in bits */ + const int keybitsinc; /* in bits */ + const int blockbits; /* in bits */ + const blockCipherSetup setup; + const blockCipherEncrypt encrypt; + const blockCipherDecrypt decrypt; + const blockMode* mode; +} blockCipher; + +/* + * You can use the following functions to find blockciphers implemented by + * the library: + * + * blockCipherCount returns the number of blockciphers available. + * + * blockCipherGet returns the blockcipher with a given index (starting + * at zero, up to blockCipherCount() - 1), or NULL if the index was out of + * bounds. + * + * blockCipherFind returns the blockcipher with the given name, or + * NULL if no hash function exists with that name. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int blockCipherCount(); +BEEDLLAPI +const blockCipher* blockCipherGet(int); +BEEDLLAPI +const blockCipher* blockCipherFind(const char*); +BEEDLLAPI +const blockCipher* blockCipherDefault(); + +#ifdef __cplusplus +} +#endif + +/* + * The struct 'blockCipherContext' is used to contain both the functional + * part (the blockCipher), and its parameters. + */ + +typedef struct +{ + const blockCipher* ciph; + blockCipherParam* param; +} blockCipherContext; + +/* + * The following functions can be used to initialize and free a + * blockCipherContext. Initializing will allocate a buffer of the size + * required by the blockCipher, freeing will deallocate that buffer. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void blockCipherContextInit(blockCipherContext*, const blockCipher*); +BEEDLLAPI +void blockCipherContextFree(blockCipherContext*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/beecrypt.mcp b/beecrypt/beecrypt.mcp new file mode 100644 index 0000000000000000000000000000000000000000..805bcbc62f44baae8aa2d3daa06a0f62d47f2160 GIT binary patch literal 75718 zcmeHQ37izg^{#CO5Rg+u9S{dWMbPC&!~>Q+*nwRbmxV<{+1c4y7?{}^XJ!@DC>|lG zcqZ}0BSuj)#uMWmjT(=5U-3*dF>2H#5=mmz{QZBg`t@}8Odqqj3bI{4KKkodudAzG zRlTa|>aL9^laVe$h>;~iY#3Z3o*hymKJO_+8)QlsAO2TEd9pd$5KgCK$#fu;PA-o| zvRYK9IDSQ?gpEEPieo^C{@_+20^w@ll&<)1Cn4fE*ab>L0m%MjX}Y8v&>g^~q6dJg z5WRq%f!;tLzz_5V`T_lc0l+T6Kwwv35U?AtJFq7(7}x_C0#Nq%0=8uc;O5f+D*HGb zP<91nS5S5ZWmiyk1$k6Zb_HcuP<937R#0XIWmZsT1!Y!HW(DO{P+kS)RZw09l@O^SLLg`8Qbd*x2ZrlxbXJNBIwJ}z7y4`(vbOz8=+6zNz8G~~%U(LLoqN|~B= zE>P+{YNP3;(ZJlct#q5y5XwTK8oGy1ESybWb3gn%P}I$$190n7xdfgn&1lmjOMCjeEz4}jSK zb==j!slds=NkABA0wO>&5CvL*(}1PG>A+l|5|{5VfurUCM{G;;0-91n~Dh6DQm#{pFN!+^bk#lX?PF~AaFCC~`00!9Pm zt@j1U*X$3B0uBeJ0n>ppU_3Ahm<${Q%mCogL<}IOG7(q-91J9YRv-z)f#tw_U;)qo zECh}O76H`Oj{=Sb4g)3tQ-G-eyp1>%fcG_xI6j=CtK~*6cx2h{;ML`*1y3$VGk9}3 zGQm^Jk&C))Z=f&G59kk+019wBa2xPX;6C7C;CkRj;6dOq;8tJ*@C)E3U?Z>zxC{6U zxEr_!xEJ^pa0hTF@LS-Qz|FuG;C|rOz;A$ufJcGPfg6CwfiHktfG2^cfd_y`fIkB7 z0)GPj3_J(C2)qWo4!i?A3%m@x1iS#e3j7}U2km8W8fp; zufSh`=Yc-}ZvbxsuK;fWZv*E8=K=o$E(NXveh91u)&oBW&IQf@&H~N^egym&_zCcD z;3D8+;1b}czy-jCz_q|S;B4SOz-7P{z}3K&z%{^sfi=K&z?Z-|z!SjlfXjiO0r_DF z1jB%xfd0UdKnQ38!oVTGQ9wN~52ync0*3d8=mq$I`9Khu1%j*bC?ij08%7xxf@)Z{QeUDzGy!4wwXt z1qK4U0)v2|zye?l&;>Xc*bkThOaw*&2LRoGZ4u;fjj=}`ILQi5BM6m(N~|4E`CDXD zkg7W`P%U|(b6cQ9wvzg}bIEPU;Hyg}v(zy|^Xp_Er_R@HUa~D6iBcb}tO-`3|M}<$ z-y@IkP4bAoDUa|6@`(N>k7$kZh`ue4=*#kmzAumP2l5F2CXd7Ti2g6n;Va}3{Z<~) zcjXcNS02$%P-V`=hXzt=FAHQYGO_4a5@&v zQ0Jf`B3fR8&Lod0szP!kp=e1^N86<#);eK)U|z-S!ZeVUycTXs9^p#lF~CQ-9C;4+ zCy#Jh@(4HP)<-E@lsqL($x@P(WvU^n9jY0s6{-=c4XO#M1*!qEK3SfuP8KI?lcmYZ zWMQ%{S(dCy7A0$vCCQ3pLCP*=k+M%&CQB;PM}xQqMf9tSW@NJprK2sem8Hu{m*rhW zP0uaL16>QM}gC5MEYgmG@1}!1WqFp@eFu?`B~t@m|qRPH}l)Uhco{j_z32I0^f)E z=ivJ??~RJzkNI%$k<6!p@6S90PNNs)VFfsi`ovd*(}+g=B5)cSh+hv*BPfN3!D&RK z@FqBoniReSr;(Jx?r3;4`cs$!P9r9T1>k5mGEhH4yOZHUaI`NOZUaaAk>Le!v?Ccd zgQGpk&%m6=>c^LdK<|l*GY=^>S;54J5unBy+WSC)smofi4_zdPf z(Rs?5j|Q(`UIkvsya~LD`6}?4%r6J8W_~YtkojBSvzUJcPO~5igVA|vR4NVyuVsET z_#EaZgU@At1$c=0ec(qhe+^u7+y4fi$MRj#`0JTZ0H4o%0r&#u8SnOYc9|2D?e;+)> zyh|_jmmi%D15dMj5_pFB5#U+oY4A4Y=YSu_d?Wbr%pUr@>n9l@1nRyKS6z1!|S2MpA{8Z*ogP+Fy@8G91?}Gv24CV)b|B(4?@HNb% z;6Gx12KZX$*MgtP{4wyen129%HuDk;KI@nd13!oPH1KnoH-MkVJPUq4^K-#3V7?Lj zLgtTw|Cssf;6Gvh8Te0`_v)+udZW`};1{!e3iu_=XMtbJJPdvr^B;m=&U^#-dgf1o zU%~tn@GF`3?x+5`q|XQdL9SQy`mREz{%{&Hv5A${4_cFf~{66L{f#1*kU*Hcg zA2?8b@g@cZv%gr`NiPBVSX?8Bh23hf0X%`;EyriV^{Ub2%U}xf1Ks> z!JlBB0e_PD#o$jdzX$wx%wGY2n)w#+XP6Jd3UJw2}^9=Y4%+CjZk@?Nw zFEM`#{AK1JgTKPO>u&1P6*?UO{(F|s0Dp~nBlzpgPX>R3`4!-AGJg>KE#~ilzsBfe}{Pr{9Wdkg8zy6L*RdA{zvflnA4)gUzqO={yy_c@DG@`fPct* z4ftP~Zv_8{`7_`jGyfO(C(H-<)h9}HIv)J*EUyRu2lL~=KV|+?@XgF00RJcRH^Dz+ z{ss6J=0gUnPn+oU5b%Gqd_MSpn6Co=ocYDz|7Cs`_!rFI1pkuxm*8J9_YV=`f6NaD z|3Bu7!M|pH61be;;cz*)IvYk`1XoH_rPsl`F#ihN$9%6n@pOgxbntG>mwF1Rtn{tM%4gj+cjzkRq@h=KcN^W#EiUfK8hJc`evCZAp47}PA$d5@LBdA0q6t=VY0HJS}nu1v*~>1eur_V|XE zx9?`2_V#B1eP+G=<;}~HXMyd<0=woWwB7l6>NoB?+x+LZ`S}kX{zOZyo&a^g^B<$F zXxc*oKSdQR!=0+UQPSU6QXatbr>W&_nQSrpepd@|jf5vsH-5{YIqflxTROcT|I z@dkM|FfW?T##)zZ(yCZI8mJAYQU=+KwphFw<6|}**3`Hnpo=!lZy6zk$S7T=n45rPo6S6FCCIp#4_}*exgY)Ac;-MlfayOc~vchqP#7g zj<#k4s*wfj1S*n|wgky@R@Y*r-D_f*tf2R*)U4)Lr5eeNBRjx;vs$CZwtKKZ-`Y{W&I?|=4W}u6yLbWDkmYSM_ zIjZ26#%7_ba?{WSp>QS=j_a+lAg0jHfr@BT+tPwgp1YFct=k7j+O`sow`nUJYu#cv z(yrZ@qHRlMYY)Dh<880EZi9TW(dp!yOU4=7BVS|JDmmJ^ZE~b#3pK>$HyT4!L2KnW z>o&`gmMzy1XWf1c3N{(CY|DIEev1y&MdQ(MChE{WH4U2m1(qQ%-Y6D``hp%`Ornu<}yHfz?+MZ1(6 zj9NEk@pwT)(PK;vL>K2b3_Zr&AauFPc=n=;^BO>YM6TlXh`b8dBTN;oi;Wd*ma_HC zLajn|si`7$v9SWpQd7m5qY7?mtSDX8wny9hX02}Ry>m_@+M*BnIbRV9(OgfR#p#YY zcMW1q#j;khZI6_?W?B7GbrcPm^20LA+~{#OdC?ULa-v6R`OwXsZ`Fbri)KiOhuYX*8|PW_3FjXwc$ApDij=%Y+=oYr?Hd+rmq&a$r3JFkP+HP+*dwkm5ekr5{nqEjCxdI>GU|gT)Hg3 zMCKU1EO~PN0g@-xDq9z8MK($F!eRix=PL5IS$j4LVguF>S&c^r9^fzxfeSn&97U<8;3`$cpi$ZqG;@Ly}xmov`VC~?OAE%duS^i zy`@^knq~)93i*xNPDgLvwi?{fZR52jZ>2!?;(@^`n(EvknrhP_I&ZdRcY_c-tWBJA zH#E*>Y!b+g99Hp^eJA6XreanJs0GXo*H$X|6C^7g$c&G^j4G=4b@Df=hOM_zqn&(> zs$uVG)OcGzqejdB4Ff@88FCs{K1NN%(ZlE}R{lkewev1&tc7n;BOE=8u3~>*XRo5B z;N(+O4Qr30#@YH4HQLFW=o;3(#1L=cNer=8T}6$y@gi!ZjSo>HZ9Iq?>EJ)~r1QN; zF2>q-sL^(wBX_Z-Ur=N1yoMTU>oe472amz`Rv!;q`V>{e!CPq4TFPSO%19KC&XcXQ z06??r!Y*m4rcZ+`qm8K;Z#OfZY{Fwr{b{{XQO!7|SD!nPY*0qY`q~T z;p7fk#oiyXf~`a3cv)r}kC?AwTM^h^7fp{%prQ zwK2_OWXCj2T5{*w425p24KVq?XiT#VLk{z17Zjtp&%Eidg@bn<&n>*B&}Tw)r-C^L z35)QRrsgACwQOEmWs$_>-Y8k!Rng;cd?S=dp}*wz=>&}@BP$YE_8@UQd3;MOv&=w~ z*vvB`n&ZuMS#x}adPuF1XPM)gQwKJadNjT?oCwE>wKm7Xt*v;;N1kNU$e|br68GQ;c=W+ z6Bd0ZPlSxyD%m7g*c3J-oe_=hI#|4g>J1y4>FhpV`a(nQ-_{1ImK0?7GMgLQvl6`p$pfX*Rr@ zZHE@1KJhgI4%6vlAvte4kcN;_Wc=UY5Q!3ux^EZ&TZ}3(QK? zoejN~@vYUu_Ls2ME-;45c7b1O+g~QV9DU~&(Aov&Rnv_hXK!srx)?r3-P$y?>q_K4 z*E4WR--e6=Xy!K>pjqAl0L}Ui1SozCK(oTJd|rwp=}!V^MtBgPkHe8>j)wtM`iTI| zDklRp!#o@y`N06CTh8ai)vYJ#Lw56S2|eeBf~6_BdnsuZ21-!Q=42{by!XAXW(nhw zDz)G-kWs7_G^r}>>BhnFVkz})5 zeu{{1jHEN|+)2bT)kcz*M(D4GS;k9Y5%!UK&VO~RC_B5(HU|jVG9vc5r5NN`Uy!y@ zRnr+wzhP`c@##2csQ7eJwt1n5cBJE&P|@ko;uZq^W@^EPuU&AYA82&m7obgG>EVS@ zMtT%aprCpLmD~MaM1K0obR0`1?PFM`x4xU24t5%F2*^*7>0s^AArw)r)oOks%bZ$b z@#&=69I`|0$E{pyey|Se6p#+4#dYOQI@U?~LPX^1 zuO_iL;(@I3trQClRaBa6T5cPOh`hI3Y*kA;z&`5Re1;bS^X@iyyPJ#6sHt_Gvlwau zMawG^pH|g`IwYNrnnML<&6sPQQ(amcYS3DkZMm9~HL|tpS8WyR*g2g`|I2wO+fwmJ z5OMNzh7ry+9p?-cpC9KTr5))wCRB7f(Up$r6w?x<=XD&Hin4P%N8HI%R@h{&eIu@0 zIz^7S_U)&ABd%*Y#g4eP+ z8v`BE`JRtCwk2z7-8qZes9SHQ-&6mo?QR@TnTop_{ET3}f=o0>Xi46PcLX4+ayBgw>=R65z* z7RhGDEN@;hW?bpGF?f=k852&$=pD5kEYJrSUMRExeU#Ew{lc^`vPj7^gtAbmW;I;S z>V-vKk=`6WF{PBcyN=sq1AD8U};{&@J}eCyKItUw>b_{74QH5JXV6_Mr1 zbf`Quuc6o0CF)(Z16jcPnA2>h4w$1L8OKl}^jVA|LU`jx{vps#-*pG>S3b9*a=*ZS6=n5hID~@b_4_$ma>t77 z^bKIgs!p#oo&`J$Y=s5zX{5Jl#8%j?Gh9Mrq_=5AXQ=7+l~HRKco;a{dNUDk(}?z2 zbjQ%v+C>*`7v823J4U^J(^6>d0$<=v_rBKurq=YX|Grzm__aRop!t0-QoHi+eXZXv zbM5fTUGYqo{&n&|yAhEc=yAFiJPQ~tKyQ&H!m(DPtg~^?Lv*$p_sY9<7T7g6nr?4< z^r_o0^rbCq%4tK7Xr^>|xL}izMZr*@wqa37mcEO(?VVLC@U}RzvWiiLPp4eBO7gZi zGFq&V%g>^{EshEeqe?pM7Du}X*)r&lOmH}@`^AISp1Jtg<9F*K>ev20NMh5UsaSi% z!sBTV9u8eZwR{&>rsMogW;?bNDstlnY<#ZeBmb!8$2mi}k1}1;as0Nk9py?nCRB8O zyseUKD_+(+{h1brP=uY^_tC0-`{8to-MGOvAvGPBZ2(X%Z>uDSdiSSMBdI*tkD#$>m2zUwjBK0n@8NzN{zv7OuV*;?A$D#_WH}Usu(yvF<5|G7KW9EaW?n_ z=9hp^Wd3vTNz88t*FMa65d0vPKLb96`P<+JGyep9Ds$0Ah(nkU06&!Z5b(p8j{~PR zM4<{?+ui<1@aa-2L=3!)`HA2&n6CvdXMPcQ1@mjbE1BO6Ud8+#@R`gX1+QlQBDnlG z2IsGX&tmyI;Io;308W3hn!;z`)Yd8d4}6YFMNf1V?Jv0w1P`%%DEJY~M}pTe9|Nxa z^^wWo^(?OdpU?aV@CD3|0&ifx6kOY@HwAtq%TEN?{^I-@;776iJn+TL*MlF;d?WZV z%^FzUxF|P!VF<%6} zocRjy70lbfw0#Yiq4iley`7*!>!xmc_^wH*FzM+(Pjn{NrIpGe z^zfdoLTiWmef3myCfBwVT32+_!&x^!Cs0)SGAl>v(7YeOUy6K@V6k5A<(;EO4 zTGw>b+XX7L=IN%lD^zF=)J<;?RA_zFO%H4T3ay>G>EXQqh1ONw^zhDrLTj#WdU&5e zq4iidJ-lC_(E6;K9^O4rXzkWb5AP)?w65!>hj$hfTJv?&+Z!s4COy5M8{6}6=+Qd1 zTY7j0L7}x{H$A+cpwODJo8B0x&>FRy-dLzai_jYfJz6t%OAjhu@GRh2z_Y*(WdTg* ze7#X3-T&$S-dIpbeVCiL>S3PfD{`LbD{`LbD{`Lbvzyl$%Yk{K&u(64)WbZ{XE(1i z>h*-4-Mr4Iw=?wY=5J(UT4%pUHI(gbw)kZh0ktYXVgPo`0VC&Mm^Mp&u(64 z)WiJGXE(1i>J5aR-Mr4Ihk2sUZeC~9!#vSvH?K45VV>x-o7WljFi-T^&FhSMnE(0g z=5*v7Vs?KS>W5Uz)2I3azKc5R{vWMbg$=WGKI-VJWsv`59H`Wj@CT+NVs)c&5z~D zPohB9OH)XeJ^a4{J%tm=iFVt|NKMEcZblb18Y>0nI_>eyJ_QN(|B|Bt-cMzf!F{ z!15#}4FgdIlArTJweld#PsiPk!z7R7o0bQaU$guPq~D#(RdGsCd5GoDVyiP=Hr zF_vF8Oo%r)KaX|~D!*mRDo?Py8F_31r~DlAX|?hs%in=~ z3d`R=JE%Ox@_&}1A8~mf9+@0%JVD_LLXgH-uJIRtyW%O`MyYm z@=WC#|46m+BFjH)7UDvdC;n5dyu|X|(H0J8`9842%PimX9DEDL`7HagT6u-#W8n{B z3iZCn29;M?KIvSzG1mXlsX^uUEZ=;Q`t2Fzr~8I#@?((C5iCFBlWOH{mY)W>)?doH z9xndK@|Tg0R*z-7`o*7Ez5w-Bzp*^_>;p5-lf3GpEJ>$}GK#T6_c zceCEFho0^iNLGd^ztsD6pHuzfDwdCUR`1t`^%yL!W_dmGsoAaVBfof;Ri z7aLjLXwbj@L%+C@<#EWhcDT6JFK%b~jga>Nr}}OArC;2`@*7Z(n%_9NLG3{1pOPpNPqoEzd$pS;X-s|&2Kzh=NEUdd|-?2SD)S2 zFR!Jj8pyT&`{0#+aWCuN_=fI3r@ieLH?jOdbY#tct~=Q;e!=pgFchj%=I8qT{Q}Kf zhG)?LH2?X74Ss>*IK*nF>8|8sYI1ucPYkS_yQ`|S3@QVOebVmk9ybiHy=Au zejiH_SHM1+{JdXH6unq~@Avg|&WcSGJF|Qd=2x2jpn;P_Z + +1 VERSIONINFO + FILEVERSION 2,1,0,0 + PRODUCTVERSION 2,1,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0x0L + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" /* U.S. English; Unicode */ + BEGIN + VALUE "CompanyName", "Virtual Unlimited B.V.\0" + VALUE "FileDescription", "BeeCrypt Cryptography Library\0" + VALUE "FileVersion", "2.1.0\0" + VALUE "InternalName", "beecrypt\0" + VALUE "LegalCopyright", "Copyright (c) 1997-2001 Virtual Unlimited B.V.\0" + VALUE "LegalTradeMarks", "BeeCrypt is a trademark of Virtual Unlimited B.V.\0" + VALUE "OriginalFileName", "BEECRYPT.DLL\0" + VALUE "ProductName", "BeeCrypt\0" + VALUE "ProductVersion", "2.1.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/beecrypt/beetest.c b/beecrypt/beetest.c new file mode 100644 index 0000000..c2f1d62 --- /dev/null +++ b/beecrypt/beetest.c @@ -0,0 +1,496 @@ +/* + * beetest.c + * + * BeeCrypt test and benchmark application + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 "beecrypt.h" +#include "blockmode.h" +#include "mp32barrett.h" +#include "dldp.h" +#include "fips180.h" + +#if HAVE_STDLIB_H +#include +#endif +#if HAVE_ERRNO_H +#include +#endif +#if HAVE_TIME_H +#include +#endif + +#include + +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"; + +int testVectorExpMod() +{ + mp32barrett p; + mp32number g; + mp32number x; + mp32number y; + + mp32number tmp; + + mp32bzero(&p); + mp32nzero(&g); + mp32nzero(&x); + mp32nzero(&y); + + mp32nzero(&tmp); + + mp32nsethex(&tmp, dsa_p); + + mp32bset(&p, tmp.size, tmp.data); + + mp32nsethex(&g, dsa_g); + mp32nsethex(&x, dsa_x); + + mp32bnpowmod(&p, &g, &x); + + mp32nset(&y, p.size, p.data); + + mp32nsethex(&tmp, dsa_y); + + return mp32eqx(y.size, y.data, tmp.size, tmp.data); +} + +int testVectorSHA() +{ + uint32 expect[5] = { 0xA9993E36, 0x4706816A, 0xBA3E2571, 0x7850C26C, 0x9CD0D89D }; + uint32 digest[5]; + sha1Param param; + + sha1Reset(¶m); + sha1Update(¶m, (const unsigned char *) "abc", 3); + sha1Digest(¶m, digest); + + return mp32eq(5, expect, digest); +} + +void testBlockInit(uint8* block, int length) +{ + register int i; + for (i = 1; i <= length; i++) + *(block++) = (uint8) i; +} + +void testBlockCiphers() +{ + int i, k; + + printf("\tTesting the blockciphers:\n"); + + for (i = 0; i < blockCipherCount(); i++) + { + const blockCipher* tmp = blockCipherGet(i); + + if (tmp) + { + uint32 blockwords = tmp->blockbits >> 5; + + uint32* src_block = (uint32*) malloc(blockwords * sizeof(uint32)); + uint32* dst_block = (uint32*) malloc(blockwords * sizeof(uint32)); + uint32* spd_block = (uint32*) malloc(1024 * 1024 * blockwords * sizeof(uint32)); + + void* encrypt_param = (void*) malloc(tmp->paramsize); + void* decrypt_param = (void*) malloc(tmp->paramsize); + + printf("\t%s:\n", tmp->name); + + for (k = tmp->keybitsmin; k <= tmp->keybitsmax; k += tmp->keybitsinc) + { + void* key = (void*) malloc(k >> 3); + + testBlockInit((uint8*) key, k >> 3); + + printf("\t\tsetup encrypt (%d bits key): ", k); + if (tmp->setup(encrypt_param, key, k, ENCRYPT) < 0) + { + free(key); + printf("failed\n"); + continue; + } + printf("ok\n"); + printf("\t\tsetup decrypt (%d bits key): ", k); + if (tmp->setup(decrypt_param, key, k, DECRYPT) < 0) + { + free(key); + printf("failed\n"); + continue; + } + printf("ok\n"); + printf("\t\tencrypt/decrypt test block: "); + testBlockInit((uint8*) src_block, tmp->blockbits >> 3); + memcpy(dst_block, src_block, tmp->blockbits >> 3); + tmp->encrypt(encrypt_param, dst_block); + /* + for (j = 0; j < (tmp->blockbits >> 3); j++) + { + printf("%02x", *(((uint8*)dst_block)+j)); + } + printf(" "); + */ + tmp->decrypt(decrypt_param, dst_block); + if (memcmp(src_block, dst_block, tmp->blockbits >> 3)) + { + free(key); + printf("failed\n"); + continue; + } + free(key); + printf("ok\n"); + printf("\t\tspeed measurement:\n"); + { + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + + #if HAVE_TIME_H + tstart = clock(); + #endif + blockEncrypt(tmp, encrypt_param, ECB, 1024 * 1024, spd_block, spd_block, 0); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t\t\tECB encrypts 1M blocks of %d bits in %.3f seconds\n", tmp->blockbits, ttime); + #endif + #if HAVE_TIME_H + tstart = clock(); + #endif + blockDecrypt(tmp, decrypt_param, ECB, 1024 * 1024, spd_block, spd_block, 0); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t\t\tECB decrypts 1M blocks of %d bits in %.3f seconds\n", tmp->blockbits, ttime); + #endif + #if HAVE_TIME_H + tstart = clock(); + #endif + blockEncrypt(tmp, encrypt_param, CBC, 1024 * 1024, spd_block, spd_block, 0); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t\t\tCBC encrypts 1M blocks of %d bits in %.3f seconds\n", tmp->blockbits, ttime); + #endif + #if HAVE_TIME_H + tstart = clock(); + #endif + blockEncrypt(tmp, decrypt_param, CBC, 1024 * 1024, spd_block, spd_block, 0); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t\t\tCBC decrypts 1M blocks of %d bits in %.3f seconds\n", tmp->blockbits, ttime); + #endif + } + } + free(spd_block); + free(dst_block); + free(src_block); + free(decrypt_param); + free(encrypt_param); + } + } +} + +void testHashFunctions() +{ + int i; + + uint8* data = (uint8*) malloc(16 * 1024 * 1024); + + if (data) + { + hashFunctionContext hfc; + + printf("\tTesting the hash functions:\n"); + + for (i = 0; i < hashFunctionCount(); i++) + { + const hashFunction* tmp = hashFunctionGet(i); + + if (tmp) + { + uint8* digest = (uint8*) malloc(tmp->digestsize); + + printf("\t%s:\n", tmp->name); + + if (digest) + { + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + + hashFunctionContextInit(&hfc, tmp); + + #if HAVE_TIME_H + tstart = clock(); + #endif + hfc.hash->reset(hfc.param); + hfc.hash->update(hfc.param, data, 16 * 1024 * 1024); + hfc.hash->digest(hfc.param, (uint32*) digest); + + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t\thashes 16MB in %.3f seconds\n", ttime); + #endif + + #if HAVE_TIME_H + tstart = clock(); + #endif + hfc.hash->reset(hfc.param); + hfc.hash->update(hfc.param, data, 16 * 1024 * 1024); + hfc.hash->digest(hfc.param, (uint32*) digest); + + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t\thashes 16MB in %.3f seconds\n", ttime); + #endif + free(digest); + } + hashFunctionContextFree(&hfc); + } + } + } +} + +void testExpMods() +{ + static const char* p_512 = "ffcf0a0767f18f9b659d92b9550351430737c3633dc6ae7d52445d937d8336e07a7ccdb119e9ab3e011a8f938151230e91187f84ac05c3220f335193fc5e351b"; + + static const char* p_768 = "f9c3dc0b8e199094e3e69386e01de863908348196d6ad2557065e6ba36d10412579f394d1114c954ee647c84551d52f214e1e1682a75e7074b91085cfaf20b2888aa056bf760948a0b678bc253633eccfca86556ddb90f000ef93041b0d53171"; + + static const char* p_1024 = "c615c47a56b47d869010256171ab164525f2ef4b887a4e0cdfc87043a9dd8894f2a18fa56729448e700f4b7420470b61257d11ecefa9ff518dc9fed5537ec6a9665ba73c948674320ff61b29c4cfa61e5baf47dfc1b80939e1bffb51787cc3252c4d1190a7f13d1b0f8d4aa986571ce5d4de5ecede1405e9bc0b5bf040a46d99"; + + randomGeneratorContext rc; + + mp32barrett p; + mp32number tmp; + mp32number g; + mp32number x; + + mp32bzero(&p); + mp32nzero(&g); + mp32nzero(&x); + mp32nzero(&tmp); + + randomGeneratorContextInit(&rc, randomGeneratorDefault()); + + if (rc.rng && rc.param) + { + if (rc.rng->setup(rc.param) == 0) + { + int i; + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + + printf("Timing modular exponentiations\n"); + printf("\t(512 bits ^ 512 bits) mod 512 bits:"); + mp32nsethex(&tmp, p_512); + mp32bset(&p, tmp.size, tmp.data); + mp32nsize(&g, p.size); + mp32nsize(&x, p.size); + mp32brndres(&p, g.data, &rc); + mp32brndres(&p, x.data, &rc); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t 100x in %.3f seconds\n", ttime); + #endif + printf("\t(768 bits ^ 768 bits) mod 768 bits:"); + mp32nsethex(&tmp, p_768); + mp32bset(&p, tmp.size, tmp.data); + mp32nsize(&g, p.size); + mp32nsize(&x, p.size); + mp32brndres(&p, g.data, &rc); + mp32brndres(&p, x.data, &rc); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t 100x in %.3f seconds\n", ttime); + #endif + printf("\t(1024 bits ^ 1024 bits) mod 1024 bits:"); + mp32nsethex(&tmp, p_1024); + mp32bset(&p, tmp.size, tmp.data); + mp32nsize(&g, p.size); + mp32nsize(&x, p.size); + mp32brndres(&p, g.data, &rc); + mp32brndres(&p, x.data, &rc); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t 100x in %.3f seconds\n", ttime); + #endif + /* now run a test with x having 160 bits */ + mp32nsize(&x, 5); + rc.rng->next(rc.param, x.data, x.size); + printf("\t(1024 bits ^ 160 bits) mod 1024 bits:"); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\t 100x in %.3f seconds\n", ttime); + #endif + mp32bfree(&p); + mp32nfree(&g); + mp32nfree(&x); + mp32nfree(&tmp); + } + } + + randomGeneratorContextFree(&rc); +} + +void testDLParams() +{ + randomGeneratorContext rc; + dldp_p dp; + + memset(&dp, 0, sizeof(dldp_p)); + + randomGeneratorContextInit(&rc, randomGeneratorDefault()); + + if (rc.rng && rc.param) + { + if (rc.rng->setup(rc.param) == 0) + { + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + #if HAVE_TIME_H + tstart = clock(); + #endif + printf("Generating P (768 bits) Q (512 bits) G with order Q\n"); + dldp_pgoqMake(&dp, &rc, 768 >> 5, 512 >> 5, 1); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf("\tdone in %.3f seconds\n", ttime); + #endif + } + } + + randomGeneratorContextFree(&rc); +} + +int main() +{ + + int i, j; + + printf("the beecrypt library implements:\n"); + printf("\t%d entropy source%s:\n", entropySourceCount(), entropySourceCount() == 1 ? "" : "s"); + for (i = 0; i < entropySourceCount(); i++) + { + const entropySource* tmp = entropySourceGet(i); + if (tmp) + printf("\t\t%s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf("\t%d random generator%s:\n", randomGeneratorCount(), randomGeneratorCount() == 1 ? "" : "s"); + for (i = 0; i < randomGeneratorCount(); i++) + { + const randomGenerator* tmp = randomGeneratorGet(i); + if (tmp) + printf("\t\t%s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf("\t%d hash function%s:\n", hashFunctionCount(), hashFunctionCount() == 1 ? "" : "s"); + for (i = 0; i < hashFunctionCount(); i++) + { + const hashFunction* tmp = hashFunctionGet(i); + if (tmp) + printf("\t\t%s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf("\t%d keyed hash function%s:\n", keyedHashFunctionCount(), keyedHashFunctionCount() == 1 ? "" : "s"); + for (i = 0; i < keyedHashFunctionCount(); i++) + { + const keyedHashFunction* tmp = keyedHashFunctionGet(i); + if (tmp) + printf("\t\t%s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf("\t%d blockcipher%s:\n", blockCipherCount(), blockCipherCount() == 1 ? "" : "s"); + for (i = 0; i < blockCipherCount(); i++) + { + const blockCipher* tmp = blockCipherGet(i); + if (tmp) + { + printf("\t\t%s ", tmp->name); + for (j = tmp->keybitsmin; j <= tmp->keybitsmax; j += tmp->keybitsinc) + { + printf("%d", j); + if (j < tmp->keybitsmax) + printf("/"); + else + printf(" bit keys\n"); + } + } + else + printf("*** error: library corrupt\n"); + } + + testBlockCiphers(); + testHashFunctions(); + testExpMods(); + testDLParams(); + + printf("done\n"); + + return 0; +} diff --git a/beecrypt/blockmode.c b/beecrypt/blockmode.c new file mode 100644 index 0000000..662041f --- /dev/null +++ b/beecrypt/blockmode.c @@ -0,0 +1,167 @@ +/* + * blockmode.c + * + * Block cipher operation modes, code + * + * Copyright (c) 2000, Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "blockmode.h" +#include "mp32.h" + +/* generic functions for those blockCiphers that don't implement an optimized version */ + +static int ecbencrypt(const blockCipher* bc, blockCipherParam* bp, int blocks, uint32* dst, const uint32* src) +{ + register int i; + register uint32 blockwords = (bc->blockbits >> 5); + + mp32copy(blocks * blockwords, dst, src); + for (i = 0; i < blocks; i++) + { + bc->encrypt(bp, dst); + dst += blockwords; + } + return 0; +} + +static int ecbdecrypt(const blockCipher* bc, blockCipherParam* bp, int blocks, uint32* dst, const uint32* src) +{ + register int i; + register uint32 blockwords = (bc->blockbits >> 5); + + mp32copy(blocks * blockwords, dst, src); + for (i = 0; i < blocks; i++) + { + bc->decrypt(bp, dst); + dst += blockwords; + } + return 0; +} + + +static int cbcencrypt(const blockCipher* bc, blockCipherParam* bp, int blocks, uint32* dst, const uint32* src, const uint32* iv) +{ + register int i; + register uint32 blockwords = (bc->blockbits >> 5); + + mp32copy(blockwords, dst, src); + + if (iv) + mp32xor(blockwords, dst, iv); + + bc->encrypt(bp, dst); + + dst += blockwords; + src += blockwords; + + for (i = 1; i < blocks; i++) + { + mp32xor(blockwords, dst, dst - blockwords); + + mp32copy(blockwords, dst, src); + bc->encrypt(bp, dst); + + dst += blockwords; + src += blockwords; + } + return 0; +} + +static int cbcdecrypt(const blockCipher* bc, blockCipherParam* bp, int blocks, uint32* dst, const uint32* src, const uint32* iv) +{ + register int i; + register uint32 blockwords = (bc->blockbits >> 5); + + mp32copy(blockwords, dst, src); + bc->decrypt(bp, dst); + + if (iv) + mp32xor(blockwords, dst, iv); + + dst += blockwords; + src += blockwords; + + for (i = 1; i < blocks; i++) + { + mp32copy(blockwords, dst, src); + bc->decrypt(bp, dst); + + mp32xor(blockwords, dst, src - blockwords); + + dst += blockwords; + src += blockwords; + } + return 0; +} + +int blockEncrypt(const blockCipher* bc, blockCipherParam* bp, cipherMode mode, int blocks, uint32* dst, const uint32* src, const uint32* iv) +{ + if (bc->mode) + { + register const blockMode* bm = bc->mode+mode; + + if (bm) + { + register const blockModeEncrypt be = bm->encrypt; + + if (be) /* we have an optimized version for this cipher / mode combination */ + return be(bp, blocks, dst, src, iv); + } + } + + switch (mode) + { + case ECB: + return ecbencrypt(bc, bp, blocks, dst, src); + case CBC: + return cbcencrypt(bc, bp, blocks, dst, src, iv); + default: /* other block modes aren't implemented yet */ + return -1; + } +} + +int blockDecrypt(const blockCipher* bc, blockCipherParam* bp, cipherMode mode, int blocks, uint32* dst, const uint32* src, const uint32* iv) +{ + if (bc->mode) + { + register const blockMode* bm = bc->mode+mode; + + if (bm) + { + register const blockModeEncrypt bd = bm->decrypt; + + if (bd) /* we have an optimized version for this cipher / mode combination */ + return bd(bp, blocks, dst, src, iv); + } + } + + switch (mode) + { + case ECB: + return ecbdecrypt(bc, bp, blocks, dst, src); + case CBC: + return cbcdecrypt(bc, bp, blocks, dst, src, iv); + default: /* other block modes aren't implemented yet */ + return -1; + } +} diff --git a/beecrypt/blockmode.h b/beecrypt/blockmode.h new file mode 100644 index 0000000..acbf972 --- /dev/null +++ b/beecrypt/blockmode.h @@ -0,0 +1,44 @@ +/* + * blockmode.h + * + * Blockcipher operation modes, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _BLOCKMODE_H +#define _BLOCKMODE_H + +#include "beecrypt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int blockEncrypt(const blockCipher*, blockCipherParam*, cipherMode, int, uint32*, const uint32*, const uint32*); +BEEDLLAPI +int blockDecrypt(const blockCipher*, blockCipherParam*, cipherMode, int, uint32*, const uint32*, const uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/blockpad.c b/beecrypt/blockpad.c new file mode 100644 index 0000000..0efccf2 --- /dev/null +++ b/beecrypt/blockpad.c @@ -0,0 +1,146 @@ +/* + * blockpad.c + * + * Blockcipher padding, code + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "blockpad.h" + +#if HAVE_STDLIB_H +# include +#endif + +int pkcs5PadInline(int blockbytes, memchunk* src) +{ + if (src != (memchunk*) 0) + { + byte padvalue = blockbytes - (src->size % blockbytes); + + src->size += padvalue; + src->data = (byte*) realloc(src->data, src->size); + memset(src->data - padvalue, padvalue, padvalue); + + return 0; + } + + return -1; +} + +int pkcs5UnpadInline(int blockbytes, memchunk* src) +{ + if (src != (memchunk*) 0) + { + byte padvalue = src->data[src->size - 1]; + + int i; + + if (padvalue > blockbytes) + return -1; + + for (i = (src->size - padvalue); i < (src->size - 1); i++) + { + if (src->data[i] != padvalue) + return -1; + } + + src->size -= padvalue; +/* src->data = (byte*) realloc(src->data, src->size; */ + + return 0; + } + + return -1; +} + +memchunk* pkcs5Pad(int blockbytes, const memchunk* src) +{ + memchunk* dst; + + if (src == (memchunk*) 0) + return (memchunk*) 0; + + dst = (memchunk*) calloc(1, sizeof(memchunk)); + + if (dst != (memchunk*) 0) + { + byte padvalue = blockbytes - (src->size % blockbytes); + + dst->size = src->size + padvalue; + + dst->data = (byte*) malloc(dst->size); + + if (dst->data == (byte*) 0) + { + free(dst); + dst = (memchunk*) 0; + } + else + { + memcpy(dst->data, src->data, src->size); + memset(dst->data+src->size, padvalue, padvalue); + } + } + + return dst; +} + +memchunk* pkcs5Unpad(int blockbytes, const memchunk* src) +{ + memchunk* dst; + + if (src == (memchunk*) 0) + return (memchunk*) 0; + + dst = (memchunk*) calloc(1, sizeof(memchunk)); + + if (dst != (memchunk*) 0) + { + byte padvalue = src->data[src->size - 1]; + int i; + + for (i = (src->size - padvalue); i < (src->size - 1); i++) + { + if (src->data[i] != padvalue) + { + free(dst); + return (memchunk*) 0; + } + } + + dst->size = src->size - padvalue; + dst->data = (byte*) malloc(dst->size); + + if (dst->data == (byte*) 0) + { + free(dst); + dst = (memchunk*) 0; + } + else + { + memcpy(dst->data, src->data, dst->size); + } + } + + return dst; +} diff --git a/beecrypt/blockpad.h b/beecrypt/blockpad.h new file mode 100644 index 0000000..c845646 --- /dev/null +++ b/beecrypt/blockpad.h @@ -0,0 +1,49 @@ +/* + * blockpad.h + * + * Blockcipher padding, header + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 _BLOCKPAD_H +#define _BLOCKPAD_H + +#include "beecrypt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int pkcs5PadInline (int, memchunk*); +BEEDLLAPI +int pkcs5UnpadInline(int, memchunk*); + +BEEDLLAPI +memchunk* pkcs5Pad (int, const memchunk*); +BEEDLLAPI +memchunk* pkcs5Unpad(int, const memchunk*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/blowfish.c b/beecrypt/blowfish.c new file mode 100644 index 0000000..b35181b --- /dev/null +++ b/beecrypt/blowfish.c @@ -0,0 +1,548 @@ +/* + * blowfish.c + * + * Blowfish block cipher, code + * + * For more information on this blockcipher, see: + * "Applied Cryptography", second edition + * Bruce Schneier + * Wiley & Sons + * + * Also see: http://www.counterpane.com/blowfish.html + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "blowfish.h" +#include "endianness.h" + +#include + +static uint32 _bf_p[BLOWFISHPSIZE] = { + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x9216d5d9, 0x8979fb1b +}; + +static uint32 _bf_s[1024] = { + 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, + 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, + 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, + 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, + 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, + 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, + 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, + 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, + 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, + 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, + 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, + 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, + 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, + 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, + 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, + 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, + 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, + 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, + 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, + 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, + 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, + 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, + 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, + 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, + 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, + 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, + 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, + 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, + 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, + 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, + 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, + 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, + 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, + 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, + 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, + 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, + 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, + 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, + 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, + 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, + 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, + 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, + 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, + 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, + 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, + 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, + 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, + 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, + 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, + 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, + 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, + 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, + 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, + 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, + 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, + 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, + 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, + 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, + 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, + 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, + 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, + 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, + 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, + 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, + 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, + 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, + 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, + 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, + 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, + 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, + 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, + 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, + 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, + 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, + 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, + 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, + 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, + 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, + 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, + 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, + 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, + 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, + 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, + 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, + 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, + 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, + 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, + 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, + 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, + 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, + 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, + 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, + 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, + 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, + 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, + 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, + 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, + 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, + 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, + 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, + 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, + 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, + 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, + 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, + 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, + 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, + 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, + 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, + 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, + 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, + 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, + 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, + 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, + 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, + 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, + 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, + 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, + 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, + 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, + 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, + 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, + 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, + 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, + 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, + 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, + 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, + 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, + 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, + 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, + 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, + 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, + 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, + 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, + 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, + 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, + 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, + 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, + 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, + 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, + 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, + 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, + 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, + 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, + 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, + 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, + 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, + 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, + 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, + 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, + 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, + 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, + 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, + 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, + 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, + 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, + 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, + 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, + 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, + 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, + 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, + 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, + 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, + 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, + 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, + 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, + 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, + 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, + 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, + 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, + 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, + 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, + 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, + 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, + 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, + 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, + 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, + 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, + 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, + 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, + 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, + 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, + 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, + 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, + 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, + 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, + 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, + 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, + 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, + 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, + 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, + 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, + 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, + 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, + 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, + 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, + 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, + 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, + 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, + 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, + 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, + 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, + 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, + 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, + 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, + 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, + 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, + 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, + 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, + 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, + 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, + 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, + 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, + 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, + 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, + 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, + 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, + 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, + 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, + 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, + 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, + 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, + 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, + 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, + 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, + 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, + 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, + 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, + 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, + 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, + 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, + 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, + 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, + 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, + 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, + 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, + 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, + 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, + 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, + 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, + 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, + 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, + 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, + 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, + 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, + 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, + 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, + 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, + 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, + 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, + 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, + 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, + 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, + 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, + 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, + 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, + 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 +}; + +#define EROUND(l,r) l ^= *(p++); r ^= ((s[((l>>24)&0xff)+0x000]+s[((l>>16)&0xff)+0x100])^s[((l>>8)&0xff)+0x200])+s[((l>>0)&0xff)+0x300] +#define DROUND(l,r) l ^= *(p--); r ^= ((s[((l>>24)&0xff)+0x000]+s[((l>>16)&0xff)+0x100])^s[((l>>8)&0xff)+0x200])+s[((l>>0)&0xff)+0x300] + +static const blockMode blowfishModes[2] = +{ + { /* ECB */ (blockModeEncrypt) blowfishECBEncrypt, (blockModeDecrypt) blowfishECBDecrypt }, + { /* CBC */ (blockModeEncrypt) blowfishCBCEncrypt, (blockModeDecrypt) blowfishCBCDecrypt } +}; + +const blockCipher blowfish = { "Blowfish", sizeof(blowfishParam), 64, 448, 32, 64, (const blockCipherSetup) blowfishSetup, (const blockCipherEncrypt) blowfishEncrypt, (const blockCipherDecrypt) blowfishDecrypt, blowfishModes }; + +int blowfishSetup(blowfishParam* bp, const uint32* key, int keybits, cipherOperation op) +{ + uint32 work[2]; + + register int keywords = (keybits >> 5); /* i.e. in 32 bit words */ + register uint32* p = bp->p; + register uint32* s = bp->s; + register int i; + + if ((keywords < 2) || (keywords > 14)) + return -1; + + memcpy(p, _bf_p, BLOWFISHPSIZE * sizeof(uint32)); + memcpy(s, _bf_s, 1024 * sizeof(uint32)); + + for (i = 0; i < BLOWFISHPSIZE; i++) + { + /* key is stored in 32 bit words in host-endian format; no swap necessary */ + p[i] ^= key[i % keywords]; + } + + work[0] = work[1] = 0; + + for (i = 0; i < BLOWFISHPSIZE; i += 2, p += 2) + { + blowfishEncrypt(bp, work); + #if WORDS_BIGENDIAN + p[0] = work[0]; + p[1] = work[1]; + #else + p[0] = swapu32(work[0]); + p[1] = swapu32(work[1]); + #endif + } + + for (i = 0; i < 1024; i += 2, s += 2) + { + blowfishEncrypt(bp, work); + #if WORDS_BIGENDIAN + s[0] = work[0]; + s[1] = work[1]; + #else + s[0] = swapu32(work[0]); + s[1] = swapu32(work[1]); + #endif + } + return 0; +} + +#ifndef ASM_BLOWFISHENCRYPT +int blowfishEncrypt(blowfishParam* bp, uint32* bl) +{ + #if WORDS_BIGENDIAN + register uint32 xl = bl[0], xr = bl[1]; + #else + register uint32 xl = swapu32(bl[0]), xr = swapu32(bl[1]); + #endif + register uint32* p = bp->p; + register uint32* s = bp->s; + + EROUND(xl, xr); EROUND(xr, xl); + EROUND(xl, xr); EROUND(xr, xl); + EROUND(xl, xr); EROUND(xr, xl); + EROUND(xl, xr); EROUND(xr, xl); + EROUND(xl, xr); EROUND(xr, xl); + EROUND(xl, xr); EROUND(xr, xl); + EROUND(xl, xr); EROUND(xr, xl); + EROUND(xl, xr); EROUND(xr, xl); + + #if WORDS_BIGENDIAN + bl[1] = xl ^ *(p++); + bl[0] = xr ^ *(p++); + #else + bl[1] = swapu32(xl ^ *(p++)); + bl[0] = swapu32(xr ^ *(p++)); + #endif + + return 0; +} +#endif + +#ifndef ASM_BLOWFISHDECRYPT +int blowfishDecrypt(blowfishParam* bp, uint32* bl) +{ + #if WORDS_BIGENDIAN + register uint32 xl = bl[0], xr = bl[1]; + #else + register uint32 xl = swapu32(bl[0]), xr = swapu32(bl[1]); + #endif + register uint32* p = bp->p+BLOWFISHPSIZE-1; + register uint32* s = bp->s; + + DROUND(xl, xr); DROUND(xr, xl); + DROUND(xl, xr); DROUND(xr, xl); + DROUND(xl, xr); DROUND(xr, xl); + DROUND(xl, xr); DROUND(xr, xl); + DROUND(xl, xr); DROUND(xr, xl); + DROUND(xl, xr); DROUND(xr, xl); + DROUND(xl, xr); DROUND(xr, xl); + DROUND(xl, xr); DROUND(xr, xl); + + #if WORDS_BIGENDIAN + bl[1] = xl ^ *(p--); + bl[0] = xr ^ *(p--); + #else + bl[1] = swapu32(xl ^ *(p--)); + bl[0] = swapu32(xr ^ *(p--)); + #endif + + return 0; +} +#endif + +#ifndef ASM_BLOWFISHECBENCRYPT +int blowfishECBEncrypt(blowfishParam* bp, int count, uint32* dst, const uint32* src) +{ + while (count > 0) + { + dst[0] = src[0]; + dst[1] = src[1]; + + blowfishEncrypt(bp, dst); + + dst += 2; + src += 2; + + count--; + } + return 0; +} +#endif + +#ifndef ASM_BLOWFISHECBDECRYPT +int blowfishECBDecrypt(blowfishParam* bp, int count, uint32* dst, const uint32* src) +{ + while (count > 0) + { + dst[0] = src[0]; + dst[1] = src[1]; + + blowfishDecrypt(bp, dst); + + dst += 2; + src += 2; + + count--; + } + return 0; +} +#endif + +#ifndef ASM_BLOWFISHCBCENCRYPT +int blowfishCBCEncrypt(blowfishParam* bp, int count, uint32* dst, const uint32* src, const uint32* iv) +{ + if (count > 0) + { + if (iv) + { + dst[0] = src[0] ^ iv[0]; + dst[1] = src[1] ^ iv[1]; + } + else + { + dst[0] = src[0]; + dst[1] = src[1]; + } + + blowfishEncrypt(bp, dst); + + dst += 2; + src += 2; + + count--; + + while (count > 0) + { + dst[0] = src[0] ^ dst[-2]; + dst[1] = src[1] ^ dst[-1]; + + blowfishEncrypt(bp, dst); + + dst += 2; + src += 2; + + count--; + } + } + return 0; +} +#endif + +#ifndef ASM_BLOWFISHCBCDECRYPT +int blowfishCBCDecrypt(blowfishParam* bp, int count, uint32* dst, const uint32* src, const uint32* iv) +{ + if (count > 0) + { + dst[0] = src[0]; + dst[1] = src[1]; + + blowfishDecrypt(bp, dst); + + if (iv) + { + dst[0] ^= iv[0]; + dst[1] ^= iv[1]; + } + + dst += 2; + src += 2; + + count--; + + while (count > 0) + { + dst[0] = src[0]; + dst[1] = src[1]; + + blowfishDecrypt(bp, dst); + + dst[0] ^= src[-2]; + dst[1] ^= src[-1]; + + dst += 2; + src += 2; + + count--; + } + } + return 0; +} +#endif diff --git a/beecrypt/blowfish.h b/beecrypt/blowfish.h new file mode 100644 index 0000000..2bfc497 --- /dev/null +++ b/beecrypt/blowfish.h @@ -0,0 +1,68 @@ +/* + * blowfish.h + * + * Blowfish block cipher, header + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 _BLOWFISH_H +#define _BLOWFISH_H + +#include "beecrypt.h" +#include "blowfishopt.h" + +#define BLOWFISHROUNDS 16 +#define BLOWFISHPSIZE (BLOWFISHROUNDS+2) + +typedef struct +{ + uint32 p[BLOWFISHPSIZE]; + uint32 s[1024]; +} blowfishParam; + +#ifdef __cplusplus +extern "C" { +#endif + +extern const BEEDLLAPI blockCipher blowfish; + +BEEDLLAPI +int blowfishSetup (blowfishParam*, const uint32*, int, cipherOperation); +BEEDLLAPI +int blowfishEncrypt(blowfishParam*, uint32*); +BEEDLLAPI +int blowfishDecrypt(blowfishParam*, uint32*); + +BEEDLLAPI +int blowfishECBEncrypt(blowfishParam*, int, uint32*, const uint32*); +BEEDLLAPI +int blowfishECBDecrypt(blowfishParam*, int, uint32*, const uint32*); + +BEEDLLAPI +int blowfishCBCEncrypt(blowfishParam*, int, uint32*, const uint32*, const uint32*); +BEEDLLAPI +int blowfishCBCDecrypt(blowfishParam*, int, uint32*, const uint32*, const uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/blowfishopt.c b/beecrypt/blowfishopt.c new file mode 100644 index 0000000..1692edb --- /dev/null +++ b/beecrypt/blowfishopt.c @@ -0,0 +1,12 @@ +/* + * blowfishopt.c + * + * An empty file, in case the library is compiled on a platform for which there are no + * assembler-optimized functions implemented (yet) + * + * And just so that the compiler doesn't complain: + */ + +#define BEECRYPT_DLL_EXPORT + +#include "blowfishopt.h" diff --git a/beecrypt/blowfishopt.h b/beecrypt/blowfishopt.h new file mode 100644 index 0000000..e1b5782 --- /dev/null +++ b/beecrypt/blowfishopt.h @@ -0,0 +1,54 @@ +/* + * blowfishopt.h + * + * Blowfish block cipher assembler-optimized routines, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _BLOWFISHOPT_H +#define _BLOWFISHOPT_H + +#include "beecrypt.h" +#include "blowfish.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if WIN32 +#if __INTEL__ && __MWERKS__ +#define ASM_BLOWFISHENCRYPT +#define ASM_BLOWFISHDECRYPT +#endif +#endif + +#ifdef __GNUC__ +#if defined(i586) || defined(i686) +#define ASM_BLOWFISHENCRYPT +#define ASM_BLOWFISHDECRYPT +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/config.gas.h b/beecrypt/config.gas.h new file mode 100644 index 0000000..66d6b01 --- /dev/null +++ b/beecrypt/config.gas.h @@ -0,0 +1,74 @@ +#ifndef _CONFIG_GAS_H +#define _CONFIG_GAS_H + +#include "config.gnu.h" + +#ifndef C_FUNCTION_NAME +# if LEADING_UNDERSCORE +# ifdef __STDC__ +# define C_FUNCTION_NAME(name) _##name +# else +# define C_FUNCTION_NAME(name) _/**/name +# endif +# else +# define C_FUNCTION_NAME(name) name +# endif +#endif + +#if defined(OPTIMIZE_ALPHA) +# define ALIGNMENT 5 +#elif defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) +# define ALIGNMENT 8 +#elif defined(OPTIMIZE_IA64) +# define ALIGNMENT 32 +#elif defined(OPTIMIZE_ARM) +# define ALIGNMENT 4 +#elif defined(OPTIMIZE_POWERPC) +# define ALIGNMENT 8 +#elif defined(OPTIMIZE_SPARCV8PLUS) || defined(OPTIMIZE_SPARCV9) +# define ALIGNMENT 8 +#else +# define ALIGNMENT 8 +#endif + +#if CYGWIN +# define C_FUNCTION_BEGIN(name) \ + .align ALIGNMENT; \ + .globl C_FUNCTION_NAME(name); \ + .def C_FUNCTION_NAME(name); \ + .scl 2; \ + .type 32; \ + .endef; \ +C_FUNCTION_NAME(name): +# define C_FUNCTION_END(name, label) +#else +# if SOLARIS +# define C_FUNCTION_TYPE #function +# elif defined(OPTIMIZE_ARM) +# define C_FUNCTION_TYPE %function +# else +# define C_FUNCTION_TYPE @function +# endif +# if DARWIN +# define C_FUNCTION_BEGIN(name) \ + .type C_FUNCTION_NAME(name),C_FUNCTION_TYPE; \ +C_FUNCTION_NAME(name): +# elif defined(OPTIMIZE_IA64) +# define C_FUNCTION_BEGIN(name) \ + .align ALIGNMENT; \ + .global name#; \ + .proc name#; \ +name: +# define C_FUNCTION_END(name) \ + .endp name# +# else +# define C_FUNCTION_BEGIN(name) \ + .align ALIGNMENT; \ + .global C_FUNCTION_NAME(name); \ +C_FUNCTION_NAME(name): +# define C_FUNCTION_END(name, label) \ + label: .size name,label-name; +# endif +#endif + +#endif diff --git a/beecrypt/config.gnu.h.in b/beecrypt/config.gnu.h.in new file mode 100644 index 0000000..7a745eb --- /dev/null +++ b/beecrypt/config.gnu.h.in @@ -0,0 +1,259 @@ +/* config.gnu.h.in. Generated automatically from configure.in by autoheader. */ +/* + * acconfig.h + * + * acconfig.h pre-announces symbols defines by configure.in + * + * Copyright (c) 2001 Virtual Unlimited B.V. + * + * Author: 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 _REENTRANT +#define _REENTRANT +#endif + +#undef PACKAGE +#undef VERSION + +#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 HAVE_ERRNO_H +#undef HAVE_STRING_H +#undef HAVE_CTYPE_H +#undef HAVE_STDLIB_H +#undef HAVE_MTMALLOC_H + +#undef HAVE_UNISTD_H +#undef HAVE_FCNTL_H + +#undef HAVE_TIME_H + +#undef HAVE_SYS_TYPES_H +#undef HAVE_SYS_STAT_H +#undef HAVE_SYS_TIME_H + +#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_TERMIO_H +#undef HAVE_TERMIOS_H + +#undef HAVE_SYS_AUDIOIO_H +#undef HAVE_SYS_IOCTL_H +#undef HAVE_SYS_SOUNDCARD_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 + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define if you have the header file. */ +#undef HAVE_AIO_H + +/* Define if you have the header file. */ +#undef HAVE_CTYPE_H + +/* Define if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_INTTYPES_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 + +/* Define if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define if you have the header file. */ +#undef HAVE_MTMALLOC_H + +/* Define if you have the header file. */ +#undef HAVE_PTHREAD_H + +/* Define if you have the header file. */ +#undef HAVE_SEMAPHORE_H + +/* Define if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the header file. */ +#undef HAVE_SYNCH_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_AUDIOIO_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SOUNDCARD_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIO_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define if you have the header file. */ +#undef HAVE_THREAD_H + +/* Define if you have the header file. */ +#undef HAVE_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +#undef inline + +/* Name of package */ +#undef PACKAGE + +/* Define to `unsigned' if does not define. */ +#undef size_t + +/* The size of a `char', as computed by sizeof. */ +#undef SIZEOF_CHAR + +/* The size of a `double', as computed by sizeof. */ +#undef SIZEOF_DOUBLE + +/* The size of a `float', as computed by sizeof. */ +#undef SIZEOF_FLOAT + +/* The size of a `int', as computed by sizeof. */ +#undef SIZEOF_INT + +/* The size of a `long', as computed by sizeof. */ +#undef SIZEOF_LONG + +/* The size of a `long long', as computed by sizeof. */ +#undef SIZEOF_LONG_LONG + +/* The size of a `short', as computed by sizeof. */ +#undef SIZEOF_SHORT + +/* The size of a `unsigned char', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_CHAR + +/* The size of a `unsigned int', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_INT + +/* The size of a `unsigned long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG + +/* The size of a `unsigned long long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG_LONG + +/* The size of a `unsigned short', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_SHORT + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define if your processor stores words with the most significant byte first + (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN diff --git a/beecrypt/config.guess b/beecrypt/config.guess new file mode 100755 index 0000000..72f934d --- /dev/null +++ b/beecrypt/config.guess @@ -0,0 +1,1012 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# The master version of this file is at the FSF in /home/gd/gnu/lib. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than generic posix subsystem? + # Should we change UNAME_MACHINE based on the output of uname + # instead of the specific alpha model. + echo alpha-pc-interix + exit 0;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:NetBSD:*:*) + echo m68k-cbm-netbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:NetBSD:*:*) + echo m68k-atari-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:NetBSD:*:*) + echo m68k-sun-netbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:NetBSD:*:*) + echo m68k-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >dummy.c + int main (argc, argv) int argc; char **argv; { + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + ${CC-cc} dummy.c -o dummy \ + && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + *9??*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9] ) + + sed 's/^ //' << EOF >dummy.c + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy` + rm -f dummy.c dummy + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + if test -x /usr/bin/objformat -a "elf" = "`/usr/bin/objformat`"; then + echo ${UNAME_MACHINE}-unknown-freebsdelf + else + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` + fi + exit 0 ;; + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin32 + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than generic posix subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # change UNAME_MACHINE based on the output of uname instead of + # i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin32 + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + # uname on the ARM produces all sorts of strangeness, and we need to + # filter it out. + case "$UNAME_MACHINE" in + armv*) UNAME_MACHINE=$UNAME_MACHINE ;; + arm* | sa110*) UNAME_MACHINE="arm" ;; + esac + + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. + ld_help_string=`ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc | elf32ppclinux) + # Determine Lib Version + cat >dummy.c < +#if defined(__GLIBC__) +extern char __libc_version[]; +extern char __libc_release[]; +#endif +main(argc, argv) + int argc; + char *argv[]; +{ +#if defined(__GLIBC__) + printf("%s %s\n", __libc_version, __libc_release); +#else + printf("unkown\n"); +#endif + return 0; +} +EOF + LIBC="" + ${CC-cc} dummy.c -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy | grep 1\.99 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f dummy.c dummy + echo powerpc-unknown-linux-gnu${LIBC} ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + LIBC="" + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + + objdump --private-headers dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >dummy.c < +main(argc, argv) + int argc; + char *argv[]; +{ +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + fi ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:5:7*) + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 +# 5.0.4c returns "Pent II". 5.0.5 returns PentII + (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE} + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*PentII' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pent II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 +rm -f dummy.c dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/beecrypt/config.h b/beecrypt/config.h new file mode 100644 index 0000000..8100619 --- /dev/null +++ b/beecrypt/config.h @@ -0,0 +1,41 @@ +/* + * config.h + * + * Config.h generic config file + * + * Copyright (c) 2000, Virtual Unlimited B.V. + * + * Author: 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 _CONFIG_H +#define _CONFIG_H + +#if WIN32 +# include "win32/config.win.h" +# ifdef BEECRYPT_DLL_EXPORT +# define BEEDLLAPI +# else +# define BEEDLLAPI __declspec(dllimport) +# endif +#else +# include "gnu/config.gnu.h" +# define BEEDLLAPI +#endif + +#endif diff --git a/beecrypt/config.sub b/beecrypt/config.sub new file mode 100755 index 0000000..3d2a1bf --- /dev/null +++ b/beecrypt/config.sub @@ -0,0 +1,1238 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc. +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond ) # EGCS LOCAL + os= + basic_machine=$1 + ;; + -scout) # EGCS LOCAL + ;; + -wrs) # EGCS LOCAL + os=vxworks + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 \ + | tron | a29k | 580 | i960 | h8300 \ + | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ + | alpha | alphaev5 | alphaev56 | alphapca56 | alphaev6 \ + | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \ + | 1750a | dsp16xx | pdp11 \ + | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ + | mipstx39 | mipstx39el \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x) + basic_machine=$basic_machine-unknown + ;; + m88110 | m680[012346]0 | m683?2 | m68360 | m5200 | z8k | v70 \ + | h8500 | w65) # EGCS LOCAL + ;; + thumb) + basic_machine=$basic_machine-unknown + ;; + mips64vr4300 | mips64vr4300el) # EGCS LOCAL jsmith/vr4300 + basic_machine=$basic_machine-unknown + ;; + mips64vr4100 | mips64vr4100el) # EGCS LOCAL jsmith/vr4100 + basic_machine=$basic_machine-unknown + ;; + mips64vr5000 | mips64vr5000el) # EGCS LOCAL ian/vr5000 + basic_machine=$basic_machine-unknown + ;; + mips16) + basic_machine=$basic_machine-unknown + ;; + d10v) + basic_machine=$basic_machine-unknown + ;; + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[34567]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | xmp-* | ymp-* \ + | hppa-* | hppa1.0-* | hppa1.1-* \ + | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \ + | alpha-* | alphaev5-* | alphaev56-* | alphapca56-* \ + | alphaev6-* | we32k-* | cydra-* | ns16k-* | pn-* | np1-* \ + | xps100-* | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | sparc-* | sparcv8-* | sparcv8plus-* | sparcv9-* | sparc86x-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mipstx39-* | mipstx39el-* \ + | f301-* | arm*-*) + ;; + m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | h8500-* | d10v-*) # EGCS LOCAL + ;; + thumb-*) # EGCS LOCAL angela/thumb + ;; + v850-*) # EGCS LOCAL + ;; + d30v-*) # EGCS LOCAL + ;; + mips64vr4300-* | mips64vr4300el-*) # EGCS LOCAL jsmith/vr4300 + ;; + mips64vr4100-* | mips64vr4100el-*) # EGCS LOCAL jsmith/vr4100 + ;; + mips16-*) # EGCS LOCAL krk/mips16 + ;; + tic30-*) # EGCS LOCAL ian/tic30 + ;; + c30-*) # EGCS LOCAL ian/tic30 + basic_machine=tic30-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) # EGCS LOCAL + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) # EGCS LOCAL + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) # EGCS LOCAL + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) # EGCS LOCAL + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) # EGCS LOCAL + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) # EGCS LOCAL + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) # EGCS LOCAL + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + w89k-*) # EGCS LOCAL + basic_machine=hppa1.1-winbond + os=-proelf + ;; + op50n-*) # EGCS LOCAL + basic_machine=hppa1.1-oki + os=-proelf + ;; + op60c-*) # EGCS LOCAL + basic_machine=hppa1.1-oki + os=-proelf + ;; + hppro) # EGCS LOCAL + basic_machine=hppa1.1-hp + os=-proelf + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9] ) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9] ) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9] ) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | \ + hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893 ) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679] ) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) # EGCS LOCAL + basic_machine=hppa1.1-hp + os=-osf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + os=-mvs + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[34567]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[34567]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[34567]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[34567]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) # EGCS LOCAL + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) # EGCS LOCAL + basic_machine=i386-unknown + os=-vsta + ;; + i386-go32 | go32) # EGCS LOCAL + basic_machine=i386-unknown + os=-go32 + ;; + i386-mingw32 | mingw32) + basic_machine=i386-unknown + os=-mingw32 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) # EGCS LOCAL + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) # EGCS LOCAL + basic_machine=i386-unknown + os=-msdos + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown # EGCS LOCAL + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-corel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) # EGCS LOCAL + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) # EGCS LOCAL + basic_machine=i960-intel + os=-mon960 + ;; + np1) + basic_machine=np1-gould + ;; + OSE68000 | ose68000) # EGCS LOCAL + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) # EGCS LOCAL + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rom68k) # EGCS LOCAL + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) # EGCS LOCAL + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) # EGCS LOCAL + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) # EGCS LOCAL + basic_machine=m68k-tandem + ;; + stratus) # EGCS LOCAL + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) # EGCS LOCAL + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) # EGCS LOCAL + basic_machine=w65-wdc + os=-none + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) # EGCS LOCAL + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) # EGCS LOCAL + basic_machine=hppa1.1-winbond + ;; + op50n) # EGCS LOCAL + basic_machine=hppa1.1-oki + ;; + op60c) # EGCS LOCAL + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc | sparcv9) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) # EGCS LOCAL + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) # EGCS LOCAL + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* ) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + # EGCS LOCAL + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mon960* | -lnews* ) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + # END EGCS LOCAL + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) # EGCS LOCAL + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) # EGCS LOCAL + os=-ose + ;; + -es1800*) # EGCS LOCAL + os=-ose + ;; + -xenix) + os=-xenix + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-corel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) # EGCS LOCAL + os=-aout + ;; + mips*-cisco) # EGCS LOCAL + os=-elf + ;; + mips*-*) # EGCS LOCAL + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) # EGCS LOCAL + os=-proelf + ;; + *-winbond) # EGCS LOCAL + os=-proelf + ;; + *-oki) # EGCS LOCAL + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *-rom68k) # EGCS LOCAL + os=-coff + ;; + *-*bug) # EGCS LOCAL + os=-coff + ;; + *-apple) # EGCS LOCAL + os=-macos + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) # EGCS LOCAL + vendor=hitachi + ;; + -mpw* | -macos*) # EGCS LOCAL + vendor=apple + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/beecrypt/config.win.h b/beecrypt/config.win.h new file mode 100644 index 0000000..5107b4b --- /dev/null +++ b/beecrypt/config.win.h @@ -0,0 +1,126 @@ +/* + * config.win.h + * + * Win32 config file + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 _CONFIG_WIN_H +#define _CONFIG_WIN_H + +#define _REENTRANT + +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x0400 +#endif + +#include + +#if __MWERKS__ +# if __INTEL__ +# define WORDS_BIGENDIAN 0 +# else +# error Unknown CPU type in MetroWerks CodeWarrior +# endif +#elif defined(_MSC_VER) +# if defined(_M_IX86) +# define WORDS_BIGENDIAN 0 +# define ROTL32(x, s) _rotl(x, s) +# define ROTR32(x, s) _rotr(x, s) +# else +# error Unknown CPU type in Microsoft Visual C +# endif +#else +# error Unknown compiler for WIN32 +#endif + +#if defined(_MSC_VER) || __MWERKS__ +#define HAVE_ERRNO_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_FCNTL_H 1 +#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 +#define HAVE_SYNCH_H 0 +#define HAVE_PTHREAD_H 0 +#define HAVE_SEMAPHORE_H 0 + +#define HAVE_TERMIO_H 0 +#define HAVE_SYS_AUDIOIO_H 0 +#define HAVE_SYS_IOCTL_H 0 +#define HAVE_SYS_SOUNDCARD_H 0 + +#define HAVE_GETTIMEOFDAY 0 +#define HAVE_GETHRTIME 0 + +#define HAVE_DEV_TTY 0 +#define HAVE_DEV_AUDIO 0 +#define HAVE_DEV_DSP 0 +#define HAVE_DEV_RANDOM 0 +#define HAVE_DEV_URANDOM 0 +#define HAVE_DEV_TTY 0 + +#else +#error Not set up for this compiler +#endif + +#if __MWERKS__ +#define HAVE_UNISTD_H 1 +#define HAVE_MALLOC_H 1 + +#define HAVE_LONG_LONG 1 + +#define INT8_TYPE char +#define INT16_TYPE short +#define INT32_TYPE int +#define INT64_TYPE long long +#define UINT8_TYPE unsigned char +#define UINT16_TYPE unsigned short +#define UINT32_TYPE unsigned int +#define UINT64_TYPE unsigned long long +#define FLOAT4_TYPE float +#define DOUBLE8_TYPE double + +#elif defined(_MSC_VER) +#define HAVE_UNISTD_H 0 +#define HAVE_MALLOC_H 1 + +#define HAVE_LONG_LONG 0 + +#define INT8_TYPE __int8 +#define INT16_TYPE __int16 +#define INT32_TYPE __int32 +#define INT64_TYPE __int64 +#define UINT8_TYPE unsigned __int8 +#define UINT16_TYPE unsigned __int16 +#define UINT32_TYPE unsigned __int32 +#define UINT64_TYPE unsigned __int64 +#define FLOAT4_TYPE float +#define DOUBLE8_TYPE double +#endif + +#endif diff --git a/beecrypt/configure b/beecrypt/configure new file mode 100755 index 0000000..2da9910 --- /dev/null +++ b/beecrypt/configure @@ -0,0 +1,2944 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-debug creates debugging code [default=no]" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file= + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Do some error checking and defaulting for the host and target type. +# The inputs are: +# configure --host=HOST --target=TARGET --build=BUILD NONOPT +# +# The rules are: +# 1. You are not allowed to specify --host, --target, and nonopt at the +# same time. +# 2. Host defaults to nonopt. +# 3. If nonopt is not specified, then host defaults to the current host, +# as determined by config.guess. +# 4. Target and build default to nonopt. +# 5. If nonopt is not specified, then target and build default to host. + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +case $host---$target---$nonopt in +NONE---*---* | *---NONE---* | *---*---NONE) ;; +*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; +esac + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:574: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:595: checking target system type" >&5 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:613: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +test "$host_alias" != "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + +case $target_os in + solaris*) + cat >> confdefs.h <<\EOF +#define SOLARIS 1 +EOF + + ;; + linux*) + cat >> confdefs.h <<\EOF +#define LINUX 1 +EOF + + ;; + *) + { echo "configure: error: +Operating system type $host currently not supported/tested +" 1>&2; exit 1; } + ;; +esac + + + +# Check whether --enable-debug or --disable-debug was given. +if test "${enable_debug+set}" = set; then + enableval="$enable_debug" + if test "$enableval" = no; then + ac_use_debug_code=no + else + ac_use_debug_code=yes + fi + +else + ac_use_debug_code=no +fi + + +PRODUCT=beecrypt +VERSION=1.0.0 +cat >> confdefs.h <> confdefs.h <&6 +echo "configure:688: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:718: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:769: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:801: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 812 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:843: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:848: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:876: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:919: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:973: checking for inline" >&5 +if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_inline=$ac_kw; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done + +fi + +echo "$ac_t""$ac_cv_c_inline" 1>&6 +case "$ac_cv_c_inline" in + inline | yes) ;; + no) cat >> confdefs.h <<\EOF +#define inline +EOF + ;; + *) cat >> confdefs.h <&6 +echo "configure:1015: checking whether we are using Sun Workshop C" >&5 + cat > conftest.c << EOF +#ifdef __SUNPRO_C + yes; +#endif +EOF + ac_try="$CC -E conftest.c" + if { (eval echo configure:__online__: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } | egrep yes > /dev/null 2>&1; then + ac_cv_prog_SUNPRO_CC=yes + # test version of sunpro cc here + else + ac_cv_prog_SUNPRO_CC=no + fi + echo "$ac_t""$ac_cv_prog_SUNPRO_CC" 1>&6 +fi + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:1032: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1086: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1107: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1128: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1145: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1162: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1187: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1200: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:1291: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + + +echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 +echo "configure:1325: checking for 8-bit clean memcmp" >&5 +if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_memcmp_clean=no +else + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_func_memcmp_clean=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_memcmp_clean=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 +test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" + + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1362: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1375: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + +for ac_hdr in errno.h string.h ctype.h stdlib.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1470: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1480: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in unistd.h fcntl.h limits.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1510: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1520: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in time.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1550: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1560: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in sys/types.h sys/stat.h sys/time.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1590: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1600: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in thread.h pthread.h synch.h semaphore.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1630: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1640: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in termio.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1670: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in sys/audioio.h sys/ioctl.h sys/soundcard.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1710: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1720: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + + +if test "$ac_cv_header_sys_time_h" = yes; then + echo $ac_n "checking for gettimeofday""... $ac_c" 1>&6 +echo "configure:1749: checking for gettimeofday" >&5 +if eval "test \"`echo '$''{'ac_cv_func_gettimeofday'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gettimeofday(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_gettimeofday) || defined (__stub___gettimeofday) +choke me +#else +gettimeofday(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_gettimeofday=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_gettimeofday=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'gettimeofday`\" = yes"; then + echo "$ac_t""yes" 1>&6 + + cat >> confdefs.h <<\EOF +#define HAVE_GETTIMEOFDAY 1 +EOF + + +else + echo "$ac_t""no" 1>&6 +fi + + echo $ac_n "checking for gethrtime""... $ac_c" 1>&6 +echo "configure:1802: checking for gethrtime" >&5 +if eval "test \"`echo '$''{'ac_cv_func_gethrtime'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethrtime(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_gethrtime) || defined (__stub___gethrtime) +choke me +#else +gethrtime(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_gethrtime=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_gethrtime=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'gethrtime`\" = yes"; then + echo "$ac_t""yes" 1>&6 + + cat >> confdefs.h <<\EOF +#define HAVE_GETHRTIME 1 +EOF + + +else + echo "$ac_t""no" 1>&6 +fi + +fi + +if test "$ac_cv_header_thread_h" = yes; then + echo $ac_n "checking for -lthread""... $ac_c" 1>&6 +echo "configure:1858: checking for -lthread" >&5 +if eval "test \"`echo '$''{'ac_cv_lib_thread'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lthread $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_lib_thread=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_lib_thread=no +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +echo "$ac_t""$ac_cv_lib_thread" 1>&6 +if test "$ac_cv_lib_thread" = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_LIBTHREAD 1 +EOF + + LIBS="-lthread $LIBS" + +fi + +elif test "$ac_cv_header_pthread_h" = yes; then + echo $ac_n "checking for -lpthread""... $ac_c" 1>&6 +echo "configure:1897: checking for -lpthread" >&5 +if eval "test \"`echo '$''{'ac_cv_lib_pthread'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lpthread $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_lib_pthread=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_lib_pthread=no +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +echo "$ac_t""$ac_cv_lib_pthread" 1>&6 +if test "$ac_cv_lib_pthread" = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_LIBPTHREAD 1 +EOF + + LIBS="-lpthread $LIBS" + +fi + +fi + +echo $ac_n "checking size of char""... $ac_c" 1>&6 +echo "configure:1937: checking size of char" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(char)); + exit(0); +} +EOF +if { (eval echo configure:1956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_char=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_char=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_char" 1>&6 +cat >> confdefs.h <&6 +echo "configure:1976: checking size of unsigned char" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_char'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(unsigned char)); + exit(0); +} +EOF +if { (eval echo configure:1995: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_unsigned_char=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_unsigned_char=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_unsigned_char" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2015: checking size of short" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(short)); + exit(0); +} +EOF +if { (eval echo configure:2034: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_short=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_short=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_short" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2054: checking size of unsigned short" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_short'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(unsigned short)); + exit(0); +} +EOF +if { (eval echo configure:2073: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_unsigned_short=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_unsigned_short=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_unsigned_short" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2093: checking size of int" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(int)); + exit(0); +} +EOF +if { (eval echo configure:2112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_int=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_int=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_int" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2132: checking size of unsigned int" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_int'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(unsigned int)); + exit(0); +} +EOF +if { (eval echo configure:2151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_unsigned_int=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_unsigned_int=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_unsigned_int" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2171: checking size of long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long)); + exit(0); +} +EOF +if { (eval echo configure:2190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_long" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2210: checking size of unsigned long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(unsigned long)); + exit(0); +} +EOF +if { (eval echo configure:2229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_unsigned_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_unsigned_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_unsigned_long" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2249: checking size of long long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long long)); + exit(0); +} +EOF +if { (eval echo configure:2268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_long_long" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2288: checking size of unsigned long long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_long_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(unsigned long long)); + exit(0); +} +EOF +if { (eval echo configure:2307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_unsigned_long_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_unsigned_long_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_unsigned_long_long" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2327: checking size of float" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(float)); + exit(0); +} +EOF +if { (eval echo configure:2346: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_float=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_float=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_float" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2366: checking size of double" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(double)); + exit(0); +} +EOF +if { (eval echo configure:2385: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_double=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_double=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_double" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2406: checking whether byte ordering is bigendian" >&5 +if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_bigendian=unknown +# See if sys/param.h defines the BYTE_ORDER macro. +cat > conftest.$ac_ext < +#include +int main() { + +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif +; return 0; } +EOF +if { (eval echo configure:2424: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + # It does; now see whether it defined to BIG_ENDIAN or not. +cat > conftest.$ac_ext < +#include +int main() { + +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif +; return 0; } +EOF +if { (eval echo configure:2439: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_bigendian=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_bigendian=no +fi +rm -f conftest* +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +if test $ac_cv_c_bigendian = unknown; then +if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_c_bigendian=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_c_bigendian=yes +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_c_bigendian" 1>&6 +if test $ac_cv_c_bigendian = yes; then + cat >> confdefs.h <<\EOF +#define WORDS_BIGENDIAN 1 +EOF + +fi + + +if test "$ac_use_debug_code" = yes; then + if test "$ac_cv_prog_gcc" = yes; then + CFLAGS="-g -shared" + elif test "$ac_cv_prog_SUNPRO_CC" = yes; then + CFLAGS="-g -mt -KPIC" + else + CFLAGS="-g -shared" + fi +else + if test "$ac_cv_prog_gcc" = yes; then + CFLAGS="-O3 -shared" + case $target_cpu in + i386) + ;; + i486) + CFLAGS="$CFLAGS -m486 -Di486" ;; + i586) + CFLAGS="$CFLAGS -mpentium -Di586" ;; + i686) + CFLAGS="$CFLAGS -mpentiumpro -Di686" ;; + *) + echo "Don't know how to optimize for" $target_cpu ;; + esac + elif test "$ac_cv_prog_SUNPRO_CC" = yes; then + CFLAGS="-fast -mt -KPIC" + case $target_cpu in + sparcv8plus) + CFLAGS="$CFLAGS -Dsparcv8plus -xchip=ultra -xarch=v8plus" ;; + sparcv9) + CFLAGS="$CFLAGS -Dsparcv9 -xchip=ultra -xarch=v9" ;; + *) + echo "Using general optimization for" $target_cpu ;; + esac + else + CFLAGS="-O2 -shared" + fi +fi + +echo $ac_n "checking for entropy device""... $ac_c" 1>&6 +echo "configure:2535: checking for entropy device" >&5 +case $host in + *-*-solaris*) + cat >> confdefs.h <<\EOF +#define HAVE_DEV_AUDIO 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_DEV_TTY 1 +EOF + + ac_cv_entropy_device="/dev/audio,/dev/tty" + ;; + *-*-linux*) + cat >> confdefs.h <<\EOF +#define HAVE_DEV_DSP 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_DEV_RANDOM 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_DEV_TTY 1 +EOF + + ac_cv_entropy_device="/dev/dsp,/dev/random,/dev/tty" + ;; + *) + { echo "configure: error: +There is no entropy device to initialize the random generator on host $host +" 1>&2; exit 1; } + ;; +esac +echo "$ac_t""$ac_cv_entropy_device" 1>&6 + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile gnu/config.gnu.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@PRODUCT@%$PRODUCT%g +s%@VERSION@%$VERSION%g +s%@CC@%$CC%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@CPP@%$CPP%g +s%@LIBOBJS@%$LIBOBJS%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/beecrypt/configure.in b/beecrypt/configure.in new file mode 100644 index 0000000..a8598f8 --- /dev/null +++ b/beecrypt/configure.in @@ -0,0 +1,174 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT() +AC_CANONICAL_SYSTEM + +dnl Check system type +case $target_os in + solaris*) + AC_DEFINE(SOLARIS) + ;; + linux*) + AC_DEFINE(LINUX) + ;; + *) + AC_MSG_ERROR([ +Operating system type $host currently not supported/tested +]) + ;; +esac + +dnl Generate the config header +AC_CONFIG_HEADER(gnu/config.gnu.h) + +AC_ARG_ENABLE(debug, [ --enable-debug creates debugging code [default=no]], + [ if test "$enableval" = no; then + ac_use_debug_code=no + else + ac_use_debug_code=yes + fi + ], [ ac_use_debug_code=no]) + +dnl Product and version +PRODUCT=beecrypt +VERSION=1.0.0 +AC_DEFINE_UNQUOTED(PRODUCT, "$PRODUCT") +AC_DEFINE_UNQUOTED(VERSION, "$VERSION") +AC_SUBST(PRODUCT) +AC_SUBST(VERSION) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL + +AC_C_INLINE + +if test "$ac_cv_prog_gcc" != yes; then + AC_MSG_CHECKING(whether we are using Sun Workshop C) + cat > conftest.c << EOF +#ifdef __SUNPRO_C + yes; +#endif +EOF + ac_try="$CC -E conftest.c" + if { (eval echo configure:__online__: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } | egrep yes > /dev/null 2>&1; then + ac_cv_prog_SUNPRO_CC=yes + # test version of sunpro cc here + else + ac_cv_prog_SUNPRO_CC=no + fi + AC_MSG_RESULT($ac_cv_prog_SUNPRO_CC) +fi + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +dnl Checks for library functions. +AC_FUNC_MEMCMP + +dnl Checks for header files. +AC_HEADER_STDC + +AC_CHECK_HEADERS(errno.h string.h ctype.h stdlib.h) +AC_CHECK_HEADERS(unistd.h fcntl.h limits.h) +AC_CHECK_HEADERS(time.h) +AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h) +AC_CHECK_HEADERS(thread.h pthread.h synch.h semaphore.h) +AC_CHECK_HEADERS(termio.h) +AC_CHECK_HEADERS(sys/audioio.h sys/ioctl.h sys/soundcard.h) + +if test "$ac_cv_header_sys_time_h" = yes; then + AC_CHECK_FUNC(gettimeofday, [ + AC_DEFINE(HAVE_GETTIMEOFDAY, 1) + ]) + AC_CHECK_FUNC(gethrtime, [ + AC_DEFINE(HAVE_GETHRTIME, 1) + ]) +fi + +if test "$ac_cv_header_thread_h" = yes; then + AC_HAVE_LIBRARY(thread) +elif test "$ac_cv_header_pthread_h" = yes; then + AC_HAVE_LIBRARY(pthread) +fi + +dnl Checks for word sizes +AC_CHECK_SIZEOF(char) +AC_CHECK_SIZEOF(unsigned char) +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(unsigned short) +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(unsigned int) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(unsigned long) +AC_CHECK_SIZEOF(long long) +AC_CHECK_SIZEOF(unsigned long long) +AC_CHECK_SIZEOF(float) +AC_CHECK_SIZEOF(double) + +dnl Checks for endianness +AC_C_BIGENDIAN + +dnl Checks for compiler flags +if test "$ac_use_debug_code" = yes; then + if test "$ac_cv_prog_gcc" = yes; then + CFLAGS="-g -shared" + elif test "$ac_cv_prog_SUNPRO_CC" = yes; then + CFLAGS="-g -mt -KPIC" + else + CFLAGS="-g -shared" + fi +else + if test "$ac_cv_prog_gcc" = yes; then + CFLAGS="-O3 -shared" + case $target_cpu in + i386) + ;; + i486) + CFLAGS="$CFLAGS -m486 -Di486" ;; + i586) + CFLAGS="$CFLAGS -mpentium -Di586" ;; + i686) + CFLAGS="$CFLAGS -mpentiumpro -Di686" ;; + *) + echo "Don't know how to optimize for" $target_cpu ;; + esac + elif test "$ac_cv_prog_SUNPRO_CC" = yes; then + CFLAGS="-fast -mt -KPIC" + case $target_cpu in + sparcv8plus) + CFLAGS="$CFLAGS -Dsparcv8plus -xchip=ultra -xarch=v8plus" ;; + sparcv9) + CFLAGS="$CFLAGS -Dsparcv9 -xchip=ultra -xarch=v9" ;; + *) + echo "Using general optimization for" $target_cpu ;; + esac + else + CFLAGS="-O2 -shared" + fi +fi + +dnl Checks for devices +AC_MSG_CHECKING(for entropy device) +case $host in + *-*-solaris*) + AC_DEFINE(HAVE_DEV_AUDIO,1) + AC_DEFINE(HAVE_DEV_TTY,1) + ac_cv_entropy_device="/dev/audio,/dev/tty" + ;; + *-*-linux*) + AC_DEFINE(HAVE_DEV_DSP,1) + AC_DEFINE(HAVE_DEV_RANDOM,1) + AC_DEFINE(HAVE_DEV_TTY,1) + ac_cv_entropy_device="/dev/dsp,/dev/random,/dev/tty" + ;; + *) + AC_MSG_ERROR([ +There is no entropy device to initialize the random generator on host $host +]) + ;; +esac +AC_MSG_RESULT($ac_cv_entropy_device) + +dnl Output +AC_OUTPUT(Makefile) diff --git a/beecrypt/dhaes.c b/beecrypt/dhaes.c new file mode 100644 index 0000000..a34144c --- /dev/null +++ b/beecrypt/dhaes.c @@ -0,0 +1,284 @@ +/* + * dhaes.c + * + * DHAES, code + * + * This code implements the encryption scheme from the paper: + * + * "DHAES: An Encryption Scheme Based on the Diffie-Hellman Problem" + * Michel Abdalla, Mihir Bellare, Phillip Rogaway + * September 1998 + * + * Copyright (c) 2000, 2001 Virtual Unlimited, B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "dhaes.h" +#include "dlsvdp-dh.h" +#include "blockmode.h" +#include "blockpad.h" + +#if HAVE_STDLIB_H +# include +#endif + +/** + * + * Good combinations will be: + * + * For 64-bit encryption: + * DHAES(Blowfish, MD5/HMAC, MD5) + * DHAES(Blowfish, SHA-1/HMAC, MD5) + * DHAES(Blowfish, SHA-256/HMAC, MD5) + * + * For 128-bit encryption: + * DHAES(Blowfish, MD5/HMAC, SHA-256) + * DHAES(Blowfish, SHA-1/HMAC, SHA-256) + * DHAES(Blowfish, SHA-256/HMAC, SHA-256) + * + */ + +int dhaes_usable(const blockCipher* cipher, const keyedHashFunction* mac, const hashFunction* hash) +{ + int keybits = hash->digestsize << 4; + + /* test if keybits is a multiple of 32 */ + if ((keybits & 31) != 0) + return 0; + + /* test if keybits length is appropriate for cipher */ + if ((keybits < cipher->keybitsmin) || (keybits > cipher->keybitsmax)) + return 0; + + if (((keybits - cipher->keybitsmin) % cipher->keybitsinc) != 0) + return 0; + + /* test if keybits length is appropriate for mac */ + if ((keybits < mac->keybitsmin) || (keybits > mac->keybitsmax)) + return 0; + + if (((keybits - mac->keybitsmin) % mac->keybitsinc) != 0) + return 0; + + return 1; +} + +int dhaes_pInit(dhaes_p* p, const dldp_p* param, const blockCipher* cipher, const keyedHashFunction* mac, const hashFunction* hash, const randomGenerator* rng) +{ + if (dhaes_usable(cipher, mac, hash)) + { + dldp_pInit(&p->param); + dldp_pCopy(&p->param, param); + + if (blockCipherContextInit(&p->cipher, cipher)) + return -1; + + if (keyedHashFunctionContextInit(&p->mac, mac)) + return -1; + + if (hashFunctionContextInit(&p->hash, hash)) + return -1; + + if (randomGeneratorContextInit(&p->rng, rng)) + return -1; + + return 0; + } + return -1; +} + +int dhaes_pFree(dhaes_p* p) +{ + dldp_pFree(&p->param); + + if (blockCipherContextFree(&p->cipher)) + return -1; + + if (hashFunctionContextFree(&p->hash)) + return -1; + + if (keyedHashFunctionContextFree(&p->mac)) + return -1; + + if (randomGeneratorContextFree(&p->rng)) + return -1; + + return 0; +} + +static int dhaes_pSetup(dhaes_p* p, const mp32number* private, const mp32number* public, const mp32number* message, cipherOperation op) +{ + register int rc; + + mp32number secret; + mp32number digest; + + /* compute the shared secret, Diffie-Hellman style */ + mp32nzero(&secret); + dlsvdp_pDHSecret(&p->param, private, public, &secret); + + /* compute the hash of the message (ephemeral public) key and the shared secret */ + mp32nzero(&digest); + hashFunctionContextReset (&p->hash); + hashFunctionContextUpdateMP32(&p->hash, message); + hashFunctionContextUpdateMP32(&p->hash, &secret); + hashFunctionContextDigest (&p->hash, &digest); + + /* we don't need the secret anymore */ + mp32nwipe(&secret); + mp32nfree(&secret); + + /** + * NOTE: blockciphers and keyed hash functions take keys with sizes + * specified in bits and key data passed in 32-bit words. + * + * Both blockcipher and keyed hash function have a min and max key size. + * + * This function will split the digest of the shared secret in two halves, + * and pad with zero bits or truncate if necessary to meet algorithm key + * size requirements. + */ + + if ((digest.size & 1) == 0) + { /* digest contains an even number of 32 bit words */ + int keysize = digest.size >> 1; + int keybits = digest.size << 4; + + if ((rc = keyedHashFunctionContextSetup(&p->mac, digest.data, keybits))) + goto setup_end; + + if ((rc = blockCipherContextSetup(&p->cipher, digest.data+keysize, keybits, op))) + goto setup_end; + + rc = 0; + } + else + rc = -1; + +setup_end: + mp32nwipe(&digest); + mp32nfree(&digest); + + return rc; +} + +memchunk* dhaes_pEncrypt(dhaes_p* p, const mp32number* publicKey, mp32number* ephemeralPublicKey, mp32number* mac, const memchunk* cleartext) +{ + memchunk* ciphertext = (memchunk*) 0; + memchunk* paddedtext; + + mp32number ephemeralPrivateKey; + + /* make the ephemeral keypair */ + mp32nzero(&ephemeralPrivateKey); + dldp_pPair(&p->param, &p->rng, &ephemeralPrivateKey, ephemeralPublicKey); + + /* Setup the key and initialize the mac and the blockcipher */ + if (dhaes_pSetup(p, &ephemeralPrivateKey, publicKey, ephemeralPublicKey, ENCRYPT)) + goto encrypt_end; + + /* add pkcs-5 padding */ + paddedtext = pkcs5Pad(p->cipher.ciph->blocksize, cleartext); + + /* encrypt the memchunk in CBC mode */ + if (blockEncrypt(p->cipher.ciph, p->cipher.param, CBC, paddedtext->size / p->cipher.ciph->blocksize, (uint32*) paddedtext->data, (const uint32*) paddedtext->data)) + { + free(paddedtext->data); + free(paddedtext); + goto encrypt_end; + } + + /* Compute the mac */ + if (keyedHashFunctionContextUpdateMC(&p->mac, paddedtext)) + { + free(paddedtext->data); + free(paddedtext); + goto encrypt_end; + } + + if (keyedHashFunctionContextDigest(&p->mac, mac)) + { + free(paddedtext->data); + free(paddedtext); + goto encrypt_end; + } + + ciphertext = paddedtext; + +encrypt_end: + mp32nwipe(&ephemeralPrivateKey); + mp32nfree(&ephemeralPrivateKey); + + return ciphertext; +} + +memchunk* dhaes_pDecrypt(dhaes_p* p, const mp32number* privateKey, const mp32number* ephemeralPublicKey, const mp32number* mac, const memchunk* ciphertext) +{ + memchunk* cleartext = (memchunk*) 0; + memchunk* paddedtext; + + /* Setup the key and initialize the mac and the blockcipher */ + if (dhaes_pSetup(p, privateKey, ephemeralPublicKey, ephemeralPublicKey, DECRYPT)) + goto decrypt_end; + + /* Verify the mac */ + if (keyedHashFunctionContextUpdateMC(&p->mac, ciphertext)) + goto decrypt_end; + + if (keyedHashFunctionContextDigestMatch(&p->mac, mac) == 0) + goto decrypt_end; + + /* decrypt the memchunk with CBC mode */ + paddedtext = (memchunk*) calloc(1, sizeof(memchunk)); + + if (paddedtext == (memchunk*) 0) + goto decrypt_end; + + paddedtext->size = ciphertext->size; + paddedtext->data = (byte*) malloc(ciphertext->size); + + if (paddedtext->data == (byte*) 0) + { + free(paddedtext); + goto decrypt_end; + } + + if (blockDecrypt(p->cipher.ciph, p->cipher.param, CBC, paddedtext->size / p->cipher.ciph->blocksize, (uint32*) paddedtext->data, (const uint32*) ciphertext->data)) + { + free(paddedtext->data); + free(paddedtext); + goto decrypt_end; + } + + /* remove pkcs-5 padding */ + if (pkcs5UnpadInline(p->cipher.ciph->blocksize, paddedtext)) + { + free(paddedtext->data); + free(paddedtext); + goto decrypt_end; + } + + cleartext = paddedtext; + +decrypt_end: + + return cleartext; +} diff --git a/beecrypt/dhaes.h b/beecrypt/dhaes.h new file mode 100644 index 0000000..21bb8f3 --- /dev/null +++ b/beecrypt/dhaes.h @@ -0,0 +1,54 @@ +/* + * dhaes.h + * + * DHAES, header + * + * Copyright (c) 2000, 2001 Virtual Unlimited, B.V. + * + * Author: 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 _DHAES_H +#define _DHAES_H + +#include "beecrypt.h" +#include "dldp.h" + +typedef struct +{ + dldp_p param; + hashFunctionContext hash; + blockCipherContext cipher; + keyedHashFunctionContext mac; + randomGeneratorContext rng; +} dhaes_p; + +BEEDLLAPI +int dhaes_usable(const blockCipher*, const keyedHashFunction*, const hashFunction*); + +BEEDLLAPI +int dhaes_pInit(dhaes_p*, const dldp_p*, const blockCipher*, const keyedHashFunction*, const hashFunction*, const randomGenerator*); +BEEDLLAPI +int dhaes_pFree(dhaes_p*); + +BEEDLLAPI +memchunk* dhaes_pEncrypt(dhaes_p*, const mp32number*, mp32number*, mp32number*, const memchunk*); +BEEDLLAPI +memchunk* dhaes_pDecrypt(dhaes_p*, const mp32number*, const mp32number*, const mp32number*, const memchunk*); + +#endif diff --git a/beecrypt/dldp.c b/beecrypt/dldp.c new file mode 100644 index 0000000..2eb47be --- /dev/null +++ b/beecrypt/dldp.c @@ -0,0 +1,323 @@ +/* + * dldp.c + * + * Discrete Logarithm Domain Parameters, code + * + * + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "dldp.h" +#include "mp32.h" +#include "mp32prime.h" + +#include + +void dldp_pPrivate(const dldp_p* dp, randomGeneratorContext* rc, mp32number* x) +{ + /* + * Note: the private key is randomly selected to be smaller than q + * + * This is the variant of Diffie-Hellman as described in IEEE P1363 + */ + + mp32brnd(&dp->q, rc); + mp32nset(x, dp->q.size, dp->q.data); +} + +void dldp_pPublic(const dldp_p* dp, const mp32number* x, mp32number* y) +{ + /* + * Public key y is computed as g^x mod p + */ + + mp32bpowmod(&dp->p, dp->g.size, dp->g.data, x->size, x->data); + mp32nset(y, dp->p.size, dp->p.data); +} + +void dldp_pPair(const dldp_p* dp, randomGeneratorContext* rc, mp32number* x, mp32number* y) +{ + /* + * Combination of the two previous functions + */ + + mp32brnd(&dp->q, rc); + mp32nset(x, dp->q.size, dp->q.data); + mp32bpowmod(&dp->p, dp->g.size, dp->g.data, x->size, x->data); + mp32nset(y, dp->p.size, dp->p.data); +} + +int dldp_pEqual(const dldp_p* a, const dldp_p* b) +{ + return mp32eqx(a->p.size, a->p.modl, b->p.size, b->p.modl) && + mp32eqx(a->q.size, a->q.modl, b->q.size, b->q.modl) && + mp32eqx(a->g.size, a->g.data, b->g.size, b->g.data); +} + +int dldp_pValidate(const dldp_p* dp, randomGeneratorContext* rc) +{ + /* check that p > 2 and p odd, then run miller-rabin test with t 50 */ + if (mp32even(dp->p.size, dp->p.modl)) + return 0; + + if (mp32pmilrab(&dp->p, rc, 50) == 0) + return 0; + + /* check that q > 2 and q odd, then run miller-rabin test with t 50 */ + if (mp32even(dp->q.size, dp->q.modl)) + return 0; + + if (mp32pmilrab(&dp->q, rc, 50) == 0) + return 0; + + /* check that 1 < g < p */ + if (mp32leone(dp->g.size, dp->g.data)) + return 0; + + if (mp32gex(dp->g.size, dp->g.data, dp->p.size, dp->p.modl)) + return 0; + + return 1; +} + +void dldp_pInit(dldp_p* dp) +{ + mp32bzero(&dp->p); + mp32bzero(&dp->q); + mp32nzero(&dp->g); + mp32nzero(&dp->r); + mp32bzero(&dp->n); +} + +void dldp_pFree(dldp_p* dp) +{ + mp32bfree(&dp->p); + mp32bfree(&dp->q); + mp32nfree(&dp->g); + mp32nfree(&dp->r); + mp32bfree(&dp->n); +} + +void dldp_pCopy(dldp_p* dst, const dldp_p* src) +{ + mp32bset(&dst->p, src->p.size, src->p.modl); + mp32bset(&dst->q, src->q.size, src->q.modl); + mp32nset(&dst->r, src->r.size, src->r.data); + mp32nset(&dst->g, src->g.size, src->g.data); + mp32bset(&dst->n, src->n.size, src->n.modl); +} + +void dldp_pgoqMake(dldp_p* dp, randomGeneratorContext* rc, uint32 psize, uint32 qsize, int cofactor) +{ + /* + * Generate parameters as described by IEEE P1363, A.16.1 + */ + + /* first generate q */ + mp32prnd(&dp->q, rc, qsize, mp32ptrials(qsize << 5), (const mp32number*) 0); + + /* generate p with the appropriate congruences */ + mp32prndconone(&dp->p, rc, psize, mp32ptrials(psize << 5), &dp->q, (const mp32number*) 0, &dp->r, cofactor); + + /* clear n */ + mp32bfree(&dp->n); + + dldp_pgoqGenerator(dp, rc); +} + +void dldp_pgoqMakeSafe(dldp_p* dp, randomGeneratorContext* rc, uint32 psize) +{ + /* + * Generate parameters with a safe prime; p = 2q+1 i.e. r=1 + * + */ + + /* generate p */ + mp32prndsafe(&dp->p, rc, psize, mp32ptrials(psize << 5)); + + /* set q */ + mp32copy(dp->p.size, dp->p.data, dp->p.modl); + mp32divtwo(dp->p.size, dp->p.data); + + mp32bset(&dp->q, dp->p.size, dp->p.data); + + /* set r = 1 */ + mp32nsetw(&dp->r, 1); + + /* clear n */ + mp32bfree(&dp->n); + + dldp_pgoqGenerator(dp, rc); +} + +void dldp_pgoqGenerator(dldp_p* dp, randomGeneratorContext* rc) +{ + /* + * Randomly determine a generator over the subgroup with order q + */ + + register uint32 psize = dp->p.size; + register uint32* hdata = dp->p.data+psize*4+2; + + while (1) + { + mp32brndres(&dp->p, hdata, rc); + + mp32bpowmod(&dp->p, psize, hdata, dp->r.size, dp->r.data); + if (mp32isone(psize, dp->p.data)) + continue; + + mp32nset(&dp->g, psize, dp->p.data); + return; + } +} + +int dldp_pgoqValidate(const dldp_p* dp, randomGeneratorContext* rc, int cofactor) +{ + if (dldp_pValidate(dp, rc) == 0) + return 0; + + /* check that g^q mod p = 1 */ + + /* if r != 0, then check that 2qr+1 = p */ + + /* if cofactor, then check that q does not divide (2r) */ + + return 1; +} + +void dldp_pgonMake(dldp_p* dp, randomGeneratorContext* rc, uint32 psize, uint32 qsize) +{ + /* + * Generate parameters with a prime p such that p = 2qr+1, with q and r prime + */ + + /* generate q */ + mp32prnd(&dp->q, rc, qsize, mp32ptrials(qsize << 5), (const mp32number*) 0); + + /* generate p with the appropriate congruences */ + mp32prndconone(&dp->p, rc, psize, mp32ptrials(psize << 5), &dp->q, (const mp32number*) 0, &dp->r, 2); + + /* set n */ + mp32bmodsubone(&dp->p); + mp32bset(&dp->n, psize, dp->p.data); + + dldp_pgonGenerator(dp, rc); +} + +void dldp_pgonMakeSafe(dldp_p* dp, randomGeneratorContext* rc, uint32 psize) +{ + /* + * Generate parameters with a safe prime; i.e. p = 2q+1, where q is prime + */ + + /* generate safe p */ + mp32prndsafe(&dp->p, rc, psize, mp32ptrials(psize << 5)); + + /* set n */ + mp32bmodsubone(&dp->p); + mp32bset(&dp->n, dp->p.size, dp->p.data); + + /* set q */ + mp32divtwo(dp->p.size, dp->p.data); + mp32bset(&dp->q, dp->p.size, dp->p.data); + + /* set r = 1 */ + mp32nsetw(&dp->r, 1); + + dldp_pgonGenerator(dp, rc); +} + +void dldp_pgonGenerator(dldp_p* dp, randomGeneratorContext* rc) +{ + register uint32 psize = dp->p.size; + register uint32* gdata = dp->p.data+psize*4+2; + + while (1) + { + mp32brndres(&dp->p, gdata, rc); + + if (mp32isone(dp->r.size, dp->r.data)) + { + /* + * A little math here: the only element in the group which has order 2 is (p-1); + * the two group elements raised to power two which result in 1 (mod p) are thus (p-1) and 1 + * + * mp32brndres doesn't return 1 or (p-1), so the test where g^2 mod p = 1 can be safely skipped + */ + + #if 0 + /* first check g^2 mod p */ + mp32bsqrmod(&dp->p, psize, gdata); + if (mp32isone(psize, dp->p.data)) + continue; + #endif + + /* check g^q mod p*/ + mp32bpowmod(&dp->p, psize, gdata, dp->q.size, dp->q.modl); + if (mp32isone(psize, dp->p.data)) + continue; + } + else + { + /* we need g^2r, g^2q and g^qr, hence we first compute t = g^r + * then compute t^2 mod p, and test if one + * then compute t^q mod p, and test if one + * then compute (g^q mod p)^2 mod p, and test if one + */ + + register uint32* tdata = gdata+psize; + + /* compute t = g^r mod p */ + mp32bpowmod(&dp->p, psize, gdata, dp->r.size, dp->r.data); + mp32copy(psize, tdata, dp->p.data); + /* compute t^2 mod p = g^2r mod p */ + mp32bsqrmod(&dp->p, psize, dp->p.data); + if (mp32isone(psize, dp->p.data)) + continue; + + /* compute t^q mod p = g^qr mod p */ + mp32bpowmod(&dp->p, psize, tdata, dp->q.size, dp->q.data); + if (mp32isone(psize, dp->p.data)) + continue; + + /* compute g^2q mod p */ + mp32bpowmod(&dp->p, psize, gdata, dp->q.size, dp->q.modl); + mp32bsqrmod(&dp->p, psize, dp->p.data); + if (mp32isone(psize, dp->p.data)) + continue; + } + + mp32nset(&dp->g, psize, dp->p.data); + + return; + } +} + +int dldp_pgonValidate(const dldp_p* dp, randomGeneratorContext* rc) +{ + if (dldp_pValidate((const dldp_p*) dp, rc) == 0) + return 0; + + return 1; +} diff --git a/beecrypt/dldp.h b/beecrypt/dldp.h new file mode 100644 index 0000000..62a5504 --- /dev/null +++ b/beecrypt/dldp.h @@ -0,0 +1,122 @@ +/* + * dldp.h + * + * Discrete Logarithm Domain Parameters, header + * + * + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _DLDP_H +#define _DLDP_H + +#include "beecrypt.h" +#include "mp32barrett.h" + +/* + * Discrete Logarithm Domain Parameters - Prime + * + * Standard definition where p = 2qr+1; in case where p=2q+1, r=1 + * + * IEEE P1363 definition is p = rk+1 + * + * Hence, IEEE r = q and IEEE cofactor k = 2 or k = 2r + * + * Make sure q is large enough to foil Pohlig-Hellman attacks + * See: "Handbook of Applied Cryptography", Chapter 3.6.4 + * + * g is either a generator of a subgroup of order q, or a generator of order + * n = (p-1) + */ + +typedef struct +{ + mp32barrett p; + mp32barrett q; + mp32number r; + mp32number g; + mp32barrett n; +} dldp_p; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Functions for setting up and copying + */ + +BEEDLLAPI +void dldp_pInit(dldp_p*); +BEEDLLAPI +void dldp_pFree(dldp_p*); +BEEDLLAPI +void dldp_pCopy(dldp_p*, const dldp_p*); + +/* + * Functions for generating keys + */ + +BEEDLLAPI +void dldp_pPrivate(const dldp_p*, randomGeneratorContext*, mp32number*); +BEEDLLAPI +void dldp_pPublic (const dldp_p*, const mp32number*, mp32number*); +BEEDLLAPI +void dldp_pPair (const dldp_p*, randomGeneratorContext*, mp32number*, mp32number*); + +/* + * Function for comparing domain parameters + */ + +BEEDLLAPI +int dldp_pEqual (const dldp_p*, const dldp_p*); + +/* + * Functions for generating and validating dldp_pgoq variant domain parameters + */ + +BEEDLLAPI +void dldp_pgoqMake (dldp_p*, randomGeneratorContext*, uint32, uint32, int); +BEEDLLAPI +void dldp_pgoqMakeSafe (dldp_p*, randomGeneratorContext*, uint32); +BEEDLLAPI +void dldp_pgoqGenerator(dldp_p*, randomGeneratorContext*); +BEEDLLAPI +int dldp_pgoqValidate (const dldp_p*, randomGeneratorContext*, int); + +/* + * Functions for generating and validating dldp_pgon variant domain parameters + */ + +BEEDLLAPI +void dldp_pgonMake (dldp_p*, randomGeneratorContext*, uint32, uint32); +BEEDLLAPI +void dldp_pgonMakeSafe (dldp_p*, randomGeneratorContext*, uint32); +BEEDLLAPI +void dldp_pgonGenerator(dldp_p*, randomGeneratorContext*); +BEEDLLAPI +int dldp_pgonValidate (const dldp_p*, randomGeneratorContext*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/dlkp.c b/beecrypt/dlkp.c new file mode 100644 index 0000000..231e536 --- /dev/null +++ b/beecrypt/dlkp.c @@ -0,0 +1,54 @@ +/* + * dlkp.c + * + * Discrete Logarithm Keypair, code + * + * + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "dlkp.h" + +void dlkp_pPair(dlkp_p* dp, randomGeneratorContext* rc, const dldp_p* param) +{ + /* copy the parameters */ + dldp_pCopy(&dp->param, param); + + dldp_pPair((const dldp_p*) param, rc, &dp->x, &dp->y); +} + +void dlkp_pFree(dlkp_p* dp) +{ + dldp_pFree(&dp->param); + + mp32nfree(&dp->y); + mp32nfree(&dp->x); +} + +void dlkp_pCopy(dlkp_p* dst, const dlkp_p* src) +{ + dldp_pCopy(&dst->param, &src->param); + + mp32nset(&dst->y, src->y.size, src->y.data); + mp32nset(&dst->x, src->x.size, src->x.data); +} diff --git a/beecrypt/dlkp.h b/beecrypt/dlkp.h new file mode 100644 index 0000000..c484f43 --- /dev/null +++ b/beecrypt/dlkp.h @@ -0,0 +1,55 @@ +/* + * dlkp.h + * + * Discrete Logarithm Keypair, header + * + * + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _DLKP_H +#define _DLKP_H + +#include "dlpk.h" + +typedef struct +{ + dldp_p param; + mp32number y; + mp32number x; +} dlkp_p; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void dlkp_pPair(dlkp_p*, randomGeneratorContext*, const dldp_p*); +BEEDLLAPI +void dlkp_pFree(dlkp_p*); +BEEDLLAPI +void dlkp_pCopy(dlkp_p*, const dlkp_p*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/dlpk.c b/beecrypt/dlpk.c new file mode 100644 index 0000000..2566fbb --- /dev/null +++ b/beecrypt/dlpk.c @@ -0,0 +1,75 @@ +/* + * dlpk.c + * + * Discrete Logarithm Public Key, code + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "dlpk.h" +#include "mp32.h" + +void dlpk_pFree(dlpk_p* dp) +{ + dldp_pFree(&dp->param); + mp32nfree(&dp->y); +} + +void dlpk_pCopy(dlpk_p* dst, const dlpk_p* src) +{ + dldp_pCopy(&dst->param, &src->param); + mp32nset(&dst->y, src->y.size, src->y.data); +} + +int dlpk_pEqual(const dlpk_p* a, const dlpk_p* b) +{ + return dldp_pEqual(&a->param, &b->param) && + mp32eqx(a->y.size, a->y.data, b->y.size, b->y.data); +} + +int dlpk_pgoqValidate(const dlpk_p* dp, randomGeneratorContext* rc, int cofactor) +{ + if (dldp_pgoqValidate(&dp->param, rc, cofactor) == 0) + return 0; + + if (mp32leone(dp->y.size, dp->y.data)) + return 0; + + if (mp32gex(dp->y.size, dp->y.data, dp->param.p.size, dp->param.p.modl)) + return 0; + + return 1; +} + +int dlpk_pgonValidate(const dlpk_p* dp, randomGeneratorContext* rc) +{ + if (dldp_pgonValidate(&dp->param, rc) == 0) + return 0; + + if (mp32leone(dp->y.size, dp->y.data)) + return 0; + + if (mp32gex(dp->y.size, dp->y.data, dp->param.p.size, dp->param.p.data)) + return 0; + + return 1; +} diff --git a/beecrypt/dlpk.h b/beecrypt/dlpk.h new file mode 100644 index 0000000..029d62e --- /dev/null +++ b/beecrypt/dlpk.h @@ -0,0 +1,58 @@ +/* + * dlpk.h + * + * Discrete Logarithm Public Key, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _DLPK_H +#define _DLPK_H + +#include "dldp.h" + +typedef struct +{ + dldp_p param; + mp32number y; +} dlpk_p; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void dlpk_pFree(dlpk_p*); +BEEDLLAPI +void dlpk_pCopy(dlpk_p*, const dlpk_p*); + +BEEDLLAPI +int dlpk_pEqual(const dlpk_p*, const dlpk_p*); + +BEEDLLAPI +int dlpk_pgoqValidate(const dlpk_p*, randomGeneratorContext*, int cofactor); +BEEDLLAPI +int dlpk_pgonValidate(const dlpk_p*, randomGeneratorContext*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/dlsvdp-dh.c b/beecrypt/dlsvdp-dh.c new file mode 100644 index 0000000..c917755 --- /dev/null +++ b/beecrypt/dlsvdp-dh.c @@ -0,0 +1,34 @@ +/* + * dlsvdp-dh.c + * + * Discrete Logarithm Secret Value Derivation Primite - Diffie Hellman, code + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "dlsvdp-dh.h" + +void dlsvdp_pDHSecret(const dldp_p* dp, const mp32number* x, const mp32number* y, mp32number* s) +{ + mp32bpowmod(&dp->p, y->size, y->data, x->size, x->data); + mp32nset(s, dp->p.size, dp->p.data); +} diff --git a/beecrypt/dlsvdp-dh.h b/beecrypt/dlsvdp-dh.h new file mode 100644 index 0000000..a580ab6 --- /dev/null +++ b/beecrypt/dlsvdp-dh.h @@ -0,0 +1,42 @@ +/* + * dlsvdp-dh.h + * + * Discrete Logarithm Secret Value Derivation Primitive - Diffie Hellman, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _DLSVDP_DH_H +#define _DLSVDP_DH_H + +#include "dldp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void dlsvdp_pDHSecret(const dldp_p*, const mp32number*, const mp32number*, mp32number*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/docs/Makefile.am b/beecrypt/docs/Makefile.am new file mode 100644 index 0000000..8a50295 --- /dev/null +++ b/beecrypt/docs/Makefile.am @@ -0,0 +1,25 @@ +# +# Makefile.am's purpose is to add the documentation html files to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + +AUTOMAKE_OPTIONS = gnu no-dependencies + +EXTRA_DIST = index.html installing.html using.html developing.html api.html manual.css diff --git a/beecrypt/docs/Makefile.in b/beecrypt/docs/Makefile.in new file mode 100644 index 0000000..6c5c818 --- /dev/null +++ b/beecrypt/docs/Makefile.in @@ -0,0 +1,209 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# +# Makefile.am's purpose is to add the documentation html files to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +AS = @AS@ +CC = @CC@ +CPP = @CPP@ +DLLTOOL = @DLLTOOL@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +ac_cv_have_java = @ac_cv_have_java@ +ac_cv_have_javac = @ac_cv_have_javac@ + +AUTOMAKE_OPTIONS = gnu no-dependencies + +EXTRA_DIST = index.html installing.html using.html developing.html api.html manual.css +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.gnu.h +CONFIG_CLEAN_FILES = +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu docs/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = docs + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# 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. +.NOEXPORT: diff --git a/beecrypt/docs/api.html b/beecrypt/docs/api.html new file mode 100644 index 0000000..2a9f242 --- /dev/null +++ b/beecrypt/docs/api.html @@ -0,0 +1,133 @@ + + + + + +The BeeCrypt API + + +
+
Entropy Sources
+
+
+
+
+
Random Generators
+
+

The following structure is used to hold information describing a +specific random generator implementation: +


+typedef struct
+{
+  const char*                  name;
+  const unsigned int           paramsize;
+  const randomGeneratorSetup   setup;
+  const randomGeneratorSeed    seed;
+  const randomGeneratorNext    next;
+  const randomGeneratorCleanup cleanup;
+} randomGenerator;
+
+

The following structure is used to work with a specific random +generator implementation: +


+typedef struct
+{
+  const randomGenerator* rng;
+  randomGeneratorparam*  param;
+} randomGeneratorContext;
+
+

The following functions will operate on this structure: +

+
+void randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng); +
+
This function initializes ctxt by allocating and +initializing parameters appropriate for rng. +
+
+void randomGeneratorContextFree(randomGeneratorContext* ctxt); +
+
This function cleans up ctxt and frees its +allocated parameters. +
+
+
+
+
Hash Functions
+
+
+
+
+
Keyed Hash Functions
+
+
+
+
+
Block Ciphers
+
+
+
+
+
Multi-Precision Integer routines
+
+

The following structure is used to hold a multi-precision integer: +


+typedef struct
+{
+  uint32  size;
+  uint32* data;
+} mp32number;
+
+

The following structure is used for barrett modular reduction operations on multi-precision integers: +


+typedef struct
+{
+  uint32  size;
+  uint32* modl;
+  uint32* mu;
+} mp32barrett;
+
+
+
+
+
Discrete Logarithm Public Key Primitives
+
+

Discrete logarithm operations can be performed in a variety of fields. This API implements discrete logarithms over a prime field, conform with IEEE P1363. +

You can find the exact mathematics in: +

+"Handbook of Applied Cryptography"
+Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone
+CRC Press +
+

The domain parameters are defined by a prime P, a prime factor Q of (P-1), and a group generator G. +

The following struct is used to hold the discrete logarithm domain parameters: +


+typedef struct
+{
+  mp32barrett p;
+  mp32barrett q;
+  mp32number  r;
+  mp32number  g;
+  mp32barrett n;
+} dldp_p;
+
+

The struct holds more than the three domain parameters required by IEEE P1363. Some discrete logarithm operations call for a reduction modulo (P-1). Hence we've defined N as (P-1). R is the cofactor of (P-1), so that P-1=N=Q*R, where P and Q are (probable) primes. +

If you save the domain parameters, you don't need to save N, and R, since they can be trivially recomputed. +

The following functions will operate on this structure: +

+
+void dldp_pInit(dldp_p* domain); +
+
+void dldp_pFree(dldp_p* domain); +
+
+void dldp_pCopy(dldp_p* dest, const dldp_p* source); +
+
+
+
+
+
+ + diff --git a/beecrypt/docs/developing.html b/beecrypt/docs/developing.html new file mode 100644 index 0000000..06edb4e --- /dev/null +++ b/beecrypt/docs/developing.html @@ -0,0 +1,13 @@ + + + + + +Developing Applications with BeeCrypt + + +To be completed. +

API +

Examples + + diff --git a/beecrypt/docs/index.html b/beecrypt/docs/index.html new file mode 100644 index 0000000..a2c4a0f --- /dev/null +++ b/beecrypt/docs/index.html @@ -0,0 +1,39 @@ + + + + + +The BeeCrypt Cryptography Library + + +

The BeeCrypt Cryptography Library

+

Copyright © 1997, 1998, 1999, 2000, 2001 Virtual Unlimited, B.V.
+

Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.1 or any +later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. +

For the specifics of this license, see file 'COPYING.DOC', included in this +distribution. +

About BeeCrypt

+

BeeCrypt is an open source cryptography library that contains highly +optimized C and assembler implementations of many well-known algorithms +including Blowfish, MD5, SHA-1, SHA-256, Diffie-Hellman, and ElGamal. +

The goal of the library is to offer a wide range of low-level cryptographic +primitives. +

BeeCrypt is licensed under the GNU Lesser Public General License (LGPL), +which means it can be used for free in both open and closed source commercial +products. +
+

About the documentation

+

This is the first attempt to write a manual for the BeeCrypt Cryptography +Library. Eventually this will become a full-blown manual, with all the jingles +and bells. +

Contents

+
    +
  1. Installing BeeCrypt +
  2. Using BeeCrypt +
  3. Developing with BeeCrypt +
+ + diff --git a/beecrypt/docs/installing.html b/beecrypt/docs/installing.html new file mode 100644 index 0000000..6cd21b2 --- /dev/null +++ b/beecrypt/docs/installing.html @@ -0,0 +1,139 @@ + + + + +Installing the BeeCrypt Cryptography Library + + +

Installing the BeeCrypt Cryptography Library

+

When it comes to installing BeeCrypt you basically have the following +alternatives: +

    +
  1. Installing from the source code - aka roll your own
  2. +
      +
    • Getting the source code
    • +

      The primary download location for the source tarball is through + +Virtual Unlimited's download page. Alternatively you can download from +SourceForge. +

    • Unpacking
    • +

      Once you have the source tarball, unpack it with GNU +tar (if you have it); on Windows you can use +WinRAR. +

    • Configuring, building and installing
    • +

      The library can be built on a variety of platforms, and we will illustrate +the two most common ways: +

      Using the GNU toolchain +

      The source tarball contains a configure script produced with +GNU autoconf; +on most platforms you will want to use this. +

      As with most configure scripts, there are a few options you can use: +

      +
      --prefix
      +
      Use this option to indicate where you want the shared library and header +files installed. By default this is set to /usr/local. Another +suggested location is the /usr directory.
      +
      --target
      +
      Use this option to indicate that you want the library built for a +processor other than the one which is normally detected. Some examples of +useful combinations are: +
      +
      --target=sparcv8plus-sun-solaris2.8
      +
      --target=i686-pc-freebsd4.3
      +
      +
      --enable-debug
      +
      will build the library with debug symbols, and without assembler +optimization, and instead just use plain C code. +
      --disable-optimized
      +
      will build the library without any processor-specific assembler +optimization, and instead just use plain C code.
      +
      --without-javaglue
      +
      will build the library without code which allows BeeCrypt for Java +to employ the native code in the library (automatic if you don't +have a JDK installed).
      +
      --disable-threads
      +
      will build the library without thread-safe code; useful on platforms +such as NetBSD (automatic if configure can't find threads).
      +
      --disable-aio
      +
      will build the library without asynchronous I/O on entropy devices +(automatic if configure can't find POSIX-compliant asynchronous I/O +routines).
      +
      --with-mtmalloc
      +
      will build the library with multi-thread optimized malloc routines +(available on Solaris 8). There is a tradeoff in speed versus the amount +of memory allocated.
      +
      +

      To build, run:

      make +

      To install, run:

      make install + +

      Using Visual C++ for Win32 +

      Microsoft Visual C++ is currently the preferred platform for compiling +the library, as it seems faster and more stable than other platforms. +

      The prerequisites for compiling are: +

      +
      Visual C++ 6.0
      +
      At the time of writing, it is recommended to install the latest service +pack for Visual Studio. You can find it through Microsoft's +download page.
      +
      Visual C++ Processor Pack
      +
      You will need this package to support compilation of the assembler source +code. You can download it + +here.
      + +

      Before going on, make sure the following Visual C++ tools are found on +your PATH: cl.exe, (the compiler), ml.exe (the assembler), link.exe (the +linker) and nmake.exe (the make utility). +

      For the Win32 platform, there is a Makefile.mak for Visual C++ included; +if you have a Pentium class processor, you won't have to configure the source +tree. +

      This Makefile.mak is set up to compile Java support into the library. If +you don't have JDK 1.2 or later installed, you'll need to edit this file. +

      To build, run:

      nmake /f Makefile.mak +

      Using Metrowerks CodeWarrior for Win32 +

      The prerequisites for compiling are: +

      +
      CodeWarrior Pro
      +
      Use version 5 or later.
      +
      CodeWarrior Pro Assembler Plugin
      +
      This tool isn't officially support by MetroWerks, but it functions fine +in conjunction with the project file included in the library.
      +
      +

      To build, start the CodeWarrior IDE, open project file 'beecrypt.mcp' +and make the BeeCrypt DLL by pressing the [F7] key. +

      Installing the BeeCrypt DLL +

      To install, either copy file 'beecrypt.dll' to your Windows System +directory (on Windows 95/98/Millenium), or to your Windows System 32 +directory (on Windows NT/2000). +

      If you don't need the BeeCrypt DLL globallly available, copy it into the same +directory as the application which is going to use it. If you intend to develop +software with BeeCrypt, you'll need file 'beecrypt.lib'. Either copy it into +project directory, or point your Makefile or project to it. +

      +
    +
    +
  3. Installing precompiled versions
  4. +

    Several different flavors of precompiled versions exist. +

    +
    Win32 BeeCrypt DLLs
    +
    Virtual Unlimited makes precompiled BeeCrypt DLL and LIB files, usable on +Pentium class processors. If you want to develop your own software with these +files, you will also need the header files from the source tarball. See +'Getting the source code'.
    +
    RedHat RPMS
    +
    Virtual Unlimited makes BeeCrypt RPM packages for every release for at +least the following platforms: i386, i586, i686, powerpc. As we get access to +more platforms, we will try to make more RPMS available; until then it +shouldn't be too hard to get the BeeCrypt SRPM file, install it and compile +your own RPMS from it. Note that RPM packages originating at Virtual +Unlimited will contain a signature, which you can verify with + +this key.
    +
    Debian Packages
    +
    Thanks to Luca Filipozzi there are Debian packages available for BeeCrypt. +You can find these packages on various Debian mirror sites.
    +
    +

    +

+ + diff --git a/beecrypt/docs/manual.css b/beecrypt/docs/manual.css new file mode 100644 index 0000000..63f1bb0 --- /dev/null +++ b/beecrypt/docs/manual.css @@ -0,0 +1,25 @@ +BODY { background: #fff } + +A:link { color: #0D45AC } +A:visited { color: #936 } + +H1 { font: bold 170% verdana,arial,sans-serif } + +H2 { +font: bold 100% verdana,arial,sans-serif; +margin-bottom: .5em +} + +H3 { +font: bold 90% verdana,arial,sans-serif; +margin-bottom: .5em +} + +A.index { font: normal 70% Verdana,Arial,Helvetica,sans-serif } +A.index { color: #0D45AC } +A.index:visited { color: #936 } + +.crumbtrail { font: normal 70% Verdana,Arial,Helvetica,sans-serif } +A.crumblink { color: #0D45AC } +A.crumblink:visited { color: #936 } + diff --git a/beecrypt/docs/using.html b/beecrypt/docs/using.html new file mode 100644 index 0000000..9bc2db6 --- /dev/null +++ b/beecrypt/docs/using.html @@ -0,0 +1,11 @@ + + + + + +Using BeeCrypt + + +To be completed. + + diff --git a/beecrypt/elgamal.c b/beecrypt/elgamal.c new file mode 100644 index 0000000..0edb6b8 --- /dev/null +++ b/beecrypt/elgamal.c @@ -0,0 +1,129 @@ +/* + * elgamal.c + * + * ElGamal signature scheme, code + * + * For more information on this algorithm, see: + * "Handbook of Applied Cryptography" + * 11.5.2 "The ElGamal signature scheme", p. 454-459 + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 + * + * + * This code implements two of the six variants described: + * + * ElGamal Signature variant 1: (i.e. the standard version) + * Signing equation: + * r = g^k mod p and + * s = inv(k) * (h(m) - x*r) mod (p-1) + * Verifying equation: + * check 1 <= r <= (p-1) + * v1 = y^r * r^s mod p + * v2 = g^h(m) mod p + * check v1 == v2 + * Simultaneous multiple exponentiation verification: + * y^r * r^s * g^(p-1-h(m)) mod p = 1 or (the former is probably faster) + * y^r * r^s * inv(g)^h(m) mod p = 1 + * + * ElGamal Signature variant 3: signing is simpler, because no inverse has to be calculated + * Signing equation: + * r = g^k mod p and + * s = x*r + k*h(m) mod (p-1) + * Verifying equation: + * check 1 <= r <= (p-1) + * v1 = g^s mod p + * v2 = y^r * r^h(m) mod p + * Simultaneous multiple exponentiation verification: + * y^r * r^h(m) * g^(p-1-s) mod p = 1 (one of the exponents is significantly smaller, i.e. h(m)) + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "elgamal.h" +#include "mp32.h" + +#if HAVE_STDLIB_H +#include +#endif + +void elgv3sign(const mp32barrett* p, const mp32barrett* n, const mp32number* g, randomGeneratorContext* rc, const mp32number* hm, const mp32number* x, mp32number* r, mp32number* s) +{ + register uint32 size = p->size; + register uint32* kdata = p->wksp+size*4+4; /* leave enough workspace for a powmod operation */ + register uint32* u1data = n->wksp+size*4+4; /* leave enough workspace for a mulmod and addmod operation */ + register uint32* u2data = u1data+size; + + /* get a random k */ + mp32brnd(p, rc); + mp32copy(size, kdata, p->data); + + /* compute r = g^k mod p */ + mp32bpowmod(p, g->size, g->data, size, kdata); + mp32nset(r, size, p->data); + + /* compute u1 = x*r mod n */ + mp32bmulmodres(n, u1data, x->size, x->data, size, p->data); + + /* compute u2 = k*h(m) mod n */ + mp32bmulmodres(n, u2data, hm->size, hm->data, size, kdata); + + /* compute s = u1+u2 mod n */ + mp32baddmod(n, size, u1data, size, u2data); + mp32nset(s, size, n->data); +} + +int elgv3vrfy(const mp32barrett* p, const mp32barrett* n, const mp32number* g, const mp32number* hm, const mp32number* y, const mp32number* r, const mp32number* s) +{ + register uint32 size = p->size; + register uint32* v1data = p->wksp+size*4+4; + register uint32* u1data = v1data+size; + + if (mp32z(r->size, r->data)) + return 0; + + if (mp32gex(r->size, r->data, size, p->modl)) + return 0; + + if (mp32z(s->size, s->data)) + return 0; + + if (mp32gex(s->size, s->data, n->size, n->modl)) + return 0; + + #ifdef COMING_SOON + /* here we need the simultaneous multiple exponentiation with three pairs */ + #endif + + /* compute v1 = g^s mod p */ + mp32bpowmod(p, g->size, g->data, s->size, s->data); + mp32copy(size, v1data, p->data); + + /* compute u1 = y^r mod p */ + mp32bpowmod(p, y->size, y->data, r->size, r->data); + mp32copy(size, u1data, p->data); + + /* compute u2 = r^h(m) mod p */ + mp32bpowmod(p, r->size, r->data, hm->size, hm->data); + + /* compute v2 = u1*u2 mod p */ + mp32bmulmod(p, size, p->data, size, u1data); + + return mp32eq(size, v1data, p->data); +} diff --git a/beecrypt/elgamal.h b/beecrypt/elgamal.h new file mode 100644 index 0000000..973fa45 --- /dev/null +++ b/beecrypt/elgamal.h @@ -0,0 +1,50 @@ +/* + * elgamal.h + * + * ElGamal signature scheme, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _ELGAMAL_H +#define _ELGAMAL_H + +#include "mp32number.h" +#include "mp32barrett.h" + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void elgv1sign(const mp32barrett* p, const mp32barrett* n, const mp32number* g, randomGeneratorContext*, const mp32number* hm, const mp32number* x, mp32number* r, mp32number* s); +BEEDLLAPI +void elgv3sign(const mp32barrett* p, const mp32barrett* n, const mp32number* g, randomGeneratorContext*, const mp32number* hm, const mp32number* x, mp32number* r, mp32number* s); + +BEEDLLAPI +int elgv1vrfy(const mp32barrett* p, const mp32barrett* n, const mp32number* g, const mp32number* hm, const mp32number* y, const mp32number* r, const mp32number* s); +BEEDLLAPI +int elgv3vrfy(const mp32barrett* p, const mp32barrett* n, const mp32number* g, const mp32number* hm, const mp32number* y, const mp32number* r, const mp32number* s); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/endianness.c b/beecrypt/endianness.c new file mode 100644 index 0000000..1b4cf21 --- /dev/null +++ b/beecrypt/endianness.c @@ -0,0 +1,477 @@ +/* + * endianness.c + * + * Endianness-dependant encoding/decoding - implementation + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "endianness.h" + +#if HAVE_STRING_H +#include +#endif + +#include + +int16 swap16(int16 n) +{ + return ( ((n & 0xff) << 8) | + ((n & 0xff00) >> 8) ); +} + +uint16 swapu16(uint16 n) +{ + return ( ((n & 0xffU) << 8) | + ((n & 0xff00U) >> 8) ); +} + +int32 swap32(int32 n) +{ + #if (SIZEOF_LONG == 4) + return ( ((n & 0xff) << 24) | + ((n & 0xff00) << 8) | + ((n & 0xff0000) >> 8) | + ((n & 0xff000000) >> 24) ); + #else + return ( ((n & 0xffL) << 24) | + ((n & 0xff00L) << 8) | + ((n & 0xff0000L) >> 8) | + ((n & 0xff000000L) >> 24) ); + #endif +} + +uint32 swapu32(uint32 n) +{ + #if (SIZEOF_UNSIGNED_LONG == 4) + return ( ((n & 0xffU) << 24) | + ((n & 0xff00U) << 8) | + ((n & 0xff0000U) >> 8) | + ((n & 0xff000000U) >> 24) ); + #else + return ( ((n & 0xffUL) << 24) | + ((n & 0xff00UL) << 8) | + ((n & 0xff0000UL) >> 8) | + ((n & 0xff000000UL) >> 24) ); + #endif +} + +int64 swap64(int64 n) +{ + #if (SIZEOF_LONG == 4) + return ( ((n & 0xffLL) << 56) | + ((n & 0xff00LL) << 40) | + ((n & 0xff0000LL) << 24) | + ((n & 0xff000000LL) << 8) | + ((n & 0xff00000000LL) >> 8) | + ((n & 0xff0000000000LL) >> 24) | + ((n & 0xff000000000000LL) >> 40) | + ((n & 0xff00000000000000LL) >> 56) ); + #else + return ( ((n & 0xffL) << 56) | + ((n & 0xff00L) << 40) | + ((n & 0xff0000L) << 24) | + ((n & 0xff000000L) << 8) | + ((n & 0xff00000000L) >> 8) | + ((n & 0xff0000000000L) >> 24) | + ((n & 0xff000000000000L) >> 40) | + ((n & 0xff00000000000000L) >> 56) ); + #endif +} + +int encodeByte(javabyte b, byte *data) +{ + *data = b; + return 1; +} + +int encodeShort(javashort s, byte *data) +{ + #if (!WORDS_BIGENDIAN) + s = swap16(s); + #endif + memcpy(data, &s, 2); + return 2; +} + +int encodeInt(javaint i, byte* data) +{ + #if (!WORDS_BIGENDIAN) + i = swap32(i); + #endif + memcpy(data, &i, 4); + return 4; +} + +int encodeLong(javalong l, byte* data) +{ + #if (!WORDS_BIGENDIAN) + l = swap64(l); + #endif + memcpy(data, &l, 8); + return 8; +} + +int encodeFloat(javafloat f, byte* data) +{ + #if (!WORDS_BIGENDIAN) + register const byte* src = ((const byte*) &f) + 3; + register int i; + for (i = 0; i < 4; i++) + data[i] = *(src--); + #else + memcpy(data, &f, 4); + #endif + return 4; +} + +int encodeDouble(javadouble d, byte* data) +{ + #if (!WORDS_BIGENDIAN) + register const byte* src = ((byte*) &d) + 7; + register int i; + for (i = 0; i < 8; i++) + data[i] = *(src--); + #else + memcpy(data, &d, 8); + #endif + return 8; +} + +int encodeChar(javachar c, byte* data) +{ + #if (!WORDS_BIGENDIAN) + c = swapu16(c); + #endif + memcpy(data, &c, 2); + return 2; +} + +int encodeInts(const javaint* i, byte* data, int count) +{ + register int rc = count << 2; + #if (WORDS_BIGENDIAN) + memcpy(data, i, rc); + #else + javaint tmp; + while (count--) + { + tmp = swap32(*(i++)); + memcpy(data, &tmp, 4); + data += 4; + } + #endif + return rc; +} + +int encodeChars(const javachar* c, byte* data, int count) +{ + register int rc = count << 1; + #if (WORDS_BIGENDIAN) + memcpy(data, c, rc); + #else + javaint tmp; + while (count--) + { + tmp = swapu16(*(c++)); + memcpy(data, &tmp, 2); + data += 2; + } + #endif + return rc; +} + +int decodeByte(javabyte* b, const byte* data) +{ + *b = *data; + return 1; +} + +int decodeShort(javashort* s, const byte* data) +{ + #if (WORDS_BIGENDIAN) + memcpy(s, data, 2); + #else + javashort tmp; + memcpy(&tmp, data, 2); + *s = swap16(tmp); + #endif + return 2; +} + +int decodeInt(javaint* i, const byte* data) +{ + #if (WORDS_BIGENDIAN) + memcpy(i, data, 4); + #else + javaint tmp; + memcpy(&tmp, data, 4); + *i = swap32(tmp); + #endif + return 4; +} + +int decodeLong(javalong* l, const byte* data) +{ + #if (WORDS_BIGENDIAN) + memcpy(l, data, 8); + #else + javalong tmp; + memcpy(&tmp, data, 8); + *l = swap64(tmp); + #endif + return 8; +} + +int decodeFloat(javafloat* f, const byte* data) +{ + #if (WORDS_BIGENDIAN) + memcpy(f, data, 4); + #else + register byte *dst = ((byte*) f) + 3; + register int i; + for (i = 0; i < 4; i++) + *(dst--) = data[i]; + #endif + return 4; +} + +int decodeDouble(javadouble* d, const byte* data) +{ + #if (WORDS_BIGENDIAN) + memcpy(d, data, 8); + #else + register byte *dst = ((byte*) d) + 7; + register int i; + for (i = 0; i < 8; i++) + *(dst--) = data[i]; + #endif + return 8; +} + +int decodeChar(javachar* c, const byte* data) +{ + #if (WORDS_BIGENDIAN) + memcpy(c, data, 2); + #else + javachar tmp; + memcpy(&tmp, data, 2); + *c = swapu16(tmp); + #endif + return 2; +} + +int decodeInts(javaint* i, const byte* data, int count) +{ + register int rc = count << 2; + #if (WORDS_BIGENDIAN) + memcpy(i, data, rc); + #else + javaint tmp; + while (count--) + { + memcpy(&tmp, data, 4); + *(i++) = swap32(tmp); + data += 4; + } + #endif + return rc; +} + +int decodeChars(javachar* c, const byte* data, int count) +{ + register int rc = count << 1; + #if (WORDS_BIGENDIAN) + memcpy(c, data, rc); + #else + javachar tmp; + while (count--) + { + memcpy(&tmp, data, 2); + *(c++) = swapu16(tmp); + data += 2; + } + #endif + return rc; +} + +int readByte(javabyte* b, FILE* in) +{ + return fread(b, 1, 1, in); +} + +int readShort(javashort* s, FILE* in) +{ + register int rc = fread(s, 2, 1, in); + #if !(WORDS_BIGENDIAN) + if (rc == 1) + { + register javashort tmp = *s; + *s = swap16(tmp); + } + #endif + return rc; +} + +int readInt(javaint* i, FILE* in) +{ + register int rc = fread(i, 4, 1, in); + #if !(WORDS_BIGENDIAN) + if (rc == 1) + { + register javaint tmp = *i; + *i = swap32(tmp); + } + #endif + return rc; +} + +int readLong(javalong* l, FILE* in) +{ + register int rc = fread(l, 8, 1, in); + #if !(WORDS_BIGENDIAN) + if (rc == 1) + { + register javalong tmp = *l; + *l = swap64(tmp); + } + #endif + return rc; +} + +int readChar(javachar* c, FILE* in) +{ + register int rc = fread(c, 2, 1, in); + #if !(WORDS_BIGENDIAN) + if (rc == 1) + { + register javachar tmp = *c; + *c = swapu16(tmp); + } + #endif + return rc; +} + +int readInts(javaint* i, FILE* in, int count) +{ + register int rc = fread(i, 4, count, in); + #if !(WORDS_BIGENDIAN) + if (rc == count) + { + while (count > 0) + { + register javaint tmp = *i; + *(i++) = swap32(tmp); + count--; + } + } + #endif + return rc; +} + +int readChars(javachar* c, FILE* in, int count) +{ + register int rc = fread(c, 2, count, in); + #if !(WORDS_BIGENDIAN) + if (rc == count) + { + while (count > 0) + { + register javachar tmp = *c; + *(c++) = swap16(tmp); + count--; + } + } + #endif + return rc; +} + +int writeByte(javabyte b, FILE* out) +{ + return fwrite(&b, 1, 1, out); +} + +int writeShort(javashort s, FILE* out) +{ + #if !(WORDS_BIGENDIAN) + s = swap16(s); + #endif + return fwrite(&s, 2, 1, out); +} + +int writeInt(javaint i, FILE* out) +{ + #if !(WORDS_BIGENDIAN) + i = swap32(i); + #endif + return fwrite(&i, 4, 1, out); +} + +int writeLong(javalong l, FILE* out) +{ + #if !(WORDS_BIGENDIAN) + l = swap64(l); + #endif + return fwrite(&l, 8, 1, out); +} + +int writeChar(javachar c, FILE* out) +{ + #if !(WORDS_BIGENDIAN) + c = swap16(c); + #endif + return fwrite(&c, 2, 1, out); +} + +int writeInts(const javaint* i, FILE* out, int count) +{ + #if WORDS_BIGENDIAN + return fwrite(i, 4, count, out); + #else + register int total = 0; + while (count-- > 0) + { + register int rc = writeInt(*(i++), out); + if (rc < 0) + break; + total += rc; + } + return total; + #endif +} + +int writeChars(const javachar* c, FILE* out, int count) +{ + #if WORDS_BIGENDIAN + return fwrite(c, 2, count, out); + #else + register int total = 0; + while (count-- > 0) + { + register int rc = writeChar(*(c++), out); + if (rc < 0) + break; + total += rc; + } + return total; + #endif +} diff --git a/beecrypt/endianness.h b/beecrypt/endianness.h new file mode 100644 index 0000000..e09e7b8 --- /dev/null +++ b/beecrypt/endianness.h @@ -0,0 +1,187 @@ +/* + * endianness.h + * + * Endian-dependant encoding/decoding, header + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: 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 _ENDIANNESS_H +#define _ENDIANNESS_H + +#include "beecrypt.h" + +#include + +#ifdef __cplusplus +inline int16 swap16(int16 n) +{ + return ( ((n & 0xff) << 8) | + ((n & 0xff00) >> 8) ); +} + +inline uint16 swapu16(uint16 n) +{ + return ( ((n & 0xffU) << 8) | + ((n & 0xff00U) >> 8) ); +} + +inline int32 swap32(int32 n) +{ + #if (SIZEOF_LONG == 4) + return ( ((n & 0xff) << 24) | + ((n & 0xff00) << 8) | + ((n & 0xff0000) >> 8) | + ((n & 0xff000000) >> 24) ); + #else + return ( ((n & 0xffL) << 24) | + ((n & 0xff00L) << 8) | + ((n & 0xff0000L) >> 8) | + ((n & 0xff000000L) >> 24) ); + #endif +} + +inline uint32 swapu32(uint32 n) +{ + #if (SIZEOF_UNSIGNED_LONG == 4) + return ( ((n & 0xffU) << 24) | + ((n & 0xff00U) << 8) | + ((n & 0xff0000U) >> 8) | + ((n & 0xff000000U) >> 24) ); + #else + return ( ((n & 0xffUL) << 24) | + ((n & 0xff00UL) << 8) | + ((n & 0xff0000UL) >> 8) | + ((n & 0xff000000UL) >> 24) ); + #endif +} + +inline int64 swap64(int64 n) +{ + #if (SIZEOF_LONG == 4) + return ( ((n & 0xffLL) << 56) | + ((n & 0xff00LL) << 40) | + ((n & 0xff0000LL) << 24) | + ((n & 0xff000000LL) << 8) | + ((n & 0xff00000000LL) >> 8) | + ((n & 0xff0000000000LL) >> 24) | + ((n & 0xff000000000000LL) >> 40) | + ((n & 0xff00000000000000LL) >> 56) ); + #else + return ( ((n & 0xffL) << 56) | + ((n & 0xff00L) << 40) | + ((n & 0xff0000L) << 24) | + ((n & 0xff000000L) << 8) | + ((n & 0xff00000000L) >> 8) | + ((n & 0xff0000000000L) >> 24) | + ((n & 0xff000000000000L) >> 40) | + ((n & 0xff00000000000000L) >> 56) ); + #endif +} +#else + int16 swap16 (int16); +uint16 swapu16(uint16); + int32 swap32 (int32); +uint32 swapu32(uint32); + int64 swap64 (int64); +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int encodeByte(javabyte, byte*); +BEEDLLAPI +int encodeShort(javashort, byte*); +BEEDLLAPI +int encodeInt(javaint, byte*); + +BEEDLLAPI +int encodeLong(javalong, byte*); +BEEDLLAPI +int encodeChar(javachar, byte*); +BEEDLLAPI +int encodeFloat(javafloat, byte*); +BEEDLLAPI +int encodeDouble(javadouble, byte*); + +BEEDLLAPI +int encodeInts(const javaint*, byte*, int); +BEEDLLAPI +int encodeChars(const javachar*, byte*, int); + +BEEDLLAPI +int decodeByte(javabyte*, const byte*); +BEEDLLAPI +int decodeShort(javashort*, const byte*); +BEEDLLAPI +int decodeInt(javaint*, const byte*); +BEEDLLAPI +int decodeLong(javalong*, const byte*); +BEEDLLAPI +int decodeChar(javachar*, const byte*); +BEEDLLAPI +int decodeFloat(javafloat*, const byte*); +BEEDLLAPI +int decodeDouble(javadouble*, const byte*); + +BEEDLLAPI +int decodeInts(javaint*, const byte*, int); +BEEDLLAPI +int decodeChars(javachar*, const byte*, int); + +BEEDLLAPI +int writeByte(javabyte, FILE*); +BEEDLLAPI +int writeShort(javashort, FILE*); +BEEDLLAPI +int writeInt(javaint, FILE*); +BEEDLLAPI +int writeLong(javalong, FILE*); +BEEDLLAPI +int writeChar(javachar, FILE*); + +BEEDLLAPI +int writeInts(const javaint*, FILE*, int); +BEEDLLAPI +int writeChars(const javachar*, FILE*, int); + +BEEDLLAPI +int readByte(javabyte*, FILE*); +BEEDLLAPI +int readShort(javashort*, FILE*); +BEEDLLAPI +int readInt(javaint*, FILE*); +BEEDLLAPI +int readLong(javalong*, FILE*); +BEEDLLAPI +int readChar(javachar*, FILE*); + +BEEDLLAPI +int readInts(javaint*, FILE*, int); +BEEDLLAPI +int readChars(javachar*, FILE*, int); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/entropy.c b/beecrypt/entropy.c new file mode 100644 index 0000000..1e31a78 --- /dev/null +++ b/beecrypt/entropy.c @@ -0,0 +1,1155 @@ +/* + * entropy.c + * + * entropy gathering routine for pseudo-random generator initialization + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "entropy.h" +#include "endianness.h" + +#if WIN32 +# include +#else +# if HAVE_SYS_IOCTL_H +# include +# endif +# if HAVE_SYS_STAT_H +# include +# include +# endif +# if HAVE_SYS_TIME_H +# include +# endif +# if HAVE_SYS_AUDIOIO_H +# include +# endif +# if HAVE_SYS_SOUNDCARD_H +# include +# endif +# if HAVE_TERMIO_H +# include +# endif +# if HAVE_SYNCH_H +# include +# elif HAVE_PTHREAD_H +# include +# else +# error need locking mechanism +# endif +#endif +#if HAVE_STDLIB_H +# include +#endif +#if HAVE_FCNTL_H +# include +#endif +#if HAVE_UNISTD_H +# include +#endif +#if HAVE_STRING_H +# include +#endif +#if HAVE_ERRNO_H +# include +#endif + +#include + +#if WIN32 +static HINSTANCE entropy_instance = (HINSTANCE) 0; + +static HANDLE entropy_wavein_lock; +static HANDLE entropy_wavein_event; + +int entropy_provider_setup(HINSTANCE hInst) +{ + if (!entropy_instance) + { + entropy_instance = hInst; + if (!(entropy_wavein_lock = CreateMutex(NULL, FALSE, NULL))) + return -1; + if (!(entropy_wavein_event = CreateEvent(NULL, FALSE, FALSE, NULL))) + return -1; + } + return 0; +} + +int entropy_provider_cleanup() +{ + if (entropy_wavein_lock) + { + CloseHandle(entropy_wavein_lock); + entropy_wavein_lock = 0; + } + if (entropy_wavein_event) + { + CloseHandle(entropy_wavein_event); + entropy_wavein_event = 0; + } + return 0; +} + +static int entropy_noisebits_8(HWAVEIN wavein, uint32 *data, int size) +{ + uint32 randombits = size << 5; + uint32 temp = 0; + + /* first set up a wave header */ + WAVEHDR header; + /* use a 1K buffer */ + uint8 sample[1024]; + + header.lpData = (LPSTR) sample; + header.dwBufferLength = 1024 * sizeof(uint8); + header.dwFlags = 0; + + /* do error handling! */ + waveInStart(wavein); + + /* the first event is the due to the opening of the wave */ + ResetEvent(entropy_wavein_event); + + while (randombits) + { + register int i; + + while (1) + { + /* pass the buffer to the wavein and wait for the event */ + waveInPrepareHeader(wavein, &header, sizeof(WAVEHDR)); + waveInAddBuffer(wavein, &header, sizeof(WAVEHDR)); + + /* in case we have to wait more than 10 seconds, bail out */ + if (WaitForSingleObject(entropy_wavein_event, 10000) == WAIT_OBJECT_0) + { + /* only process if we read the whole thing */ + if (header.dwBytesRecorded == header.dwBufferLength) + break; + } + else + { + waveInReset(wavein); + waveInClose(wavein); + return -1; + } + } + + /* on windows, no swap of sample data is necessary */ + for (i = 0; randombits && (i < 1024); i += 2) + { + if ((sample[i] ^ sample[i+1]) & 0x1) + { + temp <<= 1; + if (sample[i] & 0x1) + temp |= 0x1; + randombits--; + if (!(randombits & 0x1F)) + *(data++) = temp; + } + } + } + + waveInReset(wavein); + waveInClose(wavein); + + ReleaseMutex(entropy_wavein_lock); + + return 0; +} + +static int entropy_noisebits_16(HWAVEIN wavein, uint32 *data, int size) +{ + uint32 randombits = size << 5; + uint32 temp = 0; + + /* first set up a wave header */ + WAVEHDR header; + /* use a 1K buffer */ + uint16 sample[512]; + + header.lpData = (LPSTR) sample; + header.dwBufferLength = 512 * sizeof(uint16); + header.dwFlags = 0; + + /* do error handling! */ + waveInStart(wavein); + + /* the first event is the due to the opening of the wave */ + ResetEvent(entropy_wavein_event); + + while (randombits) + { + register int i; + + while (1) + { + /* pass the buffer to the wavein and wait for the event */ + waveInPrepareHeader(wavein, &header, sizeof(WAVEHDR)); + waveInAddBuffer(wavein, &header, sizeof(WAVEHDR)); + + /* in case we have to wait more than 10 seconds, bail out */ + if (WaitForSingleObject(entropy_wavein_event, 10000) == WAIT_OBJECT_0) + { + /* only process if we read the whole thing */ + if (header.dwBytesRecorded == header.dwBufferLength) + break; + } + else + { + waveInReset(wavein); + waveInClose(wavein); + return -1; + } + } + + /* on windows, no swap of sample data is necessary */ + for (i = 0; randombits && (i < 512); i += 2) + { + if ((sample[i] ^ sample[i+1]) & 0x1) + { + temp <<= 1; + if (sample[i] & 0x1) + temp |= 0x1; + randombits--; + if (!(randombits & 0x1F)) + *(data++) = temp; + } + } + } + + waveInReset(wavein); + waveInClose(wavein); + + ReleaseMutex(entropy_wavein_lock); + + return 0; +} + +int entropy_wavein(uint32* data, int size) +{ + WAVEINCAPS waveincaps; + WAVEFORMATEX waveformatex; + HWAVEIN wavein; + MMRESULT numdevs; + MMRESULT rc; + + numdevs = waveInGetNumDevs(); + if (numdevs <= 0) + return -1; + + rc = waveInGetDevCaps(0, &waveincaps, sizeof(WAVEINCAPS)); + if (rc != MMSYSERR_NOERROR) + return -1; + + /* first go for the 16 bits samples -> more chance of noise bits */ + switch (waveformatex.nChannels = waveincaps.wChannels) + { + case 1: + /* mono */ + if (waveincaps.dwFormats & WAVE_FORMAT_4M16) + { + waveformatex.nSamplesPerSec = 44100; + waveformatex.wBitsPerSample = 16; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_2M16) + { + waveformatex.nSamplesPerSec = 22050; + waveformatex.wBitsPerSample = 16; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_1M16) + { + waveformatex.nSamplesPerSec = 11025; + waveformatex.wBitsPerSample = 16; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_4M08) + { + waveformatex.nSamplesPerSec = 44100; + waveformatex.wBitsPerSample = 8; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_2M08) + { + waveformatex.nSamplesPerSec = 22050; + waveformatex.wBitsPerSample = 8; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_1M08) + { + waveformatex.nSamplesPerSec = 11025; + waveformatex.wBitsPerSample = 8; + } + else + return -1; + + break; + case 2: + /* stereo */ + if (waveincaps.dwFormats & WAVE_FORMAT_4S16) + { + waveformatex.nSamplesPerSec = 44100; + waveformatex.wBitsPerSample = 16; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_2S16) + { + waveformatex.nSamplesPerSec = 22050; + waveformatex.wBitsPerSample = 16; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_1S16) + { + waveformatex.nSamplesPerSec = 11025; + waveformatex.wBitsPerSample = 16; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_4S08) + { + waveformatex.nSamplesPerSec = 44100; + waveformatex.wBitsPerSample = 8; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_2S08) + { + waveformatex.nSamplesPerSec = 22050; + waveformatex.wBitsPerSample = 8; + } + else if (waveincaps.dwFormats & WAVE_FORMAT_1S08) + { + waveformatex.nSamplesPerSec = 11025; + waveformatex.wBitsPerSample = 8; + } + else + return -1; + + break; + } + + waveformatex.wFormatTag = WAVE_FORMAT_PCM; + waveformatex.nAvgBytesPerSec = (waveformatex.nSamplesPerSec * waveformatex.nChannels * waveformatex.wBitsPerSample) / 8; + waveformatex.nBlockAlign = (waveformatex.nChannels * waveformatex.wBitsPerSample) / 8; + waveformatex.cbSize = 0; + + /* we now have the wavein's capabilities hammered out; from here on we need to lock */ + + if (WaitForSingleObject(entropy_wavein_lock, INFINITE) != WAIT_OBJECT_0) + return -1; + + rc = waveInOpen(&wavein, 0, &waveformatex, (DWORD) entropy_wavein_event, (DWORD) 0, CALLBACK_EVENT); + if (rc != MMSYSERR_NOERROR) + { + fprintf(stderr, "waveInOpen returned %d\n", rc); + ReleaseMutex(entropy_wavein_lock); + return -1; + } + + switch (waveformatex.wBitsPerSample) + { + case 8: + return entropy_noisebits_8(wavein, data, size); + case 16: + return entropy_noisebits_16(wavein, data, size); + default: + waveInClose(wavein); + ReleaseMutex(entropy_wavein_lock); + return -1; + } +} +#else +#if HAVE_DEV_AUDIO +static const char* name_dev_audio = "/dev/audio"; +static int dev_audio_fd = -1; +#ifdef _REENTRANT +#if HAVE_SYNCH_H +static mutex_t dev_audio_lock = DEFAULTMUTEX; +#elif HAVE_PTHREAD_H +static pthread_mutex_t dev_audio_lock = PTHREAD_MUTEX_INITIALIZER; +#else +#error Need locking mechanism +#endif +#endif +#endif + +#if HAVE_DEV_DSP +static const char* name_dev_dsp = "/dev/dsp"; +static int dev_dsp_fd = -1; +#ifdef _REENTRANT +#if HAVE_SYNCH_H +static mutex_t dev_dsp_lock = DEFAULTMUTEX; +#elif HAVE_PTHREAD_H +static pthread_mutex_t dev_dsp_lock = PTHREAD_MUTEX_INITIALIZER; +#else +#error Need locking mechanism +#endif +#endif +#endif + +#if HAVE_DEV_RANDOM +static const char* name_dev_random = "/dev/random"; +static int dev_random_fd = -1; +#ifdef _REENTRANT +#if HAVE_SYNC_H +static mutex_t dev_random_lock = DEFAULTMUTEX; +#elif HAVE_PTHREAD_H +static pthread_mutex_t dev_random_lock = PTHREAD_MUTEX_INITIALIZER; +#else +#error Need locking mechanism +#endif +#endif +#endif + +#if HAVE_DEV_TTY +static const char *dev_tty_name = "/dev/tty"; +static int dev_tty_fd = -1; +#ifdef _REENTRANT +#if HAVE_SYNCH_H +static mutex_t dev_tty_lock = DEFAULTMUTEX; +#elif HAVE_PTHREAD_H +static pthread_mutex_t dev_tty_lock = PTHREAD_MUTEX_INITIALIZER; +#else +#error Need locking mechanism +#endif +#endif +#endif + +#if HAVE_SYS_STAT_H +static int statdevice(const char *device) +{ + struct stat s; + + if (stat(device, &s) < 0) + { + #if HAVE_ERRNO_H && HAVE_STRING_H + fprintf(stderr, "cannot stat %s: %s\n", device, strerror(errno)); + #endif + return -1; + } + if (!S_ISCHR(s.st_mode)) + { + fprintf(stderr, "%s is not a device\n", device); + return -1; + } + return 0; +} +#endif + +#if HAVE_FCNTL_H +static int opendevice(const char *device) +{ + register int fd, flags, rc; + + if ((fd = open(device, O_RDWR | O_NONBLOCK)) < 0) + { + #if HAVE_ERRNO_H && HAVE_STRING_H + fprintf(stderr, "open of %s failed: %s\n", device, strerror(errno)); + #endif + return fd; + } + + flags = fcntl(fd, F_GETFL, 0); + if (flags >= 0) + { + rc = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); + if (rc < 0) + { + #if HAVE_ERRNO_H + perror("fcntl F_SETFL failed"); + #endif + return rc; + } + } + else + { + #if HAVE_ERRNO_H + perror("fcntl F_GETFL failed"); + #endif + return flags; + } + + return fd; +} +#endif + +#if HAVE_DEV_AUDIO || HAVE_DEV_DSP +/* bit deskewing technique: the classical Von Neumann method + - only use the lsb bit of every sample + - there is a chance of bias in 0 or 1 bits, so to deskew this: + - look at two successive sampled bits + - if they are the same, discard them + - if they are different, they're either 0-1 or 1-0; use the first bit of the pair as output +*/ + +static int entropy_be_noisebits(int fd, uint32 *data, int size) +{ + register uint32 randombits = size << 5; + register uint32 temp; + uint16 sample[2]; + + while (randombits) + { + if (read(fd, sample, sizeof(sample)) < 0) + { + #if HAVE_ERRNO_H + perror("read failed"); + #endif + return -1; + } + + if ((sample[0] ^ sample[1]) & 0x1) + { + temp <<= 1; + if (sample[0] & 0x1) + temp |= 0x1; + randombits--; + if (!(randombits & 0x1F)) + *(data++) = temp; + } + } + return 0; +} + +static int entropy_le_noisebits(int fd, uint32 *data, int size) +{ + register uint32 randombits = size << 5; + register uint32 temp; + uint16 sample[2]; + + while (randombits) + { + if (read(fd, sample, sizeof(sample)) < 0) + { + #if HAVE_ERRNO_H + perror("read failed"); + #endif + return -1; + } + + if (swapu16(sample[0] ^ sample[1]) & 0x1) + { + temp <<= 1; + if (sample[0] & 0x1) + temp |= 0x1; + randombits--; + if (!(randombits & 0x1F)) + *(data++) = temp; + } + } + return 0; +} +#endif + +#if HAVE_DEV_RANDOM +static int entropy_randombits(int fd, uint32* data, int size) +{ + register uint32 randombytes = size << 2; + register uint32 temp; + uint8 ch; + + while (randombytes) + { + if (read(fd, &ch, 1) < 0) + { + #if HAVE_ERRNO_H + perror("read failed"); + #endif + return -1; + } + + temp <<= 8; + temp |= ch; + + randombytes--; + if (!(randombytes & 0x3)) + *(data++) = temp; + } + return 0; +} +#endif + +#if HAVE_DEV_TTY +static int entropy_ttybits(int fd, uint32* data, int size) +{ + register uint32 randombits = size << 5; + register uint32 temp; + byte dummy; + #if HAVE_TERMIO_H + struct termio tio_save, tio_set; + #endif + #if HAVE_GETHRTIME + hrtime_t hrtsample; + #elif HAVE_GETTIMEOFDAY + struct timeval tvsample; + #else + # error Need alternative high-precision timer + #endif + + printf("please press random keys on your keyboard\n"); + #if HAVE_TERMIO_H + if (ioctl(fd, TCGETA, &tio_save) < 0) + { + #if HAVE_ERRNO_H + perror("ioctl TCGETA failed"); + #endif + return -1; + } + + tio_set = tio_save; + tio_set.c_cc[VMIN] = 1; /* read 1 tty character at a time */ + tio_set.c_cc[VTIME] = 0; /* don't timeout the read */ + tio_set.c_iflag |= IGNBRK; /* ignore -c */ + tio_set.c_lflag &= ~(ECHO|ICANON); /* don't echo characters */ + + /* change the tty settings, and flush input characters */ + if (ioctl(fd, TCSETAF, &tio_set) < 0) + { + #if HAVE_ERRNO_H + perror("ioctl TCSETAF failed"); + #endif + return -1; + } + #else + # error Need alternative tty control library + #endif + + while (randombits) + { + if (read(fd, &dummy, 1) < 0) + { + #if HAVE_ERRNO_H + perror("tty read failed"); + #endif + return -1; + } + printf("."); fflush(stdout); + #if HAVE_GETHRTIME + hrtsample = gethrtime(); + /* get 16 bits from the sample */ + temp <<= 16; + /* discard the 10 lowest bits i.e. 1024 nanoseconds */ + temp |= (uint16)(hrtsample >> 10); + randombits -= 16; + #elif HAVE_GETTIMEOFDAY + /* discard the 4 lowest bits i.e. 4 microseconds */ + gettimeofday(&tvsample, 0); + /* get 8 bits from the sample */ + temp <<= 8; + temp |= (uint8)(tvsample.tv_usec >> 2); + randombits -= 8; + #else + # error Need alternative high-precision timer sample + #endif + if (!(randombits & 0x1f)) + *(data++) = temp; + } + + printf("\nthanks\n"); + + /* give the user 1 second to stop typing */ + sleep(1); + + #if HAVE_TERMIO_H + /* restore the tty settings, and flush input characters */ + if (ioctl(fd, TCSETAF, &tio_save) < 0) + { + #if HAVE_ERRNO_H + perror("ioctl TCSETAF failed"); + #endif + return -1; + } + #else + # error Need alternative tty control library + #endif + + return 0; +} +#endif + +#if HAVE_DEV_AUDIO +int entropy_dev_audio(uint32 *data, int size) +{ + #ifdef _REENTRANT + # if HAVE_SYNCH_H + if (mutex_lock(&dev_audio_lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&dev_audio_lock)) + return -1; + # else + # error need locking mechanism + # endif + #endif + + #if HAVE_SYS_STAT_H + if (statdevice(name_dev_audio) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_audio_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_audio_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + #endif + + if ((dev_audio_fd = opendevice(name_dev_audio)) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_audio_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_audio_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + #if HAVE_SYS_AUDIOIO_H /* i.e. Solaris */ + { + struct audio_info info; + + AUDIO_INITINFO(&info); + + info.record.sample_rate = 48000; + info.record.channels = 2; + info.record.precision = 16; + info.record.encoding = AUDIO_ENCODING_LINEAR; + info.record.gain = AUDIO_MAX_GAIN; + info.record.pause = 0; + info.record.buffer_size = 4096; + info.record.samples = 0; + + if (ioctl(dev_audio_fd, AUDIO_SETINFO, &info) < 0) + { + if (errno == EINVAL) + { + /* use a conservative setting this time */ + info.record.sample_rate = 22050; + info.record.channels = 1; + info.record.precision = 8; + + if (ioctl(dev_audio_fd, AUDIO_SETINFO, &info) < 0) + { + #if HAVE_ERRNO_H + perror("ioctl AUDIO_SETINFO failed"); + #endif + close(dev_audio_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_audio_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_audio_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + } + else + { + #if HAVE_ERRNO_H + perror("ioctl AUDIO_SETINFO failed"); + #endif + close(dev_audio_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_audio_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_audio_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + } + + if (entropy_be_noisebits(dev_audio_fd, data, size) < 0) + { + close(dev_audio_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_audio_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_audio_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + } + #else + # error Unknown type of /dev/audio interface + #endif + + close(dev_audio_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_audio_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_audio_lock); + # else + # error need locking mechanism + # endif + #endif + return 0; +} +#endif + +#if HAVE_DEV_DSP +int entropy_dev_dsp(uint32 *data, int size) +{ + #ifdef _REENTRANT + # if HAVE_SYNCH_H + if (mutex_lock(&dev_dsp_lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&dev_dsp_lock)) + return -1; + # else + # error need locking mechanism + # endif + #endif + + #if HAVE_SYS_STAT_H + if (statdevice(name_dev_dsp) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + #endif + + if ((dev_dsp_fd = opendevice(name_dev_dsp)) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + #if HAVE_SYS_SOUNDCARD_H /* i.e. Linux audio */ + { + int mask, format, stereo, speed, swap; + + if (ioctl(dev_dsp_fd, SNDCTL_DSP_GETFMTS, &mask) < 0) + { + #if HAVE_ERRNO_H + perror("ioctl SNDCTL_DSP_GETFMTS failed"); + #endif + close (dev_dsp_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + #if WORDS_BIGENDIAN + if (mask & AFMT_S16_BE) + { + format = AFMT_S16_BE; + swap = 0; + } + else if (mask & AFMT_S16_LE) + { + format = AFMT_S16_LE; + swap = 1; + } + #else + if (mask & AFMT_S16_LE) + { + format = AFMT_S16_LE; + swap = 0; + } + else if (mask & AFMT_S16_BE) + { + format = AFMT_S16_BE; + swap = 1; + } + #endif + else if (mask & AFMT_S8) + { + format = AFMT_S8; + swap = 0; + } + else + { + /* No linear audio format available */ + close(dev_dsp_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + if (ioctl(dev_dsp_fd, SNDCTL_DSP_SETFMT, &format) < 0) + { + #if HAVE_ERRNO_H + perror("ioctl SNDCTL_DSP_SETFMT failed"); + #endif + close(dev_dsp_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + stereo = 1; + ioctl(dev_dsp_fd, SNDCTL_DSP_STEREO, &stereo); + + speed = 44100; + ioctl(dev_dsp_fd, SNDCTL_DSP_SPEED, &speed); + + if (swap) + { + if (entropy_le_noisebits(dev_dsp_fd, data, size) < 0) + { + close(dev_dsp_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + } + else + { + if (entropy_be_noisebits(dev_dsp_fd, data, size) < 0) + { + close(dev_dsp_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + } + } + #else + # error Unknown type of /dev/dsp interface + #endif + + close(dev_dsp_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_dsp_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_dsp_lock); + # else + # error need locking mechanism + # endif + #endif + return 0; +} +#endif + +#if HAVE_DEV_RANDOM +int entropy_dev_random(uint32* data, int size) +{ + #ifdef _REENTRANT + # if HAVE_SYNCH_H + if (mutex_lock(&dev_random_lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&dev_random_lock)) + return -1; + # else + # error need locking mechanism + # endif + #endif + + #if HAVE_SYS_STAT_H + if (statdevice(name_dev_random) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_random_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_random_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + #endif + + if ((dev_random_fd = opendevice(name_dev_random)) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_random_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_random_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + if (entropy_randombits(dev_random_fd, data, size) < 0) + { + close(dev_random_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_random_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_random_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + close(dev_random_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_random_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_random_lock); + # else + # error need locking mechanism + # endif + #endif + return 0; +} +#endif + +#if HAVE_DEV_TTY +int entropy_dev_tty(uint32* data, int size) +{ + #ifdef _REENTRANT + # if HAVE_SYNCH_H + if (mutex_lock(&dev_tty_lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&dev_tty_lock)) + return -1; + # else + # error need locking mechanism + # endif + #endif + + #if HAVE_SYS_STAT_H + if (statdevice(dev_tty_name) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_tty_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_tty_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + #endif + + if ((dev_tty_fd = opendevice(dev_tty_name)) < 0) + { + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_tty_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_tty_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + if (entropy_ttybits(dev_tty_fd, data, size) < 0) + { + close(dev_tty_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_tty_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_tty_lock); + # else + # error need locking mechanism + # endif + #endif + return -1; + } + + close(dev_tty_fd); + #ifdef _REENTRANT + # if HAVE_SYNCH_H + mutex_unlock(&dev_tty_lock); + # elif HAVE_PTHREAD_H + pthread_mutex_unlock(&dev_tty_lock); + # else + # error need locking mechanism + # endif + #endif + return 0; +} +#endif +#endif diff --git a/beecrypt/entropy.h b/beecrypt/entropy.h new file mode 100644 index 0000000..0952d3f --- /dev/null +++ b/beecrypt/entropy.h @@ -0,0 +1,63 @@ +/* + * entropy.h + * + * Entropy gathering routine(s) for pseudo-random generator initialization, header + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: 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 _ENTROPY_H +#define _ENTROPY_H + +#include "beecrypt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if WIN32 + +BEEDLLAPI +int entropy_provider_setup(HINSTANCE); +BEEDLLAPI +int entropy_provider_cleanup(); + +BEEDLLAPI +int entropy_wavein(uint32*, int); +#else +#if HAVE_DEV_AUDIO +int entropy_dev_audio (uint32*, int); +#endif +#if HAVE_DEV_DSP +int entropy_dev_dsp (uint32*, int); +#endif +#if HAVE_DEV_RANDOM +int entropy_dev_random(uint32*, int); +#endif +#if HAVE_DEV_TTY +int entropy_dev_tty (uint32*, int); +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/fips180.c b/beecrypt/fips180.c new file mode 100644 index 0000000..4388ad1 --- /dev/null +++ b/beecrypt/fips180.c @@ -0,0 +1,206 @@ +/* + * fips180.c + * + * SHA-1 hash function, code + * + * For more information on this algorithm, see: + * NIST FIPS PUB 180-1 + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "fips180.h" +#include "mp32.h" +#include "endianness.h" + +static uint32 sha1hinit[5] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 }; + +const hashFunction sha1 = { "SHA-1", sizeof(sha1Param), 5 * sizeof(uint32), (hashFunctionReset) sha1Reset, (hashFunctionUpdate) sha1Update, (hashFunctionDigest) sha1Digest }; + +int sha1Reset(register sha1Param *p) +{ + mp32copy(5, p->h, sha1hinit); + mp32zero(80, p->data); + p->length = 0; + p->offset = 0; + return 0; +} + +#define K00 0x5a827999 +#define K20 0x6ed9eba1 +#define K40 0x8f1bbcdc +#define K60 0xca62c1d6 + +#define ROL1(x) (((x) << 1) | ((x) >> 31)) +#define ROL5(x) (((x) << 5) | ((x) >> 27)) +#define ROR2(x) (((x) >> 2) | ((x) << 30)) + +#define subround1(a, b, c, d, e, w) \ + e = ROL5(a) + ((b&(c^d))^d) + e + w + K00; b = ROR2(b) +#define subround2(a, b, c, d, e, w) \ + e = ROL5(a) + (b^c^d) + e + w + K20; b = ROR2(b) +#define subround3(a, b, c, d, e, w) \ + e = ROL5(a) + (((b|c)&d)|(b&c)) + e + w + K40; b = ROR2(b) +#define subround4(a, b, c, d, e, w) \ + e = ROL5(a) + (b^c^d) + e + w + K60; b = ROR2(b) + +#ifndef ASM_SHA1PROCESS +void sha1Process(register sha1Param *p) +{ + register uint32 a, b, c, d, e; + register uint32 *w; + register byte t; + + #if WORDS_BIGENDIAN + w = p->data + 16; + #else + w = p->data; + t = 16; + while (t--) + { + register uint32 temp = swapu32(*w); + *(w++) = temp; + } + #endif + + t = 64; + while (t--) + { + register uint32 temp = w[-3] ^ w[-8] ^ w[-14] ^ w[-16]; + *(w++) = ROL1(temp); + } + + w = p->data; + + a = p->h[0]; b = p->h[1]; c = p->h[2]; d = p->h[3]; e = p->h[4]; + + t = 4; + while (t--) + { + subround1(a,b,c,d,e,w[0]); + subround1(e,a,b,c,d,w[1]); + subround1(d,e,a,b,c,w[2]); + subround1(c,d,e,a,b,w[3]); + subround1(b,c,d,e,a,w[4]); + w += 5; + } + + t = 4; + while (t--) + { + subround2(a,b,c,d,e,w[0]); + subround2(e,a,b,c,d,w[1]); + subround2(d,e,a,b,c,w[2]); + subround2(c,d,e,a,b,w[3]); + subround2(b,c,d,e,a,w[4]); + w += 5; + } + + t = 4; + while (t--) + { + subround3(a,b,c,d,e,w[0]); + subround3(e,a,b,c,d,w[1]); + subround3(d,e,a,b,c,w[2]); + subround3(c,d,e,a,b,w[3]); + subround3(b,c,d,e,a,w[4]); + w += 5; + } + t = 4; + while (t--) + { + subround4(a,b,c,d,e,w[0]); + subround4(e,a,b,c,d,w[1]); + subround4(d,e,a,b,c,w[2]); + subround4(c,d,e,a,b,w[3]); + subround4(b,c,d,e,a,w[4]); + w += 5; + } + + p->h[0] += a; + p->h[1] += b; + p->h[2] += c; + p->h[3] += d; + p->h[4] += e; +} +#endif + +int sha1Update(register sha1Param *p, const byte *data, int size) +{ + register int proclength; + + p->length += size; + while (size > 0) + { + proclength = ((p->offset + size) > 64) ? (64 - p->offset) : size; + memcpy(((byte *) p->data) + p->offset, data, proclength); + size -= proclength; + data += proclength; + p->offset += proclength; + + if (p->offset == 64) + { + sha1Process(p); + p->offset = 0; + } + } + return 0; +} + +static void sha1Finish(register sha1Param *p) +{ + register byte *ptr = ((byte *) p->data) + p->offset++; + + *(ptr++) = 0x80; + + if (p->offset > 56) + { + while (p->offset++ < 64) + *(ptr++) = 0; + + sha1Process(p); + p->offset = 0; + } + + ptr = ((byte *) p->data) + p->offset; + while (p->offset++ < 56) + *(ptr++) = 0; + + #if WORDS_BIGENDIAN + p->data[14] = (p->length >> 29); + p->data[15] = (p->length << 3) & 0xffffffff; + #else + p->data[14] = swapu32(p->length >> 29); + p->data[15] = swapu32(p->length << 3) & 0xffffffff; + #endif + + sha1Process(p); + p->offset = 0; +} + +int sha1Digest(register sha1Param *p, uint32 *data) +{ + sha1Finish(p); + mp32copy(5, data, p->h); + sha1Reset(p); + return 0; +} diff --git a/beecrypt/fips180.h b/beecrypt/fips180.h new file mode 100644 index 0000000..64666e2 --- /dev/null +++ b/beecrypt/fips180.h @@ -0,0 +1,59 @@ +/* + * fips180.h + * + * SHA-1 hash function, header + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: 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 _FIPS180_H +#define _FIPS180_H + +#include "beecrypt.h" +#include "fips180opt.h" + +typedef struct +{ + uint32 h[5]; + uint32 data[80]; + uint64 length; + uint8 offset; +} sha1Param; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const hashFunction sha1; + +BEEDLLAPI +void sha1Process(sha1Param*); +BEEDLLAPI +int sha1Reset (sha1Param*); +BEEDLLAPI +int sha1Update (sha1Param*, const byte*, int); +BEEDLLAPI +int sha1Digest (sha1Param*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/fips180opt.c b/beecrypt/fips180opt.c new file mode 100644 index 0000000..90e368f --- /dev/null +++ b/beecrypt/fips180opt.c @@ -0,0 +1,273 @@ +/* + * fips180pt.c + * + * Inline assembler optimized sha1 routines + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "fips180.h" + +#if WIN32 +#if __INTEL__ && __MWERKS__ + +void sha1ProcessMMX(sha1Param *param) +{ + uint64 tstart, tstop; + + asm { + rdtsc + mov dword ptr tstart,eax + mov dword ptr tstart+4,edx + + mov esi,dword ptr param + lea edi,[esi+20+64] + mov ecx,-15 + xor eax,eax + +swaps: + mov edx,[edi+ecx*4] + bswap edx + mov [edi+ecx*4],eax + inc ecx + jnz swaps + +/* don't do this one in MMX */ + + mov [esi+352],al + mov ecx,16 + +/* don't unroll any futher */ + + align 4 +xors: + mov eax,[edi-12] + mov ebx,[edi-8] + xor eax,[edi-24] + xor ebx,[edi-20] + xor eax,[edi-56] + xor ebx,[edi-52] + xor eax,[edi-64] + xor ebx,[edi-60] + rol eax,1 + rol ebx,1 + mov [edi],eax + mov [edi+4],ebx + mov eax,[edi-4] + mov ebx,[edi] + xor eax,[edi-16] + xor ebx,[edi-8] + xor eax,[edi-48] + xor ebx,[edi-44] + xor eax,[edi-56] + xor ebx,[edi-52] + rol eax,1 + rol ebx,1 + mov [edi+8],eax + mov [edi+12],ebx + lea edi,[edi+16] + dec ecx + jnz xors + + mov edi,20 + +/* non-mmx subround1 */ +subround1: + ; do subround one in registers + mov eax,dword ptr [esi+0] + mov ebx,dword ptr [esi+4] + mov ecx,dword ptr [esi+8] + mov edx,dword ptr [esi+12] + rol eax,5 + xor ecx,edx + add eax,dword ptr [esi+16] + and ecx,ebx + add eax,0x5a827999 + ror ebx,2 + add eax,dword ptr [esi+edi+0] + xor ecx,edx + mov dword ptr [esi+4],ebx + add eax,ecx + mov dword ptr [esi+16],eax + ; eax is still okay! + ; ecx's value is in ebx + mov ecx,ebx + mov ebx,dword ptr [esi+0] + mov edx,dword ptr [esi+8] + rol eax,5 + xor ecx,edx + add eax,dword ptr [esi+12] + and ecx,ebx + add eax,0x5a827999 + ror ebx,2 + add eax,dword ptr [esi+edi+4] + xor ecx,edx + mov dword ptr [esi+0],ebx + add eax,ecx + mov dword ptr [esi+12],eax + ; eax is still okay! + ; ecx's value is in ebx + mov ecx,ebx + mov ebx,dword ptr [esi+16] + mov edx,dword ptr [esi+4] + rol eax,5 + xor ecx,edx + add eax,dword ptr [esi+8] + and ecx,ebx + add eax,0x5a827999 + ror ebx,2 + add eax,dword ptr [esi+edi+8] + xor ecx,edx + mov dword ptr [esi+16],ebx + add eax,ecx + mov dword ptr [esi+8],eax + ; eax is still okay! + ; ecx's value is in ebx + mov ecx,ebx + mov ebx,dword ptr [esi+12] + mov edx,dword ptr [esi+0] + rol eax,5 + xor ecx,edx + add eax,dword ptr [esi+4] + and ecx,ebx + add eax,0x5a827999 + ror ebx,2 + add eax,dword ptr [esi+edi+12] + xor ecx,edx + mov dword ptr [esi+12],ebx + add eax,ecx + mov dword ptr [esi+4],eax + ; eax is still okay! + ; ecx's value is in ebx + mov ecx,ebx + mov ebx,dword ptr [esi+8] + mov edx,dword ptr [esi+16] + rol eax,5 + xor ecx,edx + add eax,dword ptr [esi+0] + and ecx,ebx + add eax,0x5a827999 + ror ebx,2 + add eax,dword ptr [esi+edi+16] + xor ecx,edx + mov dword ptr [esi+8],ebx + add eax,ecx + mov dword ptr [esi+0],eax + ; this has to be repeated 5 times + add edi,20 + cmp edi,120 + jne subround1 + +subround2: + mov eax,dword ptr [esi+0] + mov ebx,dword ptr [esi+4] + mov ecx,dword ptr [esi+8] + mov edx,dword ptr [esi+12] + rol eax,5 + xor edx,ebx + add eax,dword ptr [esi+16] + xor edx,ecx + add eax,0x6ed9eba1 + ror ebx,2 + add eax,dword ptr [esi+edi+0] + mov dword ptr [esi+4],ebx + add eax,edx + mov dword ptr [esi+16],eax + ; eax is still okay + ; move ecx to edx + ; move ebx to ecx + mov edx,ecx + mov ecx,ebx + mov ebx,dword ptr [esi+0] + rol eax,5 + xor edx,ebx + add eax,dword ptr [esi+12] + xor edx,ecx + add eax,0x6ed9eba1 + ror ebx,2 + add eax,dword ptr [esi+edi+4] + mov dword ptr [esi+0],ebx + add eax,edx + mov dword ptr [esi+12],eax + ; eax is still okay + ; move ecx to edx + ; move ebx to ecx + mov edx,ecx + mov ecx,ebx + mov ebx,dword ptr [esi+16] + rol eax,5 + xor edx,ebx + add eax,dword ptr [esi+8] + xor edx,ecx + add eax,0x6ed9eba1 + ror ebx,2 + add eax,dword ptr [esi+edi+8] + mov dword ptr [esi+16],ebx + add eax,edx + mov dword ptr [esi+8],eax + ; eax is still okay + ; move ecx to edx + ; move ebx to ecx + mov edx,ecx + mov ecx,ebx + mov ebx,dword ptr [esi+12] + rol eax,5 + xor edx,ebx + add eax,dword ptr [esi+4] + xor edx,ecx + add eax,0x6ed9eba1 + ror ebx,2 + add eax,dword ptr [esi+edi+12] + mov dword ptr [esi+12],ebx + add eax,edx + mov dword ptr [esi+4],eax + ; eax is still okay + ; move ecx to edx + ; move ebx to ecx + mov edx,ecx + mov ecx,ebx + mov ebx,dword ptr [esi+8] + rol eax,5 + xor edx,ebx + add eax,dword ptr [esi+0] + xor edx,ecx + add eax,0x6ed9eba1 + ror ebx,2 + add eax,dword ptr [esi+edi+16] + mov dword ptr [esi+8],ebx + add eax,edx + mov dword ptr [esi+0],eax + add edi,20 + cmp edi,240 + jne subround2 + + ; time it + rdtsc + mov dword ptr tstop,eax + mov dword ptr tstop+4,edx + } + + printf("took %lld clocks\n", tstop - tstart); +} + +#endif +#endif diff --git a/beecrypt/fips180opt.h b/beecrypt/fips180opt.h new file mode 100644 index 0000000..f2f495d --- /dev/null +++ b/beecrypt/fips180opt.h @@ -0,0 +1,52 @@ +/* + * fips180opt.h + * + * SHA-1 assembler-optimized routines, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _FIPS180OPT_H +#define _FIPS180OPT_H + +#include "beecrypt.h" +#include "fips180.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if WIN32 +#if __INTEL__ && __MWERKS__ +#define ASM_SHA1PROCESS +#endif +#endif + +#ifdef __GNUC__ +#if defined(i586) || defined(i686) +#define ASM_SHA1PROCESS +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/fips186.c b/beecrypt/fips186.c new file mode 100644 index 0000000..2911b35 --- /dev/null +++ b/beecrypt/fips186.c @@ -0,0 +1,209 @@ +/* + * fips186.c + * + * NIST FIPS 186 pseudo-random generator, code + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "fips186.h" +#include "mp32.h" +#include "mp32opt.h" + +#if HAVE_STDLIB_H +#include +#endif + +static uint32 fips186hinit[5] = { 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0, 0x67452301 }; + +const randomGenerator fips186prng = { "FIPS 186", sizeof(fips186Param), (const randomGeneratorSetup) fips186Setup, (const randomGeneratorSeed) fips186Seed, (const randomGeneratorNext) fips186Next, (const randomGeneratorCleanup) fips186Cleanup }; + +static int fips186init(register sha1Param* p) +{ + mp32copy(5, p->h, fips186hinit); + return 0; +} + +int fips186Setup(fips186Param* fp) +{ + if (fp) + { + const entropySource* es = entropySourceDefault(); + + #ifdef _REENTRANT + # if WIN32 + if (!(fp->lock = CreateMutex(NULL, FALSE, NULL))) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_init(&fp->lock, USYNC_THREAD, (void *) 0)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_init(&fp->lock, (pthread_mutexattr_t *) 0)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + if (es) + { + fp->digestsize = 0; + + return es->next(fp->state, FIPS186_STATE_SIZE); + } + } + return -1; +} + +int fips186Seed(fips186Param* fp, const uint32* data, int size) +{ + if (fp) + { + #ifdef _REENTRANT + # if WIN32 + if (WaitForSingleObject(fp->lock, INFINITE) != WAIT_OBJECT_0) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_lock(&fp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&fp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + if (data) + mp32addx(FIPS186_STATE_SIZE, fp->state, size, data); + #ifdef _REENTRANT + # if WIN32 + if (!ReleaseMutex(fp->lock)) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_unlock(&fp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_unlock(&fp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + return 0; + } + return -1; +} + +int fips186Next(fips186Param* fp, uint32* data, int size) +{ + if (fp) + { + #ifdef _REENTRANT + # if WIN32 + if (WaitForSingleObject(fp->lock, INFINITE) != WAIT_OBJECT_0) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_lock(&fp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&fp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + while (size > 0) + { + register uint32 copy; + + if (fp->digestsize == 0) + { + fips186init(&fp->param); + /* copy the 512 bits of state data into the sha1Param */ + mp32copy(FIPS186_STATE_SIZE, fp->param.data, fp->state); + /* process the data */ + sha1Process(&fp->param); + /* set state to state + digest + 1 mod 2^512 */ + mp32addx(FIPS186_STATE_SIZE, fp->state, 5, fp->param.h); + mp32addw(FIPS186_STATE_SIZE, fp->state, 1); + /* we now have 5 words of pseudo-random data */ + fp->digestsize = 5; + } + + copy = (size > fp->digestsize) ? fp->digestsize : size; + mp32copy(copy, data, fp->param.h + 5 - fp->digestsize); + fp->digestsize -= copy; + size -= copy; + data += copy; + } + #ifdef _REENTRANT + # if WIN32 + if (!ReleaseMutex(fp->lock)) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_unlock(&fp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_unlock(&fp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + return 0; + } + return -1; +} + +int fips186Cleanup(fips186Param* fp) +{ + if (fp) + { + #ifdef _REENTRANT + # if WIN32 + if (!CloseHandle(fp->lock)) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_destroy(&fp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_destroy(&fp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + return 0; + } + return -1; +} diff --git a/beecrypt/fips186.h b/beecrypt/fips186.h new file mode 100644 index 0000000..3d737c2 --- /dev/null +++ b/beecrypt/fips186.h @@ -0,0 +1,89 @@ +/* + * fips186.h + * + * FIPS186 pseudo-random generator, with SHA-1 as H function, header + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: 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 _FIPS186_H +#define _FIPS186_H + +#include "beecrypt.h" + +#ifdef _REENTRANT +# if WIN32 +# include +# else +# if HAVE_SYNCH_H +# include +# elif HAVE_PTHREAD_H +# include +# else +# error need locking mechanism +# endif +# endif +#endif + +#include "beecrypt.h" +#include "fips180.h" + +#define FIPS186_STATE_SIZE 16 + +typedef struct +{ + #ifdef _REENTRANT + # if WIN32 + HANDLE lock; + # else + # if HAVE_SYNCH_H + mutex_t lock; + # elif HAVE_PTHREAD_H + pthread_mutex_t lock; + # else + # error need locking mechanism + # endif + # endif + #endif + sha1Param param; + uint32 state[FIPS186_STATE_SIZE]; + int digestsize; +} fips186Param; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const randomGenerator fips186prng; + +BEEDLLAPI +int fips186Setup (fips186Param*); +BEEDLLAPI +int fips186Seed (fips186Param*, const uint32*, int); +BEEDLLAPI +int fips186Next (fips186Param*, uint32*, int); +BEEDLLAPI +int fips186Cleanup(fips186Param*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/gas/Makefile.am b/beecrypt/gas/Makefile.am new file mode 100644 index 0000000..829dda6 --- /dev/null +++ b/beecrypt/gas/Makefile.am @@ -0,0 +1,25 @@ +# +# Makefile.am's purpose is to add the GNU Assembler sources to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + +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 diff --git a/beecrypt/gas/Makefile.in b/beecrypt/gas/Makefile.in new file mode 100644 index 0000000..d16618b --- /dev/null +++ b/beecrypt/gas/Makefile.in @@ -0,0 +1,209 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# +# Makefile.am's purpose is to add the GNU Assembler sources to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +AS = @AS@ +CC = @CC@ +CPP = @CPP@ +DLLTOOL = @DLLTOOL@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +ac_cv_have_java = @ac_cv_have_java@ +ac_cv_have_javac = @ac_cv_have_javac@ + +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 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.gnu.h +CONFIG_CLEAN_FILES = +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu gas/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = gas + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# 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. +.NOEXPORT: diff --git a/beecrypt/gas/blowfishopt.i586.S b/beecrypt/gas/blowfishopt.i586.S new file mode 100644 index 0000000..dea6772 --- /dev/null +++ b/beecrypt/gas/blowfishopt.i586.S @@ -0,0 +1,176 @@ +/* + * blowfishopt.i586.S + * + * Assembler optimized blowfish routines for Intel Pentium processors + * + * Compile target is GNU Assembler + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 "config.gas.h" + + .file "blowfishopt.i586.S" + + .text + + .macro etworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear + xorl 0+\p(%esi),%ecx + roll $16,%ecx + movb %ch,%al + movb %cl,%bl + roll $16,%ecx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %ch,%al + movb %cl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%edx + xorl 4+\p(%esi),%edx + roll $16,%edx + movb %dh,%al + movb %dl,%bl + roll $16,%edx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %dh,%al + movb %dl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%ecx + .endm + + .macro dtworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear + xorl 4+\p(%esi),%ecx + roll $16,%ecx + movb %ch,%al + movb %cl,%bl + roll $16,%ecx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %ch,%al + movb %cl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%edx + xorl 0+\p(%esi),%edx + roll $16,%edx + movb %dh,%al + movb %dl,%bl + roll $16,%edx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %dh,%al + movb %dl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%ecx + .endm + +C_FUNCTION_BEGIN(blowfishEncrypt) + /* parameter one is the blowfish parameters; need to extract bp and set it up in esi */ + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%esi # esi now contains bp + movl 24(%esp),%edi # edi now contains src + + xorl %eax,%eax + xorl %ebx,%ebx + + movl 0(%edi),%ecx + movl 4(%edi),%edx + + bswap %ecx + bswap %edx + + etworounds p= 0 + etworounds p= 8 + etworounds p=16 + etworounds p=24 + etworounds p=32 + etworounds p=40 + etworounds p=48 + etworounds p=56 + + movl 20(%esp),%edi # edi now contains dst + xorl 64(%esi),%ecx + xorl 68(%esi),%edx + + bswap %ecx + bswap %edx + + movl %ecx,4(%edi) + movl %edx,0(%edi) + + xorl %eax,%eax + popl %ebx + popl %esi + popl %edi + ret +C_FUNCTION_END(blowfishEncrypt, .LblowfishEncrypt_size) + + +C_FUNCTION_BEGIN(blowfishDecrypt) + /* parameter one is the blowfish parameters; need to extract bp and set it up in ebp */ + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%esi # esi now contains bp + movl 24(%esp),%edi # edi now contains dst + + xorl %eax,%eax + xorl %ebx,%ebx + + movl 0(%edi),%ecx + movl 4(%edi),%edx + + bswap %ecx + bswap %edx + + dtworounds p=64 + dtworounds p=56 + dtworounds p=48 + dtworounds p=40 + dtworounds p=32 + dtworounds p=24 + dtworounds p=16 + dtworounds p= 8 + + movl 20(%esp),%edi # edi now contains dst + xorl 4(%esi),%ecx + xorl 0(%esi),%edx + + bswap %ecx + bswap %edx + + movl %ecx,4(%edi) + movl %edx,0(%edi) + + xorl %eax,%eax + + popl %ebx + popl %esi + popl %edi + ret +C_FUNCTION_END(blowfishDecrypt, .LblowfishDecrypt_size) diff --git a/beecrypt/gas/fips180opt.i586.S b/beecrypt/gas/fips180opt.i586.S new file mode 100644 index 0000000..aeeef51 --- /dev/null +++ b/beecrypt/gas/fips180opt.i586.S @@ -0,0 +1,291 @@ +/* + * fips180opt.i586.S + * + * Assembler optimized SHA-1 routines for Intel Pentium processors + * + * Compile target is GNU Assembler + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 "config.gas.h" + + .file "fips180opt.i586.S" + + .text + + .equ K00, 0x5a827999 + .equ K20, 0x6ed9eba1 + .equ K40, 0x8f1bbcdc + .equ K60, 0xca62c1d6 + + .equ PARAM_H, 0 + .equ PARAM_DATA, 20 + + .macro subround1 b c d e w + movl \c,%ecx + movl \b,%ebx + movl \d,%edx + roll $5,%eax + xorl %edx,%ecx + addl \e,%eax + andl %ebx,%ecx + addl $K00,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + xorl %edx,%ecx + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + + .macro subround2 b c d e w + movl \c,%ecx + movl \b,%ebx + roll $5,%eax + xorl %ebx,%ecx + addl \e,%eax + xorl \d,%ecx + addl $K20,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + + .macro subround3 b c d e w + movl \c,%ecx + roll $5,%eax + movl \b,%ebx + movl %ecx,%edx + addl \e,%eax + orl %ebx,%ecx + andl %ebx,%edx + andl \d,%ecx + addl $K40,%eax + orl %edx,%ecx + addl \w(%esi,%edi),%eax + rorl $2,%ebx + addl %ecx,%eax + movl %ebx,\b + movl %eax,\e + .endm + + .macro subround4 b c d e w + movl \c,%ecx + movl \b,%ebx + roll $5,%eax + xorl %ebx,%ecx + addl \e,%eax + xorl \d,%ecx + addl $K60,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + +C_FUNCTION_BEGIN(sha1Process) + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + + movl 20(%esp),%esi + subl $20,%esp + leal PARAM_DATA(%esi),%edi + movl %esp,%ebp + + movl $4,%ecx +.L0: + movl (%esi,%ecx,4),%edx + movl %edx,(%ebp,%ecx,4) + decl %ecx + jns .L0 + + movl $15,%ecx + xorl %eax,%eax + + .p2align 2 +.L1: + movl (%edi,%ecx,4),%edx + bswap %edx + mov %edx,(%edi,%ecx,4) + decl %ecx + jns .L1 + + leal PARAM_DATA(%esi),%edi + movl $16,%ecx + + .p2align 2 +.L2: + movl 52(%edi),%eax + movl 56(%edi),%ebx + xorl 32(%edi),%eax + xorl 36(%edi),%ebx + xorl 8(%edi),%eax + xorl 12(%edi),%ebx + xorl (%edi),%eax + xorl 4(%edi),%ebx + roll $1,%eax + roll $1,%ebx + movl %eax,64(%edi) + movl %ebx,68(%edi) + movl 60(%edi),%eax + movl 64(%edi),%ebx + xorl 40(%edi),%eax + xorl 44(%edi),%ebx + xorl 16(%edi),%eax + xorl 20(%edi),%ebx + xorl 8(%edi),%eax + xorl 12(%edi),%ebx + roll $1,%eax + roll $1,%ebx + movl %eax,72(%edi) + movl %ebx,76(%edi) + addl $16,%edi + decl %ecx + jnz .L2 + + movl $PARAM_DATA,%edi + + movl (%ebp),%eax +.L01_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 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L21_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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L41_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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L61_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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + /* addl $20,%edi */ + + movl $4,%ecx + + .p2align 2 +.L3: + movl (%ebp,%ecx,4),%eax + addl %eax,(%esi,%ecx,4) + decl %ecx + jns .L3 + + addl $20,%esp + popl %ebp + popl %ebx + popl %esi + popl %edi + ret +C_FUNCTION_END(sha1Process, .Lsha1Process_size) diff --git a/beecrypt/gas/mp32opt.arm.S b/beecrypt/gas/mp32opt.arm.S new file mode 100644 index 0000000..0f39168 --- /dev/null +++ b/beecrypt/gas/mp32opt.arm.S @@ -0,0 +1,174 @@ +/* + * mp32opt.arm.S + * + * Assembler optimized multiprecision integer routines for ARM processors + * + * Compile target is GNU Assembler + * + * Copyright (c) 2001 Virtual Unlimited B.V. + * + * Author: 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 "config.gas.h" + + .file "mp32opt.arm.S" + + .text + +/* ARM uses up to four registers for parameter passing */ + +#if 0 +C_FUNCTION_BEGIN(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: + ldr r4, [r1, #-4] + adds r4, r4, r2 + adc r2, r3, r3 + str r4, [r1, #-4]! + subs r0, r0, #1 + bne .Lmp32addw_loop + mov r0, r2 + ldmfd sp!, {r4, pc} +C_FUNCTION_END(mp32addw, .Lmp32addw_size) + + +C_FUNCTION_BEGIN(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: + ldr r4, [r1, #-4] + subs r4, r4, r2 + adc r2, r3, r3 + str r4, [r1, #-4]! + subs r0, r0, #1 + bne .Lmp32subw_loop + mov r0, r2 + ldmfd sp!, {r4, pc} +C_FUNCTION_END(mp32subw, .Lmp32subw_size) + + +C_FUNCTION_BEGIN(mp32add) + /* r0 is size, r1 = xdata, r2 = ydata */ + stmfd sp!, {r4, r5, lr} + /* copy cpsr to r5 and clear the carry bit */ + mrs r5, cpsr + bic r5, r5, #0x20000000 + /* adjust the addresses */ + add r1, r1, r0, asl #2 + add r2, r2, r0, asl #2 +.Lmp32add_loop: + /* restore the carry bit */ + msr cpsr_c, r5 + ldr r3, [r1, #-4]! + ldr r4, [r2, #-4]! + adcs r3, r3, r2 + str r3, [r1, #0] + /* save the carry bit */ + mrs r5, cpsr + subs r0, r0, #1 + bne .Lmp32add_loop + + /* restore the carry bit */ + msr cpsr_c, r5 + + /* set the result to the proper value */ + adc r0, r0, r0 + ldmfd sp!, {r4, r5, pc} +C_FUNCTION_END(mp32add, .Lmp32add_size) +#endif + + +C_FUNCTION_BEGIN(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: + 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 + /* return carry */ + mov r0, ip + ldmfd sp!, {r4, r5, pc} +C_FUNCTION_END(mp32setmul, .Lmp32setmul_size) + + +C_FUNCTION_BEGIN(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: + ldr r4, [r2, #-4]! + ldr r5, [r1, #-4] + mov r6, #0 + umlal ip, r6, r3, r4 + adds r5, r5, ip + adc ip, r6, #0 + str r5, [r1, #-4]! + subs r0, r0, #1 + bne .Lmp32addmul_loop + /* return carry */ + mov r0, ip + ldmfd sp!, {r4, r5, r6, pc} +C_FUNCTION_END(mp32addmul, .Lmp32addmul_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) + stmfd sp!, {r4, r5, r6, lr} + /* adjust the addresses */ + add r1, r1, r0, asl #2 + add r2, r2, r0, asl #2 + /* r3 is a zero register, ip is the carry */ + mov r3, #0 + mov ip, #0 +.Lmp32addsqrtrc_loop: + ldr r4, [r2, #-4]! + mov r6, #0 + umlal ip, r6, r4, r4 + ldr r5, [r1, #-4] /* lo word */ + ldr r4, [r1, #-8] /* hi word */ + adds r5, r5, ip + adcs r4, r4, r6 + str r5, [r1, #-4] + str r4, [r1, #-8]! + adc ip, r3, #0 /* set carry */ + subs r0, r0, #1 + bne .Lmp32addsqrtrc_loop + /* return carry */ + mov r0, ip + ldmfd sp!, {r4, r5, r6, pc} +C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size) +#endif diff --git a/beecrypt/gas/mp32opt.i386.S b/beecrypt/gas/mp32opt.i386.S new file mode 100644 index 0000000..2f3eef9 --- /dev/null +++ b/beecrypt/gas/mp32opt.i386.S @@ -0,0 +1,339 @@ +/* + * mp32opt.i386.S + * + * Assembler optimized multiprecision integer routines for Intel 386 and higher + * + * Compile target is GNU Assembler + * + * Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 "config.gas.h" + + .file "mp32opt.i386.S" + + .text + + +C_FUNCTION_BEGIN(mp32zero) + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + + xorl %eax,%eax + repz stosl + + popl %edi + ret +C_FUNCTION_END(mp32zero, .Lmp32zero_size) + + +C_FUNCTION_BEGIN(mp32fill) + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + movl 16(%esp),%eax + + repz stosl + + popl %edi + ret +C_FUNCTION_END(mp32fill, .Lmp32fill_size) + + +C_FUNCTION_BEGIN(mp32even) + mov 4(%esp),%ecx + mov 8(%esp),%eax + mov 4(%esp,%ecx,4),%eax + not %eax + and %eax,1 + ret +C_FUNCTION_END(mp32even, .Lmp32even_size) + + +C_FUNCTION_BEGIN(mp32odd) + mov 4(%esp),%ecx + mov 8(%esp),%eax + mov 4(%esp,%ecx,4),%eax + and %eax,1 + ret +C_FUNCTION_END(mp32odd, .Lmp32odd_size) + + +C_FUNCTION_BEGIN(mp32addw) + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + movl 16(%esp),%eax + + xorl %edx,%edx + leal -4(%edi,%ecx,4),%edi + addl %eax,(%edi) + decl %ecx + jz .Lmp32addw_skip + leal -4(%edi),%edi + + .align 4 +.Lmp32addw_loop: + adcl %edx,(%edi) + leal -4(%edi),%edi + decl %ecx + jnz .Lmp32addw_loop +.Lmp32addw_skip: + sbbl %eax,%eax + negl %eax + + popl %edi + ret +C_FUNCTION_END(mp32addw, .Lmp32addw_size) + + +C_FUNCTION_BEGIN(mp32subw) + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + movl 16(%esp),%eax + + xorl %edx,%edx + leal -4(%edi,%ecx,4),%edi + subl %eax,(%edi) + decl %ecx + jz .Lmp32subw_skip + leal -4(%edi),%edi + + .align 4 +.Lmp32subw_loop: + sbbl %edx,(%edi) + leal -4(%edi),%edi + decl %ecx + jnz .Lmp32subw_loop +.Lmp32subw_skip: + sbbl %eax,%eax + negl %eax + popl %edi + ret +C_FUNCTION_END(mp32subw, .Lmp32subw_size) + + +C_FUNCTION_BEGIN(mp32add) + pushl %edi + pushl %esi + + movl 12(%esp),%ecx + movl 16(%esp),%edi + movl 20(%esp),%esi + + xorl %edx,%edx + decl %ecx + + .align 4 +.Lmp32add_loop: + movl (%esi,%ecx,4),%eax + adcl %eax,(%edi,%ecx,4) + decl %ecx + jns .Lmp32add_loop + + sbbl %eax,%eax + negl %eax + + popl %esi + popl %edi + ret +C_FUNCTION_END(mp32add, .Lmp32add_size) + + +C_FUNCTION_BEGIN(mp32sub) + pushl %edi + pushl %esi + + movl 12(%esp),%ecx + movl 16(%esp),%edi + movl 20(%esp),%esi + + xorl %edx,%edx + decl %ecx + + .align 4 +.Lmp32sub_loop: + movl (%esi,%ecx,4),%eax + sbbl %eax,(%edi,%ecx,4) + decl %ecx + jns .Lmp32sub_loop + + sbbl %eax,%eax + negl %eax + popl %esi + popl %edi + ret +C_FUNCTION_END(mp32sub, .Lmp32sub_size) + + +C_FUNCTION_BEGIN(mp32divtwo) + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + + leal (%edi,%ecx,4),%edi + negl %ecx + clc + + .align 4 +.Lmp32divtwo_loop: + rcrl $1,(%edi,%ecx,4) + inc %ecx + jnz .Lmp32divtwo_loop + + popl %edi + ret +C_FUNCTION_END(mp32divtwo, .Lmp32divtwo_size) + + +C_FUNCTION_BEGIN(mp32multwo) + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + + clc + decl %ecx + + .align 4 +.Lmp32multwo_loop: + rcll $1,(%edi,%ecx,4) + decl %ecx + jns .Lmp32multwo_loop + + sbbl %eax,%eax + negl %eax + + popl %edi + ret +C_FUNCTION_END(mp32multwo, .Lmp32multwo_size) + + +C_FUNCTION_BEGIN(mp32setmul) + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + + movl 20(%esp),%ecx + movl 24(%esp),%edi + movl 28(%esp),%esi + movl 32(%esp),%ebp + + xorl %edx,%edx + decl %ecx + + .align 4 +.Lmp32setmul_loop: + movl %edx,%ebx + movl (%esi,%ecx,4),%eax + mull %ebp + addl %ebx,%eax + adcl $0,%edx + movl %eax,(%edi,%ecx,4) + decl %ecx + jns .Lmp32setmul_loop + + movl %edx,%eax + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret +C_FUNCTION_END(mp32setmul, .Lmp32setmul_size) + + +C_FUNCTION_BEGIN(mp32addmul) + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + + movl 20(%esp),%ecx + movl 24(%esp),%edi + movl 28(%esp),%esi + movl 32(%esp),%ebp + + xorl %edx,%edx + decl %ecx + + .align 4 +.Lmp32addmul_loop: + movl %edx,%ebx + movl (%esi,%ecx,4),%eax + mull %ebp + addl %ebx,%eax + adcl $0,%edx + addl (%edi,%ecx,4),%eax + adcl $0,%edx + movl %eax,(%edi,%ecx,4) + decl %ecx + jns .Lmp32addmul_loop + + movl %edx,%eax + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret +C_FUNCTION_END(mp32addmul, .Lmp32addmul_size) + + +C_FUNCTION_BEGIN(mp32addsqrtrc) + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%ecx + movl 20(%esp),%edi + movl 24(%esp),%esi + + xorl %ebx,%ebx + decl %ecx + + .align 4 +.Lmp32addsqrtrc_loop: + movl (%esi,%ecx,4),%eax + mull %eax + addl %ebx,%eax + adcl $0,%edx + addl %eax,4(%edi,%ecx,8) + adcl %edx,(%edi,%ecx,8) + sbbl %ebx,%ebx + negl %ebx + decl %ecx + jns .Lmp32addsqrtrc_loop + + movl %ebx,%eax + + popl %ebx + popl %esi + popl %edi + ret +C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size) diff --git a/beecrypt/gas/mp32opt.ia64.S b/beecrypt/gas/mp32opt.ia64.S new file mode 100644 index 0000000..87ff581 --- /dev/null +++ b/beecrypt/gas/mp32opt.ia64.S @@ -0,0 +1,260 @@ +/* + * mp32opt.ia64.S + * + * Assembler optimized multiprecision integer routines for ia64 (Intel Itanium) + * + * Compile target is GNU Assembler + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 + * + */ + +/* + * I will need to implement 64 bit multiprecision assembler-optimized routines + * before this platform can be tested adequately. The current 32 bit ones suffer + * from loading into integer registers, conversion to floating point, doing the xma + * and converting back to integer; 64 bit values can be loaded directly into + * floating point registers, which should shave off a lot of cycles. + */ + +#include "config.gas.h" + +#define saved_pfs r14 +#define saved_lc r15 + +#define size r16 +#define dst r17 +#define src r18 + + .file "mp32opt.ia64.S" + + .text + + .explicit + + .align 32 + .global mp32zero# + .proc mp32zero# + +mp32zero: + alloc saved_pfs = ar.pfs,2,0,0,0 + mov saved_lc = ar.lc + sub size = in0,r0,1;; + mov src = in1 + mov ar.lc = size;; +.L00: + st4 [src] = r0,4 + br.ctop.sptk .L00 + ;; + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 + .endp mp32zero# + + + .align 32 + .global mp32copy# + .proc mp32copy# + +mp32copy: + alloc saved_pfs = ar.pfs,3,5,0,8 + mov saved_lc = ar.lc + sub size = in0,r0,1 + mov dst = in1 + mov src = in2;; + mov ar.lc = size + mov ar.ec = 2 + mov pr.rot = (1 << 16);; +.L01: + (p17) st4 [dst] = r33,4 + (p16) ld4 r32 = [src],4;; + br.ctop.sptk .L01;; + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 + .endp mp32copy# + + + .if 0 + .align 32 + .global mp32z + .type mp32z,@function + +mp32z: + alloc r14 = ar.pfs,2,6,0,8 + mov r15 = ar.lc + sub r16= in0,r0,1 + mov r17 = in1 + mov r18 = in2;; + mov r8 = 1 + mov pr.rot = 1 << 16 + mov ar.ec = 2 + mov ar.lc = r16;; +.L02: + (p16) ld4 r32 = [r18],4 + (p18) cmp.eq p0,p32 = r34,r0 + (p33) mov r8 = r0 + (p33) br.exit + .endif + + + .align 32 + .global mp32add# + .proc mp32add# + +mp32add: + alloc r14 = ar.pfs,3,0,0,0 + mov r15 = ar.lc + # adjust size by -1 + sub r16 = in0,r0,1 + # clear carry + mov r8 = r0;; + # load addresses + shladd r17 = r16,2,in1 + shladd r18 = r16,2,in2 + # load loop count + mov ar.lc = r16;; +.L20: + ld4 r20 = [r18],-4 + ld4 r19 = [r17] + tbit.z p1,p2 = r8,32;; + (p1) add r8 = r19,r20 + (p2) add r8 = r19,r20,1;; + st4 [r17] = r8,-4 + br.cloop.sptk .L20;; + extr.u r8 = r8,32,1 + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + .endp mp32add# + + + .align 32 + .global mp32sub# + .proc mp32sub# + +mp32sub: + alloc r14 = ar.pfs,3,0,0,0 + mov r15 = ar.lc + # adjust size by -1 + sub r16 = in0,r0,1 + # clear carry + mov r8 = r0;; + # load addresses + shladd r17 = r16,2,in1 + shladd r18 = r16,2,in2 + # load loop count + mov ar.lc = r16;; +.L30: + ld4 r20 = [r18],-4 + ld4 r19 = [r17] + tbit.z p1,p2 = r8,32;; + (p1) sub r8 = r19,r20 + (p2) sub r8 = r19,r20,1;; + st4 [r17] = r8,-4 + br.cloop.sptk .L30;; + extr.u r8 = r8,32,1 + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + .endp mp32sub# + + + .if 0 + + .align 32 + .global mp32setmul# + .proc mp32setmul# + +mp32setmul: + alloc r14 = ar.pfs,4,0,0,0 + mov r15 = ar.lc + # load mul + setf.sig f96 = in3 + # adjust size by -1 + sub r16 = in0,r0,1 + # clear carry + mov r8 = r0;; + # adjust addresses + shladd r17 = r16,2,in1 + shladd r18 = r16,2,in2 + # load loop count + mov ar.lc = r16;; +.L40: + ld4 r19 = [r18],-4;; + setf.sig f98 = r8 + setf.sig f97 = r19;; + # multiplication can only be done in f registers, but we do have a multiply-add + xma.l f98 = f96,f97,f98;; + getf.sig r8 = f98;; + st4 [r17] = r8,-4 + shr.u r8 = r8,32 + br.cloop.sptk .L40;; + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + .endp mp32setmul# + + + .align 32 + .global mp32addmul# + .proc mp32addmul# + +mp32addmul: + alloc saved_pfs = ar.pfs,4,0,0,0 + mov saved_lc = ar.lc + # load mul + setf.sig f96 = in3 + # adjust size by -1 + sub size = in0,r0,1 + # clear carry + mov r8 = r0;; + # adjust addresses + shladd dst = size,2,in1 + shladd src = size,2,in2 + # load loop count + mov ar.lc = r16;; +.L50: + ld4 r19 = [dst] + ld4 r20 = [dst],-4;; + setf.sig f98 = r8 + setf.sig f97 = r20;; + # multiplication can only be done in f registers, but we do have a multiply-add + xma.l f98 = f96,f97,f98;; + getf.sig r8 = f98;; + add r8 = r8,r19;; + st4 [r17] = r8,-4 + shr.u r8 = r8,32 + br.cloop.sptk .L50;; + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + .endp mp32addmul# + + .endif + + + .if 0 + .align 16 + .global mp32addsqrtrc# + .proc mp32addsqrtrc# + +mp32addsqrtrc: + .endp mp32addsqrtrc# + .endif diff --git a/beecrypt/gas/mp32opt.powerpc.S b/beecrypt/gas/mp32opt.powerpc.S new file mode 100644 index 0000000..3e07e95 --- /dev/null +++ b/beecrypt/gas/mp32opt.powerpc.S @@ -0,0 +1,223 @@ +/* + * mp32opt.powerpc.S + * + * Assembler optimized multiprecision integer routines for PowerPC + * + * Compile target is GNU Assembler + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 "config.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) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + li r0,0 + lwzu r6,-4(r4) + addc r6,r6,r5 + stw r6,0(r4) + bdz .Lmp32addw_skip +.Lmp32addw_loop: + lwzu r6,-4(r4) + adde r6,r0,r6 + stw r6,0(r4) + bdnz .Lmp32addw_loop +.Lmp32addw_skip: + /* return the carry */ + addze r3,r0 + blr +C_FUNCTION_END(mp32addw, .Lmp32addw_size) + + +C_FUNCTION_BEGIN(mp32subw) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + li r0,0 + lwz r6,-4(r4) + subfc r6,r5,r6 + stwu r6,-4(r4) + bdz .Lmp32subw_skip +.Lmp32subw_loop: + lwz r6,-4(r4) + subfe r6,r0,r6 + stwu r6, -4(r4) + bdnz .Lmp32subw_loop +.Lmp32subw_skip: + /* return the carry */ + subfe r3,r0,r0 + neg r3,r3 + blr +C_FUNCTION_END(mp32subw, .Lmp32subw_size) + + +C_FUNCTION_BEGIN(mp32add) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + add r5,r5,r0 + li r0,0 + lwz r6,-4(r4) + lwzu r7,-4(r5) + addc r6,r7,r6 + stwu r6,-4(r4) + bdz .Lmp32add_skip +.Lmp32add_loop: + lwz r6,-4(r4) + lwzu r7,-4(r5) + adde r6,r7,r6 + stwu r6,-4(r4) + bdnz .Lmp32add_loop +.Lmp32add_skip: + /* return the carry */ + addze r3,r0 + blr +C_FUNCTION_END(mp32add, .Lmp32add_size) + + +C_FUNCTION_BEGIN(mp32sub) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + add r5,r5,r0 + li r0,0 + lwz r6,-4(r4) + lwzu r7,-4(r5) + subfc r6,r7,r6 + stwu r6,-4(r4) + bdz .Lmp32sub_skip +.Lmp32sub_loop: + lwz r6,-4(r4) + lwzu r7,-4(r5) + subfe r6,r7,r6 + stwu r6,-4(r4) + bdnz .Lmp32sub_loop +.Lmp32sub_skip: + /* return the carry */ + subfe r3,r0,r0 + neg r3,r3 + blr +C_FUNCTION_END(mp32sub, .Lmp32sub_size) + + +C_FUNCTION_BEGIN(mp32multwo) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + li r0,0 + lwz r6,-4(r4) + addc r6,r6,r6 + stwu r6,-4(r4) + bdz .Lmp32multwo_skip +.Lmp32multwo_loop: + lwz r6,-4(r4) + adde r6,r6,r6 + stwu r6,-4(r4) + bdnz .Lmp32multwo_loop +.Lmp32multwo_skip: + /* return the carry */ + addze r3,r0 + blr +C_FUNCTION_END(mp32multwo, .Lmp32multwo_size) + + +C_FUNCTION_BEGIN(mp32setmul) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + add r5,r5,r0 + li r3,0 +.Lmp32setmul_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 + blr +C_FUNCTION_END(mp32setmul, .Lmp32setmul_size) + + +C_FUNCTION_BEGIN(mp32addmul) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + add r5,r5,r0 + li r3,0 +.Lmp32addmul_loop: + lwzu r8,-4(r5) + lwzu r7,-4(r4) + mullw r9,r8,r6 + addc r9,r9,r3 + mulhwu r10,r8,r6 + addze r3,r10 + addc r9,r9,r7 + addze r3,r3 + stw r9,0(r4) + bdnz .Lmp32addmul_loop + blr +C_FUNCTION_END(mp32addmul, .Lmp32addmul_size) + + +C_FUNCTION_BEGIN(mp32addsqrtrc) + mtctr r3 + slwi r0,r3,2 + add r4,r4,r0 + add r5,r5,r0 + add r4,r4,r0 + li r3,0 +.Lmp32addsqrtrc_loop: + lwzu r0,-4(r5) + lwz r6,-8(r4) + lwz r7,-4(r4) + mullw r9,r0,r0 + addc r9,r9,r3 + mulhwu r8,r0,r0 + addze r8,r8 + li r3,0 + addc r7,r7,r9 + adde r6,r6,r8 + addze r3,r3 + stw r7,-4(r4) + stwu r6,-8(r4) + bdnz .Lmp32addsqrtrc_loop + blr +C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size) diff --git a/beecrypt/gas/mp32opt.sparcv8.S b/beecrypt/gas/mp32opt.sparcv8.S new file mode 100644 index 0000000..aa9660d --- /dev/null +++ b/beecrypt/gas/mp32opt.sparcv8.S @@ -0,0 +1,93 @@ +/* + * mp32opt.sparcv8.S + * + * Assembler optimized multiprecision integer routines for Sparc v8 + * + * Compile target is GNU Assembler, Sun Solaris Assembler + * + * Copyright (c) 2001 Virtual Unlimited B.V. + * + * Author: 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 "config.gas.h" + + .file "mp32opt.sparcv8.S" + + .text + +C_FUNCTION_BEGIN(mp32setmul) + sll %o0,2,%g1 + dec 4,%o2 + clr %o0 +.Lmp32setmul_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 + st %g2,[%o1+%g1] + retl + nop +C_FUNCTION_END(mp32setmul, .Lmp32setmul_size) + + +C_FUNCTION_BEGIN(mp32addmul) + sll %o0,2,%g1 + mov %o1,%o4 + dec 4,%o1 + dec 4,%o2 + clr %o0 +.Lmp32addmul_loop: + ld [%o2+%g1],%g2 + ld [%o1+%g1],%g3 + umul %o3,%g2,%g2 + rd %y,%g4 + addcc %o0,%g2,%g2 + addx %g0,%g4,%g4 + addcc %g2,%g3,%g2 + addx %g0,%g4,%o0 + deccc 4,%g1 + bnz .Lmp32addmul_loop + st %g2,[%o4+%g1] + retl + nop +C_FUNCTION_END(mp32addmul, .Lmp32addmul_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 diff --git a/beecrypt/gas/mp32opt.sparcv9.S b/beecrypt/gas/mp32opt.sparcv9.S new file mode 100644 index 0000000..1af4c39 --- /dev/null +++ b/beecrypt/gas/mp32opt.sparcv9.S @@ -0,0 +1,212 @@ +/* + * mp32opt.sparcv9.S + * + * Assembler optimized multiprecision integer routines for UltraSparc (64 bits instructions, will run on 32 bit OS) + * + * Compile target is GNU Assembler, Sun Solaris Assembler + * + * Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 "config.gas.h" + + .file "mp32opt.sparcv9.S" + + .text + +C_FUNCTION_BEGIN(mp32addw) + + .register %g2,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + clr %o0 + lduw [%o1+%g1],%g2 + addcc %g2,%o2,%g2 + stw %g2,[%o1+%g1] + brz,pn %g1,.Lmp32addw_skip + dec 4,%g1 +.Lmp32addw_loop: + lduw [%o1+%g1],%g2 + addccc %g2,%g0,%g2 + stw %g2,[%o1+%g1] + brnz,pt %g1,.Lmp32addw_loop + dec 4,%g1 +.Lmp32addw_skip: + retl + movcs %icc,1,%o0 +.Lend_addw: +C_FUNCTION_END(mp32addw, .Lmp32addw_size) + + +C_FUNCTION_BEGIN(mp32subw) + + .register %g2,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + clr %o0 + lduw [%o1+%g1],%g2 + subcc %g2,%o2,%g2 + stw %g2,[%o1+%g1] + brz,pn %g1,.Lmp32subw_skip + dec 4,%g1 +.Lmp32subw_loop: + lduw [%o1+%g1],%g2 + subccc %g2,%g0,%g2 + stw %g2,[%o1+%g1] + brnz,pt %g1,.Lmp32subw_loop + dec 4,%g1 +.Lmp32subw_skip: + retl + movcs %icc,1,%o0 +C_FUNCTION_END(mp32subw, .Lmp32subw_size) + + +C_FUNCTION_BEGIN(mp32add) + + .register %g2,#scratch + .register %g3,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + addcc %g0,%g0,%o0 +.Lmp32add_loop: + lduw [%o1+%g1],%g2 + lduw [%o2+%g1],%g3 + addccc %g2,%g3,%g4 + stw %g4,[%o1+%g1] + brnz,pt %g1,.Lmp32add_loop + dec 4,%g1 + retl + movcs %icc,1,%o0 +C_FUNCTION_END(mp32add, .Lmp32add_size) + + +C_FUNCTION_BEGIN(mp32sub) + + .register %g2,#scratch + .register %g3,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + addcc %g0,%g0,%o0 +.Lmp32sub_loop: + lduw [%o1+%g1],%g2 + lduw [%o2+%g1],%g3 + subccc %g2,%g3,%g4 + stw %g4,[%o1+%g1] + brnz,pt %g1,.Lmp32sub_loop + dec 4,%g1 + retl + movcs %icc,1,%o0 +C_FUNCTION_END(mp32sub, .Lmp32sub_size) + + +C_FUNCTION_BEGIN(mp32multwo) + + .register %g2,#scratch + .register %g3,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + addcc %g0,%g0,%o0 +.Lmp32multwo_loop: + lduw [%o1+%g1],%g2 + addccc %g2,%g2,%g3 + stw %g3,[%o1+%g1] + brnz,pt %g1,.Lmp32multwo_loop + dec 4,%g1 + retl + movcs %icc,1,%o0 +C_FUNCTION_END(mp32multwo, .Lmp32multwo_size) + + +C_FUNCTION_BEGIN(mp32setmul) + + .register %g2,#scratch + .register %g3,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + clr %o0 +.Lmp32setmul_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 + dec 4,%g1 + retl + srlx %o0,32,%o0 +C_FUNCTION_END(mp32setmul, .Lmp32setmul_size) + + +C_FUNCTION_BEGIN(mp32addmul) + + .register %g2,#scratch + .register %g3,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + clr %o0 +.Lmp32addmul_loop: + lduw [%o2+%g1],%g2 + lduw [%o1+%g1],%g4 + srlx %o0,32,%o0 + mulx %o3,%g2,%g3 + add %o0,%g3,%o0 + add %o0,%g4,%o0 + stw %o0,[%o1+%g1] + brnz,pt %g1,.Lmp32addmul_loop + dec 4,%g1 + retl + srlx %o0,32,%o0 +C_FUNCTION_END(mp32addmul, .Lmp32addmul_size) + + +C_FUNCTION_BEGIN(mp32addsqrtrc) + + .register %g2,#scratch + .register %g3,#scratch + + sll %o0,2,%g1 + dec 4,%g1 + add %o1,%g1,%o1 + add %o1,%g1,%o1 + clr %o0 +.Lmp32addsqrtrc_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 + mulx %g2,%g2,%g2 + add %o0,%g4,%g3 + clr %o0 + add %g3,%g2,%g3 + cmp %g4,%g3 + movgu %xcc,1,%o0 + stx %g3,[%o1] + sub %o1,8,%o1 + brnz,pt %g1,.Lmp32addsqrtrc_loop + dec 4,%g1 + retl + nop +C_FUNCTION_END(mp32addsqrtrc, .Lmp32addsqrtrc_size) diff --git a/beecrypt/gas/mp64opt.ia64.S b/beecrypt/gas/mp64opt.ia64.S new file mode 100644 index 0000000..5be6911 --- /dev/null +++ b/beecrypt/gas/mp64opt.ia64.S @@ -0,0 +1,322 @@ +/* + * mp64opt.ia64.S + * + * Assembler optimized multiprecision integer routines for ia64 (Intel Itanium) + * + * Compile target is GNU Assembler + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 "config.gas.h" + +#define saved_pfs r14 +#define saved_lc r15 + +#define size r16 +#define dst r17 +#define src r18 +#define alt r19 + + .text + + .explicit + +/* functions to add, in order of priority: + * mp64addsqrtrc + * mp64neg -> can vectorize + * mp64multwo -> can vectorize + * mp32divtwo -> .. + * mp64fill -> easy + * mp64z -> vectorizable with br.wtop + * mp64nz -> vectorizable with br.wtop + * mp64eq -> .. + * mp64eqx -> .. + * mp64ne -> .. + * mp64nex -> .. + * mp64gt -> .. + * mp64gtx -> .. + * mp64lt -> .. + * mp64ltx -> .. + * mp64ge -> substitute with mp64lt with swap of parameters + * mp64gex -> .. mp64ltx + * mp64le -> .. mp64gt + * mp64lex -> .. mp64gtx + * mp64isone -> vectorizable with br.wtop + * mp64istwo -> .. + * mp64leone -> .. + * mp64size -> .. + +/* mp64zero works */ +C_FUNCTION_BEGIN(mp64zero) + alloc saved_pfs = ar.pfs,2,0,0,0 + mov saved_lc = ar.lc + sub size = in0,r0,1;; + mov src = in1 + mov ar.lc = size;; + +.Lmp64zero_loop: + st8 [src] = r0,8 + br.ctop.sptk .Lmp64zero_loop;; + + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 +C_FUNCTION_END(mp64zero) + + +/* mp64copy works */ +C_FUNCTION_BEGIN(mp64copy) + alloc saved_pfs = ar.pfs,3,5,0,8 + mov saved_lc = ar.lc + sub size = in0,r0,1;; + mov dst = in1 + mov src = in2 + /* prepare loop */ + mov ar.lc = size + mov ar.ec = 2 + mov pr.rot = (1 << 16);; + +.Lmp64copy_loop: + (p17) st8 [dst] = r33,-8 + (p16) ld8 r32 = [src],-8;; + br.ctop.sptk .Lmp64copy_loop;; + + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 +C_FUNCTION_END(mp64copy) + + +#if 0 +/* mp64z is in development */ +C_FUNCTION_BEGIN(mp64z) + alloc saved_pfs = ar.pfs,2,6,0,8 + mov saved_lc = ar.lc + sub size = in0,r0,1;; + + mov ret0 = 1 + mov src = in1 + + mov ar.lc = size + mov ar.ec = 2 + mov pr.rot = ((1 << 16) | (1 << 20));; + +.Lmp64z_loop: + (p16) ld8 r32 = [src],8 + (p17) cmp.ne p1,p0 = r33,r0 + (p1) br.exit.dpnt .Lmp64z_exit;; + br.ctop.dptk .Lmp64z_loop;; +.Lmp64z_exit: + (p1) mov ret0 = r0 + + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 +C_FUNCTION_END(mp64z) +#endif + + +/* mp64add works */ +C_FUNCTION_BEGIN(mp64add) + alloc saved_pfs = ar.pfs,3,5,0,8 + mov saved_lc = ar.lc + sub size = in0,r0,1;; + + /* adjust addresses */ + shladd dst = size,3,in1 + shladd src = size,3,in2 + shladd alt = size,3,in1 + + /* prepare modulo-scheduled loop */ + mov ar.lc = size + mov ar.ec = 3 + mov pr.rot = ((1 << 16) | (1 << 19));; + +.Lmp64add_loop: + (p16) ld8 r32 = [src],-8 + (p16) ld8 r35 = [alt],-8 + (p20) add r36 = r33,r36 /* no carry add */ + (p22) add r36 = r33,r36,1 /* carry add */ + ;; + (p20) cmp.leu p19,p21 = r33,r36 /* no previous carry */ + (p22) cmp.ltu p19,p21 = r33,r36 /* previous carry */ + (p18) st8 [dst] = r37,-8 + br.ctop.dptk .Lmp64add_loop;; + + /* return carry */ + (p21) add ret0 = r0,r0 + (p23) add ret0 = r0,r0,1 + ;; + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 +C_FUNCTION_END(mp64add) + + +/* mp64sub is in development */ +C_FUNCTION_BEGIN(mp64sub) + alloc saved_pfs = ar.pfs,3,5,0,8 + mov saved_lc = ar.lc + sub size = in0,r0,1;; + + /* adjust addresses */ + shladd dst = size,3,in1 + shladd src = size,3,in2 + shladd alt = size,3,in1 + + /* prepare modulo-scheduled loop */ + mov ar.lc = size + mov ar.ec = 3 + mov pr.rot = ((1 << 16) | (1 << 19));; + +.Lmp64sub_loop: + (p16) ld8 r32 = [src],-8 + (p16) ld8 r35 = [alt],-8 + (p20) sub r36 = r33,r36 /* no carry sub */ + (p22) sub r36 = r33,r36,1 /* carry sub */ + ;; + (p20) cmp.geu p19,p21 = r33,r36 /* no previous carry */ + (p22) cmp.gtu p19,p21 = r33,r36 /* previous carry */ + (p18) st8 [dst] = r37,-8 + br.ctop.dptk .Lmp64sub_loop;; + + /* return carry */ + (p21) add ret0 = r0,r0 + (p23) add ret0 = r0,r0,1 + ;; + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 +C_FUNCTION_END(mp64sub) + + +/* mp64setmul works */ +C_FUNCTION_BEGIN(mp64setmul) + alloc saved_pfs = ar.pfs,4,4,0,8 + mov saved_lc = ar.lc + + setf.sig f6 = in3 /* the multiplier */ + setf.sig f7 = r0 /* the carry */ + sub size = in0,r0,1;; + + /* adjust addresses */ + shladd dst = size,3,in1 + shladd src = size,3,in2 + + /* prepare modulo-scheduled loop */ + mov ar.lc = size + mov ar.ec = 3 + mov pr.rot = (1 << 16);; + +.Lmp64setmul_loop: + (p16) ldf8 f36 = [src],-8 + (p18) stf8 [dst] = f33,-8 + (p17) xma.lu f32 = f6,f37,f7 + (p17) xma.hu f7 = f6,f37,f7;; + br.ctop.dptk .Lmp64setmul_loop;; + + /* return carry */ + getf.sig ret0 = f7;; + + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 +C_FUNCTION_END(mp64setmul) + + +/* mp64addmul needs fixing */ +C_FUNCTION_BEGIN(mp64addmul) + alloc saved_pfs = ar.pfs,4,12,0,16 + mov saved_lc = ar.lc + + sub size = in0,r0,1;; + setf.sig f6 = in3 /* the multiplier */ + + /* adjust addresses */ + shladd dst = size,3,in1 + shladd src = size,3,in2 + shladd alt = size,3,in1;; + + /* prepare the rotate-in carry */ + mov r32 = r0 + + /* prepare modulo-scheduled loop */ + mov ar.lc = size + mov ar.ec = 5 + mov pr.rot = ((1 << 16) | (1 << 21)); + +.Lmp64addmul_loop: + (p18) getf.sig r33 = f34 /* hi 64 bit word */ + (p24) add r38 = r35,r38 + (p17) xma.lu f37 = f6,f41,f45 + (p18) getf.sig r37 = f38 /* lo 64 bit word */ + (p26) add r38 = r35,r38,1 + (p17) xma.hu f33 = f6,f41,f45 + (p16) ldf8 f40 = [src],-8 + (p16) ldf8 f44 = [alt],-8 + ;; + /* set carry from this operation */ + (p24) cmp.leu p23,p25 = r35,r38 + (p26) cmp.ltu p23,p25 = r35,r38 + (p20) st8 [dst] = r39,-8 + br.ctop.dptk .Lmp64addmul_loop;; + + /* return carry */ + (p25) add ret0 = r36,r0 + (p27) add ret0 = r36,r0,1 + + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 +C_FUNCTION_END(mp64addmul) + +/* mp64addsqrtrc will be a little more challenging */ + +/* the primary loop will look like this: + +.Lmp64addsqrtrc_loop: + /* stage 1 */ + (p16) ldf8 to_square + (p16) ld8 lo_to_add + (p16) ld8 hi_to_add + /* stage 2 */ + (p17) xma.lu to_square,to_square,carry + (p17) xma.hu to_square,to_square,carry + /* stage 3 */ + (p18) getf lo xma + (p18) getf hi xma + /* stage 4 */ + (p?) add lo no carry + (p?) add lo carry + /* stage 5 */ + (p?+1) add hi no carry + (p?+1) add hi carry + ;; + /* also stage 4 */ + (p?) cmp lo for carry + (p?) cmp lo for carry + /* also stage 5 */ + (p?+1) cmp hi for carry + (p?+1) cmp hi for carry + st8 lo + st8 hi + br.ctop +*/ diff --git a/beecrypt/gnu/blowfishopt.gas.i586.S b/beecrypt/gnu/blowfishopt.gas.i586.S new file mode 100644 index 0000000..02a00a8 --- /dev/null +++ b/beecrypt/gnu/blowfishopt.gas.i586.S @@ -0,0 +1,200 @@ +/* + * blowfishopt.gas.i586.S + * + * Assembler optimized blowfish routines for Intel Pentium processors + * + * Compile target is GNU Assembler + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 + * + */ + + .file "blowfishopt.gas.i586.S" + + .text + + .macro etworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear + xorl 0+\p(%esi),%ecx + roll $16,%ecx + movb %ch,%al + movb %cl,%bl + roll $16,%ecx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %ch,%al + movb %cl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%edx + xorl 4+\p(%esi),%edx + roll $16,%edx + movb %dh,%al + movb %dl,%bl + roll $16,%edx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %dh,%al + movb %dl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%ecx + .endm + + .macro dtworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear + xorl 4+\p(%esi),%ecx + roll $16,%ecx + movb %ch,%al + movb %cl,%bl + roll $16,%ecx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %ch,%al + movb %cl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%edx + xorl 0+\p(%esi),%edx + roll $16,%edx + movb %dh,%al + movb %dl,%bl + roll $16,%edx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %dh,%al + movb %dl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%ecx + .endm + + .align 4 +#if defined(CYGWIN) + .globl _blowfishEncrypt + .def _blowfishEncrypt + .scl 2 + .type 32 + .endef + +_blowfishEncrypt: +#else + .global blowfishEncrypt + .type blowfishEncrypt,@function + +blowfishEncrypt: +#endif + /* parameter one is the blowfish parameters; need to extract bp and set it up in esi */ + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%esi # esi now contains bp + movl 24(%esp),%edi # edi now contains src + + xorl %eax,%eax + xorl %ebx,%ebx + + movl 0(%edi),%ecx + movl 4(%edi),%edx + + bswap %ecx + bswap %edx + + etworounds p= 0 + etworounds p= 8 + etworounds p=16 + etworounds p=24 + etworounds p=32 + etworounds p=40 + etworounds p=48 + etworounds p=56 + + movl 20(%esp),%edi # edi now contains dst + xorl 64(%esi),%ecx + xorl 68(%esi),%edx + + bswap %ecx + bswap %edx + + movl %ecx,4(%edi) + movl %edx,0(%edi) + + xorl %eax,%eax + popl %ebx + popl %esi + popl %edi + ret + + .align 4 +#if defined(CYGWIN) + .globl _blowfishDecrypt + .def _blowfishDecrypt + .scl 2 + .type 32 + .endef + +_blowfishDecrypt: +#else + .global blowfishDecrypt + .type blowfishDecrypt,@function + +blowfishDecrypt: +#endif + /* parameter one is the blowfish parameters; need to extract bp and set it up in ebp */ + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%esi # esi now contains bp + movl 24(%esp),%edi # edi now contains dst + + xorl %eax,%eax + xorl %ebx,%ebx + + movl 0(%edi),%ecx + movl 4(%edi),%edx + + bswap %ecx + bswap %edx + + dtworounds p=64 + dtworounds p=56 + dtworounds p=48 + dtworounds p=40 + dtworounds p=32 + dtworounds p=24 + dtworounds p=16 + dtworounds p= 8 + + movl 20(%esp),%edi # edi now contains dst + xorl 4(%esi),%ecx + xorl 0(%esi),%edx + + bswap %ecx + bswap %edx + + movl %ecx,4(%edi) + movl %edx,0(%edi) + + xorl %eax,%eax + + popl %ebx + popl %esi + popl %edi + ret + diff --git a/beecrypt/gnu/blowfishopt.gas.i586.s b/beecrypt/gnu/blowfishopt.gas.i586.s new file mode 100644 index 0000000..39fa552 --- /dev/null +++ b/beecrypt/gnu/blowfishopt.gas.i586.s @@ -0,0 +1,179 @@ +# +# blowfishopt.gas.i586.s +# +# Assembler optimized blowfish routines for Intel Pentium processors +# +# Compile target is GNU Assembler +# +# Copyright (c) 2000 Virtual Unlimited B.V. +# +# Author: 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 +# + + .file "blowfishopt.gas.i586.s" + + .text + + .macro etworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear + xorl 0+\p(%esi),%ecx + roll $16,%ecx + movb %ch,%al + movb %cl,%bl + roll $16,%ecx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %ch,%al + movb %cl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%edx + xorl 4+\p(%esi),%edx + roll $16,%edx + movb %dh,%al + movb %dl,%bl + roll $16,%edx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %dh,%al + movb %dl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%ecx + .endm + + .macro dtworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear + xorl 4+\p(%esi),%ecx + roll $16,%ecx + movb %ch,%al + movb %cl,%bl + roll $16,%ecx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %ch,%al + movb %cl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%edx + xorl 0+\p(%esi),%edx + roll $16,%edx + movb %dh,%al + movb %dl,%bl + roll $16,%edx + movl 0x000+72(%esi,%eax,4),%edi + addl 0x400+72(%esi,%ebx,4),%edi + movb %dh,%al + movb %dl,%bl + xorl 0x800+72(%esi,%eax,4),%edi + addl 0xC00+72(%esi,%ebx,4),%edi + xorl %edi,%ecx + .endm + + .align 4 + .globl blowfishEncrypt + .type blowfishEncrypt,@function + +blowfishEncrypt: + # parameter one is the blowfish parameters; need to extract bp and set it up in esi + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%esi # esi now contains bp + movl 20(%esp),%edi # edi now contains bl + + xorl %eax,%eax + xorl %ebx,%ebx + + movl 0(%edi),%ecx + movl 4(%edi),%edx + + bswap %ecx + bswap %edx + + etworounds p= 0 + etworounds p= 8 + etworounds p=16 + etworounds p=24 + etworounds p=32 + etworounds p=40 + etworounds p=48 + etworounds p=56 + + movl 20(%esp),%edi + xorl 64(%esi),%ecx + xorl 68(%esi),%edx + + bswap %ecx + bswap %edx + + movl %ecx,4(%edi) + movl %edx,0(%edi) + + xorl %eax,%eax + popl %ebx + popl %esi + popl %edi + ret + + .align 4 + .globl blowfishDecrypt + .type blowfishDecrypt,@function + +blowfishDecrypt: + # parameter one is the blowfish parameters; need to extract bp and set it up in ebp + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%esi # esi now contains bp + movl 20(%esp),%edi # edi now contains bl + + xorl %eax,%eax + xorl %ebx,%ebx + + movl 0(%edi),%ecx + movl 4(%edi),%edx + + bswap %ecx + bswap %edx + + dtworounds p=64 + dtworounds p=56 + dtworounds p=48 + dtworounds p=40 + dtworounds p=32 + dtworounds p=24 + dtworounds p=16 + dtworounds p= 8 + + movl 20(%esp),%edi + xorl 4(%esi),%ecx + xorl 0(%esi),%edx + + bswap %ecx + bswap %edx + + movl %ecx,4(%edi) + movl %edx,0(%edi) + + xorl %eax,%eax + + popl %ebx + popl %esi + popl %edi + ret + diff --git a/beecrypt/gnu/config.gas.h b/beecrypt/gnu/config.gas.h new file mode 100644 index 0000000..5903708 --- /dev/null +++ b/beecrypt/gnu/config.gas.h @@ -0,0 +1,49 @@ +#ifndef _CONFIG_GAS_H +#define _CONFIG_GAS_H + +#include + +#ifndef C_FUNCTION_NAME +# if LEADING_UNDERSCORE +# ifdef __STDC__ +# define C_FUNCTION_NAME(name) _##name +# else +# define C_FUNCTION_NAME(name) _/**/name +# endif +# else +# define C_FUNCTION_NAME(name) name +# endif +#endif + +#if defined(alpha) +# define ALIGNMENT 5 +#elif defined(i386) || defined(i486) || defined(i586) || defined(i686) +# define ALIGNMENT 8 +#elif defined(ia64) +# define ALIGNMENT 32 +#elif defined(powerpc) +# define ALIGNMENT 8 +#elif defined(sparcv8plus) || defined(sparcv9) +# define ALIGNMENT 8 +#else +# define ALIGNMENT 8 +#endif + +#if CYGWIN +# define C_FUNCTION(name) \ + .align ALIGNMENT; \ + .globl C_FUNCTION_NAME(name); \ + .def C_FUNCTION_NAME(name); \ + .scl 2; \ + .type 32; \ + .endef; \ +C_FUNCTION_NAME(name): +#else +# define C_FUNCTION(name) \ + .align ALIGNMENT; \ + .global C_FUNCTION_NAME(name); \ + .type C_FUNCTION_NAME(name),@function; \ +C_FUNCTION_NAME(name): +#endif + +#endif diff --git a/beecrypt/gnu/config.gnu.h.in b/beecrypt/gnu/config.gnu.h.in new file mode 100644 index 0000000..a99b320 --- /dev/null +++ b/beecrypt/gnu/config.gnu.h.in @@ -0,0 +1,175 @@ +/* + * config.gnu.h.in + * + * Autoconf config.gnu.h template + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 _CONFIG_GNU_H +#define _CONFIG_GNU_H + +#ifndef _REENTRANT +#define _REENTRANT +#endif + +#ifndef __cplusplus +#undef inline +#endif + +#define AIX 0 +#define BEOS 0 +#define FREEBSD 0 +#define HPUX 0 +#define LINUX 0 +#define MACOSX 0 +#define OPENBSD 0 +#define SOLARIS 0 +#define WIN32 0 + +#if LINUX +#define _LIBC_REENTRANT +#endif + +#define WORDS_BIGENDIAN 0 + +#define HAVE_ERRNO_H 0 +#define HAVE_STRING_H 0 +#define HAVE_STDLIB_H 0 +#define HAVE_CTYPE_H 0 +#define HAVE_UNISTD_H 0 +#define HAVE_FCNTL_H 0 +#define HAVE_TIME_H 0 + +#define HAVE_SYS_TYPES_H 0 +#define HAVE_SYS_STAT_H 0 +#define HAVE_SYS_TIME_H 0 + +#define HAVE_THREAD_H 0 +#define HAVE_SYNCH_H 0 +#define HAVE_PTHREAD_H 0 +#define HAVE_SEMAPHORE_H 0 + +#define HAVE_TERMIO_H 0 +#define HAVE_SYS_AUDIOIO_H 0 +#define HAVE_SYS_IOCTL_H 0 +#define HAVE_SYS_SOUNDCARD_H 0 + +#define HAVE_GETTIMEOFDAY 0 +#define HAVE_GETHRTIME 0 + +#define HAVE_DEV_TTY 0 +#define HAVE_DEV_AUDIO 0 +#define HAVE_DEV_DSP 0 +#define HAVE_DEV_RANDOM 0 + +#define SIZEOF_CHAR 0 +#define SIZEOF_UNSIGNED_CHAR 0 +#define SIZEOF_SHORT 0 +#define SIZEOF_UNSIGNED_SHORT 0 +#define SIZEOF_INT 0 +#define SIZEOF_UNSIGNED_INT 0 +#define SIZEOF_LONG 0 +#define SIZEOF_UNSIGNED_LONG 0 +#define SIZEOF_LONG_LONG 0 +#define SIZEOF_UNSIGNED_LONG_LONG 0 + +#define SIZEOF_FLOAT 0 +#define SIZEOF_DOUBLE 0 + +#if (SIZEOF_CHAR == 1) +typedef char int8; +typedef char javabyte; +#else +#error sizeof(char) not 1 +#endif + +#if (SIZEOF_SHORT == 2) +typedef short int16; +typedef short javashort; +#else +#error sizeof(short) is not 2 +#endif + +#if (SIZEOF_INT == 4) +typedef int int32; +typedef int javaint; +#elif (SIZEOF_LONG == 4) +typedef int int32; +typedef long javaint; +#else +#error compiler has no 32 bit integer +#endif + +#if (SIZEOF_LONG == 8) +typedef long int64; +typedef long javalong; +#elif (SIZEOF_LONG_LONG == 8) +typedef long long int64; +typedef long long javalong; +#else +#error compiler has no 64 bit integer +#endif + +#if (SIZEOF_FLOAT == 4) +typedef float javafloat; +#else +#error compiler has no 32 bit float +#endif + +#if (SIZEOF_DOUBLE == 8) +typedef double javadouble; +#else +#error compiler has no 64 bit double; +#endif + +#if (SIZEOF_UNSIGNED_CHAR == 1) +typedef unsigned char uint8; +#else +#error sizeof(unsigned char) is not 1 +#endif + +#if (SIZEOF_UNSIGNED_SHORT == 2) +typedef unsigned short uint16; +typedef unsigned short javachar; +typedef unsigned short unicode; +#else +#error sizeof(unsigned short) is not 2 +#endif + +#if (SIZEOF_UNSIGNED_INT == 4) +typedef unsigned int uint32; +#elif (SIZEOF_UNSIGNED_LONG == 4) +typedef unsigned long uint32; +#else +#error compiler has no 32 bit unsigned integer +#endif + +#if (SIZEOF_UNSIGNED_LONG == 8) +typedef unsigned long uint64; +#elif (SIZEOF_UNSIGNED_LONG_LONG == 8) +typedef unsigned long long uint64; +#else +#error compiler has no 64 bit unsigned integer +#endif + +typedef uint8 byte; + +#endif diff --git a/beecrypt/gnu/fips180opt.gas.i586.S b/beecrypt/gnu/fips180opt.gas.i586.S new file mode 100644 index 0000000..5087f3e --- /dev/null +++ b/beecrypt/gnu/fips180opt.gas.i586.S @@ -0,0 +1,301 @@ +/* + * fips180opt.gas.i586.S + * + * Assembler optimized SHA-1 routines for Intel Pentium processors + * + * Compile target is GNU AS + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 + * + */ + + .file "fips180opt.gas.i586.S" + + .text + + .equ K00, 0x5a827999 + .equ K20, 0x6ed9eba1 + .equ K40, 0x8f1bbcdc + .equ K60, 0xca62c1d6 + + .equ PARAM_H, 0 + .equ PARAM_DATA, 20 + + .macro subround1 b c d e w + movl \c,%ecx + movl \b,%ebx + movl \d,%edx + roll $5,%eax + xorl %edx,%ecx + addl \e,%eax + andl %ebx,%ecx + addl $K00,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + xorl %edx,%ecx + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + + .macro subround2 b c d e w + movl \c,%ecx + movl \b,%ebx + roll $5,%eax + xorl %ebx,%ecx + addl \e,%eax + xorl \d,%ecx + addl $K20,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + + .macro subround3 b c d e w + movl \c,%ecx + roll $5,%eax + movl \b,%ebx + movl %ecx,%edx + addl \e,%eax + orl %ebx,%ecx + andl %ebx,%edx + andl \d,%ecx + addl $K40,%eax + orl %edx,%ecx + addl \w(%esi,%edi),%eax + rorl $2,%ebx + addl %ecx,%eax + movl %ebx,\b + movl %eax,\e + .endm + + .macro subround4 b c d e w + movl \c,%ecx + movl \b,%ebx + roll $5,%eax + xorl %ebx,%ecx + addl \e,%eax + xorl \d,%ecx + addl $K60,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + + .align 4 +#if defined(CYGWIN) + .globl _sha1Process + .def _sha1Process + .scl 2 + .type 32 + .endef + +_sha1Process: +#else + .global sha1Process + .type sha1Process,@function + +sha1Process: +#endif + pushl %edi + pushl %esi + pushl %ebx + + pushl %ebp + leal -20(%esp),%ebp + + movl 20(%esp),%esi + leal PARAM_DATA(%esi),%edi + + movl $4,%ecx +.L0: + movl (%esi,%ecx,4),%edx + movl %edx,(%ebp,%ecx,4) + decl %ecx + jns .L0 + + movl $15,%ecx + xorl %eax,%eax + + .p2align 2 +.L1: + movl (%edi,%ecx,4),%edx + bswap %edx + mov %edx,(%edi,%ecx,4) + decl %ecx + jns .L1 + + leal PARAM_DATA(%esi),%edi + movl $16,%ecx + + .p2align 2 +.L2: + movl 52(%edi),%eax + movl 56(%edi),%ebx + xorl 32(%edi),%eax + xorl 36(%edi),%ebx + xorl 8(%edi),%eax + xorl 12(%edi),%ebx + xorl (%edi),%eax + xorl 4(%edi),%ebx + roll $1,%eax + roll $1,%ebx + movl %eax,64(%edi) + movl %ebx,68(%edi) + movl 60(%edi),%eax + movl 64(%edi),%ebx + xorl 40(%edi),%eax + xorl 44(%edi),%ebx + xorl 16(%edi),%eax + xorl 20(%edi),%ebx + xorl 8(%edi),%eax + xorl 12(%edi),%ebx + roll $1,%eax + roll $1,%ebx + movl %eax,72(%edi) + movl %ebx,76(%edi) + addl $16,%edi + decl %ecx + jnz .L2 + + movl $PARAM_DATA,%edi + + movl (%ebp),%eax +.L01_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 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L21_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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L41_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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L61_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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + /* addl $20,%edi */ + + movl $4,%ecx + + .p2align 2 +.L3: + movl (%ebp,%ecx,4),%eax + addl %eax,(%esi,%ecx,4) + decl %ecx + jns .L3 + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret diff --git a/beecrypt/gnu/fips180opt.gas.i586.s b/beecrypt/gnu/fips180opt.gas.i586.s new file mode 100644 index 0000000..1c03b44 --- /dev/null +++ b/beecrypt/gnu/fips180opt.gas.i586.s @@ -0,0 +1,292 @@ +# +# fips180opt.gas.i586.asm +# +# Assembler optimized SHA-1 routines for Intel Pentium processors +# +# Compile target is GNU AS +# +# Copyright (c) 2000 Virtual Unlimited B.V. +# +# Author: 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 +# + +.if 1 + .file "fips180opt.gas.i586.s" + + .text + + .equ K00, 0x5a827999 + .equ K20, 0x6ed9eba1 + .equ K40, 0x8f1bbcdc + .equ K60, 0xca62c1d6 + + .equ PARAM_H, 0 + .equ PARAM_DATA, 20 + + .macro subround1 b c d e w + movl \c,%ecx + movl \b,%ebx + movl \d,%edx + roll $5,%eax + xorl %edx,%ecx + addl \e,%eax + andl %ebx,%ecx + addl $K00,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + xorl %ecx,%edx + movl %ebx,\b + addl %ebx,%eax + movl %eax,\e + .endm + + .macro subround2 b c d e w + movl \c,%ecx + movl \b,%ebx + roll $5,%eax + xorl %ebx,%ecx + addl \e,%eax + xorl \d,%ecx + addl $K20,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + + .macro subround3 b c d e w + movl \c,%ecx + roll $5,%eax + movl \b,%ebx + movl %ecx,%edx + addl \e,%eax + orl %ebx,%ecx + andl %ebx,%edx + andl \d,%ecx + addl $K40,%eax + orl %edx,%ecx + addl \w(%esi,%edi),%eax + rorl $4,%ebx + addl %ecx,%eax + movl %ebx,\b + movl %eax,\e + .endm + + .macro subround4 b c d e w + movl \c,%ecx + movl \b,%ebx + roll $5,%eax + xorl %ebx,%ecx + addl \e,%eax + xorl \d,%ecx + addl $K60,%eax + rorl $2,%ebx + addl \w(%esi,%edi),%eax + movl %ebx,\b + addl %ecx,%eax + movl %eax,\e + .endm + + .align 4 + .globl sha1Process + .type sha1Process,@function + +sha1Process: + pushl %edi + pushl %esi + pushl %ebx + + pushl %ebp + leal -20(%esp),%ebp + + movl 20(%esp),%esi + leal PARAM_DATA(%esi),%edi + + movl $4,%ecx +.L0: + movl (%esi,%ecx,4),%edx + movl %edx,(%ebp,%ecx,4) + decl %ecx + jns .L0 + + movl $15,%ecx + xorl %eax,%eax + + .p2align 2 +.L1: + movl (%edi,%ecx,4),%edx + bswap %edx + mov %edx,(%edi,%ecx,4) + decl %ecx + jns .L1 + + leal PARAM_DATA(%esi),%edi + movl $16,%ecx + + .p2align 2 +.L2: + movl 52(%edi),%eax + movl 56(%edi),%ebx + xorl 32(%edi),%eax + xorl 36(%edi),%ebx + xorl 8(%edi),%eax + xorl 12(%edi),%eax + xorl (%edi),%ebx + xorl 4(%edi),%ebx + roll $1,%eax + roll $1,%ebx + movl %eax,64(%edi) + movl %ebx,68(%edi) + movl 60(%edi),%eax + movl 64(%edi),%ebx + xorl 36(%edi),%eax + xorl 40(%edi),%ebx + xorl 16(%edi),%eax + xorl 20(%edi),%eax + xorl 8(%edi),%ebx + xorl 12(%edi),%ebx + roll $1,%eax + roll $1,%ebx + movl %eax,72(%edi) + movl %ebx,76(%edi) + addl $16,%edi + decl %ecx + jnz .L2 + + movl $PARAM_DATA,%edi + + movl (%ebp),%eax +.L01_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 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 + subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 + subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 + subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L21_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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L41_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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + +.L61_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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + addl $20,%edi + 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 + subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 + subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 + # addl $20,%edi + + movl $4,%ecx + + .p2align 2 +.L3: + movl (%ebp,%ecx,4),%eax + addl %eax,(%esi,%ecx,4) + decl %ecx + jns .L3 + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret +.endif diff --git a/beecrypt/gnu/mp32opt.gas.i386.S b/beecrypt/gnu/mp32opt.gas.i386.S new file mode 100644 index 0000000..94d8514 --- /dev/null +++ b/beecrypt/gnu/mp32opt.gas.i386.S @@ -0,0 +1,361 @@ +/* + * mp32opt.gas.i386.S + * + * Assembler optimized multiprecision integer routines for Intel 386 and higher + * + * Compile target is GNU AS + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: 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 + * + */ + + .file "mp32opt.gas.i386.S" + + .text + + .align 4 +#if defined(CYGWIN) + .globl _mp32addw + .def _mp32addw + .scl 2 + .type 32 + .endef + +_mp32addw: +#else + .global mp32addw + .type mp32addw,@function + +mp32addw: +#endif + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + movl 16(%esp),%eax + + xorl %edx,%edx + leal -4(%edi,%ecx,4),%edi + addl %eax,(%edi) + decl %ecx + jz .L1 + leal -4(%edi),%edi + + .p2align 4,,7 +.L0: + adcl %edx,(%edi) + leal -4(%edi),%edi + decl %ecx + jnz .L0 +.L1: + sbbl %eax,%eax + negl %eax + + popl %edi + ret + +#if defined(CYGWIN) + .globl _mp32subw + .def _mp32subw + .scl 2 + .type 32 + .endef + +_mp32subw: +#else + .global mp32subw + .type mp32subw,@function + +mp32subw: +#endif + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + movl 16(%esp),%eax + + xorl %edx,%edx + leal -4(%edi,%ecx,4),%edi + subl %eax,(%edi) + decl %ecx + jz .L3 + leal -4(%edi),%edi + + .p2align 4,,7 +.L2: + sbbl %edx,(%edi) + leal -4(%edi),%edi + decl %ecx + jnz .L2 +.L3: + sbbl %eax,%eax + negl %eax + popl %edi + ret + +#if defined(CYGWIN) + .globl _mp32add + .def _mp32add + .scl 2 + .type 32 + .endef + +_mp32add: +#else + .global mp32add + .type mp32add,@function + +mp32add: +#endif + pushl %edi + pushl %esi + + movl 12(%esp),%ecx + movl 16(%esp),%edi + movl 20(%esp),%esi + + xorl %edx,%edx + decl %ecx + + .p2align 4,,7 +.L4: + movl (%esi,%ecx,4),%eax + adcl %eax,(%edi,%ecx,4) + decl %ecx + jns .L4 + + sbbl %eax,%eax + negl %eax + + popl %esi + popl %edi + ret + +#if defined(CYGWIN) + .globl _mp32sub + .def _mp32sub + .scl 2 + .type 32 + .endef + +_mp32sub: +#else + .global mp32sub + .type mp32sub,@function + +mp32sub: +#endif + pushl %edi + pushl %esi + + movl 12(%esp),%ecx + movl 16(%esp),%edi + movl 20(%esp),%esi + + xorl %edx,%edx + decl %ecx + + .p2align 4,,7 +.L5: + movl (%esi,%ecx,4),%eax + sbbl %eax,(%edi,%ecx,4) + decl %ecx + jns .L5 + + sbbl %eax,%eax + negl %eax + popl %esi + popl %edi + ret + +#if defined(CYGWIN) + .globl _mp32multwo + .def _mp32multwo + .scl 2 + .type 32 + .endef + +_mp32multwo: +#else + .global mp32multwo + .type mp32multwo,@function + +mp32multwo: +#endif + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + + xorl %eax,%eax + decl %ecx + + .p2align 4,,7 +.L6: + movl (%edi,%ecx,4),%eax + adcl %eax,(%edi,%ecx,4) + decl %ecx + jns .L6 + + sbbl %eax,%eax + negl %eax + + popl %edi + ret + +#if defined(CYGWIN) + .globl _mp32setmul + .def _mp32setmul + .scl 2 + .type 32 + .endef + +_mp32setmul: +#else + .global mp32setmul + .type mp32setmul,@function + +mp32setmul: +#endif + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + + movl 20(%esp),%ecx + movl 24(%esp),%edi + movl 28(%esp),%esi + movl 32(%esp),%ebp + + xorl %ebx,%ebx + decl %ecx + + .p2align 4,,7 +.L7: + movl (%esi,%ecx,4),%eax + mull %ebp + addl %ebx,%eax + adcl $0,%edx + movl %eax,(%edi,%ecx,4) + movl %edx,%ebx + decl %ecx + jns .L7 + + movl %ebx,%eax + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret + +#if defined(CYGWIN) + .globl _mp32addmul + .def _mp32addmul + .scl 2 + .type 32 + .endef + +_mp32addmul: +#else + .global mp32addmul + .type mp32addmul,@function + +mp32addmul: +#endif + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + + movl 20(%esp),%ecx + movl 24(%esp),%edi + movl 28(%esp),%esi + movl 32(%esp),%ebp + + xorl %ebx,%ebx + decl %ecx + + .p2align 4,,7 +.L8: + movl (%esi,%ecx,4),%eax + mull %ebp + addl %ebx,%eax + adcl $0,%edx + addl (%edi,%ecx,4),%eax + adcl $0,%edx + movl %eax,(%edi,%ecx,4) + movl %edx,%ebx + decl %ecx + jns .L8 + + movl %ebx,%eax + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret + +#if defined(CYGWIN) + .globl _mp32addsqrtrc + .def _mp32addsqrtrc + .scl 2 + .type 32 + .endef + +_mp32addsqrtrc: +#else + .global mp32addsqrtrc + .type mp32addsqrtrc,@function + +mp32addsqrtrc: +#endif + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%ecx + movl 20(%esp),%edi + movl 24(%esp),%esi + + xorl %ebx,%ebx + decl %ecx + + .p2align 4,,7 +.L9: + movl (%esi,%ecx,4),%eax + mull %eax + addl %ebx,%eax + adcl $0,%edx + addl 4(%edi,%ecx,8),%eax + adcl (%edi,%ecx,8),%edx + sbbl %ebx,%ebx + movl %eax,4(%edi,%ecx,8) + movl %edx,(%edi,%ecx,8) + negl %ebx + decl %ecx + jns .L9 + + movl %ebx,%eax + + popl %ebx + popl %esi + popl %edi + ret diff --git a/beecrypt/gnu/mp32opt.gas.i386.s b/beecrypt/gnu/mp32opt.gas.i386.s new file mode 100644 index 0000000..31ea45c --- /dev/null +++ b/beecrypt/gnu/mp32opt.gas.i386.s @@ -0,0 +1,287 @@ +# +# mp32opt.gas.i386.s +# +# Assembler optimized multiprecision integer routines for Intel 386 and higher +# +# Compile target is GNU AS +# +# Copyright (c) 1998-2000 Virtual Unlimited B.V. +# +# Author: 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 +# + + .file "mp32opt.gas.i386.s" + + .text + + .align 4 + .globl mp32addw + .type mp32addw,@function + +mp32addw: + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + movl 16(%esp),%eax + + xorl %edx,%edx + leal -4(%edi,%ecx,4),%edi + addl %eax,(%edi) + decl %ecx + jz .L1 + leal -4(%edi),%edi + + .p2align 4,,7 +.L0: + adcl %edx,(%edi) + leal -4(%edi),%edi + decl %ecx + jnz .L0 +.L1: + sbbl %eax,%eax + negl %eax + + popl %edi + ret + + .align 4 + .globl mp32subw + .type mp32subw,@function + +mp32subw: + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + movl 16(%esp),%eax + + xorl %edx,%edx + leal -4(%edi,%ecx,4),%edi + subl %eax,(%edi) + decl %ecx + jz .L3 + leal -4(%edi),%edi + + .p2align 4,,7 +.L2: + sbbl %edx,(%edi) + leal -4(%edi),%edi + decl %ecx + jnz .L2 +.L3: + sbbl %eax,%eax + negl %eax + popl %edi + ret + + .align 4 + .globl mp32add + .type mp32add,@function + +mp32add: + pushl %edi + pushl %esi + + movl 12(%esp),%ecx + movl 16(%esp),%edi + movl 20(%esp),%esi + + xorl %edx,%edx + decl %ecx + + .p2align 4,,7 +.L4: + movl (%esi,%ecx,4),%eax + adcl %eax,(%edi,%ecx,4) + decl %ecx + jns .L4 + + sbbl %eax,%eax + negl %eax + + popl %esi + popl %edi + ret + + .align 4 + .globl mp32sub + .type mp32sub,@function + +mp32sub: + pushl %edi + pushl %esi + + movl 12(%esp),%ecx + movl 16(%esp),%edi + movl 20(%esp),%esi + + xorl %edx,%edx + decl %ecx + + .p2align 4,,7 +.L5: + movl (%esi,%ecx,4),%eax + sbbl %eax,(%edi,%ecx,4) + decl %ecx + jns .L5 + + sbbl %eax,%eax + negl %eax + popl %esi + popl %edi + ret + + .align 4 + .globl mp32multwo + .type mp32multwo,@function + +mp32multwo: + pushl %edi + + movl 8(%esp),%ecx + movl 12(%esp),%edi + + xorl %eax,%eax + decl %ecx + + .p2align 4,,7 +.L6: + movl (%edi,%ecx,4),%eax + adcl %eax,(%edi,%ecx,4) + decl %ecx + jns .L6 + + sbbl %eax,%eax + negl %eax + + popl %edi + ret + + .align 4 + .globl mp32setmul + .type mp32setmul,@function + +mp32setmul: + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + + movl 20(%esp),%ecx + movl 24(%esp),%edi + movl 28(%esp),%esi + movl 32(%esp),%ebp + + xorl %ebx,%ebx + decl %ecx + + .p2align 4,,7 +.L7: + movl (%esi,%ecx,4),%eax + mull %ebp + addl %ebx,%eax + adcl $0,%edx + movl %eax,(%edi,%ecx,4) + movl %edx,%ebx + decl %ecx + jns .L7 + + movl %ebx,%eax + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret + + .align 4 + .globl mp32addmul + .type mp32addmul,@function + +mp32addmul: + pushl %edi + pushl %esi + pushl %ebx + pushl %ebp + + movl 20(%esp),%ecx + movl 24(%esp),%edi + movl 28(%esp),%esi + movl 32(%esp),%ebp + + xorl %ebx,%ebx + decl %ecx + + .p2align 4,,7 +.L8: + movl (%esi,%ecx,4),%eax + mull %ebp + addl %ebx,%eax + adcl $0,%edx + addl (%edi,%ecx,4),%eax + adcl $0,%edx + movl %eax,(%edi,%ecx,4) + movl %edx,%ebx + decl %ecx + jns .L8 + + movl %ebx,%eax + + popl %ebp + popl %ebx + popl %esi + popl %edi + ret + + .align 4 + .globl mp32addsqrtrc + .type mp32addsqrtrc,@function + +mp32addsqrtrc: + pushl %edi + pushl %esi + pushl %ebx + + movl 16(%esp),%ecx + movl 20(%esp),%edi + movl 24(%esp),%esi + + xorl %ebx,%ebx + decl %ecx + + .p2align 4,,7 +.L9: + movl (%esi,%ecx,4),%eax + mull %eax + addl %ebx,%eax + adcl $0,%edx + addl 4(%edi,%ecx,8),%eax + adcl (%edi,%ecx,8),%edx + sbbl %ebx,%ebx + movl %eax,4(%edi,%ecx,8) + movl %edx,(%edi,%ecx,8) + negl %ebx + decl %ecx + jns .L9 + + movl %ebx,%eax + + popl %ebx + popl %esi + popl %edi + ret diff --git a/beecrypt/gnu/mp32opt.gas.ia64.S b/beecrypt/gnu/mp32opt.gas.ia64.S new file mode 100644 index 0000000..e7d95f7 --- /dev/null +++ b/beecrypt/gnu/mp32opt.gas.ia64.S @@ -0,0 +1,242 @@ +/* + * mp32opt.gas.ia64.S + * + * Assembler optimized multiprecision integer routines for ia64 (Intel Itanium) + * + * Compile target is GNU AS + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define saved_pfs r14 +#define saved_lc r15 + +#define size r16 +#define dst r17 +#define src r18 + + .file "mp32opt.gas.ia64.s" + + .text + + .explicit + + .align 32 + .global mp32zero + .type mp32zero,@function + +mp32zero: + alloc saved_pfs = ar.pfs,2,0,0,0 + mov saved_lc = ar.lc + sub size = in0,r0,1;; + mov src = in1 + mov ar.lc = size;; +.L00: + st4 [src] = r0,4 + br.ctop.sptk .L00 + ;; + mov ar.lc = saved_lc + mov ar.pfs = saved_pfs + br.ret.sptk b0 + + + .align 32 + .global mp32copy + .type mp32copy,@function + +mp32copy: + alloc r14 = ar.pfs,3,5,0,8 + mov r15 = ar.lc + sub r16 = in0,r0,1 + mov r17 = in1 + mov r18 = in2;; + mov ar.lc = r16 + mov ar.ec = 3 + mov pr.rot = (1 << 16);; +.L01: + (p16) ld4 r32 = [r18],4 + (p18) st4 [r17] = r34,4 + br.ctop.sptk .L01;; + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + + + .if 0 + .align 32 + .global mp32z + .type mp32z,@function + +mp32z: + alloc r14 = ar.pfs,2,6,0,8 + mov r15 = ar.lc + sub r16= in0,r0,1 + mov r17 = in1 + mov r18 = in2;; + mov r8 = 1 + mov pr.rot = 1 << 16 + mov ar.ec = 2 + mov ar.lc = r16;; +.L02: + (p16) ld4 r32 = [r18],4 + (p18) cmp.eq p0,p32 = r34,r0 + (p33) mov r8 = r0 + (p33) br.exit + .endif + + + .align 32 + .global mp32add + .type mp32add,@function + +mp32add: + alloc r14 = ar.pfs,3,0,0,0 + mov r15 = ar.lc + # adjust size by -1 + sub r16 = in0,r0,1 + # clear carry + mov r8 = r0;; + # load addresses + shladd r17 = r16,2,in1 + shladd r18 = r16,2,in2 + # load loop count + mov ar.lc = r16;; +.L20: + ld4 r20 = [r18],-4 + ld4 r19 = [r17] + tbit.z p1,p2 = r8,32;; + (p1) add r8 = r19,r20 + (p2) add r8 = r19,r20,1;; + st4 [r17] = r8,-4 + br.cloop.sptk .L20;; + extr.u r8 = r8,32,1 + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + + + .align 32 + .global mp32sub + .type mp32sub,@function + +mp32sub: + alloc r14 = ar.pfs,3,0,0,0 + mov r15 = ar.lc + # adjust size by -1 + sub r16 = in0,r0,1 + # clear carry + mov r8 = r0;; + # load addresses + shladd r17 = r16,2,in1 + shladd r18 = r16,2,in2 + # load loop count + mov ar.lc = r16;; +.L30: + ld4 r20 = [r18],-4 + ld4 r19 = [r17] + tbit.z p1,p2 = r8,32;; + (p1) sub r8 = r19,r20 + (p2) sub r8 = r19,r20,1;; + st4 [r17] = r8,-4 + br.cloop.sptk .L30;; + extr.u r8 = r8,32,1 + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + + + .align 32 + .global mp32setmul + .type mp32setmul,@function + +mp32setmul: + alloc r14 = ar.pfs,4,0,0,0 + mov r15 = ar.lc + # adjust size by -1 + sub r16 = in0,r0,1 + # clear carry + mov r8 = r0;; + # adjust addresses + shladd r17 = r16,2,in1 + shladd r18 = r16,2,in2 + # load loop count + mov ar.lc = r16 + # load mul + setf.sig f96 = in3;; +.L40: + ld4 r19 = [r18],-4;; + setf.sig f98 = r8 + setf.sig f97 = r19;; + # multiplication can only be done in f registers, but we do have a multiply-add + xma.l f98 = f96, f97, f98;; + getf.sig r8 = f98;; + st4 [r17] = r8,-4 + shr.u r8 = r8,32 + br.cloop.sptk .L40;; + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + + + .align 32 + .global mp32addmul + .type mp32addmul,@function + +mp32addmul: + alloc r14 = ar.pfs,4,0,0,0 + mov r15 = ar.lc + # adjust size by -1 + sub r16 = in0,r0,1 + # load mul + # setf.sig f6 = r0 + setf.sig f7 = in3 + # clear carry + mov r8 = r0;; + # adjust addresses + shladd r17 = r16,2,in1 + shladd r18 = r16,2,in2 + # load loop count + mov ar.lc = r16;; +.L50: + ld4 r19 = [r17] + ld4 r20 = [r18],-4;; + setf.sig f8 = r8 + setf.sig f32 = r20;; + # multiplication can only be done in f registers, but we do have a multiply-add + xma.l f8 = f7,f32,f8;; + getf.sig r8 = f8;; + add r8 = r8,r19;; + st4 [r17] = r8,-4 + shr.u r8 = r8,32 + br.cloop.sptk .L50;; + mov ar.lc = r15 + mov ar.pfs = r14 + br.ret.sptk b0 + + + .if 0 + .align 16 + .global mp32addsqrtrc# + .proc mp32addsqrtrc# + +mp32addsqrtrc: + .endp mp32addsqrtrc# + .endif + diff --git a/beecrypt/gnu/mp32opt.gas.powerpc.S b/beecrypt/gnu/mp32opt.gas.powerpc.S new file mode 100644 index 0000000..9ae0489 --- /dev/null +++ b/beecrypt/gnu/mp32opt.gas.powerpc.S @@ -0,0 +1,259 @@ +/* + * mp32opt.gas.powerpc.S + * + * Assembler optimized multiprecision integer routines for PowerPC + * + * Compile target is GNU AS + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 + * + */ + + .file "mp32opt.gas.powerpc.S" + + .text + +#if defined(DARWIN) +# define reg0 r0 +# define reg3 r3 +# define reg4 r4 +# define reg5 r5 +# define reg6 r6 +# define reg7 r7 +# define reg8 r8 +# define reg9 r9 +#else +# define reg0 %r0 +# define reg3 %r3 +# define reg4 %r4 +# define reg5 %r5 +# define reg6 %r6 +# define reg7 %r7 +# define reg8 %r8 +# define reg9 %r9 +#endif + + .align 4 +#if defined(DARWIN) + .globl _mp32addw + +_mp32addw: +#else + .global mp32addw + .type mp32addw,@function + +mp32addw: +#endif + mtctr reg3 + slwi reg0,reg3,2 + add reg4,reg4,reg0 + li reg0,0 + lwzu reg6,-4(reg4) + addc reg6,reg6,reg5 + stw reg6,0(reg4) + bdz .L01 +.L00: + lwzu reg6,-4(reg4) + adde reg6,reg0,reg6 + stw reg6,0(reg4) + bdnz .L00 +.L01: # return the carry + addze reg3,reg0 + blr + + .align 4 +#if defined(DARWIN) + .globl _mp32subw + +_mp32subw: +#else + .global mp32subw + .type mp32subw,@function + +mp32subw: +#endif + mtctr reg3 + slwi reg0,reg3,2 + add reg4,reg4,reg0 + li reg0,0 + lwz reg6,-4(reg4) + subfc reg6,reg5,reg6 + stwu reg6,-4(reg4) + bdz .L11 +.L10: + lwz reg6,-4(reg4) + subfe reg6,reg0,reg6 + stwu reg6, -4(reg4) + bdnz .L10 +.L11: # return the carry + subfe reg3,reg0,reg0 + neg reg3,reg3 + blr + + .align 4 +#if defined(DARWIN) + .globl _mp32add + +_mp32add: +#else + .global mp32add + .type mp32add,@function + +mp32add: +#endif + mtctr reg3 + slwi reg0,reg3,2 + add reg4,reg4,reg0 + add reg5,reg5,reg0 + li reg0,0 + lwz reg6,-4(reg4) + lwzu reg7,-4(reg5) + addc reg6,reg7,reg6 + stwu reg6,-4(reg4) + bdz .L21 +.L20: + lwz reg6,-4(reg4) + lwzu reg7,-4(reg5) + adde reg6,reg7,reg6 + stwu reg6,-4(reg4) + bdnz .L20 +.L21: # return the carry + addze reg3,reg0 + blr + + .align 4 +#if defined(DARWIN) + .globl _mp32sub + +_mp32sub: +#else + .global mp32sub + .type mp32sub,@function + +mp32sub: +#endif + mtctr reg3 + slwi reg0,reg3,2 + add reg4,reg4,reg0 + add reg5,reg5,reg0 + li reg0,0 + lwz reg6,-4(reg4) + lwzu reg7,-4(reg5) + subfc reg6,reg7,reg6 + stwu reg6,-4(reg4) + bdz .L31 +.L30: + lwz reg6,-4(reg4) + lwzu reg7,-4(reg5) + subfe reg6,reg7,reg6 + stwu reg6,-4(reg4) + bdnz .L30 +.L31: # return the carry + subfe reg3,reg0,reg0 + neg reg3,reg3 + blr + + .align 4 +#if defined(DARWIN) + .globl _mp32setmul + +_mp32setmul: +#else + .globl mp32setmul + .type mp32setmul,@function + +mp32setmul: +#endif + mtctr reg3 + slwi reg0,reg3,2 + add reg4,reg4,reg0 + add reg5,reg5,reg0 + li reg3,0 +.L40: + lwzu reg7,-4(reg5) + mullw reg8,reg7,reg6 + addc reg8,reg8,reg3 + mulhwu reg3,reg7,reg6 + addze reg3,reg3 + stwu reg8,-4(reg4) + bdnz .L40 + blr + + .align 4 +#if defined(DARWIN) + .globl _mp32addmul + +_mp32addmul: +#else + .globl mp32addmul + .type mp32addmul,@function + +mp32addmul: +#endif + mtctr reg3 + slwi reg0,reg3,2 + add reg4,reg4,reg0 + add reg5,reg5,reg0 + li reg3,0 +.L50: + lwzu reg7,-4(reg4) + lwzu reg8,-4(reg5) + mullw reg9,reg8,reg6 + addc reg9,reg9,reg3 + mulhwu reg3,reg8,reg6 + addze reg3,reg3 + addc reg9,reg9,reg7 + addze reg3,reg3 + stw reg9,0(reg4) + bdnz .L50 + blr + + .align 4 +#if defined(DARWIN) + .globl _mp32addsqrtrc + +_mp32addsqrtrc: +#else + .globl mp32addsqrtrc + .type mp32addsqrtrc,@function + +mp32addsqrtrc: +#endif + mtctr reg3 + slwi reg0,reg3,2 + add reg4,reg4,reg0 + add reg5,reg5,reg0 + add reg4,reg4,reg0 + li reg3,0 +.L60: + lwzu reg0,-4(reg5) + lwz reg6,-8(reg4) + lwz reg7,-4(reg4) + mullw reg9,reg0,reg0 + mulhwu reg8,reg0,reg0 + addc reg9,reg9,reg3 + addze reg8,reg8 + addc reg7,reg7,reg9 + adde reg6,reg6,reg8 + li reg3,0 + addze reg3,reg3 + stw reg7,-4(reg4) + stwu reg6,-8(reg4) + bdnz .L60 + blr diff --git a/beecrypt/gnu/mp32opt.gas.powerpc.s b/beecrypt/gnu/mp32opt.gas.powerpc.s new file mode 100644 index 0000000..1f60176 --- /dev/null +++ b/beecrypt/gnu/mp32opt.gas.powerpc.s @@ -0,0 +1,210 @@ +# +# mp32opt.gas.powerpc.s +# +# Assembler optimized multiprecision integer routines for PowerPC +# +# Compile target is GNU AS +# +# Copyright (c) 2000 Virtual Unlimited B.V. +# +# Author: 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 +# + + .file "mp32opt.gas.powerpc.s" + + .align 4 + .globl mp32addw + .type mp32addw,@function + +mp32addw: + mtctr %r3 + slwi %r0,%r3,2 + add %r4,%r4,%r0 + li %r0,0 + lwzu %r6,-4(%r4) + addc %r6,%r6,%r5 + stw %r6,0(%r4) + bdz .L01 +.L00: + lwzu %r6,-4(%r4) + adde %r6,%r0,%r6 + stw %r6,0(%r4) + bdnz .L00 +.L01: # return the carry + addze %r3,%r0 + blr + + .if 0 # doesn't work yet + .align 4 + .globl mp32subw + .type mp32subw,@function + +mp32subw: + mtctr %r3 + slwi %r0,%r3,2 + add %r4,%r4,%r0 + li %r0,0 + lwz %r6,-4(%r4) + subfc %r6,%r5,%r6 + stwu %r6,-4(%r4) + bdz .L11 +.L10: + lwz %r6,-4(%r4) + subfe %r6,%r0,%r6 + stwu %r6, -4(%r4) + bdnz .L10 +.L11: # return the carry + addze %r3,%r0 + blr + .endif + + .align 4 + .globl mp32add + .type mp32add,@function + +mp32add: + mtctr %r3 + slwi %r0,%r3,2 + add %r4,%r4,%r0 + add %r5,%r5,%r0 + li %r0,0 + lwz %r6,-4(%r4) + lwzu %r7,-4(%r5) + addc %r6,%r7,%r6 + stwu %r6,-4(%r4) + bdz .L21 +.L20: + lwz %r6,-4(%r4) + lwzu %r7,-4(%r5) + adde %r6,%r7,%r6 + stwu %r6,-4(%r4) + bdnz .L20 +.L21: # return the carry + addze %r3,%r0 + blr + + .if 0 # doesn't work yet + .align 4 + .globl mp32sub + .type mp32sub,@function + +mp32sub: + mtctr %r3 + slwi %r0,%r3,2 + add %r4,%r4,%r0 + add %r5,%r5,%r0 + li %r0,0 + lwz %r6,-4(%r4) + lwzu %r7,-4(%r5) + subfc %r6,%r7,%r6 + stwu %r6,-4(%r4) + bdz .L31 +.L30: + lwz %r6,-4(%r4) + lwzu %r7,-4(%r5) + subfe %r6,%r7,%r6 + stwu %r6,-4(%r4) + bdnz .L30 +.L31: # return the carry + addze %r3,%r0 + blr + .endif + + .align 4 + .globl mp32setmul + .type mp32setmul,@function + +# size %r3 +# dst %r4 +# src %r5 +# mulw %r6 + +mp32setmul: + mtctr %r3 + slwi %r0,%r3,2 + add %r4,%r4,%r0 + add %r5,%r5,%r0 + li %r3,0 +.L40: + lwzu %r7,-4(%r5) + mullw %r8,%r7,%r6 + addc %r8,%r8,%r3 + mulhwu %r3,%r7,%r6 + addze %r3,%r3 + stwu %r8,-4(%r4) + bdnz .L40 + blr + + .align 4 + .globl mp32addmul + .type mp32addmul,@function + +# size %r3 +# dst %r4 +# src %r5 +# mulw %r6 + +mp32addmul: + mtctr %r3 + slwi %r0,%r3,2 + add %r4,%r4,%r0 + add %r5,%r5,%r0 + li %r3,0 +.L50: + lwzu %r7,-4(%r4) + lwzu %r8,-4(%r5) + mullw %r9,%r8,%r6 + addc %r9,%r9,%r3 + mulhwu %r3,%r8,%r6 + addze %r3,%r3 + addc %r9,%r9,%r7 + addze %r3,%r3 + stw %r9,0(%r4) + bdnz .L50 + blr + + .align 4 + .globl mp32addsqrtrc + .type mp32addsqrtrc,@function + +# size %r3 +# dst %r4 +# src %r5 + +mp32addsqrtrc: + mtctr %r3 + slwi %r0,%r3,2 + add %r4,%r4,%r0 + add %r5,%r5,%r0 + add %r4,%r4,%r0 + li %r3,0 +.L60: + lwzu %r0,-4(%r5) + lwz %r6,-8(%r4) + lwz %r7,-4(%r4) + mullw %r9,%r0,%r0 + mulhwu %r8,%r0,%r0 + addc %r9,%r9,%r3 + addze %r8,%r8 + addc %r7,%r7,%r9 + adde %r6,%r6,%r8 + li %r3,0 + addze %r3,%r3 + stw %r7,-4(%r4) + stwu %r6,-8(%r4) + bdnz .L60 + blr diff --git a/beecrypt/gnu/mp32opt.gas.sparcv9.S b/beecrypt/gnu/mp32opt.gas.sparcv9.S new file mode 100644 index 0000000..9fe7c6c --- /dev/null +++ b/beecrypt/gnu/mp32opt.gas.sparcv9.S @@ -0,0 +1,180 @@ +/* + * mp32opt.gas.sparcv9.S + * + * Assembler optimized multiprecision integer routines for UltraSparc (64 bits instructions, will run on 32 bit OS) + * + * Compile target is GNU AS + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: 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 + * + */ + + .file "mp32opt.gas.sparcv9.S" + + .text + + .align 8 + .globl mp32addw + .type mp32addw,@function + +mp32addw: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 + lduw [%o1+%g1],%g2 + addcc %g2,%o2,%g2 + stw %g2,[%o1+%g1] + brz,pn %g1,.L01 + sub %g1,4,%g1 +.L00: + lduw [%o1+%g1],%g2 + addccc %g2,%g0,%g2 + stw %g2,[%o1+%g1] + brnz,pt %g1,.L00 + sub %g1,4,%g1 +.L01: + retl + movcs %icc,1,%o0 + + .align 8 + .globl mp32subw + .type mp32subw,@function + +mp32subw: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 + lduw [%o1+%g1],%g2 + subcc %g2,%o2,%g2 + stw %g2,[%o1+%g1] + brz,pn %g1,.L11 + sub %g1,4,%g1 +.L10: + lduw [%o1+%g1],%g2 + subccc %g2,%g0,%g2 + stw %g2,[%o1+%g1] + brnz,pt %g1,.L10 + sub %g1,4,%g1 +.L11: + retl + movcs %icc,1,%o0 + + .align 8 + .globl mp32add + .type mp32add,@function + +mp32add: + sll %o0,2,%g1 + sub %g1,4,%g1 + addcc %g0,%g0,%o0 +.L20: + lduw [%o1+%g1],%g2 + lduw [%o2+%g1],%g3 + addccc %g2,%g3,%g4 + stw %g4,[%o1+%g1] + brnz,pt %g1,.L20 + sub %g1,4,%g1 + retl + movcs %icc,1,%o0 + + .align 8 + .globl mp32sub + .type mp32sub,@function + +mp32sub: + sll %o0,2,%g1 + sub %g1,4,%g1 + addcc %g0,%g0,%o0 +.L30: + lduw [%o1+%g1],%g2 + lduw [%o2+%g1],%g3 + subccc %g2,%g3,%g4 + stw %g4,[%o1+%g1] + brnz,pt %g1,.L30 + sub %g1,4,%g1 + retl + movcs %icc,1,%o0 + + .align 8 + .globl mp32setmul + .type mp32setmul,@function + +mp32setmul: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 +.L40: + lduw [%o2+%g1],%g2 + mulx %o3,%g2,%g3 + add %o0,%g3,%o0 + stw %o0,[%o1+%g1] + srlx %o0,32,%o0 + brnz,pt %g1,.L40 + sub %g1,4,%g1 + retl + nop + + .align 8 + .globl mp32addmul + .type mp32addmul,@function + +mp32addmul: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 +.L50: + lduw [%o2+%g1],%g2 + lduw [%o1+%g1],%g4 + mulx %o3,%g2,%g3 + add %o0,%g3,%o0 + add %o0,%g4,%o0 + stw %o0,[%o1+%g1] + srlx %o0,32,%o0 + brnz,pt %g1,.L50 + sub %g1,4,%g1 + retl + nop + + .align 8 + .globl mp32addsqrtrc + .type mp32addsqrtrc,@function + +mp32addsqrtrc: + sll %o0,2,%g1 + sub %g1,4,%g1 + add %o1,%g1,%o1 + add %o1,%g1,%o1 + mov %g0,%o0 + +.L60: + /* 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 + mulx %g2,%g2,%g2 + add %o0,%g4,%g3 + add %g3,%g2,%g3 + cmp %g4,%g3 + or %g0,0,%o0 + movgu %xcc,1,%o0 + stx %g3,[%o1] + sub %o1,8,%o1 + brnz,pt %g1,.L60 + sub %g1,4,%g1 + retl + nop diff --git a/beecrypt/gnu/mp32opt.gas.sparcv9.s b/beecrypt/gnu/mp32opt.gas.sparcv9.s new file mode 100644 index 0000000..50e0ed4 --- /dev/null +++ b/beecrypt/gnu/mp32opt.gas.sparcv9.s @@ -0,0 +1,189 @@ +# +# mp32opt.gas.sparcv9.s +# +# Assembler optimized multiprecision integer routines for UltraSparc (64 bits instructions, will run on 32 bit OS) +# +# Compile target is GNU AS +# +# Copyright (c) 1998-2000 Virtual Unlimited B.V. +# +# Author: 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 +# + + .file "mp32opt.gas.sparcv9.s" + + .section ".text" + + .align 4 + .globl mp32addw + .type mp32addw,@function + +# INPUT PARAMETERS +# size %o0 +# data %o1 +# addw %o2 + +mp32addw: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 + lduw [%o1+%g1],%g2 + addcc %g2,%o2,%g2 + stw %g2,[%o1+%g1] + brz,pn %g1,.L01 + sub %g1,4,%g1 +.L00: + lduw [%o1+%g1],%g2 + addccc %g2,%g0,%g2 + stw %g2,[%o1+%g1] + brnz,pt %g1,.L00 + sub %g1,4,%g1 +.L01: + retl + movcs %icc,1,%o0 + + .align 4 + .globl mp32subw + .type mp32subw,@function + +mp32subw: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 + lduw [%o1+%g1],%g2 + subcc %g2,%o2,%g2 + stw %g2,[%o1+%g1] + brz,pn %g1,.L11 + sub %g1,4,%g1 +.L10: + lduw [%o1+%g1],%g2 + subccc %g2,%g0,%g2 + stw %g2,[%o1+%g1] + brnz,pt %g1,.L10 + sub %g1,4,%g1 +.L11: + retl + movcs %icc,1,%o0 + + .align 4 + .globl mp32add + .type mp32add,@function + +mp32add: + sll %o0,2,%g1 + sub %g1,4,%g1 + addcc %g0,%g0,%o0 +.L20: + lduw [%o1+%g1],%g2 + lduw [%o2+%g1],%g3 + addccc %g2,%g3,%g4 + stw %g4,[%o1+%g1] + brnz,pt %g1,.L20 + sub %g1,4,%g1 + retl + movcs %icc,1,%o0 + + .align 4 + .globl mp32sub + .type mp32sub,@function + +mp32sub: + sll %o0,2,%g1 + sub %g1,4,%g1 + addcc %g0,%g0,%o0 +.L30: + lduw [%o1+%g1],%g2 + lduw [%o2+%g1],%g3 + subccc %g2,%g3,%g4 + stw %g4,[%o1+%g1] + brnz,pt %g1,.L30 + sub %g1,4,%g1 + retl + movcs %icc,1,%o0 + + .align 4 + .globl mp32setmul + .type mp32setmul,@function + +mp32setmul: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 +.L40: + lduw [%o2+%g1],%g2 + mulx %o3,%g2,%g3 + add %o0,%g3,%o0 + stw %o0,[%o1+%g1] + srlx %o0,32,%o0 + brnz,pt %g1,.L40 + sub %g1,4,%g1 + retl + nop + + .align 4 + .globl mp32addmul + .type mp32addmul,@function + +mp32addmul: + sll %o0,2,%g1 + sub %g1,4,%g1 + mov %g0,%o0 +.L50: + lduw [%o2+%g1],%g2 + lduw [%o1+%g1],%g4 + mulx %o3,%g2,%g3 + add %o0,%g3,%o0 + add %o0,%g4,%o0 + stw %o0,[%o1+%g1] + srlx %o0,32,%o0 + brnz,pt %g1,.L50 + sub %g1,4,%g1 + retl + nop + +.if 0 + # not finished ! + .align 4 + .globl mp32addsqrtrc + .type mp32addsqrtrc,@function + +mp32addsqrtrc: + sll %o0,2,%g1 + add %o1,%g1,%o1 + sub %g1,4,%g1 + add %o1,%g1,%o1 + mov %g0,%o0 + +.L60: + lduw [%o2+%g1],%g2 + lduw [%o1],%g4 + mulx %g2,%g2,%g3 + add %o0,%g3,%o0 + add %o0,%g4,%o0 + stw %o0,[%o1] + sub %o1,4,%o1 + srlx %o0,32,%o0 + lduw [%o1],%g4 + add %o0,%g4,%g0 + stw %o0,[%o1] + sub %o1,4,%o1 + srlx %o0,32,%o0 + brnz,pt %g1,.L60 + sub %g1,4,%g1 + retl + nop +.endif diff --git a/beecrypt/hmac.c b/beecrypt/hmac.c new file mode 100644 index 0000000..80b6858 --- /dev/null +++ b/beecrypt/hmac.c @@ -0,0 +1,102 @@ +/* + * hmac.c + * + * HMAC message authentication code, code + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "hmac.h" +#include "endianness.h" + +#define HMAC_IPAD 0x36363636 +#define HMAC_OPAD 0x5c5c5c5c + +int hmacSetup(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param, const uint32* key, int keybits) +{ + int keywords = keybits >> 5; + + if (keywords <= 16) + { + register int i; + + if (keywords > 0) + { + encodeInts((const javaint*) key, (byte*) hp->kxi, keywords); + encodeInts((const javaint*) key, (byte*) hp->kxo, keywords); + + for (i = 0; i < keywords; i++) + { + hp->kxi[i] ^= HMAC_IPAD; + hp->kxo[i] ^= HMAC_OPAD; + } + } + + for (i = keywords; i < 16; i++) + { + hp->kxi[i] = HMAC_IPAD; + hp->kxo[i] = HMAC_OPAD; + } + + return hmacReset(hp, hash, param); + } + + /* key too long */ + + return -1; +} + +int hmacReset(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param) +{ + if (hash->reset(param)) + return -1; + + if (hash->update(param, (const byte*) hp->kxi, 64)) + return -1; + + return 0; +} + +int hmacUpdate(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param, const byte* data, int size) +{ + return hash->update(param, data, size); +} + +int hmacDigest(hmacParam* hp, const hashFunction* hash, hashFunctionParam* param, uint32* data) +{ + if (hash->digest(param, data)) + return -1; + + if (hash->update(param, (const byte*) hp->kxo, 64)) + return -1; + + /* digestsize is in bytes; divide by 4 to get the number of words */ + encodeInts((const javaint*) data, (byte*) data, hash->digestsize >> 2); + + if (hash->update(param, (const byte*) data, hash->digestsize)) + return -1; + + if (hash->digest(param, data)) + return -1; + + return 0; +} diff --git a/beecrypt/hmac.h b/beecrypt/hmac.h new file mode 100644 index 0000000..540e285 --- /dev/null +++ b/beecrypt/hmac.h @@ -0,0 +1,56 @@ +/* + * hmac.h + * + * HMAC message authentication code, header + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 _HMAC_H +#define _HMAC_H + +#include "beecrypt.h" + +typedef struct +{ + uint32 kxi[16]; + uint32 kxo[16]; +} hmacParam; + +#ifdef __cplusplus +extern "C" { +#endif + +/* not used directly as keyed hash function, but instead used as generic methods */ + +BEEDLLAPI +int hmacSetup (hmacParam*, const hashFunction*, hashFunctionParam*, const uint32*, int); +BEEDLLAPI +int hmacReset (hmacParam*, const hashFunction*, hashFunctionParam*); +BEEDLLAPI +int hmacUpdate(hmacParam*, const hashFunction*, hashFunctionParam*, const byte*, int); +BEEDLLAPI +int hmacDigest(hmacParam*, const hashFunction*, hashFunctionParam*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/hmacmd5.c b/beecrypt/hmacmd5.c new file mode 100644 index 0000000..8dbdfe2 --- /dev/null +++ b/beecrypt/hmacmd5.c @@ -0,0 +1,50 @@ +/* + * hmacmd5.c + * + * HMAC-MD5 message authentication code, code + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "hmacmd5.h" + +const keyedHashFunction hmacmd5 = { "HMAC-MD5", sizeof(hmacmd5Param), 64, 4 * sizeof(uint32), 64, 512, 32, (const keyedHashFunctionSetup) hmacmd5Setup, (const keyedHashFunctionReset) hmacmd5Reset, (const keyedHashFunctionUpdate) hmacmd5Update, (const keyedHashFunctionDigest) hmacmd5Digest }; + +int hmacmd5Setup (hmacmd5Param* sp, const uint32* key, int keybits) +{ + return hmacSetup((hmacParam*) sp, &md5, &sp->param, key, keybits); +} + +int hmacmd5Reset (hmacmd5Param* sp) +{ + return hmacReset((hmacParam*) sp, &md5, &sp->param); +} + +int hmacmd5Update(hmacmd5Param* sp, const byte* data, int size) +{ + return hmacUpdate((hmacParam*) sp, &md5, &sp->param, data, size); +} + +int hmacmd5Digest(hmacmd5Param* sp, uint32* data) +{ + return hmacDigest((hmacParam*) sp, &md5, &sp->param, data); +} diff --git a/beecrypt/hmacmd5.h b/beecrypt/hmacmd5.h new file mode 100644 index 0000000..541847a --- /dev/null +++ b/beecrypt/hmacmd5.h @@ -0,0 +1,58 @@ +/* + * hmacmd5.h + * + * HMAC-MD5 message authentication code, header + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 _HMACMD5_H +#define _HMACMD5_H + +#include "hmac.h" +#include "md5.h" + +typedef struct +{ + byte kxi[64]; + byte kxo[64]; + md5Param param; +} hmacmd5Param; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const keyedHashFunction hmacmd5; + +BEEDLLAPI +int hmacmd5Setup (hmacmd5Param*, const uint32*, int); +BEEDLLAPI +int hmacmd5Reset (hmacmd5Param*); +BEEDLLAPI +int hmacmd5Update(hmacmd5Param*, const byte*, int); +BEEDLLAPI +int hmacmd5Digest(hmacmd5Param*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/hmacsha1.c b/beecrypt/hmacsha1.c new file mode 100644 index 0000000..8a90d24 --- /dev/null +++ b/beecrypt/hmacsha1.c @@ -0,0 +1,50 @@ +/* + * hmacsha1.c + * + * HMAC-SHA-1 message authentication code, code + * + * Copyright (c) 1999, 2000, 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "hmacsha1.h" + +const keyedHashFunction hmacsha1 = { "HMAC-SHA-1", sizeof(hmacsha1Param), 64, 5 * sizeof(uint32), 64, 512, 32, (const keyedHashFunctionSetup) hmacsha1Setup, (const keyedHashFunctionReset) hmacsha1Reset, (const keyedHashFunctionUpdate) hmacsha1Update, (const keyedHashFunctionDigest) hmacsha1Digest }; + +int hmacsha1Setup (hmacsha1Param* sp, const uint32* key, int keybits) +{ + return hmacSetup((hmacParam*) sp, &sha1, &sp->param, key, keybits); +} + +int hmacsha1Reset (hmacsha1Param* sp) +{ + return hmacReset((hmacParam*) sp, &sha1, &sp->param); +} + +int hmacsha1Update(hmacsha1Param* sp, const byte* data, int size) +{ + return hmacUpdate((hmacParam*) sp, &sha1, &sp->param, data, size); +} + +int hmacsha1Digest(hmacsha1Param* sp, uint32* data) +{ + return hmacDigest((hmacParam*) sp, &sha1, &sp->param, data); +} diff --git a/beecrypt/hmacsha1.h b/beecrypt/hmacsha1.h new file mode 100644 index 0000000..dab8000 --- /dev/null +++ b/beecrypt/hmacsha1.h @@ -0,0 +1,58 @@ +/* + * hmacsha1.h + * + * HMAC-SHA-1 message authentication code, header + * + * Copyright (c) 1999, 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 _HMACSHA1_H +#define _HMACSHA1_H + +#include "hmac.h" +#include "fips180.h" + +typedef struct +{ + byte kxi[64]; + byte kxo[64]; + sha1Param param; +} hmacsha1Param; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const keyedHashFunction hmacsha1; + +BEEDLLAPI +int hmacsha1Setup (hmacsha1Param*, const uint32*, int); +BEEDLLAPI +int hmacsha1Reset (hmacsha1Param*); +BEEDLLAPI +int hmacsha1Update(hmacsha1Param*, const byte*, int); +BEEDLLAPI +int hmacsha1Digest(hmacsha1Param*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/hmacsha256.c b/beecrypt/hmacsha256.c new file mode 100644 index 0000000..b70d0fc --- /dev/null +++ b/beecrypt/hmacsha256.c @@ -0,0 +1,50 @@ +/* + * hmacsha256.c + * + * HMAC-SHA-256 message authentication code, code + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "hmacsha256.h" + +const keyedHashFunction hmacsha256 = { "HMAC-SHA-256", sizeof(hmacsha256Param), 64, 8 * sizeof(uint32), 64, 512, 32, (const keyedHashFunctionSetup) hmacsha256Setup, (const keyedHashFunctionReset) hmacsha256Reset, (const keyedHashFunctionUpdate) hmacsha256Update, (const keyedHashFunctionDigest) hmacsha256Digest }; + +int hmacsha256Setup (hmacsha256Param* sp, const uint32* key, int keybits) +{ + return hmacSetup((hmacParam*) sp, &sha256, &sp->param, key, keybits); +} + +int hmacsha256Reset (hmacsha256Param* sp) +{ + return hmacReset((hmacParam*) sp, &sha256, &sp->param); +} + +int hmacsha256Update(hmacsha256Param* sp, const byte* data, int size) +{ + return hmacUpdate((hmacParam*) sp, &sha256, &sp->param, data, size); +} + +int hmacsha256Digest(hmacsha256Param* sp, uint32* data) +{ + return hmacDigest((hmacParam*) sp, &sha256, &sp->param, data); +} diff --git a/beecrypt/hmacsha256.h b/beecrypt/hmacsha256.h new file mode 100644 index 0000000..e59a332 --- /dev/null +++ b/beecrypt/hmacsha256.h @@ -0,0 +1,58 @@ +/* + * hmacsha256.h + * + * HMAC-SHA-256 message authentication code, header + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 _HMACSHA256_H +#define _HMACSHA256_H + +#include "hmac.h" +#include "sha256.h" + +typedef struct +{ + byte kxi[64]; + byte kxo[64]; + sha256Param param; +} hmacsha256Param; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const keyedHashFunction hmacsha256; + +BEEDLLAPI +int hmacsha256Setup (hmacsha256Param*, const uint32*, int); +BEEDLLAPI +int hmacsha256Reset (hmacsha256Param*); +BEEDLLAPI +int hmacsha256Update(hmacsha256Param*, const byte*, int); +BEEDLLAPI +int hmacsha256Digest(hmacsha256Param*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/install-sh b/beecrypt/install-sh new file mode 100755 index 0000000..67c9429 --- /dev/null +++ b/beecrypt/install-sh @@ -0,0 +1,238 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. +# + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f "$src" -o -d "$src" ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd "$src" $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/beecrypt/javaglue.c b/beecrypt/javaglue.c new file mode 100644 index 0000000..1585dca --- /dev/null +++ b/beecrypt/javaglue.c @@ -0,0 +1,710 @@ +#define BEECRYPT_DLL_EXPORT + +#include "beecrypt.h" +#include "blockmode.h" + +#if JAVAGLUE + +#if HAVE_STDLIB_H +# include +#endif + +#include "javaglue.h" + +static const char* JAVA_OUT_OF_MEMORY_ERROR = "java/lang/OutOfMemoryError"; +static const char* JAVA_PROVIDER_EXCEPTION = "java/security/ProviderException"; +static const char* JAVA_INVALID_KEY_EXCEPTION = "java/security/InvalidKeyException"; +static const char* MSG_OUT_OF_MEMORY = "out of memory"; +static const char* MSG_NO_SUCH_ALGORITHM = "algorithm not available"; +static const char* MSG_NO_ENTROPY_SOURCE = "no entropy source"; +static const char* MSG_INVALID_KEY = "invalid key"; + +/* NativeMessageDigest */ + +jlong JNICALL Java_com_beeyond_security_NativeMessageDigest_find(JNIEnv* env, jclass dummy, jstring algorithm) +{ + const char* name = (*env)->GetStringUTFChars(env, algorithm, (jboolean*) 0); + const hashFunction* hash = hashFunctionFind(name); + (*env)->ReleaseStringUTFChars(env, algorithm, name); + if (hash == (hashFunction*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); + if (ex != (jclass) 0) + (*env)->ThrowNew(env, ex, MSG_NO_SUCH_ALGORITHM); + } + return (jlong) hash; +} + +jlong JNICALL Java_com_beeyond_security_NativeMessageDigest_allocParam(JNIEnv* env, jclass dummy, jlong hash) +{ + void *param = malloc(((const hashFunction*) hash)->paramsize); + if (param == (void*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex != (jclass) 0) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + } + return (jlong) param; +} + +jlong JNICALL Java_com_beeyond_security_NativeMessageDigest_cloneParam(JNIEnv* env, jclass dummy, jlong hash, jlong param) +{ + unsigned int paramsize = ((const hashFunction*) hash)->paramsize; + void *clone = malloc(paramsize); + memcpy(clone, (void*) param, paramsize); + return (jlong) clone; +} + +void JNICALL Java_com_beeyond_security_NativeMessageDigest_freeParam(JNIEnv* env, jclass dummy, jlong param) +{ + if (param) + free((void*) param); +} + +void JNICALL Java_com_beeyond_security_NativeMessageDigest_reset(JNIEnv* env, jclass dummy, jlong hash, jlong param) +{ + ((const hashFunction*) hash)->reset((hashFunctionParam*) param); +} + +void JNICALL Java_com_beeyond_security_NativeMessageDigest_update(JNIEnv* env, jclass dummy, jlong hash, jlong param, jbyte input) +{ + ((const hashFunction*) hash)->update((hashFunctionParam*) param, (const byte*) &input, 1); +} + +void JNICALL Java_com_beeyond_security_NativeMessageDigest_updateBlock(JNIEnv* env, jclass dummy, jlong hash, jlong param, jbyteArray input, jint offset, jint len) +{ + jbyte* data = (*env)->GetByteArrayElements(env, input, (jboolean*) 0); + if (data == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, input, data, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + ((const hashFunction*) hash)->update((hashFunctionParam*) param, (const byte*) data+offset, len); + (*env)->ReleaseByteArrayElements(env, input, data, JNI_ABORT); +} + +jbyteArray JNICALL Java_com_beeyond_security_NativeMessageDigest_digest(JNIEnv* env, jclass dummy, jlong hash, jlong param) +{ + jbyteArray digestArray; + jbyte* digest; + + int digestsize = (jsize) ((const hashFunction*) hash)->digestsize; + int digestwords = digestsize >> 2; + + digestArray = (*env)->NewByteArray(env, digestsize); + digest = (*env)->GetByteArrayElements(env, digestArray, (jboolean*) 0); + + if (digest == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return (jbyteArray) 0; + } + + if (!WORDS_BIGENDIAN || (int) digest & 0x3) + { /* unaligned, or swap necessary */ + uint32* data = (uint32*) malloc(digestwords * sizeof(uint32)); + + if (data == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, digestArray, digest, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return (jbyteArray) 0; + } + + ((const hashFunction*) hash)->digest((hashFunctionParam*) param, data); + encodeInts((const javaint*) data, digest, digestwords); + free(data); + } + else + { /* aligned */ + ((const hashFunction*) hash)->digest((hashFunctionParam*) param, (uint32*) digest); + } + + (*env)->ReleaseByteArrayElements(env, digestArray, digest, 0); + + return digestArray; +} + +jint JNICALL Java_com_beeyond_security_NativeMessageDigest_digestLength(JNIEnv* env, jclass dummy, jlong hash) +{ + return (jint) ((const hashFunction*) hash)->digestsize; +} + +/* NativeSecureRandom */ + +jlong JNICALL Java_com_beeyond_security_NativeSecureRandom_find(JNIEnv* env, jclass dummy, jstring algorithm) +{ + const char* name = (*env)->GetStringUTFChars(env, algorithm, (jboolean*) 0); + const randomGenerator* prng = randomGeneratorFind(name); + (*env)->ReleaseStringUTFChars(env, algorithm, name); + if (prng == (randomGenerator*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); + if (ex) + (*env)->ThrowNew(env, ex, MSG_NO_SUCH_ALGORITHM); + } + return (jlong) prng; +} + +jlong JNICALL Java_com_beeyond_security_NativeSecureRandom_allocParam(JNIEnv* env, jclass dummy, jlong prng) +{ + void *param = malloc(((const randomGenerator*) prng)->paramsize); + if (param == (void*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + } + return (jlong) param; +} + +jlong JNICALL Java_com_beeyond_security_NativeSecureRandom_cloneParam(JNIEnv* env, jclass dummy, jlong prng, jlong param) +{ + unsigned int paramsize = ((const randomGenerator*) prng)->paramsize; + void *clone = malloc(paramsize); + memcpy(clone, (void*) param, paramsize); + return (jlong) clone; +} + +void JNICALL Java_com_beeyond_security_NativeSecureRandom_freeParam(JNIEnv* env, jclass dummy, jlong param) +{ + if (param) + free((void*) param); +} + +void JNICALL Java_com_beeyond_security_NativeSecureRandom_setup(JNIEnv* env, jclass dummy, jlong prng, jlong param) +{ + ((const randomGenerator*) prng)->setup((randomGeneratorParam*) param); +} + +void JNICALL Java_com_beeyond_security_NativeSecureRandom_setSeed(JNIEnv* env, jclass dummy, jlong prng, jlong param, jbyteArray seedArray) +{ + /* BeeCrypt takes size in words */ + jsize seedSize = (*env)->GetArrayLength(env, seedArray); + if (seedSize) + { + jbyte* seed = (*env)->GetByteArrayElements(env, seedArray, (jboolean*) 0); + if (seed == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + /* check memory alignment of seed and seedSize */ + if (((int) seed & 0x3) || (seedSize & 0x3)) + { /* unaligned */ + int size = (seedSize+3) >> 2; + uint32* data = (uint32*) malloc(size * sizeof(uint32)); + + if (data == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, seedArray, seed, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + decodeIntsPartial(data, seed, seedSize); + ((const randomGenerator*) prng)->seed((randomGeneratorParam*) param, data, size); + free(data); + } + else + { /* aligned and properly sized */ + ((const randomGenerator*) prng)->seed((randomGeneratorParam*) param, (uint32*) seed, seedSize >> 2); + } + + (*env)->ReleaseByteArrayElements(env, seedArray, seed, JNI_ABORT); + } +} + +void JNICALL Java_com_beeyond_security_NativeSecureRandom_nextBytes(JNIEnv* env, jclass dummy, jlong prng, jlong param, jbyteArray bytesArray) +{ + /* BeeCrypt takes size in words */ + jsize bytesSize = (*env)->GetArrayLength(env, bytesArray); + if (bytesSize) + { + jbyte* bytes = (*env)->GetByteArrayElements(env, bytesArray, (jboolean*) 0); + if (bytes == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + /* check memory alignment of bytes and bytesSize */ + if (((int) bytes & 0x3) || (bytesSize & 0x3)) + { /* unaligned */ + int size = (bytesSize+3) >> 2; + uint32* data = (uint32*) malloc(size * sizeof(uint32)); + + if (data == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, bytesArray, bytes, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + ((const randomGenerator*) prng)->next((randomGeneratorParam*) param, data, size); + memcpy(bytes, data, bytesSize); + free(data); + } + else + { /* aligned and properly sized */ + ((const randomGenerator*) prng)->next((randomGeneratorParam*) param, (uint32*) bytes, bytesSize >> 2); + } + + (*env)->ReleaseByteArrayElements(env, bytesArray, bytes, 0); + } +} + +void JNICALL Java_com_beeyond_security_NativeSecureRandom_generateSeed(JNIEnv* env, jclass dummy, jbyteArray seedArray) +{ + /* BeeCrypt takes size in words */ + jsize seedSize = (*env)->GetArrayLength(env, seedArray); + + if (seedSize) + { + jbyte* seed = (*env)->GetByteArrayElements(env, seedArray, (jboolean*) 0); + + const entropySource* ents = entropySourceDefault(); + + if (seed == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + if (ents == (entropySource*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); + (*env)->ReleaseByteArrayElements(env, seedArray, seed, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_NO_ENTROPY_SOURCE); + return; + } + + /* check memory alignment of seed and seedSize */ + if (((int) seed & 0x3) || (seedSize & 0x3)) + { /* unaligned */ + int size = (seedSize+3) >> 2; + uint32* data = (uint32*) malloc(size * sizeof(uint32)); + ents->next(data, size); + memcpy(seed, data, seedSize); + free(data); + } + else + { /* aligned */ + ents->next((uint32*) seed, seedSize >> 2); + } + + (*env)->ReleaseByteArrayElements(env, seedArray, seed, 0); + } +} + +/* NativeBlockCipher */ + +jlong JNICALL Java_com_beeyond_crypto_NativeBlockCipher_find(JNIEnv* env, jclass dummy, jstring algorithm) +{ + const char* name = (*env)->GetStringUTFChars(env, algorithm, (jboolean*) 0); + const blockCipher* ciph = blockCipherFind(name); + (*env)->ReleaseStringUTFChars(env, algorithm, name); + if (ciph == (blockCipher*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); + if (ex) + (*env)->ThrowNew(env, ex, MSG_NO_SUCH_ALGORITHM); + } + return (jlong) ciph; +} + +jlong JNICALL Java_com_beeyond_crypto_NativeBlockCipher_allocParam(JNIEnv* env, jclass dummy, jlong ciph) +{ + void *param = malloc(((const blockCipher*) ciph)->paramsize); + if (param == (void*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + } + return (jlong) param; +} + +void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_freeParam(JNIEnv* env, jclass dummy, jlong param) +{ + if (param) + free((void*) param); +} + +jint JNICALL Java_com_beeyond_crypto_NativeBlockCipher_getBlockSize(JNIEnv* env, jclass dummy, jlong ciph) +{ + return ((const blockCipher*) ciph)->blocksize; +} + +void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_setup(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jint mode, jbyteArray keyArray) +{ + /* BeeCrypt takes key in 32 bit words with size in bits */ + jsize keysize = (*env)->GetArrayLength(env, keyArray); + + if (keysize) + { + int rc; + cipherOperation nativeop; + jbyte* key; + + switch (mode) + { + case javax_crypto_Cipher_ENCRYPT_MODE: + nativeop = ENCRYPT; + break; + case javax_crypto_Cipher_DECRYPT_MODE: + nativeop = DECRYPT; + break; + } + + key = (*env)->GetByteArrayElements(env, keyArray, (jboolean*) 0); + if (key == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + if (!WORDS_BIGENDIAN || ((int) key & 0x3) || (keysize & 0x3)) + { /* unaligned */ + int size = (keysize + 3) >> 2; + uint32* data = (uint32*) malloc(size * sizeof(uint32)); + + if (data == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, keyArray, key, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + decodeIntsPartial(data, key, keysize); + rc = ((const blockCipher*) ciph)->setup((blockCipherParam*) param, data, keysize << 3, nativeop); + free(data); + } + else + { /* aligned and properly sized */ + rc = ((const blockCipher*) ciph)->setup((blockCipherParam*) param, (const uint32*) key, keysize << 3, nativeop); + } + + if (rc != 0) + { + jclass ex = (*env)->FindClass(env, JAVA_INVALID_KEY_EXCEPTION); + if (ex) + (*env)->ThrowNew(env, ex, MSG_INVALID_KEY); + } + + (*env)->ReleaseByteArrayElements(env, keyArray, key, JNI_ABORT); + } +} + +void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_setIV(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray ivArray) +{ + jsize ivsize = (*env)->GetArrayLength(env, ivArray); + + if (ivsize > 0) + { + jbyte* iv = (*env)->GetByteArrayElements(env, ivArray, (jboolean*) 0); + + if (iv == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + if (!WORDS_BIGENDIAN || ((int) iv & 0x3) || (ivsize & 0x3)) + { /* unaligned */ + int size = (ivsize + 3) >> 2; + uint32* data = (uint32*) malloc(size * sizeof(uint32)); + + if (data == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, ivArray, iv, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + decodeIntsPartial(data, iv, ivsize); + ((const blockCipher*) ciph)->setiv((blockCipherParam*) param, data); + free(data); + } + else + { /* aligned */ + ((const blockCipher*) ciph)->setiv((blockCipherParam*) param, (uint32*) iv); + } + (*env)->ReleaseByteArrayElements(env, ivArray, iv, JNI_ABORT); + } +} + +void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_encryptECB(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) +{ + jbyte* input; + jbyte* output; + + input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) + { /* unaligned */ + uint32* datain; + uint32* dataout; + + datain = (uint32*) malloc(blocks * sizeof(uint32)); + if (datain == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + dataout = (uint32*) malloc(blocks * sizeof(uint32)); + if (dataout == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + free(datain); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + memcpy(datain, input+inputOffset, blocks * sizeof(uint32)); + blockEncrypt((const blockCipher*) ciph, (blockCipherParam*) param, ECB, blocks, dataout, datain); + memcpy(output+outputOffset, dataout, blocks * sizeof(uint32)); + } + else + { /* aligned */ + blockEncrypt((const blockCipher*) ciph, (blockCipherParam*) param, ECB, blocks, (uint32*)(output+outputOffset), (uint32*) (input+inputOffset)); + } + + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); +} + +void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_decryptECB(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) +{ + jbyte* input; + jbyte* output; + + input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) + { /* unaligned */ + uint32* datain; + uint32* dataout; + + datain = (uint32*) malloc(blocks * sizeof(uint32)); + if (datain == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + dataout = (uint32*) malloc(blocks * sizeof(uint32)); + if (dataout == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + free(datain); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + memcpy(datain, input+inputOffset, blocks * sizeof(uint32)); + blockDecrypt((const blockCipher*) ciph, (blockCipherParam*) param, ECB, blocks, dataout, datain); + memcpy(output+outputOffset, dataout, blocks * sizeof(uint32)); + } + else + { /* aligned */ + blockDecrypt((const blockCipher*) ciph, (blockCipherParam*) param, ECB, blocks, (uint32*)(output+outputOffset), (uint32*) (input+inputOffset)); + } + + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); +} + +void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_encryptCBC(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) +{ + jbyte* input; + jbyte* output; + + input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) + { /* unaligned */ + uint32* datain; + uint32* dataout; + + datain = (uint32*) malloc(blocks * sizeof(uint32)); + if (datain == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + dataout = (uint32*) malloc(blocks * sizeof(uint32)); + if (dataout == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + free(datain); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + memcpy(datain, input+inputOffset, blocks * sizeof(uint32)); + blockEncrypt((const blockCipher*) ciph, (blockCipherParam*) param, CBC, blocks, dataout, datain); + memcpy(output+outputOffset, dataout, blocks * sizeof(uint32)); + } + else + { /* aligned */ + blockEncrypt((const blockCipher*) ciph, (blockCipherParam*) param, CBC, blocks, (uint32*)(output+outputOffset), (uint32*) (input+inputOffset)); + } + + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); +} + +void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_decryptCBC(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) +{ + jbyte* input; + jbyte* output; + + input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); + if (input == (jbyte*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + + if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) + { /* unaligned */ + uint32* datain; + uint32* dataout; + + datain = (uint32*) malloc(blocks * sizeof(uint32)); + if (datain == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + dataout = (uint32*) malloc(blocks * sizeof(uint32)); + if (dataout == (uint32*) 0) + { + jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); + free(datain); + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); + if (ex) + (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); + return; + } + memcpy(datain, input+inputOffset, blocks * sizeof(uint32)); + blockDecrypt((const blockCipher*) ciph, (blockCipherParam*) param, CBC, blocks, dataout, datain); + memcpy(output+outputOffset, dataout, blocks * sizeof(uint32)); + } + else + { /* aligned */ + blockDecrypt((const blockCipher*) ciph, (blockCipherParam*) param, CBC, blocks, (uint32*)(output+outputOffset), (uint32*) (input+inputOffset)); + } + + (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); +} + +#endif diff --git a/beecrypt/javaglue.h b/beecrypt/javaglue.h new file mode 100644 index 0000000..883b199 --- /dev/null +++ b/beecrypt/javaglue.h @@ -0,0 +1,277 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class javax_crypto_Cipher */ + +#ifndef _Included_javax_crypto_Cipher +#define _Included_javax_crypto_Cipher +#ifdef __cplusplus +extern "C" { +#endif +#undef javax_crypto_Cipher_ENCRYPT_MODE +#define javax_crypto_Cipher_ENCRYPT_MODE 1L +#undef javax_crypto_Cipher_DECRYPT_MODE +#define javax_crypto_Cipher_DECRYPT_MODE 2L +#ifdef __cplusplus +} +#endif +#endif +/* Header for class com_beeyond_security_NativeMessageDigest */ + +#ifndef _Included_com_beeyond_security_NativeMessageDigest +#define _Included_com_beeyond_security_NativeMessageDigest +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: find + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_security_NativeMessageDigest_find + (JNIEnv *, jclass, jstring); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: allocParam + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_security_NativeMessageDigest_allocParam + (JNIEnv *, jclass, jlong); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: cloneParam + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_security_NativeMessageDigest_cloneParam + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: freeParam + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeMessageDigest_freeParam + (JNIEnv *, jclass, jlong); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: reset + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeMessageDigest_reset + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: update + * Signature: (JJB)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeMessageDigest_update + (JNIEnv *, jclass, jlong, jlong, jbyte); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: updateBlock + * Signature: (JJ[BII)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeMessageDigest_updateBlock + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jint); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: digest + * Signature: (JJ)[B + */ +JNIEXPORT jbyteArray JNICALL Java_com_beeyond_security_NativeMessageDigest_digest + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: com_beeyond_security_NativeMessageDigest + * Method: digestLength + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_com_beeyond_security_NativeMessageDigest_digestLength + (JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class com_beeyond_security_NativeSecureRandom */ + +#ifndef _Included_com_beeyond_security_NativeSecureRandom +#define _Included_com_beeyond_security_NativeSecureRandom +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: find + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_security_NativeSecureRandom_find + (JNIEnv *, jclass, jstring); + +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: allocParam + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_security_NativeSecureRandom_allocParam + (JNIEnv *, jclass, jlong); + +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: cloneParam + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_security_NativeSecureRandom_cloneParam + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: freeParam + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeSecureRandom_freeParam + (JNIEnv *, jclass, jlong); + +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: setup + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeSecureRandom_setup + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: setSeed + * Signature: (JJ[B)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeSecureRandom_setSeed + (JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: nextBytes + * Signature: (JJ[B)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeSecureRandom_nextBytes + (JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: com_beeyond_security_NativeSecureRandom + * Method: generateSeed + * Signature: ([B)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_security_NativeSecureRandom_generateSeed + (JNIEnv *, jclass, jbyteArray); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class com_beeyond_crypto_NativeBlockCipher */ + +#ifndef _Included_com_beeyond_crypto_NativeBlockCipher +#define _Included_com_beeyond_crypto_NativeBlockCipher +#ifdef __cplusplus +extern "C" { +#endif +#undef com_beeyond_crypto_NativeBlockCipher_MODE_ECB +#define com_beeyond_crypto_NativeBlockCipher_MODE_ECB 0L +#undef com_beeyond_crypto_NativeBlockCipher_MODE_CBC +#define com_beeyond_crypto_NativeBlockCipher_MODE_CBC 1L +/* Inaccessible static: MODES */ +#undef com_beeyond_crypto_NativeBlockCipher_PADDING_NOPADDING +#define com_beeyond_crypto_NativeBlockCipher_PADDING_NOPADDING 0L +#undef com_beeyond_crypto_NativeBlockCipher_PADDING_PKCS5 +#define com_beeyond_crypto_NativeBlockCipher_PADDING_PKCS5 1L +/* Inaccessible static: PADDINGS */ +/* Inaccessible static: class_00024javax_00024crypto_00024spec_00024IvParameterSpec */ +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: find + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_crypto_NativeBlockCipher_find + (JNIEnv *, jclass, jstring); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: allocParam + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_com_beeyond_crypto_NativeBlockCipher_allocParam + (JNIEnv *, jclass, jlong); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: freeParam + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_freeParam + (JNIEnv *, jclass, jlong); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: getBlockSize + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_com_beeyond_crypto_NativeBlockCipher_getBlockSize + (JNIEnv *, jclass, jlong); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: setup + * Signature: (JJI[B)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_setup + (JNIEnv *, jclass, jlong, jlong, jint, jbyteArray); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: setIV + * Signature: (JJ[B)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_setIV + (JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: encryptECB + * Signature: (JJ[BI[BII)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_encryptECB + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: decryptECB + * Signature: (JJ[BI[BII)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_decryptECB + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: encryptCBC + * Signature: (JJ[BI[BII)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_encryptCBC + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); + +/* + * Class: com_beeyond_crypto_NativeBlockCipher + * Method: decryptCBC + * Signature: (JJ[BI[BII)V + */ +JNIEXPORT void JNICALL Java_com_beeyond_crypto_NativeBlockCipher_decryptCBC + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/beecrypt/ltconfig b/beecrypt/ltconfig new file mode 100755 index 0000000..c14d83c --- /dev/null +++ b/beecrypt/ltconfig @@ -0,0 +1,3114 @@ +#! /bin/sh + +# ltconfig - Create a system-specific libtool. +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A lot of this script is taken from autoconf-2.10. + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} +echo=echo +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec "$SHELL" "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null`} + case X$UNAME in + *-DOS) PATH_SEPARATOR=';' ;; + *) PATH_SEPARATOR=':' ;; + esac +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" != 'X\t' || + test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running ltconfig again with it. + ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}" + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf "%s\n"' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # Cool, printf works + : + elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL" + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# The name of this program. +progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` + +# Constants: +PROGRAM=ltconfig +PACKAGE=libtool +VERSION=1.3.5 +TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)" +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +rm="rm -f" + +help="Try \`$progname --help' for more information." + +# Global variables: +default_ofile=libtool +can_build_shared=yes +enable_shared=yes +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +enable_static=yes +enable_fast_install=yes +enable_dlopen=unknown +enable_win32_dll=no +ltmain= +silent= +srcdir= +ac_config_guess= +ac_config_sub= +host= +nonopt= +ofile="$default_ofile" +verify_host=yes +with_gcc=no +with_gnu_ld=no +need_locks=yes +ac_ext=c +objext=o +libext=a +exeext= +cache_file= + +old_AR="$AR" +old_CC="$CC" +old_CFLAGS="$CFLAGS" +old_CPPFLAGS="$CPPFLAGS" +old_LDFLAGS="$LDFLAGS" +old_LD="$LD" +old_LN_S="$LN_S" +old_LIBS="$LIBS" +old_NM="$NM" +old_RANLIB="$RANLIB" +old_DLLTOOL="$DLLTOOL" +old_OBJDUMP="$OBJDUMP" +old_AS="$AS" + +# Parse the command line options. +args= +prev= +for option +do + case "$option" in + -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$option" + prev= + continue + fi + + case "$option" in + --help) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + if test -z "$ltmain"; then + ltmain="$option" + elif test -z "$host"; then +# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 +# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then +# echo "$progname: warning \`$option' is not a valid host type" 1>&2 +# fi + host="$option" + else + echo "$progname: too many arguments" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac +done + +if test -z "$ltmain"; then + echo "$progname: you must specify a LTMAIN file" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +if test ! -f "$ltmain"; then + echo "$progname: \`$ltmain' does not exist" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +# Quote any args containing shell metacharacters. +ltconfig_args= +for arg +do + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ltconfig_args="$ltconfig_args '$arg'" ;; + *) ltconfig_args="$ltconfig_args $arg" ;; + esac +done + +# A relevant subset of AC_INIT. + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 5 compiler messages saved in config.log +# 6 checking for... messages and results +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>>./config.log + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi +if test "X${LANG+set}" = Xset; then LANG=C; export LANG; fi + +if test -n "$cache_file" && test -r "$cache_file"; then + echo "loading cache $cache_file within ltconfig" + . $cache_file +fi + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + +if test -z "$srcdir"; then + # Assume the source directory is the same one as the path to LTMAIN. + srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'` + test "$srcdir" = "$ltmain" && srcdir=. +fi + +trap "$rm conftest*; exit 1" 1 2 15 +if test "$verify_host" = yes; then + # Check for config.guess and config.sub. + ac_aux_dir= + for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/config.guess; then + ac_aux_dir=$ac_dir + break + fi + done + if test -z "$ac_aux_dir"; then + echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 + echo "$help" 1>&2 + exit 1 + fi + ac_config_guess=$ac_aux_dir/config.guess + ac_config_sub=$ac_aux_dir/config.sub + + # Make sure we can run config.sub. + if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then : + else + echo "$progname: cannot run $ac_config_sub" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + echo $ac_n "checking host system type""... $ac_c" 1>&6 + + host_alias=$host + case "$host_alias" in + "") + if host_alias=`$SHELL $ac_config_guess`; then : + else + echo "$progname: cannot guess host type; you must specify one" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac + host=`$SHELL $ac_config_sub $host_alias` + echo "$ac_t$host" 1>&6 + + # Make sure the host verified. + test -z "$host" && exit 1 + +elif test -z "$host"; then + echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 + echo "$help" 1>&2 + exit 1 +else + host_alias=$host +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case "$host_os" in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +case "$host_os" in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR cru $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +# Set a sane default for `AR'. +test -z "$AR" && AR=ar + +# Set a sane default for `OBJDUMP'. +test -z "$OBJDUMP" && OBJDUMP=objdump + +# If RANLIB is not set, then run the test. +if test "${RANLIB+set}" != "set"; then + result=no + + echo $ac_n "checking for ranlib... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then + RANLIB="ranlib" + result="ranlib" + break + fi + done + IFS="$save_ifs" + + echo "$ac_t$result" 1>&6 +fi + +if test -n "$RANLIB"; then + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" +fi + +# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin. +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$AS" && AS=as + +# Check to see if we are using GCC. +if test "$with_gcc" != yes || test -z "$CC"; then + # If CC is not set, then try to find GCC or a usable CC. + if test -z "$CC"; then + echo $ac_n "checking for gcc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then + CC="gcc" + break + fi + done + IFS="$save_ifs" + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + fi + + # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". + if test -z "$CC"; then + echo $ac_n "checking for cc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + cc_rejected=no + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/cc || test -f $dir/cc$ac_exeext; then + if test "$dir/cc" = "/usr/ucb/cc"; then + cc_rejected=yes + continue + fi + CC="cc" + break + fi + done + IFS="$save_ifs" + if test $cc_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same name, so the bogon will be chosen + # first if we set CC to just the name; use the full file name. + shift + set dummy "$dir/cc" "$@" + shift + CC="$@" + fi + fi + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$CC"; then + echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 + exit 1 + fi + fi + + # Now see if the compiler is really GCC. + with_gcc=no + echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 + echo "$progname:581: checking whether we are using GNU C" >&5 + + $rm conftest.c + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + with_gcc=yes + fi + $rm conftest.c + echo "$ac_t$with_gcc" 1>&6 +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +echo $ac_n "checking for object suffix... $ac_c" 1>&6 +$rm conftest* +echo 'int i = 1;' > conftest.c +echo "$progname:603: checking for object suffix" >& 5 +if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c) ;; + *) objext=`echo $ac_file | sed -e s/conftest.//` ;; + esac + done +else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 +fi +$rm conftest* +echo "$ac_t$objext" 1>&6 + +echo $ac_n "checking for executable suffix... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_exeext="no" + $rm conftest* + echo 'main () { return 0; }' > conftest.c + echo "$progname:629: checking for executable suffix" >& 5 + if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c | *.err | *.$objext ) ;; + *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;; + esac + done + else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* +fi +if test "X$ac_cv_exeext" = Xno; then + exeext="" +else + exeext="$ac_cv_exeext" +fi +echo "$ac_t$ac_cv_exeext" 1>&6 + +echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 +pic_flag= +special_shlib_compile_flags= +wl= +link_static_flag= +no_builtin_flag= + +if test "$with_gcc" = yes; then + wl='-Wl,' + link_static_flag='-static' + + case "$host_os" in + beos* | irix5* | irix6* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + aix*) + # Below there is a dirty hack to force normal static linking with -ldl + # The problem is because libdl dynamically linked with both libc and + # libC (AIX C++ library), which obviously doesn't included in libraries + # list by gcc. This cause undefined symbols with -static flags. + # This hack allows C programs to be linked with "-static -ldl", but + # we not sure about C++ programs. + link_static_flag="$link_static_flag ${wl}-lC" + ;; + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + pic_flag='-m68020 -resident32 -malways-restore-a4' + ;; + sysv4*MP*) + if test -d /usr/nec; then + pic_flag=-Kconform_pic + fi + ;; + *) + pic_flag='-fPIC' + ;; + esac +else + # PORTME Check for PIC flags for the system compiler. + case "$host_os" in + aix3* | aix4*) + # All AIX code is PIC. + link_static_flag='-bnso -bI:/lib/syscalls.exp' + ;; + + hpux9* | hpux10* | hpux11*) + # Is there a better link_static_flag that works with the bundled CC? + wl='-Wl,' + link_static_flag="${wl}-a ${wl}archive" + pic_flag='+Z' + ;; + + irix5* | irix6*) + wl='-Wl,' + link_static_flag='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + wl='-Wl,' + link_static_flag='-non_shared' + ;; + + sco3.2v5*) + pic_flag='-Kpic' + link_static_flag='-dn' + special_shlib_compile_flags='-belf' + ;; + + solaris*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + sunos4*) + pic_flag='-PIC' + link_static_flag='-Bstatic' + wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + uts4*) + pic_flag='-pic' + link_static_flag='-Bstatic' + ;; + sysv4*MP*) + if test -d /usr/nec ;then + pic_flag='-Kconform_pic' + link_static_flag='-Bstatic' + fi + ;; + *) + can_build_shared=no + ;; + esac +fi + +if test -n "$pic_flag"; then + echo "$ac_t$pic_flag" 1>&6 + + # Check to make sure the pic_flag actually works. + echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $pic_flag -DPIC" + echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5 + if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + case "$host_os" in + hpux9* | hpux10* | hpux11*) + # On HP-UX, both CC and GCC only warn that PIC is supported... then they + # create non-PIC objects. So, if there were any warnings, we assume that + # PIC is not supported. + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + can_build_shared=no + pic_flag= + else + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + fi + ;; + *) + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + ;; + esac + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + can_build_shared=no + pic_flag= + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + echo "$ac_t"none 1>&6 +fi + +# Check to see if options -o and -c are simultaneously supported by compiler +echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6 +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +$rm conftest* +echo "int some_variable = 0;" > conftest.c +mkdir out +# According to Tom Tromey, Ian Lance Taylor reported there are C compilers +# that will create temporary files in the current directory regardless of +# the output directory. Thus, making CWD read-only will cause this test +# to fail, enabling locking or at least warning the user not to do parallel +# builds. +chmod -w . +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -o out/conftest2.o" +echo "$progname:829: checking if $compiler supports -c -o file.o" >&5 +if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s out/conftest.err; then + echo "$ac_t"no 1>&6 + compiler_c_o=no + else + echo "$ac_t"yes 1>&6 + compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&5 + compiler_c_o=no + echo "$ac_t"no 1>&6 +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5 +if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_o_lo=no + else + echo "$ac_t"yes 1>&6 + compiler_o_lo=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_o_lo=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + compiler_o_lo=no +fi + +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$ac_t$hard_links" 1>&6 + $rm conftest* + if test "$hard_links" = no; then + echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2 + need_locks=warn + fi +else + need_locks=no +fi + +if test "$with_gcc" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c" + echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_rtti_exceptions=no + else + echo "$ac_t"yes 1>&6 + compiler_rtti_exceptions=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_rtti_exceptions=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi + +fi + +# Check for any special shared library compilation flags. +if test -n "$special_shlib_compile_flags"; then + echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : + else + echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 + can_build_shared=no + fi +fi + +echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6 +$rm conftest* +echo 'main(){return(0);}' > conftest.c +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS $link_static_flag" +echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5 +if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + echo "$ac_t$link_static_flag" 1>&6 +else + echo "$ac_t"none 1>&6 + link_static_flag= +fi +LDFLAGS="$save_LDFLAGS" +$rm conftest* + +if test -z "$LN_S"; then + # Check to see if we can use ln -s, or we need hard links. + echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 + $rm conftest.dat + if ln -s X conftest.dat 2>/dev/null; then + $rm conftest.dat + LN_S="ln -s" + else + LN_S=ln + fi + if test "$LN_S" = "ln -s"; then + echo "$ac_t"yes 1>&6 + else + echo "$ac_t"no 1>&6 + fi +fi + +# Make sure LD is an absolute path. +if test -z "$LD"; then + ac_prog=ld + if test "$with_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 + echo "$progname:991: checking for ld used by GCC" >&5 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we are not using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld... $ac_c" 1>&6 + echo "$progname:1015: checking for GNU ld" >&5 + else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 + echo "$progname:1018: checking for non-GNU ld" >&5 + fi + + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" + fi + + if test -n "$LD"; then + echo "$ac_t$LD" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$LD"; then + echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 + exit 1 + fi +fi + +# Check to see if it really is or is not GNU ld. +echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 +# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + with_gnu_ld=yes +else + with_gnu_ld=no +fi +echo "$ac_t$with_gnu_ld" 1>&6 + +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +export_dynamic_flag_spec= +whole_archive_flag_spec= +thread_safe_flag_spec= +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= +always_export_symbols=no +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' +# include_expsyms should be a list of space-separated symbols to be *always* +# included in the symbol list +include_expsyms= +# exclude_expsyms can be an egrep regular expression of symbols to exclude +# it will be wrapped by ` (' and `)$', so one must not match beginning or +# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', +# as well as any symbol that contains `d'. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" +# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out +# platforms (ab)use it in PIC code, but their linkers get confused if +# the symbol is explicitly referenced. Since portable code cannot +# rely on this symbol name, it's probably fine to never include it in +# preloaded symbol tables. + +case "$host_os" in +cygwin* | mingw*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$with_gcc" != yes; then + with_gnu_ld=no + fi + ;; + +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case "$host_os" in + aix3* | aix4*) + # On AIX, the GNU linker is very broken + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=yes + + # Extract the symbol export list from an `--export-all' def file, + # then regenerate the def file from the symbol export list, so that + # the compiled dll only exports the symbol export list. + # Be careful not to strip the DATA tag left by newer dlltools. + export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ + sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols' + + # If DATA tags from a recent dlltool are present, honour them! + archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \$# in + 2) echo " \$2 @ \$_lt_hint ; " >> $objdir/$soname-def;; + *) echo " \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done~ + test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts' + + old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib' + # can we support soname and/or expsyms with a.out? -oliva + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + case $host_os in + cygwin* | mingw*) + # dlltool doesn't understand --whole-archive et. al. + whole_archive_flag_spec= + ;; + *) + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + ;; + esac + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case "$host_os" in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$with_gcc" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4*) + hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib' + hardcode_libdir_separator=':' + if test "$with_gcc" = yes; then + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + shared_flag='-shared' + else + shared_flag='${wl}-bM:SRE' + hardcode_direct=yes + fi + allow_undefined_flag=' ${wl}-berok' + archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}' + archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}' + case "$host_os" in aix4.[01]|aix4.[01].*) + # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on + always_export_symbols=yes ;; + esac + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + cygwin* | mingw*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs' + fix_srcfile_path='`cygpath -w $srcfile`' + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9* | hpux10* | hpux11*) + case "$host_os" in + hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;; + *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;; + esac + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_minus_L=yes # Not in the search PATH, but as the default + # location of the library. + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6*) + if test "$with_gcc" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts' # ELF + fi + hardcode_libdir_flag_spec='${wl}-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + openbsd*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' + ;; + + osf3*) + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # As osf3* with the addition of the -msym flag + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + rhapsody*) + archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flags_spec='-L$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case "$host_os" in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $linkopts' + else + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + unixware7*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +echo "$ac_t$ld_shlibs" 1>&6 +test "$ld_shlibs" = no && can_build_shared=no + +if test -z "$NM"; then + echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 + case "$NM" in + [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path. + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -p" + break + else + NM=${NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$NM" && NM=nm + ;; + esac + echo "$ac_t$NM" 1>&6 +fi + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Define system-specific variables. +case "$host_os" in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'" + ;; +irix*) + symcode='[BCDEGRST]' + ;; +solaris*) + symcode='[BDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + symcode='[ABCDGISTW]' +fi + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + $rm conftest* + cat > conftest.c <&5 + if { (eval echo $progname:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then + # Now try to grab the symbols. + nlist=conftest.nm + if { echo "$progname:1657: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then + + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.c +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c' + + cat <> conftest.c +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c + cat <<\EOF >> conftest.c + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$objext conftstm.$objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if { (eval echo $progname:1709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + pipe_works=yes + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + LIBS="$save_LIBS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + global_symbol_pipe= + fi +done +if test "$pipe_works" = yes; then + echo "${ac_t}ok" 1>&6 +else + echo "${ac_t}failed" 1>&6 +fi + +if test -z "$global_symbol_pipe"; then + global_symbol_to_cdecl= +fi + +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$ac_t$hardcode_action" 1>&6 + + +reload_flag= +reload_cmds='$LD$reload_flag -o $output$reload_objs' +echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 +# PORTME Some linkers may need a different reload flag. +reload_flag='-r' +echo "$ac_t$reload_flag" 1>&6 +test -n "$reload_flag" && reload_flag=" $reload_flag" + +# PORTME Fill in your ld.so characteristics +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +file_magic_cmd= +file_magic_test_file= +deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [regex]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given egrep regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. +echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 +case "$host_os" in +aix3*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so$major' + ;; + +aix4*) + version_type=linux + # AIX has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + # We preserve .a as extension for shared libraries though AIX4.2 + # and later linker supports .so + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a' + shlibpath_var=LIBPATH + deplibs_check_method=pass_all + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}.so' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + deplibs_check_method=pass_all + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + export_dynamic_flag_spec=-rdynamic + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw*) + version_type=windows + need_version=no + need_lib_prefix=no + if test "$with_gcc" = yes; then + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a' + else + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' + fi + dynamic_linker='Win32 ld.exe' + deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + file_magic_cmd='${OBJDUMP} -f' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case "$version_type" in + freebsd-elf*) + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + deplibs_check_method=unknown + library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case "$host_os" in + freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + need_lib_prefix=no + need_version=no + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' + soname_spec='${libname}${release}.sl$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + case "$host_os" in + hpux10.20*) + # TODO: Does this work for hpux-11 too? + deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6*) + version_type=irix + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}.so.$major' + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so' + case "$host_os" in + irix5*) + libsuff= shlibsuff= + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + case "$LD" in # libtool.m4 will add one of these switches to LD + *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /lib${libsuff}/libc.so*` + deplibs_check_method='pass_all' + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + deplibs_check_method=pass_all + + if test -f /lib/ld.so.1; then + dynamic_linker='GNU ld.so' + else + # Only the GNU ld.so supports shared libraries on MkLinux. + case "$host_cpu" in + powerpc*) dynamic_linker=no ;; + *) dynamic_linker='Linux ld.so' ;; + esac + fi + ;; + +netbsd*) + version_type=sunos + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' + soname_spec='${libname}${release}.so$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + ;; + +openbsd*) + version_type=sunos + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + need_version=no + fi + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + need_lib_prefix=no + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_version=no + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + shlibpath_var=LD_LIBRARY_PATH + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method='file_magic COFF format alpha shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + deplibs_check_method='pass_all' + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rhapsody*) + version_type=sunos + library_names_spec='${libname}.so' + soname_spec='${libname}.so' + shlibpath_var=DYLD_LIBRARY_PATH + deplibs_check_method=pass_all + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib" + file_magic_cmd=/usr/bin/file + file_magic_test_file=/lib/libc.so + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + case "$host_vendor" in + sequent) + file_magic_cmd='/bin/file' + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + ncr) + deplibs_check_method='pass_all' + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t$dynamic_linker" 1>&6 +test "$dynamic_linker" = no && can_build_shared=no + +# Report the final consequences. +echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 + +# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in +# configure.in, otherwise build static only libraries. +case "$host_os" in +cygwin* | mingw* | os2*) + if test x$can_build_shared = xyes; then + test x$enable_win32_dll = xno && can_build_shared=no + echo "checking if package supports dlls... $can_build_shared" 1>&6 + fi +;; +esac + +if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then + case "$deplibs_check_method" in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac +fi + +echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + test "$enable_shared" = yes && enable_static=no + ;; +esac + +echo "$ac_t$enable_shared" 1>&6 + +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes + +echo "checking whether to build static libraries... $enable_static" 1>&6 + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +echo $ac_n "checking for objdir... $ac_c" 1>&6 +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +echo "$ac_t$objdir" 1>&6 + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else +if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then + lt_cv_dlopen=no lt_cv_dlopen_libs= +echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "$progname:2248: checking for dlopen in -ldl" >&5 +ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen""... $ac_c" 1>&6 +echo "$progname:2288: checking for dlopen" >&5 +if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +dlopen(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_dlopen=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_dlopen=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 +echo "$progname:2335: checking for dld_link in -ldld" >&5 +ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load""... $ac_c" 1>&6 +echo "$progname:2375: checking for shl_load" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +shl_load(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shl_load=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shl_load=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 +echo "$progname:2423: checking for shl_load in -ldld" >&5 +ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + +fi + + +fi + + +fi + +fi + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + fi + + case "$lt_cv_dlopen" in + dlopen) +for ac_hdr in dlfcn.h; do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "$progname:2488: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int fnord = 0; +EOF +ac_try="$ac_compile >/dev/null 2>conftest.out" +{ (eval echo $progname:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +done + + if test "x$ac_cv_header_dlfcn_h" = xyes; then + CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + fi + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2526: checking whether a program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self" 1>&6 + + if test "$lt_cv_dlopen_self" = yes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2599: checking whether a statically linked program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self_static=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self_static=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self_static=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 +fi + ;; + esac + + case "$lt_cv_dlopen_self" in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case "$lt_cv_dlopen_self_static" in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + +# Copy echo and quote the copy, instead of the original, because it is +# used later. +ltecho="$echo" +if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ltecho="$CONFIG_SHELL \$0 --fallback-echo" +fi +LTSHELL="$SHELL" + +LTCONFIG_VERSION="$VERSION" + +# Only quote variables if we're using ltmain.sh. +case "$ltmain" in +*.sh) + # Now quote all the things that may contain metacharacters. + for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \ + AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \ + reload_flag reload_cmds wl \ + pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ + thread_safe_flag_spec whole_archive_flag_spec libname_spec \ + library_names_spec soname_spec \ + RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \ + file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + hardcode_libdir_flag_spec hardcode_libdir_separator \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + + case "$var" in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case "$ltecho" in + *'\$0 --fallback-echo"') + ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + + trap "$rm \"$ofile\"; exit 1" 1 2 15 + echo "creating $ofile" + $rm "$ofile" + cat < "$ofile" +#! $SHELL + +# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="sed -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +### BEGIN LIBTOOL CONFIG +EOF + cfgfile="$ofile" + ;; + +*) + # Double-quote the variables that need it (for aesthetics). + for var in old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do + eval "$var=\\\"\$var\\\"" + done + + # Just create a config file. + cfgfile="$ofile.cfg" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + echo "creating $cfgfile" + $rm "$cfgfile" + cat < "$cfgfile" +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +EOF + ;; +esac + +cat <> "$cfgfile" +# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\ +# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\ +# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\ +# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\ +# $0$ltconfig_args +# +# Compiler and other test output produced by $progname, useful for +# debugging $progname, is in ./config.log if it exists. + +# The version of $progname that generated this script. +LTCONFIG_VERSION=$LTCONFIG_VERSION + +# Shell to use when invoking shell scripts. +SHELL=$LTSHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$ltecho + +# The archiver. +AR=$AR + +# The default C compiler. +CC=$CC + +# The linker used to build libraries. +LD=$LD + +# Whether we need hard or soft links. +LN_S=$LN_S + +# A BSD-compatible nm program. +NM=$NM + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$reload_flag +reload_cmds=$reload_cmds + +# How to pass a linker flag through the compiler. +wl=$wl + +# Object file suffix (normally "o"). +objext="$objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$pic_flag + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$RANLIB +old_archive_cmds=$old_archive_cmds +old_postinstall_cmds=$old_postinstall_cmds +old_postuninstall_cmds=$old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$old_archive_from_new_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$archive_cmds +archive_expsym_cmds=$archive_expsym_cmds +postinstall_cmds=$postinstall_cmds +postuninstall_cmds=$postuninstall_cmds + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$global_symbol_to_cdecl + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$hardcode_libdir_separator + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$include_expsyms + +EOF + +case "$ltmain" in +*.sh) + echo '### END LIBTOOL CONFIG' >> "$ofile" + echo >> "$ofile" + case "$host_os" in + aix3*) + cat <<\EOF >> "$ofile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # Append the ltmain.sh script. + sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1) + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + + chmod +x "$ofile" + ;; + +*) + # Compile the libtool program. + echo "FIXME: would compile $ltmain" + ;; +esac + +test -n "$cache_file" || exit 0 + +# AC_CACHE_SAVE +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/beecrypt/ltmain.sh b/beecrypt/ltmain.sh new file mode 100644 index 0000000..766732d --- /dev/null +++ b/beecrypt/ltmain.sh @@ -0,0 +1,4024 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun ltconfig. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + echo "$modename: not configured to build any kind of library" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +# Parse our command line options once, thoroughly. +while test $# -gt 0 +do + arg="$1" + shift + + case "$arg" in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + execute_dlfiles) + eval "$prev=\"\$$prev \$arg\"" + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case "$arg" in + --help) + show_help=yes + ;; + + --version) + echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + exit 0 + ;; + + --config) + sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0 + exit 0 + ;; + + --debug) + echo "$progname: enabling shell trace mode" + set -x + ;; + + --dry-run | -n) + run=: + ;; + + --features) + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --quiet | --silent) + show=: + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 +fi + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + case "$nonopt" in + *cc | *++ | gcc* | *-gcc*) + mode=link + for arg + do + case "$arg" in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case "$mode" in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + lastarg= + srcfile="$nonopt" + suppress_output= + + user_target=no + for arg + do + # Accept any command-line options. + case "$arg" in + -o) + if test "$user_target" != "no"; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit 1 + fi + user_target=next + ;; + + -static) + build_old_libs=yes + continue + ;; + esac + + case "$user_target" in + next) + # The next one is the -o target name + user_target=yes + continue + ;; + yes) + # We got the output file + user_target=set + libobj="$arg" + continue + ;; + esac + + # Accept the current argument as the source file. + lastarg="$srcfile" + srcfile="$arg" + + # Aesthetically quote the previous argument. + + # Backslashify any backslashes, double quotes, and dollar signs. + # These are the only characters that are still specially + # interpreted inside of double-quoted scrings. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly in scan + # sets, so we specify it separately. + case "$lastarg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + lastarg="\"$lastarg\"" + ;; + esac + + # Add the previous argument to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + done + + case "$user_target" in + set) + ;; + no) + # Get the name of the library object. + libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + *) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit 1 + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSfmso]' + case "$libobj" in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case "$libobj" in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit 1 + ;; + esac + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $libobj" + else + removelist="$libobj" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit 1" 1 2 15 + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit 1" 1 2 15 + else + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until ln "$0" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + # All platforms use -DPIC, to notify preprocessed assembler code. + command="$base_compile $srcfile $pic_flag -DPIC" + if test "$build_old_libs" = yes; then + lo_libobj="$libobj" + dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$libobj"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + + if test -d "$dir"; then + $show "$rm $libobj" + $run $rm $libobj + else + $show "$mkdir $dir" + $run $mkdir $dir + status=$? + if test $status -ne 0 && test ! -d $dir; then + exit $status + fi + fi + fi + if test "$compiler_o_lo" = yes; then + output_obj="$libobj" + command="$command -o $output_obj" + elif test "$compiler_c_o" = yes; then + output_obj="$obj" + command="$command -o $output_obj" + fi + + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + test -n "$output_obj" && $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed, then go on to compile the next one + if test x"$output_obj" != x"$libobj"; then + $show "$mv $output_obj $libobj" + if $run $mv $output_obj $libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # If we have no pic_flag, then copy the object into place and finish. + if test -z "$pic_flag" && test "$build_old_libs" = yes; then + # Rename the .lo from within objdir to obj + if test -f $obj; then + $show $rm $obj + $run $rm $obj + fi + + $show "$mv $libobj $obj" + if $run $mv $libobj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` + libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + # Now arrange that obj and lo_libobj become the same file + $show "(cd $xdir && $LN_S $baseobj $libobj)" + if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then + exit 0 + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Allow error messages only from the first compilation. + suppress_output=' >/dev/null 2>&1' + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + command="$base_compile $srcfile" + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + output_obj="$obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed + if test x"$output_obj" != x"$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Create an invalid libtool object if no PIC, so that we do not + # accidentally link it into a program. + if test "$build_libtool_libs" != yes; then + $show "echo timestamp > $libobj" + $run eval "echo timestamp > \$libobj" || exit $? + else + # Move the .lo from within objdir + $show "$mv $libobj $lo_libobj" + if $run $mv $libobj $lo_libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + fi + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $rm "$lockfile" + fi + + exit 0 + ;; + + # libtool link mode + link) + modename="$modename: link" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invokation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + + # This is a source program that is used to create dlls on Windows + # Don't remove nor modify the starting and closing comments +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments +# /* impgen.c starts here */ +# /* Copyright (C) 1999 Free Software Foundation, Inc. +# +# This file is part of GNU libtool. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# */ +# +# #include /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* for strdup() */ +# +# static unsigned int +# pe_get16 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[2]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 2); +# return b[0] + (b[1]<<8); +# } +# +# static unsigned int +# pe_get32 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[4]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 4); +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# static unsigned int +# pe_as32 (ptr) +# void *ptr; +# { +# unsigned char *b = ptr; +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# int +# main (argc, argv) +# int argc; +# char *argv[]; +# { +# int dll; +# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; +# unsigned long export_rva, export_size, nsections, secptr, expptr; +# unsigned long name_rvas, nexp; +# unsigned char *expdata, *erva; +# char *filename, *dll_name; +# +# filename = argv[1]; +# +# dll = open(filename, O_RDONLY|O_BINARY); +# if (!dll) +# return 1; +# +# dll_name = filename; +# +# for (i=0; filename[i]; i++) +# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') +# dll_name = filename + i +1; +# +# pe_header_offset = pe_get32 (dll, 0x3c); +# opthdr_ofs = pe_header_offset + 4 + 20; +# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# +# if (num_entries < 1) /* no exports */ +# return 1; +# +# export_rva = pe_get32 (dll, opthdr_ofs + 96); +# export_size = pe_get32 (dll, opthdr_ofs + 100); +# nsections = pe_get16 (dll, pe_header_offset + 4 +2); +# secptr = (pe_header_offset + 4 + 20 + +# pe_get16 (dll, pe_header_offset + 4 + 16)); +# +# expptr = 0; +# for (i = 0; i < nsections; i++) +# { +# char sname[8]; +# unsigned long secptr1 = secptr + 40 * i; +# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); +# unsigned long vsize = pe_get32 (dll, secptr1 + 16); +# unsigned long fptr = pe_get32 (dll, secptr1 + 20); +# lseek(dll, secptr1, SEEK_SET); +# read(dll, sname, 8); +# if (vaddr <= export_rva && vaddr+vsize > export_rva) +# { +# expptr = fptr + (export_rva - vaddr); +# if (export_rva + export_size > vaddr + vsize) +# export_size = vsize - (export_rva - vaddr); +# break; +# } +# } +# +# expdata = (unsigned char*)malloc(export_size); +# lseek (dll, expptr, SEEK_SET); +# read (dll, expdata, export_size); +# erva = expdata - export_rva; +# +# nexp = pe_as32 (expdata+24); +# name_rvas = pe_as32 (expdata+32); +# +# printf ("EXPORTS\n"); +# for (i = 0; i&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test $# -gt 0; do + arg="$1" + shift + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case "$prev" in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case "$arg" in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit 1 + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case "$arg" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi + + prevarg="$arg" + + case "$arg" in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: not more than one -exported-symbols argument allowed" + exit 1 + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + absdir="$dir" + fi + dir="$absdir" + ;; + esac + case " $deplibs " in + *" $arg "*) ;; + *) deplibs="$deplibs $arg";; + esac + case " $lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir";; + esac + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + dllsearchdir=`cd "$dir" && pwd || echo "$dir"` + case ":$dllsearchpath:" in + ::) dllsearchpath="$dllsearchdir";; + *":$dllsearchdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dllsearchdir";; + esac + ;; + esac + ;; + + -l*) + if test "$arg" = "-lc"; then + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # These systems don't actually have c library (as such) + continue + ;; + esac + elif test "$arg" = "-lm"; then + case "$host" in + *-*-cygwin* | *-*-beos*) + # These systems don't actually have math library (as such) + continue + ;; + esac + fi + deplibs="$deplibs $arg" + ;; + + -module) + module=yes + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -o) prev=output ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # If we have no pic_flag, then this is the same as -all-static. + if test -z "$pic_flag" && test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + + *.o | *.obj | *.a | *.lib) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A library object. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` + prev= + fi + libobjs="$libobjs $arg" + ;; + + *.la) + # A libtool-controlled library. + + dlname= + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2 + exit 1 + fi + + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + # If there is no directory component, then add one. + case "$arg" in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$arg'" 1>&2 + exit 1 + fi + + # Find the relevant object directory and library name. + name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'` + + if test "X$installed" = Xyes; then + dir="$libdir" + else + dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$arg"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + fi + + if test -n "$dependency_libs"; then + # Extract -R and -L from dependency_libs + temp_deplibs= + for deplib in $dependency_libs; do + case "$deplib" in + -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + case " $rpath $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + -L*) case "$compile_command $temp_deplibs " in + *" $deplib "*) ;; + *) temp_deplibs="$temp_deplibs $deplib";; + esac + temp_dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'` + case " $lib_search_path " in + *" $temp_dir "*) ;; + *) lib_search_path="$lib_search_path $temp_dir";; + esac + ;; + *) temp_deplibs="$temp_deplibs $deplib";; + esac + done + dependency_libs="$temp_deplibs" + fi + + if test -z "$libdir"; then + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$deplibs$dependency_libs" + compile_command="$compile_command $dir/$old_library$dependency_libs" + finalize_command="$finalize_command $dir/$old_library$dependency_libs" + continue + fi + + # This library was specified with -dlopen. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking statically, + # we need to preload. + prev=dlprefiles + else + # We should not create a dependency on this library, but we + # may need any libraries it requires. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + prev= + continue + fi + fi + + # The library was specified with -dlpreopen. + if test "$prev" = dlprefiles; then + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + dlprefiles="$dlprefiles $dir/$old_library" + else + dlprefiles="$dlprefiles $dir/$linklib" + fi + prev= + fi + + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + link_against_libtool_libs="$link_against_libtool_libs $arg" + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # We need an absolute path. + case "$dir" in + [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + absdir="$dir" + fi + ;; + esac + + # This is the magic to use -rpath. + # Skip directories that are in the system default run-time + # search path, unless they have been requested with -R. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + + lib_linked=yes + case "$hardcode_action" in + immediate | unsupported) + if test "$hardcode_direct" = no; then + compile_command="$compile_command $dir/$linklib" + deplibs="$deplibs $dir/$linklib" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + dllsearchdir=`cd "$dir" && pwd || echo "$dir"` + if test -n "$dllsearchpath"; then + dllsearchpath="$dllsearchpath:$dllsearchdir" + else + dllsearchpath="$dllsearchdir" + fi + ;; + esac + elif test "$hardcode_minus_L" = no; then + case "$host" in + *-*-sunos*) + compile_shlibpath="$compile_shlibpath$dir:" + ;; + esac + case "$compile_command " in + *" -L$dir "*) ;; + *) compile_command="$compile_command -L$dir";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -L$dir -l$name" + elif test "$hardcode_shlibpath_var" = no; then + case ":$compile_shlibpath:" in + *":$dir:"*) ;; + *) compile_shlibpath="$compile_shlibpath$dir:";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -l$name" + else + lib_linked=no + fi + ;; + + relink) + if test "$hardcode_direct" = yes; then + compile_command="$compile_command $absdir/$linklib" + deplibs="$deplibs $absdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + case "$compile_command " in + *" -L$absdir "*) ;; + *) compile_command="$compile_command -L$absdir";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -L$absdir -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case ":$compile_shlibpath:" in + *":$absdir:"*) ;; + *) compile_shlibpath="$compile_shlibpath$absdir:";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -l$name" + else + lib_linked=no + fi + ;; + + *) + lib_linked=no + ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit 1 + fi + + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + finalize_command="$finalize_command $libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + case "$finalize_command " in + *" -L$libdir "*) ;; + *) finalize_command="$finalize_command -L$libdir";; + esac + finalize_command="$finalize_command -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case ":$finalize_shlibpath:" in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:";; + esac + finalize_command="$finalize_command -l$name" + else + # We cannot seem to hardcode it, guess we'll fake it. + case "$finalize_command " in + *" -L$dir "*) ;; + *) finalize_command="$finalize_command -L$libdir";; + esac + finalize_command="$finalize_command -l$name" + fi + else + # Transform directly to old archives if we don't build new libraries. + if test -n "$pic_flag" && test -z "$old_library"; then + $echo "$modename: cannot find static library for \`$arg'" 1>&2 + exit 1 + fi + + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_command="$compile_command $dir/$linklib" + finalize_command="$finalize_command $dir/$linklib" + else + case "$compile_command " in + *" -L$dir "*) ;; + *) compile_command="$compile_command -L$dir";; + esac + compile_command="$compile_command -l$name" + case "$finalize_command " in + *" -L$dir "*) ;; + *) finalize_command="$finalize_command -L$dir";; + esac + finalize_command="$finalize_command -l$name" + fi + fi + + # Add in any libraries that this one depends upon. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + esac + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + case "$output" in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *.a | *.lib) + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link libtool libraries into archives" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + ;; + + *.la) + # Make sure we only generate libraries of the form `libNAME.la'. + case "$outputname" in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + + if test -n "$objs"; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 + exit 1 + fi + + # How the heck are we supposed to write a wrapper for a shared library? + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2 + exit 1 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test $# -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + libext=al + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + dependency_libs="$deplibs" + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + current="$2" + revision="$3" + age="$4" + + # Check that each of the things are valid numbers. + case "$current" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$revision" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$age" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test $age -gt $current; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case "$version_type" in + none) ;; + + irix) + major=`expr $current - $age + 1` + versuffix="$major.$revision" + verstring="sgi$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test $loop != 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="sgi$major.$iface:$verstring" + done + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test $loop != 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + windows) + # Like Linux, but with '-' rather than '.', since we only + # want one extension on Windows 95. + major=`expr $current - $age` + versuffix="-$major-$age-$revision" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + verstring="0.0" + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + dependency_libs="$deplibs" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody*) + # rhapsody is a little odd... + deplibs="$deplibs -framework System" + ;; + *) + # Add libc to deplibs on all other systems. + deplibs="$deplibs -lc" + ;; + esac + fi + + # Create the output directory, or remove our outputs if we need to. + if test -d $output_objdir; then + $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" + $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* + else + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + if test "$build_libtool_libs" = yes; then + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case "$deplibs_check_method" in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behaviour. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | sed 's/.* -> //'` + case "$potliblink" in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | sed 10q \ + | egrep "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + echo "*** Warning: This library needs some functionality provided by $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | + grep . >/dev/null; then + echo + if test "X$deplibs_check_method" = "Xnone"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + echo "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + # Get the real and link names of the library. + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Ensure that we have .o objects for linkers which dislike .lo + # (e.g. aix) in case we are running --disable-static + for obj in $libobjs; do + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + if test ! -f $xdir/$oldobj; then + $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" + $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? + fi + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + eval cmds=\"$export_symbols_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linkopts="$linkopts $flag" + fi + + # Do each of the archive commands. + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval cmds=\"$archive_expsym_cmds\" + else + eval cmds=\"$archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + *.lo | *.o | *.obj) + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link libtool libraries into objects" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case "$output" in + *.lo) + if test -n "$objs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + # Create the old-style object. + reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" + + output="$obj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + else + # Just create a symlink. + $show $rm $libobj + $run $rm $libobj + xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$libobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + $show "(cd $xdir && $LN_S $oldobj $baseobj)" + $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + ;; + + # Anything else should be a program. + *) + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$compile_rpath " in + *" $libdir "*) ;; + *) compile_rpath="$compile_rpath $libdir" ;; + esac + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + + # Create the binary in the object directory, then wrap it. + if test ! -d $output_objdir; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case "$dlsyms" in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`echo "$arg" | sed -e 's%^.*/%%'` + $run eval 'echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{\ +" + + sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \ + -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \ + < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr_t) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case "$host" in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case "$0" in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + link_against_libtool_libs='$link_against_libtool_libs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + echo >> $output "\ + program=lt-'$outputname' + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if (cd \"\$thisdir\" && eval \$relink_command); then : + else + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # win32 systems need to use the prog path for dll + # lookup to work + *-*-cygwin*) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + # Ensure that we have .o objects in place in case we decided + # not to build a shared library, and have fallen back to building + # static libs even though --disable-static was passed! + for oldobj in $oldobjs; do + if test ! -f $oldobj; then + xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$oldobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` + obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + $show "(cd $xdir && ${LN_S} $obj $baseobj)" + $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? + fi + done + + eval cmds=\"$old_archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + if test -n "$xrpath"; then + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + done + dependency_libs="$temp_xrpath $dependency_libs" + fi + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + fi + $rm $output + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$dlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Directory that this library needs to be installed in: +libdir='$install_libdir'\ +" + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case "$arg" in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a | *.lib) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$realname $destdir/$realname" + $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + + if test $# -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.o | *.obj) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + link_against_libtool_libs= + relink_command= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $SHELL $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit 0 + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case "$file" in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case "$file" in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool uninstall mode + uninstall) + modename="$modename: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + $show "$rm $rmfiles" + $run $rm $rmfiles + + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + + *) + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + esac + done + exit 0 + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/beecrypt/masm/Makefile.am b/beecrypt/masm/Makefile.am new file mode 100644 index 0000000..990ff8f --- /dev/null +++ b/beecrypt/masm/Makefile.am @@ -0,0 +1,25 @@ +# +# Makefile.am's purpose is to add the Microsoft assembler files to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + +AUTOMAKE_OPTIONS = gnu no-dependencies + +EXTRA_DIST = blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm diff --git a/beecrypt/masm/Makefile.in b/beecrypt/masm/Makefile.in new file mode 100644 index 0000000..5eff34d --- /dev/null +++ b/beecrypt/masm/Makefile.in @@ -0,0 +1,209 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# +# Makefile.am's purpose is to add the Microsoft assembler files to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +AS = @AS@ +CC = @CC@ +CPP = @CPP@ +DLLTOOL = @DLLTOOL@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +ac_cv_have_java = @ac_cv_have_java@ +ac_cv_have_javac = @ac_cv_have_javac@ + +AUTOMAKE_OPTIONS = gnu no-dependencies + +EXTRA_DIST = blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.gnu.h +CONFIG_CLEAN_FILES = +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu masm/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = masm + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# 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. +.NOEXPORT: diff --git a/beecrypt/masm/blowfishopt.i586.asm b/beecrypt/masm/blowfishopt.i586.asm new file mode 100644 index 0000000..16cb161 --- /dev/null +++ b/beecrypt/masm/blowfishopt.i586.asm @@ -0,0 +1,180 @@ +; +; blowfishopt.i586.asm +; +; Assembler optimized blowfish routines for Intel Pentium processors +; +; Compile target is Microsoft Macro Assembler +; +; Copyright (c) 2000 Virtual Unlimited B.V. +; +; Author: 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 +; + + .586 + .model flat,C + + .code + +etworounds macro offset + xor ecx,dword ptr [esi+offset] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,ch + mov bl,cl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor edx,edi + xor edx,dword ptr [esi+offset+4] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,dh + mov bl,dl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor ecx,edi + endm + +dtworounds macro offset + xor ecx,dword ptr [esi+offset+4] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,ch + mov bl,cl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor edx,edi + xor edx,dword ptr [esi+offset] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,dh + mov bl,dl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor ecx,edi + endm + + + align 8 + +blowfishEncrypt proc + push edi + push esi + push ebx + + mov esi,dword ptr [esp+16] + mov edi,dword ptr [esp+24] + + xor eax,eax + xor ebx,ebx + + mov ecx,dword ptr [edi] + mov edx,dword ptr [edi+4] + + bswap ecx + bswap edx + + etworounds 0 + etworounds 8 + etworounds 16 + etworounds 24 + etworounds 32 + etworounds 40 + etworounds 48 + etworounds 56 + + mov edi,dword ptr [esp+20] + xor ecx,dword ptr [esi+64] + xor edx,dword ptr [esi+68] + + bswap ecx + bswap edx + + mov dword ptr [edi+4],ecx + mov dword ptr [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret +blowfishEncrypt endp + + + align 8 + +blowfishDecrypt proc + push edi + push esi + push ebx + + mov esi,dword ptr [esp+16] + mov edi,dword ptr [esp+24] + + xor eax,eax + xor ebx,ebx + + mov ecx,dword ptr [edi] + mov edx,dword ptr [edi+4] + + bswap ecx + bswap edx + + dtworounds 64 + dtworounds 56 + dtworounds 48 + dtworounds 40 + dtworounds 32 + dtworounds 24 + dtworounds 16 + dtworounds 8 + + mov edi,dword ptr [esp+20] + xor ecx,dword ptr [esi+4] + xor edx,dword ptr [esi] + + bswap ecx + bswap edx + + mov dword ptr [edi+4],ecx + mov dword ptr [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret +blowfishDecrypt endp + + end diff --git a/beecrypt/masm/fips180opt.i586.asm b/beecrypt/masm/fips180opt.i586.asm new file mode 100644 index 0000000..7c5eada --- /dev/null +++ b/beecrypt/masm/fips180opt.i586.asm @@ -0,0 +1,298 @@ +; +; fips180opt.i586.asm +; +; Assembler optimized SHA-1 routines for Intel Pentium processors +; +; Compile target is Microsoft Macro Assembler +; +; Copyright (c) 2000 Virtual Unlimited B.V. +; +; Author: 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 +; + + .586 + .model flat,C + +K00 equ 5a827999h +K20 equ 6ed9eba1h +K40 equ 8f1bbcdch +K60 equ 0ca62c1d6h + +PARAM_H equ 0 +PARAM_DATA equ 20 +PARAM_OFFSET equ 352 + + .code + +subround1 macro b,c,d,e,w + mov ecx,c + mov ebx,b + mov edx,d + rol eax,5 + xor ecx,edx + add eax,e + and ecx,ebx + add eax,K00 + ror ebx,2 + add eax,w + xor ecx,edx + mov b,ebx + add eax,ecx + mov e,eax + endm + +subround2 macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K20 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + endm + +subround3 macro b,c,d,e,w + mov ecx,c + rol eax,5 + mov ebx,b + mov edx,ecx + add eax,e + or ecx,ebx + and edx,ebx + and ecx,d + add eax,K40 + or ecx,edx + add eax,w + ror ebx,2 + add eax,ecx + mov b,ebx + mov e,eax + endm + +subround4 macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K60 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + endm + + + align 8 + +sha1Process proc + push edi + push esi + push ebx + push ebp + ; allocate local variables + mov esi,dword ptr [esp+20] ; esi now points to param + sub esp,20 ; esp now points below the local variables + lea edi,dword ptr [esi+PARAM_DATA] + mov ebp,esp ; ebp now points to the local variables + + mov ecx,4 +@loads: + mov edx,dword ptr [esi+ecx*4] + mov dword ptr [ebp+ecx*4],edx + dec ecx + jns @loads + + mov ecx,15 + xor eax,eax + + align 4 +@swaps: + mov edx,dword ptr [edi+ecx*4] + bswap edx + mov dword ptr [edi+ecx*4],edx + dec ecx + jns @swaps + + lea edi,dword ptr [esi+PARAM_DATA] + mov byte ptr [esi+PARAM_OFFSET],al + mov ecx,16 + + align 4 +@xors: + mov eax,dword ptr [edi+52] + mov ebx,dword ptr [edi+56] + xor eax,dword ptr [edi+32] + xor ebx,dword ptr [edi+36] + xor eax,dword ptr [edi+ 8] + xor ebx,dword ptr [edi+12] + xor eax,dword ptr [edi ] + xor ebx,dword ptr [edi+ 4] + rol eax,1 + rol ebx,1 + mov dword ptr [edi+64],eax + mov dword ptr [edi+68],ebx + mov eax,dword ptr [edi+60] + mov ebx,dword ptr [edi+64] + xor eax,dword ptr [edi+40] + xor ebx,dword ptr [edi+44] + xor eax,dword ptr [edi+16] + xor ebx,dword ptr [edi+20] + xor eax,dword ptr [edi+ 8] + xor ebx,dword ptr [edi+12] + rol eax,1 + rol ebx,1 + mov dword ptr [edi+72],eax + mov dword ptr [edi+76],ebx + add edi,16 + dec ecx + jnz @xors + + mov edi,PARAM_DATA + + ; to optimize further, use esi only, and store the add constant into edi + ; will make code smaller and faster + +@round01to20: + mov eax,dword ptr [ebp] + subround1 dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + +@round21to40: + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + +@round41to60: + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + +@round61to80: + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + ; add edi,20 + + mov ecx,4 + +@adds: + mov eax,dword ptr [ebp+ecx*4] + add dword ptr [esi+ecx*4],eax + dec ecx + jns @adds + + add esp,20 + pop ebp + pop ebx + pop esi + pop edi + ret +sha1Process endp + + end diff --git a/beecrypt/masm/mp32opt.i386.asm b/beecrypt/masm/mp32opt.i386.asm new file mode 100644 index 0000000..156bf01 --- /dev/null +++ b/beecrypt/masm/mp32opt.i386.asm @@ -0,0 +1,351 @@ +; +; mp32opt.i386.asm +; +; Assembler optimized multiprecision integer routines for Intel 386 +; +; Compile target is Microsoft Macro Assembler +; +; Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V. +; +; Author: 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 +; + + .586 + .model flat,C + + .code + + align 8 +mp32zero proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + + xor eax,eax + rep stosd + + pop edi + ret +mp32zero endp + + + align 8 +mp32fill proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + mov eax,dword ptr [esp+16] + + rep stosd + + pop edi + ret +mp32fill endp + + + align 8 +mp32odd proc + mov ecx,dword ptr [esp+4] + mov eax,dword ptr [esp+8] + mov eax,dword ptr [eax+ecx*4-4] + and eax,1 + ret +mp32odd endp + + + align 8 +mp32even proc + mov ecx,dword ptr [esp+4] + mov eax,dword ptr [esp+8] + mov eax,dword ptr [eax+ecx*4-4] + not eax + and eax,1 + ret +mp32even endp + + + align 8 +mp32addw proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + mov eax,dword ptr [esp+16] + + lea edi,dword ptr [edi+ecx*4-4] + add dword ptr [edi],eax + dec ecx + jz @mp32addw_end + sub edi,4 + xor edx,edx + + align 4 +@mp32addw_loop: + adc dword ptr [edi],edx + sub edi,4 + dec ecx + jnz @mp32addw_loop +@mp32addw_end: + sbb eax,eax + neg eax + + pop edi + ret +mp32addw endp + + + align 8 +mp32subw proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + mov eax,dword ptr [esp+16] + + lea edi,dword ptr [edi+ecx*4-4] + sub dword ptr [edi],eax + dec ecx + jz @mp32subw_end + sub edi,4 + xor edx,edx + + align 4 +@mp32subw_loop: + sbb dword ptr [edi],edx + sub edi,4 + dec ecx + jnz @mp32subw_loop +@mp32subw_end: + sbb eax,eax + neg eax + + pop edi + ret +mp32subw endp + + + align 8 +mp32add proc + push edi + push esi + + mov ecx,dword ptr [esp+12] + mov edi,dword ptr [esp+16] + mov esi,dword ptr [esp+20] + + xor edx,edx + dec ecx + + align 4 +@mp32add_loop: + mov eax,dword ptr [esi+ecx*4] + adc dword ptr [edi+ecx*4],eax + dec ecx + jns @mp32add_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret +mp32add endp + + align 8 +mp32sub proc + push edi + push esi + + mov ecx,dword ptr [esp+12] + mov edi,dword ptr [esp+16] + mov esi,dword ptr [esp+20] + + xor edx,edx + dec ecx + + align 4 +@mp32sub_loop: + mov eax,dword ptr [esi+ecx*4] + sbb dword ptr [edi+ecx*4],eax + dec ecx + jns @mp32sub_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret +mp32sub endp + + + align 8 +mp32divtwo proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + + lea edi,dword ptr [edi+ecx*4] + neg ecx + clc +@mp32divtwo_loop: + rcr dword ptr [edi+ecx*4],1 + inc ecx + jnz @mp32divtwo_loop + + pop edi + ret +mp32divtwo endp + + + align 8 +mp32multwo proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + + clc + dec ecx + + align 4 +@mp32multwo_loop: + rcl dword ptr [edi+ecx*4],1 + dec ecx + jns @mp32multwo_loop + + sbb eax,eax + neg eax + + pop edi + ret +mp32multwo endp + + + align 8 +mp32setmul proc + push edi + push esi + push ebx + push ebp + + mov ecx,dword ptr [esp+20] + mov edi,dword ptr [esp+24] + mov esi,dword ptr [esp+28] + mov ebp,dword ptr [esp+32] + + xor edx,edx + dec ecx + + align 4 +@mp32setmul_loop: + mov ebx,edx + mov eax,dword ptr [esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + mov dword ptr [edi+ecx*4],eax + dec ecx + jns @mp32setmul_loop + + mov eax,edx + + pop ebp + pop ebx + pop esi + pop edi + ret +mp32setmul endp + + + align 8 + +mp32addmul proc + push edi + push esi + push ebx + push ebp + + mov ecx,dword ptr [esp+20] + mov edi,dword ptr [esp+24] + mov esi,dword ptr [esp+28] + mov ebp,dword ptr [esp+32] + + xor edx,edx + dec ecx + + align 4 +@mp32addmul_loop: + mov ebx,edx + mov eax,dword ptr [esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + add dword ptr [edi+ecx*4],eax + adc edx,0 + dec ecx + jns @mp32addmul_loop + + mov eax,edx + + pop ebp + pop ebx + pop esi + pop edi + ret +mp32addmul endp + + + align 8 + +mp32addsqrtrc proc + push edi + push esi + push ebx + + mov ecx,dword ptr [esp+16] + mov edi,dword ptr [esp+20] + mov esi,dword ptr [esp+24] + + xor ebx,ebx + dec ecx + + align 4 +@mp32addsqrtrc_loop: + mov eax,dword ptr [esi+ecx*4] + mul eax + add eax,ebx + adc edx,0 + add dword ptr [edi+ecx*8+4],eax + adc dword ptr [edi+ecx*8+0],edx + sbb ebx,ebx + neg ebx + dec ecx + jns @mp32addsqrtrc_loop + + mov eax,ebx + + pop ebx + pop esi + pop edi + ret +mp32addsqrtrc endp + + end diff --git a/beecrypt/md5.c b/beecrypt/md5.c new file mode 100644 index 0000000..e87db2c --- /dev/null +++ b/beecrypt/md5.c @@ -0,0 +1,230 @@ +/* + * md5.c + * + * MD5 hash function, code + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "md5.h" +#include "mp32.h" +#include "endianness.h" + +static uint32 md5hinit[4] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }; + +const hashFunction md5 = { "MD5", sizeof(md5Param), 4 * sizeof(uint32), (hashFunctionReset) md5Reset, (hashFunctionUpdate) md5Update, (hashFunctionDigest) md5Digest }; + +int md5Reset(register md5Param* p) +{ + mp32copy(4, p->h, md5hinit); + mp32zero(16, p->data); + p->length = 0; + p->offset = 0; + return 0; +} + +#define ROL(x, s) (((x) << (s)) | ((x) >> (32 - (s)))) + +#define FF(a, b, c, d, w, s, t) \ + a += ((b&(c^d))^d) + w + t; \ + a = ROL(a, s); \ + a += b; + +#define GG(a, b, c, d, w, s, t) \ + a += ((d&(b^c))^c) + w + t; \ + a = ROL(a, s); \ + a += b; + +#define HH(a, b, c, d, w, s, t) \ + a += (b^c^d) + w + t; \ + a = ROL(a, s); \ + a += b; + +#define II(a, b, c, d, w, s, t) \ + a += (c^(b|~d)) + w + t; \ + a = ROL(a, s); \ + a += b; + +#ifndef ASM_MD5PROCESS +void md5Process(md5Param* p) +{ + register uint32 a,b,c,d; + register uint32* w; + #if WORDS_BIGENDIAN + register byte t; + #endif + + w = p->data; + #if WORDS_BIGENDIAN + t = 16; + while (t--) + { + register uint32 temp = swapu32(*w); + *(w++) = temp; + } + w = p->data; + #endif + + a = p->h[0]; b = p->h[1]; c = p->h[2]; d = p->h[3]; + + FF(a, b, c, d, w[ 0], 7, 0xd76aa478); + FF(d, a, b, c, w[ 1], 12, 0xe8c7b756); + FF(c, d, a, b, w[ 2], 17, 0x242070db); + FF(b, c, d, a, w[ 3], 22, 0xc1bdceee); + FF(a, b, c, d, w[ 4], 7, 0xf57c0faf); + FF(d, a, b, c, w[ 5], 12, 0x4787c62a); + FF(c, d, a, b, w[ 6], 17, 0xa8304613); + FF(b, c, d, a, w[ 7], 22, 0xfd469501); + FF(a, b, c, d, w[ 8], 7, 0x698098d8); + FF(d, a, b, c, w[ 9], 12, 0x8b44f7af); + FF(c, d, a, b, w[10], 17, 0xffff5bb1); + FF(b, c, d, a, w[11], 22, 0x895cd7be); + FF(a, b, c, d, w[12], 7, 0x6b901122); + FF(d, a, b, c, w[13], 12, 0xfd987193); + FF(c, d, a, b, w[14], 17, 0xa679438e); + FF(b, c, d, a, w[15], 22, 0x49b40821); + + GG(a, b, c, d, w[ 1], 5, 0xf61e2562); + GG(d, a, b, c, w[ 6], 9, 0xc040b340); + GG(c, d, a, b, w[11], 14, 0x265e5a51); + GG(b, c, d, a, w[ 0], 20, 0xe9b6c7aa); + GG(a, b, c, d, w[ 5], 5, 0xd62f105d); + GG(d, a, b, c, w[10], 9, 0x02441453); + GG(c, d, a, b, w[15], 14, 0xd8a1e681); + GG(b, c, d, a, w[ 4], 20, 0xe7d3fbc8); + GG(a, b, c, d, w[ 9], 5, 0x21e1cde6); + GG(d, a, b, c, w[14], 9, 0xc33707d6); + GG(c, d, a, b, w[ 3], 14, 0xf4d50d87); + GG(b, c, d, a, w[ 8], 20, 0x455a14ed); + GG(a, b, c, d, w[13], 5, 0xa9e3e905); + GG(d, a, b, c, w[ 2], 9, 0xfcefa3f8); + GG(c, d, a, b, w[ 7], 14, 0x676f02d9); + GG(b, c, d, a, w[12], 20, 0x8d2a4c8a); + + HH(a, b, c, d, w[ 5], 4, 0xfffa3942); + HH(d, a, b, c, w[ 8], 11, 0x8771f681); + HH(c, d, a, b, w[11], 16, 0x6d9d6122); + HH(b, c, d, a, w[14], 23, 0xfde5380c); + HH(a, b, c, d, w[ 1], 4, 0xa4beea44); + HH(d, a, b, c, w[ 4], 11, 0x4bdecfa9); + HH(c, d, a, b, w[ 7], 16, 0xf6bb4b60); + HH(b, c, d, a, w[10], 23, 0xbebfbc70); + HH(a, b, c, d, w[13], 4, 0x289b7ec6); + HH(d, a, b, c, w[ 0], 11, 0xeaa127fa); + HH(c, d, a, b, w[ 3], 16, 0xd4ef3085); + HH(b, c, d, a, w[ 6], 23, 0x04881d05); + HH(a, b, c, d, w[ 9], 4, 0xd9d4d039); + HH(d, a, b, c, w[12], 11, 0xe6db99e5); + HH(c, d, a, b, w[15], 16, 0x1fa27cf8); + HH(b, c, d, a, w[ 2], 23, 0xc4ac5665); + + II(a, b, c, d, w[ 0], 6, 0xf4292244); + II(d, a, b, c, w[ 7], 10, 0x432aff97); + II(c, d, a, b, w[14], 15, 0xab9423a7); + II(b, c, d, a, w[ 5], 21, 0xfc93a039); + II(a, b, c, d, w[12], 6, 0x655b59c3); + II(d, a, b, c, w[ 3], 10, 0x8f0ccc92); + II(c, d, a, b, w[10], 15, 0xffeff47d); + II(b, c, d, a, w[ 1], 21, 0x85845dd1); + II(a, b, c, d, w[ 8], 6, 0x6fa87e4f); + II(d, a, b, c, w[15], 10, 0xfe2ce6e0); + II(c, d, a, b, w[ 6], 15, 0xa3014314); + II(b, c, d, a, w[13], 21, 0x4e0811a1); + II(a, b, c, d, w[ 4], 6, 0xf7537e82); + II(d, a, b, c, w[11], 10, 0xbd3af235); + II(c, d, a, b, w[ 2], 15, 0x2ad7d2bb); + II(b, c, d, a, w[ 9], 21, 0xeb86d391); + + p->h[0] += a; + p->h[1] += b; + p->h[2] += c; + p->h[3] += d; +} +#endif + +int md5Update(md5Param* p, const byte* data, int size) +{ + register int proclength; + + p->length += size; + while (size > 0) + { + proclength = ((p->offset + size) > 64) ? (64 - p->offset) : size; + memcpy(((byte *) p->data) + p->offset, data, proclength); + size -= proclength; + data += proclength; + p->offset += proclength; + + if (p->offset == 64) + { + md5Process(p); + p->offset = 0; + } + } + return 0; +} + +static void md5Finish(md5Param* p) +{ + register byte *ptr = ((byte *) p->data) + p->offset++; + + *(ptr++) = 0x80; + + if (p->offset > 56) + { + while (p->offset++ < 64) + *(ptr++) = 0; + + md5Process(p); + p->offset = 0; + } + + ptr = ((byte *) p->data) + p->offset; + while (p->offset++ < 56) + *(ptr++) = 0; + + #if !WORDS_BIGENDIAN + p->data[14] = ((uint32)((p->length << 3) & 0xffffffff)); + p->data[15] = ((uint32)(p->length >> 29)); + #else + p->data[14] = swapu32((uint32)((p->length << 3) & 0xffffffff)); + p->data[15] = swapu32((uint32)(p->length >> 29)); + #endif + + md5Process(p); + + #if 1 /* WORDS_BIGENDIAN */ + p->h[0] = swapu32(p->h[0]); + p->h[1] = swapu32(p->h[1]); + p->h[2] = swapu32(p->h[2]); + p->h[3] = swapu32(p->h[3]); + #endif + p->offset = 0; +} + +int md5Digest(md5Param* p, uint32* data) +{ + md5Finish(p); + mp32copy(4, data, p->h); + md5Reset(p); + return 0; +} diff --git a/beecrypt/md5.h b/beecrypt/md5.h new file mode 100644 index 0000000..361c5c1 --- /dev/null +++ b/beecrypt/md5.h @@ -0,0 +1,59 @@ +/* + * md5.h + * + * MD5 hash function, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _MD5_H +#define _MD5_H + +#include "beecrypt.h" +/*#include "md5opt.h"*/ + +typedef struct +{ + uint32 h[4]; + uint32 data[16]; + uint64 length; + uint8 offset; +} md5Param; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const hashFunction md5; + +BEEDLLAPI +void md5Process(md5Param*); +BEEDLLAPI +int md5Reset (md5Param*); +BEEDLLAPI +int md5Update (md5Param*, const byte*, int); +BEEDLLAPI +int md5Digest (md5Param*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/memchunk.c b/beecrypt/memchunk.c new file mode 100644 index 0000000..6edf7c7 --- /dev/null +++ b/beecrypt/memchunk.c @@ -0,0 +1,90 @@ +/* + * memchunk.c + * + * BeeCrypt memory block handling, code + * + * Copyright (c) 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "memchunk.h" + +#if HAVE_STDLIB_H +# include +#endif +#if HAVE_MALLOC_H +# include +#endif + +memchunk* memchunkAlloc(int size) +{ + memchunk* tmp = (memchunk*) calloc(1, sizeof(memchunk)); + + if (tmp) + { + tmp->size = size; + tmp->data = (byte*) malloc(size); + + if (tmp->data == (byte*) 0) + { + free(tmp); + tmp = 0; + } + } + + return tmp; +} + +void memchunkFree(memchunk* m) +{ + if (m) + { + if (m->data) + { + free(m->data); + + m->size = 0; + m->data = (byte*) 0; + } + free(m); + } +} + +memchunk* memchunkResize(memchunk* m, int size) +{ + if (m) + { + if (m->data) + m->data = (byte*) realloc(m->data, size); + else + m->data = (byte*) malloc(size); + + if (m->data == (byte*) 0) + { + free(m); + m = (memchunk*) 0; + } + else + m->size = size; + } + + return m; +} diff --git a/beecrypt/memchunk.h b/beecrypt/memchunk.h new file mode 100644 index 0000000..f8495b9 --- /dev/null +++ b/beecrypt/memchunk.h @@ -0,0 +1,53 @@ +/* + * memchunk.h + * + * Beecrypt memory block handling, header + * + * Copyright (c) 2001 Virtual Unlimited B.V. + * + * Author: 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 _MEMCHUNK_H +#define _MEMCHUNK_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +typedef struct +{ + int size; + byte* data; +} memchunk; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +memchunk* memchunkAlloc(int); +BEEDLLAPI +void memchunkFree(memchunk*); +BEEDLLAPI +memchunk* memchunkResize(memchunk*, int); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/missing b/beecrypt/missing new file mode 100755 index 0000000..7789652 --- /dev/null +++ b/beecrypt/missing @@ -0,0 +1,190 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Franc,ois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing - GNU libit 0.0" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`configure.in'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`configure.in'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`configure.in'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/beecrypt/mkinstalldirs b/beecrypt/mkinstalldirs new file mode 100755 index 0000000..6571451 --- /dev/null +++ b/beecrypt/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# Id: mkinstalldirs,v 1.1 2001/03/21 10:50:16 bob Exp + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/beecrypt/mp32.c b/beecrypt/mp32.c new file mode 100644 index 0000000..cd29c87 --- /dev/null +++ b/beecrypt/mp32.c @@ -0,0 +1,1085 @@ +/* + * mp32.c + * + * Multiprecision 2's complement integer routines for 32 bit cpu, code + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "mp32.h" + +#include + +#ifndef ASM_MP32ZERO +void mp32zero(register uint32 xsize, register uint32* xdata) +{ + while (xsize--) + *(xdata++) = 0; +} +#endif + +#ifndef ASM_MP32FILL +void mp32fill(register uint32 xsize, register uint32* xdata, uint32 val) +{ + while (xsize--) + *(xdata++) = val; +} +#endif + +#ifndef ASM_MP32ODD +int mp32odd(register uint32 xsize, register const uint32* xdata) +{ + return (xdata[xsize-1] & 0x1); +} +#endif + +#ifndef ASM_MP32EVEN +int mp32even(register uint32 xsize, register const uint32* xdata) +{ + return !(xdata[xsize-1] & 0x1); +} +#endif + +#ifndef ASM_MP32Z +int mp32z(register uint32 xsize, register const uint32* xdata) +{ + while (xsize--) + if (*(xdata++)) + return 0; + return 1; +} +#endif + +#ifndef ASM_MP32NZ +int mp32nz(register uint32 xsize, register const uint32* xdata) +{ + while (xsize--) + if (*(xdata++)) + return 1; + return 0; +} +#endif + +#ifndef ASM_MP32EQ +int mp32eq(register uint32 size, register const uint32* xdata, register const uint32* ydata) +{ + while (size--) + { + if (*xdata == *ydata) + { + xdata++; + ydata++; + } + else + return 0; + } + + return 1; +} +#endif + +#ifndef ASM_MP32EQX +int mp32eqx(register uint32 xsize, register const uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + if (xsize > ysize) + { + register int diff = xsize - ysize; + return mp32eq(ysize, xdata + diff, ydata) && mp32z(diff, xdata); + } + else if (xsize < ysize) + { + register int diff = ysize - xsize; + return mp32eq(xsize, ydata + diff, xdata) && mp32z(diff, ydata); + } + else + return mp32eq(xsize, xdata, ydata); +} +#endif + +#ifndef ASM_MP32NE +int mp32ne(register uint32 size, register const uint32* xdata, register const uint32* ydata) +{ + while (size--) + { + if (*xdata == *ydata) + { + xdata++; + ydata++; + } + else + return 1; + } + + return 0; +} +#endif + +#ifndef ASM_MP32NEX +int mp32nex(register uint32 xsize, register const uint32* xdata, register uint32 ysize, register const uint32*ydata) +{ + if (xsize > ysize) + { + register int diff = xsize - ysize; + return mp32nz(diff, xdata) || mp32ne(ysize, xdata + diff, ydata); + } + else if (xsize < ysize) + { + register int diff = ysize - xsize; + return mp32nz(diff, ydata) || mp32ne(xsize, ydata + diff, xdata); + } + else + return mp32ne(xsize, xdata, ydata); +} +#endif + +#ifndef ASM_MP32GT +int mp32gt(register uint32 size, register const uint32* xdata, register const uint32* ydata) +{ + while (size--) + { + if (*xdata < *ydata) + return 0; + if (*xdata > *ydata) + return 1; + xdata++; ydata++; + } + return 0; +} +#endif + +#ifndef ASM_MP32GTX +int mp32gtx(register uint32 xsize, register const uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + if (xsize > ysize) + { + register uint32 diff = xsize - ysize; + return mp32nz(diff, xdata) || mp32gt(ysize, xdata + diff, ydata); + } + else if (xsize < ysize) + { + register uint32 diff = ysize - xsize; + return mp32z(diff, ydata) && mp32gt(xsize, xdata, ydata + diff); + } + else + return mp32gt(xsize, xdata, ydata); +} +#endif + +#ifndef ASM_MP32LT +int mp32lt(register uint32 size, register const uint32* xdata, register const uint32* ydata) +{ + while (size--) + { + if (*xdata > *ydata) + return 0; + if (*xdata < *ydata) + return 1; + xdata++; ydata++; + } + return 0; +} +#endif + +#ifndef ASM_MP32LTX +int mp32ltx(register uint32 xsize, register const uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + if (xsize > ysize) + { + register uint32 diff = xsize - ysize; + return mp32z(diff, xdata) && mp32lt(ysize, xdata + diff, ydata); + } + else if (xsize < ysize) + { + register uint32 diff = ysize - xsize; + return mp32nz(diff, ydata) || mp32lt(xsize, xdata, ydata + diff); + } + else + return mp32lt(xsize, xdata, ydata); +} +#endif + +#ifndef ASM_MP32GE +int mp32ge(register uint32 size, register const uint32* xdata, register const uint32* ydata) +{ + while (size--) + { + if (*xdata < *ydata) + return 0; + if (*xdata > *ydata) + return 1; + xdata++; ydata++; + } + return 1; +} +#endif + +#ifndef ASM_MP32GEX +int mp32gex(register uint32 xsize, register const uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + if (xsize > ysize) + { + register uint32 diff = xsize - ysize; + return mp32nz(diff, xdata) || mp32ge(ysize, xdata + diff, ydata); + } + else if (xsize < ysize) + { + register uint32 diff = ysize - xsize; + return mp32z(diff, ydata) && mp32ge(xsize, xdata, ydata + diff); + } + else + return mp32ge(xsize, xdata, ydata); +} +#endif + +#ifndef ASM_MP32LE +int mp32le(register uint32 size, register const uint32* xdata, register const uint32* ydata) +{ + while (size--) + { + if (*xdata < *ydata) + return 1; + if (*xdata > *ydata) + return 0; + xdata++; ydata++; + } + return 1; +} +#endif + +#ifndef ASM_MP32LEX +int mp32lex(register uint32 xsize, register const uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + if (xsize > ysize) + { + register uint32 diff = xsize - ysize; + return mp32z(diff, xdata) && mp32le(ysize, xdata + diff, ydata); + } + else if (xsize < ysize) + { + register uint32 diff = ysize - xsize; + return mp32nz(diff, ydata) || mp32le(xsize, xdata, ydata + diff); + } + else + return mp32le(xsize, xdata, ydata); +} +#endif + + +#ifndef ASM_MP32ISONE +int mp32isone(register uint32 xsize, register const uint32* xdata) +{ + xdata += xsize; + if (*(--xdata) == 1) + { + while (--xsize) + if (*(--xdata)) + return 0; + return 1; + } + return 0; +} +#endif + +#ifndef ASM_MP32EQMONE +int mp32eqmone(register uint32 size, register const uint32* xdata, register const uint32* ydata) +{ + xdata += size; + ydata += size; + + if (*(--xdata)+1 == *(--ydata)) + { + while (--size) + if (*(--xdata) != *(--ydata)) + return 0; + return 1; + } + return 0; +} +#endif + +#ifndef ASM_MP32LEONE +int mp32leone(register uint32 xsize, register const uint32* xdata) +{ + xdata += xsize; + if (*(--xdata) > 1) + return 0; + else + { + while (--xsize) + if (*(--xdata)) + return 0; + return 1; + } +} +#endif + +#ifndef ASM_MP32MSBSET +int mp32msbset(register uint32 xsize, register const uint32* xdata) +{ + return ((*xdata) & 0x80000000); +} +#endif + +#ifndef ASM_MP32LSBSET +int mp32lsbset(register uint32 xsize, register const uint32* xdata) +{ + return xdata[xsize-1] & 0x1; +} +#endif + +#ifndef ASM_MP32SETMSB +void mp32setmsb(register uint32 xsize, register uint32* xdata) +{ + *xdata |= 0x80000000; +} +#endif + +#ifndef ASM_MP32SETLSB +void mp32setlsb(register uint32 xsize, register uint32* xdata) +{ + xdata[xsize-1] |= 0x00000001; +} +#endif + +#ifndef ASM_MP32CLRMSB +void mp32clrmsb(register uint32 xsize, register uint32* xdata) +{ + *xdata &= 0x7fffffff; +} +#endif + +#ifndef ASM_MP32CLRLSB +void mp32clrlsb(register uint32 xsize, register uint32* xdata) +{ + xdata[xsize-1] &= 0xfffffffe; +} +#endif + +#ifndef ASM_MP32XOR +void mp32xor(register uint32 size, register uint32* xdata, register const uint32* ydata) +{ + do + { + --size; + xdata[size] ^= ydata[size]; + } while (size); +} +#endif + +#ifndef ASM_MP32NOT +void mp32not(register uint32 xsize, register uint32* xdata) +{ + do + { + --xsize; + xdata[xsize] = ~xdata[xsize]; + } while (xsize); +} +#endif + +#ifndef ASM_MP32SETW +void mp32setw(register uint32 xsize, register uint32* xdata, register uint32 y) +{ + while (--xsize) + *(xdata++) = 0; + *(xdata++) = y; +} +#endif + +#ifndef ASM_MP32SETX +void mp32setx(register uint32 xsize, register uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + while (xsize > ysize) + { + xsize--; + *(xdata++) = 0; + } + while (ysize > xsize) + { + ysize--; + ydata++; + } + while (xsize--) + *(xdata++) = *(ydata++); +} +#endif + +#ifndef ASM_MP32ADDW +uint32 mp32addw(register uint32 xsize, register uint32* xdata, register uint32 y) +{ + register uint64 temp; + register uint32 carry = 0; + + xdata += xsize; + temp = *(--xdata); + temp += y; + *xdata = (uint32) temp; + while (--xsize && (carry = (uint32) (temp >> 32))) + { + temp = *(--xdata); + temp += carry; + *xdata = (uint32) temp; + } + return (temp >> 32); +} +#endif + +#ifndef ASM_MP32ADD +uint32 mp32add(register uint32 size, register uint32* xdata, register const uint32* ydata) +{ + register uint64 temp; + register uint32 carry = 0; + + xdata += size; + ydata += size; + + while (size--) + { + temp = *(--xdata); + temp += *(--ydata) + carry; + *xdata = (uint32) temp; + carry = (uint32) (temp >> 32); + } + return carry; +} +#endif + +#ifndef ASM_MP32ADDX +uint32 mp32addx(register uint32 xsize, register uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + if (xsize > ysize) + { + register uint32 diff = xsize - ysize; + register uint32 carry = mp32add(ysize, xdata + diff, ydata); + return mp32addw(diff, xdata, carry); + } + else + { + register int diff = ysize - xsize; + return mp32add(xsize, xdata, ydata + diff); + } +} +#endif + +#ifndef ASM_MP32SUBW +uint32 mp32subw(register uint32 xsize, register uint32* xdata, register uint32 y) +{ + register uint64 temp; + register uint32 carry = 0; + + xdata += xsize; + temp = *(--xdata); + temp -= y; + *xdata = (uint32) temp; + carry = (temp >> 32) ? 1 : 0; + while (--xsize && carry) + { + temp = *(--xdata); + temp -= carry; + *xdata = (uint32) temp; + carry = (temp >> 32) ? 1 : 0; + } + return carry; +} +#endif + +#ifndef ASM_MP32SUB +uint32 mp32sub(register uint32 size, register uint32* xdata, register const uint32* ydata) +{ + register uint64 temp; + register uint32 carry = 0; + + xdata += size; + ydata += size; + + while (size--) + { + temp = *(--xdata); + temp -= *(--ydata) + carry; + *xdata = (uint32) temp; + carry = (temp >> 32) != 0; + } + return carry; +} +#endif + +#ifndef ASM_MP32SUBX +uint32 mp32subx(register uint32 xsize, register uint32* xdata, register uint32 ysize, register const uint32* ydata) +{ + if (xsize > ysize) + { + register uint32 diff = xsize - ysize; + register uint32 carry = mp32sub(ysize, xdata + diff, ydata); + return mp32subw(diff, xdata, carry); + } + else + { + register uint32 diff = ysize - xsize; + return mp32sub(xsize, xdata, ydata + diff); + } +} +#endif + +#ifndef ASM_MP32NEG +void mp32neg(register uint32 xsize, register uint32* xdata) +{ + mp32not(xsize, xdata); + mp32addw(xsize, xdata, 1); +} +#endif + +#ifndef ASM_MP32SETMUL +uint32 mp32setmul(register uint32 size, register uint32* result, register const uint32* xdata, register uint32 y) +{ + register uint64 temp; + register uint32 carry = 0; + + xdata += size; + result += size; + + while (size--) + { + temp = *(--xdata); + temp *= y; + temp += carry; + *(--result) = (uint32) temp; + carry = (uint32) (temp >> 32); + } + return carry; +} +#endif + +#ifndef ASM_MP32ADDMUL +uint32 mp32addmul(register uint32 size, register uint32* result, register const uint32* xdata, register uint32 y) +{ + register uint64 temp; + register uint32 carry = 0; + + xdata += size; + result += size; + + while (size--) + { + temp = *(--xdata); + temp *= y; + temp += carry; + temp += *(--result); + *result = (uint32) temp; + carry = (uint32) (temp >> 32); + } + return carry; +} +#endif + +#ifndef ASM_MP32MUL +void mp32mul(uint32* result, uint32 xsize, const uint32* xdata, uint32 ysize, const uint32* ydata) +{ + if (xsize <= ysize) + { + register uint32 rc; + + result += xsize; + xdata += xsize; + + rc = mp32setmul(ysize, result, ydata, *(--xdata)); + *(--result) = rc; + + while (--xsize) + { + rc = mp32addmul(ysize, result, ydata, *(--xdata)); + *(--result) = rc; + } + } + else + { + register uint32 rc; + + result += ysize; + ydata += ysize; + + rc = mp32setmul(xsize, result, xdata, *(--ydata)); + *(--result) = rc; + + while (--ysize) + { + rc = mp32addmul(xsize, result, xdata, *(--ydata)); + *(--result) = rc; + } + } +} +#endif + +#ifndef ASM_MP32ADDSQRTRC +uint32 mp32addsqrtrc(register uint32 size, register uint32* result, register const uint32* xdata) +{ + register uint64 temp; + register uint32 n, carry = 0; + + result += size*2; + + while (size--) + { + temp = n = xdata[size]; + temp *= n; + temp += carry; + temp += *(--result); + *result = (uint32) temp; + temp >>= 32; + temp += *(--result); + *result = (uint32) temp; + carry = (uint32) (temp >> 32); + } + return carry; +} +#endif + +#ifndef ASM_MP32SQR +void mp32sqr(register uint32* result, register uint32 xsize, register const uint32* xdata) +{ + register uint32 carry; + register uint32 n = xsize-1; + + result += xsize; + result[n] = 0; + + if (n) + { + carry = mp32setmul(n, result, xdata, xdata[n]); + *(--result) = carry; + while (--n) + { + carry = mp32addmul(n, result, xdata, xdata[n]); + *(--result) = carry; + } + } + + *(--result) = 0; + + mp32multwo(xsize*2, result); + + mp32addsqrtrc(xsize, result, xdata); +} +#endif + +#ifndef ASM_MP32SIZE +uint32 mp32size(register uint32 xsize, register const uint32* xdata) +{ + while (xsize) + { + if (*xdata) + return xsize; + xdata++; + xsize--; + } + return 0; +} +#endif + +#ifndef ASM_MP32NORM +uint32 mp32norm(register uint32 xsize, register uint32* xdata) +{ + register uint32 shift = mp32mszcnt(xsize, xdata); + mp32lshift(xsize, xdata, shift); + return shift; +} +#endif + +#ifndef ASM_MP32DIVPOWTWO +uint32 mp32divpowtwo(register uint32 xsize, register uint32* xdata) +{ + register uint32 shift = mp32lszcnt(xsize, xdata); + mp32rshift(xsize, xdata, shift); + return shift; +} +#endif + +#ifndef ASM_MP32DIVTWO +void mp32divtwo(register uint32 xsize, register uint32* xdata) +{ + register uint64 temp; + register uint32 carry = 0; + + while (xsize--) + { + temp = *xdata; + *(xdata++) = (temp >> 1) | carry; + carry = (temp << 31); + } +} +#endif + +#ifndef ASM_MP32SDIVTWO +void mp32sdivtwo(register uint32 xsize, register uint32* xdata) +{ + mp32divtwo(xsize, xdata); + if (*xdata & 0x40000000) + *xdata |= 0x80000000; +} +#endif + +#ifndef ASM_MP32MULTWO +uint32 mp32multwo(register uint32 xsize, register uint32* xdata) +{ + register uint32 temp; + register uint32 carry = 0; + + xdata += xsize; + while (xsize--) + { + temp = *(--xdata); + *xdata = (temp << 1) | carry; + carry = (temp >> 31); + } + return carry; +} +#endif + +#ifndef ASM_MP32MSZCNT +uint32 mp32mszcnt(register uint32 xsize, register const uint32* xdata) +{ + register uint32 zbits = 0; + register uint32 i = 0; + + while (i < xsize) + { + register uint32 temp = xdata[i++]; + if (temp) + { + while (!(temp & 0x80000000)) + { + zbits++; + temp <<= 1; + } + break; + } + else + zbits += 32; + } + return zbits; +} +#endif + +#ifndef ASM_MP32LSZCNT +uint32 mp32lszcnt(register uint32 xsize, register const uint32* xdata) +{ + register uint32 zbits = 0; + + while (xsize--) + { + register uint32 temp = xdata[xsize]; + if (temp) + { + while (!(temp & 0x1)) + { + zbits++; + temp >>= 1; + } + break; + } + else + zbits += 32; + } + return zbits; +} +#endif + +#ifndef ASM_MP32LSHIFT +void mp32lshift(register uint32 xsize, register uint32* xdata, uint32 count) +{ + register uint32 words = count >> 5; + + if (words < xsize) + { + register uint8 lbits = (uint8) (count & 0x1f); + + /* first do the shifting, then do the moving */ + if (lbits) + { + register uint32 temp; + register uint32 carry = 0; + register uint8 rbits = 32-lbits; + register int i = xsize; + + while (i > words) + { + temp = xdata[--i]; + xdata[i] = (temp << lbits) | carry; + carry = (temp >> rbits); + } + } + if (words) + { + mp32move(xsize-words, xdata, xdata+words); + mp32zero(words, xdata+xsize-words); + } + } + else + mp32zero(xsize, xdata); +} +#endif + +#ifndef ASM_MP32RSHIFT +void mp32rshift(register uint32 xsize, register uint32* xdata, uint32 count) +{ + register uint32 words = count >> 5; + + if (words < xsize) + { + register uint8 rbits = (uint8) (count & 0x1f); + + /* first do the shifting, then do the moving */ + if (rbits) + { + register uint32 temp; + register uint32 carry = 0; + register uint8 lbits = 32-rbits; + register uint32 i = 0; + + while (i < xsize-words) + { + temp = xdata[i]; + xdata[i++] = (temp >> rbits) | carry; + carry = (temp << lbits); + } + } + if (words) + { + mp32move(xsize-words, xdata+words, xdata); + mp32zero(words, xdata); + } + } + else + mp32zero(xsize, xdata); +} +#endif + +#ifndef ASM_MP32GCD +void mp32gcd(uint32* result, uint32 size, const uint32* xdata, const uint32* ydata, uint32* workspace) +{ + register uint32 shift = 0; + register uint32 temp; + + if (mp32ge(size, xdata, ydata)) + { + mp32copy(size, workspace, xdata); + mp32copy(size, result, ydata); + } + else + { + mp32copy(size, workspace, ydata); + 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, workspace))) + mp32rshift(size, workspace, temp); + + shift = temp; + + if ((temp = mp32lszcnt(size, result))) + mp32rshift(size, result, temp); + + if (shift > temp) + shift = temp; + + while (mp32nz(size, workspace)) + { + if ((temp = mp32lszcnt(size, workspace))) + mp32rshift(size, workspace, temp); + + if ((temp = mp32lszcnt(size, result))) + mp32rshift(size, result, temp); + + if (mp32ge(size, workspace, result)) + mp32sub(size, workspace, result); + else + mp32sub(size, result, workspace); + } + mp32lshift(size, result, shift); +} +#endif + +#ifndef ASM_MP32NMODW +uint32 mp32nmodw(uint32* result, uint32 xsize, const uint32* xdata, uint32 y, uint32* workspace) +{ + /* result size xsize, workspace size xsize+1 */ + register uint64 temp; + register uint32 q; + uint32 qsize = xsize-1; + uint32* rdata = result; + + mp32copy(xsize, rdata, xdata); + /* + if (*rdata >= y) + *rdata -= y; + */ + if (mp32ge(1, rdata, &y)) + mp32sub(1, rdata, &y); + + while (qsize--) + { + /* printf("result = "); MP32println(xsize+1, result); */ + /* get the two high words of r into temp */ + temp = rdata[0]; + temp <<= 32; + temp += rdata[1]; + /* printf("q = %016llx / %08lx\n", temp, msw); */ + temp /= y; + /* + temp *= y; + workspace[0] = (uint32) (temp >> 32); + workspace[1] = (uint32) (temp); + */ + q = (uint32) temp; + + /* printf("q = %08x\n", q); */ + *workspace = mp32setmul(1, workspace+1, &y, q); + + /* printf("mplt "); mp32print(2, rdata); printf(" < "); mp32println(2, workspace); */ + while (mp32lt(2, rdata, workspace)) + { + /* printf("mp32lt! "); mp32print(2, rdata); printf(" < "); mp32println(2, workspace); */ + /* printf("decreasing q\n"); */ + mp32subx(2, workspace, 1, &y); + /* q--; */ + } + /* printf("subtracting\n"); */ + mp32sub(2, rdata, workspace); + rdata++; + } + + return *rdata; +} +#endif + +#ifndef ASM_MP32NMOD +void mp32nmod(uint32* result, uint32 xsize, const uint32* xdata, uint32 ysize, const uint32* ydata, uint32* workspace) +{ + /* result size xsize, workspace size xsize+1 */ + register uint64 temp; + register uint32 q; + uint32 msw = *ydata; + uint32 qsize = xsize-ysize; + uint32* rdata = result; + + mp32copy(xsize, rdata, xdata); + if (mp32ge(ysize, rdata, ydata)) + mp32sub(ysize, rdata, ydata); + + while (qsize--) + { + /* printf("result = "); mp32println(xsize+1, result); */ + /* get the two high words of r into temp */ + temp = rdata[0]; + temp <<= 32; + temp += rdata[1]; + /* printf("q = %016llx / %08lx\n", temp, msw); */ + temp /= msw; + q = (uint32) temp; + + /* printf("q = %08x\n", q); */ + *workspace = mp32setmul(ysize, workspace+1, ydata, q); + + /* printf("mp32lt "); mp32print(ysize+1, rdata); printf(" < "); mp32println(ysize+1, workspace); */ + while (mp32lt(ysize+1, rdata, workspace)) + { + /* printf("mp32lt! "); mp32print(ysize+1, rdata); printf(" < "); mp32println(ysize+1, workspace); */ + /* printf("decreasing q\n"); */ + mp32subx(ysize+1, workspace, ysize, ydata); + q--; + } + /* printf("subtracting\n"); */ + mp32sub(ysize+1, rdata, workspace); + rdata++; + } +} +#endif + +#ifndef ASM_MP32NDIVMOD +void mp32ndivmod(uint32* result, uint32 xsize, const uint32* xdata, uint32 ysize, const uint32* ydata, register uint32* workspace) +{ + /* result must be xsize+1 in length */ + /* workspace must be ysize+1 in length */ + /* expect ydata to be normalized */ + register uint64 temp; + register uint32 q; + uint32 msw = *ydata; + uint32 qsize = xsize-ysize; + + mp32copy(xsize, result+1, xdata); + if (mp32ge(ysize, result+1, ydata)) + { + /* printf("subtracting\n"); */ + mp32sub(ysize, result+1, ydata); + *(result++) = 1; + } + else + *(result++) = 0; + + while (qsize--) + { + /* printf("result = "); mp32println(xsize+1, result); */ + /* get the two high words of r into temp */ + temp = result[0]; + temp <<= 32; + temp += result[1]; + /* printf("q = %016llx / %08lx\n", temp, msw); */ + temp /= msw; + q = (uint32) temp; + + /* printf("q = %08x\n", q); */ + + *workspace = mp32setmul(ysize, workspace+1, ydata, q); + + /* printf("mp32lt "); mp32print(ysize+1, result); printf(" < "); mp32println(ysize+1, workspace); */ + while (mp32lt(ysize+1, result, workspace)) + { + /* printf("mp32lt! "); mp32print(ysize+1, result); printf(" < "); mp32println(ysize+1, workspace); */ + /* printf("decreasing q\n"); */ + mp32subx(ysize+1, workspace, ysize, ydata); + q--; + } + /* printf("subtracting\n"); */ + mp32sub(ysize+1, result, workspace); + *(result++) = q; + } +} +#endif + +#ifndef ASM_MP32PRINT +void mp32print(register uint32 xsize, register const uint32* xdata) +{ + while (xsize--) + printf("%08x", *(xdata++)); +} +#endif + +#ifndef ASM_MP32PRINTLN +void mp32println(register uint32 xsize, register const uint32* xdata) +{ + while (xsize--) + printf("%08x", *(xdata++)); + printf("\n"); +} +#endif diff --git a/beecrypt/mp32.h b/beecrypt/mp32.h new file mode 100644 index 0000000..972fe27 --- /dev/null +++ b/beecrypt/mp32.h @@ -0,0 +1,200 @@ +/* + * mp32.h + * + * Multiprecision 2's complement integer routines for 32 bit cpu, header + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: 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 _MP32_H +#define _MP32_H + +#include "beecrypt.h" + +#if HAVE_STRING_H +#include +#endif + +#include "mp32opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASM_MP32COPY +#define mp32copy(size, dst, src) memcpy(dst, src, (size) << 2) +#else +BEEDLLAPI +void mp32copy(uint32, uint32*, const uint32*); +#endif + +#ifndef ASM_MP32MOVE +#define mp32move(size, dst, src) memmove(dst, src, (size) << 2) +#else +BEEDLLAPI +void mp32move(uint32, uint32*, const uint32*); +#endif + +BEEDLLAPI +void mp32zero(uint32, uint32*); +BEEDLLAPI +void mp32fill(uint32, uint32*, uint32); + +BEEDLLAPI +int mp32odd (uint32, const uint32*); +BEEDLLAPI +int mp32even(uint32, const uint32*); + +BEEDLLAPI +int mp32z (uint32, const uint32*); +BEEDLLAPI +int mp32nz (uint32, const uint32*); +BEEDLLAPI +int mp32eq (uint32, const uint32*, const uint32*); +BEEDLLAPI +int mp32ne (uint32, const uint32*, const uint32*); +BEEDLLAPI +int mp32gt (uint32, const uint32*, const uint32*); +BEEDLLAPI +int mp32lt (uint32, const uint32*, const uint32*); +BEEDLLAPI +int mp32ge (uint32, const uint32*, const uint32*); +BEEDLLAPI +int mp32le (uint32, const uint32*, const uint32*); +BEEDLLAPI +int mp32eqx(uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +int mp32nex(uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +int mp32gtx(uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +int mp32ltx(uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +int mp32gex(uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +int mp32lex(uint32, const uint32*, uint32, const uint32*); + +BEEDLLAPI +int mp32isone(uint32, const uint32*); +BEEDLLAPI +int mp32leone(uint32, const uint32*); +BEEDLLAPI +int mp32eqmone(uint32, const uint32*, const uint32*); + +BEEDLLAPI +int mp32msbset(uint32, const uint32*); +BEEDLLAPI +int mp32lsbset(uint32, const uint32*); + +BEEDLLAPI +void mp32setmsb(uint32, uint32*); +BEEDLLAPI +void mp32setlsb(uint32, uint32*); +BEEDLLAPI +void mp32clrmsb(uint32, uint32*); +BEEDLLAPI +void mp32clrlsb(uint32, uint32*); + +BEEDLLAPI +void mp32xor(uint32, uint32*, const uint32*); +BEEDLLAPI +void mp32not(uint32, uint32*); + +BEEDLLAPI +void mp32setw(uint32, uint32*, uint32); +BEEDLLAPI +void mp32setx(uint32, uint32*, uint32, const uint32*); + +BEEDLLAPI +uint32 mp32addw(uint32, uint32*, uint32); +BEEDLLAPI +uint32 mp32add (uint32, uint32*, const uint32*); +BEEDLLAPI +uint32 mp32addx(uint32, uint32*, uint32, const uint32*); + +BEEDLLAPI +uint32 mp32subw(uint32, uint32*, uint32); +BEEDLLAPI +uint32 mp32sub (uint32, uint32*, const uint32*); +BEEDLLAPI +uint32 mp32subx(uint32, uint32*, uint32, const uint32*); + +BEEDLLAPI +uint32 mp32multwo(uint32, uint32*); + +BEEDLLAPI +void mp32neg(uint32, uint32*); + +BEEDLLAPI +uint32 mp32size(uint32, const uint32*); + +BEEDLLAPI +uint32 mp32mszcnt(uint32, const uint32*); +BEEDLLAPI +uint32 mp32lszcnt(uint32, const uint32*); + +BEEDLLAPI +void mp32lshift(uint32, uint32*, uint32); +BEEDLLAPI +void mp32rshift(uint32, uint32*, uint32); + +BEEDLLAPI +uint32 mp32norm(uint32, uint32*); +BEEDLLAPI +uint32 mp32divpowtwo(uint32, uint32*); + +BEEDLLAPI +void mp32divtwo (uint32, uint32*); +BEEDLLAPI +void mp32sdivtwo(uint32, uint32*); + +BEEDLLAPI +uint32 mp32setmul (uint32, uint32*, const uint32*, uint32); +BEEDLLAPI +uint32 mp32addmul (uint32, uint32*, const uint32*, uint32); +BEEDLLAPI +uint32 mp32addsqrtrc(uint32, uint32*, const uint32*); + +BEEDLLAPI +void mp32mul(uint32*, uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +void mp32sqr(uint32*, uint32, const uint32*); + +BEEDLLAPI +void mp32gcd(uint32*, uint32, const uint32*, const uint32*, uint32*); + +BEEDLLAPI +uint32 mp32nmodw(uint32*, uint32, const uint32*, uint32, uint32*); + +BEEDLLAPI +void mp32nmod(uint32*, uint32, const uint32*, uint32, const uint32*, uint32*); +BEEDLLAPI +void mp32ndivmod(uint32*, uint32, const uint32*, uint32, const uint32*, uint32*); + +BEEDLLAPI +void mp32print(uint32, const uint32*); +BEEDLLAPI +void mp32println(uint32, const uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/mp32barrett.c b/beecrypt/mp32barrett.c new file mode 100644 index 0000000..67e324b --- /dev/null +++ b/beecrypt/mp32barrett.c @@ -0,0 +1,572 @@ +/* + * mp32barrett.c + * + * Barrett modular reduction, code + * + * For more information on this algorithm, see: + * "Handbook of Applied Cryptography", Chapter 14.3.3 + * Menezes, van Oorschot, Vanstone + * CRC Press + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "mp32.h" +#include "mp32prime.h" +#include "mp32barrett.h" + +#if HAVE_STDLIB_H +#include +#endif + +#include + +void mp32bmu(mp32barrett* b) +{ + /* workspace needs to acommodate the dividend (size*2+1), and the divmod result (size*2+1) */ + register uint32 size = b->size; + register uint32* divmod = b->mu-1; /* uses the last word of b->modl, which we made large enough */ + register uint32* dividend = divmod+(size*2+2); + register uint32* workspace = dividend+(size*2+1); + register uint32 shift; + + /* normalize modulus before division */ + shift = mp32norm(size, b->modl); + /* make the dividend, initialize first word to 1 (shifted); the rest is zero */ + *dividend = (1 << shift); + mp32zero(size*2, dividend+1); + mp32ndivmod(divmod, size*2+1, dividend, size, b->modl, workspace); + /* de-normalize */ + mp32rshift(size, b->modl, shift); +} + +void mp32brndres(const mp32barrett* b, uint32* result, randomGeneratorContext* rc) +{ + uint32 msz = mp32mszcnt(b->size, b->modl); + + mp32copy(b->size, b->wksp, b->modl); + mp32subw(b->size, b->wksp, 1); + + do + { + rc->rng->next(rc->param, result, b->size); + + result[0] &= (0xffffffff >> msz); + + while (mp32ge(b->size, result, b->wksp)) + mp32sub(b->size, result, b->wksp); + } while (mp32leone(b->size, result)); +} + +void mp32bmodres(const mp32barrett* b, uint32* result, const uint32* xdata) +{ + register uint32 rc; + register uint32 sp = 2; + register const uint32* src = xdata+b->size+1; + register uint32* dst = b->wksp+b->size+1; + + rc = mp32setmul(sp, dst, b->mu, *(--src)); + *(--dst) = rc; + + while (sp <= b->size) + { + sp++; + if ((rc = *(--src))) + { + rc = mp32addmul(sp, dst, b->mu, rc); + *(--dst) = rc; + } + else + *(--dst) = 0; + } + if ((rc = *(--src))) + { + rc = mp32addmul(sp, dst, b->mu, rc); + *(--dst) = rc; + } + else + *(--dst) = 0; + + /* q3 is one word larger than b->modl */ + /* r2 is (2*size+1) words, of which we only needs the (size+1) lsw's */ + + sp = b->size; + rc = 0; + + dst = b->wksp+b->size+1; + src = dst; + + *dst = mp32setmul(sp, dst+1, b->modl, *(--src)); + + while (sp > 0) + { + mp32addmul(sp--, dst, b->modl+(rc++), *(--src)); + } + + mp32setx(b->size+1, b->wksp, b->size*2, xdata); + mp32sub(b->size+1, b->wksp, b->wksp+b->size+1); + while (mp32gex(b->size+1, b->wksp, b->size, b->modl)) + { + mp32subx(b->size+1, b->wksp, b->size, b->modl); + } + mp32copy(b->size, result, b->wksp+1); +} + +void mp32binit(mp32barrett* b, uint32 size) +{ + /* data, modulus and mu take 3*size+2 words, wksp needed = 7*size+2; total = 10*size+4 */ + b->size = size; + b->data = (uint32*) calloc(size*10+4, sizeof(uint32)); + + if (b->data) + { + b->modl = b->data+size+0; + b->mu = b->modl+size+1; + b->wksp = b->mu +size+1; + } + else + { + b->modl = b->mu = b->wksp = (uint32*) 0; + } +} + +void mp32bzero(mp32barrett* b) +{ + b->size = 0; + b->data = b->modl = b->mu = b->wksp = (uint32*) 0; +} + +void mp32bfree(mp32barrett* b) +{ + if (b->data) + { + free(b->data); + b->data = b->modl = b->mu = b->wksp = (uint32*) 0; + } + b->size = 0; +} + +void mp32bset(mp32barrett* b, uint32 size, const uint32 *data) +{ + /* assumes that the msw of data is not zero */ + if (b->data) + mp32bfree(b); + + if (size) + { + mp32binit(b, size); + + if (b->data) + { + mp32copy(size, b->modl, data); + mp32bmu(b); + } + } +} + +/* function mp32bsethex would be very useful! */ + +void mp32bmod(const mp32barrett* b, uint32 xsize, const uint32* xdata) +{ + register uint32 size = b->size; + register uint32* opnd = b->wksp + size*2+2; + + mp32setx(size*2, opnd, xsize, xdata); + mp32bmodres(b, b->data, opnd); +} + +void mp32bmodsubone(const mp32barrett* b) +{ + register uint32 size = b->size; + + mp32copy(size, b->data, b->modl); + mp32subw(size, b->data, 1); +} + +void mp32bneg(const mp32barrett* b) +{ + register uint32 size = b->size; + + mp32neg(size, b->data); + mp32add(size, b->data, b->modl); +} + +void mp32baddmod(const mp32barrett* b, uint32 xsize, const uint32* xdata, uint32 ysize, const uint32* ydata) +{ + register uint32 size = b->size; + register uint32* opnd = b->wksp+size*2+2; + + mp32setx(2*size, opnd, xsize, xdata); + mp32addx(2*size, opnd, ysize, ydata); + + mp32bmodres(b, b->data, opnd); +} + +void mp32bmulmodres(const mp32barrett* b, uint32* result, uint32 xsize, const uint32* xdata, uint32 ysize, const uint32* ydata) +{ + /* needs workspace of (size*2) in addition to what is needed by mp32bmodres (size*2+2) */ + /* xsize and ysize must be <= b->size */ + /* stores result in b->data */ + register uint32 size = b->size; + register uint32 fill = 2*size-xsize-ysize; + register uint32* opnd = b->wksp+size*2+2; + + if (fill) + mp32zero(fill, opnd); + + mp32mul(opnd+fill, xsize, xdata, ysize, ydata); + mp32bmodres(b, result, opnd); +} + +void mp32bsqrmodres(const mp32barrett* b, uint32* result, uint32 xsize, const uint32* xdata) +{ + /* needs workspace of (size*2) in addition to what is needed by mp32bmodres (size*2+2) */ + /* xsize must be <= b->size */ + register uint32 size = b->size; + register uint32 fill = 2*(size-xsize); + register uint32* opnd = b->wksp + size*2+2; + + if (fill) + mp32zero(fill, opnd); + + mp32sqr(opnd+fill, xsize, xdata); + mp32bmodres(b, result, opnd); +} + +void mp32bmulmod(const mp32barrett* b, uint32 xsize, const uint32* xdata, uint32 ysize, const uint32* ydata) +{ + mp32bmulmodres(b, b->data, xsize, xdata, ysize, ydata); +} + +void mp32bsqrmod(const mp32barrett* b, uint32 xsize, const uint32* xdata) +{ + mp32bsqrmodres(b, b->data, xsize, xdata); +} + +void mp32bpowmod(const mp32barrett* b, uint32 xsize, const uint32* xdata, uint32 psize, const uint32* pdata) +{ + /* + * Modular exponention + * + * Uses left-to-right exponentiation; needs no extra storage + * + */ + + /* this routine calls mp32bmod, which needs (size*2+2), this routine needs (size*2) for sdata */ + + register uint32 temp; + + mp32setw(b->size, b->data, 1); + + while (psize) + { + if ((temp = *(pdata++))) /* break when first non-zero word found */ + break; + psize--; + } + + /* if temp is still zero, then we're trying to raise x to power zero, and result stays one */ + if (temp) + { + register int count = 32; + + /* first skip bits until we reach a one */ + while (count) + { + if (temp & 0x80000000) + break; + temp <<= 1; + count--; + } + + while (psize) + { + while (count) + { + /* always square */ + mp32bnsqrmodres(b, b->data, (mp32number*) b); + + /* multiply by x if bit is 1 */ + if (temp & 0x80000000) + mp32bmulmod(b, xsize, xdata, b->size, b->data); + + temp <<= 1; + count--; + } + if (--psize) + { + count = 32; + temp = *(pdata++); + } + } + } +} + +void mp32btwopowmod(const mp32barrett* b, uint32 psize, const uint32* pdata) +{ + /* + * Modular exponention, 2^p mod modulus, special optimization + * + * Uses left-to-right exponentiation; needs no extra storage + * + */ + + /* this routine calls mp32bmod, which needs (size*2+2), this routine needs (size*2) for sdata */ + + register uint32 temp; + + mp32setw(b->size, b->data, 1); + + while (psize) + { + if ((temp = *(pdata++))) /* break when first non-zero word found */ + break; + psize--; + } + + /* if temp is still zero, then we're trying to raise x to power zero, and result stays one */ + if (temp) + { + register int count = 32; + + /* first skip bits until we reach a one */ + while (count) + { + if (temp & 0x80000000) + break; + temp <<= 1; + count--; + } + + while (psize) + { + while (count) + { + /* always square */ + mp32bnsqrmodres(b, b->data, (mp32number*) b); + + /* multiply by two if bit is 1 */ + if (temp & 0x80000000) + { + if (mp32add(b->size, b->data, b->data) || mp32ge(b->size, b->data, b->modl)) + { + /* there was carry, or the result is greater than the modulus, so we need to adjust */ + mp32sub(b->size, b->data, b->modl); + } + } + + temp <<= 1; + count--; + } + if (psize--) + { + count = 32; + temp = *(pdata++); + } + } + } +} + +int mp32binv(const mp32barrett* b, uint32 xsize, const uint32* xdata) +{ + /* + * Fact: if a element of Zn, then a is invertible if and only if gcd(a,n) = 1 + * + */ + + /* where x or modl is odd, that algorithm will need (4*size+4) */ + + if (mp32odd(b->size, b->modl)) + { + /* use simplified binary extended gcd algorithm */ + + register uint32 size = b->size; + + uint32* udata = b->wksp; + uint32* vdata = udata+size+1; + uint32* bdata = vdata+size+1; + uint32* ddata = bdata+size+1; + + mp32setx(size+1, udata, size, b->modl); + mp32setx(size+1, vdata, xsize, xdata); + mp32zero(size+1, bdata); + mp32setw(size+1, ddata, 1); + + while (1) + { + while (mp32even(size+1, udata)) + { + mp32divtwo(size+1, udata); + + if (mp32odd(size+1, bdata)) + mp32subx(size+1, bdata, size, b->modl); + + mp32sdivtwo(size+1, bdata); + } + while (mp32even(size+1, vdata)) + { + mp32divtwo(size+1, vdata); + + if (mp32odd(size+1, ddata)) + mp32subx(size+1, ddata, size, b->modl); + + mp32sdivtwo(size+1, ddata); + } + if (mp32ge(size+1, udata, vdata)) + { + mp32sub(size+1, udata, vdata); + mp32sub(size+1, bdata, ddata); + } + else + { + mp32sub(size+1, vdata, udata); + mp32sub(size+1, ddata, bdata); + } + + if (mp32z(size+1, udata)) + { + if (mp32isone(size+1, vdata)) + { + mp32setx(size, b->data, size+1, ddata); + if (*ddata & 0x80000000) + mp32add(size, b->data, b->modl); + + return 1; + } + return 0; + } + } + } + else + { + /* + * If x is even, then it is not invertible + * + */ + + if (mp32even(xsize, xdata)) + return 0; + + /* use simplified binary extended gcd algorithm */ + + /* INCOMPLETE */ + return 0; + } +} + +int mp32bpprime(const mp32barrett* b, randomGeneratorContext* r, int t) +{ + /* + * This test works for candidate probable primes >= 3, which are also not small primes + * + * It assumes that b->modl contains the candidate prime + * + */ + + /* first test if modl is odd */ + + if (mp32odd(b->size, b->modl)) + { + /* + * Small prime factor test: + * + * Tables in mp32spprod contain multi-precision integers with products of small primes + * If the greatest common divisor of this product and the candidate is not one, then + * the candidate has small prime factors, or is a small prime. Neither is acceptable when + * we are looking for large probable primes =) + * + */ + + if (b->size > SMALL_PRIMES_PRODUCT_MAX) + { + mp32setx(b->size, b->wksp+b->size, SMALL_PRIMES_PRODUCT_MAX, mp32spprod[SMALL_PRIMES_PRODUCT_MAX-1]); + mp32gcd(b->data, b->size, b->modl, b->wksp+b->size, b->wksp); + } + else + { + mp32gcd(b->data, b->size, b->modl, mp32spprod[b->size-1], b->wksp); + } + + if (mp32isone(b->size, b->data)) + { + return mp32pmilrab(b, r, t); + } + } + + return 0; +} + +void mp32brnd(const mp32barrett* b, randomGeneratorContext* rc) +{ + mp32brndres(b, b->data, rc); +} + +void mp32bnmulmodres(const mp32barrett* b, uint32* result, const mp32number* x, const mp32number* y) +{ + /* needs workspace of (size*2) in addition to what is needed by mp32bmodres (size*2+2) */ + /* xsize and ysize must be <= b->size */ + /* stores result in b->data */ + register uint32 size = b->size; + register uint32 fill = 2*size-x->size-y->size; + register uint32* opnd = b->wksp+size*2+2; + + if (fill) + mp32zero(fill, opnd); + + mp32mul(opnd+fill, x->size, x->data, y->size, y->data); + mp32bmodres(b, result, opnd); +} + +void mp32bnsqrmodres(const mp32barrett* b, uint32* result, const mp32number* x) +{ + /* needs workspace of (size*2) in addition to what is needed by mp32bmodres (size*2+2) */ + /* xsize must be <= b->size */ + register uint32 size = b->size; + register uint32 fill = 2*(size-x->size); + register uint32* opnd = b->wksp + size*2+2; + + if (fill) + mp32zero(fill, opnd); + + mp32sqr(opnd+fill, x->size, x->data); + mp32bmodres(b, result, opnd); +} + +void mp32bnmulmod(const mp32barrett* b, const mp32number* x, const mp32number* y) +{ + mp32bnmulmodres(b, b->data, x, y); +} + +void mp32bnpowmod(const mp32barrett* b, const mp32number* x, const mp32number* y) +{ + mp32bpowmod(b, x->size, x->data, y->size, y->data); +} + +void mp32bnsqrmod(const mp32barrett* b, const mp32number* x) +{ + mp32bnsqrmodres(b, b->data, x); +} + +void mp32bspowmod3(const mp32number* b, const uint32* x0, const uint32* p0, const uint32* x1, const uint32* p1, const uint32* x2, const uint32* p2) +{ + /* this algorithm needs (size*8) storage, which won't fit in the normal buffer */ +} diff --git a/beecrypt/mp32barrett.h b/beecrypt/mp32barrett.h new file mode 100644 index 0000000..ad27278 --- /dev/null +++ b/beecrypt/mp32barrett.h @@ -0,0 +1,118 @@ +/* + * mp32barrett.h + * + * Barrett modular reduction, header + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: 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 _MP32BARRETT_H +#define _MP32BARRETT_H + +#include "beecrypt.h" +#include "mp32number.h" + +typedef struct +{ + uint32 size; + uint32* data; /* (size) words / allocated on one block of 9*size+5 words and set the other pointers appropriately */ + uint32* modl; /* (size+1) words */ + uint32* mu; /* (size+1) words */ + uint32* wksp; /* (6*size+4) words */ +} mp32barrett; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void mp32bzero (mp32barrett*); +BEEDLLAPI +void mp32binit (mp32barrett*, uint32); +BEEDLLAPI +void mp32bfree (mp32barrett*); +BEEDLLAPI +void mp32bset (mp32barrett*, uint32, const uint32*); + +BEEDLLAPI +void mp32bmu (mp32barrett*); + +BEEDLLAPI +void mp32brnd (const mp32barrett*, randomGeneratorContext*); +BEEDLLAPI +void mp32brndres (const mp32barrett*, uint32*, randomGeneratorContext*); + +BEEDLLAPI +void mp32bmodsubone(const mp32barrett*); +BEEDLLAPI +void mp32bneg (const mp32barrett*); + +BEEDLLAPI +void mp32bmod (const mp32barrett*, uint32, const uint32*); +BEEDLLAPI +void mp32baddmod (const mp32barrett*, uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +void mp32bsubmod (const mp32barrett*, uint32, const uint32*, uint32, const uint32*); + +BEEDLLAPI +void mp32bmulmodres(const mp32barrett*, uint32*, uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +void mp32bsqrmodres(const mp32barrett*, uint32*, uint32, const uint32*); + +BEEDLLAPI +void mp32bmulmod (const mp32barrett*, uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +void mp32bsqrmod (const mp32barrett*, uint32, const uint32*); + +BEEDLLAPI +void mp32bpowmod (const mp32barrett*, uint32, const uint32*, uint32, const uint32*); +BEEDLLAPI +void mp32btwopowmod(const mp32barrett*, uint32, const uint32*); + +/* simultaneous multiple exponentiation, for use in dsa and elgamal signature verification */ + +BEEDLLAPI +void mp32bsm2powmod(const mp32barrett*, const uint32*, const uint32*, const uint32*, const uint32*); +BEEDLLAPI +void mp32bsm3powmod(const mp32barrett*, const uint32*, const uint32*, const uint32*, const uint32*, const uint32*, const uint32*); + +BEEDLLAPI +int mp32binv (const mp32barrett*, uint32, const uint32*); + +BEEDLLAPI +int mp32bpprime (const mp32barrett*, randomGeneratorContext*, int); + +/* the next routines take mp32numbers as parameters */ + +BEEDLLAPI +void mp32bnmulmodres(const mp32barrett*, uint32*, const mp32number*, const mp32number*); +BEEDLLAPI +void mp32bnsqrmodres(const mp32barrett*, uint32*, const mp32number*); + +BEEDLLAPI +void mp32bnpowmod (const mp32barrett*, const mp32number*, const mp32number*); +BEEDLLAPI +void mp32bnsqrmod (const mp32barrett*, const mp32number*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/mp32number.c b/beecrypt/mp32number.c new file mode 100644 index 0000000..ede59b0 --- /dev/null +++ b/beecrypt/mp32number.c @@ -0,0 +1,160 @@ +/* + * mp32number.c + * + * Multiple precision numbers, code + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "mp32number.h" +#include "mp32.h" + +#if HAVE_STDLIB_H +#include +#endif + +void mp32nzero(mp32number* n) +{ + n->size = 0; + n->data = (uint32*) 0; +} + +void mp32nsize(mp32number* n, uint32 size) +{ + n->size = size; + n->data = (uint32*) malloc(size * sizeof(uint32)); +} + +void mp32ninit(mp32number* n, uint32 size, const uint32* data) +{ + n->size = size; + n->data = (uint32*) malloc(size * sizeof(uint32)); + + if (n->data) + { + mp32copy(size, n->data, data); + } +} + +void mp32nfree(mp32number* n) +{ + if (n->data) + { + free(n->data); + n->data = (uint32*) 0; + } + n->size = 0; +} + +void mp32nset(mp32number* n, uint32 size, const uint32* data) +{ + if (size) + { + if (n->data) + { + if (n->size != size) + n->data = (uint32*) realloc(n->data, size * sizeof(uint32)); + } + else + { + n->data = (uint32*) malloc(size * sizeof(uint32)); + } + } + else + { + free(n->data); + n->data = (uint32*) 0; + } + + if (n->data) + { + n->size = size; + mp32copy(size, n->data, data); + } + else + n->size = 0; +} + +void mp32nsetw(mp32number* n, uint32 val) +{ + if (n->data) + { + if (n->size != 1) + n->data = (uint32*) realloc(n->data, sizeof(uint32)); + } + else + n->data = (uint32*) malloc(sizeof(uint32)); + + if (n->data) + { + n->size = 1; + n->data[0] = val; + } + else + n->size = 0; +} + +void mp32nsethex(mp32number* n, const char* hex) +{ + int length = strlen(hex); + int size = (length+7) >> 3; + int rem = length & 0x7; + + if (n->data) + { + if (n->size != size) + n->data = (uint32*) realloc(n->data, size * sizeof(uint32)); + } + else + n->data = (uint32*) malloc(size * sizeof(uint32)); + + if (n->data) + { + register uint32 temp = 0; + register uint32* dst = n->data; + register char ch; + + n->size = size; + + while (length-- > 0) + { + ch = *(hex++); + temp <<= 4; + if (ch >= '0' && ch <= '9') + temp += (ch - '0'); + else if (ch >= 'A' && ch <= 'F') + temp += (ch - 'A') + 10; + else if (ch >= 'a' && ch <= 'f') + temp += (ch - 'a') + 10; + + if ((length & 0x7) == 0) + { + *(dst++) = temp; + temp = 0; + } + } + if (rem) + *dst = temp; + } + else + n->size = 0; +} diff --git a/beecrypt/mp32number.h b/beecrypt/mp32number.h new file mode 100644 index 0000000..3ada02d --- /dev/null +++ b/beecrypt/mp32number.h @@ -0,0 +1,61 @@ +/* + * mp32number.h + * + * Multiprecision numbers, header + * + * Copyright (c) 1997-2000 Virtual Unlimited B.V. + * + * Author: 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 _MP32NUMBER_H +#define _MP32NUMBER_H + +#include "beecrypt.h" + +typedef struct +{ + uint32 size; + uint32* data; +} mp32number; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +void mp32nzero(mp32number*); +BEEDLLAPI +void mp32nsize(mp32number*, uint32); +BEEDLLAPI +void mp32ninit(mp32number*, uint32, const uint32*); +BEEDLLAPI +void mp32nfree(mp32number*); + +BEEDLLAPI +void mp32nset (mp32number*, uint32, const uint32*); +BEEDLLAPI +void mp32nsetw (mp32number*, uint32); +BEEDLLAPI +void mp32nsethex(mp32number*, const char*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/mp32opt.c b/beecrypt/mp32opt.c new file mode 100644 index 0000000..ddebca2 --- /dev/null +++ b/beecrypt/mp32opt.c @@ -0,0 +1,28 @@ +/* + * mp32opt.c + * + * Inline assembler optimized multi-precision integer routines + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "mp32opt.h" diff --git a/beecrypt/mp32opt.h b/beecrypt/mp32opt.h new file mode 100644 index 0000000..6fb5a21 --- /dev/null +++ b/beecrypt/mp32opt.h @@ -0,0 +1,87 @@ +/* + * mp32opt.h + * + * Multiprecision integer assembler-optimized routined for 32 bit cpu, header + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 _MP32OPT_H +#define _MP32OPT_H + +#include "beecrypt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if WIN32 +#if __INTEL__ && __MWERKS__ +#define ASM_MP32ADDW +#define ASM_MP32ADD +#define ASM_MP32SUBW +#define ASM_MP32SUB +#define ASM_MP32MULTWO +#define ASM_MP32SETMUL +#define ASM_MP32ADDMUL +#define ASM_MP32ADDSQRTRC +#endif +#endif + +#ifdef __GNUC__ +#ifdef i386 +#define ASM_MP32ADDW +#define ASM_MP32ADD +#define ASM_MP32SUBW +#define ASM_MP32SUB +#define ASM_MP32MULTWO +#define ASM_MP32SETMUL +#define ASM_MP32ADDMUL +#define ASM_MP32ADDSQRTRC +#endif +#ifdef powerpc +#define ASM_MP32ADDW +#define ASM_MP32ADD +/* there's still a problem to be fixed in the subtraction routines */ +#undef ASM_MP32SUBW +#undef ASM_MP32SUB +#define ASM_MP32SETMUL +#define ASM_MP32ADDMUL +#define ASM_MP32ADDSQRTRC +#endif +#endif + +#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +#if defined(sparcv9) || defined(sparcv8plus) +#define ASM_MP32ADDW +#define ASM_MP32ADD +#define ASM_MP32SUBW +#define ASM_MP32SUB +#define ASM_MP32SETMUL +#define ASM_MP32ADDMUL +#undef ASM_MP32ADDSQRTRC +# endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/mp32prime.c b/beecrypt/mp32prime.c new file mode 100644 index 0000000..c81eca1 --- /dev/null +++ b/beecrypt/mp32prime.c @@ -0,0 +1,1217 @@ +/* + * mp32prime.c + * + * Multi-precision primes, code + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "mp32prime.h" +#include "mp32.h" +#include "mp32barrett.h" + +#if HAVE_STDLIB_H +#include +#endif + +#include + +/* + * A word of explanation here on what this table accomplishes: + * + * For fast checking whether a candidate prime can be divided by small primes, we use this table, + * which contains the products of all small primes starting at 3, up to a word size equal to the size + * of the candidate tested. + * + * Instead of trying each small prime in successive divisions, we compute one gcd with a product of small + * primes from this table. + * If the gcd result is not 1, the candidate is divisable by at least one of the small primes(*). If the gcd + * result is 1, then we can subject the candidate to a probabilistic test. + * + * (*) Note: the candidate prime could also be one of the small primes, in which is it IS prime, + * but too small to be of cryptographic interest. Hence, use only for candidate primes that are large enough. + */ + +static uint32 spp_01[] = /* primes 3 to 29 */ +{ 0xc0cfd797 }; + +static uint32 spp_02[] = /* primes 3 to 53 */ +{ 0xe221f97c, 0x30e94e1d }; + +static uint32 spp_03[] = /* primes 3 to 73 */ +{ 0x41cd66ac, 0xc237b226, 0x81a18067 }; + +static uint32 spp_04[] = /* primes 3 to 101 */ +{ 0x5797d47c, 0x51681549, 0xd734e4fc, 0x4c3eaf7f }; + +static uint32 spp_05[] = /* primes 3 to 113 */ +{ 0x02c4b8d0, 0xd2e0d937, 0x3935200f, 0xb49be231, + 0x5ce1a307 }; + +static uint32 spp_06[] = /* primes 3 to 149 */ +{ 0x1e6d8e2a, 0x0ffceafb, 0xbcbfc14a, 0x4c3bc1e1, + 0x009c6a22, 0xa0a7adf5 }; + +static uint32 spp_07[] = /* primes 3 to 167 */ +{ 0x049265d3, 0x574cefd0, 0x4229bfd6, 0x62a4a46f, + 0x8611ed02, 0x26c655f0, 0x76ebade3 }; + +static uint32 spp_08[] = /* primes 3 to 193 */ +{ 0xdbf05b6f, 0x5654b3c0, 0xf5243551, 0x43958688, + 0x9f155887, 0x819aed2a, 0xc05b9335, 0x2be98677 }; + +static uint32 spp_09[] = /* primes 3 to 223 */ +{ 0x5e75cec8, 0xb5de5ea1, 0x5da8302a, 0x2f28b4ad, + 0x2735bdc3, 0x9344c52e, 0x67570925, 0x6feb71ef, + 0x6811d741 }; + +static uint32 spp_10[] = /* primes 3 to 239 */ +{ 0x3faa5dad, 0xb695ce58, 0x4a579328, 0xeab20f1f, + 0xef00fe27, 0xffc36456, 0x0a65723e, 0x27d8884a, + 0xd59da0a9, 0x92f77529 }; + +static uint32 spp_11[] = /* primes 3 to 263 */ +{ 0x3c9b6e49, 0xb7cf685b, 0xe7f3a239, 0xfb4084cb, + 0x166885e3, 0x9d4f65b4, 0x0bb0e51c, 0x0a5d36fe, + 0x98c32069, 0xfd5c441c, 0x6d82f115 }; + +static uint32 spp_12[] = /* primes 3 to 281 */ +{ 0x501201cc, 0x51a492a5, 0x44d3900a, 0xd4f8b32a, + 0x203c8584, 0x06a4457c, 0xab0b4f80, 0x5ab18ac6, + 0xeb9572ac, 0x6e9394fa, 0x522bffb6, 0xf44af2f3 }; + +static uint32 spp_13[] = /* primes 3 to 311 */ +{ 0x9397b5b4, 0x414dc331, 0x04561364, 0x79958cc8, + 0xfd5ea01f, 0x5d5e9f61, 0xbd0f1cb6, 0x24af7e6a, + 0x3284dbb2, 0x9857622b, 0x8be980a6, 0x5456a5c1, + 0xed928009 }; + +static uint32 spp_14[] = /* primes 3 to 331 */ +{ 0x0120eb4d, 0x70279230, 0x9ed122fc, 0xe0488be4, + 0x1d0c99f5, 0xd8c039ad, 0x058c90b4, 0x780500fe, + 0xf39c05cc, 0x09817a27, 0xc3e1776a, 0x246b6af2, + 0x946a10d6, 0x6eafaedf }; + +static uint32 spp_15[] = /* primes 3 to 353 */ +{ 0x03c91dd1, 0x2e893191, 0x94095649, 0x874b41d6, + 0x05810c06, 0x195d70eb, 0xbd54a862, 0x50c52733, + 0x06dc6648, 0x1c251ca4, 0xa02c9a04, 0x78c96f0d, + 0x02f0db0b, 0x39d624ca, 0x0b0441c1 }; + +static uint32 spp_16[] = /* primes 3 to 379 */ +{ 0x106aa9fb, 0x7646fa6e, 0xb0813c28, 0xc5d5f09f, + 0x077ec3ba, 0x238bfb99, 0xc1b631a2, 0x03e81187, + 0x233db117, 0xcbc38405, 0x6ef04659, 0xa4a11de4, + 0x9f7ecb29, 0xbada8f98, 0x0decece9, 0x2e30c48f }; + +static uint32 spp_17[] = /* primes 3 to 401 */ +{ 0x5aa88d8c, 0x594bb372, 0xc4bc813f, 0x4a87a266, + 0x1f984840, 0xdab15692, 0x2c2a177d, 0x95843665, + 0x6f36d41a, 0x11c35ccc, 0x2904b7e9, 0xc424eb61, + 0x3b3536a4, 0x0b2745bd, 0xadf1a6c9, 0x7b23e85a, + 0xdc6695c1 }; + +static uint32 spp_18[] = /* primes 3 to 421 */ +{ 0x0185dbeb, 0x2b8b11d3, 0x7633e9dc, 0x1eec5415, + 0x65c6ce84, 0x31d227ee, 0x28f0328a, 0x60c90118, + 0xae031cc5, 0xa781c824, 0xd1f16d25, 0xf4f0cccf, + 0xf35e9745, 0x79072ec8, 0xcaf1ac8e, 0xefd5566f, + 0xa15fb94f, 0xe34f5d37 }; + +static uint32 spp_19[] = /* primes 3 to 443 */ +{ 0x0cde6fd1, 0xcf108066, 0xcc548df9, 0x070e102c, + 0x2c651b88, 0x5f24f503, 0xaaffe276, 0xfeb57311, + 0x0c1e4592, 0xa35890d7, 0x678aaeee, 0x9f44800f, + 0xc43f999d, 0x5d06b89f, 0xcb22e533, 0x5a9287bc, + 0x6d75a3e9, 0x1e53906d, 0x413163d5 }; + +static uint32 spp_20[] = /* primes 3 to 463 */ +{ 0x833a505c, 0xf9922bee, 0xc80265a6, 0xd50e1cce, + 0xa22f6fec, 0x2eb84450, 0xcec64a3c, 0x0e10d472, + 0xdd653b9b, 0x51d81d0e, 0x3a3142ea, 0x49b91e3a, + 0x5e210232, 0x67bda426, 0x738730cf, 0xb8e6e2ae, + 0xc08c9d4b, 0xd2420066, 0xdccf95ef, 0x49a560b7 }; + +static uint32 spp_21[] = /* primes 3 to 487 */ +{ 0x035417f1, 0xe321c06c, 0xbe32ffce, 0xae752cc9, + 0xa9fe11a6, 0x3d94c946, 0x456edd7d, 0x5a060de1, + 0x84a826a6, 0xf0740c13, 0x48fa1038, 0x911d771d, + 0xb3773e87, 0x52300c29, 0xc82c3012, 0x131673bb, + 0x491cbd61, 0x55e565af, 0x4a9f4331, 0x0adbb0d7, + 0x06e86f6d }; + +static uint32 spp_22[] = /* primes 3 to 509 */ +{ 0x309d024b, 0xd5380319, 0x2ca33469, 0x0bafb43a, + 0x0abd5840, 0xfbeb24d1, 0xf49b6330, 0x47902bae, + 0x581ca4cb, 0xa778fdb1, 0x6dc0a6af, 0xef960687, + 0x16855d95, 0x93746604, 0x201f1919, 0xb725fcb7, + 0x8ffd0db8, 0xe8fa61a1, 0x6e1c0970, 0xbeb81adc, + 0xf49c82df, 0xf960d36f }; + +static uint32 spp_23[] = /* primes 3 to 541 */ +{ 0x01ab244a, 0x33bc047e, 0x804590b4, 0xc3207237, + 0xea503fa0, 0x7541b251, 0x57cfd03f, 0xf602c9d0, + 0x3dcd12ba, 0xa4947ae6, 0xc6ee61be, 0xedf6c716, + 0xfa45377d, 0x5b3c84fa, 0x5fb78b41, 0x395251eb, + 0xb6a5129c, 0x7699fb5c, 0xccec6d45, 0x56c9b8ea, + 0xfa05897c, 0xb8c5cf72, 0xb77603d9 }; + +static uint32 spp_24[] = /* primes 3 to 569 */ +{ 0x25eac89f, 0x8d4da338, 0x337b4985, 0x0d2d1489, + 0x2663177b, 0x4010af3d, 0xd23eeb0b, 0x228f3832, + 0xffcee2e5, 0xcbd1acc9, 0x8f47f251, 0x873380ae, + 0x10f0ffdd, 0x8e602ffa, 0x210f41f6, 0x69a1570a, + 0x93c158c1, 0xa9a8227f, 0xf81a90c5, 0x630e9c44, + 0x845c755c, 0x7df35a7d, 0x430c679a, 0x11575655 }; + +static uint32 spp_25[] = /* primes 3 to 587 */ +{ 0x01b515a8, 0xdca3d6e4, 0x69090373, 0x84febfe8, + 0xf32e06cf, 0x9bde8c89, 0x6b3f992f, 0x2ff23508, + 0xe1c01024, 0x3b8ad0c4, 0xac54e7c7, 0x3f4081d8, + 0xe495d54d, 0x74ed01e8, 0x9dfcbdde, 0x1fe7e61a, + 0x839bd902, 0xf43bf273, 0x2441f0ae, 0xb4211c70, + 0x6b3faafc, 0x0f200b35, 0x7485ce4a, 0x2f08f148, + 0xcce6887d }; + +static uint32 spp_26[] = /* primes 3 to 607 */ +{ 0x3383219d, 0x26454f06, 0xe2789b7f, 0x9c3b940e, + 0x03be2105, 0x798e3ff7, 0x945bd325, 0x997bc262, + 0x025598f8, 0x8577748e, 0xc7155ff8, 0x8a1ff4c9, + 0x2ce95bd8, 0xb015101f, 0x19b73b14, 0x81627f9a, + 0x6f83da3a, 0x03259fbd, 0x41f92a6e, 0x85ac6efa, + 0xde195be8, 0x6e66ba89, 0xb0ab042d, 0x3276976c, + 0x3dbeb3d7, 0x413ea96d }; + +static uint32 spp_27[] = /* primes 3 to 619 */ +{ 0x02ced4b7, 0xf15179e8, 0x7fcba6da, 0x7b07a6f3, + 0xf9311218, 0xa7b88985, 0xac74b503, 0xbf745330, + 0x6d0a23f5, 0x27a1fa9a, 0xc2b85f1a, 0x26152470, + 0x6ac242f3, 0x518cc497, 0x09a23d74, 0xff28da52, + 0xe7bbf7f7, 0xa63c1c88, 0x6f684195, 0x65e472ce, + 0x80751585, 0xc70e20c2, 0x2d15d3fe, 0xc1b40c7f, + 0x8e25dd07, 0xdb09dd86, 0x791aa9e3 }; + +static uint32 spp_28[] = /* primes 3 to 647 */ +{ 0x6e026454, 0x60adbd18, 0xcd52ce1a, 0x1beab1c0, + 0x36e468e9, 0xf350d69b, 0x1d357d08, 0x3a59f778, + 0xc2cc262b, 0x4a29ce52, 0x509bcf97, 0x349ba2bf, + 0x22402d71, 0x6b32517e, 0x1941e18a, 0xce76cbd8, + 0x5809701e, 0x70eaef96, 0x9aac365c, 0x8a9fea5e, + 0xc74d951d, 0xb361f061, 0xc4d14f00, 0x0d806db4, + 0xcd939110, 0xc7cab492, 0x2f3ea4c4, 0x852ca469 }; + +static uint32 spp_29[] = /* primes 3 to 661 */ +{ 0x074921f7, 0x6a76cec3, 0xaeb05f74, 0x60b21f16, + 0x49dece2f, 0x21bb3ed9, 0xe4cb4ebc, 0x05d6f408, + 0xed3d408a, 0xdee16505, 0xdc657c6d, 0x93877982, + 0xf2d11ce6, 0xcb5b0bb0, 0x579b3189, 0xb339c2cc, + 0xcf81d846, 0xa9fbde0c, 0x723afbc7, 0x36655d41, + 0x0018d768, 0x21779cf3, 0x52642f1b, 0x2d17165d, + 0xc7001c45, 0x4a84a45d, 0x66007591, 0x27e85693, + 0x2288d0fb }; + +static uint32 spp_30[] = /* primes 3 to 683 */ +{ 0x00872313, 0x1f66758a, 0x414bbebb, 0x2f8670bf, + 0x01dc959d, 0x74468901, 0x57c57f40, 0xe210c9c2, + 0x74f54469, 0x7c71cc1d, 0xe2be67a2, 0x03d8d56f, + 0x6c363fca, 0x0a78676a, 0x2b977789, 0x6ea2db50, + 0xdb31b737, 0x51992f73, 0x0def293e, 0xbc028877, + 0xdf95ac1b, 0x4d0c0128, 0x9a0b05e0, 0x0e6c0bc8, + 0xe61b766e, 0xc0943254, 0x1cd70f0f, 0xd5a0ce6b, + 0x8ab998fb, 0x8ab36e0d }; + +static uint32 spp_31[] = /* primes 3 to 719 */ +{ 0x1e595df4, 0x3064a8c9, 0xd61ae17b, 0xde1938f0, + 0x22ee6357, 0x35f4cadd, 0x3d39f473, 0xafed7df5, + 0x92ae0fd3, 0xfe910508, 0x9ad9e939, 0x988b0227, + 0x60dec749, 0xae7ee54f, 0xeb0572ac, 0x0aed266d, + 0x92daafd8, 0x6135f7a3, 0xe4e8bf05, 0x0124c928, + 0xb0d719d5, 0x2181aec8, 0x0f79820f, 0xcb158642, + 0x20969ec0, 0x1a480d31, 0x331b3252, 0x01b36fab, + 0x3d5b415b, 0x1a4567e7, 0x3baf6389 }; + +static uint32 spp_32[] = /* primes 3 to 739 */ +{ 0x02c85ff8, 0x70f24be8, 0x0f62b1ba, 0x6c20bd72, + 0xb837efdf, 0x121206d8, 0x7db56b7d, 0x69fa4c02, + 0x1c107c3c, 0xa206fe8f, 0xa7080ef5, 0x76effc82, + 0xf9b10f57, 0x50656b77, 0x94b16afd, 0x70996e91, + 0xaef6e0ad, 0x15e91b07, 0x1ac9b24d, 0x98b233ad, + 0x86ee0555, 0x18e58e56, 0x638ef18b, 0xac5c74cb, + 0x35bbb6e5, 0xdae2783d, 0xd1c0ce7d, 0xec4fc70e, + 0x5186d411, 0xdf36368f, 0x061aa360, 0x11f30179 }; + +static uint32 spp_33[] = /* primes 3 to 761 */ +{ 0xd0440ea6, 0x8b382bcb, 0x75b4df8b, 0x6f8aa6cd, + 0x494daee4, 0x38b1922e, 0x46cef6ca, 0xdc74a93e, + 0xdf45643d, 0x05cc1aa5, 0x556f9c72, 0x0682676d, + 0x6668f9c1, 0x89284c78, 0xa770e3a8, 0x423b3833, + 0x96c4b063, 0xdb37bced, 0xd891a10f, 0x99328d8a, + 0x7c863078, 0xbd323cbc, 0x5ccea379, 0x252d31d3, + 0x39d2a084, 0x1717596a, 0x005fbd71, 0xa171925c, + 0x902bfb88, 0x6d99e44c, 0xb3a33020, 0xf05cadbe, + 0x4a8014ad }; + +static uint32 spp_34[] = /* primes 3 to 787 */ +{ 0x16af5c18, 0xa2bef8ef, 0xf2278332, 0x182d0fbf, + 0x0038cc20, 0x5148b83d, 0x06e3d7d9, 0x32828b18, + 0xe11e0940, 0x28c7eaed, 0xa3395017, 0xe07d8ae9, + 0xb5940604, 0x51d05f93, 0x084cb481, 0x663c94c6, + 0xff980dde, 0xccdb42ad, 0x37097f41, 0xa7837fc9, + 0x5afe3f18, 0xad76f234, 0x83ae942e, 0x0f0c0bc6, + 0xe4001612, 0x3189872b, 0xe58f6dfc, 0x239ca28f, + 0xb0cfbf96, 0x4c8f27ce, 0x05d6c77a, 0x01f9d332, + 0x36c9d442, 0xad69ed33 }; + +static uint32 spp_35[] = /* primes 3 to 811 */ +{ 0x02c30b50, 0xedc2e94a, 0x3940a943, 0x968984e8, + 0x5a132fca, 0x78aedf5b, 0x4e307eec, 0xec19323e, + 0x71957e6e, 0xc70aab41, 0x43eb94a6, 0x20e9ca78, + 0x25d112d2, 0x055a3562, 0x1629b4b7, 0xb9208518, + 0x395b967a, 0xa4b564f8, 0x307459f7, 0x851d00e0, + 0x89d845dc, 0xa8e9423d, 0x2f0293bf, 0xdf0a3123, + 0xa1719e4c, 0xe4c577b3, 0x485ede33, 0xdd79a1ad, + 0xb6f9d10c, 0x8707cd1c, 0x2006396a, 0x192645b9, + 0x105ad4a4, 0xbd28a578, 0x5394c375 }; + +static uint32 spp_36[] = /* primes 3 to 827 */ +{ 0x005bfd25, 0x83ab7a44, 0x13d4df0f, 0x537c686c, + 0xa8e6b583, 0xe491130e, 0x96dfcc1c, 0x05ba298f, + 0x8701314b, 0x45bf6ff4, 0xecf372ff, 0xe78bccdf, + 0xfc18365a, 0x6ae5ca41, 0x2794281f, 0xbcc762f1, + 0x8ca1eb11, 0xfc8efe0b, 0x6bb5a7a0, 0x9954e758, + 0x074256ad, 0x443a8e4b, 0xaa267515, 0x4c43d626, + 0x46411944, 0x6e683d08, 0xd4683db5, 0x757d1199, + 0x9513a9cb, 0xe3e67e3a, 0xe501c1c5, 0x22aa8ba9, + 0xf9557895, 0x89161feb, 0xc69941a1, 0x47aa9685 }; + +static uint32 spp_37[] = /* primes 3 to 857 */ +{ 0x2a89d844, 0x7bf83428, 0x8464b909, 0x31ce3aaa, + 0xed0c2683, 0xb26f15e4, 0x32e95677, 0x65036627, + 0x80802634, 0x4328b107, 0x89fb23c6, 0x11b484ca, + 0xcd937f07, 0x65e0f5df, 0xc8f9a3a2, 0xc7aac35f, + 0x3e8a8a35, 0x26515cc0, 0x38c822e0, 0x7a1bd893, + 0x852c7ec0, 0xc01d7303, 0x90f69c22, 0xf56ba6cc, + 0xd90063cf, 0x72d6ad3d, 0x7a0a7455, 0xef28f5c6, + 0x1af3825a, 0x536b8464, 0xe90b2d32, 0x9e831029, + 0x638a6241, 0x8946766c, 0x6392ec57, 0x9bd0c31a, + 0xb4ce65ab }; + +static uint32 spp_38[] = /* primes 3 to 877 */ +{ 0x06706918, 0xe8355b7f, 0xfd3f024d, 0xa6b012e2, + 0xbb7338f3, 0x0d51a968, 0x0f3d9120, 0x35ed70e0, + 0x2d38d422, 0xe41812d4, 0xe29d637b, 0x318ce6f4, + 0xea117321, 0xce8b712d, 0xcca9345f, 0xd03ccaf5, + 0x2e75dafc, 0xda909cd4, 0xb41a9f87, 0x53c8df3d, + 0x284198bc, 0xb759d059, 0x94136057, 0x2b7ab25f, + 0x396b9fa3, 0x7ae0a200, 0xd998ea09, 0x167edc30, + 0xf9d2c45c, 0x7e487029, 0x92750098, 0x3f7fb4e8, + 0xe85d8e94, 0x34a37006, 0x8cebc960, 0x60ab2f87, + 0x81efeb18, 0x2d0e724b }; + +static uint32 spp_39[] = /* primes 3 to 887 */ +{ 0x0108d441, 0xce330894, 0xff143672, 0x5fee20c5, + 0x9b8fb49f, 0xbb29ad13, 0x5f0888b0, 0x59181b63, + 0x54380731, 0x8906204b, 0x7e16cc5e, 0x2d8c613b, + 0x4414b03a, 0x30587c32, 0xa08bbc57, 0x95f63e1e, + 0x6f237e7c, 0xdfc70204, 0xdd20d5d2, 0xd93a0fcb, + 0xd54d4e92, 0xd750c3c8, 0x4b276eca, 0x9081b543, + 0xa8979c2b, 0xb14e3fa1, 0x7c87d031, 0x300588b2, + 0x6b1aa738, 0xbe02e7b4, 0x57a9ed5f, 0x341b72e6, + 0x19296afb, 0x2ae2f6b0, 0xf6f00832, 0x9e0d7b8f, + 0x61a10c17, 0xa07a962e, 0x5bc81157 }; + +static uint32 spp_40[] = /* primes 3 to 929 */ +{ 0xa9e9591f, 0x7815617e, 0xcabe352f, 0xa13445c4, + 0xf8e319ba, 0x63042e1c, 0xb0a017d0, 0xe729a699, + 0x5480da4e, 0x5091cab4, 0x12910cf4, 0x7bb0f24e, + 0x5e1db412, 0x64b9f96a, 0x2b327e90, 0x1d9d0a39, + 0x12659a52, 0xd3792d52, 0x991bfa96, 0x4fe7d212, + 0x60374c24, 0xa04de69d, 0xf5d4e46b, 0x249cafc7, + 0x347c6181, 0xbd6dc6b8, 0x13a29dc6, 0xd4f785ac, + 0x78066355, 0x13530cd5, 0xdb94de48, 0x58c157f0, + 0x30b96bfb, 0x6475393b, 0x5f43a549, 0xd95c5619, + 0x7e274850, 0xad1a6d18, 0xb5eaa41d, 0xd42fda55 }; + +static uint32 spp_41[] = /* primes 3 to 947 */ +{ 0x2108556d, 0x64bbc9f2, 0xa87149a3, 0x26013838, + 0x4d8e761d, 0xab793496, 0x415dad5b, 0xa6682448, + 0xe3c8495c, 0xd3f2e881, 0xf3546b54, 0xb8b14068, + 0x97668326, 0xe4aa5c56, 0xe8b03fe7, 0x32b53f8b, + 0xe55d11c4, 0xfce09e57, 0xee4d8232, 0x1447c16b, + 0xe0e1a32d, 0x54972732, 0x5b58b113, 0x136127eb, + 0xf48c987d, 0x6532476f, 0x8800deab, 0x4b93a717, + 0x6a7cdc07, 0xf51ff3ef, 0x8fdc7d30, 0x289949c2, + 0xad7f1d56, 0xe40ca555, 0xa3a33043, 0x74bc64b1, + 0x546974cb, 0x927a6b4e, 0x85bf34af, 0x54cd54d6, + 0xbbec2afb }; + +static uint32 spp_42[] = /* primes 3 to 971 */ +{ 0x06e1d136, 0xcb78cac5, 0x4da4bfcb, 0x6f2c4a24, + 0xfcf3796b, 0x77719c31, 0xd2791586, 0x0001f03e, + 0x4347621b, 0xf62577e0, 0x280ebfdb, 0x77b4f1e9, + 0x0f954eca, 0xfd198609, 0x68629be9, 0x1424c37a, + 0x8f320a34, 0x444953d5, 0x2c278d64, 0x85238798, + 0x709d0063, 0xe3fa8623, 0xea24bf2a, 0x2c5278e7, + 0x4460d05a, 0x0a708bd9, 0xc019d632, 0xe39e7300, + 0x22b9dbb9, 0x13df73cf, 0xb959dffe, 0x348f9623, + 0xf697a822, 0xf4a11320, 0xbd044ecc, 0x74878f53, + 0x0d57d0f0, 0x76647b0a, 0xb191f543, 0xdc08c392, + 0x3167e5ee, 0x56c66847 }; + +static uint32 spp_43[] = /* primes 3 to 991 */ +{ 0x0186695f, 0xa95755fc, 0xe74a9a4e, 0x8fbc30df, + 0x119e4901, 0x7edb320f, 0xe8114129, 0xb3bddd0d, + 0x2b0cf0f7, 0x2306fb1d, 0x6a5cae26, 0xe4a286ce, + 0xe1acd2fb, 0x5e6770b2, 0xc58355ca, 0x1c782114, + 0xb05f881d, 0x090a7fcb, 0xe043ebaa, 0x592672ae, + 0x9e0335e3, 0xc77acab9, 0xc4aeb4cb, 0xdc1f1341, + 0x20257620, 0x7c2ecd85, 0x130f3c11, 0xcad1192b, + 0xb43daff3, 0xfd555877, 0xce47d74b, 0x1e878cfd, + 0xd7b779a5, 0xca965949, 0xb03075a8, 0x25f009ab, + 0x509f0ff9, 0x5202ec37, 0xe9a0f3f4, 0xdc2d184d, + 0x10575170, 0xe3e7d4d0, 0xaf86a76f }; + +static uint32 spp_44[] = /* primes 3 to 1013 */ +{ 0x005ca1a9, 0x2edd0e81, 0x9619289e, 0x1ecfe2d7, + 0xf3949eaf, 0x363a5fe8, 0xf6fee01c, 0xcd480490, + 0x30a1346a, 0xb83c4967, 0x8c7d5882, 0x6caf81ca, + 0x1d02473b, 0xea8ad400, 0xd1ce270a, 0x5743c3cd, + 0x892c3bd9, 0x3b84525d, 0x8a42071a, 0x508fdb8f, + 0x32952aaa, 0x2384cf5d, 0xf23ed81d, 0x10ac0031, + 0xd85d0e95, 0xe3c5bb51, 0x71a0e3f1, 0x2b671f8f, + 0xb07965cc, 0x353a784b, 0x78f71968, 0x1326c790, + 0x6e2b7f7b, 0x0782848e, 0xeb1aea5b, 0xab10b80e, + 0x5b7138fc, 0x36f7989c, 0xe85b07c2, 0xd4d59d42, + 0x1541c765, 0xf6c2111d, 0xb82eca06, 0xb437f757 }; + +static uint32 spp_45[] = /* primes 3 to 1033 */ +{ 0x5d59c98b, 0x452d0c02, 0x1291e1ef, 0x6ab50494, + 0xce984e89, 0xdc563773, 0x96b510a6, 0xeef593cb, + 0x73e4eb74, 0x6a1c83ef, 0x9a7bff75, 0x7ee6e25a, + 0xe12d86af, 0x743e83ad, 0x0f28e9c6, 0x0aee1694, + 0xf5bd9a93, 0xd9e9dc26, 0xd1ed4b29, 0xff2f3094, + 0xd431b844, 0xe0cea92f, 0x639ebb6f, 0x7107f740, + 0x7c23abc1, 0xcc3789e9, 0x4ddb2532, 0x32ecc6c5, + 0x0ecbe5e5, 0x32fd5097, 0x49cc5252, 0x2730c08e, + 0x1f7117c2, 0x71c83657, 0x087f4608, 0xe003e4f6, + 0x7cb9e029, 0xd33f00ae, 0xd3dad2a0, 0x76735950, + 0x7da17074, 0xb23e9701, 0x7e0e9f7e, 0x2ed03221, + 0x76712827 }; + +static uint32 spp_46[] = /* primes 3 to 1051 */ +{ 0x18e5b310, 0x229f618d, 0xe0f54782, 0xf57fff33, + 0x10546ba8, 0xefc0a69c, 0xac4b573b, 0x749cc43d, + 0xd3ba4df6, 0x1fe2800d, 0x733f4eb7, 0x19a6ea7f, + 0xa88aebf2, 0xd35b26c8, 0x6e89fe0b, 0x27e198de, + 0xe12a14da, 0x03cef215, 0xe6651c60, 0xbe9cf337, + 0x3620f4ab, 0xa453eeb9, 0xeb439ba0, 0x79201376, + 0x0e3cc7f8, 0x722f09a4, 0x685a5556, 0xb4efd158, + 0xb27a6b79, 0xb15f161f, 0xecf3fd80, 0x2767da7a, + 0x37ceb764, 0xbebfcc2b, 0x2d833be0, 0x0b21bb68, + 0xeab326b9, 0xebb20cc2, 0xd76273ed, 0xefa152ad, + 0x531bccbf, 0x17e3c78d, 0x5c43d8f6, 0x866ad640, + 0xfdbbba0f, 0xe997b27b }; + +static uint32 spp_47[] = /* primes 3 to 1069 */ +{ 0x06fd3257, 0x047a7639, 0xcb2cfcfb, 0x193180fe, + 0x1f21979a, 0x2376042b, 0x6b2809ba, 0x216e6d5b, + 0x57fec6ff, 0x96b878bb, 0xe1d4371b, 0x2f53c7e0, + 0x036c8309, 0x2f6b0512, 0x7416844f, 0xbdc36a56, + 0xa1d7ae59, 0x332552e8, 0xe32f4324, 0xdc90f2d8, + 0x546904d8, 0x3b8f0e24, 0x8df97f60, 0x7af99875, + 0xae419d8e, 0x2954463b, 0x1f4aef0c, 0x52a102b4, + 0xccca2b78, 0x9d2b46c2, 0x0fb3c949, 0x49cbafc5, + 0x5ec2b085, 0x03b5beb4, 0x6b6eb1d1, 0xed78e5f2, + 0x398baf6c, 0x33ae0815, 0xf0bd3d5b, 0xe1ebbadc, + 0x5aa7a694, 0x352122fc, 0xd4c1c770, 0x016d76cb, + 0xc050191f, 0x6ce5ab73, 0x6d43113d }; + +static uint32 spp_48[] = /* primes 3 to 1093 */ +{ 0x021bf949, 0x7091b8c3, 0x68cc7c8e, 0x00c1990c, + 0x6027481b, 0x79215ac8, 0xa7517749, 0xa2151377, + 0x9a993d29, 0x58fcb49a, 0x73680292, 0x68527994, + 0xc6cc1928, 0xadd41295, 0x96765f4c, 0xc3141a04, + 0x4eb1d615, 0x78881667, 0x57d86187, 0x81813062, + 0x03226798, 0x7df0d471, 0x9cd38f1b, 0x7085fca5, + 0x334be3a6, 0x003a3ce7, 0xe19aba55, 0x3e80cc5a, + 0xe4060eff, 0x6e180666, 0x1da5eeb7, 0xd142d3b2, + 0xe40739f1, 0x443dee3a, 0x198637f0, 0x3c062845, + 0xeaff3ff2, 0x7ea38d93, 0x44d8a902, 0x22472df0, + 0x7dfb5c9c, 0x8ada77cd, 0x0d5b94ef, 0xf021e02e, + 0x307d0801, 0x0312d57c, 0xb5d97576, 0x4697842d }; + +static uint32 spp_49[] = /* primes 3 to 1109 */ +{ 0x00a8b455, 0xb6b4a84f, 0x6834364b, 0x936a996f, + 0xbceb3f49, 0x88ee2732, 0x24b48131, 0x2357ae12, + 0x4d520af5, 0xc87eb399, 0x90944c44, 0xc3a75724, + 0x1e3caf22, 0x26585d51, 0x6875521d, 0xb3f466ec, + 0xe4117740, 0x5c808598, 0xeded00eb, 0x951faff9, + 0xf8d8beee, 0x127c796c, 0x2a358484, 0x8df645d1, + 0x31b11876, 0xb04f57d2, 0x4e0c0751, 0x4448e66a, + 0x4bd5c496, 0x435274ce, 0x9a059e30, 0xb39a47d0, + 0x0c6cbf84, 0x8a46fc8c, 0x4bb19382, 0xe2799723, + 0x5fb598f1, 0xdfb21e4a, 0x05b2eeb2, 0xfa25db86, + 0x5183ce51, 0xcf330c32, 0xe2749deb, 0x4b7d3fd7, + 0x9781307a, 0xc1aee399, 0x0451d911, 0xc9204d5e, + 0x80edaf17 }; + +static uint32 spp_50[] = /* primes 3 to 1151 */ +{ 0xfa1bd62b, 0xaae1e767, 0x47535af3, 0x830fc07d, + 0xebcf3ef7, 0xe5a8e46b, 0x8937c4af, 0xe02aef0a, + 0xce420c7b, 0x2c3f2fac, 0xb9dc94e5, 0x100a7191, + 0xb47cf523, 0x520f613b, 0xee8e095a, 0x7b06d781, + 0xb6204bde, 0x1648e17f, 0x0f1bd4ab, 0xa00f7e90, + 0xd8fc2a05, 0xf5f1e832, 0x6e88a4a6, 0x7e73cae1, + 0xc4a93d89, 0xad6b301b, 0x1f185b13, 0x0246ab44, + 0x5cadc384, 0x931189b5, 0x566b3ed9, 0xdafba4e6, + 0x59f5446e, 0x5a70c8d1, 0x4626b66d, 0x0f1ccfbf, + 0xd4238b68, 0x84af7dd3, 0xa91d2063, 0xceb2c2f7, + 0xf273b1da, 0x4cb542ea, 0x62c624cf, 0x4fcb0486, + 0x138b42a3, 0xc1d9593c, 0xe1254fb3, 0x214d2b08, + 0x52532bc5, 0x28bc6467 }; + +static uint32 spp_51[] = /* primes 3 to 1171 */ +{ 0x5b7091ea, 0xdbc63f00, 0x64dd01de, 0x204ee72f, + 0xc4644db7, 0x573e04ee, 0x706df728, 0x7a49af78, + 0xc5b99680, 0x528566bc, 0x17d57a00, 0x16a5b12e, + 0xf30fa9e3, 0xa1d437c8, 0xbf8e3283, 0x3eeb4036, + 0xaf3dfa3d, 0xd69f4d6a, 0xae6b7947, 0x18e2e8fa, + 0xafccb2a5, 0xf3b3ed57, 0xaac15fb8, 0xd04f7035, + 0x0f9edc0e, 0xd868ec8d, 0x430f42ab, 0xad8cf315, + 0xee97237c, 0x6df5577e, 0x5a2857d5, 0xc6e41cfc, + 0x1557e427, 0xafc62698, 0x9703722f, 0x50f10c60, + 0x78579c80, 0x32f8bec2, 0x5bbce21a, 0xa20c3cdb, + 0xdbb80d64, 0x31c06f68, 0xa743d08d, 0x220c0f0a, + 0x1fbb5766, 0xb6977732, 0x3f869dd0, 0xe286a091, + 0x7e3f520e, 0xc3203bce, 0x170ef097 }; + +static uint32 spp_52[] = /* primes 3 to 1193 */ +{ 0x239afcd4, 0x38799705, 0xab8a0cda, 0x4802bc8f, + 0xb0e87f44, 0xa568f618, 0x7c604708, 0xdfb79072, + 0xe24b49cb, 0x8b2ac531, 0x005cf298, 0x2437b16e, + 0x027fa014, 0x14e3dbf5, 0xbf766811, 0x66e276ff, + 0xcf676855, 0x0bc1cd9a, 0x1b387eba, 0xaa8550ae, + 0xfc10c69c, 0x372a0254, 0xb84666ff, 0x35044b9a, + 0xa34fcf7c, 0x817b33f3, 0x7088a289, 0xa17891a7, + 0xe66f88e8, 0xec2ba784, 0xb2a09a91, 0x02609726, + 0x17a3dbea, 0x8463439d, 0x47972d09, 0xb0e63752, + 0xbac58d33, 0x9b402dc1, 0xa0991554, 0x3360cd68, + 0x4df24e43, 0x7487571d, 0xfaf68f4f, 0xe0a93546, + 0x66aa84bf, 0x84d4448d, 0x21190291, 0x66db27bd, + 0x515599cd, 0xcd147810, 0x3acf73e7, 0xfe62aed9 }; + +static uint32 spp_53[] = /* primes 3 to 1217 */ +{ 0x0eb29f45, 0x5fc46bf0, 0xd4857e41, 0xa0059da0, + 0xda0b3770, 0xf445bac2, 0x37decad9, 0x954f2a17, + 0x849520eb, 0x001349bf, 0xf0264427, 0xb01519ec, + 0xf6fdb496, 0x80797a72, 0x17df3f5e, 0x95dea2d3, + 0xfded40a1, 0x3bcd8ac6, 0x0af97a12, 0x43383501, + 0x915ba38c, 0x90ec4f69, 0x2f931a60, 0x56bf7e42, + 0xd2969fab, 0xd442987c, 0x62e0fe9e, 0xaa412cba, + 0x8335fe9d, 0x33343d9f, 0x760e9e43, 0xf2b0f8dc, + 0xbe1e28ac, 0xa0ce2864, 0x5db05820, 0x71a88a56, + 0x4013a0f7, 0xc3d72268, 0x6e2fb29a, 0xc2d23e4e, + 0x6ad5ff62, 0x99a85da1, 0x535ff17b, 0x0e26402a, + 0xf5669a3d, 0x513660ce, 0x800afdf9, 0xe6ef66e1, + 0x9a202974, 0xa1069be2, 0xd54ceff7, 0x8e333c48, + 0x4ebbe265 }; + +static uint32 spp_54[] = /* primes 3 to 1231 */ +{ 0x0654f0d4, 0xcdacb307, 0x5419612f, 0xae3cf746, + 0xfbab751f, 0xd0887955, 0x28adc68d, 0x26f32877, + 0xeb1b772d, 0xb48e49f6, 0xcb445987, 0xc4966560, + 0xdff84737, 0x02bb0fd4, 0xf8b68b5c, 0xe2d496a6, + 0x0dc7d7e4, 0x3c3cb0bf, 0x72665c6e, 0x4c86a7ce, + 0xb78c9da4, 0x0f4d90a8, 0xf5dfe2a4, 0xdc559b8a, + 0xba10a63a, 0x0ca25d3a, 0xdec2c419, 0x8b688d80, + 0x71c05d3b, 0x694f19de, 0xda32955f, 0x77fbb577, + 0x27eb6521, 0x40495e56, 0x2f4a13e8, 0xb648daf2, + 0x13d1da75, 0xe3f04bb0, 0x43fedcd2, 0xb2a0cd30, + 0xa4339e3a, 0x03b7f3a0, 0xe02a31c2, 0x8394368c, + 0x7f73bbf3, 0x2712e69e, 0x7ac58373, 0xe5f7c7e7, + 0x55e0d645, 0x628c5475, 0x6217c0bd, 0xf119900b, + 0x05ea71dd, 0x714fd2c9 }; + +static uint32 spp_55[] = /* primes 3 to 1259 */ +{ 0x02de1de4, 0xcbca29fc, 0x94a50bb7, 0xae89c417, + 0xb8063484, 0x5c71a8c6, 0xa641d997, 0x65355b7e, + 0xed63ea84, 0xeaeead3c, 0x2a49b4d2, 0xefdd333e, + 0xbc90594b, 0x30eab1fb, 0x519151b2, 0x536ef5a7, + 0x40b8e2d9, 0x2c02ffd5, 0x149dc0db, 0xcb0416cf, + 0xf8b08c27, 0xcc47095e, 0xbbe5263c, 0x327da58a, + 0xcd5825d9, 0x3a0ac60e, 0x7a667d47, 0x084d08aa, + 0x5c2449e0, 0x65b7f051, 0xc34d6fb8, 0xac5a5d99, + 0xd082950c, 0x11650560, 0x4f2fa1de, 0xf26e51ea, + 0xa4ea5ac2, 0x87e2f953, 0xcdfc4d30, 0xf05d6553, + 0xa2a28858, 0xea28dc4d, 0x24ae0063, 0xa49c8d44, + 0xeedc858f, 0x55e16f54, 0xf9c3f019, 0x6a9c92c9, + 0x7b685023, 0x3f0d9c13, 0x7f7c114d, 0xbe550751, + 0xbc8560cb, 0x746a4b6c, 0x373cde1f }; + +static uint32 spp_56[] = /* primes 3 to 1283 */ +{ 0x01662c66, 0xdab7a4fa, 0xdba4265a, 0xc2075912, + 0x59e9c885, 0xe1330cb6, 0xc91bee92, 0xf1b334ff, + 0x384f827c, 0xc8057aa7, 0xc3b65fc6, 0xde53dcac, + 0x2db6d790, 0x3febbe07, 0xcc401232, 0x6b128eb7, + 0x1afd3136, 0xa9e7f786, 0x14648da1, 0x7b4f50c7, + 0xbd4129ca, 0x746dab21, 0x09583797, 0xfc1c2ecd, + 0x4c0768a8, 0x1892bd16, 0xdfea8227, 0xbcb2b8bf, + 0x168a1452, 0x370b0863, 0xb299d088, 0x8434c213, + 0x2383a6c7, 0xb6b4bf20, 0x5addc8da, 0x76d2b172, + 0xb416f5b0, 0xb9a38d87, 0x738c1cca, 0x3fe33dd2, + 0xf9b7570e, 0x3f663f8b, 0x34169076, 0x51b1dd42, + 0x2192331d, 0x9436304a, 0x0303422f, 0x4d420389, + 0x4548a055, 0x62ed1c09, 0x1a63309b, 0xf1a9df8b, + 0xf0c59af9, 0x12a62c22, 0xe1e1f49b, 0xb0115c17 }; + +static uint32 spp_57[] = /* primes 3 to 1297 */ +{ 0x00b3fde4, 0xe9dbc2a2, 0x1c8f4d4b, 0x53b0ff59, + 0x643cf537, 0x88f9d4ba, 0x69472171, 0x6a2f33d5, + 0xa93b03b2, 0x59142a0e, 0x117006bc, 0x8b4e1475, + 0x1adf80d1, 0x96c20ffd, 0xfa1775f1, 0x83b2df43, + 0x1c766011, 0xdefc6c34, 0xc6bfafcd, 0xd51ef8ef, + 0x253052b2, 0xc818df16, 0x37372435, 0xe9e55783, + 0x6c7d476d, 0x966ec455, 0x1ef8d32f, 0x7d687828, + 0xc978db5a, 0xabf1cc69, 0x74e86c65, 0x260bec72, + 0x1a609875, 0x6d5942ef, 0x4d4d8b42, 0x6a9cd4fb, + 0xe0030023, 0xd9bf209b, 0x4a93c089, 0xc4f634b1, + 0xd5463616, 0x33307dbf, 0x127489d6, 0xaa674108, + 0xe2c74fd3, 0x63aba6a2, 0x9f2f887d, 0xfc8b13a6, + 0xbb230a35, 0x390669ff, 0x22f8243b, 0xbc59cf3d, + 0x58bafd1a, 0xc6f2f456, 0xe938c1f8, 0x4051aadc, + 0x54d4a035 }; + +static uint32 spp_58[] = /* primes 3 to 1307 */ +{ 0x005cda0c, 0x54b07f4f, 0xff0caca0, 0x7cc89b95, + 0x1c021191, 0x164be693, 0x6665357e, 0xbb2f689c, + 0x7157ea4f, 0x98037ce1, 0x5aca14ca, 0x3cf1a386, + 0xb03e831e, 0xe09a8d5c, 0x48d51f5e, 0x6646ed8a, + 0x7ec2b955, 0x216587f0, 0x7f3c42ee, 0x06ae3844, + 0x4c776b8c, 0x3ef32747, 0x97cd2ac1, 0xc7cce7ec, + 0xe75bb029, 0x0f5b5a0e, 0x2c96c460, 0x0c678a21, + 0x0d992d36, 0xd441b1fd, 0x682adf0e, 0xf289947e, + 0x6d3de1a2, 0xaf0ca945, 0x859aa1f2, 0xb2bb793d, + 0x351dbebf, 0xe05144ee, 0xfe9c752d, 0x75ec602c, + 0x0e0344dd, 0xcfcb642b, 0x6cfc8722, 0x19d69873, + 0xb8c4ace3, 0xffd460e9, 0x43d903b4, 0x5de9d402, + 0x958a41fb, 0x5e008a94, 0xc9361081, 0x4e5e2811, + 0xd052c10a, 0xbfc67bf6, 0x915d4435, 0x2688091b, + 0x1eb1c711, 0x7c91eae5 }; + +static uint32 spp_59[] = /* primes 3 to 1327 */ +{ 0x0031fc6d, 0x6918c954, 0x9fe61e37, 0xe79cea8a, + 0xe12d234b, 0x7642915b, 0x85e4b88b, 0x83eeba5f, + 0x429d8086, 0x9a31c342, 0x0020beb9, 0xbc48ece8, + 0xcb7bb572, 0xad3a8e34, 0x085a4765, 0x6ba28651, + 0xad8a45d5, 0x26ea9c98, 0x90740760, 0xca7bf7e9, + 0x9acf6665, 0xc6a9232a, 0x720b8d78, 0x1f51a8b2, + 0xdfcbe4ee, 0xa4a48126, 0xad4a6fd8, 0xb5a0c187, + 0x12021d6c, 0x3ca2c624, 0xd477495f, 0x11752cc7, + 0x77c2b465, 0x8b3cfc3f, 0x2cb0ab3c, 0xc70277e3, + 0xd1d97a12, 0xebc6b0db, 0xfe7ad411, 0xdede9e15, + 0x905166d9, 0x403ae854, 0x9432b6a4, 0xf45d1540, + 0xca51bffd, 0xf107b16c, 0x08deae8e, 0x49bc15e8, + 0xd1d3ac9c, 0x2a76465a, 0xe778cc84, 0x810878db, + 0xfad8b7e5, 0xd5151c83, 0x9045920b, 0xfa0cecd0, + 0x43e94546, 0xee4f4361, 0x84901bb5 }; + +static uint32 spp_60[] = /* primes 3 to 1381 */ +{ 0xa0604bc5, 0x4c251ade, 0xcf22bf07, 0x5a150bb1, + 0x2a67d65a, 0x5045c183, 0x17246627, 0x0d72a8c6, + 0x3e2dd1c4, 0x6694a251, 0xf55bca5e, 0x7d834c87, + 0x2a8d10e5, 0xea91ba4d, 0xcce166f1, 0x6b1be0ef, + 0xba025bf3, 0x62f29284, 0xa36db516, 0x75c7d25e, + 0xac751992, 0x5560c7a1, 0xc7047093, 0x8bdf2818, + 0xed42d042, 0x53130bef, 0x0d92e596, 0x844e073b, + 0xdd40bd15, 0x6f433f09, 0xbdfd3e38, 0x769a485c, + 0xf29380b7, 0x9c18989c, 0xed0e6ec4, 0x3bcc7b73, + 0x087e1fb9, 0x4e8cf2d3, 0x475c7760, 0x5c707f6b, + 0x31f7217c, 0x4c628da2, 0xe3263e30, 0xa83c1066, + 0x1378f415, 0x33ca7d71, 0x5d4e2b87, 0xc0e142ba, + 0x462e6ffb, 0x506e09f9, 0x7850c73e, 0x4b3f7a24, + 0xca98bda0, 0x5c0c6ac6, 0x666daad0, 0x14d2ff3f, + 0x7138fa68, 0xddd5e9f0, 0xe92edcaa, 0x62b56483 }; + +static uint32 spp_61[] = /* primes 3 to 1423 */ +{ 0x68bd8015, 0x91071573, 0x8a205b51, 0xe1be9357, + 0xdab961de, 0x59c9e43c, 0xb9becf7a, 0x8adba9a9, + 0x926a87bb, 0x7f574190, 0x3ee07b97, 0x83b5ed87, + 0x503ee854, 0xbfc61ca4, 0x9531565e, 0x4e8136f5, + 0xdb315f85, 0x3ae9f609, 0x2deebbac, 0x45e36b1b, + 0x1f3a6d76, 0xe4e758c0, 0x2477bd33, 0x40b9cf8e, + 0xe1815167, 0x132e13ab, 0x82cf7f08, 0x51b86b6f, + 0xfd7cfaea, 0x9b7b7dcc, 0xcd7c9d57, 0x9ccb5269, + 0xa01e7ef9, 0x52ec1995, 0xbc6df02c, 0x649435e7, + 0x3e12d47d, 0xc484c579, 0xda72631f, 0x976b8eda, + 0x270cc80b, 0x56141511, 0xf857bc1c, 0x898e8aeb, + 0xb836ca21, 0x2ed0d5cb, 0xcd16c412, 0x81a67e69, + 0xbbb68933, 0x5ead39cf, 0xdefe9acb, 0x9721e75c, + 0xd59b372e, 0xc91ec67d, 0x0df39398, 0x106914b7, + 0xba405fde, 0xe85bb37c, 0xdae528dd, 0xe98d3250, + 0xbec22e6b }; + +static uint32 spp_62[] = /* primes 3 to 1433 */ +{ 0x4742fdaf, 0xf7e8231a, 0xded68277, 0x58493423, + 0x12b13d2f, 0x5925c539, 0x82d876ef, 0x7ff69e7f, + 0x5b4ff04e, 0x8454faea, 0x620dc960, 0x0c65fd57, + 0x2aecce4c, 0x9656588f, 0x79dfb5df, 0xd7f99148, + 0x196c24df, 0x6d8c704b, 0xd6ffb8d9, 0xcedb8ee8, + 0x448d4352, 0xd834cef7, 0xfce9b929, 0x07eeca6a, + 0xcc107008, 0xfa118ff7, 0xedcc0b84, 0x207c3eef, + 0xdb5ea3ef, 0x89c684d8, 0x89c4187a, 0x10775358, + 0xc429d4d2, 0xa76bb2c3, 0x9f406fdc, 0x49dcf4b6, + 0xed773586, 0x770e4651, 0xcb63c783, 0x54d2a578, + 0x5f52816b, 0x14d29d62, 0x06d952ca, 0x4428030e, + 0x2e793590, 0xf75f1d07, 0x79363fa6, 0x047f0c64, + 0xf3ed6a91, 0x2dbc4437, 0x673d4184, 0x00d005ca, + 0x9ca42ff6, 0x841c84dd, 0xaaff5fb0, 0x87f85954, + 0x177c5dc0, 0xfbfbb491, 0xa1e5e03e, 0x5715875c, + 0xa02a0fa4, 0x1fde7abd }; + +static uint32 spp_63[] = /* primes 3 to 1451 */ +{ 0x322123be, 0x40a1853c, 0xd02ea217, 0x363a368b, + 0xacb2117a, 0x342a5ee6, 0xa03a7fda, 0x4338eaac, + 0x9d9cc512, 0xffa944f1, 0x767e0a56, 0xc82c051f, + 0xe91415e0, 0x4cfddc19, 0x7f9539ee, 0x3801a5cc, + 0x3b68d593, 0xa5a8a3a9, 0x71ccc478, 0x938461f7, + 0xe804c928, 0xb3f42839, 0x97fa73a7, 0x09b9ebe5, + 0x7cbb88f1, 0xea9754c4, 0xbc0a20c1, 0xe0b7f585, + 0x6649a4b8, 0x88eec46b, 0xf86f7ccf, 0xfdecbfbd, + 0x46b40b23, 0xcf80aaef, 0xf810bf21, 0x8f793d2d, + 0x2722ddc8, 0xc8c87536, 0x66fc2278, 0xb5186905, + 0xe9f8220c, 0x0b454fa8, 0xc461c002, 0x80e6882a, + 0xb5e77c84, 0xde0b068e, 0xb34cdd5a, 0xa370bc8a, + 0x6e38121f, 0x2f3e9009, 0x82df957a, 0x585c307d, + 0x9b2b1f9d, 0x732df2a0, 0x1d9e6968, 0xbc23657f, + 0x4d152676, 0xe28268ad, 0xf7c026d3, 0x55a2a944, + 0xf41bc21f, 0x67b73894, 0x5828ad87 }; + +static uint32 spp_64[] = /* primes 3 to 1471 */ +{ 0x2465a7bd, 0x85011e1c, 0x9e052792, 0x9fff268c, + 0x82ef7efa, 0x416863ba, 0xa5acdb09, 0x71dba0cc, + 0xac3ee499, 0x9345029f, 0x2cf810b9, 0x9e406aac, + 0x5fce5dd6, 0x9d1c717d, 0xaea5d18a, 0xb913f456, + 0x505679bc, 0x91c57d46, 0xd9888857, 0x862b36e2, + 0xede2e473, 0xc1f0ab35, 0x9da25271, 0xaffe15ff, + 0x240e299d, 0x0b04f4cd, 0x0e4d7c0e, 0x47b1a7ba, + 0x007de89a, 0xae848fd5, 0xbdcd7f98, 0x15564eb0, + 0x60ae14f1, 0x9cb50c29, 0x1f0bbd8e, 0xd1c4c7f8, + 0xfc5fba51, 0x66200193, 0x9b532d92, 0xdac844a8, + 0x431d400c, 0x832d039f, 0x5f900b27, 0x8a75219c, + 0x2986140c, 0x79045d77, 0x59540854, 0xc31504dc, + 0x56f1df5e, 0xebe7bee4, 0x47658b91, 0x7bf696d6, + 0x927f2e24, 0x28fbeb34, 0x0e515cb9, 0x835d6387, + 0x1be8bbe0, 0x9cf13445, 0x799f2e67, 0x78815157, + 0x1a93b4c1, 0xeee55d1b, 0x9072e0b2, 0xf5c4607f }; + +uint32* mp32spprod[SMALL_PRIMES_PRODUCT_MAX] = +{ + spp_01, + spp_02, + spp_03, + spp_04, + spp_05, + spp_06, + spp_07, + spp_08, + spp_09, + spp_10, + spp_11, + spp_12, + spp_13, + spp_14, + spp_15, + spp_16, + spp_17, + spp_18, + spp_19, + spp_20, + spp_21, + spp_22, + spp_23, + spp_24, + spp_25, + spp_26, + spp_27, + spp_28, + spp_29, + spp_30, + spp_31, + spp_32, + spp_33, + spp_34, + spp_35, + spp_36, + spp_37, + spp_38, + spp_39, + spp_40, + spp_41, + spp_42, + spp_43, + spp_44, + spp_45, + spp_46, + spp_47, + spp_48, + spp_49, + spp_50, + spp_51, + spp_52, + spp_53, + spp_54, + spp_55, + spp_56, + spp_57, + spp_58, + spp_59, + spp_60, + spp_61, + spp_62, + spp_63, + spp_64, +}; + +int mp32ptrials(uint32 bits) +{ + if (bits >= 1854) + return 2; + if (bits >= 1223) + return 3; + if (bits >= 927) + return 4; + if (bits >= 747) + return 5; + if (bits >= 627) + return 6; + if (bits >= 543) + return 7; + if (bits >= 480) + return 8; + if (bits >= 431) + return 9; + if (bits >= 393) + return 10; + if (bits >= 361) + return 11; + if (bits >= 335) + return 12; + if (bits >= 314) + return 13; + if (bits >= 295) + return 14; + if (bits >= 279) + return 15; + if (bits >= 265) + return 16; + if (bits >= 253) + return 17; + if (bits >= 242) + return 18; + if (bits >= 232) + return 19; + if (bits >= 223) + return 20; + if (bits >= 216) + return 21; + if (bits >= 209) + return 22; + if (bits >= 202) + return 23; + if (bits >= 196) + return 24; + if (bits >= 191) + return 25; + if (bits >= 186) + return 26; + if (bits >= 182) + return 27; + if (bits >= 178) + return 28; + if (bits >= 174) + return 29; + if (bits >= 170) + return 30; + if (bits >= 167) + return 31; + if (bits >= 164) + return 32; + if (bits >= 161) + return 33; + if (bits >= 160) + return 34; + return 35; +} + +static void mp32prndbits(mp32barrett* p, uint8 msbclr, uint8 lsbset, randomGeneratorContext* rc) +{ + register uint32 size = p->size; + + rc->rng->next(rc->param, p->modl, size); + + if (msbclr) + p->modl[0] &= (0xffffffff >> msbclr); + + p->modl[0] |= (0x80000000 >> msbclr); + + if (lsbset) + p->modl[size] |= (0xffffffff >> (32 - lsbset)); +} + +int mp32psppdiv(const mp32barrett* p) +{ + /* small prime product trial division test */ + register uint32 size = p->size; + + if (size > SMALL_PRIMES_PRODUCT_MAX) + { + mp32setx(size, p->wksp+size, SMALL_PRIMES_PRODUCT_MAX, mp32spprod[SMALL_PRIMES_PRODUCT_MAX-1]); + mp32gcd(p->data, size, p->modl, p->wksp+size, p->wksp); + } + else + { + mp32gcd(p->data, size, p->modl, mp32spprod[size-1], p->wksp); + } + + return mp32isone(size, p->data); +} + +int mp32pmilrabtwo(const mp32barrett* p, uint32 s, const uint32* rdata, const uint32* ndata) +{ + register uint32 j = 0; + + mp32btwopowmod(p, p->size, rdata); + + while (1) + { + if (mp32isone(p->size, p->data)) + return (j == 0); + + if (mp32eq(p->size, p->data, ndata)) + return 1; + + if (++j < s) + mp32bnsqrmodres(p, p->data, (mp32number*) p); + else + return 0; + } +} + +int mp32pmilraba(const mp32barrett* p, const uint32* adata, uint32 s, const uint32* rdata, const uint32* ndata) +{ + register uint32 j = 0; + + mp32bpowmod(p, p->size, adata, p->size, rdata); + + while (1) + { + if (mp32isone(p->size, p->data)) + return (j == 0); + + if (mp32eq(p->size, p->data, ndata)) + return 1; + + if (++j < s) + mp32bnsqrmodres(p, p->data, (mp32number*) p); + else + return 0; + } +} + +int mp32pmilrab(const mp32barrett* p, randomGeneratorContext* rc, int t) +{ + /* + * Miller-Rabin probabilistic primality test, with modification + * + * For more information, see: + * "Handbook of Applied Cryptography" + * Chapter 4.24 + * + * Modification to the standard algorithm: + * The first value of a is not obtained randomly, but set to two + */ + + /* this routine uses (size*3) storage, and calls mp32bpowmod, which needs (size*4+2) */ + /* (size) for a, (size) for r, (size) for n-1 */ + + register uint32* ndata = p->wksp+p->size*4+2; + register uint32* rdata = ndata+p->size; + register uint32* adata = rdata+p->size; + uint32 s; + + mp32copy(p->size, ndata, p->modl); + mp32subw(p->size, ndata, 1); + mp32copy(p->size, rdata, ndata); + + s = mp32divpowtwo(p->size, rdata); /* we've split p-1 into (2^s)*r */ + + /* should do an assert that s != 0 */ + + /* do at least one test, with a = 2 */ + if (t == 0) + t++; + + if (!mp32pmilrabtwo(p, s, rdata, ndata)) + return 0; + + while (t-- > 0) + { + /* generate a random 'a' into b->data */ + mp32brndres(p, adata, rc); + + if (!mp32pmilraba(p, adata, s, rdata, ndata)) + return 0; + } + + return 1; +} + +void mp32prnd(mp32barrett* p, randomGeneratorContext* rc, uint32 size, int t, const mp32number* f) +{ + /* + * Generate a prime p with (size*32) bits + * + * Conditions: size(f) <= size(p) + * + * Optional input f: if f is not null, then search p so that GCD(p-1,f) = 1 + */ + + p->size = size; + p->data = (uint32*) calloc(size*10+4, sizeof(uint32)); + + if (p->data) + { + p->modl = p->data+size+0; + p->mu = p->modl+size+1; + p->wksp = p->mu +size+1; + } + else + { + p->modl = p->mu = p->wksp = (uint32*) 0; + } + + if (p->data) + { + while (1) + { + /* + * Generate a random appropriate candidate prime, and test + * it with small prime divisor test BEFORE computing mu + */ + + mp32prndbits(p, 0, 1, rc); + + /* do a small prime product trial division test on p */ + if (!mp32psppdiv(p)) + continue; + + /* if we have an f, do the congruence test */ + if (f) + { + mp32copy(size, p->data, p->modl); + mp32subw(size, p->data, 1); + mp32setx(size, p->wksp, f->size, f->data); + mp32gcd(p->wksp+2*size, size, p->data, p->wksp, p->wksp+size); + if (!mp32isone(size, p->wksp+2*size)) + continue; + } + + /* candidate has passed so far, now we do the probabilistic test */ + mp32bmu(p); + + if (mp32pmilrab(p, rc, t)) + return; + } + } +} + +void mp32prndconone(mp32barrett* p, randomGeneratorContext* rc, uint32 size, int t, const mp32barrett* q, const mp32number* f, mp32number* rr, int cofactor) +{ + /* + * Generate a prime p with n bits such that p mod q = 1, and p = 2qr+1; k = 2r + * + * Conditions: q > 2 and size(q) < size(p) and size(f) <= size(p) + * + * Conditions: k must be chosen so that k is even, otherwise p will be even! + * + * if cofactor == 0, then r will be chosen randomly + * if cofactor == 1, then make sure that q does not divide k, i.e.: + * q cannot be equal to k, since k is even, and q > 2; hence if q <= r make sure that GCD(q,r) == 1 + * if cofactor == 2, then make sure that r is prime + * + * Optional input f: if f is not null, then search p so that GCD(p-1,f) = 1 + */ + + mp32binit(p, size); + + if (p->data) + { + mp32barrett r; + + memset(&r, 0, sizeof(mp32barrett)); + + mp32binit(&r, p->size - q->size); + + while (1) + { + mp32prndbits(&r, 1, 0, rc); + + if (cofactor == 1) + { + r.modl[r.size-1] |= 0x1; + + /* if (q <= r) check if GCD(q,r) != 1 */ + if (mp32lex(q->size, q->modl, r.size, r.modl)) + { + /* we can find adequate storage for computing the gcd in r->wksp */ + mp32setx(r.size, r.wksp+r.size, q->size, q->modl); + mp32gcd(r.data, r.size, r.modl, r.wksp+r.size, r.wksp); + + if (!mp32isone(r.size, r.data)) + continue; + } + } + else if (cofactor == 2) + { + r.modl[r.size-1] |= 0x1; + } + + /* should do an assert that k is even */ + + if (cofactor == 2) + { + /* do a small prime product trial division test on r */ + if (!mp32psppdiv(&r)) + continue; + } + + /* multiply q*r into p, multiply by two, then add 1 */ + mp32mul(p->modl, r.size, r.modl, q->size, q->modl); + mp32multwo(p->size, p->modl); + mp32addw(p->size, p->modl, 1); + + /* do a small prime product trial division test on p */ + if (!mp32psppdiv(p)) + continue; + + /* if we have an f, do the congruence test */ + if (f) + { + mp32copy(size, p->data, p->modl); + mp32subw(size, p->data, 1); + mp32setx(size, p->wksp, f->size, f->data); + mp32gcd(p->wksp+2*size, size, p->data, p->wksp, p->wksp+size); + if (!mp32isone(size, p->wksp+2*size)) + continue; + } + + /* if cofactor is two, test if r is prime */ + if (cofactor == 2) + { + mp32bmu(&r); + + if (!mp32pmilrab(&r, rc, mp32ptrials(r.size << 5))) + continue; + } + + /* candidate has passed so far, now we do the probabilistic test on p */ + mp32bmu(p); + + if (!mp32pmilrab(p, rc, t)) + continue; + + mp32nset(rr, r.size, r.modl); + mp32bfree(&r); + + return; + } + } +} + +void mp32prndsafe(mp32barrett* p, randomGeneratorContext* rc, uint32 size, int t) +{ + /* + * Initialize with a probable safe prime of 'size' words, with probability factor t + * + * A safe prime p has the property that p = 2q+1, where q is also prime + * Use for ElGamal type schemes, where a generator of order (p-1) is required + */ + + p->size = size; + p->data = (uint32*) calloc(size*10+4, sizeof(uint32)); + + if (p->data) + { + p->modl = p->data+size+0; + p->mu = p->modl+size+1; + p->wksp = p->mu +size+1; + } + else + { + p->modl = p->mu = p->wksp = (uint32*) 0; + } + + if (p->data) + { + mp32barrett q; + + memset(&q, 0, sizeof(mp32barrett)); + + mp32binit(&q, size); + + while (1) + { + /* + * Generate a random appropriate candidate prime, and test + * it with small prime divisor test BEFORE computing mu + */ + + mp32prndbits(p, 0, 2, rc); + + mp32copy(size, q.modl, p->modl); + mp32divtwo(size, q.modl); + + /* do a small prime product trial division on q */ + if (!mp32psppdiv(&q)) + continue; + + /* do a small prime product trial division on p */ + if (!mp32psppdiv(p)) + continue; + + /* candidate prime has passed small prime division test for p and q */ + mp32bmu(&q); + + if (!mp32pmilrab(&q, rc, t)) + continue; + + mp32bmu(p); + + if (!mp32pmilrab(p, rc, t)) + continue; + + mp32bfree(&q); + + return; + } + } +} diff --git a/beecrypt/mp32prime.h b/beecrypt/mp32prime.h new file mode 100644 index 0000000..c2ff588 --- /dev/null +++ b/beecrypt/mp32prime.h @@ -0,0 +1,57 @@ +/* + * mp32prime.h + * + * Multi-precision primes, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _MP32PRIME_H +#define _MP32PRIME_H + +#include "mp32barrett.h" + +#define SMALL_PRIMES_PRODUCT_MAX 64 + +extern uint32* mp32spprod[SMALL_PRIMES_PRODUCT_MAX]; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int mp32ptrials (uint32); +BEEDLLAPI +int mp32pmilrab (const mp32barrett*, randomGeneratorContext*, int); + +BEEDLLAPI +void mp32prnd (mp32barrett*, randomGeneratorContext*, uint32, int, const mp32number*); +BEEDLLAPI +void mp32prndsafe (mp32barrett*, randomGeneratorContext*, uint32, int); +BEEDLLAPI +void mp32prndcon (mp32barrett*, randomGeneratorContext*, uint32, int, const mp32number*, const mp32number*, const mp32number*, mp32number*); +BEEDLLAPI +void mp32prndconone(mp32barrett*, randomGeneratorContext*, uint32, int, const mp32barrett*, const mp32number*, mp32number*, int); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/mtprng.c b/beecrypt/mtprng.c new file mode 100644 index 0000000..dd2eaa2 --- /dev/null +++ b/beecrypt/mtprng.c @@ -0,0 +1,232 @@ +/* + * mtprng.c + * + * Mersenne Twister pseudo-random number generator + * + * Developed by Makoto Matsumoto and Takuji Nishimura + * + * For more information, see: + * http://www.math.keio.ac.jp/~matumoto/emt.html + * + * Adapted from optimized code by Shawn J. Cokus + * + * Note: this generator has a very long period, passes statistical test, but + * needs more study to determine whether it is cryptographically strong enough. + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "mtprng.h" +#include "mp32.h" +#include "mp32opt.h" + +#if HAVE_STDLIB_H +#include +#endif + +#define hiBit(a) ((a) & 0x80000000) +#define loBit(a) ((a) & 0x1) +#define loBits(a) ((a) & 0x7FFFFFFF) +#define mixBits(a, b) (hiBit(a) | loBits(b)) + +const randomGenerator mtprng = { "Mersenne Twister", sizeof(mtprngParam), (const randomGeneratorSetup) mtprngSetup, (const randomGeneratorSeed) mtprngSeed, (const randomGeneratorNext) mtprngNext, (const randomGeneratorCleanup) mtprngCleanup }; + +static void mtprngReload(mtprngParam* mp) +{ + register uint32* p0 = mp->state, *p2=p0+2, *pM = p0+M, s0, s1; + register int j; + + for (s0=mp->state[0], s1=mp->state[1], j=N-M+1; --j; s0=s1, s1=*(p2++)) + *(p0++) = *(pM++) ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0); + + for (pM=mp->state, j=M; --j; s0=s1, s1=*(p2++)) + *(p0++) = *(pM++) ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0); + + s1 = mp->state[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0); + + mp->left = N; + mp->nextw = mp->state; +} + +int mtprngSetup(mtprngParam* mp) +{ + if (mp) + { + const entropySource* es = entropySourceDefault(); + + #ifdef _REENTRANT + # if WIN32 + if (!(mp->lock = CreateMutex(NULL, FALSE, NULL))) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_init(&mp->lock, USYNC_THREAD, (void *) 0)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_init(&mp->lock, (pthread_mutexattr_t *) 0)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + if (es) + { + mp->left = 0; + + return es->next(mp->state, N+1); + } + } + return -1; +} + +int mtprngSeed(mtprngParam* mp, const uint32* data, int size) +{ + if (mp) + { + uint32 needed = N+1; + uint32* dest = mp->state; + + #ifdef _REENTRANT + # if WIN32 + if (WaitForSingleObject(mp->lock, INFINITE) != WAIT_OBJECT_0) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_lock(&mp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&mp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + while (size < needed) + { + mp32copy(size, dest, data); + dest += size; + needed -= size; + } + mp32copy(needed, dest, data); + #ifdef _REENTRANT + # if WIN32 + if (!ReleaseMutex(mp->lock)) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_unlock(&mp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_unlock(&mp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + return 0; + } + return -1; +} + +int mtprngNext(mtprngParam* mp, uint32* data, int size) +{ + if (mp) + { + register uint32 tmp; + + #ifdef _REENTRANT + # if WIN32 + if (WaitForSingleObject(mp->lock, INFINITE) != WAIT_OBJECT_0) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_lock(&mp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_lock(&mp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + while (size--) + { + if (mp->left == 0) + mtprngReload(mp); + + tmp = *(mp->nextw++); + tmp ^= (tmp >> 11); + tmp ^= (tmp << 7) & 0x9D2C5680; + tmp ^= (tmp << 15) & 0xEFC60000; + tmp ^= (tmp >> 18); + mp->left--; + *(data++) = tmp; + } + #ifdef _REENTRANT + # if WIN32 + if (!ReleaseMutex(mp->lock)) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_unlock(&mp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_unlock(&mp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + return 0; + } + return -1; +} + +int mtprngCleanup(mtprngParam* mp) +{ + if (mp) + { + #ifdef _REENTRANT + # if WIN32 + if (!CloseHandle(mp->lock)) + return -1; + # else + # if HAVE_SYNCH_H + if (mutex_destroy(&mp->lock)) + return -1; + # elif HAVE_PTHREAD_H + if (pthread_mutex_destroy(&mp->lock)) + return -1; + # else + # error need locking mechanism + # endif + # endif + #endif + return 0; + } + return -1; +} diff --git a/beecrypt/mtprng.h b/beecrypt/mtprng.h new file mode 100644 index 0000000..1efeca1 --- /dev/null +++ b/beecrypt/mtprng.h @@ -0,0 +1,88 @@ +/* + * mtprng.h + * + * Mersenne twister pseudo-random number generator, header + * + * Copyright (c) 1998-2000 Virtual Unlimited B.V. + * + * Author: 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 _MTPRNG_H +#define _MTPRNG_H + +#include "beecrypt.h" + +#if WIN32 +# include +#else +# if HAVE_SYNCH_H +# include +# elif HAVE_PTHREAD_H +# include +# else +# error need locking mechanism +# endif +#endif + +#include "beecrypt.h" + +#define N 624 +#define M 397 +#define K 0x9908B0DF + +typedef struct +{ + #ifdef _REENTRANT + # if WIN32 + HANDLE lock; + # else + # if HAVE_SYNCH_H + mutex_t lock; + # elif HAVE_PTHREAD_H + pthread_mutex_t lock; + # else + # error need locking mechanism + # endif + # endif + #endif + uint32 state[N+1]; + uint32 left; + uint32* nextw; +} mtprngParam; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const randomGenerator mtprng; + +BEEDLLAPI +int mtprngSetup (mtprngParam*); +BEEDLLAPI +int mtprngSeed (mtprngParam*, const uint32*, int); +BEEDLLAPI +int mtprngNext (mtprngParam*, uint32*, int); +BEEDLLAPI +int mtprngCleanup(mtprngParam*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/mwerks/Makefile.am b/beecrypt/mwerks/Makefile.am new file mode 100644 index 0000000..b1e006f --- /dev/null +++ b/beecrypt/mwerks/Makefile.am @@ -0,0 +1,25 @@ +# +# Makefile.am's purpose is to add the Metrowerks CodeWarrior assembler sources to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + +AUTOMAKE_OPTIONS = gnu no-dependencies + +EXTRA_DIST = beecrypt.pch blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm diff --git a/beecrypt/mwerks/Makefile.in b/beecrypt/mwerks/Makefile.in new file mode 100644 index 0000000..023fa79 --- /dev/null +++ b/beecrypt/mwerks/Makefile.in @@ -0,0 +1,209 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# +# Makefile.am's purpose is to add the Metrowerks CodeWarrior assembler sources to the dist +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +AS = @AS@ +CC = @CC@ +CPP = @CPP@ +DLLTOOL = @DLLTOOL@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +ac_cv_have_java = @ac_cv_have_java@ +ac_cv_have_javac = @ac_cv_have_javac@ + +AUTOMAKE_OPTIONS = gnu no-dependencies + +EXTRA_DIST = beecrypt.pch blowfishopt.i586.asm fips180opt.i586.asm mp32opt.i386.asm +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.gnu.h +CONFIG_CLEAN_FILES = +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu mwerks/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = mwerks + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# 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. +.NOEXPORT: diff --git a/beecrypt/mwerks/beecrypt.pch b/beecrypt/mwerks/beecrypt.pch new file mode 100644 index 0000000..059bc82 --- /dev/null +++ b/beecrypt/mwerks/beecrypt.pch @@ -0,0 +1,6 @@ +#include + +#pragma precompile_target "beecrypt.mch" + +#define HAVE_CONFIG_H +#define JAVAGLUE 1 diff --git a/beecrypt/mwerks/blowfishopt.i586.asm b/beecrypt/mwerks/blowfishopt.i586.asm new file mode 100644 index 0000000..1c283b6 --- /dev/null +++ b/beecrypt/mwerks/blowfishopt.i586.asm @@ -0,0 +1,173 @@ +# +# blowfishopt.i586.asm +# +# Assembler optimized blowfish routines for Intel Pentium processors +# +# Compile target is Metrowerks CodeWarrior Pro 5 for Windows +# +# Copyright (c) 2000 Virtual Unlimited B.V. +# +# Author: 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 +# + +etworounds: .macro p + xor ecx,[esi+p] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,ch + mov bl,cl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor edx,edi + xor edx,[esi+p+4] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,dh + mov bl,dl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor ecx,edi + .endm + +dtworounds: .macro p + xor ecx,[esi+p+4] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,ch + mov bl,cl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor edx,edi + xor edx,[esi+p] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,dh + mov bl,dl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor ecx,edi + .endm + + .text + + .align 8 + .globl _blowfishEncrypt + +_blowfishEncrypt: + push edi + push esi + push ebx + + mov esi,[esp+16] + mov edi,[esp+24] + + xor eax,eax + xor ebx,ebx + + mov ecx,[edi] + mov edx,[edi+4] + + bswap ecx + bswap edx + + etworounds 0 + etworounds 8 + etworounds 16 + etworounds 24 + etworounds 32 + etworounds 40 + etworounds 48 + etworounds 56 + + mov edi,[esp+20] + xor ecx,[esi+64] + xor edx,[esi+68] + + bswap ecx + bswap edx + + mov [edi+4],ecx + mov [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret + + .align 8 + .globl _blowfishDecrypt + +_blowfishDecrypt: + push edi + push esi + push ebx + + mov esi,[esp+16] + mov edi,[esp+24] + + xor eax,eax + xor ebx,ebx + + mov ecx,[edi] + mov edx,[edi+4] + + bswap ecx + bswap edx + + dtworounds 64 + dtworounds 56 + dtworounds 48 + dtworounds 40 + dtworounds 32 + dtworounds 24 + dtworounds 16 + dtworounds 8 + + mov edi,[esp+20] + xor ecx,[esi+4] + xor edx,[esi] + + bswap ecx + bswap edx + + mov [edi+4],ecx + mov [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret diff --git a/beecrypt/mwerks/fips180opt.i586.asm b/beecrypt/mwerks/fips180opt.i586.asm new file mode 100644 index 0000000..61149b4 --- /dev/null +++ b/beecrypt/mwerks/fips180opt.i586.asm @@ -0,0 +1,292 @@ +# +# fips180opt.i586.asm +# +# Assembler optimized SHA-1 routines for Intel Pentium processors +# +# Compile target is Metrowerks CodeWarrior Pro 5 for Windows +# +# Copyright (c) 2000 Virtual Unlimited B.V. +# +# Author: 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 +# + +K00 .equ 0x5a827999 +K20 .equ 0x6ed9eba1 +K40 .equ 0x8f1bbcdc +K60 .equ 0xca62c1d6 + +PARAM_H .equ 0 +PARAM_DATA .equ 20 +PARAM_OFFSET .equ 352 + +subround1: .macro b,c,d,e,w + mov ecx,c + mov ebx,b + mov edx,d + rol eax,5 + xor ecx,edx + add eax,e + and ecx,ebx + add eax,K00 + ror ebx,2 + add eax,w + xor ecx,edx + mov b,ebx + add eax,ecx + mov e,eax + .endm + +subround2: .macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K20 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + .endm + +subround3: .macro b,c,d,e,w + mov ecx,c + rol eax,5 + mov ebx,b + mov edx,ecx + add eax,e + or ecx,ebx # (b|c) + and edx,ebx # (b&c) + and ecx,d # (b|c)&d + add eax,K40 + or ecx,edx + add eax,w + ror ebx,2 + add eax,ecx + mov b,ebx + mov e,eax + .endm + +subround4: .macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K60 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + .endm + + .text + + .align 8 + .globl _sha1Process + +_sha1Process: + push edi + push esi + push ebx + push ebp + # allocate local variables + mov esi,[esp+20] + sub esp,20 + lea edi,[esi+PARAM_DATA] + mov ebp,esp + + mov ecx,4 +@loads: + mov edx,[esi+ecx*4] + mov [ebp+ecx*4],edx + dec ecx + jns @loads + + mov ecx,15 + xor eax,eax + + .align 4 +@swaps: + mov edx,[edi+ecx*4] + bswap edx + mov [edi+ecx*4],edx + dec ecx + jns @swaps + + lea edi,[esi+PARAM_DATA] + mov [esi+PARAM_OFFSET],al + mov ecx,16 + + .align 4 +@xors: + mov eax,[edi+52] + mov ebx,[edi+56] + xor eax,[edi+32] + xor ebx,[edi+36] + xor eax,[edi+ 8] + xor ebx,[edi+12] + xor eax,[edi ] + xor ebx,[edi+ 4] + rol eax,1 + rol ebx,1 + mov [edi+64],eax + mov [edi+68],ebx + mov eax,[edi+60] + mov ebx,[edi+64] + xor eax,[edi+40] + xor ebx,[edi+44] + xor eax,[edi+16] + xor ebx,[edi+20] + xor eax,[edi+ 8] + xor ebx,[edi+12] + rol eax,1 + rol ebx,1 + mov [edi+72],eax + mov [edi+76],ebx + add edi,16 + dec ecx + jnz @xors + + mov edi,PARAM_DATA + + # to optimize further, use esi only, and store the add constant into edi + # will make code smaller and faster + +@round01to20: + mov eax,[ebp] + subround1 [ebp+4],[ebp+8],[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + +@round21to40: + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + +@round41to60: + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + +@round61to80: + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + # add edi,20 + + mov ecx,4 + +@adds: + mov eax,[ebp+ecx*4] + add [esi+ecx*4],eax + dec ecx + jns @adds + + add esp,20 + pop ebp + pop ebx + pop esi + pop edi + ret diff --git a/beecrypt/mwerks/mp32opt.i386.asm b/beecrypt/mwerks/mp32opt.i386.asm new file mode 100644 index 0000000..a5dd319 --- /dev/null +++ b/beecrypt/mwerks/mp32opt.i386.asm @@ -0,0 +1,299 @@ +# +# mp32opt.i386.asm +# +# Assembler optimized multiprecision integer routines for Intel 386 +# +# Compile target is MetroWerks CodeWarrior Pro 5 for Windows +# +# Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + + .text + + .align 8 + .globl _mp32zero +_mp32zero: + push edi + + mov ecx,[esp+8] + mov edi,[esp+12] + + xor eax,eax + rep stosd + + pop edi + ret + + + .align 8 + .globl _mp32fill +_mp32fill: + push edi + + mov ecx,[esp+8] + mov edi,[esp+12] + mov eax,[esp+16] + + rep stosd + + pop edi + ret + + + .align 8 + .globl _mp32odd +_mp32odd: + mov ecx,[esp+4] + mov eax,[esp+8] + mov eax,[eax+ecx*4-4] + and eax,1 + ret + + + .align 8 + .globl _mp32even +_mp32even: + mov ecx,[esp+4] + mov eax,[esp+8] + mov eax,[eax+ecx*4-4] + not eax + and eax,1 + ret + + + .align 8 + .globl _mp32addw +_mp32addw: + push edi + + mov ecx,[esp+8] + mov edi,[esp+12] + mov eax,[esp+16] + + lea edi,[edi+ecx*4-4] + add [edi],eax + dec ecx + jz @mp32addw_end + sub edi,4 + xor edx,edx + + .align 4 +@mp32addw_loop: + adc [edi],edx + sub edi,4 + dec ecx + jnz @mp32addw_loop +@mp32addw_end: + sbb eax,eax + neg eax + + pop edi + ret + + + .align 8 + .globl _mp32subw +_mp32subw: + push edi + + mov ecx,[esp+8] + mov edi,[esp+12] + mov eax,[esp+16] + + lea edi,[edi+ecx*4-4] + sub [edi],eax + dec ecx + jz @mp32subw_end + sub edi,4 + xor edx,edx + + .align 4 +@mp32subw_loop: + sbb [edi],edx + sub edi,4 + dec ecx + jnz @mp32subw_loop +@mp32subw_end: + sbb eax,eax + neg eax + + pop edi + ret + + + .align 8 + .globl _mp32add +_mp32add: + push edi + push esi + + mov ecx,[esp+12] + mov edi,[esp+16] + mov esi,[esp+20] + + xor edx,edx + dec ecx + +@mp32add_loop: + mov eax,[esi+ecx*4] + adc [edi+ecx*4],eax + dec ecx + jns @mp32add_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret + + + .align 8 + .globl _mp32sub +_mp32sub: + push edi + push esi + + mov ecx,[esp+12] + mov edi,[esp+16] + mov esi,[esp+20] + + xor edx,edx + dec ecx + +@mp32sub_loop: + mov eax,[esi+ecx*4] + sbb [edi+ecx*4],eax + dec ecx + jns @mp32sub_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret + + + .align 8 + .globl _mp32setmul +_mp32setmul: + push edi + push esi + push ebx + push ebp + + mov ecx,[esp+20] + mov edi,[esp+24] + mov esi,[esp+28] + mov ebp,[esp+32] + + xor edx,edx + dec ecx + + .align 4 +@mp32setmul_loop: + mov ebx,edx + mov eax,[esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + mov [edi+ecx*4],eax + dec ecx + jns @mp32setmul_loop + + mov eax,edx + + pop ebp + pop ebx + pop esi + pop edi + ret + + + .align 8 + .globl _mp32addmul +_mp32addmul: + push edi + push esi + push ebx + push ebp + + mov ecx,[esp+20] + mov edi,[esp+24] + mov esi,[esp+28] + mov ebp,[esp+32] + + xor edx,edx + dec ecx + + .align 4 +@mp32addmul_loop: + mov ebx,edx + mov eax,[esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + add [edi+ecx*4],eax + adc edx,0 + dec ecx + jns @mp32addmul_loop + + mov eax,edx + + pop ebp + pop ebx + pop esi + pop edi + ret + + + .align 8 + .globl _mp32addsqrtrc +_mp32addsqrtrc: + push edi + push esi + push ebx + + mov ecx,[esp+16] + mov edi,[esp+20] + mov esi,[esp+24] + + xor ebx,ebx + dec ecx + + .align 4 +@mp32addsqrtrc_loop: + mov eax,[esi+ecx*4] + mul eax + add eax,ebx + adc edx,0 + add [edi+ecx*8+4],eax + adc [edi+ecx*8+0],edx + sbb ebx,ebx + neg ebx + dec ecx + jns @mp32addsqrtrc_loop + + mov eax,ebx + + pop ebx + pop esi + pop edi + ret diff --git a/beecrypt/rsa.c b/beecrypt/rsa.c new file mode 100644 index 0000000..79320c7 --- /dev/null +++ b/beecrypt/rsa.c @@ -0,0 +1,121 @@ +/* + * rsa.c + * + * RSA Encryption & signature scheme, code + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "rsa.h" +#include "mp32.h" + +#if HAVE_STDLIB_H +# include "stdlib.h" +#endif +int rsapri(const rsakp* kp, const mp32number* m, mp32number* c) +{ + register uint32 size = kp->n.size; + register uint32* temp = (uint32*) malloc((4*size+2)*sizeof(uint32)); + + if (temp) + { + mp32nsize(c, size); + mp32bpowmod_w(&kp->n, m->size, m->data, kp->d.size, kp->d.data, c->data, temp); + + free(temp); + + return 0; + } + return -1; +} + +/* 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(uint32)); + register uint32* wksp = temp+psize+qsize+nsize; + + /* compute j1 = m^d1 mod p */ + if (mp32gex(psize, kp->p.modl, m->size, m->data)) + { + mp32setx(nsize, temp+psize+qsize, m->size, m->data); + mp32bmod_w(&kp->p, temp+psize+qsize, temp, wksp); + } + 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); + mp32bmod_w(&kp->q, temp+psize+qsize, temp+psize, wksp); + } + else + mp32setx(qsize, temp+psize, m->size, m->data); + + mp32bpowmod_w(&kp->q, qsize, temp+psize, kp->d2.size, kp->d2.data, temp+psize, wksp); + + /* compute j1-j2 */ + mp32subx(psize, temp, qsize, temp+psize); + + /* compute h = c*(j1-j2) mod p */ + mp32bmulmod_w(&kp->p, psize, temp, psize, kp->c.data, temp, wksp); + + /* 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); + mp32addx(nsize, c->data, qsize, temp+psize); + + free(temp); + + return -1; +} + +/** + * returns: 0 if signature verifies + * -1 otherwise, can also indicate errors + */ +int rsavrfy(const rsapk* pk, const mp32number* m, const mp32number* c) +{ + int rc; + register uint32 size = pk->n.size; + register uint32* temp = (uint32*) malloc((5*size+2)*sizeof(uint32)); + + if (temp) + { + mp32bpowmod_w(&pk->n, c->size, c->data, pk->e.size, pk->e.data, temp, temp+size); + + rc = mp32eqx(size, temp, m->size, m->data); + + free(temp); + + return rc; + } + return 0; +} diff --git a/beecrypt/rsa.h b/beecrypt/rsa.h new file mode 100644 index 0000000..2722620 --- /dev/null +++ b/beecrypt/rsa.h @@ -0,0 +1,47 @@ +/* + * rsa.h + * + * RSA encryption & signature scheme, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _RSA_H +#define _RSA_H + +#include "rsakp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int rsapri (const rsakp* kp, const mp32number* m, mp32number* c); +BEEDLLAPI +int rsapricrt(const rsakp* kp, const mp32number* m, mp32number* c); + +BEEDLLAPI +int rsavrfy (const rsapk* pk, const mp32number* m, const mp32number* c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/rsakp.c b/beecrypt/rsakp.c new file mode 100644 index 0000000..7874fb2 --- /dev/null +++ b/beecrypt/rsakp.c @@ -0,0 +1,187 @@ +/* + * rsakp.c + * + * RSA Keypair, code + * + * + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "rsakp.h" +#include "mp32prime.h" +#include "mp32.h" + +#if HAVE_STDLIB_H +# include +#endif + +int rsakpMake(rsakp* kp, randomGeneratorContext* rgc, int nsize) +{ + /* + * Generates an RSA Keypair for use with the Chinese Remainder Theorem + */ + + register uint32 pqsize = (nsize+1) >> 1; + register uint32* temp = (uint32*) malloc((16*pqsize+6)*sizeof(uint32)); + register uint32 newn = 1; + + if (temp) + { + mp32barrett r, psubone, qsubone, phi; + + nsize = pqsize << 1; + + /* set e */ + mp32nsetw(&kp->e, 65535); + + /* generate a random prime p and q */ + mp32prnd_w(&kp->p, rgc, pqsize, mp32ptrials(pqsize << 5), &kp->e, temp); + mp32prnd_w(&kp->q, rgc, pqsize, mp32ptrials(pqsize << 5), &kp->e, temp); + + /* if p <= q, perform a swap to make p larger than q */ + if (mp32le(pqsize, kp->p.modl, kp->q.modl)) + { + memcpy(&r, &kp->q, sizeof(mp32barrett)); + memcpy(&kp->q, &kp->p, sizeof(mp32barrett)); + memcpy(&kp->p, &r, sizeof(mp32barrett)); + } + + mp32bzero(&r); + mp32bzero(&psubone); + mp32bzero(&qsubone); + mp32bzero(&phi); + + while (1) + { + mp32mul(temp, pqsize, kp->p.modl, pqsize, kp->q.modl); + + if (newn && mp32msbset(nsize, temp)) + break; + + /* product of p and q doesn't have the required size (one bit short) */ + + mp32prnd_w(&r, rgc, pqsize, mp32ptrials(pqsize << 5), &kp->e, temp); + + if (mp32le(pqsize, kp->p.modl, r.modl)) + { + mp32bfree(&kp->q); + memcpy(&kp->q, &kp->p, sizeof(mp32barrett)); + memcpy(&kp->p, &r, sizeof(mp32barrett)); + mp32bzero(&r); + newn = 1; + } + else if (mp32le(pqsize, kp->q.modl, r.modl)) + { + mp32bfree(&kp->q); + memcpy(&kp->q, &r, sizeof(mp32barrett)); + mp32bzero(&r); + newn = 1; + } + else + { + mp32bfree(&r); + newn = 0; + } + } + + mp32bset(&kp->n, nsize, temp); + + /* compute p-1 */ + mp32bsubone(&kp->p, temp); + mp32bset(&psubone, pqsize, temp); + + /* compute q-1 */ + mp32bsubone(&kp->q, temp); + mp32bset(&qsubone, pqsize, temp); + + /* compute phi = (p-1)*(q-1) */ + mp32mul(temp, pqsize, psubone.modl, pqsize, qsubone.modl); + mp32bset(&phi, nsize, temp); + + /* compute d = inv(e) mod phi */ + mp32nsize(&kp->d, nsize); + mp32binv_w(&phi, kp->e.size, kp->e.data, kp->d.data, temp); + + /* compute d1 = d mod (p-1) */ + mp32nsize(&kp->d1, pqsize); + mp32bmod_w(&psubone, kp->d.data, kp->d1.data, temp); + + /* compute d2 = d mod (q-1) */ + mp32nsize(&kp->d2, pqsize); + mp32bmod_w(&qsubone, kp->d.data, kp->d2.data, temp); + + /* compute c = inv(q) mod p */ + mp32nsize(&kp->c, pqsize); + mp32binv_w(&kp->p, pqsize, kp->q.modl, kp->c.data, temp); + + free(temp); + + return 0; + } + return -1; +} + +int rsakpInit(rsakp* kp) +{ + memset(kp, 0, sizeof(rsakp)); + /* or + mp32bzero(&kp->n); + mp32nzero(&kp->e); + mp32nzero(&kp->d); + mp32bzero(&kp->p); + mp32bzero(&kp->q); + mp32nzero(&kp->d1); + mp32nzero(&kp->d2); + mp32nzero(&kp->c); + */ + + return 0; +} + +int rsakpFree(rsakp* kp) +{ + mp32bfree(&kp->n); + mp32nfree(&kp->e); + mp32nfree(&kp->d); + mp32bfree(&kp->p); + mp32bfree(&kp->q); + mp32nfree(&kp->d1); + mp32nfree(&kp->d2); + mp32nfree(&kp->c); + + return 0; +} + +int rsakpCopy(rsakp* dst, const rsakp* src) +{ + mp32bcopy(&dst->n, &src->n); + mp32ncopy(&dst->e, &src->e); + mp32ncopy(&dst->d, &src->d); + mp32bcopy(&dst->p, &src->p); + mp32bcopy(&dst->q, &src->q); + mp32ncopy(&dst->d1, &src->d1); + mp32ncopy(&dst->d2, &src->d2); + mp32ncopy(&dst->c, &src->c); + + return 0; +} diff --git a/beecrypt/rsakp.h b/beecrypt/rsakp.h new file mode 100644 index 0000000..cac05cc --- /dev/null +++ b/beecrypt/rsakp.h @@ -0,0 +1,62 @@ +/* + * rsakp.h + * + * RSA Keypair, header + * + * + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 _RSAKP_H +#define _RSAKP_H + +#include "rsapk.h" + +typedef struct +{ + mp32barrett n; + mp32number e; + mp32number d; + mp32barrett p; + mp32barrett q; + mp32number d1; + mp32number d2; + mp32number c; +} rsakp; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int rsakpMake(rsakp*, randomGeneratorContext*, int); +BEEDLLAPI +int rsakpInit(rsakp*); +BEEDLLAPI +int rsakpFree(rsakp*); +BEEDLLAPI +int rsakpCopy(rsakp*, const rsakp*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/rsapk.c b/beecrypt/rsapk.c new file mode 100644 index 0000000..97ab023 --- /dev/null +++ b/beecrypt/rsapk.c @@ -0,0 +1,57 @@ +/* + * rsapk.c + * + * RSA Public Key, code + * + * + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "rsapk.h" + +int rsapkInit(rsapk* pk) +{ + memset(pk, 0, sizeof(rsapk)); + /* or + mp32bzero(&pk->n); + mp32nzero(&pk->e); + */ + + return 0; +} + +int rsapkFree(rsapk* pk) +{ + mp32bfree(&pk->n); + mp32nfree(&pk->e); + + return 0; +} + +int rsapkCopy(rsapk* dst, const rsapk* src) +{ + mp32bcopy(&dst->n, &src->n); + mp32ncopy(&dst->e, &src->e); + + return 0; +} diff --git a/beecrypt/rsapk.h b/beecrypt/rsapk.h new file mode 100644 index 0000000..f1f784a --- /dev/null +++ b/beecrypt/rsapk.h @@ -0,0 +1,52 @@ +/* + * rsapk.h + * + * RSA Public Key, header + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 _RSAPK_H +#define _RSAPK_H + +#include "mp32barrett.h" + +typedef struct +{ + mp32barrett n; + mp32number e; +} rsapk; + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +int rsapkInit(rsapk*); +BEEDLLAPI +int rsapkFree(rsapk*); +BEEDLLAPI +int rsapkCopy(rsapk*, const rsapk*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/sha1hmac.c b/beecrypt/sha1hmac.c new file mode 100644 index 0000000..bd0558c --- /dev/null +++ b/beecrypt/sha1hmac.c @@ -0,0 +1,50 @@ +/* + * sha1hmac.c + * + * SHA-1/HMAC message authentication code, code + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "sha1hmac.h" + +const keyedHashFunction sha1hmac = { "SHA-1/HMAC", sizeof(sha1hmacParam), 5 * sizeof(uint32), 64, 512, 32, (const keyedHashFunctionSetup) sha1hmacSetup, (const keyedHashFunctionReset) sha1hmacReset, (const keyedHashFunctionUpdate) sha1hmacUpdate, (const keyedHashFunctionDigest) sha1hmacDigest }; + +int sha1hmacSetup (sha1hmacParam* sp, const uint32* key, int keybits) +{ + return hmacSetup((hmacParam*) sp, &sha1, &sp->param, key, keybits); +} + +int sha1hmacReset (sha1hmacParam* sp) +{ + return hmacReset((hmacParam*) sp, &sha1, &sp->param); +} + +int sha1hmacUpdate(sha1hmacParam* sp, const byte* data, int size) +{ + return hmacUpdate((hmacParam*) sp, &sha1, &sp->param, data, size); +} + +int sha1hmacDigest(sha1hmacParam* sp, uint32* data) +{ + return hmacDigest((hmacParam*) sp, &sha1, &sp->param, data); +} diff --git a/beecrypt/sha1hmac.h b/beecrypt/sha1hmac.h new file mode 100644 index 0000000..f687668 --- /dev/null +++ b/beecrypt/sha1hmac.h @@ -0,0 +1,58 @@ +/* + * sha1hmac.h + * + * SHA-1/HMAC message authentication code, header + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 _SHA1HMAC_H +#define _SHA1HMAC_H + +#include "hmac.h" +#include "fips180.h" + +typedef struct +{ + byte kxi[64]; + byte kxo[64]; + sha1Param param; +} sha1hmacParam; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const keyedHashFunction sha1hmac; + +BEEDLLAPI +int sha1hmacSetup (sha1hmacParam*, const uint32*, int); +BEEDLLAPI +int sha1hmacReset (sha1hmacParam*); +BEEDLLAPI +int sha1hmacUpdate(sha1hmacParam*, const byte*, int); +BEEDLLAPI +int sha1hmacDigest(sha1hmacParam*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/sha256.c b/beecrypt/sha256.c new file mode 100644 index 0000000..0fd4635 --- /dev/null +++ b/beecrypt/sha256.c @@ -0,0 +1,239 @@ +/* + * sha256.c + * + * SHA-256 hash function, code + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "sha256.h" +#include "mp32.h" +#include "endianness.h" + +static const uint32 k[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; + +static const uint32 hinit[8] = { + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 +}; + +const hashFunction sha256 = { "SHA-256", sizeof(sha256Param), 64, 8 * sizeof(uint32), (hashFunctionReset) sha256Reset, (hashFunctionUpdate) sha256Update, (hashFunctionDigest) sha256Digest }; + +int sha256Reset(register sha256Param *p) +{ + mp32copy(8, p->h, hinit); + mp32zero(64, p->data); + p->length = 0; + p->offset = 0; + return 0; +} + +#define R(x,s) ((x) >> (s)) +#define S(x,s) ROTR32(x, s) + +#define CH(x,y,z) ((x&(y^z))^z) +#define MAJ(x,y,z) (((x|y)&z)|(x&y)) +#define SIG0(x) (S(x,2) ^ S(x,13) ^ S(x,22)) +#define SIG1(x) (S(x,6) ^ S(x,11) ^ S(x,25)) +#define sig0(x) (S(x,7) ^ S(x,18) ^ R(x,3)) +#define sig1(x) (S(x,17) ^ S(x,19) ^ R(x,10)) + +#define ROUND(a,b,c,d,e,f,g,h,w,k) \ + temp = h + SIG1(e) + CH(e,f,g) + k + w; \ + h = temp + SIG0(a) + MAJ(a,b,c); \ + d += temp + +#ifndef ASM_SHA256PROCESS +void sha256Process(register sha256Param *p) +{ + register uint32 a, b, c, d, e, f, g, h, temp; + register uint32 *w; + register byte t; + + #if WORDS_BIGENDIAN + w = p->data + 16; + #else + w = p->data; + t = 16; + while (t--) + { + register uint32 temp = swapu32(*w); + *(w++) = temp; + } + #endif + + t = 48; + while (t--) + { + register uint32 temp = sig1(w[-2]) + w[-7] + sig0(w[-15]) + w[-16]; + *(w++) = temp; + } + + w = p->data; + + a = p->h[0]; b = p->h[1]; c = p->h[2]; d = p->h[3]; + e = p->h[4]; f = p->h[5]; g = p->h[6]; h = p->h[7]; + + ROUND(a,b,c,d,e,f,g,h,w[ 0],k[ 0]); + ROUND(h,a,b,c,d,e,f,g,w[ 1],k[ 1]); + ROUND(g,h,a,b,c,d,e,f,w[ 2],k[ 2]); + ROUND(f,g,h,a,b,c,d,e,w[ 3],k[ 3]); + ROUND(e,f,g,h,a,b,c,d,w[ 4],k[ 4]); + ROUND(d,e,f,g,h,a,b,c,w[ 5],k[ 5]); + ROUND(c,d,e,f,g,h,a,b,w[ 6],k[ 6]); + ROUND(b,c,d,e,f,g,h,a,w[ 7],k[ 7]); + ROUND(a,b,c,d,e,f,g,h,w[ 8],k[ 8]); + ROUND(h,a,b,c,d,e,f,g,w[ 9],k[ 9]); + ROUND(g,h,a,b,c,d,e,f,w[10],k[10]); + ROUND(f,g,h,a,b,c,d,e,w[11],k[11]); + ROUND(e,f,g,h,a,b,c,d,w[12],k[12]); + ROUND(d,e,f,g,h,a,b,c,w[13],k[13]); + ROUND(c,d,e,f,g,h,a,b,w[14],k[14]); + ROUND(b,c,d,e,f,g,h,a,w[15],k[15]); + ROUND(a,b,c,d,e,f,g,h,w[16],k[16]); + ROUND(h,a,b,c,d,e,f,g,w[17],k[17]); + ROUND(g,h,a,b,c,d,e,f,w[18],k[18]); + ROUND(f,g,h,a,b,c,d,e,w[19],k[19]); + ROUND(e,f,g,h,a,b,c,d,w[20],k[20]); + ROUND(d,e,f,g,h,a,b,c,w[21],k[21]); + ROUND(c,d,e,f,g,h,a,b,w[22],k[22]); + ROUND(b,c,d,e,f,g,h,a,w[23],k[23]); + ROUND(a,b,c,d,e,f,g,h,w[24],k[24]); + ROUND(h,a,b,c,d,e,f,g,w[25],k[25]); + ROUND(g,h,a,b,c,d,e,f,w[26],k[26]); + ROUND(f,g,h,a,b,c,d,e,w[27],k[27]); + ROUND(e,f,g,h,a,b,c,d,w[28],k[28]); + ROUND(d,e,f,g,h,a,b,c,w[29],k[29]); + ROUND(c,d,e,f,g,h,a,b,w[30],k[30]); + ROUND(b,c,d,e,f,g,h,a,w[31],k[31]); + ROUND(a,b,c,d,e,f,g,h,w[32],k[32]); + ROUND(h,a,b,c,d,e,f,g,w[33],k[33]); + ROUND(g,h,a,b,c,d,e,f,w[34],k[34]); + ROUND(f,g,h,a,b,c,d,e,w[35],k[35]); + ROUND(e,f,g,h,a,b,c,d,w[36],k[36]); + ROUND(d,e,f,g,h,a,b,c,w[37],k[37]); + ROUND(c,d,e,f,g,h,a,b,w[38],k[38]); + ROUND(b,c,d,e,f,g,h,a,w[39],k[39]); + ROUND(a,b,c,d,e,f,g,h,w[40],k[40]); + ROUND(h,a,b,c,d,e,f,g,w[41],k[41]); + ROUND(g,h,a,b,c,d,e,f,w[42],k[42]); + ROUND(f,g,h,a,b,c,d,e,w[43],k[43]); + ROUND(e,f,g,h,a,b,c,d,w[44],k[44]); + ROUND(d,e,f,g,h,a,b,c,w[45],k[45]); + ROUND(c,d,e,f,g,h,a,b,w[46],k[46]); + ROUND(b,c,d,e,f,g,h,a,w[47],k[47]); + ROUND(a,b,c,d,e,f,g,h,w[48],k[48]); + ROUND(h,a,b,c,d,e,f,g,w[49],k[49]); + ROUND(g,h,a,b,c,d,e,f,w[50],k[50]); + ROUND(f,g,h,a,b,c,d,e,w[51],k[51]); + ROUND(e,f,g,h,a,b,c,d,w[52],k[52]); + ROUND(d,e,f,g,h,a,b,c,w[53],k[53]); + ROUND(c,d,e,f,g,h,a,b,w[54],k[54]); + ROUND(b,c,d,e,f,g,h,a,w[55],k[55]); + ROUND(a,b,c,d,e,f,g,h,w[56],k[56]); + ROUND(h,a,b,c,d,e,f,g,w[57],k[57]); + ROUND(g,h,a,b,c,d,e,f,w[58],k[58]); + ROUND(f,g,h,a,b,c,d,e,w[59],k[59]); + ROUND(e,f,g,h,a,b,c,d,w[60],k[60]); + ROUND(d,e,f,g,h,a,b,c,w[61],k[61]); + ROUND(c,d,e,f,g,h,a,b,w[62],k[62]); + ROUND(b,c,d,e,f,g,h,a,w[63],k[63]); + + p->h[0] += a; + p->h[1] += b; + p->h[2] += c; + p->h[3] += d; + p->h[4] += e; + p->h[5] += f; + p->h[6] += g; + p->h[7] += h; +} +#endif + +int sha256Update(register sha256Param *p, const byte *data, int size) +{ + register int proclength; + + p->length += size; + while (size > 0) + { + proclength = ((p->offset + size) > 64) ? (64 - p->offset) : size; + memcpy(((byte *) p->data) + p->offset, data, proclength); + size -= proclength; + data += proclength; + p->offset += proclength; + + if (p->offset == 64) + { + sha256Process(p); + p->offset = 0; + } + } + return 0; +} + +static void sha256Finish(register sha256Param *p) +{ + register byte *ptr = ((byte *) p->data) + p->offset++; + + *(ptr++) = 0x80; + + if (p->offset > 56) + { + while (p->offset++ < 64) + *(ptr++) = 0; + + sha256Process(p); + p->offset = 0; + } + + ptr = ((byte *) p->data) + p->offset; + while (p->offset++ < 56) + *(ptr++) = 0; + + #if WORDS_BIGENDIAN + p->data[14] = ((uint32)(p->length >> 29)); + p->data[15] = ((uint32)((p->length << 3) & 0xffffffff)); + #else + p->data[14] = swapu32((uint32)(p->length >> 29)); + p->data[15] = swapu32((uint32)((p->length << 3) & 0xffffffff)); + #endif + + sha256Process(p); + p->offset = 0; +} + +int sha256Digest(register sha256Param *p, uint32 *data) +{ + sha256Finish(p); + mp32copy(8, data, p->h); + sha256Reset(p); + return 0; +} diff --git a/beecrypt/sha256.h b/beecrypt/sha256.h new file mode 100644 index 0000000..5b1672d --- /dev/null +++ b/beecrypt/sha256.h @@ -0,0 +1,58 @@ +/* + * sha256.h + * + * SHA-256 hash function, header + * + * Copyright (c) 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 _SHA256_H +#define _SHA256_H + +#include "beecrypt.h" + +typedef struct +{ + uint32 h[8]; + uint32 data[64]; + uint64 length; + uint8 offset; +} sha256Param; + +#ifdef __cplusplus +extern "C" { +#endif + +extern BEEDLLAPI const hashFunction sha256; + +BEEDLLAPI +void sha256Process(sha256Param*); +BEEDLLAPI +int sha256Reset (sha256Param*); +BEEDLLAPI +int sha256Update (sha256Param*, const byte*, int); +BEEDLLAPI +int sha256Digest (sha256Param*, uint32*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/stamp-h.in b/beecrypt/stamp-h.in new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/beecrypt/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/beecrypt/tests/Makefile.am b/beecrypt/tests/Makefile.am new file mode 100644 index 0000000..b374221 --- /dev/null +++ b/beecrypt/tests/Makefile.am @@ -0,0 +1,30 @@ +# +# Makefile.am's purpose is to build the beetest test program. +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + +AUTOMAKE_OPTIONS = gnu no-dependencies + +INCLUDES = -I$(top_srcdir) +LDADD = $(top_builddir)/libbeecrypt.la + +EXTRA_PROGRAMS = beetest + +beetest_SOURCES = beetest.c diff --git a/beecrypt/tests/Makefile.in b/beecrypt/tests/Makefile.in new file mode 100644 index 0000000..61bff83 --- /dev/null +++ b/beecrypt/tests/Makefile.in @@ -0,0 +1,308 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# +# Makefile.am's purpose is to build the beetest test program. +# +# Copyright (c) 2001 Virtual Unlimited B.V. +# +# Author: 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 +# + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +AS = @AS@ +CC = @CC@ +CPP = @CPP@ +DLLTOOL = @DLLTOOL@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +ac_cv_have_java = @ac_cv_have_java@ +ac_cv_have_javac = @ac_cv_have_javac@ + +AUTOMAKE_OPTIONS = gnu no-dependencies + +INCLUDES = -I$(top_srcdir) +LDADD = $(top_builddir)/libbeecrypt.la + +EXTRA_PROGRAMS = beetest + +beetest_SOURCES = beetest.c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.gnu.h +CONFIG_CLEAN_FILES = + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +beetest_OBJECTS = beetest.o +beetest_LDADD = $(LDADD) +beetest_DEPENDENCIES = $(top_builddir)/libbeecrypt.la +beetest_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +SOURCES = $(beetest_SOURCES) +OBJECTS = $(beetest_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +.c.o: + $(COMPILE) -c $< + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +beetest: $(beetest_OBJECTS) $(beetest_DEPENDENCIES) + @rm -f beetest + $(LINK) $(beetest_LDFLAGS) $(beetest_OBJECTS) $(beetest_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = tests + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-compile mostlyclean-libtool \ + mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-compile clean-libtool clean-tags clean-generic \ + mostlyclean-am + +clean: clean-am + +distclean-am: distclean-compile distclean-libtool distclean-tags \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# 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. +.NOEXPORT: diff --git a/beecrypt/tests/beetest.c b/beecrypt/tests/beetest.c new file mode 100644 index 0000000..a443ece --- /dev/null +++ b/beecrypt/tests/beetest.c @@ -0,0 +1,813 @@ +/* + * beetest.c + * + * BeeCrypt test and benchmark application + * + * Copyright (c) 1999, 2000, 2001 Virtual Unlimited B.V. + * + * Author: 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 "beecrypt.h" +#include "blockmode.h" +#include "blowfish.h" +#include "mp32barrett.h" +#include "dhaes.h" +#include "dlkp.h" +#include "elgamal.h" +#include "fips180.h" +#include "hmacmd5.h" +#include "md5.h" +#include "rsa.h" +#include "sha256.h" + +#if HAVE_STDLIB_H +# include +#endif +#if HAVE_STRING_H +# include +#endif +#if HAVE_ERRNO_H +# include +#endif +#if HAVE_TIME_H +# include +#endif + +#include + +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* elg_n = "8df2a494492276aa3d25759bb06869cbeac0d83afb8d0cf7cbb8324f0d7882e5d0762fc5b7210eafc2e9adac32ab7aac49693dfbf83724c2ec0736ee31c80290"; + +int testVectorInvMod(const dlkp_p* keypair) +{ + randomGeneratorContext rngc; + + if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0) + { + register int rc; + + register uint32 size = keypair->param.p.size; + register uint32* temp = (uint32*) malloc((8*size+6) * sizeof(uint32)); + + mp32brndinv_w(&keypair->param.n, &rngc, temp, temp+size, temp+2*size); + + mp32bmulmod_w(&keypair->param.n, size, temp, size, temp+size, temp, temp+2*size); + + rc = mp32isone(size, temp); + + free(temp); + + randomGeneratorContextFree(&rngc); + + return rc; + } + return -1; +} + +int testVectorExpMod(const dlkp_p* keypair) +{ + int rc; + mp32number y; + + mp32nzero(&y); + + mp32bnpowmod(&keypair->param.p, &keypair->param.g, &keypair->x, &y); + + rc = mp32eqx(y.size, y.data, keypair->y.size, keypair->y.data); + + mp32nfree(&y); + + return rc; +} + +int testVectorElGamalV1(const dlkp_p* keypair) +{ + int rc = 0; + + randomGeneratorContext rngc; + + if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0) + { + mp32number digest, r, s; + + mp32nzero(&digest); + mp32nzero(&r); + mp32nzero(&s); + + mp32nsize(&digest, 5); + + rngc.rng->next(rngc.param, digest.data, digest.size); + + elgv1sign(&keypair->param.p, &keypair->param.n, &keypair->param.g, &rngc, &digest, &keypair->x, &r, &s); + + rc = elgv1vrfy(&keypair->param.p, &keypair->param.n, &keypair->param.g, &digest, &keypair->y, &r, &s); + + mp32nfree(&digest); + mp32nfree(&r); + mp32nfree(&s); + + randomGeneratorContextFree(&rngc); + } + return rc; +} + +int testVectorElGamalV3(const dlkp_p* keypair) +{ + int rc = 0; + + randomGeneratorContext rngc; + + if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0) + { + mp32number digest, r, s; + + mp32nzero(&digest); + mp32nzero(&r); + mp32nzero(&s); + + mp32nsize(&digest, 5); + + rngc.rng->next(rngc.param, digest.data, digest.size); + + elgv3sign(&keypair->param.p, &keypair->param.n, &keypair->param.g, &rngc, &digest, &keypair->x, &r, &s); + + rc = elgv3vrfy(&keypair->param.p, &keypair->param.n, &keypair->param.g, &digest, &keypair->y, &r, &s); + + mp32nfree(&digest); + mp32nfree(&r); + mp32nfree(&s); + + randomGeneratorContextFree(&rngc); + } + return rc; +} + +#if 0 +int testVectorDHAES(const dlkp_p* keypair) +{ + /* try encrypting and decrypting a randomly generated message */ + + int rc = 0; + + dhaes_p dh; + + /* incomplete */ + if (dhaes_pInit(&dh, &keypair->param) == 0) + { + mp32number mkey, mac; + + memchunk src, *dst, *cmp; + + /* make a random message of 2K size */ + src.size = 2048; + src.data = (byte*) malloc(src.size); + memset(src.data, 1, src.size); + + /* initialize the message key and mac */ + mp32nzero(&mkey); + mp32nzero(&mac); + + /* encrypt the message */ + dst = dhaes_pEncrypt(&dh, &keypair->y, &mkey, &mac, &src); + /* decrypt the message */ + cmp = dhaes_pDecrypt(&dh, &keypair->x, &mkey, &mac, dst); + + if (cmp != (memchunk*) 0) + { + if (src.size == cmp->size) + { + if (memcmp(src.data, cmp->data, src.size) == 0) + rc = 1; + } + + free(cmp->data); + free(cmp); + } + + free(dst->data); + free(dst); + free(src.data); + + dhaes_pFree(&dh); + + return rc; + } + + return -1; +} +#endif + +int testVectorRSA() +{ + int rc = 0; + + randomGeneratorContext rngc; + + if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0) + { + rsakp kp; + mp32number digest, s; + + rsakpInit(&kp); + printf("making RSA CRT keypair\n"); + rsakpMake(&kp, &rngc, 32); + printf("RSA CRT keypair generated\n"); + + mp32nzero(&digest); + mp32nzero(&s); + + mp32bnrnd(&kp.n, &rngc, &digest); + + rsapri(&kp, &digest, &s); + + rc = rsavrfy((rsapk*) &kp, &digest, &s); + + mp32nfree(&digest); + mp32nfree(&s); + + rsakpFree(&kp); + + randomGeneratorContextFree(&rngc); + + return rc; + } + return -1; +} + +int testVectorDLDP() +{ + /* try generating dldp_p parameters, then see if the order of the generator is okay */ + randomGeneratorContext rc; + dldp_p dp; + + memset(&dp, 0, sizeof(dldp_p)); + + if (randomGeneratorContextInit(&rc, randomGeneratorDefault()) == 0) + { + register int result; + mp32number gq; + + mp32nzero(&gq); + + dldp_pgoqMake(&dp, &rc, 768 >> 5, 512 >> 5, 1); + + /* we have the parameters, now see if g^q == 1 */ + mp32bnpowmod(&dp.p, &dp.g, (mp32number*) &dp.q, &gq); + result = mp32isone(gq.size, gq.data); + + mp32nfree(&gq); + dldp_pFree(&dp); + + randomGeneratorContextFree(&rc); + + return result; + } + return 0; +} + +int testVectorMD5() +{ + uint32 expect[4] = { 0x90015098, 0x3cd24fb0, 0xd6963f7d, 0x28e17f72 }; + uint32 digest[4]; + md5Param param; + + md5Reset(¶m); + md5Update(¶m, (const unsigned char*) "abc", 3); + md5Digest(¶m, digest); + + return mp32eq(4, expect, digest); +} + +int testVectorSHA1() +{ + uint32 expect[5] = { 0xA9993E36, 0x4706816A, 0xBA3E2571, 0x7850C26C, 0x9CD0D89D }; + uint32 digest[5]; + sha1Param param; + + sha1Reset(¶m); + sha1Update(¶m, (const unsigned char*) "abc", 3); + sha1Digest(¶m, digest); + + return mp32eq(5, expect, digest); +} + +int testVectorSHA256() +{ + uint32 expect[8] = { 0xba7816bf, 0x8f01cfea, 0x414140de, 0x5dae2223, 0xb00361a3, 0x96177a9c, 0xb410ff61, 0xf20015ad }; + uint32 digest[8]; + sha256Param param; + + sha256Reset(¶m); + sha256Update(¶m, (const unsigned char*) "abc", 3); + sha256Digest(¶m, digest); + + return mp32eq(8, expect, digest); +} + +uint32 keyValue[] = +{ + 0x00010203, + 0x04050607, + 0x08090a0b, + 0x0c0d0e0f, + 0x10111213, + 0x14151617, + 0x18191a1b, + 0x1c1d1e1f, + 0x20212223, + 0x24252627, + 0x28292a2b, + 0x2c2d2e2f, + 0x30313233, + 0x34353637, + 0x38393a3b, + 0x3c3d3e3f +}; + +void testBlockInit(uint8* block, int length) +{ + register int i; + for (i = 1; i <= length; i++) + *(block++) = (uint8) i; +} + +void testBlockCiphers() +{ + int i, k; + + printf(" Testing the blockciphers:\n"); + + for (i = 0; i < blockCipherCount(); i++) + { + const blockCipher* tmp = blockCipherGet(i); + + if (tmp) + { + uint32 blockwords = tmp->blocksize >> 2; + + uint32* src_block = (uint32*) malloc(2 * blockwords * sizeof(uint32)); + uint32* enc_block = (uint32*) malloc(2 * blockwords * sizeof(uint32)); + uint32* dec_block = (uint32*) malloc(2 * blockwords * sizeof(uint32)); + uint32* spd_block = (uint32*) malloc(1024 * 1024 * blockwords * sizeof(uint32)); + + void* encrypt_param = (void*) malloc(tmp->paramsize); + void* decrypt_param = (void*) malloc(tmp->paramsize); + + printf(" %s:\n", tmp->name); + + for (k = tmp->keybitsmin; k <= tmp->keybitsmax; k += tmp->keybitsinc) + { + printf(" setup encrypt (%d bits key): ", k); + if (tmp->setup(encrypt_param, keyValue, k, ENCRYPT) < 0) + { + printf("failed\n"); + continue; + } + printf("ok\n"); + printf(" setup decrypt (%d bits key): ", k); + if (tmp->setup(decrypt_param, keyValue, k, DECRYPT) < 0) + { + printf("failed\n"); + continue; + } + printf("ok\n"); + printf(" encrypt/decrypt test block: "); + testBlockInit((uint8*) src_block, tmp->blocksize >> 2); + + blockEncrypt(tmp, encrypt_param, CBC, 2, enc_block, src_block); + blockDecrypt(tmp, decrypt_param, CBC, 2, dec_block, enc_block); + + if (memcmp(dec_block, src_block, tmp->blocksize >> 2)) + { + printf("failed\n"); + continue; + } + printf("ok\n"); + printf(" speed measurement:\n"); + { + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + + #if HAVE_TIME_H + tstart = clock(); + #endif + blockEncrypt(tmp, encrypt_param, ECB, 1024 * 1024, spd_block, spd_block); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" ECB encrypts 1M blocks of %d bits in %.3f seconds (%.3f MB/s)\n", tmp->blocksize << 3, ttime, (tmp->blocksize) / ttime); + #endif + #if HAVE_TIME_H + tstart = clock(); + #endif + blockDecrypt(tmp, decrypt_param, ECB, 1024 * 1024, spd_block, spd_block); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" ECB decrypts 1M blocks of %d bits in %.3f seconds (%.3f MB/s)\n", tmp->blocksize << 3, ttime, (tmp->blocksize) / ttime); + #endif + #if HAVE_TIME_H + tstart = clock(); + #endif + blockEncrypt(tmp, encrypt_param, CBC, 1024 * 1024, spd_block, spd_block); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" CBC encrypts 1M blocks of %d bits in %.3f seconds (%.3f MB/s)\n", tmp->blocksize << 3, ttime, (tmp->blocksize) / ttime); + #endif + #if HAVE_TIME_H + tstart = clock(); + #endif + blockDecrypt(tmp, decrypt_param, CBC, 1024 * 1024, spd_block, spd_block); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" CBC decrypts 1M blocks of %d bits in %.3f seconds (%.3f MB/s)\n", tmp->blocksize << 3, ttime, (tmp->blocksize) / ttime); + #endif + } + } + free(spd_block); + free(dec_block); + free(enc_block); + free(src_block); + free(decrypt_param); + free(encrypt_param); + } + } +} + +void testHashFunctions() +{ + int i, j; + + uint8* data = (uint8*) malloc(32 * 1024 * 1024); + + if (data) + { + hashFunctionContext hfc; + + printf(" Testing the hash functions:\n"); + + for (i = 0; i < hashFunctionCount(); i++) + { + const hashFunction* tmp = hashFunctionGet(i); + + if (tmp) + { + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + mp32number digest; + + mp32nzero(&digest); + + printf(" %s:\n", tmp->name); + + if (hashFunctionContextInit(&hfc, tmp) == 0) + { + for (j = 0; j < 4; j++) + { + #if HAVE_TIME_H + tstart = clock(); + #endif + + hashFunctionContextUpdate(&hfc, data, 32 * 1024 * 1024); + hashFunctionContextDigest(&hfc, &digest); + + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" hashes 32 MB in %.3f seconds (%.3f MB/s)\n", ttime, 32.0 / ttime); + #endif + } + + hashFunctionContextFree(&hfc); + } + + mp32nfree(&digest); + } + } + } +} + +void testExpMods() +{ + static const char* p_512 = "ffcf0a0767f18f9b659d92b9550351430737c3633dc6ae7d52445d937d8336e07a7ccdb119e9ab3e011a8f938151230e91187f84ac05c3220f335193fc5e351b"; + + static const char* p_768 = "f9c3dc0b8e199094e3e69386e01de863908348196d6ad2557065e6ba36d10412579f394d1114c954ee647c84551d52f214e1e1682a75e7074b91085cfaf20b2888aa056bf760948a0b678bc253633eccfca86556ddb90f000ef93041b0d53171"; + + static const char* p_1024 = "c615c47a56b47d869010256171ab164525f2ef4b887a4e0cdfc87043a9dd8894f2a18fa56729448e700f4b7420470b61257d11ecefa9ff518dc9fed5537ec6a9665ba73c948674320ff61b29c4cfa61e5baf47dfc1b80939e1bffb51787cc3252c4d1190a7f13d1b0f8d4aa986571ce5d4de5ecede1405e9bc0b5bf040a46d99"; + + randomGeneratorContext rngc; + + mp32barrett p; + mp32number tmp; + mp32number g; + mp32number x; + mp32number y; + + mp32bzero(&p); + mp32nzero(&g); + mp32nzero(&x); + mp32nzero(&y); + mp32nzero(&tmp); + + if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0) + { + int i; + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + + printf("Timing modular exponentiations\n"); + printf(" (512 bits ^ 512 bits) mod 512 bits:"); + mp32nsethex(&tmp, p_512); + mp32bset(&p, tmp.size, tmp.data); + mp32nsize(&g, p.size); + mp32nsize(&x, p.size); + mp32bnrnd(&p, &rngc, &g); + mp32bnrnd(&p, &rngc, &x); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x, &y); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" 100x in %.3f seconds\n", ttime); + #endif + printf(" (768 bits ^ 768 bits) mod 768 bits:"); + mp32nsethex(&tmp, p_768); + mp32bset(&p, tmp.size, tmp.data); + mp32nsize(&g, p.size); + mp32nsize(&x, p.size); + mp32bnrnd(&p, &rngc, &g); + mp32bnrnd(&p, &rngc, &x); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x, &y); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" 100x in %.3f seconds\n", ttime); + #endif + printf(" (1024 bits ^ 1024 bits) mod 1024 bits:"); + mp32nsethex(&tmp, p_1024); + mp32bset(&p, tmp.size, tmp.data); + mp32nsize(&g, p.size); + mp32nsize(&x, p.size); + mp32bnrnd(&p, &rngc, &g); + mp32bnrnd(&p, &rngc, &x); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x, &y); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" 100x in %.3f seconds\n", ttime); + #endif + /* now run a test with x having 160 bits */ + mp32nsize(&x, 5); + rngc.rng->next(rngc.param, x.data, x.size); + printf(" (1024 bits ^ 160 bits) mod 1024 bits:"); + #if HAVE_TIME_H + tstart = clock(); + #endif + for (i = 0; i < 100; i++) + mp32bnpowmod(&p, &g, &x, &y); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" 100x in %.3f seconds\n", ttime); + #endif + mp32bfree(&p); + mp32nfree(&g); + mp32nfree(&x); + mp32nfree(&y); + mp32nfree(&tmp); + + randomGeneratorContextFree(&rngc); + } + else + printf("random generator setup problem\n"); +} + +void testDLParams() +{ + randomGeneratorContext rc; + dldp_p dp; + + memset(&dp, 0, sizeof(dldp_p)); + + if (randomGeneratorContextInit(&rc, randomGeneratorDefault()) == 0) + { + #if HAVE_TIME_H + double ttime; + clock_t tstart, tstop; + #endif + printf("Generating P (768 bits) Q (512 bits) G with order Q\n"); + #if HAVE_TIME_H + tstart = clock(); + #endif + dldp_pgoqMake(&dp, &rc, 768 >> 5, 512 >> 5, 1); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" done in %.3f seconds\n", ttime); + #endif + printf("P = "); fflush(stdout); mp32println(dp.p.size, dp.p.modl); + printf("Q = "); fflush(stdout); mp32println(dp.q.size, dp.q.modl); + printf("G = "); fflush(stdout); mp32println(dp.g.size, dp.g.data); + dldp_pFree(&dp); + + printf("Generating P (768 bits) Q (512 bits) G with order (P-1)\n"); + #if HAVE_TIME_H + tstart = clock(); + #endif + dldp_pgonMake(&dp, &rc, 768 >> 5, 512 >> 5); + #if HAVE_TIME_H + tstop = clock(); + ttime = ((double)(tstop - tstart)) / CLOCKS_PER_SEC; + printf(" done in %.3f seconds\n", ttime); + #endif + printf("P = "); fflush(stdout); mp32println(dp.p.size, dp.p.modl); + printf("Q = "); fflush(stdout); mp32println(dp.q.size, dp.q.modl); + printf("G = "); fflush(stdout); mp32println(dp.g.size, dp.g.data); + printf("N = "); fflush(stdout); mp32println(dp.n.size, dp.n.modl); + dldp_pFree(&dp); + + randomGeneratorContextFree(&rc); + } +} + +#if 0 +int main() +{ + dlkp_p keypair; + + if (testVectorMD5()) + printf("MD5 works!\n"); + else + exit(1); + + if (testVectorSHA1()) + printf("SHA-1 works!\n"); + else + exit(1); + + if (testVectorSHA256()) + printf("SHA-256 works!\n"); + else + exit(1); + + dlkp_pInit(&keypair); + + mp32bsethex(&keypair.param.p, dsa_p); + mp32bsethex(&keypair.param.q, dsa_q); + mp32nsethex(&keypair.param.g, dsa_g); + mp32bsethex(&keypair.param.n, elg_n); + mp32nsethex(&keypair.y, dsa_y); + mp32nsethex(&keypair.x, dsa_x); + + if (testVectorInvMod(&keypair)) + printf("InvMod works!\n"); + else + exit(1); + + if (testVectorExpMod(&keypair)) + printf("ExpMod works!\n"); + else + exit(1); + + if (testVectorElGamalV1(&keypair)) + printf("ElGamal v1 works!\n"); + else + exit(1); + + if (testVectorElGamalV3(&keypair)) + printf("ElGamal v3 works!\n"); + else + exit(1); + +/* + if (testVectorDHAES(&keypair)) + printf("DHAES works!\n"); + else + exit(1); +*/ + + dlkp_pFree(&keypair); + + if (testVectorRSA()) + printf("RSA works!\n"); + else + exit(1); +/* + if (testVectorDLDP()) + printf("dldp with generator of order q works!\n"); + else + exit(1); +*/ + + return 0; +} +#else +int main() +{ + int i, j; + + printf("the beecrypt library implements:\n"); + printf(" %d entropy source%s:\n", entropySourceCount(), entropySourceCount() == 1 ? "" : "s"); + for (i = 0; i < entropySourceCount(); i++) + { + const entropySource* tmp = entropySourceGet(i); + if (tmp) + printf(" %s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf(" %d random generator%s:\n", randomGeneratorCount(), randomGeneratorCount() == 1 ? "" : "s"); + for (i = 0; i < randomGeneratorCount(); i++) + { + const randomGenerator* tmp = randomGeneratorGet(i); + if (tmp) + printf(" %s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf(" %d hash function%s:\n", hashFunctionCount(), hashFunctionCount() == 1 ? "" : "s"); + for (i = 0; i < hashFunctionCount(); i++) + { + const hashFunction* tmp = hashFunctionGet(i); + if (tmp) + printf(" %s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf(" %d keyed hash function%s:\n", keyedHashFunctionCount(), keyedHashFunctionCount() == 1 ? "" : "s"); + for (i = 0; i < keyedHashFunctionCount(); i++) + { + const keyedHashFunction* tmp = keyedHashFunctionGet(i); + if (tmp) + printf(" %s\n", tmp->name); + else + printf("*** error: library corrupt\n"); + } + printf(" %d blockcipher%s:\n", blockCipherCount(), blockCipherCount() == 1 ? "" : "s"); + for (i = 0; i < blockCipherCount(); i++) + { + const blockCipher* tmp = blockCipherGet(i); + if (tmp) + { + printf(" %s ", tmp->name); + for (j = tmp->keybitsmin; j <= tmp->keybitsmax; j += tmp->keybitsinc) + { + printf("%d", j); + if (j < tmp->keybitsmax) + printf("/"); + else + printf(" bit keys\n"); + } + } + else + printf("*** error: library corrupt\n"); + } + testBlockCiphers(); + testHashFunctions(); + testExpMods(); + testDLParams(); + + printf("done\n"); + + return 0; +} +#endif diff --git a/beecrypt/timestamp.c b/beecrypt/timestamp.c new file mode 100644 index 0000000..86462f2 --- /dev/null +++ b/beecrypt/timestamp.c @@ -0,0 +1,50 @@ +/* + * timestamp.c + * + * Java compatible 64-bit timestamp, code + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: Bob Deblier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define BEECRYPT_DLL_EXPORT + +#include "timestamp.h" + +#if HAVE_TIME_H +# include +#endif +#if HAVE_SYS_TIME_H +# include +#endif + +javalong timestamp() +{ + #if HAVE_SYS_TIME_H + # if HAVE_GETTIMEOFDAY + struct timeval now; + gettimeofday(&now, 0); + return (now.tv_sec * 1000LL) + (now.tv_usec / 1000); + # endif + #elif HAVE_TIME_H + return time(0) * 1000LL; + #else + # error implement other time function + #endif +} diff --git a/beecrypt/timestamp.h b/beecrypt/timestamp.h new file mode 100644 index 0000000..efb1d1e --- /dev/null +++ b/beecrypt/timestamp.h @@ -0,0 +1,47 @@ +/* + * timestamp.h + * + * Java-compatible 64 bit timestamp, header + * + * Copyright (c) 1999-2000 Virtual Unlimited B.V. + * + * Author: 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 _TIMESTAMP_H +#define _TIMESTAMP_H + +#include "beecrypt.h" + +#define ONE_SECOND 1000LL +#define ONE_MINUTE 60000LL +#define ONE_HOUR 3600000LL +#define ONE_DAY 86400000LL + +#ifdef __cplusplus +extern "C" { +#endif + +BEEDLLAPI +javalong timestamp(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/beecrypt/win32/beecrypt.def b/beecrypt/win32/beecrypt.def new file mode 100644 index 0000000..965017f --- /dev/null +++ b/beecrypt/win32/beecrypt.def @@ -0,0 +1,259 @@ +; +; beecrypt.def +; +; BeeCrypt DLL exports +; +; Copyright (c) 2000 Virtual Unlimited B.V. +; +; Author: 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 +; + +LIBRARY beecrypt + +EXPORTS + DllMain + b64enc + b64dec + blockCipherContextFree + blockCipherContextInit + blockCipherCount + blockCipherDefault + blockCipherFind + blockCipherGet + blockEncrypt + blockDecrypt + blowfish data + blowfishCBCEncrypt + blowfishCBCDecrypt + blowfishDecrypt + blowfishECBEncrypt + blowfishECBDecrypt + blowfishEncrypt + blowfishSetup + decodeByte + decodeChar + decodeChars + decodeDouble + decodeFloat + decodeInt + decodeInts + decodeLong + decodeShort + dldp_pCopy + dldp_pEqual + dldp_pFree + dldp_pInit + dldp_pPair + dldp_pPrivate + dldp_pPublic + dldp_pgonGenerator + dldp_pgonMake + dldp_pgonMakeSafe + dldp_pgonValidate + dldp_pgoqGenerator + dldp_pgoqMake + dldp_pgoqMakeSafe + dldp_pgoqValidate + dlkp_pCopy + dlkp_pFree + dlkp_pPair + dlpk_pCopy + dlpk_pEqual + dlpk_pFree + dlpk_pgoqValidate + dlpk_pgonValidate + dlsvdp_pDHSecret + ;elgv1sign + ;elgv1vrfy + elgv3sign + elgv3vrfy + encodeByte + encodeChar + encodeChars + encodeDouble + encodeFloat + encodeInt + encodeInts + encodeLong + encodeShort + entropySourceCount + entropySourceDefault + entropySourceFind + entropySourceGet + fips186Cleanup + fips186Next + fips186Seed + fips186Setup + fips186prng data + hashFunctionContextFree + hashFunctionContextInit + hashFunctionCount + hashFunctionDefault + hashFunctionFind + hashFunctionGet + hmacDigest + hmacReset + hmacSetup + hmacUpdate + keyedHashFunctionContextFree + keyedHashFunctionContextInit + keyedHashFunctionCount + keyedHashFunctionDefault + keyedHashFunctionFind + keyedHashFunctionGet + ;mp32copy + ;mp32move + mp32zero + mp32fill + mp32odd + mp32even + mp32z + mp32nz + mp32eq + mp32ne + mp32gt + mp32lt + mp32ge + mp32le + mp32eqx + mp32nex + mp32gtx + mp32ltx + mp32gex + mp32lex + mp32isone + mp32leone + mp32eqmone + mp32msbset + mp32lsbset + mp32setmsb + mp32setlsb + mp32clrmsb + mp32clrlsb + mp32xor + mp32not + mp32setw + mp32setx + mp32addw + mp32add + mp32addx + mp32subw + mp32sub + mp32subx + mp32multwo + mp32neg + mp32size + mp32mszcnt + mp32lszcnt + mp32lshift + mp32rshift + mp32norm + mp32divpowtwo + mp32divtwo + mp32sdivtwo + mp32setmul + mp32addmul + mp32addsqrtrc + mp32mul + mp32sqr + mp32gcd + mp32nmodw + mp32nmod + mp32ndivmod + mp32print + mp32println + mp32bzero + mp32binit + mp32bfree + mp32bset + mp32bmu + mp32brnd + mp32brndres + mp32bmodsubone + mp32bneg + mp32bmod + mp32baddmod + ;mp32bsubmod + mp32bmulmodres + mp32bsqrmodres + mp32bmulmod + mp32bsqrmod + mp32bpowmod + mp32btwopowmod + ;mp32bsm2powmod + ;mp32bsm3powmod + mp32binv + mp32bpprime + mp32bnmulmodres + mp32bnsqrmodres + mp32bnpowmod + mp32bnsqrmod + mp32ptrials + mp32pmilrab + mp32prnd + mp32prndsafe + ;mp32prndcon + mp32prndconone + mp32nzero + mp32nsize + mp32ninit + mp32nfree + mp32nset + mp32nsetw + mp32nsethex + mtprng data + mtprngCleanup + mtprngNext + mtprngSeed + mtprngSetup + randomGeneratorCount + randomGeneratorGet + randomGeneratorFind + randomGeneratorDefault + randomGeneratorContextInit + randomGeneratorContextFree + readByte + readChar + readChars + readInt + readInts + readLong + readShort + sha1 data + sha1Process + sha1Reset + sha1Update + sha1Digest + sha1hmac data + sha1hmacDigest + sha1hmacReset + sha1hmacSetup + sha1hmacUpdate + swap16 + swap32 + swap64 + swapu16 + swapu32 + ;swapu64 + timestamp + writeByte + writeChar + writeChars + writeInt + writeInts + writeLong + writeShort diff --git a/beecrypt/win32/beecrypt.dll.c b/beecrypt/win32/beecrypt.dll.c new file mode 100644 index 0000000..1090051 --- /dev/null +++ b/beecrypt/win32/beecrypt.dll.c @@ -0,0 +1,43 @@ +/* + * beecrypt.c + * + * BeeCrypt DLL entry point, code + * + * Copyright (c) 2000 Virtual Unlimited B.V. + * + * Author: 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 "beecrypt.h" + +#include + +__declspec(dllexport) +BOOL WINAPI DllMain(HINSTANCE hInst, DWORD wDataSeg, LPVOID lpReserved) +{ + switch (wDataSeg) + { + case DLL_PROCESS_ATTACH: + entropy_provider_setup(hInst); + break; + case DLL_PROCESS_DETACH: + entropy_provider_cleanup(); + break; + } + return TRUE; +} diff --git a/beecrypt/win32/beecrypt.rc b/beecrypt/win32/beecrypt.rc new file mode 100644 index 0000000..5274205 --- /dev/null +++ b/beecrypt/win32/beecrypt.rc @@ -0,0 +1,31 @@ +#include + +1 VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0x0L + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" /* U.S. English; Unicode */ + BEGIN + VALUE "CompanyName", "Virtual Unlimited B.V.\0" + VALUE "FileDescription", "BeeCrypt Cryptography Library\0" + VALUE "FileVersion", "1.0.0\0" + VALUE "InternalName", "beecrypt\0" + VALUE "LegalCopyright", "Copyright (c) 1997-2000 Virtual Unlimited B.V.\0" + VALUE "LegalTradeMarks", "BeeCrypt is a trademark of Virtual Unlimited B.V.\0" + VALUE "OriginalFileName", "BEECRYPT.DLL\0" + VALUE "ProductName", "BeeCrypt\0" + VALUE "ProductVersion", "1.0.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/beecrypt/win32/config.win.h b/beecrypt/win32/config.win.h new file mode 100644 index 0000000..bd6c934 --- /dev/null +++ b/beecrypt/win32/config.win.h @@ -0,0 +1,162 @@ +/* + * config.win.h + * + * Win32 config file + * + * Copyright (c) 2000, Virtual Unlimited B.V. + * + * Author: 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 _CONFIG_WIN_H +#define _CONFIG_WIN_H + +#define _REENTRANT + +#if __INTEL__ +#define WORDS_BIGENDIAN 0 +#else +#error Trying to compile for WIN32 on non-Intel hardware +#endif + +#if __MWERKS__ +#define HAVE_ERRNO_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_FCNTL_H 1 +#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 +#define HAVE_PTHREAD_H 0 +#define HAVE_SYNCH_H 0 + +#define HAVE_TERMIO_H 0 +#define HAVE_SYS_AUDIOIO_H 0 +#define HAVE_SYS_IOCTL_H 0 +#define HAVE_SYS_SOUNDCARD_H 0 + +#define HAVE_GETTIMEOFDAY 0 +#define HAVE_GETHRTIME 0 + +#define HAVE_DEV_TTY 0 +#define HAVE_DEV_AUDIO 0 +#define HAVE_DEV_DSP 0 +#define HAVE_DEV_RANDOM 0 + +#define SIZEOF_CHAR 1 +#define SIZEOF_UNSIGNED_CHAR 1 +#define SIZEOF_SHORT 2 +#define SIZEOF_UNSIGNED_SHORT 2 +#define SIZEOF_INT 4 +#define SIZEOF_UNSIGNED_INT 4 +#define SIZEOF_LONG 4 +#define SIZEOF_UNSIGNED_LONG 4 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +#define SIZEOF_FLOAT 4 +#define SIZEOF_DOUBLE 8 +#else +#error Not set up for this compiler +#endif + +#if (SIZEOF_CHAR == 1) +typedef char int8; +typedef char javabyte; +#else +#error sizeof(char) not 1 +#endif + +#if (SIZEOF_SHORT == 2) +typedef short int16; +typedef short javashort; +#else +#error sizeof(short) is not 2 +#endif + +#if (SIZEOF_INT == 4) +typedef int int32; +typedef int javaint; +#elif (SIZEOF_LONG == 4) +typedef int int32; +typedef long javaint; +#else +#error compiler has no 32 bit integer +#endif + +#if (SIZEOF_LONG == 8) +typedef long int64; +typedef long javalong; +#elif (SIZEOF_LONG_LONG == 8) +typedef long long int64; +typedef long long javalong; +#else +#error compiler has no 64 bit integer +#endif + +#if (SIZEOF_FLOAT == 4) +typedef float javafloat; +#else +#error compiler has no 32 bit float +#endif + +#if (SIZEOF_DOUBLE == 8) +typedef double javadouble; +#else +#error compiler has no 64 bit double; +#endif + +#if (SIZEOF_UNSIGNED_CHAR == 1) +typedef unsigned char uint8; +#else +#error sizeof(unsigned char) is not 1 +#endif + +#if (SIZEOF_UNSIGNED_SHORT == 2) +typedef unsigned short uint16; +typedef unsigned short javachar; +typedef unsigned short unicode; +#else +#error sizeof(unsigned short) is not 2 +#endif + +#if (SIZEOF_UNSIGNED_INT == 4) +typedef unsigned int uint32; +#elif (SIZEOF_UNSIGNED_LONG == 4) +typedef unsigned long uint32; +#else +#error compiler has no 32 bit unsigned integer +#endif + +#if (SIZEOF_UNSIGNED_LONG == 8) +typedef unsigned long uint64; +#elif (SIZEOF_UNSIGNED_LONG_LONG == 8) +typedef unsigned long long uint64; +#else +#error compiler has no 64 bit unsigned integer +#endif + +/* typedef uint8 byte */ + +#endif diff --git a/beecrypt/win32/masm/blowfishopt.i586.asm b/beecrypt/win32/masm/blowfishopt.i586.asm new file mode 100644 index 0000000..16cb161 --- /dev/null +++ b/beecrypt/win32/masm/blowfishopt.i586.asm @@ -0,0 +1,180 @@ +; +; blowfishopt.i586.asm +; +; Assembler optimized blowfish routines for Intel Pentium processors +; +; Compile target is Microsoft Macro Assembler +; +; Copyright (c) 2000 Virtual Unlimited B.V. +; +; Author: 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 +; + + .586 + .model flat,C + + .code + +etworounds macro offset + xor ecx,dword ptr [esi+offset] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,ch + mov bl,cl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor edx,edi + xor edx,dword ptr [esi+offset+4] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,dh + mov bl,dl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor ecx,edi + endm + +dtworounds macro offset + xor ecx,dword ptr [esi+offset+4] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,ch + mov bl,cl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor edx,edi + xor edx,dword ptr [esi+offset] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,dword ptr [esi+eax*4+72+0000h] + add edi,dword ptr [esi+ebx*4+72+0400h] + mov al,dh + mov bl,dl + xor edi,dword ptr [esi+eax*4+72+0800h] + add edi,dword ptr [esi+ebx*4+72+0C00h] + xor ecx,edi + endm + + + align 8 + +blowfishEncrypt proc + push edi + push esi + push ebx + + mov esi,dword ptr [esp+16] + mov edi,dword ptr [esp+24] + + xor eax,eax + xor ebx,ebx + + mov ecx,dword ptr [edi] + mov edx,dword ptr [edi+4] + + bswap ecx + bswap edx + + etworounds 0 + etworounds 8 + etworounds 16 + etworounds 24 + etworounds 32 + etworounds 40 + etworounds 48 + etworounds 56 + + mov edi,dword ptr [esp+20] + xor ecx,dword ptr [esi+64] + xor edx,dword ptr [esi+68] + + bswap ecx + bswap edx + + mov dword ptr [edi+4],ecx + mov dword ptr [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret +blowfishEncrypt endp + + + align 8 + +blowfishDecrypt proc + push edi + push esi + push ebx + + mov esi,dword ptr [esp+16] + mov edi,dword ptr [esp+24] + + xor eax,eax + xor ebx,ebx + + mov ecx,dword ptr [edi] + mov edx,dword ptr [edi+4] + + bswap ecx + bswap edx + + dtworounds 64 + dtworounds 56 + dtworounds 48 + dtworounds 40 + dtworounds 32 + dtworounds 24 + dtworounds 16 + dtworounds 8 + + mov edi,dword ptr [esp+20] + xor ecx,dword ptr [esi+4] + xor edx,dword ptr [esi] + + bswap ecx + bswap edx + + mov dword ptr [edi+4],ecx + mov dword ptr [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret +blowfishDecrypt endp + + end diff --git a/beecrypt/win32/masm/fips180opt.i586.asm b/beecrypt/win32/masm/fips180opt.i586.asm new file mode 100644 index 0000000..7c5eada --- /dev/null +++ b/beecrypt/win32/masm/fips180opt.i586.asm @@ -0,0 +1,298 @@ +; +; fips180opt.i586.asm +; +; Assembler optimized SHA-1 routines for Intel Pentium processors +; +; Compile target is Microsoft Macro Assembler +; +; Copyright (c) 2000 Virtual Unlimited B.V. +; +; Author: 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 +; + + .586 + .model flat,C + +K00 equ 5a827999h +K20 equ 6ed9eba1h +K40 equ 8f1bbcdch +K60 equ 0ca62c1d6h + +PARAM_H equ 0 +PARAM_DATA equ 20 +PARAM_OFFSET equ 352 + + .code + +subround1 macro b,c,d,e,w + mov ecx,c + mov ebx,b + mov edx,d + rol eax,5 + xor ecx,edx + add eax,e + and ecx,ebx + add eax,K00 + ror ebx,2 + add eax,w + xor ecx,edx + mov b,ebx + add eax,ecx + mov e,eax + endm + +subround2 macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K20 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + endm + +subround3 macro b,c,d,e,w + mov ecx,c + rol eax,5 + mov ebx,b + mov edx,ecx + add eax,e + or ecx,ebx + and edx,ebx + and ecx,d + add eax,K40 + or ecx,edx + add eax,w + ror ebx,2 + add eax,ecx + mov b,ebx + mov e,eax + endm + +subround4 macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K60 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + endm + + + align 8 + +sha1Process proc + push edi + push esi + push ebx + push ebp + ; allocate local variables + mov esi,dword ptr [esp+20] ; esi now points to param + sub esp,20 ; esp now points below the local variables + lea edi,dword ptr [esi+PARAM_DATA] + mov ebp,esp ; ebp now points to the local variables + + mov ecx,4 +@loads: + mov edx,dword ptr [esi+ecx*4] + mov dword ptr [ebp+ecx*4],edx + dec ecx + jns @loads + + mov ecx,15 + xor eax,eax + + align 4 +@swaps: + mov edx,dword ptr [edi+ecx*4] + bswap edx + mov dword ptr [edi+ecx*4],edx + dec ecx + jns @swaps + + lea edi,dword ptr [esi+PARAM_DATA] + mov byte ptr [esi+PARAM_OFFSET],al + mov ecx,16 + + align 4 +@xors: + mov eax,dword ptr [edi+52] + mov ebx,dword ptr [edi+56] + xor eax,dword ptr [edi+32] + xor ebx,dword ptr [edi+36] + xor eax,dword ptr [edi+ 8] + xor ebx,dword ptr [edi+12] + xor eax,dword ptr [edi ] + xor ebx,dword ptr [edi+ 4] + rol eax,1 + rol ebx,1 + mov dword ptr [edi+64],eax + mov dword ptr [edi+68],ebx + mov eax,dword ptr [edi+60] + mov ebx,dword ptr [edi+64] + xor eax,dword ptr [edi+40] + xor ebx,dword ptr [edi+44] + xor eax,dword ptr [edi+16] + xor ebx,dword ptr [edi+20] + xor eax,dword ptr [edi+ 8] + xor ebx,dword ptr [edi+12] + rol eax,1 + rol ebx,1 + mov dword ptr [edi+72],eax + mov dword ptr [edi+76],ebx + add edi,16 + dec ecx + jnz @xors + + mov edi,PARAM_DATA + + ; to optimize further, use esi only, and store the add constant into edi + ; will make code smaller and faster + +@round01to20: + mov eax,dword ptr [ebp] + subround1 dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + +@round21to40: + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + +@round41to60: + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + +@round61to80: + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + add edi,20 + subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] + subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] + subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] + subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] + subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] + ; add edi,20 + + mov ecx,4 + +@adds: + mov eax,dword ptr [ebp+ecx*4] + add dword ptr [esi+ecx*4],eax + dec ecx + jns @adds + + add esp,20 + pop ebp + pop ebx + pop esi + pop edi + ret +sha1Process endp + + end diff --git a/beecrypt/win32/masm/mp32opt.i386.asm b/beecrypt/win32/masm/mp32opt.i386.asm new file mode 100644 index 0000000..61e3054 --- /dev/null +++ b/beecrypt/win32/masm/mp32opt.i386.asm @@ -0,0 +1,287 @@ +; +; mp32opt.i386.asm +; +; Assembler optimized multiprecision integer routines for Intel 386 +; +; Compile target is Microsoft Macro Assembler +; +; Copyright (c) 1998-2000 Virtual Unlimited B.V. +; +; Author: 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 +; + + .586 + .model flat,C + + .code + + align 8 + +mp32addw proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + mov eax,dword ptr [esp+16] + + lea edi,dword ptr [edi+ecx*4-4] + add dword ptr [edi],eax + dec ecx + jz @addw_end + sub edi,4 + xor edx,edx + + align 4 +@addw_loop: + adc dword ptr [edi],edx + sub edi,4 + dec ecx + jnz @addw_loop +@addw_end: + sbb eax,eax + neg eax + + pop edi + ret +mp32addw endp + + + align 8 + +mp32subw proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + mov eax,dword ptr [esp+16] + + lea edi,dword ptr [edi+ecx*4-4] + sub dword ptr [edi],eax + dec ecx + jz @subw_end + sub edi,4 + xor edx,edx + + align 4 +@subw_loop: + sbb dword ptr [edi],edx + sub edi,4 + dec ecx + jnz @subw_loop +@subw_end: + sbb eax,eax + neg eax + + pop edi + ret +mp32subw endp + + + align 8 + +mp32add proc + push edi + push esi + + mov ecx,dword ptr [esp+12] + mov edi,dword ptr [esp+16] + mov esi,dword ptr [esp+20] + + xor edx,edx + dec ecx + +@add_loop: + mov eax,dword ptr [esi+ecx*4] + adc dword ptr [edi+ecx*4],eax + dec ecx + jns @add_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret +mp32add endp + + align 8 + +mp32sub proc + push edi + push esi + + mov ecx,dword ptr [esp+12] + mov edi,dword ptr [esp+16] + mov esi,dword ptr [esp+20] + + xor edx,edx + dec ecx + +@sub_loop: + mov eax,dword ptr [esi+ecx*4] + sbb dword ptr [edi+ecx*4],eax + dec ecx + jns @sub_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret +mp32sub endp + + + align 8 + +mp32multwo proc + push edi + + mov ecx,dword ptr [esp+8] + mov edi,dword ptr [esp+12] + + xor eax,eax + dec ecx + +@multwo_loop: + mov eax,dword ptr [edi+ecx*4] + adc dword ptr [edi+ecx*4],eax + dec ecx + jns @multwo_loop + + sbb eax,eax + neg eax + + pop edi + ret +mp32multwo endp + + + align 8 + +mp32setmul proc + push edi + push esi + push ebx + push ebp + + mov ecx,dword ptr [esp+20] + mov edi,dword ptr [esp+24] + mov esi,dword ptr [esp+28] + mov ebp,dword ptr [esp+32] + + xor ebx,ebx + dec ecx + + align 4 +@setmul_loop: + mov eax,dword ptr [esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + mov dword ptr [edi+ecx*4],eax + mov ebx,edx + dec ecx + jns @setmul_loop + + mov eax,ebx + + pop ebp + pop ebx + pop esi + pop edi + ret +mp32setmul endp + + + align 8 + +mp32addmul proc + push edi + push esi + push ebx + push ebp + + mov ecx,dword ptr [esp+20] + mov edi,dword ptr [esp+24] + mov esi,dword ptr [esp+28] + mov ebp,dword ptr [esp+32] + + xor ebx,ebx + dec ecx + + align 4 +@addmul_loop: + mov eax,dword ptr [esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + add eax,dword ptr [edi+ecx*4] + adc edx,0 + mov dword ptr [edi+ecx*4],eax + mov ebx,edx + dec ecx + jns @addmul_loop + + mov eax,ebx + + pop ebp + pop ebx + pop esi + pop edi + ret +mp32addmul endp + + + align 8 + +mp32addsqrtrc proc + push edi + push esi + push ebx + + mov ecx,dword ptr [esp+16] + mov edi,dword ptr [esp+20] + mov esi,dword ptr [esp+24] + + xor ebx,ebx + dec ecx + + align 4 +@addsqrtrc_loop: + mov eax,dword ptr [esi+ecx*4] + mul eax + add eax,ebx + adc edx,0 + add eax,dword ptr [edi+ecx*8+4] + adc edx,dword ptr [edi+ecx*8+0] + sbb ebx,ebx + mov dword ptr [edi+ecx*8+4],eax + mov dword ptr [edi+ecx*8+0],edx + neg ebx + dec ecx + jns @addsqrtrc_loop + + mov eax,ebx + + pop ebx + pop esi + pop edi + ret +mp32addsqrtrc endp + + end diff --git a/beecrypt/win32/mwerks/beecrypt.pch b/beecrypt/win32/mwerks/beecrypt.pch new file mode 100644 index 0000000..286d5ef --- /dev/null +++ b/beecrypt/win32/mwerks/beecrypt.pch @@ -0,0 +1,5 @@ +#include + +#pragma precompile_target "beecrypt.mch" + +#define HAVE_CONFIG_H \ No newline at end of file diff --git a/beecrypt/win32/mwerks/blowfishopt.i586.asm b/beecrypt/win32/mwerks/blowfishopt.i586.asm new file mode 100644 index 0000000..6732141 --- /dev/null +++ b/beecrypt/win32/mwerks/blowfishopt.i586.asm @@ -0,0 +1,173 @@ +# +# blowfishopt.i586.asm +# +# Assembler optimized blowfish routines for Intel Pentium processors +# +# Compile target is Metrowerks CodeWarrior Pro 5 for Windows +# +# Copyright (c) 2000 Virtual Unlimited B.V. +# +# Author: 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 +# + +etworounds: .macro p + xor ecx,[esi+p] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,ch + mov bl,cl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor edx,edi + xor edx,[esi+p+4] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,dh + mov bl,dl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor ecx,edi + .endm + +dtworounds: .macro p + xor ecx,[esi+p+4] + rol ecx,16 + mov al,ch + mov bl,cl + rol ecx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,ch + mov bl,cl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor edx,edi + xor edx,[esi+p] + rol edx,16 + mov al,dh + mov bl,dl + rol edx,16 + mov edi,[esi+eax*4+72+0x000] + add edi,[esi+ebx*4+72+0x400] + mov al,dh + mov bl,dl + xor edi,[esi+eax*4+72+0x800] + add edi,[esi+ebx*4+72+0xC00] + xor ecx,edi + .endm + + .text + + .align 4 + .globl _blowfishEncrypt + +_blowfishEncrypt: + push edi + push esi + push ebx + + mov esi,[esp+16] + mov edi,[esp+20] + + xor eax,eax + xor ebx,ebx + + mov ecx,[edi] + mov edx,[edi+4] + + bswap ecx + bswap edx + + etworounds 0 + etworounds 8 + etworounds 16 + etworounds 24 + etworounds 32 + etworounds 40 + etworounds 48 + etworounds 56 + + mov edi,[esp+20] + xor ecx,[esi+64] + xor edx,[esi+68] + + bswap ecx + bswap edx + + mov [edi+4],ecx + mov [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret + + .align 4 + .globl _blowfishDecrypt + +_blowfishDecrypt: + push edi + push esi + push ebx + + mov esi,[esp+16] + mov edi,[esp+20] + + xor eax,eax + xor ebx,ebx + + mov ecx,[edi] + mov edx,[edi+4] + + bswap ecx + bswap edx + + dtworounds 64 + dtworounds 56 + dtworounds 48 + dtworounds 40 + dtworounds 32 + dtworounds 24 + dtworounds 16 + dtworounds 8 + + mov edi,[esp+20] + xor ecx,[esi+4] + xor edx,[esi] + + bswap ecx + bswap edx + + mov [edi+4],ecx + mov [edi],edx + + xor eax,eax + + pop ebx + pop esi + pop edi + ret diff --git a/beecrypt/win32/mwerks/fips180opt.i586.asm b/beecrypt/win32/mwerks/fips180opt.i586.asm new file mode 100644 index 0000000..a87ac46 --- /dev/null +++ b/beecrypt/win32/mwerks/fips180opt.i586.asm @@ -0,0 +1,291 @@ +# +# fips180opt.i586.asm +# +# Assembler optimized SHA-1 routines for Intel Pentium processors +# +# Compile target is Metrowerks CodeWarrior Pro 5 for Windows +# +# Copyright (c) 2000 Virtual Unlimited B.V. +# +# Author: 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 +# + +K00 .equ 0x5a827999 +K20 .equ 0x6ed9eba1 +K40 .equ 0x8f1bbcdc +K60 .equ 0xca62c1d6 + +PARAM_H .equ 0 +PARAM_DATA .equ 20 +PARAM_OFFSET .equ 352 + +subround1: .macro b,c,d,e,w + mov ecx,c + mov ebx,b + mov edx,d + rol eax,5 + xor ecx,edx + add eax,e + and ecx,ebx + add eax,K00 + ror ebx,2 + add eax,w + xor ecx,edx + mov b,ebx + add eax,ecx + mov e,eax + .endm + +subround2: .macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K20 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + .endm + +subround3: .macro b,c,d,e,w + mov ecx,c + rol eax,5 + mov ebx,b + mov edx,ecx + add eax,e + or ecx,ebx # (b|c) + and edx,ebx # (b&c) + and ecx,d # (b|c)&d + add eax,K40 + or ecx,edx + add eax,w + ror ebx,2 + add eax,ecx + mov b,ebx + mov e,eax + .endm + +subround4: .macro b,c,d,e,w + mov ecx,c + mov ebx,b + rol eax,5 + xor ecx,ebx + add eax,e + xor ecx,d + add eax,K60 + ror ebx,2 + add eax,w + mov b,ebx + add eax,ecx + mov e,eax + .endm + + .text + + .align 4 + .globl _sha1Process + +_sha1Process: + push edi + push esi + push ebx + # allocate local variables + push ebp + lea ebp,[esp-24] + + mov esi,[esp+20] + lea edi,[esi+PARAM_DATA] + + mov ecx,4 +@loads: + mov edx,[esi+ecx*4] + mov [ebp+ecx*4],edx + dec ecx + jns @loads + + mov ecx,15 + xor eax,eax + + .align 4 +@swaps: + mov edx,[edi+ecx*4] + bswap edx + mov [edi+ecx*4],edx + dec ecx + jns @swaps + + lea edi,[esi+PARAM_DATA] + mov [esi+PARAM_OFFSET],al + mov ecx,16 + + .align 4 +@xors: + mov eax,[edi+52] + mov ebx,[edi+56] + xor eax,[edi+32] + xor ebx,[edi+36] + xor eax,[edi+ 8] + xor ebx,[edi+12] + xor eax,[edi ] + xor ebx,[edi+ 4] + rol eax,1 + rol ebx,1 + mov [edi+64],eax + mov [edi+68],ebx + mov eax,[edi+60] + mov ebx,[edi+64] + xor eax,[edi+40] + xor ebx,[edi+44] + xor eax,[edi+16] + xor ebx,[edi+20] + xor eax,[edi+ 8] + xor ebx,[edi+12] + rol eax,1 + rol ebx,1 + mov [edi+72],eax + mov [edi+76],ebx + add edi,16 + dec ecx + jnz @xors + + mov edi,PARAM_DATA + + # to optimize further, use esi only, and store the add constant into edi + # will make code smaller and faster + +@round01to20: + mov eax,[ebp] + subround1 [ebp+4],[ebp+8],[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + +@round21to40: + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + +@round41to60: + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + +@round61to80: + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + add edi,20 + subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] + subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] + subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] + subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] + subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] + # add edi,20 + + mov ecx,4 + +@adds: + mov eax,[ebp+ecx*4] + add [esi+ecx*4],eax + dec ecx + jns @adds + + pop ebp + pop ebx + pop esi + pop edi + ret diff --git a/beecrypt/win32/mwerks/mp32opt.i386.asm b/beecrypt/win32/mwerks/mp32opt.i386.asm new file mode 100644 index 0000000..f43d759 --- /dev/null +++ b/beecrypt/win32/mwerks/mp32opt.i386.asm @@ -0,0 +1,275 @@ +# +# mp32opt.i386.asm +# +# Assembler optimized multiprecision integer routines for Intel 386 +# +# Compile target is MetroWerks CodeWarrior Pro 5 for Windows +# +# Copyright (c) 1998-2000 Virtual Unlimited B.V. +# +# Author: 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 +# + + .text + + .align 4 + .globl _mp32addw + +_mp32addw: + push edi + + mov ecx,[esp+8] + mov edi,[esp+12] + mov eax,[esp+16] + + lea edi,[edi+ecx*4-4] + add [edi],eax + dec ecx + jz @addw_end + sub edi,4 + xor edx,edx + +@addw_loop: + adc [edi],edx + sub edi,4 + dec ecx + jnz @addw_loop +@addw_end: + sbb eax,eax + neg eax + + pop edi + ret + + .align 4 + .globl _mp32subw + +_mp32subw: + push edi + + mov ecx,[esp+8] + mov edi,[esp+12] + mov eax,[esp+16] + + lea edi,[edi+ecx*4-4] + sub [edi],eax + dec ecx + jz @subw_end + sub edi,4 + xor edx,edx + +@subw_loop: + sbb [edi],edx + sub edi,4 + dec ecx + jnz @subw_loop +@subw_end: + sbb eax,eax + neg eax + + pop edi + ret + + .align 4 + .globl _mp32add + +_mp32add: + push edi + push esi + + mov ecx,[esp+12] + mov edi,[esp+16] + mov esi,[esp+20] + + xor edx,edx + dec ecx + +@add_loop: + mov eax,[esi+ecx*4] + adc [edi+ecx*4],eax + dec ecx + jns @add_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret + + .align 4 + .globl _mp32sub + +_mp32sub: + push edi + push esi + + mov ecx,[esp+12] + mov edi,[esp+16] + mov esi,[esp+20] + + xor edx,edx + dec ecx + +@sub_loop: + mov eax,[esi+ecx*4] + sbb [edi+ecx*4],eax + dec ecx + jns @sub_loop + + sbb eax,eax + neg eax + + pop esi + pop edi + ret + + .align 4 + .globl _mp32multwo + +_mp32multwo: + push edi + + mov ecx,[esp+8] + mov edi,[esp+12] + + xor eax,eax + dec ecx + +@multwo_loop: + mov eax,[edi+ecx*4] + adc [edi+ecx*4],eax + dec ecx + jns @multwo_loop + + sbb eax,eax + neg eax + + pop edi + ret + + .align 4 + .globl _mp32setmul + +_mp32setmul: + push edi + push esi + push ebx + push ebp + + mov ecx,[esp+20] + mov edi,[esp+24] + mov esi,[esp+28] + mov ebp,[esp+32] + + xor ebx,ebx + dec ecx + + .align 4 +@setmul_loop: + mov eax,[esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + mov [edi+ecx*4],eax + mov ebx,edx + dec ecx + jns @setmul_loop + + mov eax,ebx + + pop ebp + pop ebx + pop esi + pop edi + ret + + + .align 4 + .globl _mp32addmul + +_mp32addmul: + push edi + push esi + push ebx + push ebp + + mov ecx,[esp+20] + mov edi,[esp+24] + mov esi,[esp+28] + mov ebp,[esp+32] + + xor ebx,ebx + dec ecx + + .align 4 +@addmul_loop: + mov eax,[esi+ecx*4] + mul ebp + add eax,ebx + adc edx,0 + add eax,[edi+ecx*4] + adc edx,0 + mov [edi+ecx*4],eax + mov ebx,edx + dec ecx + jns @addmul_loop + + mov eax,ebx + + pop ebp + pop ebx + pop esi + pop edi + ret + + .align 4 + .globl _mp32addsqrtrc + +_mp32addsqrtrc: + push edi + push esi + push ebx + + mov ecx,[esp+16] + mov edi,[esp+20] + mov esi,[esp+24] + + xor ebx,ebx + dec ecx + + .align 4 +@addsqrtrc_loop: + mov eax,[esi+ecx*4] + mul eax + add eax,ebx + adc edx,0 + add eax,[edi+ecx*8+4] + adc edx,[edi+ecx*8+0] + sbb ebx,ebx + mov [edi+ecx*8+4],eax + mov [edi+ecx*8+0],edx + neg ebx + dec ecx + jns @addsqrtrc_loop + + mov eax,ebx + + pop ebx + pop esi + pop edi + ret \ No newline at end of file -- 2.7.4