diff options
author | jbj <devnull@localhost> | 2001-09-18 19:23:46 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-09-18 19:23:46 +0000 |
commit | 78de87f74cc1a9cfffb9a198509f2e6697b8bca8 (patch) | |
tree | c2be7e2aeda8290b9108dba15750ee5af72f9d4f /beecrypt/win32 | |
parent | 38edc494525ccdf25f11ed2288378ba640928900 (diff) | |
download | rpm-78de87f74cc1a9cfffb9a198509f2e6697b8bca8.tar.gz rpm-78de87f74cc1a9cfffb9a198509f2e6697b8bca8.tar.bz2 rpm-78de87f74cc1a9cfffb9a198509f2e6697b8bca8.zip |
Initial revision
CVS patchset: 5051
CVS date: 2001/09/18 19:23:46
Diffstat (limited to 'beecrypt/win32')
-rw-r--r-- | beecrypt/win32/beecrypt.def | 259 | ||||
-rw-r--r-- | beecrypt/win32/beecrypt.dll.c | 43 | ||||
-rw-r--r-- | beecrypt/win32/beecrypt.rc | 31 | ||||
-rw-r--r-- | beecrypt/win32/config.win.h | 162 | ||||
-rw-r--r-- | beecrypt/win32/masm/blowfishopt.i586.asm | 180 | ||||
-rw-r--r-- | beecrypt/win32/masm/fips180opt.i586.asm | 298 | ||||
-rw-r--r-- | beecrypt/win32/masm/mp32opt.i386.asm | 287 | ||||
-rw-r--r-- | beecrypt/win32/mwerks/beecrypt.pch | 5 | ||||
-rw-r--r-- | beecrypt/win32/mwerks/blowfishopt.i586.asm | 173 | ||||
-rw-r--r-- | beecrypt/win32/mwerks/fips180opt.i586.asm | 291 | ||||
-rw-r--r-- | beecrypt/win32/mwerks/mp32opt.i386.asm | 275 |
11 files changed, 2004 insertions, 0 deletions
diff --git a/beecrypt/win32/beecrypt.def b/beecrypt/win32/beecrypt.def new file mode 100644 index 000000000..965017ff8 --- /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 <bob@virtualunlimited.com> +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +; + +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 000000000..109005187 --- /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 <bob@virtualunlimited.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "beecrypt.h" + +#include <windows.h> + +__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 000000000..527420543 --- /dev/null +++ b/beecrypt/win32/beecrypt.rc @@ -0,0 +1,31 @@ +#include <winver.h> + +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 000000000..bd6c934a3 --- /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 <bob@virtualunlimited.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#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 000000000..16cb1616b --- /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 <bob@virtualunlimited.com> +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +; + + .586 + .model flat,C + + .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 000000000..7c5eadac7 --- /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 <bob@virtualunlimited.com> +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +; + + .586 + .model flat,C + +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 000000000..61e305432 --- /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 <bob@virtualunlimited.com> +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +; + + .586 + .model flat,C + + .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 000000000..286d5ef4b --- /dev/null +++ b/beecrypt/win32/mwerks/beecrypt.pch @@ -0,0 +1,5 @@ +#include <Win32Headers.mch> + +#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 000000000..673214119 --- /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 <bob@virtualunlimited.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +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 000000000..a87ac462d --- /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 <bob@virtualunlimited.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +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 000000000..f43d75938 --- /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 <bob@virtualunlimited.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + .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 |