Compare commits
4 Commits
BEFORE_COM
...
SSLeay_0_9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
162d5f30be | ||
|
|
15403de6ca | ||
|
|
c7e9169997 | ||
|
|
ec96f926b9 |
324
apps/bss_file.c
324
apps/bss_file.c
@@ -1,324 +0,0 @@
|
||||
/* crypto/bio/bss_file.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#define APPS_WIN16
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bio.h"
|
||||
#include "err.h"
|
||||
|
||||
#ifndef NOPROTO
|
||||
static int MS_CALLBACK file_write(BIO *h,char *buf,int num);
|
||||
static int MS_CALLBACK file_read(BIO *h,char *buf,int size);
|
||||
static int MS_CALLBACK file_puts(BIO *h,char *str);
|
||||
static int MS_CALLBACK file_gets(BIO *h,char *str,int size);
|
||||
static long MS_CALLBACK file_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int MS_CALLBACK file_new(BIO *h);
|
||||
static int MS_CALLBACK file_free(BIO *data);
|
||||
#else
|
||||
static int MS_CALLBACK file_write();
|
||||
static int MS_CALLBACK file_read();
|
||||
static int MS_CALLBACK file_puts();
|
||||
static int MS_CALLBACK file_gets();
|
||||
static long MS_CALLBACK file_ctrl();
|
||||
static int MS_CALLBACK file_new();
|
||||
static int MS_CALLBACK file_free();
|
||||
#endif
|
||||
|
||||
static BIO_METHOD methods_filep=
|
||||
{
|
||||
BIO_TYPE_FILE,"FILE pointer",
|
||||
file_write,
|
||||
file_read,
|
||||
file_puts,
|
||||
file_gets,
|
||||
file_ctrl,
|
||||
file_new,
|
||||
file_free,
|
||||
};
|
||||
|
||||
BIO *BIO_new_file(filename,mode)
|
||||
char *filename;
|
||||
char *mode;
|
||||
{
|
||||
BIO *ret;
|
||||
FILE *file;
|
||||
|
||||
if ((file=fopen(filename,mode)) == NULL)
|
||||
{
|
||||
SYSerr(SYS_F_FOPEN,errno);
|
||||
BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
|
||||
return(NULL);
|
||||
}
|
||||
if ((ret=BIO_new_fp(file,BIO_CLOSE)) == NULL)
|
||||
{
|
||||
fclose(file);
|
||||
return(NULL);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
BIO *BIO_new_fp(stream,close_flag)
|
||||
FILE *stream;
|
||||
int close_flag;
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
if ((ret=BIO_new(BIO_s_file())) == NULL)
|
||||
return(NULL);
|
||||
BIO_set_fp(ret,stream,close_flag);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#if !defined(WIN16) || defined(APPS_WIN16)
|
||||
|
||||
BIO_METHOD *BIO_s_file()
|
||||
{
|
||||
return(&methods_filep);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BIO_METHOD *BIO_s_file_internal_w16()
|
||||
{
|
||||
return(&methods_filep);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int MS_CALLBACK file_new(bi)
|
||||
BIO *bi;
|
||||
{
|
||||
bi->init=0;
|
||||
bi->num=0;
|
||||
bi->ptr=NULL;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_free(a)
|
||||
BIO *a;
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->shutdown)
|
||||
{
|
||||
if ((a->init) && (a->ptr != NULL))
|
||||
{
|
||||
fclose((FILE *)a->ptr);
|
||||
a->ptr=NULL;
|
||||
}
|
||||
a->init=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_read(b,out,outl)
|
||||
BIO *b;
|
||||
char *out;
|
||||
int outl;
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
if (b->init && (out != NULL))
|
||||
{
|
||||
ret=fread(out,1,(int)outl,(FILE *)b->ptr);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_write(b,in,inl)
|
||||
BIO *b;
|
||||
char *in;
|
||||
int inl;
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
if (b->init && (in != NULL))
|
||||
{
|
||||
if (fwrite(in,(int)inl,1,(FILE *)b->ptr))
|
||||
ret=inl;
|
||||
/* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */
|
||||
/* acording to Tim Hudson <tjh@cryptsoft.com>, the commented
|
||||
* out version above can cause 'inl' write calls under
|
||||
* some stupid stdio implementations (VMS) */
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long MS_CALLBACK file_ctrl(b,cmd,num,ptr)
|
||||
BIO *b;
|
||||
int cmd;
|
||||
long num;
|
||||
char *ptr;
|
||||
{
|
||||
long ret=1;
|
||||
FILE *fp=(FILE *)b->ptr;
|
||||
FILE **fpp;
|
||||
char p[4];
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
ret=(long)fseek(fp,num,0);
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret=(long)feof(fp);
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret=ftell(fp);
|
||||
break;
|
||||
case BIO_C_SET_FILE_PTR:
|
||||
file_free(b);
|
||||
b->shutdown=(int)num;
|
||||
b->ptr=(char *)ptr;
|
||||
b->init=1;
|
||||
break;
|
||||
case BIO_C_SET_FILENAME:
|
||||
file_free(b);
|
||||
b->shutdown=(int)num&BIO_CLOSE;
|
||||
if (num & BIO_FP_APPEND)
|
||||
{
|
||||
if (num & BIO_FP_READ)
|
||||
strcpy(p,"a+");
|
||||
else strcpy(p,"a");
|
||||
}
|
||||
else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
|
||||
strcpy(p,"r+");
|
||||
else if (num & BIO_FP_WRITE)
|
||||
strcpy(p,"w");
|
||||
else if (num & BIO_FP_READ)
|
||||
strcpy(p,"r");
|
||||
else
|
||||
{
|
||||
BIOerr(BIO_F_FILE_CTRL,BIO_R_BAD_FOPEN_MODE);
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
#if defined(MSDOS) || defined(WINDOWS)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
strcat(p,"b");
|
||||
else
|
||||
strcat(p,"t");
|
||||
#endif
|
||||
fp=fopen(ptr,p);
|
||||
if (fp == NULL)
|
||||
{
|
||||
SYSerr(SYS_F_FOPEN,errno);
|
||||
BIOerr(BIO_F_FILE_CTRL,ERR_R_SYS_LIB);
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
b->ptr=(char *)fp;
|
||||
b->init=1;
|
||||
break;
|
||||
case BIO_C_GET_FILE_PTR:
|
||||
/* the ptr parameter is actually a FILE ** in this case. */
|
||||
if (ptr != NULL)
|
||||
{
|
||||
fpp=(FILE **)ptr;
|
||||
*fpp=(FILE *)b->ptr;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret=(long)b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_FLUSH:
|
||||
fflush((FILE *)b->ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
ret=1;
|
||||
break;
|
||||
|
||||
case BIO_CTRL_PENDING:
|
||||
case BIO_CTRL_PUSH:
|
||||
case BIO_CTRL_POP:
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_gets(bp,buf,size)
|
||||
BIO *bp;
|
||||
char *buf;
|
||||
int size;
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
buf[0]='\0';
|
||||
fgets(buf,size,(FILE *)bp->ptr);
|
||||
if (buf[0] != '\0')
|
||||
ret=strlen(buf);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_puts(bp,str)
|
||||
BIO *bp;
|
||||
char *str;
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=file_write(bp,str,n);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBOwIBAAJBALtv55QyzG6i2PlwZ1pah7++Gv8L5j6Hnyr/uTZE1NLG0ABDDexm
|
||||
q/R4KedLjFEIYjocDui+IXs62NNtXrT8odkCAwEAAQJAbwXq0vJ/+uyEvsNgxLko
|
||||
/V86mGXQ/KrSkeKlL0r4ENxjcyeMAGoKu6J9yMY7+X9+Zm4nxShNfTsf/+Freoe1
|
||||
HQIhAPOSm5Q1YI+KIsII2GeVJx1U69+wnd71OasIPakS1L1XAiEAxQAW+J3/JWE0
|
||||
ftEYakbhUOKL8tD1OaFZS71/5GdG7E8CIQCefUMmySSvwd6kC0VlATSWbW+d+jp/
|
||||
nWmM1KvqnAo5uQIhALqEADu5U1Wvt8UN8UDGBRPQulHWNycuNV45d3nnskWPAiAw
|
||||
ueTyr6WsZ5+SD8g/Hy3xuvF3nPmJRH+rwvVihlcFOg==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -1,8 +0,0 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBGzCBxgIBADBjMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDEa
|
||||
MBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxIzAhBgNVBAMTGkNsaWVudCB0ZXN0
|
||||
IGNlcnQgKDUxMiBiaXQpMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALtv55QyzG6i
|
||||
2PlwZ1pah7++Gv8L5j6Hnyr/uTZE1NLG0ABDDexmq/R4KedLjFEIYjocDui+IXs6
|
||||
2NNtXrT8odkCAwEAATANBgkqhkiG9w0BAQQFAANBAC5JBTeji7RosqMaUIDzIW13
|
||||
oO6+kPhx9fXSpMFHIsY3aH92Milkov/2A4SuZTcnv/P6+8klmS0EaiUKcRzak4E=
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
@@ -1,8 +0,0 @@
|
||||
-----BEGIN X509 CRL-----
|
||||
MIIBDjCBuTANBgkqhkiG9w0BAQQFADBgMQswCQYDVQQGEwJBVTEMMAoGA1UECBMD
|
||||
UUxEMRkwFwYDVQQKExBNaW5jb20gUHR5LiBMdGQuMQswCQYDVQQLEwJDUzEbMBkG
|
||||
A1UEAxMSU1NMZWF5IGRlbW8gc2VydmVyFw05NzA3MDkwMDAwMjJaFw05NzA4MDgw
|
||||
MDAwMjJaMCgwEgIBARcNOTUxMDA5MjMzMjA1WjASAgEDFw05NTEyMDEwMTAwMDBa
|
||||
MA0GCSqGSIb3DQEBBAUAA0EAcEBIWVZPXxSlLMPPLfBi4s0N3lzTgskZkgO6pjZi
|
||||
oQRwh5vi5zFqDNQteGx7RTHpUYntgyoAZ87FZE0GOJgBaQ==
|
||||
-----END X509 CRL-----
|
||||
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
-----BEGIN xxx-----
|
||||
MIAGCSqGSIb3DQEHAqCAMIACAQExADCABgkqhkiG9w0BBwEAAKCAMIIB
|
||||
rTCCAUkCAgC2MA0GCSqGSIb3DQEBAgUAME0xCzAJBgNVBAYTAlVTMSAw
|
||||
HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEcMBoGA1UECxMT
|
||||
UGVyc29uYSBDZXJ0aWZpY2F0ZTAeFw05NDA0MDkwMDUwMzdaFw05NDA4
|
||||
MDIxODM4NTdaMGcxCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0
|
||||
YSBTZWN1cml0eSwgSW5jLjEcMBoGA1UECxMTUGVyc29uYSBDZXJ0aWZp
|
||||
Y2F0ZTEYMBYGA1UEAxMPU2V0ZWMgQXN0cm9ub215MFwwDQYJKoZIhvcN
|
||||
AQEBBQADSwAwSAJBAMy8QcW7RMrB4sTdQ8Nmb2DFmJmkWn+el+NdeamI
|
||||
DElX/qw9mIQu4xNj1FfepfJNxzPvA0OtMKhy6+bkrlyMEU8CAwEAATAN
|
||||
BgkqhkiG9w0BAQIFAANPAAYn7jDgirhiIL4wnP8nGzUisGSpsFsF4/7z
|
||||
2P2wqne6Qk8Cg/Dstu3RyaN78vAMGP8d82H5+Ndfhi2mRp4YHiGHz0Hl
|
||||
K6VbPfnyvS2wdjCCAccwggFRAgUCQAAAFDANBgkqhkiG9w0BAQIFADBf
|
||||
MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXUlNBIERhdGEgU2VjdXJpdHks
|
||||
IEluYy4xLjAsBgNVBAsTJUxvdyBBc3N1cmFuY2UgQ2VydGlmaWNhdGlv
|
||||
biBBdXRob3JpdHkwHhcNOTQwMTA3MDAwMDAwWhcNOTYwMTA3MjM1OTU5
|
||||
WjBNMQswCQYDVQQGEwJVUzEgMB4GA1UEChMXUlNBIERhdGEgU2VjdXJp
|
||||
dHksIEluYy4xHDAaBgNVBAsTE1BlcnNvbmEgQ2VydGlmaWNhdGUwaTAN
|
||||
BgkqhkiG9w0BAQEFAANYADBVAk4GqghQDa9Xi/2zAdYEqJVIcYhlLN1F
|
||||
pI9tXQ1m6zZ39PYXK8Uhoj0Es7kWRv8hC04vqkOKwndWbzVtvoHQOmP8
|
||||
nOkkuBi+AQvgFoRcgOUCAwEAATANBgkqhkiG9w0BAQIFAANhAD/5Uo7x
|
||||
Ddp49oZm9GoNcPhZcW1e+nojLvHXWAU/CBkwfcR+FSf4hQ5eFu1AjYv6
|
||||
Wqf430Xe9Et5+jgnMTiq4LnwgTdA8xQX4elJz9QzQobkE3XVOjVAtCFc
|
||||
miin80RB8AAAMYAAAAAAAAAAAA==
|
||||
-----END xxx-----
|
||||
@@ -1,11 +0,0 @@
|
||||
-----BEGIN PRIVACY-ENHANCED MESSAGE-----
|
||||
MIAGCSqGSIb3DQEHBqCAMIACAQAwgAYJKoZIhvcNAQcBMBEGBSsOAwIHBAifqtdy
|
||||
x6uIMYCCARgvFzJtOZBn773DtmXlx037ck3giqnV0WC0QAx5f+fesAiGaxMqWcir
|
||||
r9XvT0nT0LgSQ/8tiLCDBEKdyCNgdcJAduy3D0r2sb5sNTT0TyL9uydG3w55vTnW
|
||||
aPbCPCWLudArI1UHDZbnoJICrVehxG/sYX069M8v6VO8PsJS7//hh1yM+0nekzQ5
|
||||
l1p0j7uWKu4W0csrlGqhLvEJanj6dQAGSTNCOoH3jzEXGQXntgesk8poFPfHdtj0
|
||||
5RH4MuJRajDmoEjlrNcnGl/BdHAd2JaCo6uZWGcnGAgVJ/TVfSVSwN5nlCK87tXl
|
||||
nL7DJwaPRYwxb3mnPKNq7ATiJPf5u162MbwxrddmiE7e3sST7naSN+GS0ateY5X7
|
||||
AAAAAAAAAAA=
|
||||
-----END PRIVACY-ENHANCED MESSAGE-----
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
-----BEGIN PRIVACY-ENHANCED MESSAGE-----
|
||||
MIAGCSqGSIb3DQEHA6CAMIACAQAxgDCBqQIBADBTME0xCzAJBgNVBAYTAlVTMSAw
|
||||
HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEcMBoGA1UECxMTUGVyc29u
|
||||
YSBDZXJ0aWZpY2F0ZQICALYwDQYJKoZIhvcNAQEBBQAEQCU/R+YCJSUsV6XLilHG
|
||||
cNVzwqKcWzmT/rZ+duOv8Ggb7oO/d8H3xUVGQ2LsX4kYGq2szwj8Q6eWhsmhf4oz
|
||||
lvMAADCABgkqhkiG9w0BBwEwEQYFKw4DAgcECFif7BadXlw3oIAEgZBNcMexKe16
|
||||
+mNxx8YQPukBCL0bWqS86lvws/AgRkKPELmysBi5lco8MBCsWK/fCyrnxIRHs1oK
|
||||
BXBVlsAhKkkusk1kCf/GbXSAphdSgG+d6LxrNZwHbBFOX6A2hYS63Iczd5bOVDDW
|
||||
Op2gcgUtMJq6k2LFrs4L7HHqRPPlqNJ6j5mFP4xkzOCNIQynpD1rV6EECMIk/T7k
|
||||
1JLSAAAAAAAAAAAAAA==
|
||||
-----END PRIVACY-ENHANCED MESSAGE-----
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
-----BEGIN PKCS7-----
|
||||
MIIIEgYJKoZIhvcNAQcCMIIIAwIBATEAMAsGCSqGSIb3DQEHAaCCBDUwggIhMIIB
|
||||
jgIFAnIAAGcwDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMxIDAeBgNVBAoT
|
||||
F1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYDVQQLEyVTZWN1cmUgU2VydmVy
|
||||
IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk1MDUxNzAwMDAwMFoXDTk1MTEx
|
||||
NjIzNTk1OVowdzELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5h
|
||||
MRIwEAYDVQQHEwlDaGFybG90dGUxIzAhBgNVBAoTGlZuZXQgSW50ZXJuZXQgQWNj
|
||||
ZXNzLCBJbmMuMRYwFAYDVQQDFA13d3cqLnZuZXQubmV0MHwwDQYJKoZIhvcNAQEB
|
||||
BQADawAwaAJhAOngW+io4W1lAp1b2k4+KqICaLHatp6AWkPLpa3Li2mwmggSGeRD
|
||||
AmTI4FQB0EFrDMfKLOteHgGoDJ0vifmV5cKvevRt5Gn+xPn54Halu7i145iUldyv
|
||||
oViUNpWmLJhKTQIDAQABMA0GCSqGSIb3DQEBAgUAA34AQkyfJje6H8fxtN68TvXV
|
||||
RibnPpQol2jMbh0VnK9cP9ePvsXy+7JoGuWxj6zlgjZGwia49xITggZ+0b+wP51l
|
||||
5e8xEEc2K7eC5QVD0qh/NSqdPcVP+UG6UK/LT25w/yLuZgqJ3g87kGbOo9myLhkZ
|
||||
3jr3kXnsriBmwmqcjgUwggIMMIIBlgIFAkAAAEUwDQYJKoZIhvcNAQECBQAwXzEL
|
||||
MAkGA1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4w
|
||||
LAYDVQQLEyVMb3cgQXNzdXJhbmNlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4X
|
||||
DTk0MTEwOTIzMTk0NFoXDTk5MTIzMTIzMTk0NFowXzELMAkGA1UEBhMCVVMxIDAe
|
||||
BgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYDVQQLEyVTZWN1cmUg
|
||||
U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGbMA0GCSqGSIb3DQEBAQUA
|
||||
A4GJADCBhQJ+AJLOesGugz5aqomDV6wlAXYMra6OLDfO6zV4ZFQD5YRAUcm/jwji
|
||||
ioII0haGN1XpsSECrXZogZoFokvJSyVmIlZsiAeP94FZbYQHZXATcXY+m3dM41CJ
|
||||
VphIuR2nKRoTLkoRWZweFdVJVCxzOmmCsZc5nG1wZ0jl3S3WyB57AgMBAAEwDQYJ
|
||||
KoZIhvcNAQECBQADYQAjOCnuhWTdRq+8PhUBSzKbOhmafQQPQ8Ltw+49U8N1zgq9
|
||||
1ROaW46znUQykAPUdaAIflEfV2e0ULuyOWCwDJ2ME7NUmWL86SLkk6QLC9iItjva
|
||||
h+tdpLV/+TerjmrxCWChggOyMIICjTCCAfowDQYJKoZIhvcNAQECBQAwXzELMAkG
|
||||
A1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYD
|
||||
VQQLEyVTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5Fw05NTA1
|
||||
MDIwMjEyMjZaFw05NTA2MDEwMDAxNDlaMIIBaDAWAgUCQQAABBcNOTUwMjAxMTcy
|
||||
NDI2WjAWAgUCQQAACRcNOTUwMjEwMDIxNjM5WjAWAgUCQQAADxcNOTUwMjI0MDAx
|
||||
MjQ5WjAWAgUCQQAADBcNOTUwMjI1MDA0NjQ0WjAWAgUCQQAAGxcNOTUwMzEzMTg0
|
||||
MDQ5WjAWAgUCQQAAFhcNOTUwMzE1MTkxNjU0WjAWAgUCQQAAGhcNOTUwMzE1MTk0
|
||||
MDQxWjAWAgUCQQAAHxcNOTUwMzI0MTk0NDMzWjAWAgUCcgAABRcNOTUwMzI5MjAw
|
||||
NzExWjAWAgUCcgAAERcNOTUwMzMwMDIzNDI2WjAWAgUCQQAAIBcNOTUwNDA3MDEx
|
||||
MzIxWjAWAgUCcgAAHhcNOTUwNDA4MDAwMjU5WjAWAgUCcgAAQRcNOTUwNDI4MTcx
|
||||
NzI0WjAWAgUCcgAAOBcNOTUwNDI4MTcyNzIxWjAWAgUCcgAATBcNOTUwNTAyMDIx
|
||||
MjI2WjANBgkqhkiG9w0BAQIFAAN+AHqOEJXSDejYy0UwxxrH/9+N2z5xu/if0J6q
|
||||
QmK92W0hW158wpJg+ovV3+wQwvIEPRL2rocL0tKfAsVq1IawSJzSNgxG0lrcla3M
|
||||
rJBnZ4GaZDu4FutZh72MR3GtJaAL3iTJHJD55kK2D/VoyY1djlsPuNh6AEgdVwFA
|
||||
yp0vMIIBHTCBqDANBgkqhkiG9w0BAQIFADBfMQswCQYDVQQGEwJVUzEgMB4GA1UE
|
||||
ChMXUlNBIERhdGEgU2VjdXJpdHksIEluYy4xLjAsBgNVBAsTJUxvdyBBc3N1cmFu
|
||||
Y2UgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkXDTk1MDUwMTE5MjcyOVoXDTk1MDYw
|
||||
MTA4MDAwMFowGDAWAgUCQAAAXhcNOTUwMjA4MDE0NjIyWjANBgkqhkiG9w0BAQIF
|
||||
AANhAF70VxEAKgGlS2otYkWSqYJ286MMDbdAIoEGCDTtVuLCOP3YKHOSTjFhbIhL
|
||||
5mBd+Q/W+lKSqdoyYhdObaBk4I4Wk+/BE2QK1x4QhtYG144spESXIRIKAbhffg1g
|
||||
rRe/ETEA
|
||||
-----END PKCS7-----
|
||||
@@ -1,16 +0,0 @@
|
||||
www.microsoft.com:443
|
||||
sectest.microsoft.com:443
|
||||
https://sectest.microsoft.com/ClientAuth/test.asp
|
||||
ssl3.netscape.com:443
|
||||
ssl3.netscape.com:444
|
||||
www.openmarket.com:443 - no session ID caching. - no swap
|
||||
|
||||
Servers
|
||||
bad www.openmarket.com Open-Market-Secure-WebServer/V2.1
|
||||
bad www.microsoft.com Server: Microsoft-IIS/3.0
|
||||
good transact.netscape.com Netscape-Enterprise/2.01
|
||||
|
||||
clients
|
||||
good netscape
|
||||
hmm MSIE
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 1 (0x1)
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
Issuer: O=European ICE-TEL project, OU=V3-Certification Authority
|
||||
Validity
|
||||
Not Before: Apr 2 17:35:53 1997 GMT
|
||||
Not After : Apr 2 17:35:53 1998 GMT
|
||||
Subject: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsa
|
||||
RSA Public Key: (512 bit)
|
||||
Modulus (512 bit):
|
||||
00:82:75:ba:f6:d1:60:b5:f9:15:b3:6a:dd:29:8f:
|
||||
8b:a4:6f:1a:88:e0:50:43:40:0b:79:41:d5:d3:16:
|
||||
44:7d:74:65:17:42:06:52:0b:e9:50:c8:10:cd:24:
|
||||
e2:ae:8d:22:30:73:e6:b4:b7:93:1f:e5:6e:a2:ae:
|
||||
49:11:a5:c9:45
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Authority Key Identifier:
|
||||
0.........z.."p......e..
|
||||
X509v3 Subject Key Identifier:
|
||||
..~r..:..B.44fu......3
|
||||
X509v3 Key Usage: critical
|
||||
....
|
||||
X509v3 Certificate Policies: critical
|
||||
0.0...*...
|
||||
X509v3 Subject Alternative Name:
|
||||
0!..secude-support@darmstadt.gmd.de
|
||||
X509v3 Issuer Alternative Name:
|
||||
0I..ice-tel-ca@darmstadt.gmd.de.*http://www.darmstadt.gmd.de/ice-tel/euroca
|
||||
X509v3 Basic Constraints: critical
|
||||
0....
|
||||
X509v3 CRL Distribution Points:
|
||||
0200...,.*http://www.darmstadt.gmd.de/ice-tel/euroca
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
17:a2:88:b7:99:5a:05:41:e4:13:34:67:e6:1f:3e:26:ec:4b:
|
||||
69:f9:3e:28:22:be:9d:1c:ab:41:6f:0c:00:85:fe:45:74:f6:
|
||||
98:f0:ce:9b:65:53:4a:50:42:c7:d4:92:bd:d7:a2:a8:3d:98:
|
||||
88:73:cd:60:28:79:a3:fc:48:7a
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICzDCCAnagAwIBAgIBATANBgkqhkiG9w0BAQQFADBIMSEwHwYDVQQKExhFdXJv
|
||||
cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g
|
||||
QXV0aG9yaXR5MB4XDTk3MDQwMjE3MzU1M1oXDTk4MDQwMjE3MzU1M1owXDEhMB8G
|
||||
A1UEChMYRXVyb3BlYW4gSUNFLVRFTCBwcm9qZWN0MSMwIQYDVQQLExpWMy1DZXJ0
|
||||
aWZpY2F0aW9uIEF1dGhvcml0eTESMBAGA1UEBxMJRGFybXN0YWR0MFkwCgYEVQgB
|
||||
AQICAgADSwAwSAJBAIJ1uvbRYLX5FbNq3SmPi6RvGojgUENAC3lB1dMWRH10ZRdC
|
||||
BlIL6VDIEM0k4q6NIjBz5rS3kx/lbqKuSRGlyUUCAwEAAaOCATgwggE0MB8GA1Ud
|
||||
IwQYMBaAFIr3yNUOx3ro1yJw4AuJ1bbsZbzPMB0GA1UdDgQWBBR+cvL4OoacQog0
|
||||
NGZ1w9T80aIRMzAOBgNVHQ8BAf8EBAMCAfYwFAYDVR0gAQH/BAowCDAGBgQqAwQF
|
||||
MCoGA1UdEQQjMCGBH3NlY3VkZS1zdXBwb3J0QGRhcm1zdGFkdC5nbWQuZGUwUgYD
|
||||
VR0SBEswSYEbaWNlLXRlbC1jYUBkYXJtc3RhZHQuZ21kLmRlhipodHRwOi8vd3d3
|
||||
LmRhcm1zdGFkdC5nbWQuZGUvaWNlLXRlbC9ldXJvY2EwDwYDVR0TAQH/BAUwAwEB
|
||||
/zA7BgNVHR8ENDAyMDCgLqAshipodHRwOi8vd3d3LmRhcm1zdGFkdC5nbWQuZGUv
|
||||
aWNlLXRlbC9ldXJvY2EwDQYJKoZIhvcNAQEEBQADQQAXooi3mVoFQeQTNGfmHz4m
|
||||
7Etp+T4oIr6dHKtBbwwAhf5FdPaY8M6bZVNKUELH1JK916KoPZiIc81gKHmj/Eh6
|
||||
-----END CERTIFICATE-----
|
||||
@@ -1,48 +0,0 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 0 (0x0)
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
Issuer: O=European ICE-TEL project, OU=V3-Certification Authority
|
||||
Validity
|
||||
Not Before: Apr 2 17:33:36 1997 GMT
|
||||
Not After : Apr 2 17:33:36 1998 GMT
|
||||
Subject: O=European ICE-TEL project, OU=V3-Certification Authority
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsa
|
||||
RSA Public Key: (512 bit)
|
||||
Modulus (512 bit):
|
||||
00:80:3e:eb:ae:47:a9:fe:10:54:0b:81:8b:9c:2b:
|
||||
82:ab:3a:61:36:65:8b:f3:73:9f:ac:ac:7a:15:a7:
|
||||
13:8f:b4:c4:ba:a3:0f:bc:a5:58:8d:cc:b1:93:31:
|
||||
9e:81:9e:8c:19:61:86:fa:52:73:54:d1:97:76:22:
|
||||
e7:c7:9f:41:cd
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Key Identifier:
|
||||
........z.."p......e..
|
||||
X509v3 Key Usage: critical
|
||||
....
|
||||
X509v3 Subject Alternative Name:
|
||||
0I.*http://www.darmstadt.gmd.de/ice-tel/euroca..ice-tel-ca@darmstadt.gmd.de
|
||||
X509v3 Basic Constraints: critical
|
||||
0....
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
76:69:61:db:b7:cf:8b:06:9e:d8:8c:96:53:d2:4d:a8:23:a6:
|
||||
03:44:e8:8f:24:a5:c0:84:a8:4b:77:d4:2d:2b:7d:37:91:67:
|
||||
f2:2c:ce:02:31:4c:6b:cc:ce:f2:68:a6:11:11:ab:7d:88:b8:
|
||||
7e:22:9f:25:06:60:bd:79:30:3d
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICFjCCAcCgAwIBAgIBADANBgkqhkiG9w0BAQQFADBIMSEwHwYDVQQKExhFdXJv
|
||||
cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g
|
||||
QXV0aG9yaXR5MB4XDTk3MDQwMjE3MzMzNloXDTk4MDQwMjE3MzMzNlowSDEhMB8G
|
||||
A1UEChMYRXVyb3BlYW4gSUNFLVRFTCBwcm9qZWN0MSMwIQYDVQQLExpWMy1DZXJ0
|
||||
aWZpY2F0aW9uIEF1dGhvcml0eTBZMAoGBFUIAQECAgIAA0sAMEgCQQCAPuuuR6n+
|
||||
EFQLgYucK4KrOmE2ZYvzc5+srHoVpxOPtMS6ow+8pViNzLGTMZ6BnowZYYb6UnNU
|
||||
0Zd2IufHn0HNAgMBAAGjgZcwgZQwHQYDVR0OBBYEFIr3yNUOx3ro1yJw4AuJ1bbs
|
||||
ZbzPMA4GA1UdDwEB/wQEAwIB9jBSBgNVHREESzBJhipodHRwOi8vd3d3LmRhcm1z
|
||||
dGFkdC5nbWQuZGUvaWNlLXRlbC9ldXJvY2GBG2ljZS10ZWwtY2FAZGFybXN0YWR0
|
||||
LmdtZC5kZTAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBBAUAA0EAdmlh27fP
|
||||
iwae2IyWU9JNqCOmA0TojySlwISoS3fULSt9N5Fn8izOAjFMa8zO8mimERGrfYi4
|
||||
fiKfJQZgvXkwPQ==
|
||||
-----END CERTIFICATE-----
|
||||
@@ -1,63 +0,0 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 1 (0x1)
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
Issuer: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt
|
||||
Validity
|
||||
Not Before: Apr 2 17:35:59 1997 GMT
|
||||
Not After : Apr 2 17:35:59 1998 GMT
|
||||
Subject: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt, CN=USER
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsa
|
||||
RSA Public Key: (512 bit)
|
||||
Modulus (512 bit):
|
||||
00:a8:a8:53:63:49:1b:93:c3:c3:0b:6c:88:11:55:
|
||||
de:7e:6a:e2:f9:52:a0:dc:69:25:c4:c8:bf:55:e1:
|
||||
31:a8:ce:e4:a9:29:85:99:8a:15:9a:de:f6:2f:e1:
|
||||
b4:50:5f:5e:04:75:a6:f4:76:dc:3c:0e:39:dc:3a:
|
||||
be:3e:a4:61:8b
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Authority Key Identifier:
|
||||
0...~r..:..B.44fu......3
|
||||
X509v3 Subject Key Identifier:
|
||||
...... .*...1.*.......
|
||||
X509v3 Key Usage: critical
|
||||
....
|
||||
X509v3 Certificate Policies: critical
|
||||
0.0...*...0.......
|
||||
X509v3 Subject Alternative Name:
|
||||
0:..user@darmstadt.gmd.de.!http://www.darmstadt.gmd.de/~user
|
||||
X509v3 Issuer Alternative Name:
|
||||
0....gmdca@gmd.de..http://www.gmd.de..saturn.darmstadt.gmd.de.\1!0...U.
|
||||
..European ICE-TEL project1#0!..U....V3-Certification Authority1.0...U....Darmstadt..141.12.62.26
|
||||
X509v3 Basic Constraints: critical
|
||||
0.
|
||||
X509v3 CRL Distribution Points:
|
||||
0.0.......gmdca@gmd.de
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
69:0c:e1:b7:a7:f2:d8:fb:e8:69:c0:13:cd:37:ad:21:06:22:
|
||||
4d:e8:c6:db:f1:04:0b:b7:e0:b3:d6:0c:81:03:ce:c3:6a:3e:
|
||||
c7:e7:24:24:a4:92:64:c2:83:83:06:42:53:0e:6f:09:1e:84:
|
||||
9a:f7:6f:63:9b:94:99:83:d6:a4
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDTzCCAvmgAwIBAgIBATANBgkqhkiG9w0BAQQFADBcMSEwHwYDVQQKExhFdXJv
|
||||
cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g
|
||||
QXV0aG9yaXR5MRIwEAYDVQQHEwlEYXJtc3RhZHQwHhcNOTcwNDAyMTczNTU5WhcN
|
||||
OTgwNDAyMTczNTU5WjBrMSEwHwYDVQQKExhFdXJvcGVhbiBJQ0UtVEVMIHByb2pl
|
||||
Y3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24gQXV0aG9yaXR5MRIwEAYDVQQH
|
||||
EwlEYXJtc3RhZHQxDTALBgNVBAMTBFVTRVIwWTAKBgRVCAEBAgICAANLADBIAkEA
|
||||
qKhTY0kbk8PDC2yIEVXefmri+VKg3GklxMi/VeExqM7kqSmFmYoVmt72L+G0UF9e
|
||||
BHWm9HbcPA453Dq+PqRhiwIDAQABo4IBmDCCAZQwHwYDVR0jBBgwFoAUfnLy+DqG
|
||||
nEKINDRmdcPU/NGiETMwHQYDVR0OBBYEFJfc4B8gjSoRmLUx4Sq/ucIYiMrPMA4G
|
||||
A1UdDwEB/wQEAwIB8DAcBgNVHSABAf8EEjAQMAYGBCoDBAUwBgYECQgHBjBDBgNV
|
||||
HREEPDA6gRV1c2VyQGRhcm1zdGFkdC5nbWQuZGWGIWh0dHA6Ly93d3cuZGFybXN0
|
||||
YWR0LmdtZC5kZS9+dXNlcjCBsQYDVR0SBIGpMIGmgQxnbWRjYUBnbWQuZGWGEWh0
|
||||
dHA6Ly93d3cuZ21kLmRlghdzYXR1cm4uZGFybXN0YWR0LmdtZC5kZaRcMSEwHwYD
|
||||
VQQKExhFdXJvcGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRp
|
||||
ZmljYXRpb24gQXV0aG9yaXR5MRIwEAYDVQQHEwlEYXJtc3RhZHSHDDE0MS4xMi42
|
||||
Mi4yNjAMBgNVHRMBAf8EAjAAMB0GA1UdHwQWMBQwEqAQoA6BDGdtZGNhQGdtZC5k
|
||||
ZTANBgkqhkiG9w0BAQQFAANBAGkM4ben8tj76GnAE803rSEGIk3oxtvxBAu34LPW
|
||||
DIEDzsNqPsfnJCSkkmTCg4MGQlMObwkehJr3b2OblJmD1qQ=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -1,9 +0,0 @@
|
||||
-----BEGIN X509 CRL-----
|
||||
MIIBNDCBnjANBgkqhkiG9w0BAQIFADBFMSEwHwYDVQQKExhFdXJvcGVhbiBJQ0Ut
|
||||
VEVMIFByb2plY3QxIDAeBgNVBAsTF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5Fw05
|
||||
NzA2MDkxNDQyNDNaFw05NzA3MDkxNDQyNDNaMCgwEgIBChcNOTcwMzAzMTQ0MjU0
|
||||
WjASAgEJFw05NjEwMDIxMjI5MjdaMA0GCSqGSIb3DQEBAgUAA4GBAH4vgWo2Tej/
|
||||
i7kbiw4Imd30If91iosjClNpBFwvwUDBclPEeMuYimHbLOk4H8Nofc0fw11+U/IO
|
||||
KSNouUDcqG7B64oY7c4SXKn+i1MWOb5OJiWeodX3TehHjBlyWzoNMWCnYA8XqFP1
|
||||
mOKp8Jla1BibEZf14+/HqCi2hnZUiEXh
|
||||
-----END X509 CRL-----
|
||||
@@ -1,16 +0,0 @@
|
||||
subject=/C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority
|
||||
issuer= /C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICMTCCAZoCBQKmAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMRcw
|
||||
FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMg
|
||||
UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NjAxMjkwMDAwMDBa
|
||||
Fw05OTEyMzEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln
|
||||
biwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZp
|
||||
Y2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0LJ1
|
||||
9njQrlpQ9OlQqZ+M1++RlHDo0iSQdomF1t+s5gEXMoDwnZNHvJplnR+Xrr/phnVj
|
||||
IIm9gFidBAydqMEk6QvlMXi9/C0MN2qeeIDpRnX57aP7E3vIwUzSo+/1PLBij0pd
|
||||
O92VZ48TucE81qcmm+zDO3rZTbxtm+gVAePwR6kCAwEAATANBgkqhkiG9w0BAQIF
|
||||
AAOBgQBT3dPwnCR+QKri/AAa19oM/DJhuBUNlvP6Vxt/M3yv6ZiaYch6s7f/sdyZ
|
||||
g9ysEvxwyR84Qu1E9oAuW2szaayc01znX1oYx7EteQSWQZGZQbE8DbqEOcY7l/Am
|
||||
yY7uvcxClf8exwI/VAx49byqYHwCaejcrOICdmHEPgPq0ook0Q==
|
||||
-----END CERTIFICATE-----
|
||||
117
crypto/asn1/pk.c
117
crypto/asn1/pk.c
@@ -1,117 +0,0 @@
|
||||
/* crypto/asn1/pk.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../error/err.h"
|
||||
#include "./asn1.h"
|
||||
#include "rsa.h"
|
||||
#include "x509.h"
|
||||
#include "pkcs7.h"
|
||||
|
||||
main()
|
||||
{
|
||||
PKCS7 *x;
|
||||
FILE *in;
|
||||
unsigned char buf[10240],buf2[10240],*p;
|
||||
int num,i;
|
||||
|
||||
PKCS7 *nx=NULL,*mx=NULL;
|
||||
|
||||
in=fopen("pkcs7.der","r");
|
||||
if (in == NULL)
|
||||
{
|
||||
perror("pkcs7.der");
|
||||
exit(1);
|
||||
}
|
||||
num=fread(buf,1,10240,in);
|
||||
fclose(in);
|
||||
|
||||
|
||||
p=buf;
|
||||
if (d2i_PKCS7(&nx,&p,num) == NULL) goto err;
|
||||
printf("num=%d p-buf=%d\n",num,p-buf);
|
||||
|
||||
exit(0);
|
||||
p=buf2;
|
||||
num=i2d_PKCS7(nx,&p);
|
||||
printf("num=%d p-buf=%d\n",num,p-buf2);
|
||||
|
||||
if (memcmp(buf,buf2,num) != 0)
|
||||
{
|
||||
fprintf(stderr,"data difference\n");
|
||||
for (i=0; i<num; i++)
|
||||
fprintf(stderr,"%c%03d <%02X-%02X>\n",
|
||||
(buf[i] == buf2[i])?' ':'*',i,
|
||||
buf[i],buf2[i]);
|
||||
fprintf(stderr,"\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p=buf2;
|
||||
if (d2i_PKCS7(&mx,&p,num) == NULL) goto err;
|
||||
printf("num=%d p-buf=%d\n",num,p-buf2);
|
||||
|
||||
/* X509_print(stdout,mx);*/
|
||||
|
||||
exit(0);
|
||||
err:
|
||||
ERR_load_crypto_strings();
|
||||
ERR_print_errors(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,253 +0,0 @@
|
||||
/* crypto/asn1/test.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../error/err.h"
|
||||
#include "./asn1.h"
|
||||
#include "rsa.h"
|
||||
#include "../x509/x509.h"
|
||||
#include "x509.h"
|
||||
|
||||
main()
|
||||
{
|
||||
main1();
|
||||
main2();
|
||||
main3();
|
||||
main4();
|
||||
}
|
||||
|
||||
main1()
|
||||
{
|
||||
FILE *in;
|
||||
unsigned char buf[10240],buf2[10240],*p;
|
||||
int num,i;
|
||||
|
||||
X509 *nx=NULL,*mx=NULL;
|
||||
|
||||
in=fopen("x.der","r");
|
||||
if (in == NULL)
|
||||
{
|
||||
perror("x.der");
|
||||
exit(1);
|
||||
}
|
||||
num=fread(buf,1,10240,in);
|
||||
fclose(in);
|
||||
|
||||
|
||||
p=buf;
|
||||
if (d2i_X509(&nx,&p,num) == NULL) goto err;
|
||||
printf("num=%d p-buf=%d\n",num,p-buf);
|
||||
|
||||
p=buf2;
|
||||
num=i2d_X509(nx,&p);
|
||||
printf("num=%d p-buf=%d\n",num,p-buf2);
|
||||
|
||||
if (memcmp(buf,buf2,num) != 0)
|
||||
{
|
||||
fprintf(stderr,"data difference\n");
|
||||
for (i=0; i<num; i++)
|
||||
fprintf(stderr,"%c%03d <%02X-%02X>\n",
|
||||
(buf[i] == buf2[i])?' ':'*',i,
|
||||
buf[i],buf2[i]);
|
||||
fprintf(stderr,"\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p=buf2;
|
||||
if (d2i_X509(&mx,&p,num) == NULL) goto err;
|
||||
printf("num=%d p-buf=%d\n",num,p-buf2);
|
||||
|
||||
return(1);
|
||||
err:
|
||||
ERR_load_crypto_strings();
|
||||
ERR_print_errors(stderr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
main2()
|
||||
{
|
||||
FILE *in;
|
||||
unsigned char buf[10240],buf2[10240],*p;
|
||||
int num,i;
|
||||
|
||||
X509_CRL *nx=NULL,*mx=NULL;
|
||||
|
||||
in=fopen("crl.der","r");
|
||||
if (in == NULL)
|
||||
{
|
||||
perror("crl.der");
|
||||
exit(1);
|
||||
}
|
||||
num=fread(buf,1,10240,in);
|
||||
fclose(in);
|
||||
|
||||
|
||||
p=buf;
|
||||
if (d2i_X509_CRL(&nx,&p,num) == NULL) goto err;
|
||||
printf("num=%d p-buf=%d\n",num,p-buf);
|
||||
|
||||
p=buf2;
|
||||
num=i2d_X509_CRL(nx,&p);
|
||||
printf("num=%d p-buf=%d\n",num,p-buf2);
|
||||
|
||||
if (memcmp(buf,buf2,num) != 0)
|
||||
{
|
||||
fprintf(stderr,"data difference\n");
|
||||
for (i=0; i<num; i++)
|
||||
fprintf(stderr,"%c%03d <%02X-%02X>\n",
|
||||
(buf[i] == buf2[i])?' ':'*',i,
|
||||
buf[i],buf2[i]);
|
||||
fprintf(stderr,"\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return(1);
|
||||
err:
|
||||
ERR_load_crypto_strings();
|
||||
ERR_print_errors(stderr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
main3()
|
||||
{
|
||||
FILE *in;
|
||||
unsigned char buf[10240],buf2[10240],*p;
|
||||
int num,i;
|
||||
|
||||
X509_REQ *nx=NULL,*mx=NULL;
|
||||
|
||||
in=fopen("req.der","r");
|
||||
if (in == NULL)
|
||||
{
|
||||
perror("req.der");
|
||||
exit(1);
|
||||
}
|
||||
num=fread(buf,1,10240,in);
|
||||
fclose(in);
|
||||
|
||||
|
||||
p=buf;
|
||||
if (d2i_X509_REQ(&nx,&p,num) == NULL) goto err;
|
||||
printf("num=%d p-buf=%d\n",num,p-buf);
|
||||
|
||||
p=buf2;
|
||||
num=i2d_X509_REQ(nx,&p);
|
||||
printf("num=%d p-buf=%d\n",num,p-buf2);
|
||||
|
||||
if (memcmp(buf,buf2,num) != 0)
|
||||
{
|
||||
fprintf(stderr,"data difference\n");
|
||||
for (i=0; i<num; i++)
|
||||
fprintf(stderr,"%c%03d <%02X-%02X>\n",
|
||||
(buf[i] == buf2[i])?' ':'*',i,
|
||||
buf[i],buf2[i]);
|
||||
fprintf(stderr,"\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return(1);
|
||||
err:
|
||||
ERR_load_crypto_strings();
|
||||
ERR_print_errors(stderr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
main4()
|
||||
{
|
||||
FILE *in;
|
||||
unsigned char buf[10240],buf2[10240],*p;
|
||||
int num,i;
|
||||
|
||||
RSA *nx=NULL,*mx=NULL;
|
||||
|
||||
in=fopen("rsa.der","r");
|
||||
if (in == NULL)
|
||||
{
|
||||
perror("rsa.der");
|
||||
exit(1);
|
||||
}
|
||||
num=fread(buf,1,10240,in);
|
||||
fclose(in);
|
||||
|
||||
|
||||
p=buf;
|
||||
if (d2i_RSAPrivateKey(&nx,&p,num) == NULL) goto err;
|
||||
printf("num=%d p-buf=%d\n",num,p-buf);
|
||||
|
||||
p=buf2;
|
||||
num=i2d_RSAPrivateKey(nx,&p);
|
||||
printf("num=%d p-buf=%d\n",num,p-buf2);
|
||||
|
||||
if (memcmp(buf,buf2,num) != 0)
|
||||
{
|
||||
fprintf(stderr,"data difference\n");
|
||||
for (i=0; i<num; i++)
|
||||
fprintf(stderr,"%c%03d <%02X-%02X>\n",
|
||||
(buf[i] == buf2[i])?' ':'*',i,
|
||||
buf[i],buf2[i]);
|
||||
fprintf(stderr,"\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return(1);
|
||||
err:
|
||||
ERR_load_crypto_strings();
|
||||
ERR_print_errors(stderr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
#!/usr/local/bin/perl
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
$prog="bf586.pl";
|
||||
|
||||
# base code is in microsft
|
||||
# op dest, source
|
||||
# format.
|
||||
#
|
||||
|
||||
if ( ($ARGV[0] eq "elf"))
|
||||
{ require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "a.out"))
|
||||
{ $aout=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "sol"))
|
||||
{ $sol=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "cpp"))
|
||||
{ $cpp=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "win32"))
|
||||
{ require "x86ms.pl"; }
|
||||
else
|
||||
{
|
||||
print STDERR <<"EOF";
|
||||
Pick one target type from
|
||||
elf - linux, FreeBSD etc
|
||||
a.out - old linux
|
||||
sol - x86 solaris
|
||||
cpp - format so x86unix.cpp can be used
|
||||
win32 - Windows 95/Windows NT
|
||||
EOF
|
||||
exit(1);
|
||||
}
|
||||
|
||||
&comment("Don't even think of reading this code");
|
||||
&comment("It was automatically generated by $prog");
|
||||
&comment("Which is a perl program used to generate the x86 assember for");
|
||||
&comment("any of elf, a.out, Win32, or Solaris");
|
||||
&comment("It can be found in SSLeay 0.7.0+");
|
||||
&comment("eric <eay\@cryptsoft.com>");
|
||||
&comment("");
|
||||
|
||||
&file("bfx86xxxx");
|
||||
|
||||
$BF_ROUNDS=16;
|
||||
$BF_OFF=($BF_ROUNDS+2)*4;
|
||||
$L="ecx";
|
||||
$R="edx";
|
||||
$P="edi";
|
||||
$tot="esi";
|
||||
$tmp1="eax";
|
||||
$tmp2="ebx";
|
||||
$tmp3="ebp";
|
||||
|
||||
&des_encrypt("BF_encrypt");
|
||||
|
||||
&file_end();
|
||||
|
||||
sub des_encrypt
|
||||
{
|
||||
local($name)=@_;
|
||||
|
||||
&function_begin($name,3,"");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
&mov("eax",&wparam(0));
|
||||
&mov($L,&DWP(0,"eax","",0));
|
||||
&mov($R,&DWP(4,"eax","",0));
|
||||
|
||||
&comment("");
|
||||
&comment("P pointer, s and enc flag");
|
||||
&mov($P,&wparam(1));
|
||||
|
||||
&xor( $tmp1, $tmp1);
|
||||
&xor( $tmp2, $tmp2);
|
||||
|
||||
# encrypting part
|
||||
|
||||
&mov("ebp",&wparam(2)); # get encrypt flag
|
||||
&cmp("ebp","0");
|
||||
&je(&label("start_decrypt"));
|
||||
|
||||
&xor($L,&DWP(0,$P,"",0));
|
||||
for ($i=0; $i<$BF_ROUNDS; $i+=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&BF_ENCRYPT($i+1,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
|
||||
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i+1));
|
||||
&BF_ENCRYPT($i+2,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
|
||||
}
|
||||
&xor($R,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
|
||||
|
||||
&mov("eax",&wparam(0));
|
||||
&mov(&DWP(0,"eax","",0),$R);
|
||||
&mov(&DWP(4,"eax","",0),$L);
|
||||
&function_end_A($name);
|
||||
|
||||
&set_label("start_decrypt");
|
||||
|
||||
&xor($L,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
|
||||
for ($i=$BF_ROUNDS; $i>0; $i-=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&BF_ENCRYPT($i,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i-1));
|
||||
&BF_ENCRYPT($i-1,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
|
||||
}
|
||||
&xor($R,&DWP(0,$P,"",0));
|
||||
|
||||
&mov("eax",&wparam(0));
|
||||
&mov(&DWP(0,"eax","",0),$R);
|
||||
&mov(&DWP(4,"eax","",0),$L);
|
||||
&function_end_A($name);
|
||||
|
||||
&function_end_B($name);
|
||||
}
|
||||
|
||||
sub BF_ENCRYPT
|
||||
{
|
||||
local($i,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3)=@_;
|
||||
|
||||
&rotr( $R, 16);
|
||||
&mov( $tot, &DWP(&n2a($i*4),$P,"",0));
|
||||
|
||||
&movb( &LB($tmp1), &HB($R));
|
||||
&movb( &LB($tmp2), &LB($R));
|
||||
|
||||
&rotr( $R, 16);
|
||||
&xor( $L, $tot);
|
||||
|
||||
&mov( $tot, &DWP(&n2a($BF_OFF+0x0000),$P,$tmp1,4));
|
||||
&mov( $tmp3, &DWP(&n2a($BF_OFF+0x0400),$P,$tmp2,4));
|
||||
|
||||
&movb( &LB($tmp1), &HB($R));
|
||||
&movb( &LB($tmp2), &LB($R));
|
||||
|
||||
&add( $tot, $tmp3);
|
||||
&mov( $tmp1, &DWP(&n2a($BF_OFF+0x0800),$P,$tmp1,4)); # delay
|
||||
|
||||
&xor( $tot, $tmp1);
|
||||
&mov( $tmp3, &DWP(&n2a($BF_OFF+0x0C00),$P,$tmp2,4));
|
||||
|
||||
&add( $tot, $tmp3);
|
||||
&xor( $tmp1, $tmp1);
|
||||
|
||||
&xor( $L, $tot);
|
||||
# delay
|
||||
}
|
||||
|
||||
sub n2a
|
||||
{
|
||||
sprintf("%d",$_[0]);
|
||||
}
|
||||
|
||||
@@ -1,666 +0,0 @@
|
||||
/* Don't even think of reading this code */
|
||||
/* It was automatically generated by bf586.pl */
|
||||
/* Which is a perl program used to generate the x86 assember for */
|
||||
/* any of elf, a.out, Win32, or Solaris */
|
||||
/* It can be found in SSLeay 0.7.0+ */
|
||||
/* eric <eay@cryptsoft.com> */
|
||||
|
||||
.file "bfx86xxxx.s"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.text
|
||||
.align ALIGN
|
||||
.globl BF_encrypt
|
||||
TYPE(BF_encrypt,@function)
|
||||
BF_encrypt:
|
||||
pushl %ebp
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
|
||||
|
||||
/* Load the 2 words */
|
||||
movl 20(%esp), %eax
|
||||
movl (%eax), %ecx
|
||||
movl 4(%eax), %edx
|
||||
|
||||
/* P pointer, s and enc flag */
|
||||
movl 24(%esp), %edi
|
||||
xorl %eax, %eax
|
||||
xorl %ebx, %ebx
|
||||
movl 28(%esp), %ebp
|
||||
cmpl $0, %ebp
|
||||
je .L000start_decrypt
|
||||
xorl (%edi), %ecx
|
||||
|
||||
/* Round 0 */
|
||||
rorl $16, %ecx
|
||||
movl 4(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 1 */
|
||||
rorl $16, %edx
|
||||
movl 8(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 2 */
|
||||
rorl $16, %ecx
|
||||
movl 12(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 3 */
|
||||
rorl $16, %edx
|
||||
movl 16(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 4 */
|
||||
rorl $16, %ecx
|
||||
movl 20(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 5 */
|
||||
rorl $16, %edx
|
||||
movl 24(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 6 */
|
||||
rorl $16, %ecx
|
||||
movl 28(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 7 */
|
||||
rorl $16, %edx
|
||||
movl 32(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 8 */
|
||||
rorl $16, %ecx
|
||||
movl 36(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 9 */
|
||||
rorl $16, %edx
|
||||
movl 40(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 10 */
|
||||
rorl $16, %ecx
|
||||
movl 44(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 11 */
|
||||
rorl $16, %edx
|
||||
movl 48(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 12 */
|
||||
rorl $16, %ecx
|
||||
movl 52(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 13 */
|
||||
rorl $16, %edx
|
||||
movl 56(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 14 */
|
||||
rorl $16, %ecx
|
||||
movl 60(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 15 */
|
||||
rorl $16, %edx
|
||||
movl 64(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
xorl 68(%edi), %edx
|
||||
movl 20(%esp), %eax
|
||||
movl %edx, (%eax)
|
||||
movl %ecx, 4(%eax)
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %ebp
|
||||
ret
|
||||
.align ALIGN
|
||||
.L000start_decrypt:
|
||||
xorl 68(%edi), %ecx
|
||||
|
||||
/* Round 16 */
|
||||
rorl $16, %ecx
|
||||
movl 64(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 15 */
|
||||
rorl $16, %edx
|
||||
movl 60(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 14 */
|
||||
rorl $16, %ecx
|
||||
movl 56(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 13 */
|
||||
rorl $16, %edx
|
||||
movl 52(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 12 */
|
||||
rorl $16, %ecx
|
||||
movl 48(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 11 */
|
||||
rorl $16, %edx
|
||||
movl 44(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 10 */
|
||||
rorl $16, %ecx
|
||||
movl 40(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 9 */
|
||||
rorl $16, %edx
|
||||
movl 36(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 8 */
|
||||
rorl $16, %ecx
|
||||
movl 32(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 7 */
|
||||
rorl $16, %edx
|
||||
movl 28(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 6 */
|
||||
rorl $16, %ecx
|
||||
movl 24(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 5 */
|
||||
rorl $16, %edx
|
||||
movl 20(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 4 */
|
||||
rorl $16, %ecx
|
||||
movl 16(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 3 */
|
||||
rorl $16, %edx
|
||||
movl 12(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
|
||||
/* Round 2 */
|
||||
rorl $16, %ecx
|
||||
movl 8(%edi), %esi
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
rorl $16, %ecx
|
||||
xorl %esi, %edx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %ch, %al
|
||||
movb %cl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %edx
|
||||
|
||||
/* Round 1 */
|
||||
rorl $16, %edx
|
||||
movl 4(%edi), %esi
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
rorl $16, %edx
|
||||
xorl %esi, %ecx
|
||||
movl 72(%edi,%eax,4),%esi
|
||||
movl 1096(%edi,%ebx,4),%ebp
|
||||
movb %dh, %al
|
||||
movb %dl, %bl
|
||||
addl %ebp, %esi
|
||||
movl 2120(%edi,%eax,4),%eax
|
||||
xorl %eax, %esi
|
||||
movl 3144(%edi,%ebx,4),%ebp
|
||||
addl %ebp, %esi
|
||||
xorl %eax, %eax
|
||||
xorl %esi, %ecx
|
||||
xorl (%edi), %edx
|
||||
movl 20(%esp), %eax
|
||||
movl %edx, (%eax)
|
||||
movl %ecx, 4(%eax)
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %ebp
|
||||
ret
|
||||
.BF_encrypt_end:
|
||||
SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt)
|
||||
.ident "desasm.pl"
|
||||
@@ -1,663 +0,0 @@
|
||||
; Don't even think of reading this code
|
||||
; It was automatically generated by bf586.pl
|
||||
; Which is a perl program used to generate the x86 assember for
|
||||
; any of elf, a.out, Win32, or Solaris
|
||||
; It can be found in SSLeay 0.7.0+
|
||||
; eric <eay@cryptsoft.com>
|
||||
;
|
||||
TITLE bfx86xxxx.asm
|
||||
.386
|
||||
.model FLAT
|
||||
_TEXT SEGMENT
|
||||
PUBLIC _BF_encrypt
|
||||
EXTRN _des_SPtrans:DWORD
|
||||
_BF_encrypt PROC NEAR
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
;
|
||||
; Load the 2 words
|
||||
mov eax, DWORD PTR 20[esp]
|
||||
mov ecx, DWORD PTR [eax]
|
||||
mov edx, DWORD PTR 4[eax]
|
||||
;
|
||||
; P pointer, s and enc flag
|
||||
mov edi, DWORD PTR 24[esp]
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
cmp ebp, 0
|
||||
je $L000start_decrypt
|
||||
xor ecx, DWORD PTR [edi]
|
||||
;
|
||||
; Round 0
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 4[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 1
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 8[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 2
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 12[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 3
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 16[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 4
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 20[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 5
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 24[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 6
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 28[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 7
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 32[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 8
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 36[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 9
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 40[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 10
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 44[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 11
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 48[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 12
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 52[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 13
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 56[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 14
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 60[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 15
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 64[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
xor edx, DWORD PTR 68[edi]
|
||||
mov eax, DWORD PTR 20[esp]
|
||||
mov DWORD PTR [eax],edx
|
||||
mov DWORD PTR 4[eax],ecx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
$L000start_decrypt:
|
||||
xor ecx, DWORD PTR 68[edi]
|
||||
;
|
||||
; Round 16
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 64[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 15
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 60[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 14
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 56[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 13
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 52[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 12
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 48[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 11
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 44[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 10
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 40[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 9
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 36[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 8
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 32[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 7
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 28[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 6
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 24[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 5
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 20[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 4
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 16[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 3
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 12[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
;
|
||||
; Round 2
|
||||
ror ecx, 16
|
||||
mov esi, DWORD PTR 8[edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
ror ecx, 16
|
||||
xor edx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, ch
|
||||
mov bl, cl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor edx, esi
|
||||
;
|
||||
; Round 1
|
||||
ror edx, 16
|
||||
mov esi, DWORD PTR 4[edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
ror edx, 16
|
||||
xor ecx, esi
|
||||
mov esi, DWORD PTR 72[eax*4+edi]
|
||||
mov ebp, DWORD PTR 1096[ebx*4+edi]
|
||||
mov al, dh
|
||||
mov bl, dl
|
||||
add esi, ebp
|
||||
mov eax, DWORD PTR 2120[eax*4+edi]
|
||||
xor esi, eax
|
||||
mov ebp, DWORD PTR 3144[ebx*4+edi]
|
||||
add esi, ebp
|
||||
xor eax, eax
|
||||
xor ecx, esi
|
||||
xor edx, DWORD PTR [edi]
|
||||
mov eax, DWORD PTR 20[esp]
|
||||
mov DWORD PTR [eax],edx
|
||||
mov DWORD PTR 4[eax],ecx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
_BF_encrypt ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
@@ -1,243 +0,0 @@
|
||||
/* crypto/bf/bf_local.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify bf_locl.org since bf_locl.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
/* Special defines which change the way the code is built depending on the
|
||||
CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
|
||||
even newer MIPS CPU's, but at the moment one size fits all for
|
||||
optimization options. Older Sparc's work better with only UNROLL, but
|
||||
there's no way to tell at compile time what it is you're running on */
|
||||
|
||||
#if defined( sun ) /* Newer Sparc's */
|
||||
# define BF_PTR
|
||||
#elif defined( __ultrix ) /* Older MIPS */
|
||||
# define BF_PTR
|
||||
#elif defined( __osf1__ ) /* Alpha */
|
||||
/* None */
|
||||
#elif defined ( _AIX ) /* RS6000 */
|
||||
/* Unknown */
|
||||
#elif defined( __hpux ) /* HP-PA */
|
||||
/* None */
|
||||
#elif defined( __aux ) /* 68K */
|
||||
/* Unknown */
|
||||
#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
|
||||
/* Unknown */
|
||||
#elif defined( __sgi ) /* Newer MIPS */
|
||||
# define BF_PTR
|
||||
#elif defined( i386 ) /* x86 boxes, should be gcc */
|
||||
# define BF_PTR2
|
||||
#elif defined( _MSC_VER ) /* x86 boxes, Visual C */
|
||||
# define BF_PTR2
|
||||
#endif /* Systems-specific speed defines */
|
||||
|
||||
#undef c2l
|
||||
#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
|
||||
l|=((unsigned long)(*((c)++)))<< 8L, \
|
||||
l|=((unsigned long)(*((c)++)))<<16L, \
|
||||
l|=((unsigned long)(*((c)++)))<<24L)
|
||||
|
||||
/* NOTE - c is not incremented as per c2l */
|
||||
#undef c2ln
|
||||
#define c2ln(c,l1,l2,n) { \
|
||||
c+=n; \
|
||||
l1=l2=0; \
|
||||
switch (n) { \
|
||||
case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
|
||||
case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
|
||||
case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
|
||||
case 5: l2|=((unsigned long)(*(--(c)))); \
|
||||
case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
|
||||
case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
|
||||
case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
|
||||
case 1: l1|=((unsigned long)(*(--(c)))); \
|
||||
} \
|
||||
}
|
||||
|
||||
#undef l2c
|
||||
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>24L)&0xff))
|
||||
|
||||
/* NOTE - c is not incremented as per l2c */
|
||||
#undef l2cn
|
||||
#define l2cn(l1,l2,c,n) { \
|
||||
c+=n; \
|
||||
switch (n) { \
|
||||
case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
|
||||
case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
|
||||
case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
|
||||
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
||||
case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
|
||||
case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
|
||||
case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
|
||||
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* NOTE - c is not incremented as per n2l */
|
||||
#define n2ln(c,l1,l2,n) { \
|
||||
c+=n; \
|
||||
l1=l2=0; \
|
||||
switch (n) { \
|
||||
case 8: l2 =((unsigned long)(*(--(c)))) ; \
|
||||
case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
|
||||
case 6: l2|=((unsigned long)(*(--(c))))<<16; \
|
||||
case 5: l2|=((unsigned long)(*(--(c))))<<24; \
|
||||
case 4: l1 =((unsigned long)(*(--(c)))) ; \
|
||||
case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
|
||||
case 2: l1|=((unsigned long)(*(--(c))))<<16; \
|
||||
case 1: l1|=((unsigned long)(*(--(c))))<<24; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* NOTE - c is not incremented as per l2n */
|
||||
#define l2nn(l1,l2,c,n) { \
|
||||
c+=n; \
|
||||
switch (n) { \
|
||||
case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
||||
case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
|
||||
case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
|
||||
case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
|
||||
case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
||||
case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
|
||||
case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
|
||||
case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
|
||||
} \
|
||||
}
|
||||
|
||||
#undef n2l
|
||||
#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
|
||||
l|=((unsigned long)(*((c)++)))<<16L, \
|
||||
l|=((unsigned long)(*((c)++)))<< 8L, \
|
||||
l|=((unsigned long)(*((c)++))))
|
||||
|
||||
#undef l2n
|
||||
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l) )&0xff))
|
||||
|
||||
/* This is actually a big endian algorithm, the most significate byte
|
||||
* is used to lookup array 0 */
|
||||
|
||||
/* use BF_PTR2 for intel boxes,
|
||||
* BF_PTR for sparc and MIPS/SGI
|
||||
* use nothing for Alpha and HP.
|
||||
*/
|
||||
#if !defined(BF_PTR) && !defined(BF_PTR2)
|
||||
#undef BF_PTR
|
||||
#endif
|
||||
|
||||
#define BF_M 0x3fc
|
||||
#define BF_0 22L
|
||||
#define BF_1 14L
|
||||
#define BF_2 6L
|
||||
#define BF_3 2L /* left shift */
|
||||
|
||||
#if defined(BF_PTR2)
|
||||
|
||||
/* This is basically a special pentium verson */
|
||||
#define BF_ENC(LL,R,S,P) \
|
||||
{ \
|
||||
BF_LONG t,u,v; \
|
||||
u=R>>BF_0; \
|
||||
v=R>>BF_1; \
|
||||
u&=BF_M; \
|
||||
v&=BF_M; \
|
||||
t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \
|
||||
u=R>>BF_2; \
|
||||
t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \
|
||||
v=R<<BF_3; \
|
||||
u&=BF_M; \
|
||||
v&=BF_M; \
|
||||
t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
|
||||
LL^=P; \
|
||||
t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
|
||||
LL^=t; \
|
||||
}
|
||||
|
||||
#elif defined(BF_PTR)
|
||||
|
||||
/* This is normally very good */
|
||||
|
||||
#define BF_ENC(LL,R,S,P) \
|
||||
LL^=P; \
|
||||
LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
|
||||
*(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
|
||||
*(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
|
||||
*(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M)));
|
||||
#else
|
||||
|
||||
/* This will always work, even on 64 bit machines and strangly enough,
|
||||
* on the Alpha it is faster than the pointer versions (both 32 and 64
|
||||
* versions of BF_LONG) */
|
||||
|
||||
#define BF_ENC(LL,R,S,P) \
|
||||
LL^=P; \
|
||||
LL^=((( S[ (int)(R>>24L) ] + \
|
||||
S[0x0100+((int)(R>>16L)&0xff)])^ \
|
||||
S[0x0200+((int)(R>> 8L)&0xff)])+ \
|
||||
S[0x0300+((int)(R )&0xff)])&0xffffffffL;
|
||||
#endif
|
||||
12
crypto/bn/asm/......add.c
Normal file
12
crypto/bn/asm/......add.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
{
|
||||
unsigned long a[10],b[10],c[10];
|
||||
|
||||
a[0]=0xFFFFFFFF;
|
||||
a[1]=0xFFFFFFFF;
|
||||
b[0]=0xFFFFFFFF;
|
||||
b[1]=0xFFFFFFFF;
|
||||
|
||||
c[2]=bn_add_words(c,a,b,2);
|
||||
printf("%08X %08X %08X\n",c[2],c[1],c[0]);
|
||||
}
|
||||
@@ -1,646 +0,0 @@
|
||||
.file 1 "../bn_mulw.c"
|
||||
.set nobopt
|
||||
.option pic2
|
||||
|
||||
# GNU C 2.6.3 [AL 1.1, MM 40] SGI running IRIX 5.0 compiled by GNU C
|
||||
|
||||
# Cc1 defaults:
|
||||
# -mabicalls
|
||||
|
||||
# Cc1 arguments (-G value = 0, Cpu = 3000, ISA = 1):
|
||||
# -quiet -dumpbase -O2 -o
|
||||
|
||||
gcc2_compiled.:
|
||||
__gnu_compiled_c:
|
||||
.rdata
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x34,0x39,0x20
|
||||
.byte 0x24,0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x33,0x34,0x20
|
||||
.byte 0x24,0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x35,0x20,0x24
|
||||
.byte 0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
|
||||
.byte 0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x32,0x33,0x20
|
||||
.byte 0x24,0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x37,0x38,0x20
|
||||
.byte 0x24,0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x33,0x2e,0x37,0x30,0x20
|
||||
.byte 0x24,0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x32,0x20,0x24
|
||||
.byte 0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x34,0x20,0x24
|
||||
.byte 0x0
|
||||
|
||||
.byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
|
||||
.byte 0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
|
||||
.byte 0x0
|
||||
.text
|
||||
.align 2
|
||||
.globl bn_mul_add_words
|
||||
.ent bn_mul_add_words
|
||||
bn_mul_add_words:
|
||||
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
|
||||
.mask 0x00000000,0
|
||||
.fmask 0x00000000,0
|
||||
.set noreorder
|
||||
.cpload $25
|
||||
.set reorder
|
||||
move $12,$4
|
||||
move $14,$5
|
||||
move $9,$6
|
||||
move $13,$7
|
||||
move $8,$0
|
||||
addu $10,$12,12
|
||||
addu $11,$14,12
|
||||
$L2:
|
||||
lw $6,0($14)
|
||||
#nop
|
||||
multu $13,$6
|
||||
mfhi $6
|
||||
mflo $7
|
||||
#nop
|
||||
move $5,$8
|
||||
move $4,$0
|
||||
lw $3,0($12)
|
||||
addu $9,$9,-1
|
||||
move $2,$0
|
||||
addu $7,$7,$3
|
||||
sltu $8,$7,$3
|
||||
addu $6,$6,$2
|
||||
addu $6,$6,$8
|
||||
addu $7,$7,$5
|
||||
sltu $2,$7,$5
|
||||
addu $6,$6,$4
|
||||
addu $6,$6,$2
|
||||
srl $3,$6,0
|
||||
move $2,$0
|
||||
move $8,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $9,$0,$L3
|
||||
sw $7,0($12)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $6,-8($11)
|
||||
#nop
|
||||
multu $13,$6
|
||||
mfhi $6
|
||||
mflo $7
|
||||
#nop
|
||||
move $5,$8
|
||||
move $4,$0
|
||||
lw $3,-8($10)
|
||||
addu $9,$9,-1
|
||||
move $2,$0
|
||||
addu $7,$7,$3
|
||||
sltu $8,$7,$3
|
||||
addu $6,$6,$2
|
||||
addu $6,$6,$8
|
||||
addu $7,$7,$5
|
||||
sltu $2,$7,$5
|
||||
addu $6,$6,$4
|
||||
addu $6,$6,$2
|
||||
srl $3,$6,0
|
||||
move $2,$0
|
||||
move $8,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $9,$0,$L3
|
||||
sw $7,-8($10)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $6,-4($11)
|
||||
#nop
|
||||
multu $13,$6
|
||||
mfhi $6
|
||||
mflo $7
|
||||
#nop
|
||||
move $5,$8
|
||||
move $4,$0
|
||||
lw $3,-4($10)
|
||||
addu $9,$9,-1
|
||||
move $2,$0
|
||||
addu $7,$7,$3
|
||||
sltu $8,$7,$3
|
||||
addu $6,$6,$2
|
||||
addu $6,$6,$8
|
||||
addu $7,$7,$5
|
||||
sltu $2,$7,$5
|
||||
addu $6,$6,$4
|
||||
addu $6,$6,$2
|
||||
srl $3,$6,0
|
||||
move $2,$0
|
||||
move $8,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $9,$0,$L3
|
||||
sw $7,-4($10)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $6,0($11)
|
||||
#nop
|
||||
multu $13,$6
|
||||
mfhi $6
|
||||
mflo $7
|
||||
#nop
|
||||
move $5,$8
|
||||
move $4,$0
|
||||
lw $3,0($10)
|
||||
addu $9,$9,-1
|
||||
move $2,$0
|
||||
addu $7,$7,$3
|
||||
sltu $8,$7,$3
|
||||
addu $6,$6,$2
|
||||
addu $6,$6,$8
|
||||
addu $7,$7,$5
|
||||
sltu $2,$7,$5
|
||||
addu $6,$6,$4
|
||||
addu $6,$6,$2
|
||||
srl $3,$6,0
|
||||
move $2,$0
|
||||
move $8,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $9,$0,$L3
|
||||
sw $7,0($10)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
addu $11,$11,16
|
||||
addu $14,$14,16
|
||||
addu $10,$10,16
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $L2
|
||||
addu $12,$12,16
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
$L3:
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $31
|
||||
move $2,$8
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
.end bn_mul_add_words
|
||||
.align 2
|
||||
.globl bn_mul_words
|
||||
.ent bn_mul_words
|
||||
bn_mul_words:
|
||||
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
|
||||
.mask 0x00000000,0
|
||||
.fmask 0x00000000,0
|
||||
.set noreorder
|
||||
.cpload $25
|
||||
.set reorder
|
||||
move $11,$4
|
||||
move $12,$5
|
||||
move $8,$6
|
||||
move $6,$0
|
||||
addu $10,$11,12
|
||||
addu $9,$12,12
|
||||
$L10:
|
||||
lw $4,0($12)
|
||||
#nop
|
||||
multu $7,$4
|
||||
mfhi $4
|
||||
mflo $5
|
||||
#nop
|
||||
move $3,$6
|
||||
move $2,$0
|
||||
addu $8,$8,-1
|
||||
addu $5,$5,$3
|
||||
sltu $6,$5,$3
|
||||
addu $4,$4,$2
|
||||
addu $4,$4,$6
|
||||
srl $3,$4,0
|
||||
move $2,$0
|
||||
move $6,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $8,$0,$L11
|
||||
sw $5,0($11)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $4,-8($9)
|
||||
#nop
|
||||
multu $7,$4
|
||||
mfhi $4
|
||||
mflo $5
|
||||
#nop
|
||||
move $3,$6
|
||||
move $2,$0
|
||||
addu $8,$8,-1
|
||||
addu $5,$5,$3
|
||||
sltu $6,$5,$3
|
||||
addu $4,$4,$2
|
||||
addu $4,$4,$6
|
||||
srl $3,$4,0
|
||||
move $2,$0
|
||||
move $6,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $8,$0,$L11
|
||||
sw $5,-8($10)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $4,-4($9)
|
||||
#nop
|
||||
multu $7,$4
|
||||
mfhi $4
|
||||
mflo $5
|
||||
#nop
|
||||
move $3,$6
|
||||
move $2,$0
|
||||
addu $8,$8,-1
|
||||
addu $5,$5,$3
|
||||
sltu $6,$5,$3
|
||||
addu $4,$4,$2
|
||||
addu $4,$4,$6
|
||||
srl $3,$4,0
|
||||
move $2,$0
|
||||
move $6,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $8,$0,$L11
|
||||
sw $5,-4($10)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $4,0($9)
|
||||
#nop
|
||||
multu $7,$4
|
||||
mfhi $4
|
||||
mflo $5
|
||||
#nop
|
||||
move $3,$6
|
||||
move $2,$0
|
||||
addu $8,$8,-1
|
||||
addu $5,$5,$3
|
||||
sltu $6,$5,$3
|
||||
addu $4,$4,$2
|
||||
addu $4,$4,$6
|
||||
srl $3,$4,0
|
||||
move $2,$0
|
||||
move $6,$3
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $8,$0,$L11
|
||||
sw $5,0($10)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
addu $9,$9,16
|
||||
addu $12,$12,16
|
||||
addu $10,$10,16
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $L10
|
||||
addu $11,$11,16
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
$L11:
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $31
|
||||
move $2,$6
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
.end bn_mul_words
|
||||
.align 2
|
||||
.globl bn_sqr_words
|
||||
.ent bn_sqr_words
|
||||
bn_sqr_words:
|
||||
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
|
||||
.mask 0x00000000,0
|
||||
.fmask 0x00000000,0
|
||||
.set noreorder
|
||||
.cpload $25
|
||||
.set reorder
|
||||
move $9,$4
|
||||
addu $7,$9,28
|
||||
addu $8,$5,12
|
||||
$L18:
|
||||
lw $2,0($5)
|
||||
#nop
|
||||
multu $2,$2
|
||||
mfhi $2
|
||||
mflo $3
|
||||
#nop
|
||||
addu $6,$6,-1
|
||||
sw $3,0($9)
|
||||
srl $3,$2,0
|
||||
move $2,$0
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $6,$0,$L19
|
||||
sw $3,-24($7)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $2,-8($8)
|
||||
#nop
|
||||
multu $2,$2
|
||||
mfhi $2
|
||||
mflo $3
|
||||
#nop
|
||||
addu $6,$6,-1
|
||||
sw $3,-20($7)
|
||||
srl $3,$2,0
|
||||
move $2,$0
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $6,$0,$L19
|
||||
sw $3,-16($7)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $2,-4($8)
|
||||
#nop
|
||||
multu $2,$2
|
||||
mfhi $2
|
||||
mflo $3
|
||||
#nop
|
||||
addu $6,$6,-1
|
||||
sw $3,-12($7)
|
||||
srl $3,$2,0
|
||||
move $2,$0
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $6,$0,$L19
|
||||
sw $3,-8($7)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
lw $2,0($8)
|
||||
#nop
|
||||
multu $2,$2
|
||||
mfhi $2
|
||||
mflo $3
|
||||
#nop
|
||||
addu $6,$6,-1
|
||||
sw $3,-4($7)
|
||||
srl $3,$2,0
|
||||
move $2,$0
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $6,$0,$L19
|
||||
sw $3,0($7)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
addu $8,$8,16
|
||||
addu $5,$5,16
|
||||
addu $7,$7,32
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $L18
|
||||
addu $9,$9,32
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
$L19:
|
||||
j $31
|
||||
.end bn_sqr_words
|
||||
.rdata
|
||||
.align 2
|
||||
$LC0:
|
||||
|
||||
.byte 0x44,0x69,0x76,0x69,0x73,0x69,0x6f,0x6e
|
||||
.byte 0x20,0x77,0x6f,0x75,0x6c,0x64,0x20,0x6f
|
||||
.byte 0x76,0x65,0x72,0x66,0x6c,0x6f,0x77,0xa
|
||||
.byte 0x0
|
||||
.text
|
||||
.align 2
|
||||
.globl bn_div64
|
||||
.ent bn_div64
|
||||
bn_div64:
|
||||
.frame $sp,56,$31 # vars= 0, regs= 7/0, args= 16, extra= 8
|
||||
.mask 0x901f0000,-8
|
||||
.fmask 0x00000000,0
|
||||
.set noreorder
|
||||
.cpload $25
|
||||
.set reorder
|
||||
subu $sp,$sp,56
|
||||
.cprestore 16
|
||||
sw $16,24($sp)
|
||||
move $16,$4
|
||||
sw $17,28($sp)
|
||||
move $17,$5
|
||||
sw $18,32($sp)
|
||||
move $18,$6
|
||||
sw $20,40($sp)
|
||||
move $20,$0
|
||||
sw $19,36($sp)
|
||||
li $19,0x00000002 # 2
|
||||
sw $31,48($sp)
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
bne $18,$0,$L26
|
||||
sw $28,44($sp)
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $L43
|
||||
li $2,-1 # 0xffffffff
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
$L26:
|
||||
move $4,$18
|
||||
jal BN_num_bits_word
|
||||
move $4,$2
|
||||
li $2,0x00000020 # 32
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $4,$2,$L27
|
||||
li $2,0x00000001 # 1
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
sll $2,$2,$4
|
||||
sltu $2,$2,$16
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $2,$0,$L44
|
||||
li $5,0x00000020 # 32
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
la $4,__iob+32
|
||||
la $5,$LC0
|
||||
jal fprintf
|
||||
jal abort
|
||||
$L27:
|
||||
li $5,0x00000020 # 32
|
||||
$L44:
|
||||
sltu $2,$16,$18
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
bne $2,$0,$L28
|
||||
subu $4,$5,$4
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
subu $16,$16,$18
|
||||
$L28:
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $4,$0,$L29
|
||||
li $10,-65536 # 0xffff0000
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
sll $18,$18,$4
|
||||
sll $3,$16,$4
|
||||
subu $2,$5,$4
|
||||
srl $2,$17,$2
|
||||
or $16,$3,$2
|
||||
sll $17,$17,$4
|
||||
$L29:
|
||||
srl $7,$18,16
|
||||
andi $9,$18,0xffff
|
||||
$L30:
|
||||
srl $2,$16,16
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $2,$7,$L34
|
||||
li $6,0x0000ffff # 65535
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
divu $6,$16,$7
|
||||
$L34:
|
||||
mult $6,$9
|
||||
mflo $5
|
||||
#nop
|
||||
#nop
|
||||
mult $6,$7
|
||||
and $2,$17,$10
|
||||
srl $8,$2,16
|
||||
mflo $4
|
||||
$L35:
|
||||
subu $3,$16,$4
|
||||
and $2,$3,$10
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
bne $2,$0,$L36
|
||||
sll $2,$3,16
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
addu $2,$2,$8
|
||||
sltu $2,$2,$5
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $2,$0,$L36
|
||||
subu $5,$5,$9
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
subu $4,$4,$7
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $L35
|
||||
addu $6,$6,-1
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
$L36:
|
||||
mult $6,$7
|
||||
mflo $5
|
||||
#nop
|
||||
#nop
|
||||
mult $6,$9
|
||||
mflo $4
|
||||
#nop
|
||||
#nop
|
||||
srl $3,$4,16
|
||||
sll $2,$4,16
|
||||
and $4,$2,$10
|
||||
sltu $2,$17,$4
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $2,$0,$L40
|
||||
addu $5,$5,$3
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
addu $5,$5,1
|
||||
$L40:
|
||||
sltu $2,$16,$5
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $2,$0,$L41
|
||||
subu $17,$17,$4
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
addu $16,$16,$18
|
||||
addu $6,$6,-1
|
||||
$L41:
|
||||
addu $19,$19,-1
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
beq $19,$0,$L31
|
||||
subu $16,$16,$5
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
sll $20,$6,16
|
||||
sll $3,$16,16
|
||||
srl $2,$17,16
|
||||
or $16,$3,$2
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
j $L30
|
||||
sll $17,$17,16
|
||||
.set macro
|
||||
.set reorder
|
||||
|
||||
$L31:
|
||||
or $2,$20,$6
|
||||
$L43:
|
||||
lw $31,48($sp)
|
||||
lw $20,40($sp)
|
||||
lw $19,36($sp)
|
||||
lw $18,32($sp)
|
||||
lw $17,28($sp)
|
||||
lw $16,24($sp)
|
||||
addu $sp,$sp,56
|
||||
j $31
|
||||
.end bn_div64
|
||||
|
||||
.globl abort .text
|
||||
.globl fprintf .text
|
||||
.globl BN_num_bits_word .text
|
||||
@@ -1,272 +0,0 @@
|
||||
.file "bn_mulw.c"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.text
|
||||
.align 4
|
||||
.globl _bn_mul_add_word
|
||||
_bn_mul_add_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
# ax L(t)
|
||||
# dx H(t)
|
||||
# bx a
|
||||
# cx w
|
||||
# di r
|
||||
# si c
|
||||
# bp num
|
||||
xorl %esi,%esi # c=0
|
||||
movl 20(%esp),%edi # r => edi
|
||||
movl 24(%esp),%ebx # a => exb
|
||||
movl 32(%esp),%ecx # w => ecx
|
||||
movl 28(%esp),%ebp # num => ebp
|
||||
|
||||
shrl $2,%ebp # num/4
|
||||
je .L910
|
||||
|
||||
# .align 4
|
||||
.L110:
|
||||
# Round 1
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl (%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+= carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 2
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl 4(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+= carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 3
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl 8(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 4
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 12(%ebx) # w * *a
|
||||
addl 12(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,12(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
addl $16,%ebx # a+=4 (4 words)
|
||||
addl $16,%edi # r+=4 (4 words)
|
||||
|
||||
decl %ebp # --num
|
||||
je .L910
|
||||
jmp .L110
|
||||
# .align 4
|
||||
.L910:
|
||||
movl 28(%esp),%ebp # num => ebp
|
||||
andl $3,%ebp
|
||||
je .L111
|
||||
|
||||
# Round 1
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl (%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L111
|
||||
|
||||
# Round 2
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl 4(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L111
|
||||
|
||||
# Round 3
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl 8(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# .align 4
|
||||
.L111:
|
||||
movl %esi,%eax # return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe1:
|
||||
.align 4
|
||||
.globl _bn_mul_word
|
||||
_bn_mul_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
# ax L(t)
|
||||
# dx H(t)
|
||||
# bx a
|
||||
# cx w
|
||||
# di r
|
||||
# num bp
|
||||
# si c
|
||||
xorl %esi,%esi # c=0
|
||||
movl 20(%esp),%edi # r => edi
|
||||
movl 24(%esp),%ebx # a => exb
|
||||
movl 28(%esp),%ebp # num => bp
|
||||
movl 32(%esp),%ecx # w => ecx
|
||||
|
||||
# .align 4
|
||||
.L210:
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 12(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,12(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
addl $16,%ebx # a+=4 (4 words)
|
||||
addl $16,%edi # r+=4 (4 words)
|
||||
|
||||
jmp .L210
|
||||
# .align 4
|
||||
.L211:
|
||||
movl %esi,%eax # return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe2:
|
||||
.align 4
|
||||
.globl _bn_sqr_words
|
||||
_bn_sqr_words:
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
movl 16(%esp),%esi # r
|
||||
movl 20(%esp),%edi # a
|
||||
movl 24(%esp),%ebx # n
|
||||
# .align 4
|
||||
shrl $2,%ebx
|
||||
jz .L99
|
||||
.L28:
|
||||
movl (%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,(%esi) # put low into return addr
|
||||
movl %edx,4(%esi) # put high into return addr
|
||||
|
||||
movl 4(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,8(%esi) # put low into return addr
|
||||
movl %edx,12(%esi) # put high into return addr
|
||||
|
||||
movl 8(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,16(%esi) # put low into return addr
|
||||
movl %edx,20(%esi) # put high into return addr
|
||||
|
||||
movl 12(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,24(%esi) # put low into return addr
|
||||
movl %edx,28(%esi) # put high into return addr
|
||||
|
||||
addl $16,%edi
|
||||
addl $32,%esi
|
||||
decl %ebx # n-=4;
|
||||
jz .L99
|
||||
jmp .L28
|
||||
# .align 4
|
||||
.L99:
|
||||
movl 24(%esp),%ebx # n
|
||||
andl $3,%ebx
|
||||
jz .L29
|
||||
movl (%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,(%esi) # put low into return addr
|
||||
movl %edx,4(%esi) # put high into return addr
|
||||
decl %ebx # n--;
|
||||
jz .L29
|
||||
movl 4(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,8(%esi) # put low into return addr
|
||||
movl %edx,12(%esi) # put high into return addr
|
||||
decl %ebx # n--;
|
||||
jz .L29
|
||||
movl 8(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,16(%esi) # put low into return addr
|
||||
movl %edx,20(%esi) # put high into return addr
|
||||
|
||||
.L29:
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
.Lfe3:
|
||||
.align 4
|
||||
.globl _bn_div64
|
||||
_bn_div64:
|
||||
movl 4(%esp),%edx # a
|
||||
movl 8(%esp),%eax # b
|
||||
divl 12(%esp) # ab/c
|
||||
ret
|
||||
.Lfe4:
|
||||
.ident "GCC: (GNU) 2.6.3"
|
||||
@@ -1,282 +0,0 @@
|
||||
.file "bn_mulw.c"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.text
|
||||
.align 16
|
||||
.globl bn_mul_add_word
|
||||
.type bn_mul_add_word,@function
|
||||
bn_mul_add_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
# ax L(t)
|
||||
# dx H(t)
|
||||
# bx a
|
||||
# cx w
|
||||
# di r
|
||||
# si c
|
||||
# bp num
|
||||
xorl %esi,%esi # c=0
|
||||
movl 20(%esp),%edi # r => edi
|
||||
movl 24(%esp),%ebx # a => exb
|
||||
movl 32(%esp),%ecx # w => ecx
|
||||
movl 28(%esp),%ebp # num => ebp
|
||||
|
||||
shrl $2,%ebp # num/4
|
||||
je .L910
|
||||
|
||||
.align 4
|
||||
.L110:
|
||||
# Round 1
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl (%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+= carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 2
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl 4(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+= carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 3
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl 8(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 4
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 12(%ebx) # w * *a
|
||||
addl 12(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,12(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
addl $16,%ebx # a+=4 (4 words)
|
||||
addl $16,%edi # r+=4 (4 words)
|
||||
|
||||
decl %ebp # --num
|
||||
je .L910
|
||||
jmp .L110
|
||||
.align 4
|
||||
.L910:
|
||||
movl 28(%esp),%ebp # num => ebp
|
||||
andl $3,%ebp
|
||||
je .L111
|
||||
|
||||
# Round 1
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl (%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L111
|
||||
|
||||
# Round 2
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl 4(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L111
|
||||
|
||||
# Round 3
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl 8(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
.align 4
|
||||
.L111:
|
||||
movl %esi,%eax # return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe1:
|
||||
.size bn_mul_add_word,.Lfe1-bn_mul_add_word
|
||||
.align 16
|
||||
.globl bn_mul_word
|
||||
.type bn_mul_word,@function
|
||||
bn_mul_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
# ax L(t)
|
||||
# dx H(t)
|
||||
# bx a
|
||||
# cx w
|
||||
# di r
|
||||
# num bp
|
||||
# si c
|
||||
xorl %esi,%esi # c=0
|
||||
movl 20(%esp),%edi # r => edi
|
||||
movl 24(%esp),%ebx # a => exb
|
||||
movl 28(%esp),%ebp # num => bp
|
||||
movl 32(%esp),%ecx # w => ecx
|
||||
|
||||
.align 4
|
||||
.L210:
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 12(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,12(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
addl $16,%ebx # a+=4 (4 words)
|
||||
addl $16,%edi # r+=4 (4 words)
|
||||
|
||||
jmp .L210
|
||||
.align 16
|
||||
.L211:
|
||||
movl %esi,%eax # return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe2:
|
||||
.size bn_mul_word,.Lfe2-bn_mul_word
|
||||
|
||||
.align 16
|
||||
.globl bn_sqr_words
|
||||
.type bn_sqr_words,@function
|
||||
bn_sqr_words:
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
movl 16(%esp),%esi # r
|
||||
movl 20(%esp),%edi # a
|
||||
movl 24(%esp),%ebx # n
|
||||
.align 4
|
||||
shrl $2,%ebx
|
||||
jz .L99
|
||||
.L28:
|
||||
movl (%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,(%esi) # put low into return addr
|
||||
movl %edx,4(%esi) # put high into return addr
|
||||
|
||||
movl 4(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,8(%esi) # put low into return addr
|
||||
movl %edx,12(%esi) # put high into return addr
|
||||
|
||||
movl 8(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,16(%esi) # put low into return addr
|
||||
movl %edx,20(%esi) # put high into return addr
|
||||
|
||||
movl 12(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,24(%esi) # put low into return addr
|
||||
movl %edx,28(%esi) # put high into return addr
|
||||
|
||||
addl $16,%edi
|
||||
addl $32,%esi
|
||||
decl %ebx # n-=4;
|
||||
jz .L99
|
||||
jmp .L28
|
||||
.align 16
|
||||
.L99:
|
||||
movl 24(%esp),%ebx # n
|
||||
andl $3,%ebx
|
||||
jz .L29
|
||||
movl (%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,(%esi) # put low into return addr
|
||||
movl %edx,4(%esi) # put high into return addr
|
||||
decl %ebx # n--;
|
||||
jz .L29
|
||||
movl 4(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,8(%esi) # put low into return addr
|
||||
movl %edx,12(%esi) # put high into return addr
|
||||
decl %ebx # n--;
|
||||
jz .L29
|
||||
movl 8(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,16(%esi) # put low into return addr
|
||||
movl %edx,20(%esi) # put high into return addr
|
||||
|
||||
.L29:
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
.Lfe3:
|
||||
.size bn_sqr_words,.Lfe3-bn_sqr_words
|
||||
|
||||
.align 16
|
||||
.globl bn_div64
|
||||
.type bn_div64,@function
|
||||
bn_div64:
|
||||
movl 4(%esp),%edx # a
|
||||
movl 8(%esp),%eax # b
|
||||
divl 12(%esp) # ab/c
|
||||
ret
|
||||
.Lfe4:
|
||||
.size bn_div64,.Lfe4-bn_div64
|
||||
.ident "GCC: (GNU) 2.6.3"
|
||||
@@ -1,282 +0,0 @@
|
||||
.file "bn_mulw.c"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.text
|
||||
.align 4
|
||||
.globl _bn_mul_add_word
|
||||
.type _bn_mul_add_word,@function
|
||||
_bn_mul_add_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
# ax L(t)
|
||||
# dx H(t)
|
||||
# bx a
|
||||
# cx w
|
||||
# di r
|
||||
# si c
|
||||
# bp num
|
||||
xorl %esi,%esi # c=0
|
||||
movl 20(%esp),%edi # r => edi
|
||||
movl 24(%esp),%ebx # a => exb
|
||||
movl 32(%esp),%ecx # w => ecx
|
||||
movl 28(%esp),%ebp # num => ebp
|
||||
|
||||
shrl $2,%ebp # num/4
|
||||
je .L910
|
||||
|
||||
# .align 4
|
||||
.L110:
|
||||
# Round 1
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl (%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+= carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 2
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl 4(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+= carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 3
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl 8(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# Round 4
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 12(%ebx) # w * *a
|
||||
addl 12(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,12(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
addl $16,%ebx # a+=4 (4 words)
|
||||
addl $16,%edi # r+=4 (4 words)
|
||||
|
||||
decl %ebp # --num
|
||||
je .L910
|
||||
jmp .L110
|
||||
# .align 4
|
||||
.L910:
|
||||
movl 28(%esp),%ebp # num => ebp
|
||||
andl $3,%ebp
|
||||
je .L111
|
||||
|
||||
# Round 1
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl (%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L111
|
||||
|
||||
# Round 2
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl 4(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L111
|
||||
|
||||
# Round 3
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl 8(%edi),%eax # *r+=L(t)
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r+=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
|
||||
# .align 4
|
||||
.L111:
|
||||
movl %esi,%eax # return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe1:
|
||||
.size _bn_mul_add_word,.Lfe1-_bn_mul_add_word
|
||||
.align 4
|
||||
.globl _bn_mul_word
|
||||
.type _bn_mul_word,@function
|
||||
_bn_mul_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
# ax L(t)
|
||||
# dx H(t)
|
||||
# bx a
|
||||
# cx w
|
||||
# di r
|
||||
# num bp
|
||||
# si c
|
||||
xorl %esi,%esi # c=0
|
||||
movl 20(%esp),%edi # r => edi
|
||||
movl 24(%esp),%ebx # a => exb
|
||||
movl 28(%esp),%ebp # num => bp
|
||||
movl 32(%esp),%ecx # w => ecx
|
||||
|
||||
# .align 4
|
||||
.L210:
|
||||
movl %ecx,%eax # w => eax
|
||||
mull (%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 4(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,4(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 8(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,8(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax # w => eax
|
||||
mull 12(%ebx) # w * *a
|
||||
addl %esi,%eax # L(t)+=c
|
||||
adcl $0,%edx # H(t)+=carry
|
||||
movl %eax,12(%edi) # *r=L(t)
|
||||
movl %edx,%esi # c=H(t)
|
||||
decl %ebp # --num
|
||||
je .L211
|
||||
|
||||
addl $16,%ebx # a+=4 (4 words)
|
||||
addl $16,%edi # r+=4 (4 words)
|
||||
|
||||
jmp .L210
|
||||
# .align 4
|
||||
.L211:
|
||||
movl %esi,%eax # return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe2:
|
||||
.size _bn_mul_word,.Lfe2-_bn_mul_word
|
||||
|
||||
.align 4
|
||||
.globl _bn_sqr_words
|
||||
.type _bn_sqr_words,@function
|
||||
_bn_sqr_words:
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
movl 16(%esp),%esi # r
|
||||
movl 20(%esp),%edi # a
|
||||
movl 24(%esp),%ebx # n
|
||||
# .align 4
|
||||
shrl $2,%ebx
|
||||
jz .L99
|
||||
.L28:
|
||||
movl (%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,(%esi) # put low into return addr
|
||||
movl %edx,4(%esi) # put high into return addr
|
||||
|
||||
movl 4(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,8(%esi) # put low into return addr
|
||||
movl %edx,12(%esi) # put high into return addr
|
||||
|
||||
movl 8(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,16(%esi) # put low into return addr
|
||||
movl %edx,20(%esi) # put high into return addr
|
||||
|
||||
movl 12(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,24(%esi) # put low into return addr
|
||||
movl %edx,28(%esi) # put high into return addr
|
||||
|
||||
addl $16,%edi
|
||||
addl $32,%esi
|
||||
decl %ebx # n-=4;
|
||||
jz .L99
|
||||
jmp .L28
|
||||
# .align 4
|
||||
.L99:
|
||||
movl 24(%esp),%ebx # n
|
||||
andl $3,%ebx
|
||||
jz .L29
|
||||
movl (%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,(%esi) # put low into return addr
|
||||
movl %edx,4(%esi) # put high into return addr
|
||||
decl %ebx # n--;
|
||||
jz .L29
|
||||
movl 4(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,8(%esi) # put low into return addr
|
||||
movl %edx,12(%esi) # put high into return addr
|
||||
decl %ebx # n--;
|
||||
jz .L29
|
||||
movl 8(%edi),%eax # get a
|
||||
mull %eax # a*a
|
||||
movl %eax,16(%esi) # put low into return addr
|
||||
movl %edx,20(%esi) # put high into return addr
|
||||
|
||||
.L29:
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
.Lfe3:
|
||||
.size _bn_sqr_words,.Lfe3-_bn_sqr_words
|
||||
|
||||
.align 4
|
||||
.globl _bn_div64
|
||||
.type _bn_div64,@function
|
||||
_bn_div64:
|
||||
movl 4(%esp),%edx # a
|
||||
movl 8(%esp),%eax # b
|
||||
divl 12(%esp) # ab/c
|
||||
ret
|
||||
.Lfe4:
|
||||
.size _bn_div64,.Lfe4-_bn_div64
|
||||
.ident "GCC: (GNU) 2.6.3"
|
||||
@@ -1,224 +0,0 @@
|
||||
.file "bn_mulw.c"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.text
|
||||
.align 16
|
||||
.globl bn_mul_add_word
|
||||
.type bn_mul_add_word,@function
|
||||
bn_mul_add_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
/ ax L(t)
|
||||
/ dx H(t)
|
||||
/ bx a
|
||||
/ cx w
|
||||
/ di r
|
||||
/ si c
|
||||
/ bp num
|
||||
xorl %esi,%esi / c=0
|
||||
movl 20(%esp),%edi / r => edi
|
||||
movl 24(%esp),%ebx / a => exb
|
||||
movl 28(%esp),%ebp / num => ebp
|
||||
movl 32(%esp),%ecx / w => ecx
|
||||
|
||||
.align 4
|
||||
.L110:
|
||||
movl %ecx,%eax / w => eax
|
||||
mull (%ebx) / w * *a
|
||||
addl (%edi),%eax / L(t)+= *r
|
||||
adcl $0,%edx / H(t)+= carry
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L111
|
||||
|
||||
movl %ecx,%eax / w => eax
|
||||
mull 4(%ebx) / w * *a
|
||||
addl 4(%edi),%eax / L(t)+= *r
|
||||
adcl $0,%edx / H(t)+= carry
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,4(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L111
|
||||
|
||||
movl %ecx,%eax / w => eax
|
||||
mull 8(%ebx) / w * *a
|
||||
addl 8(%edi),%eax / L(t)+= *r
|
||||
adcl $0,%edx / H(t)+= carry
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,8(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L111
|
||||
|
||||
movl %ecx,%eax / w => eax
|
||||
mull 12(%ebx) / w * *a
|
||||
addl 12(%edi),%eax / L(t)+= *r
|
||||
adcl $0,%edx / H(t)+= carry
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,12(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L111
|
||||
|
||||
addl $16,%ebx / a+=4 (4 words)
|
||||
addl $16,%edi / r+=4 (4 words)
|
||||
|
||||
jmp .L110
|
||||
.align 16
|
||||
.L111:
|
||||
movl %esi,%eax / return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe1:
|
||||
.size bn_mul_add_word,.Lfe1-bn_mul_add_word
|
||||
.align 16
|
||||
.globl bn_mul_word
|
||||
.type bn_mul_word,@function
|
||||
bn_mul_word:
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
/ ax L(t)
|
||||
/ dx H(t)
|
||||
/ bx a
|
||||
/ cx w
|
||||
/ di r
|
||||
/ num bp
|
||||
/ si c
|
||||
xorl %esi,%esi / c=0
|
||||
movl 20(%esp),%edi / r => edi
|
||||
movl 24(%esp),%ebx / a => exb
|
||||
movl 28(%esp),%ebp / num => ebp
|
||||
movl 32(%esp),%ecx / w => ecx
|
||||
|
||||
.align 4
|
||||
.L210:
|
||||
movl %ecx,%eax / w => eax
|
||||
mull (%ebx) / w * *a
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax / w => eax
|
||||
mull 4(%ebx) / w * *a
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,4(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax / w => eax
|
||||
mull 8(%ebx) / w * *a
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,8(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L211
|
||||
|
||||
movl %ecx,%eax / w => eax
|
||||
mull 12(%ebx) / w * *a
|
||||
addl %esi,%eax / L(t)+=c
|
||||
adcl $0,%edx / H(t)+=carry
|
||||
movl %eax,12(%edi) / *r=L(t)
|
||||
movl %edx,%esi / c=H(t)
|
||||
decl %ebp / --num
|
||||
je .L211
|
||||
|
||||
addl $16,%ebx / a+=4 (4 words)
|
||||
addl $16,%edi / r+=4 (4 words)
|
||||
|
||||
jmp .L210
|
||||
.align 16
|
||||
.L211:
|
||||
movl %esi,%eax / return(c)
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe2:
|
||||
.size bn_mul_word,.Lfe2-bn_mul_word
|
||||
|
||||
.align 16
|
||||
.globl bn_sqr_words
|
||||
.type bn_sqr_words,@function
|
||||
bn_sqr_words:
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
movl 16(%esp),%esi / r
|
||||
movl 20(%esp),%edi / a
|
||||
movl 24(%esp),%ebx / n
|
||||
.align 4
|
||||
.L28:
|
||||
movl (%edi),%eax / get a
|
||||
mull %eax / a*a
|
||||
movl %eax,(%esi) / put low into return addr
|
||||
movl %edx,4(%esi) / put high into return addr
|
||||
decl %ebx / n--;
|
||||
je .L29
|
||||
|
||||
movl 4(%edi),%eax / get a
|
||||
mull %eax / a*a
|
||||
movl %eax,8(%esi) / put low into return addr
|
||||
movl %edx,12(%esi) / put high into return addr
|
||||
decl %ebx / n--;
|
||||
je .L29
|
||||
|
||||
movl 8(%edi),%eax / get a
|
||||
mull %eax / a*a
|
||||
movl %eax,16(%esi) / put low into return addr
|
||||
movl %edx,20(%esi) / put high into return addr
|
||||
decl %ebx / n--;
|
||||
je .L29
|
||||
|
||||
movl 12(%edi),%eax / get a
|
||||
mull %eax / a*a
|
||||
movl %eax,24(%esi) / put low into return addr
|
||||
movl %edx,28(%esi) / put high into return addr
|
||||
decl %ebx / n--;
|
||||
je .L29
|
||||
|
||||
addl $16,%edi
|
||||
addl $32,%esi
|
||||
jmp .L28
|
||||
.align 16
|
||||
.L29:
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
.Lfe3:
|
||||
.size bn_sqr_words,.Lfe3-bn_sqr_words
|
||||
|
||||
.align 16
|
||||
.globl bn_div64
|
||||
.type bn_div64,@function
|
||||
bn_div64:
|
||||
movl 4(%esp),%edx / a
|
||||
movl 8(%esp),%eax / b
|
||||
divl 12(%esp) / ab/c
|
||||
ret
|
||||
.Lfe4:
|
||||
.size bn_div64,.Lfe4-bn_div64
|
||||
.ident "GCC: (GNU) 2.6.3"
|
||||
@@ -1,288 +0,0 @@
|
||||
TITLE bn_mulw.c
|
||||
.386P
|
||||
.model FLAT
|
||||
PUBLIC _bn_mul_add_word
|
||||
_TEXT SEGMENT
|
||||
; File bn_mulw.c
|
||||
_bn_mul_add_word PROC NEAR
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
mov edi,DWORD PTR 20[esp] ; r
|
||||
mov ebx,DWORD PTR 24[esp] ; a
|
||||
mov ecx,DWORD PTR 32[esp] ; w
|
||||
xor esi,esi ; c=0
|
||||
|
||||
mov ebp,DWORD PTR 28[esp] ; num
|
||||
shr ebp,2 ; num/4
|
||||
jz $L666
|
||||
|
||||
$L546:
|
||||
; Round one
|
||||
mov eax,DWORD PTR [ebx] ; edx:eax = *a * w
|
||||
mul ecx
|
||||
add eax,DWORD PTR [edi] ; *r+=ax
|
||||
adc edx,0
|
||||
add eax,esi ; edx:eax += c
|
||||
adc edx,0
|
||||
mov DWORD PTR [edi],eax ; *r+=ax
|
||||
mov esi,edx ; c = overflow
|
||||
|
||||
; Round two
|
||||
mov eax,DWORD PTR 4[ebx] ; edx:eax = *a * w
|
||||
mul ecx
|
||||
add eax,DWORD PTR 4[edi] ; *r+=ax
|
||||
adc edx,0
|
||||
add eax,esi ; edx:eax += c
|
||||
adc edx,0
|
||||
mov DWORD PTR 4[edi],eax ; *r+=ax
|
||||
mov esi,edx ; c = overflow
|
||||
|
||||
; Round three
|
||||
mov eax,DWORD PTR 8[ebx] ; edx:eax = *a * w
|
||||
mul ecx
|
||||
add eax,DWORD PTR 8[edi] ; *r+=ax
|
||||
adc edx,0
|
||||
add eax,esi ; edx:eax += c
|
||||
adc edx,0
|
||||
mov DWORD PTR 8[edi],eax ; *r+=ax
|
||||
mov esi,edx ; c = overflow
|
||||
|
||||
; Round four
|
||||
mov eax,DWORD PTR 12[ebx] ; edx:eax = *a * w
|
||||
mul ecx
|
||||
add eax,DWORD PTR 12[edi] ; *r+=ax
|
||||
adc edx,0
|
||||
add eax,esi ; edx:eax += c
|
||||
adc edx,0
|
||||
mov DWORD PTR 12[edi],eax ; *r+=ax
|
||||
mov esi,edx ; c = overflow
|
||||
|
||||
add ebx,16
|
||||
add edi,16
|
||||
|
||||
dec ebp
|
||||
jz $L666
|
||||
jmp $L546
|
||||
$L666:
|
||||
mov ebp,DWORD PTR 28[esp] ; num
|
||||
and ebp,3 ; num%4
|
||||
jz $L547
|
||||
|
||||
; Round one
|
||||
mov eax,DWORD PTR [ebx] ; edx:eax = *a * w
|
||||
mul ecx
|
||||
add eax,DWORD PTR [edi] ; *r+=ax
|
||||
adc edx,0
|
||||
add eax,esi ; edx:eax += c
|
||||
adc edx,0
|
||||
mov DWORD PTR [edi],eax ; *r+=ax
|
||||
mov esi,edx ; c = overflow
|
||||
dec ebp
|
||||
jz $L547
|
||||
; Round two
|
||||
mov eax,DWORD PTR 4[ebx] ; edx:eax = *a * w
|
||||
mul ecx
|
||||
add eax,DWORD PTR 4[edi] ; *r+=ax
|
||||
adc edx,0
|
||||
add eax,esi ; edx:eax += c
|
||||
adc edx,0
|
||||
mov DWORD PTR 4[edi],eax ; *r+=ax
|
||||
mov esi,edx ; c = overflow
|
||||
dec ebp
|
||||
jz $L547
|
||||
; Round three
|
||||
mov eax,DWORD PTR 8[ebx] ; edx:eax = *a * w
|
||||
mul ecx
|
||||
add eax,DWORD PTR 8[edi] ; *r+=ax
|
||||
adc edx,0
|
||||
add eax,esi ; edx:eax += c
|
||||
adc edx,0
|
||||
mov DWORD PTR 8[edi],eax ; *r+=ax
|
||||
mov esi,edx ; c = overflow
|
||||
|
||||
$L547:
|
||||
mov eax,esi
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
_bn_mul_add_word ENDP
|
||||
_TEXT ENDS
|
||||
PUBLIC _bn_mul_word
|
||||
_TEXT SEGMENT
|
||||
_bn_mul_word PROC NEAR
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov edi,DWORD PTR 20[esp] ; r
|
||||
mov ebx,DWORD PTR 24[esp] ; a
|
||||
mov ebp,DWORD PTR 28[esp] ; num
|
||||
mov ecx,DWORD PTR 32[esp] ; w
|
||||
xor esi,esi ; c=0
|
||||
|
||||
shr ebp,2 ; num/4
|
||||
jz $L266
|
||||
|
||||
$L593:
|
||||
; Round one
|
||||
mov eax,DWORD PTR [ebx] ; edx:eax= w * *a
|
||||
mul ecx
|
||||
add eax,esi ; edx:eax+=c
|
||||
adc edx,0
|
||||
mov DWORD PTR [edi],eax ; *r=eax
|
||||
mov esi,edx ; c=edx
|
||||
; Round two
|
||||
mov eax,DWORD PTR 4[ebx] ; edx:eax= w * *a
|
||||
mul ecx
|
||||
add eax,esi ; edx:eax+=c
|
||||
adc edx,0
|
||||
mov DWORD PTR 4[edi],eax ; *r=eax
|
||||
mov esi,edx ; c=edx
|
||||
; Round three
|
||||
mov eax,DWORD PTR 8[ebx] ; edx:eax= w * *a
|
||||
mul ecx
|
||||
add eax,esi ; edx:eax+=c
|
||||
adc edx,0
|
||||
mov DWORD PTR 8[edi],eax ; *r=eax
|
||||
mov esi,edx ; c=edx
|
||||
; Round four
|
||||
mov eax,DWORD PTR 12[ebx] ; edx:eax= w * *a
|
||||
mul ecx
|
||||
add eax,esi ; edx:eax+=c
|
||||
adc edx,0
|
||||
mov DWORD PTR 12[edi],eax ; *r=eax
|
||||
mov esi,edx ; c=edx
|
||||
|
||||
add ebx,16
|
||||
add edi,16
|
||||
|
||||
dec ebp
|
||||
jz $L266
|
||||
jmp $L593
|
||||
$L266:
|
||||
mov ebp,DWORD PTR 28[esp] ; num
|
||||
and ebp,3
|
||||
jz $L601
|
||||
|
||||
; Round one
|
||||
mov eax,DWORD PTR [ebx] ; edx:eax= w * *a
|
||||
mul ecx
|
||||
add eax,esi ; edx:eax+=c
|
||||
adc edx,0
|
||||
mov DWORD PTR [edi],eax ; *r=eax
|
||||
mov esi,edx ; c=edx
|
||||
dec ebp
|
||||
jz $L601
|
||||
; Round two
|
||||
mov eax,DWORD PTR 4[ebx] ; edx:eax= w * *a
|
||||
mul ecx
|
||||
add eax,esi ; edx:eax+=c
|
||||
adc edx,0
|
||||
mov DWORD PTR 4[edi],eax ; *r=eax
|
||||
mov esi,edx ; c=edx
|
||||
dec ebp
|
||||
jz $L601
|
||||
; Round three
|
||||
mov eax,DWORD PTR 8[ebx] ; edx:eax= w * *a
|
||||
mul ecx
|
||||
add eax,esi ; edx:eax+=c
|
||||
adc edx,0
|
||||
mov DWORD PTR 8[edi],eax ; *r=eax
|
||||
mov esi,edx ; c=edx
|
||||
|
||||
$L601:
|
||||
mov eax,esi
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
_bn_mul_word ENDP
|
||||
_TEXT ENDS
|
||||
PUBLIC _bn_sqr_words
|
||||
_TEXT SEGMENT
|
||||
_bn_sqr_words PROC NEAR
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
mov esi,DWORD PTR 16[esp] ; r
|
||||
mov edi,DWORD PTR 20[esp] ; a
|
||||
mov ebx,DWORD PTR 24[esp] ; num
|
||||
|
||||
shr ebx,2 ; num/4
|
||||
jz $L111
|
||||
$L640:
|
||||
; Round 1
|
||||
mov eax, DWORD PTR [edi]
|
||||
mul eax ; *a * *a
|
||||
mov DWORD PTR [esi],eax
|
||||
mov DWORD PTR 4[esi],edx
|
||||
; Round 2
|
||||
mov eax, DWORD PTR 4[edi]
|
||||
mul eax ; *a * *a
|
||||
mov DWORD PTR 8[esi],eax
|
||||
mov DWORD PTR 12[esi],edx
|
||||
; Round 3
|
||||
mov eax, DWORD PTR 8[edi]
|
||||
mul eax ; *a * *a
|
||||
mov DWORD PTR 16[esi],eax
|
||||
mov DWORD PTR 20[esi],edx
|
||||
; Round 4
|
||||
mov eax, DWORD PTR 12[edi]
|
||||
mul eax ; *a * *a
|
||||
mov DWORD PTR 24[esi],eax
|
||||
mov DWORD PTR 28[esi],edx
|
||||
|
||||
add edi,16
|
||||
add esi,32
|
||||
|
||||
dec ebx
|
||||
jz $L111
|
||||
jmp $L640
|
||||
$L111:
|
||||
mov ebx,DWORD PTR 24[esp] ; num
|
||||
and ebx,3 ; num%3
|
||||
jz $L645
|
||||
|
||||
; Round 1
|
||||
mov eax, DWORD PTR [edi]
|
||||
mul eax ; *a * *a
|
||||
mov DWORD PTR [esi],eax
|
||||
mov DWORD PTR 4[esi],edx
|
||||
dec ebx
|
||||
jz $L645
|
||||
; Round 2
|
||||
mov eax, DWORD PTR 4[edi]
|
||||
mul eax ; *a * *a
|
||||
mov DWORD PTR 8[esi],eax
|
||||
mov DWORD PTR 12[esi],edx
|
||||
dec ebx
|
||||
jz $L645
|
||||
; Round 3
|
||||
mov eax, DWORD PTR 8[edi]
|
||||
mul eax ; *a * *a
|
||||
mov DWORD PTR 16[esi],eax
|
||||
mov DWORD PTR 20[esi],edx
|
||||
|
||||
$L645:
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
ret
|
||||
_bn_sqr_words ENDP
|
||||
_TEXT ENDS
|
||||
PUBLIC _bn_div64
|
||||
_TEXT SEGMENT
|
||||
_bn_div64 PROC NEAR
|
||||
mov edx, DWORD PTR 4[esp]
|
||||
mov eax, DWORD PTR 8[esp]
|
||||
div DWORD PTR 12[esp]
|
||||
ret
|
||||
_bn_div64 ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
@@ -1,22 +0,0 @@
|
||||
begin 640 x86nt32.obj
|
||||
M3`$"`/H&DC-6`@``"P`````````N=&5X=```````````````\@$``&0`````
|
||||
M```````````````@`#!@+F1A=&$```#R`0````````````!6`@``````````
|
||||
M````````0``PP%535E>+?"04BUPD&(M,)"`S]HML)!S![0)T7(L#]^$#!X/2
|
||||
M``/&@](`B0>+\HM#!/?A`T<$@](``\:#T@")1P2+\HM#"/?A`T<(@](``\:#
|
||||
MT@")1PB+\HM##/?A`T<,@](``\:#T@")1PR+\H/#$(/'$$UT`NNDBVPD'(/E
|
||||
M`W1"BP/WX0,'@](``\:#T@")!XOR370MBT,$]^$#1P2#T@`#QH/2`(E'!(OR
|
||||
M3705BT,(]^$#1PB#T@`#QH/2`(E'"(ORB\9?7EM=PU535E>+?"04BUPD&(ML
|
||||
M)!R+3"0@,_;![0)T18L#]^$#QH/2`(D'B_*+0P3WX0/&@](`B4<$B_*+0PCW
|
||||
MX0/&@](`B4<(B_*+0PSWX0/&@](`B4<,B_*#PQ"#QQ!-=`+KNXML)!R#Y0-T
|
||||
M,8L#]^$#QH/2`(D'B_)-="&+0P3WX0/&@](`B4<$B_)-=`^+0PCWX0/&@](`
|
||||
MB4<(B_*+QE]>6UW#4U97BW0D$(M\)!2+7"08P>L"=#6+!_?@B0:)5@2+1P3W
|
||||
MX(E&"(E6#(M'"/?@B480B584BT<,]^")1AB)5AR#QQ"#QB!+=`+KRXM<)!B#
|
||||
MXP-T)8L']^")!HE6!$MT&8M'!/?@B48(B58,2W0+BT<(]^")1A")5A1?7EO#
|
||||
MBU0D!(M$)`CW="0,PRYF:6QE`````````/[_``!G`BY<8W)Y<'1O7&)N7&%S
|
||||
M;5QX.#9N=#,R+F%S;0```````````"YT97AT``````````$````#`?(!````
|
||||
M`````````````````"YD871A``````````(````#`0``````````````````
|
||||
M```````````$``````````$`(``"```````5````R0````$`(``"```````B
|
||||
M````:@$```$`(``"```````P````Y0$```$`(``"`#H```!?8FY?;75L7V%D
|
||||
L9%]W;W)D`%]B;E]M=6Q?=V]R9`!?8FY?<W%R7W=O<F1S`%]B;E]D:78V-```
|
||||
`
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
begin 640 x86w16.obj
|
||||
M@!P`&BY<8W)Y<'1O7&)N7&%S;5QX.#9W,38N87-MQY8U```$7T)34P5?1$%4
|
||||
M009$1U)/55`&1E]415A4!4-/3E-4`T)34P5#3TY35`1$051!!$-/1$5EF`<`
|
||||
M2/`!!0H!&)@'`$@```,)`0R8!P!(```&"`$*F`<`2````@<!#YH(``3_`O\#
|
||||
M_P14D$4```$-7V)N7W-Q<E]W;W)D<U4!``E?8FY?9&EV-C3B`0`07V)N7VUU
|
||||
M;%]A9&1?=V]R9`````Q?8FY?;75L7W=O<F3<``#`B`0``*(!T:#T`0$``%53
|
||||
M5E<>!HOL,_:+?A".7A*+7A2.1A:+3AJ+;AC1[='M=&"+P2;W)P,%@](`$\:#
|
||||
MT@")!8ORB\$F]V<"`T4"@](`$\:#T@")10*+\HO!)O=G!`-%!(/2`!/&@](`
|
||||
MB44$B_*+P2;W9P8#10:#T@`3QH/2`(E%!HOR@\,(@\<(370"ZZ"+[(MN&(/E
|
||||
M`TUX18O!)O<G`P6#T@`3QH/2`(D%B_)->"^+P2;W9P(#10*#T@`3QH/2`(E%
|
||||
M`HOR37@6B\$F]V<$`T4$@](`$\:#T@")102+\HO&!Q]?7EM=RY!54U97'@8S
|
||||
M]HOLBWX0CEX2BUX4CD86BTX:BVX8B\$F]R<#QH/2`(D%B_)-=$*+P2;W9P(#
|
||||
MQH/2`(E%`HOR370OB\$F]V<$`\:#T@")102+\DUT'(O!)O=G!@/&@](`B44&
|
||||
MB_)-=`F#PPB#QPCKKI"+Q@<?7UY;7<N055-65QX&B^R+=A".7A*+?A2.1A:+
|
||||
M7AB+Z]'KT>MT.2:+!??@B02)5`(FBT4"]^")1`2)5`8FBT4$]^")1`B)5`HF
|
||||
MBT4&]^")1`R)5`Z#QPB#QA!+=`+KQX/E`TUX*":+!??@B02)5`)->!LFBT4"
|
||||
M]^")1`2)5`9->`PFBT4$]^")1`B)5`H''U]>6UW+58OLBU8&BT8(]W8*7<NZ
|
||||
%B@(``'0`
|
||||
`
|
||||
end
|
||||
@@ -1,23 +0,0 @@
|
||||
begin 640 x86w32.obj
|
||||
M@!P`&BY<8W)Y<'1O7&)N7&%S;5QX.#9W,S(N87-MR98U```$7T)34P5?1$%4
|
||||
M009$1U)/55`&1E]415A4!4-/3E-4`T)34P5#3TY35`1$051!!$-/1$5EF`<`
|
||||
M2(`"!0H!AY@'`$@```,)`0R8!P!(```&"`$*F`<`2````@<!#YH(``3_`O\#
|
||||
M_P14D$4```$-7V)N7W-Q<E]W;W)D<[\!``E?8FY?9&EV-C1H`@`07V)N7VUU
|
||||
M;%]A9&1?=V]R9`````Q?8FY?;75L7W=O<F0B`0"(B`0``*(!T:"$`@$``%53
|
||||
M9E97'@:+[&8S]HM^$HY>%(M>%HY&&&:+3AR+;AK1[='M#X2``&:+P68F]R=F
|
||||
M`P5F@](`9A/&9H/2`&:)!6:+\F:+P68F]V<$9@-%!&:#T@!F$\9F@](`9HE%
|
||||
M!&:+\F:+P68F]V<(9@-%"&:#T@!F$\9F@](`9HE%"&:+\F:+P68F]V<,9@-%
|
||||
M#&:#T@!F$\9F@](`9HE%#&:+\H/#$(/'$$UT`NN`B^R+;AJ#Y0-->%UFB\%F
|
||||
M)O<G9@,%9H/2`&83QF:#T@!FB05FB_)->#]FB\%F)O=G!&8#101F@](`9A/&
|
||||
M9H/2`&:)101FB_)->!YFB\%F)O=G"&8#10AF@](`9A/&9H/2`&:)10AFB_)F
|
||||
MB\9FB]9FP>H0!Q]?9EY;7<N055-F5E<>!F8S]HOLBWX2CEX4BUX6CD889HM.
|
||||
M'(MN&F:+P68F]R=F`\9F@](`9HD%9HOR37149HO!9B;W9P1F`\9F@](`9HE%
|
||||
M!&:+\DUT.V:+P68F]V<(9@/&9H/2`&:)10AFB_)-=")FB\%F)O=G#&8#QF:#
|
||||
MT@!FB44,9HOR370)@\,0@\<0ZY:09HO&9HO69L'J$`<?7V9>6UW+D%535E<>
|
||||
M!HOLBW80CEX2BWX4CD86BUX8B^O1Z]'K=$EF)HL%9O?@9HD$9HE4!&8FBT4$
|
||||
M9O?@9HE$"&:)5`QF)HM%"&;WX&:)1!!FB5049B:+10QF]^!FB4089HE4'(/'
|
||||
M$(/&($MT`NNW@^4#37@T9B:+!6;WX&:)!&:)5`1->"-F)HM%!&;WX&:)1`AF
|
||||
MB50,37@09B:+10AF]^!FB4009HE4%`<?7UY;7<M5B^QFBU8&9HM&"F;W=@YF
|
||||
.B]!FP>H07<O`B@(``'0`
|
||||
`
|
||||
end
|
||||
@@ -1,144 +0,0 @@
|
||||
/* crypto/bn/bn_bld.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
BN_BL_CTX *BN_BL_CTX_new()
|
||||
{
|
||||
BN_BL_CTX *ret;
|
||||
|
||||
if ((ret=(BN_BL_CTX *)Malloc(sizeof(BN_BL_CTX))) == NULL)
|
||||
{
|
||||
BNerr(BN_F_BN_BL_CTX_NEW,ERR_R_MALLOC_FAILURE);
|
||||
return(NULL);
|
||||
}
|
||||
if ((ret->num=BN_new()) == NULL) goto err;
|
||||
if ((ret->mod=BN_new()) == NULL) goto err;
|
||||
ret->inum=NULL;
|
||||
ret->count=16;
|
||||
ret->count=1;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BN_BL_CTX_Init(a,mod)
|
||||
BN_BL_CTX *a;
|
||||
BIGNUM *mod;
|
||||
{
|
||||
int i;
|
||||
BN_CTX *ctx;
|
||||
|
||||
if ((ctx=BN_CTX_new()) == NULL) goto m_err;
|
||||
|
||||
if (BN_copy(a->mod,mod) == NULL) goto err;
|
||||
i=BN_num_bits(mod);
|
||||
if (!BN_rand(a->num,i,1,0)) goto err;
|
||||
|
||||
if (a->inum != NULL) BN_clear_free(a->inum);
|
||||
a->inum=BN_mod_inverse(a->num,a->mod,ctx)
|
||||
ret->count=16;
|
||||
return(1);
|
||||
m_err:
|
||||
BNerr(BN_F_BN_BL_CTX_INIT,ERR_R_MALLOC_FAILURE);
|
||||
err:
|
||||
return(0);
|
||||
}
|
||||
|
||||
BN_BL_CTX *BN_BL_CTX_Update(a)
|
||||
BN_BL_CTX *a;
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
BN_BL_CTX *new;
|
||||
|
||||
if (--a->count > 0)
|
||||
return(1);
|
||||
|
||||
new=BN_BL_CTX_new();
|
||||
/* set/get lock */
|
||||
if ((ctx=BN_CTX_new()) == NULL)
|
||||
return(NULL);
|
||||
new->inum=BN_new();
|
||||
|
||||
BN_mod_mul(new->num,a->num,a->num,a->mod,ctx);
|
||||
BN_mod_mul(new->inum,a->inum,a->inum,a->mod,ctx);
|
||||
BN_copy(new->mod,a->mod);
|
||||
BN_BL_CTX_free(a);
|
||||
return(new);
|
||||
}
|
||||
|
||||
void BN_BL_CTX_free(a)
|
||||
BN_BL_CTX *a;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (a == NULL) return;
|
||||
|
||||
i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_RSA);
|
||||
if (i > 0) return;
|
||||
#ifdef REF_CHECK
|
||||
if (i < 0)
|
||||
{
|
||||
fprintf(stderr,"BN_BL_CTX_free, bad reference count\n");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
if (a->num == NULL) BN_clear_free(a->num);
|
||||
if (a->inum == NULL) BN_clear_free(a->inum);
|
||||
if (a->mod == NULL) BN_clear_free(a->mod);
|
||||
}
|
||||
169
crypto/bn/bn_m.c
169
crypto/bn/bn_m.c
@@ -1,169 +0,0 @@
|
||||
/* crypto/bn/bn_m.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
#include "stack.h"
|
||||
|
||||
int limit=16;
|
||||
|
||||
typedef struct bn_pool_st
|
||||
{
|
||||
int used;
|
||||
int tos;
|
||||
STACK *sk;
|
||||
} BN_POOL;
|
||||
|
||||
BIGNUM *BN_POOL_push(bp)
|
||||
BN_POOL *bp;
|
||||
{
|
||||
BIGNUM *ret;
|
||||
|
||||
if (bp->used >= bp->tos)
|
||||
{
|
||||
ret=BN_new();
|
||||
sk_push(bp->sk,(char *)ret);
|
||||
bp->tos++;
|
||||
bp->used++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret=(BIGNUM *)sk_value(bp->sk,bp->used);
|
||||
bp->used++;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void BN_POOL_pop(bp,num)
|
||||
BN_POOL *bp;
|
||||
int num;
|
||||
{
|
||||
bp->used-=num;
|
||||
}
|
||||
|
||||
int BN_m(r,a,b)
|
||||
BIGNUM *r,*a,*b;
|
||||
{
|
||||
static BN_POOL bp;
|
||||
static init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
bp.used=0;
|
||||
bp.tos=0;
|
||||
bp.sk=sk_new_null();
|
||||
init=0;
|
||||
}
|
||||
return(BN_mm(r,a,b,&bp));
|
||||
}
|
||||
|
||||
/* r must be different to a and b */
|
||||
int BN_mm(m, A, B, bp)
|
||||
BIGNUM *m,*A,*B;
|
||||
BN_POOL *bp;
|
||||
{
|
||||
int i,num;
|
||||
int an,bn;
|
||||
BIGNUM *a,*b,*c,*d,*ac,*bd;
|
||||
|
||||
an=A->top;
|
||||
bn=B->top;
|
||||
if ((an <= limit) || (bn <= limit))
|
||||
{
|
||||
return(BN_mul(m,A,B));
|
||||
}
|
||||
|
||||
a=BN_POOL_push(bp);
|
||||
b=BN_POOL_push(bp);
|
||||
c=BN_POOL_push(bp);
|
||||
d=BN_POOL_push(bp);
|
||||
ac=BN_POOL_push(bp);
|
||||
bd=BN_POOL_push(bp);
|
||||
|
||||
num=(an <= bn)?an:bn;
|
||||
num=1<<(BN_num_bits_word(num-1)-1);
|
||||
|
||||
/* Are going to now chop things into 'num' word chunks. */
|
||||
num*=BN_BITS2;
|
||||
|
||||
BN_copy(a,A);
|
||||
BN_mask_bits(a,num);
|
||||
BN_rshift(b,A,num);
|
||||
|
||||
BN_copy(c,B);
|
||||
BN_mask_bits(c,num);
|
||||
BN_rshift(d,B,num);
|
||||
|
||||
BN_sub(ac ,b,a);
|
||||
BN_sub(bd,c,d);
|
||||
BN_mm(m,ac,bd,bp);
|
||||
BN_mm(ac,a,c,bp);
|
||||
BN_mm(bd,b,d,bp);
|
||||
|
||||
BN_add(m,m,ac);
|
||||
BN_add(m,m,bd);
|
||||
BN_lshift(m,m,num);
|
||||
BN_lshift(bd,bd,num*2);
|
||||
|
||||
BN_add(m,m,ac);
|
||||
BN_add(m,m,bd);
|
||||
BN_POOL_pop(bp,6);
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/* crypto/bn/bn_mod.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
/* rem != m */
|
||||
int BN_mod(rem, m, d,ctx)
|
||||
BIGNUM *rem;
|
||||
BIGNUM *m;
|
||||
BIGNUM *d;
|
||||
BN_CTX *ctx;
|
||||
{
|
||||
#if 0 /* The old slow way */
|
||||
int i,nm,nd;
|
||||
BIGNUM *dv;
|
||||
|
||||
if (BN_ucmp(m,d) < 0)
|
||||
return((BN_copy(rem,m) == NULL)?0:1);
|
||||
|
||||
dv=ctx->bn[ctx->tos];
|
||||
|
||||
if (!BN_copy(rem,m)) return(0);
|
||||
|
||||
nm=BN_num_bits(rem);
|
||||
nd=BN_num_bits(d);
|
||||
if (!BN_lshift(dv,d,nm-nd)) return(0);
|
||||
for (i=nm-nd; i>=0; i--)
|
||||
{
|
||||
if (BN_cmp(rem,dv) >= 0)
|
||||
{
|
||||
if (!BN_sub(rem,rem,dv)) return(0);
|
||||
}
|
||||
if (!BN_rshift1(dv,dv)) return(0);
|
||||
}
|
||||
return(1);
|
||||
#else
|
||||
return(BN_div(NULL,rem,m,d,ctx));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,366 +0,0 @@
|
||||
/* crypto/bn/bn_mulw.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
#ifdef BN_LLONG
|
||||
|
||||
BN_ULONG bn_mul_add_words(rp,ap,num,w)
|
||||
BN_ULONG *rp,*ap;
|
||||
int num;
|
||||
BN_ULONG w;
|
||||
{
|
||||
BN_ULONG c1=0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mul_add(rp[0],ap[0],w,c1);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[1],ap[1],w,c1);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[2],ap[2],w,c1);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[3],ap[3],w,c1);
|
||||
if (--num == 0) break;
|
||||
ap+=4;
|
||||
rp+=4;
|
||||
}
|
||||
|
||||
return(c1);
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_words(rp,ap,num,w)
|
||||
BN_ULONG *rp,*ap;
|
||||
int num;
|
||||
BN_ULONG w;
|
||||
{
|
||||
BN_ULONG c1=0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mul(rp[0],ap[0],w,c1);
|
||||
if (--num == 0) break;
|
||||
mul(rp[1],ap[1],w,c1);
|
||||
if (--num == 0) break;
|
||||
mul(rp[2],ap[2],w,c1);
|
||||
if (--num == 0) break;
|
||||
mul(rp[3],ap[3],w,c1);
|
||||
if (--num == 0) break;
|
||||
ap+=4;
|
||||
rp+=4;
|
||||
}
|
||||
return(c1);
|
||||
}
|
||||
|
||||
void bn_sqr_words(r,a,n)
|
||||
BN_ULONG *r,*a;
|
||||
int n;
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
BN_ULLONG t;
|
||||
|
||||
t=(BN_ULLONG)(a[0])*(a[0]);
|
||||
r[0]=Lw(t); r[1]=Hw(t);
|
||||
if (--n == 0) break;
|
||||
|
||||
t=(BN_ULLONG)(a[1])*(a[1]);
|
||||
r[2]=Lw(t); r[3]=Hw(t);
|
||||
if (--n == 0) break;
|
||||
|
||||
t=(BN_ULLONG)(a[2])*(a[2]);
|
||||
r[4]=Lw(t); r[5]=Hw(t);
|
||||
if (--n == 0) break;
|
||||
|
||||
t=(BN_ULLONG)(a[3])*(a[3]);
|
||||
r[6]=Lw(t); r[7]=Hw(t);
|
||||
if (--n == 0) break;
|
||||
|
||||
a+=4;
|
||||
r+=8;
|
||||
}
|
||||
}
|
||||
|
||||
BN_ULONG bn_add_words(r,a,b,n)
|
||||
BN_ULONG *r,*a,*b;
|
||||
int n;
|
||||
{
|
||||
BN_ULLONG ll;
|
||||
|
||||
ll=0;
|
||||
for (;;)
|
||||
{
|
||||
ll+= (BN_ULLONG)a[0]+b[0];
|
||||
r[0]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
ll+= (BN_ULLONG)a[1]+b[1];
|
||||
r[1]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
ll+= (BN_ULLONG)a[2]+b[2];
|
||||
r[2]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
ll+= (BN_ULLONG)a[3]+b[3];
|
||||
r[3]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
a+=4;
|
||||
b+=4;
|
||||
r+=4;
|
||||
}
|
||||
return(ll&BN_MASK2);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BN_ULONG bn_mul_add_words(rp,ap,num,w)
|
||||
BN_ULONG *rp,*ap;
|
||||
int num;
|
||||
BN_ULONG w;
|
||||
{
|
||||
BN_ULONG c=0;
|
||||
BN_ULONG bl,bh;
|
||||
|
||||
bl=LBITS(w);
|
||||
bh=HBITS(w);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mul_add(rp[0],ap[0],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[1],ap[1],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[2],ap[2],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[3],ap[3],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
ap+=4;
|
||||
rp+=4;
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_words(rp,ap,num,w)
|
||||
BN_ULONG *rp,*ap;
|
||||
int num;
|
||||
BN_ULONG w;
|
||||
{
|
||||
BN_ULONG carry=0;
|
||||
BN_ULONG bl,bh;
|
||||
|
||||
bl=LBITS(w);
|
||||
bh=HBITS(w);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mul(rp[0],ap[0],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
mul(rp[1],ap[1],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
mul(rp[2],ap[2],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
mul(rp[3],ap[3],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
ap+=4;
|
||||
rp+=4;
|
||||
}
|
||||
return(carry);
|
||||
}
|
||||
|
||||
void bn_sqr_words(r,a,n)
|
||||
BN_ULONG *r,*a;
|
||||
int n;
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
sqr64(r[0],r[1],a[0]);
|
||||
if (--n == 0) break;
|
||||
|
||||
sqr64(r[2],r[3],a[1]);
|
||||
if (--n == 0) break;
|
||||
|
||||
sqr64(r[4],r[5],a[2]);
|
||||
if (--n == 0) break;
|
||||
|
||||
sqr64(r[6],r[7],a[3]);
|
||||
if (--n == 0) break;
|
||||
|
||||
a+=4;
|
||||
r+=8;
|
||||
}
|
||||
}
|
||||
|
||||
BN_ULONG bn_add_words(r,a,b,n)
|
||||
BN_ULONG *r,*a,*b;
|
||||
int n;
|
||||
{
|
||||
BN_ULONG t1,t2;
|
||||
int carry,i;
|
||||
|
||||
carry=0;
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
t1= *(a++);
|
||||
t2= *(b++);
|
||||
if (carry)
|
||||
{
|
||||
carry=(t2 >= ((~t1)&BN_MASK2));
|
||||
t2=(t1+t2+1)&BN_MASK2;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2=(t1+t2)&BN_MASK2;
|
||||
carry=(t2<t1);
|
||||
}
|
||||
*(r++)=t2;
|
||||
}
|
||||
return(carry);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BN_LLONG) && defined(BN_DIV2W)
|
||||
|
||||
BN_ULONG bn_div64(h,l,d)
|
||||
BN_ULONG h,l,d;
|
||||
{
|
||||
return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Divide h-l by d and return the result. */
|
||||
/* I need to test this some more :-( */
|
||||
BN_ULONG bn_div64(h,l,d)
|
||||
BN_ULONG h,l,d;
|
||||
{
|
||||
BN_ULONG dh,dl,q,ret=0,th,tl,t;
|
||||
int i,count=2;
|
||||
|
||||
if (d == 0) return(BN_MASK2);
|
||||
|
||||
i=BN_num_bits_word(d);
|
||||
if ((i != BN_BITS2) && (h > (BN_ULONG)1<<i))
|
||||
{
|
||||
#if !defined(NO_STDIO) && !defined(WIN16)
|
||||
fprintf(stderr,"Division would overflow (%d)\n",i);
|
||||
#endif
|
||||
abort();
|
||||
}
|
||||
i=BN_BITS2-i;
|
||||
if (h >= d) h-=d;
|
||||
|
||||
if (i)
|
||||
{
|
||||
d<<=i;
|
||||
h=(h<<i)|(l>>(BN_BITS2-i));
|
||||
l<<=i;
|
||||
}
|
||||
dh=(d&BN_MASK2h)>>BN_BITS4;
|
||||
dl=(d&BN_MASK2l);
|
||||
for (;;)
|
||||
{
|
||||
if ((h>>BN_BITS4) == dh)
|
||||
q=BN_MASK2l;
|
||||
else
|
||||
q=h/dh;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
t=(h-q*dh);
|
||||
if ((t&BN_MASK2h) ||
|
||||
((dl*q) <= (
|
||||
(t<<BN_BITS4)+
|
||||
((l&BN_MASK2h)>>BN_BITS4))))
|
||||
break;
|
||||
q--;
|
||||
}
|
||||
th=q*dh;
|
||||
tl=q*dl;
|
||||
t=(tl>>BN_BITS4);
|
||||
tl=(tl<<BN_BITS4)&BN_MASK2h;
|
||||
th+=t;
|
||||
|
||||
if (l < tl) th++;
|
||||
l-=tl;
|
||||
if (h < th)
|
||||
{
|
||||
h+=d;
|
||||
q--;
|
||||
}
|
||||
h-=th;
|
||||
|
||||
if (--count == 0) break;
|
||||
|
||||
ret=q<<BN_BITS4;
|
||||
h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
|
||||
l=(l&BN_MASK2l)<<BN_BITS4;
|
||||
}
|
||||
ret|=q;
|
||||
return(ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
/* crypto/bn/bn_sub.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
/* unsigned subtraction of b from a, a must be larger than b. */
|
||||
void bn_qsub(r, a, b)
|
||||
BIGNUM *r;
|
||||
BIGNUM *a;
|
||||
BIGNUM *b;
|
||||
{
|
||||
int max,min;
|
||||
register BN_ULONG t1,t2,*ap,*bp,*rp;
|
||||
int i,carry;
|
||||
#if defined(IRIX_CC_BUG) && !defined(LINT)
|
||||
int dummy;
|
||||
#endif
|
||||
|
||||
max=a->top;
|
||||
min=b->top;
|
||||
ap=a->d;
|
||||
bp=b->d;
|
||||
rp=r->d;
|
||||
|
||||
carry=0;
|
||||
for (i=0; i<min; i++)
|
||||
{
|
||||
t1= *(ap++);
|
||||
t2= *(bp++);
|
||||
if (carry)
|
||||
{
|
||||
carry=(t1 <= t2);
|
||||
t1=(t1-t2-1)&BN_MASK2;
|
||||
}
|
||||
else
|
||||
{
|
||||
carry=(t1 < t2);
|
||||
t1=(t1-t2)&BN_MASK2;
|
||||
}
|
||||
#if defined(IRIX_CC_BUG) && !defined(LINT)
|
||||
dummy=t1;
|
||||
#endif
|
||||
*(rp++)=t1&BN_MASK2;
|
||||
}
|
||||
if (carry) /* subtracted */
|
||||
{
|
||||
while (i < max)
|
||||
{
|
||||
i++;
|
||||
t1= *(ap++);
|
||||
t2=(t1-1)&BN_MASK2;
|
||||
*(rp++)=t2;
|
||||
if (t1 > t2) break;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
memcpy(rp,ap,sizeof(*rp)*(max-i));
|
||||
#else
|
||||
for (; i<max; i++)
|
||||
*(rp++)= *(ap++);
|
||||
#endif
|
||||
|
||||
r->top=max;
|
||||
bn_fix_top(r);
|
||||
}
|
||||
|
||||
int BN_sub(r, a, b)
|
||||
BIGNUM *r;
|
||||
BIGNUM *a;
|
||||
BIGNUM *b;
|
||||
{
|
||||
int max,i;
|
||||
int add=0,neg=0;
|
||||
BIGNUM *tmp;
|
||||
|
||||
/* a - b a-b
|
||||
* a - -b a+b
|
||||
* -a - b -(a+b)
|
||||
* -a - -b b-a
|
||||
*/
|
||||
if (a->neg)
|
||||
{
|
||||
if (b->neg)
|
||||
{ tmp=a; a=b; b=tmp; }
|
||||
else
|
||||
{ add=1; neg=1; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b->neg) { add=1; neg=0; }
|
||||
}
|
||||
|
||||
if (add)
|
||||
{
|
||||
/* As a fast max size, do a a->top | b->top */
|
||||
i=(a->top | b->top)+1;
|
||||
if (bn_wexpand(r,i) == NULL)
|
||||
return(0);
|
||||
if (i)
|
||||
bn_qadd(r,a,b);
|
||||
else
|
||||
bn_qadd(r,b,a);
|
||||
r->neg=neg;
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* We are actually doing a - b :-) */
|
||||
|
||||
max=(a->top > b->top)?a->top:b->top;
|
||||
if (bn_wexpand(r,max) == NULL) return(0);
|
||||
if (BN_ucmp(a,b) < 0)
|
||||
{
|
||||
bn_qsub(r,b,a);
|
||||
r->neg=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bn_qsub(r,a,b);
|
||||
r->neg=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -1,378 +0,0 @@
|
||||
/* crypto/bn/bn_knuth.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn.h"
|
||||
|
||||
/* This is just a test implementation, it has not been modified for
|
||||
* speed and it still has memory leaks. */
|
||||
|
||||
int BN_mask_bits(BIGNUM *a,int n);
|
||||
|
||||
#undef DEBUG
|
||||
#define MAIN
|
||||
|
||||
/* r must be different to a and b
|
||||
* Toom-Cook multiplication algorithm, taken from
|
||||
* The Art Of Computer Programming, Volume 2, Donald Knuth
|
||||
*/
|
||||
|
||||
#define CODE1 ((BIGNUM *)0x01)
|
||||
#define CODE2 ((BIGNUM *)0x02)
|
||||
#define CODE3 ((BIGNUM *)0x03)
|
||||
#define MAXK (30+1)
|
||||
|
||||
#define C3 3
|
||||
#define C4 4
|
||||
#define C5 5
|
||||
#define C6 6
|
||||
#define C7 7
|
||||
#define C8 8
|
||||
#define C9 9
|
||||
#define C10 10
|
||||
#define DONE 11
|
||||
|
||||
int new_total=0;
|
||||
int Free_total=0;
|
||||
int max=0,max_total=0;
|
||||
|
||||
BIGNUM *LBN_new(void );
|
||||
BIGNUM *LBN_dup(BIGNUM *a);
|
||||
void LBN_free(BIGNUM *a);
|
||||
|
||||
int BN_mul_knuth(w, a, b)
|
||||
BIGNUM *w;
|
||||
BIGNUM *a;
|
||||
BIGNUM *b;
|
||||
{
|
||||
int ret=1;
|
||||
int i,j,n,an,bn,y,z;
|
||||
BIGNUM *U[MAXK],*V[MAXK],*T[MAXK];
|
||||
BIGNUM *C[(MAXK*2*3)];
|
||||
BIGNUM *W[(MAXK*2)],*t1,*t2,*t3,*t4;
|
||||
int Utos,Vtos,Ctos,Wtos,Ttos;
|
||||
unsigned int k,Q,R;
|
||||
unsigned int q[MAXK];
|
||||
unsigned int r[MAXK];
|
||||
int state;
|
||||
|
||||
/* C1 */
|
||||
Utos=Vtos=Ctos=Wtos=Ttos=0;
|
||||
k=1;
|
||||
q[0]=q[1]=64;
|
||||
r[0]=r[1]=4;
|
||||
Q=6;
|
||||
R=2;
|
||||
|
||||
if (!bn_expand(w,BN_BITS2*2)) goto err;
|
||||
an=BN_num_bits(a);
|
||||
bn=BN_num_bits(b);
|
||||
n=(an > bn)?an:bn;
|
||||
while ((q[k-1]+q[k]) < n)
|
||||
{
|
||||
k++;
|
||||
Q+=R;
|
||||
i=R+1;
|
||||
if ((i*i) <= Q) R=i;
|
||||
q[k]=(1<<Q);
|
||||
r[k]=(1<<R);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("k =");
|
||||
for (i=0; i<=k; i++) printf("%7d",i);
|
||||
printf("\nq[k]=");
|
||||
for (i=0; i<=k; i++) printf("%7d",q[i]);
|
||||
printf("\nr[k]=");
|
||||
for (i=0; i<=k; i++) printf("%7d",r[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
/* C2 */
|
||||
C[Ctos++]=CODE1;
|
||||
if ((t1=LBN_dup(a)) == NULL) goto err;
|
||||
C[Ctos++]=t1;
|
||||
if ((t1=LBN_dup(b)) == NULL) goto err;
|
||||
C[Ctos++]=t1;
|
||||
|
||||
state=C3;
|
||||
for (;;)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("state=C%d, Ctos=%d Wtos=%d\n",state,Ctos,Wtos);
|
||||
#endif
|
||||
switch (state)
|
||||
{
|
||||
int lr,lq,lp;
|
||||
case C3:
|
||||
k--;
|
||||
if (k == 0)
|
||||
{
|
||||
t1=C[--Ctos];
|
||||
t2=C[--Ctos];
|
||||
#ifdef DEBUG
|
||||
printf("Ctos=%d poped %d\n",Ctos,2);
|
||||
#endif
|
||||
if ((t2->top == 0) || (t1->top == 0))
|
||||
w->top=0;
|
||||
else
|
||||
BN_mul(w,t1,t2);
|
||||
|
||||
LBN_free(t1); /* FREE */
|
||||
LBN_free(t2); /* FREE */
|
||||
state=C10;
|
||||
}
|
||||
else
|
||||
{
|
||||
lr=r[k];
|
||||
lq=q[k];
|
||||
lp=q[k-1]+q[k];
|
||||
state=C4;
|
||||
}
|
||||
break;
|
||||
case C4:
|
||||
for (z=0; z<2; z++) /* do for u and v */
|
||||
{
|
||||
/* break the item at C[Ctos-1]
|
||||
* into lr+1 parts of lq bits each
|
||||
* for j=0; j<=2r; j++
|
||||
*/
|
||||
t1=C[--Ctos]; /* pop off u */
|
||||
#ifdef DEBUG
|
||||
printf("Ctos=%d poped %d\n",Ctos,1);
|
||||
#endif
|
||||
if ((t2=LBN_dup(t1)) == NULL) goto err;
|
||||
BN_mask_bits(t2,lq);
|
||||
T[Ttos++]=t2;
|
||||
#ifdef DEBUG
|
||||
printf("C4 r=0 bits=%d\n",BN_num_bits(t2));
|
||||
#endif
|
||||
for (i=1; i<=lr; i++)
|
||||
{
|
||||
if (!BN_rshift(t1,t1,lq)) goto err;
|
||||
if ((t2=LBN_dup(t1)) == NULL) goto err;
|
||||
BN_mask_bits(t2,lq);
|
||||
T[Ttos++]=t2;
|
||||
#ifdef DEBUG
|
||||
printf("C4 r=%d bits=%d\n",i,
|
||||
BN_num_bits(t2));
|
||||
#endif
|
||||
}
|
||||
LBN_free(t1);
|
||||
|
||||
if ((t2=LBN_new()) == NULL) goto err;
|
||||
if ((t3=LBN_new()) == NULL) goto err;
|
||||
for (j=0; j<=2*lr; j++)
|
||||
{
|
||||
if ((t1=LBN_new()) == NULL) goto err;
|
||||
|
||||
if (!BN_set_word(t3,j)) goto err;
|
||||
for (i=lr; i>=0; i--)
|
||||
{
|
||||
if (!BN_mul(t2,t1,t3)) goto err;
|
||||
if (!BN_add(t1,t2,T[i])) goto err;
|
||||
}
|
||||
/* t1 is U(j) */
|
||||
if (z == 0)
|
||||
U[Utos++]=t1;
|
||||
else
|
||||
V[Vtos++]=t1;
|
||||
}
|
||||
LBN_free(t2);
|
||||
LBN_free(t3);
|
||||
while (Ttos) LBN_free(T[--Ttos]);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
for (i=0; i<Utos; i++)
|
||||
printf("U[%2d]=%4d bits\n",i,BN_num_bits(U[i]));
|
||||
for (i=0; i<Vtos; i++)
|
||||
printf("V[%2d]=%4d bits\n",i,BN_num_bits(V[i]));
|
||||
#endif
|
||||
/* C5 */
|
||||
#ifdef DEBUG
|
||||
printf("PUSH CODE2 and %d CODE3 onto stack\n",2*lr);
|
||||
#endif
|
||||
C[Ctos++]=CODE2;
|
||||
for (i=2*lr; i>0; i--)
|
||||
{
|
||||
C[Ctos++]=V[i];
|
||||
C[Ctos++]=U[i];
|
||||
C[Ctos++]=CODE3;
|
||||
}
|
||||
C[Ctos++]=V[0];
|
||||
C[Ctos++]=U[0];
|
||||
#ifdef DEBUG
|
||||
printf("Ctos=%d pushed %d\n",Ctos,2*lr*3+3);
|
||||
#endif
|
||||
Vtos=Utos=0;
|
||||
state=C3;
|
||||
break;
|
||||
case C6:
|
||||
if ((t1=LBN_dup(w)) == NULL) goto err;
|
||||
W[Wtos++]=t1;
|
||||
#ifdef DEBUG
|
||||
printf("put %d bit number onto w\n",BN_num_bits(t1));
|
||||
#endif
|
||||
state=C3;
|
||||
break;
|
||||
case C7:
|
||||
lr=r[k];
|
||||
lq=q[k];
|
||||
lp=q[k]+q[k-1];
|
||||
z=Wtos-2*lr-1;
|
||||
for (j=1; j<=2*lr; j++)
|
||||
{
|
||||
for (i=2*lr; i>=j; i--)
|
||||
{
|
||||
if (!BN_sub(W[z+i],W[z+i],W[z+i-1])) goto err;
|
||||
BN_div_word(W[z+i],j);
|
||||
}
|
||||
}
|
||||
state=C8;
|
||||
break;
|
||||
case C8:
|
||||
y=2*lr-1;
|
||||
if ((t1=LBN_new()) == NULL) goto err;
|
||||
if ((t3=LBN_new()) == NULL) goto err;
|
||||
|
||||
for (j=y; j>0; j--)
|
||||
{
|
||||
if (!BN_set_word(t3,j)) goto err;
|
||||
for (i=j; i<=y; i++)
|
||||
{
|
||||
if (!BN_mul(t1,W[z+i+1],t3)) goto err;
|
||||
if (!BN_sub(W[z+i],W[z+i],t1)) goto err;
|
||||
}
|
||||
}
|
||||
LBN_free(t1);
|
||||
LBN_free(t3);
|
||||
state=C9;
|
||||
break;
|
||||
case C9:
|
||||
BN_zero(w);
|
||||
#ifdef DEBUG
|
||||
printf("lq=%d\n",lq);
|
||||
#endif
|
||||
for (i=lr*2; i>=0; i--)
|
||||
{
|
||||
BN_lshift(w,w,lq);
|
||||
BN_add(w,w,W[z+i]);
|
||||
}
|
||||
for (i=0; i<=lr*2; i++)
|
||||
LBN_free(W[--Wtos]);
|
||||
state=C10;
|
||||
break;
|
||||
case C10:
|
||||
k++;
|
||||
t1=C[--Ctos];
|
||||
#ifdef DEBUG
|
||||
printf("Ctos=%d poped %d\n",Ctos,1);
|
||||
printf("code= CODE%d\n",t1);
|
||||
#endif
|
||||
if (t1 == CODE3)
|
||||
state=C6;
|
||||
else if (t1 == CODE2)
|
||||
{
|
||||
if ((t2=LBN_dup(w)) == NULL) goto err;
|
||||
W[Wtos++]=t2;
|
||||
state=C7;
|
||||
}
|
||||
else if (t1 == CODE1)
|
||||
{
|
||||
state=DONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("BAD ERROR\n");
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("bad state\n");
|
||||
goto err;
|
||||
break;
|
||||
}
|
||||
if (state == DONE) break;
|
||||
}
|
||||
ret=1;
|
||||
err:
|
||||
if (ret == 0) printf("ERROR\n");
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#ifdef MAIN
|
||||
main()
|
||||
{
|
||||
BIGNUM *a,*b,*r;
|
||||
int i;
|
||||
|
||||
if ((a=LBN_new()) == NULL) goto err;
|
||||
if ((b=LBN_new()) == NULL) goto err;
|
||||
if ((r=LBN_new()) == NULL) goto err;
|
||||
|
||||
if (!BN_rand(a,1024*2,0,0)) goto err;
|
||||
if (!BN_rand(b,1024*2,0,0)) goto err;
|
||||
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
if (!BN_mul_knuth(r,a,b)) goto err; /**/
|
||||
/*if (!BN_mul(r,a,b)) goto err; /**/
|
||||
}
|
||||
BN_print(stdout,a); printf(" * ");
|
||||
BN_print(stdout,b); printf(" =\n");
|
||||
BN_print(stdout,r); printf("\n");
|
||||
|
||||
printf("BN_new() =%d\nBN_free()=%d max=%d\n",new_total,Free_total,max);
|
||||
|
||||
|
||||
exit(0);
|
||||
err:
|
||||
ERR_load_crypto_strings();
|
||||
ERR_print_errors(stderr);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
int BN_mask_bits(a,n)
|
||||
BIGNUM *a;
|
||||
int n;
|
||||
{
|
||||
int b,w;
|
||||
|
||||
w=n/BN_BITS2;
|
||||
b=n%BN_BITS2;
|
||||
if (w >= a->top) return(0);
|
||||
if (b == 0)
|
||||
a->top=w;
|
||||
else
|
||||
{
|
||||
a->top=w+1;
|
||||
a->d[w]&= ~(BN_MASK2<<b);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
BIGNUM *LBN_dup(a)
|
||||
BIGNUM *a;
|
||||
{
|
||||
new_total++;
|
||||
max_total++;
|
||||
if (max_total > max) max=max_total;
|
||||
return(BN_dup(a));
|
||||
}
|
||||
|
||||
BIGNUM *LBN_new()
|
||||
{
|
||||
new_total++;
|
||||
max_total++;
|
||||
if (max_total > max) max=max_total;
|
||||
return(BN_new());
|
||||
}
|
||||
|
||||
void LBN_free(a)
|
||||
BIGNUM *a;
|
||||
{
|
||||
max_total--;
|
||||
if (max_total > max) max=max_total;
|
||||
Free_total++;
|
||||
BN_free(a);
|
||||
}
|
||||
@@ -1,340 +0,0 @@
|
||||
/* crypto/bn/div.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn.h"
|
||||
|
||||
BN_ULONG bn_div_2word();
|
||||
|
||||
int BN_div2(dv, rm, num, div,ctx)
|
||||
BIGNUM *dv;
|
||||
BIGNUM *rm;
|
||||
BIGNUM *num;
|
||||
BIGNUM *div;
|
||||
BN_CTX *ctx;
|
||||
{
|
||||
int norm_shift,i,j,nm,nd,loop;
|
||||
BIGNUM *tmp,wnum,*snum,*sdiv,*res;
|
||||
BN_ULONG *resp,*wnump;
|
||||
BN_ULONG d0,d1;
|
||||
int num_n,div_n;
|
||||
|
||||
#ifdef DEBUG
|
||||
BN_print(stdout,num); printf(" number\n");
|
||||
BN_print(stdout,div); printf(" divisor\n");
|
||||
#endif
|
||||
if (BN_is_zero(num))
|
||||
{
|
||||
BNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (BN_cmp(num,div) < 0)
|
||||
{
|
||||
if (rm != NULL)
|
||||
{ if (BN_copy(rm,num) == NULL) return(0); }
|
||||
if (dv != NULL) BN_zero(dv);
|
||||
return(1);
|
||||
}
|
||||
|
||||
tmp=ctx->bn[ctx->tos];
|
||||
snum=ctx->bn[ctx->tos+1];
|
||||
sdiv=ctx->bn[ctx->tos+2];
|
||||
if (dv == NULL)
|
||||
res=ctx->bn[ctx->tos+3];
|
||||
else res=dv;
|
||||
|
||||
/* First we normalise the numbers */
|
||||
norm_shift=BN_BITS2-((BN_num_bits(div))%BN_BITS2);
|
||||
BN_lshift(sdiv,div,norm_shift);
|
||||
norm_shift+=BN_BITS2;
|
||||
BN_lshift(snum,num,norm_shift);
|
||||
div_n=sdiv->top;
|
||||
num_n=snum->top;
|
||||
loop=num_n-div_n;
|
||||
#ifdef DEBUG
|
||||
BN_print(stdout,snum); printf(" shifted num, forget last word\n");
|
||||
BN_print(stdout,sdiv); printf(" shifted div\n");
|
||||
#endif
|
||||
|
||||
/* Lets setup a 'win'dow into snum
|
||||
* This is the part that corresponds to the current
|
||||
* 'area' being divided */
|
||||
wnum.d= &(snum->d[loop]);
|
||||
wnum.top= div_n;
|
||||
wnum.max= snum->max; /* a bit of a lie */
|
||||
wnum.neg= 0;
|
||||
|
||||
/* Get the top 2 words of sdiv */
|
||||
i=sdiv->top;
|
||||
d0=sdiv->d[div_n-1];
|
||||
d1=sdiv->d[div_n-2];
|
||||
|
||||
/* pointer to the 'top' of snum */
|
||||
wnump= &(snum->d[num_n-1]);
|
||||
|
||||
/* Setup to 'res' */
|
||||
res->neg=0;
|
||||
res->top=loop;
|
||||
resp= &(res->d[loop-1]);
|
||||
bn_expand(res,(loop+1)*BN_BITS2);
|
||||
|
||||
/* space for temp */
|
||||
bn_expand(tmp,(div_n+1)*BN_BITS2);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("wnum="); BN_print(stdout,&wnum); printf(" initial sub check\n");
|
||||
printf("div ="); BN_print(stdout,sdiv); printf(" loop=%d\n",loop);
|
||||
#endif
|
||||
if (BN_cmp(&wnum,sdiv) >= 0)
|
||||
{
|
||||
BN_sub(&wnum,&wnum,sdiv);
|
||||
*resp=1;
|
||||
res->d[res->top-1]=1;
|
||||
}
|
||||
else
|
||||
res->top--;
|
||||
resp--;
|
||||
#ifdef DEBUG
|
||||
BN_print(stdout,res); printf(" initial result\n");
|
||||
BN_print(stdout,&wnum); printf(" wnum\n");
|
||||
#endif
|
||||
|
||||
for (i=0; i<loop-1; i++)
|
||||
{
|
||||
BN_ULONG q,n0;
|
||||
BN_ULLONG t1,t2,t3;
|
||||
BN_ULONG l0;
|
||||
|
||||
wnum.d--;
|
||||
wnum.top++;
|
||||
|
||||
#ifdef DEBUG
|
||||
BN_print(stderr,&wnum); printf(" to divide\n");
|
||||
#endif
|
||||
|
||||
q=0;
|
||||
n0=wnump[0];
|
||||
t1=((BN_ULLONG)n0<<BN_BITS2)|wnump[-1];
|
||||
if (n0 == d0)
|
||||
q=BN_MASK2;
|
||||
else
|
||||
{
|
||||
t2=(t1/d0);
|
||||
q=(t2&BN_MASK2);
|
||||
#ifdef DEBUG
|
||||
printf("t1=%08X / d0=%08X = %X (%X)\n",t1,d0,q,t2);
|
||||
#endif
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
t2=(BN_ULLONG)d1*q;
|
||||
t3=t1-(BN_ULLONG)q*d0;
|
||||
#ifdef DEBUG
|
||||
printf("d1*q= %X n01-q*d0 = %X\n",t2,t3);
|
||||
#endif
|
||||
if ((t3>>BN_BITS2) ||
|
||||
(t2 <= ((t3<<BN_BITS2)+wnump[-2])))
|
||||
break;
|
||||
#ifdef DEBUG
|
||||
printf("reduce q\n");
|
||||
#endif
|
||||
q--;
|
||||
}
|
||||
l0=bn_mul_word(tmp->d,sdiv->d,div_n,q);
|
||||
if (l0)
|
||||
tmp->d[div_n]=l0;
|
||||
else
|
||||
tmp->d[div_n]=0;
|
||||
for (j=div_n+1; j>0; j--)
|
||||
if (tmp->d[j-1]) break;
|
||||
tmp->top=j;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("q=%08X\n",q);
|
||||
BN_print(stdout,&wnum); printf(" number\n");
|
||||
BN_print(stdout,tmp); printf(" subtract\n");
|
||||
|
||||
BN_print(stdout,snum); printf(" shifted number before\n");
|
||||
BN_print(stdout,&wnum); printf(" wnum before\n");
|
||||
#endif
|
||||
j=wnum.top;
|
||||
BN_sub(&wnum,&wnum,tmp);
|
||||
snum->top=snum->top+wnum.top-j;
|
||||
|
||||
#ifdef DEBUG
|
||||
BN_print(stdout,&wnum); printf(" wnum after\n");
|
||||
BN_print(stdout,snum); printf(" shifted number after\n");
|
||||
#endif
|
||||
|
||||
if (wnum.neg)
|
||||
{
|
||||
q--;
|
||||
j=wnum.top;
|
||||
BN_add(&wnum,&wnum,sdiv);
|
||||
snum->top+=wnum.top-j;
|
||||
fprintf(stderr,"addback\n");
|
||||
#ifdef DEBUG
|
||||
BN_print(stdout,snum); printf("after addback************************:\n");
|
||||
#endif
|
||||
}
|
||||
*(resp--)=q;
|
||||
#ifdef DEBUG
|
||||
BN_print(stdout,res); printf(" result\n");
|
||||
#endif
|
||||
wnump--;
|
||||
}
|
||||
if (rm != NULL)
|
||||
BN_rshift(rm,snum,norm_shift);
|
||||
return(1);
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
BIGNUM *a,*b,*c,*d;
|
||||
BIGNUM *cc,*dd;
|
||||
BN_CTX *ctx;
|
||||
int i,x;
|
||||
|
||||
a=BN_new();
|
||||
b=BN_new();
|
||||
c=BN_new();
|
||||
d=BN_new();
|
||||
cc=BN_new();
|
||||
dd=BN_new();
|
||||
ctx=BN_CTX_new();
|
||||
|
||||
for (i=0; i<10240; i++)
|
||||
{
|
||||
BN_rand(a,80,0,0);
|
||||
BN_rand(b,60,0,0);
|
||||
|
||||
BN_div2(d,c,a,b,ctx);
|
||||
BN_div(dd,cc,a,b,ctx);
|
||||
if ((BN_cmp(d,dd) != 0) || (BN_cmp(c,cc) != 0))
|
||||
{
|
||||
BN_print(stderr,a); fprintf(stderr," / ");
|
||||
BN_print(stderr,b); fprintf(stderr," d=");
|
||||
BN_print(stderr,d); fprintf(stderr," r= ");
|
||||
BN_print(stderr,c); fprintf(stderr,"\nd=");
|
||||
BN_print(stderr,dd); fprintf(stderr," r= ");
|
||||
BN_print(stderr,cc); fprintf(stderr,"\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef undef
|
||||
/*
|
||||
BN_rand(a,600,0,0);
|
||||
BN_rand(b,400,0,0);
|
||||
for (i=0; i<2000000; i++)
|
||||
{
|
||||
BN_div2(d,c,a,b,ctx);
|
||||
}
|
||||
*/
|
||||
/* for (i=0;;) */
|
||||
/* for (i=0; i<0xffffffff; i++)
|
||||
{
|
||||
BN_ULONG rr,r,a,b,c;
|
||||
BN_ULLONG l;
|
||||
|
||||
a=rand()&BN_MASK2;
|
||||
b=rand()&BN_MASK2;
|
||||
for (;;)
|
||||
{
|
||||
c=rand()&BN_MASK2;
|
||||
if (c) break;
|
||||
}
|
||||
/* for (x=1; x<256*256; x++) */
|
||||
{
|
||||
c=x;
|
||||
a=i>>8;
|
||||
b=i&0xff;
|
||||
a&= ~(0xFFFFFF<<(BN_num_bits_word(c)));
|
||||
|
||||
r=bn_div_2word(a,b,c);
|
||||
|
||||
rr=(BN_ULONG)((((BN_ULLONG)a<<BN_BITS2)|b)/c);
|
||||
|
||||
if ((i & 0xfffff) == 0) fprintf(stderr,"%d\n",i,r,rr);
|
||||
/*if (x == 255)
|
||||
fprintf(stderr,"%6d/%3d = %4d %4d\n",(a<<8)|b,c,r,rr); */
|
||||
if (rr != r)
|
||||
{
|
||||
fprintf(stderr,"%8d %02X%02X / %02X = %02X %02X\n",
|
||||
i,a,b,c,rr,r);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Divide h-l by d and return the result. */
|
||||
BN_ULONG bn_div_2word(l,h,d)
|
||||
BN_ULONG l,h,d;
|
||||
{
|
||||
BN_ULONG dh,dl,q,ret=0,th,tl,t,top;
|
||||
int i,count=2;
|
||||
|
||||
if (d == 0) return(-1);
|
||||
|
||||
i=BN_num_bits_word(d);
|
||||
if ((i != BN_BITS2) && (h > 1<<i))
|
||||
{
|
||||
fprintf(stderr,"Division would overflow\n");
|
||||
abort();
|
||||
}
|
||||
i=BN_BITS2-i;
|
||||
if (h >= d) h-=d;
|
||||
|
||||
if (i)
|
||||
{
|
||||
d<<=i;
|
||||
h=(h<<i)|(l>>(BN_BITS2-i));
|
||||
l<<=i;
|
||||
}
|
||||
dh=(d&BN_MASK2h)>>BN_BITS4;
|
||||
dl=(d&BN_MASK2l);
|
||||
for (;;)
|
||||
{
|
||||
if ((h>>BN_BITS4) == dh)
|
||||
q=BN_MASK2l;
|
||||
else
|
||||
q=h/dh;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
t=(h-q*dh);
|
||||
if ((t&BN_MASK2h) ||
|
||||
((dl*q) <= (
|
||||
(t<<BN_BITS4)+
|
||||
((l&BN_MASK2h)>>BN_BITS4))))
|
||||
break;
|
||||
q--;
|
||||
}
|
||||
th=q*dh;
|
||||
tl=q*dl;
|
||||
t=(tl>>BN_BITS4);
|
||||
tl=(tl<<BN_BITS4)&BN_MASK2h;
|
||||
th+=t;
|
||||
|
||||
if (l < tl) th++;
|
||||
l-=tl;
|
||||
if (h < th)
|
||||
{
|
||||
fprintf(stderr,"add back\n");
|
||||
h+=d;
|
||||
q--;
|
||||
}
|
||||
h-=th;
|
||||
|
||||
if (--count == 0) break;
|
||||
|
||||
ret=q<<BN_BITS4;
|
||||
h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
|
||||
l=(l&BN_MASK2l)<<BN_BITS4;
|
||||
}
|
||||
ret|=q;
|
||||
return(ret);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
All numbers (a) are stored aR mod N (except abRR)
|
||||
|
||||
RR = REDC(R*R) /* RR mod N */
|
||||
|
||||
|
||||
convert a -> aR
|
||||
convert b -> bR
|
||||
|
||||
{
|
||||
abRR = aR * bR
|
||||
abR = REDC(abRR); /* mod N */
|
||||
}
|
||||
|
||||
ab = REDC(abR); /* mod N */
|
||||
|
||||
|
||||
REDC strips off a multiplicaion by R mod N
|
||||
@@ -1,410 +0,0 @@
|
||||
/* crypto/bn/wei_mulw.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
BN_ULONG bn_add_word(BN_ULONG *a,BN_ULONG c,int num);
|
||||
BN_ULONG bn_add_words(BN_ULONG *ret,BN_ULONG *a,BN_ULONG *b,int num);
|
||||
BN_ULONG bn_sub_words(BN_ULONG *ret,BN_ULONG *a,BN_ULONG *b,int num);
|
||||
|
||||
void BN_mul_4words(BN_ULONG *ret,BN_ULONG a0,BN_ULONG a1,
|
||||
BN_ULONG b0,BN_ULONG b1);
|
||||
|
||||
void pr(a,n,s)
|
||||
BN_ULONG *a;
|
||||
int n;
|
||||
{
|
||||
while (n--)
|
||||
fprintf(stdout,"%02X",a[n]);
|
||||
fprintf(stdout,"%s",s);
|
||||
}
|
||||
|
||||
|
||||
BN_ULONG bn_add_word(a,w,num)
|
||||
BN_ULONG *a;
|
||||
BN_ULONG w;
|
||||
int num;
|
||||
{
|
||||
BN_ULONG t;
|
||||
|
||||
#ifdef DEBUG
|
||||
{ BN_ULONG *aa=a; int i; for (i=num; i>0; i--) fprintf(stdout,"%02X",aa[i-1]);
|
||||
fprintf(stdout," + %X - ",w); i=num;
|
||||
#endif
|
||||
|
||||
loop:
|
||||
t= *a;
|
||||
t=(t+w)&BN_MASK2;
|
||||
*(a++)=t;
|
||||
w=(t < w);
|
||||
if (w && --num) goto loop;
|
||||
|
||||
#ifdef DEBUG
|
||||
for (; i>0; i--) fprintf(stdout,"%02X",aa[i-1]);
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
return(w);
|
||||
}
|
||||
|
||||
BN_ULONG bn_add_words(r,a,b,num)
|
||||
BN_ULONG *r;
|
||||
BN_ULONG *a;
|
||||
BN_ULONG *b;
|
||||
int num;
|
||||
{
|
||||
#if defined(BN_LLONG)
|
||||
BN_ULLONG t;
|
||||
BN_ULONG c=0;
|
||||
int i;
|
||||
|
||||
if (num&1) abort();
|
||||
|
||||
for (i=0; i<num; i+=2)
|
||||
{
|
||||
t=(BN_ULLONG)a[i]+b[i]+c;
|
||||
r[i+0]=L(t);
|
||||
t=(BN_ULLONG) H(t)+a[i+1]+b[i+1];
|
||||
r[i+1]=L(t);
|
||||
c=H(t);
|
||||
}
|
||||
return(c);
|
||||
#else
|
||||
BN_ULONG c=0,t1,t2;
|
||||
|
||||
for ( ; num; num--)
|
||||
{
|
||||
t1= *(a++);
|
||||
t2= *(b++);
|
||||
|
||||
if (c)
|
||||
{
|
||||
c=(t2 >= ((~t1)&BN_MASK2));
|
||||
(*r++)=(t1+t2+1)&BN_MASK2;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2=(t1+t2)&BN_MASK2;
|
||||
c=(t2 < t1);
|
||||
(*r++)=t2;
|
||||
}
|
||||
}
|
||||
return(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
BN_ULONG bn_sub_words(r,a,b,num)
|
||||
BN_ULONG *r;
|
||||
BN_ULONG *a;
|
||||
BN_ULONG *b;
|
||||
int num;
|
||||
{
|
||||
#if defined(BN_LLONG)
|
||||
BN_ULLONG t;
|
||||
BN_ULONG c=0;
|
||||
int i;
|
||||
|
||||
if (num&1) abort();
|
||||
|
||||
for (i=0; i<num; i+=2)
|
||||
{
|
||||
t=(BN_ULLONG)a[i]-b[i]-c;
|
||||
r[i+0]=L(t);
|
||||
t=(BN_ULLONG)a[i+1]-b[i+1]-(0-H(t))&BN_MASK2;
|
||||
r[i+1]=L(t);
|
||||
c=H(t);
|
||||
}
|
||||
return(c);
|
||||
#else
|
||||
BN_ULONG c=0,t1,t2;
|
||||
|
||||
for ( ; num; num--)
|
||||
{
|
||||
t1= *(a++);
|
||||
t2= *(b++);
|
||||
|
||||
if (c)
|
||||
{
|
||||
c=(t1 <= t2);
|
||||
t1=(t1-t2-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
c=(t1 < t2);
|
||||
t1=(t1-t2);
|
||||
}
|
||||
(*r++)=t1&BN_MASK2;
|
||||
}
|
||||
return(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* ret[3,2,1,0] = a1,a0 * b1,b0 */
|
||||
void BN_mul_4words(ret,a0,a1,b0,b1)
|
||||
BN_ULONG *ret;
|
||||
BN_ULONG a0,a1,b0,b1;
|
||||
{
|
||||
BN_ULONG s,u;
|
||||
BN_ULLONG fix,a0b0,a1b1,tmp;
|
||||
|
||||
if (a1 >= a0)
|
||||
{
|
||||
s=(a1-a0);
|
||||
u=(b0-b1);
|
||||
fix=(BN_ULLONG)s*u;
|
||||
if (b0 >= b1) s=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
BN_ULONG u;
|
||||
|
||||
if (b0 > b1)
|
||||
{
|
||||
s=(b0-b1);
|
||||
u=(a1-a0);
|
||||
fix=(BN_ULLONG)s*u;
|
||||
}
|
||||
else
|
||||
{
|
||||
u=(a0-a1);
|
||||
s=(b1-b0);
|
||||
fix=(BN_ULLONG)s*u;
|
||||
s=0;
|
||||
}
|
||||
}
|
||||
|
||||
a0b0=(BN_ULLONG)a0*b0;
|
||||
ret[0]=L(a0b0);
|
||||
|
||||
a1b1=(BN_ULLONG)a1*b1;
|
||||
tmp=(BN_ULLONG) H(a0b0) + L(a0b0) + L(fix) + L(a1b1);
|
||||
ret[1]=L(tmp);
|
||||
|
||||
tmp=(BN_ULLONG) a1b1 + H(tmp) + H(a0b0) + H(fix) + H(a1b1) - s;
|
||||
ret[2]=L(tmp);
|
||||
ret[3]=H(tmp);
|
||||
}
|
||||
|
||||
/* ret[3,2,1,0] += a1,a0 * b1,b0 */
|
||||
BN_ULONG BN_mul_add_4words(ret,a0,a1,b0,b1)
|
||||
BN_ULONG *ret;
|
||||
BN_ULONG a0,a1,b0,b1;
|
||||
{
|
||||
BN_ULONG s,u;
|
||||
BN_ULLONG fix,a0b0,a1b1,tmp;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"%02X%02X%02X%02X",ret[3],ret[2],ret[1],ret[0]);
|
||||
fprintf(stdout," + ( %02X%02X * %02X%02X ) - ",a1,a0,b1,b0);
|
||||
#endif
|
||||
if (a1 >= a0)
|
||||
{
|
||||
s=(a1-a0);
|
||||
u=(b0-b1);
|
||||
fix=(BN_ULLONG)s*u;
|
||||
if (b0 >= b1) s=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b0 > b1)
|
||||
{
|
||||
s=(b0-b1);
|
||||
u=(a1-a0);
|
||||
fix=(BN_ULLONG)s*u;
|
||||
}
|
||||
else
|
||||
{
|
||||
u=(a0-a1);
|
||||
s=(b1-b0);
|
||||
fix=(BN_ULLONG)s*u;
|
||||
s=0;
|
||||
}
|
||||
}
|
||||
|
||||
a0b0=(BN_ULLONG)a0*b0;
|
||||
tmp=a0b0+ret[0];
|
||||
ret[0]=L(tmp);
|
||||
|
||||
a1b1=(BN_ULLONG)a1*b1;
|
||||
tmp=(BN_ULLONG) H(tmp) + L(a0b0) + L(fix) + L(a1b1) + ret[1];
|
||||
ret[1]=L(tmp);
|
||||
|
||||
tmp=(BN_ULLONG) H(tmp) + L(a1b1) + H(a0b0) +
|
||||
H(fix) + H(a1b1) -s + ret[2];
|
||||
ret[2]=L(tmp);
|
||||
|
||||
tmp=(BN_ULLONG) H(tmp) + H(a1b1) + ret[3];
|
||||
ret[3]=L(tmp);
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"%02X%02X%02X%02X%02X\n",H(tmp),ret[3],ret[2],ret[1],ret[0]);
|
||||
#endif
|
||||
return(H(tmp));
|
||||
}
|
||||
|
||||
/* ret[3,2,1,0] += a1,a0 * a1,a0 */
|
||||
void BN_sqr_4words(ret,a0,a1)
|
||||
BN_ULONG *ret;
|
||||
BN_ULONG a0,a1;
|
||||
{
|
||||
BN_ULONG s,u;
|
||||
BN_ULLONG tmp,tmp2;
|
||||
|
||||
tmp=(BN_ULLONG)a0*a0;
|
||||
ret[0]=L(tmp);
|
||||
|
||||
tmp2=(BN_ULLONG)a0*a1;
|
||||
tmp=(BN_ULLONG)H(tmp)+L(tmp2)*2;
|
||||
ret[1]=L(tmp);
|
||||
|
||||
tmp=(BN_ULLONG)a1*a1+H(tmp)+H(tmp2)*2;
|
||||
ret[2]=L(tmp);
|
||||
ret[3]=L(tmp);
|
||||
}
|
||||
|
||||
#define N0 (0)
|
||||
#define N1 (half)
|
||||
#define N2 (num)
|
||||
#define N3 (num+half)
|
||||
|
||||
#define word_cmp(r,a,b,num) \
|
||||
{ \
|
||||
int n=num; \
|
||||
\
|
||||
(r)=0; \
|
||||
while (n--) \
|
||||
{ \
|
||||
if ((a)[(n)] > (b)[(n)]) \
|
||||
{ (r)=1; break; } \
|
||||
else if ((a)[(n)] < (b)[(n)]) \
|
||||
{ (r)= -1; break; } \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/* (a->top == b->top) && (a->top >= 2) && !(a->top & 1) */
|
||||
void bn_recursize_mul(r,t,a,b,num)
|
||||
BN_ULONG *r,*t,*a,*b;
|
||||
int num;
|
||||
{
|
||||
if ((num < 2) || (num&1))
|
||||
abort();
|
||||
|
||||
/* fprintf(stderr,"num=%d half=%d\n",num,num/2);*/
|
||||
if (num == 2)
|
||||
BN_mul_4words(r,a[0],a[1],b[0],b[1]);
|
||||
else if (num == 4)
|
||||
{
|
||||
BN_ULONG c,tmp;
|
||||
|
||||
BN_mul_4words(&(r[0]),a[0],a[1],b[0],b[1]);
|
||||
BN_mul_4words(&(r[4]),a[2],a[3],b[2],b[3]);
|
||||
|
||||
c =BN_mul_add_4words(&(r[2]),a[0],a[1],b[2],b[3]);
|
||||
c+=BN_mul_add_4words(&(r[2]),a[2],a[3],b[0],b[1]);
|
||||
|
||||
bn_add_word(&(r[6]),c,2);
|
||||
}
|
||||
else
|
||||
{
|
||||
int half=num/2;
|
||||
int carry,cmp_a,cmp_b;
|
||||
|
||||
word_cmp(cmp_a,&(a[0]),&(a[half]),half);
|
||||
word_cmp(cmp_b,&(b[0]),&(b[half]),half);
|
||||
|
||||
switch (cmp_a*2+cmp_a+cmp_b)
|
||||
{
|
||||
case -4:
|
||||
bn_sub_words(&(t[N0]),&(a[N1]),&(a[N0]),half);
|
||||
bn_sub_words(&(t[N1]),&(b[N0]),&(b[N1]),half);
|
||||
bn_recursize_mul(&(r[N1]),&(t[N2]),
|
||||
&(t[N0]),&(t[N1]),half);
|
||||
bn_sub_words(&(r[N2]),&(r[N2]),&(t[N0]),half);
|
||||
carry= -1;
|
||||
break;
|
||||
case -2:
|
||||
bn_sub_words(&(t[N0]),&(a[N1]),&(a[N0]),half);
|
||||
bn_sub_words(&(t[N1]),&(b[N0]),&(b[N1]),half);
|
||||
bn_recursize_mul(&(r[N1]),&(t[N2]),
|
||||
&(t[N0]),&(t[N1]),half);
|
||||
carry=0;
|
||||
break;
|
||||
case 2:
|
||||
bn_sub_words(&(t[N0]),&(a[N0]),&(a[N1]),half);
|
||||
bn_sub_words(&(t[N1]),&(b[N1]),&(b[N0]),half);
|
||||
bn_recursize_mul(&(r[N1]),&(t[N2]),
|
||||
&(t[N0]),&(t[N1]),half);
|
||||
carry=0;
|
||||
break;
|
||||
case 4:
|
||||
bn_sub_words(&(t[N0]),&(a[N1]),&(a[N0]),half);
|
||||
bn_sub_words(&(t[N1]),&(b[N0]),&(b[N1]),half);
|
||||
bn_recursize_mul(&(r[N1]),&(t[N2]),
|
||||
&(t[N0]),&(t[N1]),half);
|
||||
bn_sub_words(&(r[N2]),&(r[N2]),&(t[N1]),half);
|
||||
carry= -1;
|
||||
break;
|
||||
default:
|
||||
memset(&(r[N1]),0,sizeof(BN_ULONG)*num);
|
||||
break;
|
||||
}
|
||||
|
||||
bn_recursize_mul(&(t[N0]),&(t[N2]),&(a[N0]),&(b[N0]),half);
|
||||
#ifdef DEBUG
|
||||
pr(a,half," * ");
|
||||
pr(b,half," - ");
|
||||
pr(t,num," - 0\n");
|
||||
#endif
|
||||
memcpy(&(r[N0]),&(t[N0]),half*sizeof(BN_ULONG));
|
||||
if (bn_add_words(&(r[N1]),&(r[N1]),&(t[N1]),half))
|
||||
{ bn_add_word(&(t[N1]),1,half); }
|
||||
|
||||
carry+=bn_add_words(&(r[N1]),&(r[N1]),&(t[N0]),num);
|
||||
|
||||
bn_recursize_mul(&(t[N0]),&(t[N2]),&(a[N1]),&(b[N1]),half);
|
||||
|
||||
carry+=bn_add_words(&(r[N1]),&(r[N1]),&(t[N0]),num);
|
||||
carry+=bn_add_words(&(r[N2]),&(r[N2]),&(t[N0]),half);
|
||||
memcpy(&(r[N3]),&(t[N1]),half*sizeof(BN_ULONG));
|
||||
|
||||
bn_add_word(&(r[N3]),carry,half);
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
BIGNUM *a,*b,*r,*t;
|
||||
int i,j;
|
||||
|
||||
a=BN_new();
|
||||
b=BN_new();
|
||||
r=BN_new();
|
||||
t=BN_new();
|
||||
|
||||
#define BITS 1024
|
||||
bn_expand(r,BITS*2);
|
||||
bn_expand(t,BITS*2);
|
||||
fprintf(stdout,"obase=16\n");
|
||||
fprintf(stdout,"ibase=16\n");
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
BN_rand(a,BITS,0,0);
|
||||
BN_rand(b,BITS,0,0);
|
||||
r->top=(BITS*2)/BN_BITS2;
|
||||
memset(r->d,0,sizeof(r->top)*sizeof(BN_ULONG));
|
||||
memset(t->d,0,sizeof(r->top)*sizeof(BN_ULONG));
|
||||
for (j=0; j<1000; j++)
|
||||
{
|
||||
|
||||
/* BN_mul(r,a,b); /**/
|
||||
bn_recursize_mul(r->d,t->d,a->d,b->d,a->top); /**/
|
||||
}
|
||||
BN_print(stdout,a); fprintf(stdout," * ");
|
||||
BN_print(stdout,b); fprintf(stdout," - ");
|
||||
BN_print(stdout,r); fprintf(stdout,"\n");
|
||||
}
|
||||
}
|
||||
@@ -1,929 +0,0 @@
|
||||
; Don't even think of reading this code
|
||||
; It was automatically generated by crypt.pl
|
||||
; Which is a perl program used to generate the x86 assember for
|
||||
; any of elf, a.out, Win32, or Solaris
|
||||
; It can be found in SSLeay 0.6.5+ or in libdes 3.26+
|
||||
; eric <eay@cryptsoft.com>
|
||||
; The inner loop instruction sequence and the IP/FP modifications
|
||||
; are from Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
;
|
||||
TITLE dx86xxxx.asm
|
||||
.386
|
||||
.model FLAT
|
||||
_TEXT SEGMENT
|
||||
PUBLIC _fcrypt_body
|
||||
EXTRN _des_SPtrans:DWORD
|
||||
_fcrypt_body PROC NEAR
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
;
|
||||
; Load the 2 words
|
||||
xor edi, edi
|
||||
xor esi, esi
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov DWORD PTR 36[esp],25
|
||||
L000start:
|
||||
;
|
||||
; Round 0
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR [ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 4[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 1
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 8[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 12[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 2
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 16[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 20[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 3
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 24[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 28[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 4
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 32[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 36[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 5
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 40[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 44[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 6
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 48[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 52[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 7
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 56[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 60[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 8
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 64[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 68[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 9
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 72[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 76[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 10
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 80[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 84[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 11
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 88[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 92[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 12
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 96[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 100[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 13
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 104[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 108[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 14
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 112[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 116[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 15
|
||||
mov eax, DWORD PTR 28[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 32[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 120[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 124[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
mov eax, edi
|
||||
dec DWORD PTR 36[esp]
|
||||
mov edi, esi
|
||||
mov esi, eax
|
||||
jnz L000start
|
||||
;
|
||||
; FP
|
||||
mov edx, DWORD PTR 20[esp]
|
||||
ror edi, 1
|
||||
mov eax, esi
|
||||
xor esi, edi
|
||||
and esi, 0aaaaaaaah
|
||||
xor eax, esi
|
||||
xor edi, esi
|
||||
;
|
||||
rol eax, 23
|
||||
mov esi, eax
|
||||
xor eax, edi
|
||||
and eax, 003fc03fch
|
||||
xor esi, eax
|
||||
xor edi, eax
|
||||
;
|
||||
rol esi, 10
|
||||
mov eax, esi
|
||||
xor esi, edi
|
||||
and esi, 033333333h
|
||||
xor eax, esi
|
||||
xor edi, esi
|
||||
;
|
||||
rol edi, 18
|
||||
mov esi, edi
|
||||
xor edi, eax
|
||||
and edi, 0fff0000fh
|
||||
xor esi, edi
|
||||
xor eax, edi
|
||||
;
|
||||
rol esi, 12
|
||||
mov edi, esi
|
||||
xor esi, eax
|
||||
and esi, 0f0f0f0f0h
|
||||
xor edi, esi
|
||||
xor eax, esi
|
||||
;
|
||||
ror eax, 4
|
||||
mov DWORD PTR [edx],eax
|
||||
mov DWORD PTR 4[edx],edi
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
_fcrypt_body ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
@@ -1,99 +0,0 @@
|
||||
begin 640 c-win32.obj
|
||||
M3`$"`/4&DC,,$```"0`````````N=&5X=```````````````J`H``&0````,
|
||||
M"P```````(`````@`#!@+F1A=&$```"H"@`````````````,$```````````
|
||||
M````````0``PP%535E<S_S/VBVPD&,=$)"09````BT0D'(O6P>H0BTPD(#/6
|
||||
M(\(CT8O8P>,0B\K!X1`SPS/1BUT`,\.+300SQC/6,]$E_/S\_#/;@>+/S\_/
|
||||
M,\F*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!```S_8K<P>H0
|
||||
MBZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[BYD`!P``,_N+F``$
|
||||
M```S^XN:``4``#/[BT0D'(O7P>H0BTPD(#/7(\(CT8O8P>,0B\K!X1`SPS/1
|
||||
MBUT(,\.+30PSQS/7,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS
|
||||
M]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+;"08BLXE_P``
|
||||
M`('B_P```(N;``8``#/SBYD`!P``,_.+F``$```S\XN:``4``#/SBT0D'(O6
|
||||
MP>H0BTPD(#/6(\(CT8O8P>,0B\K!X1`SPS/1BUT0,\.+310SQC/6,]$E_/S\
|
||||
M_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!
|
||||
M```S_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[BYD`
|
||||
M!P``,_N+F``$```S^XN:``4``#/[BT0D'(O7P>H0BTPD(#/7(\(CT8O8P>,0
|
||||
MB\K!X1`SPS/1BUT8,\.+31PSQS/7,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$
|
||||
MBZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+
|
||||
M;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$```S\XN:``4`
|
||||
M`#/SBT0D'(O6P>H0BTPD(#/6(\(CT8O8P>,0B\K!X1`SPS/1BUT@,\.+320S
|
||||
MQC/6,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS_8NI``(``#/]
|
||||
MBL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;
|
||||
M``8``#/[BYD`!P``,_N+F``$```S^XN:``4``#/[BT0D'(O7P>H0BTPD(#/7
|
||||
M(\(CT8O8P>,0B\K!X1`SPS/1BUTH,\.+32PSQS/7,]$E_/S\_#/;@>+/S\_/
|
||||
M,\F*V(K,P<H$BZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0
|
||||
MBZD``P``,_6+;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$
|
||||
M```S\XN:``4``#/SBT0D'(O6P>H0BTPD(#/6(\(CT8O8P>,0B\K!X1`SPS/1
|
||||
MBUTP,\.+330SQC/6,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS
|
||||
M_8NI``(``#/]BL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+;"08BLXE_P``
|
||||
M`('B_P```(N;``8``#/[BYD`!P``,_N+F``$```S^XN:``4``#/[BT0D'(O7
|
||||
MP>H0BTPD(#/7(\(CT8O8P>,0B\K!X1`SPS/1BUTX,\.+33PSQS/7,]$E_/S\
|
||||
M_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!
|
||||
M```S]8K<P>H0BZD``P``,_6+;"08BLXE_P```('B_P```(N;``8``#/SBYD`
|
||||
M!P``,_.+F``$```S\XN:``4``#/SBT0D'(O6P>H0BTPD(#/6(\(CT8O8P>,0
|
||||
MB\K!X1`SPS/1BUU`,\.+340SQC/6,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$
|
||||
MBZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+
|
||||
M;"08BLXE_P```('B_P```(N;``8``#/[BYD`!P``,_N+F``$```S^XN:``4`
|
||||
M`#/[BT0D'(O7P>H0BTPD(#/7(\(CT8O8P>,0B\K!X1`SPS/1BUU(,\.+34PS
|
||||
MQS/7,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS]8NI``(``#/U
|
||||
MBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+;"08BLXE_P```('B_P```(N;
|
||||
M``8``#/SBYD`!P``,_.+F``$```S\XN:``4``#/SBT0D'(O6P>H0BTPD(#/6
|
||||
M(\(CT8O8P>,0B\K!X1`SPS/1BUU0,\.+350SQC/6,]$E_/S\_#/;@>+/S\_/
|
||||
M,\F*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!```S_8K<P>H0
|
||||
MBZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[BYD`!P``,_N+F``$
|
||||
M```S^XN:``4``#/[BT0D'(O7P>H0BTPD(#/7(\(CT8O8P>,0B\K!X1`SPS/1
|
||||
MBUU8,\.+35PSQS/7,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS
|
||||
M]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+;"08BLXE_P``
|
||||
M`('B_P```(N;``8``#/SBYD`!P``,_.+F``$```S\XN:``4``#/SBT0D'(O6
|
||||
MP>H0BTPD(#/6(\(CT8O8P>,0B\K!X1`SPS/1BUU@,\.+360SQC/6,]$E_/S\
|
||||
M_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!
|
||||
M```S_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[BYD`
|
||||
M!P``,_N+F``$```S^XN:``4``#/[BT0D'(O7P>H0BTPD(#/7(\(CT8O8P>,0
|
||||
MB\K!X1`SPS/1BUUH,\.+36PSQS/7,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$
|
||||
MBZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+
|
||||
M;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$```S\XN:``4`
|
||||
M`#/SBT0D'(O6P>H0BTPD(#/6(\(CT8O8P>,0B\K!X1`SPS/1BUUP,\.+370S
|
||||
MQC/6,]$E_/S\_#/;@>+/S\_/,\F*V(K,P<H$BZL`````BMHS_8NI``(``#/]
|
||||
MBL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;
|
||||
M``8``#/[BYD`!P``,_N+F``$```S^XN:``4``#/[BT0D'(O7P>H0BTPD(#/7
|
||||
M(\(CT8O8P>,0B\K!X1`SPS/1BUUX,\.+37PSQS/7,]$E_/S\_#/;@>+/S\_/
|
||||
M,\F*V(K,P<H$BZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0
|
||||
MBZD``P``,_6+;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$
|
||||
M```S\XN:``4``#/SB\?_3"0DB_Z+\`^%T/7__XM4)!31SXO&,_>!YJJJJJHS
|
||||
MQC/^P<`7B_`SQR7\`_P#,_`S^,'&"HO&,_>!YC,S,S,SQC/^P<<2B_<S^('G
|
||||
M#P#P_S/W,\?!Q@R+_C/P@>;P\/#P,_XSQL'(!(D"B7H$7UY;7<-;````!P``
|
||||
M``8`90````<````&`'(````'````!@!_````!P````8`F`````<````&`*``
|
||||
M```'````!@"H````!P````8`L`````<````&`/T````'````!@`'`0``!P``
|
||||
M``8`%`$```<````&`"$!```'````!@`Z`0``!P````8`0@$```<````&`$H!
|
||||
M```'````!@!2`0``!P````8`GP$```<````&`*D!```'````!@"V`0``!P``
|
||||
M``8`PP$```<````&`-P!```'````!@#D`0``!P````8`[`$```<````&`/0!
|
||||
M```'````!@!!`@``!P````8`2P(```<````&`%@"```'````!@!E`@``!P``
|
||||
M``8`?@(```<````&`(8"```'````!@".`@``!P````8`E@(```<````&`.,"
|
||||
M```'````!@#M`@``!P````8`^@(```<````&``<#```'````!@`@`P``!P``
|
||||
M``8`*`,```<````&`#`#```'````!@`X`P``!P````8`A0,```<````&`(\#
|
||||
M```'````!@"<`P``!P````8`J0,```<````&`,(#```'````!@#*`P``!P``
|
||||
M``8`T@,```<````&`-H#```'````!@`G!```!P````8`,00```<````&`#X$
|
||||
M```'````!@!+!```!P````8`9`0```<````&`&P$```'````!@!T!```!P``
|
||||
M``8`?`0```<````&`,D$```'````!@#3!```!P````8`X`0```<````&`.T$
|
||||
M```'````!@`&!0``!P````8`#@4```<````&`!8%```'````!@`>!0``!P``
|
||||
M``8`:P4```<````&`'4%```'````!@""!0``!P````8`CP4```<````&`*@%
|
||||
M```'````!@"P!0``!P````8`N`4```<````&`,`%```'````!@`-!@``!P``
|
||||
M``8`%P8```<````&`"0&```'````!@`Q!@``!P````8`2@8```<````&`%(&
|
||||
M```'````!@!:!@``!P````8`8@8```<````&`*\&```'````!@"Y!@``!P``
|
||||
M``8`Q@8```<````&`-,&```'````!@#L!@``!P````8`]`8```<````&`/P&
|
||||
M```'````!@`$!P``!P````8`40<```<````&`%L'```'````!@!H!P``!P``
|
||||
M``8`=0<```<````&`(X'```'````!@"6!P``!P````8`G@<```<````&`*8'
|
||||
M```'````!@#S!P``!P````8`_0<```<````&``H(```'````!@`7"```!P``
|
||||
M``8`,`@```<````&`#@(```'````!@!`"```!P````8`2`@```<````&`)4(
|
||||
M```'````!@"?"```!P````8`K`@```<````&`+D(```'````!@#2"```!P``
|
||||
M``8`V@@```<````&`.((```'````!@#J"```!P````8`-PD```<````&`$$)
|
||||
M```'````!@!."0``!P````8`6PD```<````&`'0)```'````!@!\"0``!P``
|
||||
M``8`A`D```<````&`(P)```'````!@#9"0``!P````8`XPD```<````&`/`)
|
||||
M```'````!@#]"0``!P````8`%@H```<````&`!X*```'````!@`F"@``!P``
|
||||
M``8`+@H```<````&`"YF:6QE`````````/[_``!G`BY<8W)Y<'1O7&1E<UQA
|
||||
M<VU<8RUW:6XS,BYA<VT``````````"YT97AT``````````$````#`:@*``"`
|
||||
M`````````````````"YD871A``````````(````#`0``````````````````
|
||||
M```````````$```````````````"```````1``````````$`(``"`!X```!?
|
||||
99&5S7U-0=')A;G,`7V9C<GEP=%]B;V1Y````
|
||||
`
|
||||
end
|
||||
@@ -1,240 +0,0 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# The inner loop instruction sequence and the IP/FP modifications are from
|
||||
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
# I've added the stuff needed for crypt() but I've not worried about making
|
||||
# things perfect.
|
||||
#
|
||||
|
||||
$prog="crypt.pl";
|
||||
|
||||
# base code is in microsft
|
||||
# op dest, source
|
||||
# format.
|
||||
#
|
||||
|
||||
require "desboth.pl";
|
||||
|
||||
if ( ($ARGV[0] eq "elf"))
|
||||
{ require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "a.out"))
|
||||
{ $aout=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "sol"))
|
||||
{ $sol=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "cpp"))
|
||||
{ $cpp=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "win32"))
|
||||
{ require "x86ms.pl"; }
|
||||
else
|
||||
{
|
||||
print STDERR <<"EOF";
|
||||
Pick one target type from
|
||||
elf - linux, FreeBSD etc
|
||||
a.out - old linux
|
||||
sol - x86 solaris
|
||||
cpp - format so x86unix.cpp can be used
|
||||
win32 - Windows 95/Windows NT
|
||||
EOF
|
||||
exit(1);
|
||||
}
|
||||
|
||||
&comment("Don't even think of reading this code");
|
||||
&comment("It was automatically generated by $prog");
|
||||
&comment("Which is a perl program used to generate the x86 assember for");
|
||||
&comment("any of elf, a.out, Win32, or Solaris");
|
||||
&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
|
||||
&comment("eric <eay\@cryptsoft.com>");
|
||||
&comment("The inner loop instruction sequence and the IP/FP modifications");
|
||||
&comment("are from Svend Olaf Mikkelsen <svolaf\@inet.uni-c.dk>");
|
||||
|
||||
&comment("");
|
||||
|
||||
&file("dx86xxxx");
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
|
||||
&fcrypt_body("fcrypt_body");
|
||||
|
||||
&file_end();
|
||||
|
||||
sub fcrypt_body
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
|
||||
&function_begin($name,3,"EXTRN _des_SPtrans:DWORD");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
$ks="ebp";
|
||||
|
||||
&xor( $L, $L);
|
||||
&xor( $R, $R);
|
||||
&mov($ks,&wparam(1));
|
||||
|
||||
&mov(&wtmp(1), 25);
|
||||
|
||||
&set_label("start");
|
||||
for ($i=0; $i<16; $i+=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i+1));
|
||||
&D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
&mov("eax", $L);
|
||||
&dec(&wtmp(1));
|
||||
&mov($L, $R);
|
||||
&mov($R, "eax");
|
||||
&jnz(&label("start"));
|
||||
|
||||
&comment("");
|
||||
&comment("FP");
|
||||
&mov("edx",&wparam(0));
|
||||
|
||||
&FP_new($R,$L,"eax",3);
|
||||
&mov(&DWP(0,"edx","",0),"eax");
|
||||
&mov(&DWP(4,"edx","",0),$L);
|
||||
|
||||
&function_end($name);
|
||||
}
|
||||
|
||||
sub D_ENCRYPT
|
||||
{
|
||||
local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
|
||||
|
||||
&mov( $u, &wparam(2)); # 2
|
||||
&mov( $t, $R);
|
||||
&shr( $t, 16); # 1
|
||||
&mov( $tmp2, &wparam(3)); # 2
|
||||
&xor( $t, $R); # 1
|
||||
|
||||
&and( $u, $t); # 2
|
||||
&and( $t, $tmp2); # 2
|
||||
|
||||
&mov( $tmp1, $u);
|
||||
&shl( $tmp1, 16); # 1
|
||||
&mov( $tmp2, $t);
|
||||
&shl( $tmp2, 16); # 1
|
||||
&xor( $u, $tmp1); # 2
|
||||
&xor( $t, $tmp2); # 2
|
||||
&mov( $tmp1, &DWP(&n2a($S*4),$ks,"",0)); # 2
|
||||
&xor( $u, $tmp1);
|
||||
&mov( $tmp2, &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2
|
||||
&xor( $u, $R);
|
||||
&xor( $t, $R);
|
||||
&xor( $t, $tmp2);
|
||||
|
||||
&and( $u, "0xfcfcfcfc" ); # 2
|
||||
&xor( $tmp1, $tmp1); # 1
|
||||
&and( $t, "0xcfcfcfcf" ); # 2
|
||||
&xor( $tmp2, $tmp2);
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&rotr( $t, 4 );
|
||||
&mov( $ks, &DWP(" $desSP",$tmp1,"",0));
|
||||
&movb( &LB($tmp1), &LB($t) );
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks);
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&shr( $u, 16);
|
||||
&mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $ks);
|
||||
&movb( &LB($tmp1), &HB($u) );
|
||||
&shr( $t, 16);
|
||||
&mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP(24,"esp","",0));
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&and( $u, "0xff" );
|
||||
&and( $t, "0xff" );
|
||||
&mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x400+$desSP",$u,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
}
|
||||
|
||||
sub n2a
|
||||
{
|
||||
sprintf("%d",$_[0]);
|
||||
}
|
||||
|
||||
# now has a side affect of rotating $a by $shift
|
||||
sub R_PERM_OP
|
||||
{
|
||||
local($a,$b,$tt,$shift,$mask,$last)=@_;
|
||||
|
||||
&rotl( $a, $shift ) if ($shift != 0);
|
||||
&mov( $tt, $a );
|
||||
&xor( $a, $b );
|
||||
&and( $a, $mask );
|
||||
if ($notlast eq $b)
|
||||
{
|
||||
&xor( $b, $a );
|
||||
&xor( $tt, $a );
|
||||
}
|
||||
else
|
||||
{
|
||||
&xor( $tt, $a );
|
||||
&xor( $b, $a );
|
||||
}
|
||||
&comment("");
|
||||
}
|
||||
|
||||
sub IP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l);
|
||||
&R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
|
||||
&R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
|
||||
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotr($tt, 3-$lr); }
|
||||
else { &rotl($tt, $lr-3); }
|
||||
}
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotr($r, 2-$lr); }
|
||||
else { &rotl($r, $lr-2); }
|
||||
}
|
||||
}
|
||||
|
||||
sub FP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotl($r, 2-$lr); }
|
||||
else { &rotr($r, $lr-2); }
|
||||
}
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotl($l, 3-$lr); }
|
||||
else { &rotr($l, $lr-3); }
|
||||
}
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r);
|
||||
&R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt,10,"0x33333333",$l);
|
||||
&R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r);
|
||||
&rotr($tt , 4);
|
||||
}
|
||||
|
||||
@@ -1,932 +0,0 @@
|
||||
/* Don't even think of reading this code */
|
||||
/* It was automatically generated by crypt.pl */
|
||||
/* Which is a perl program used to generate the x86 assember for */
|
||||
/* any of elf, a.out, Win32, or Solaris */
|
||||
/* It can be found in SSLeay 0.6.5+ or in libdes 3.26+ */
|
||||
/* eric <eay@cryptsoft.com> */
|
||||
/* The inner loop instruction sequence and the IP/FP modifications */
|
||||
/* are from Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> */
|
||||
|
||||
.file "dx86xxxx.s"
|
||||
.version "01.01"
|
||||
gcc2_compiled.:
|
||||
.text
|
||||
.align ALIGN
|
||||
.globl fcrypt_body
|
||||
TYPE(fcrypt_body,@function)
|
||||
fcrypt_body:
|
||||
pushl %ebp
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
|
||||
|
||||
/* Load the 2 words */
|
||||
xorl %edi, %edi
|
||||
xorl %esi, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movl $25, -8(%esp)
|
||||
.align ALIGN
|
||||
.L000start:
|
||||
|
||||
/* Round 0 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl (%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 4(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 1 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 8(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 12(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
|
||||
/* Round 2 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 16(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 20(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 3 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 24(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 28(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
|
||||
/* Round 4 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 32(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 36(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 5 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 40(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 44(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
|
||||
/* Round 6 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 48(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 52(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 7 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 56(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 60(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
|
||||
/* Round 8 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 64(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 68(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 9 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 72(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 76(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
|
||||
/* Round 10 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 80(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 84(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 11 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 88(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 92(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
|
||||
/* Round 12 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 96(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 100(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 13 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 104(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 108(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
|
||||
/* Round 14 */
|
||||
movl 28(%esp), %eax
|
||||
movl %esi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %esi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 112(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 116(%ebp), %ecx
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %edi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %edi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %edi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %edi
|
||||
|
||||
/* Round 15 */
|
||||
movl 28(%esp), %eax
|
||||
movl %edi, %edx
|
||||
shrl $16, %edx
|
||||
movl 32(%esp), %ecx
|
||||
xorl %edi, %edx
|
||||
andl %edx, %eax
|
||||
andl %ecx, %edx
|
||||
movl %eax, %ebx
|
||||
sall $16, %ebx
|
||||
movl %edx, %ecx
|
||||
sall $16, %ecx
|
||||
xorl %ebx, %eax
|
||||
xorl %ecx, %edx
|
||||
movl 120(%ebp), %ebx
|
||||
xorl %ebx, %eax
|
||||
movl 124(%ebp), %ecx
|
||||
xorl %edi, %eax
|
||||
xorl %edi, %edx
|
||||
xorl %ecx, %edx
|
||||
andl $0xfcfcfcfc, %eax
|
||||
xorl %ebx, %ebx
|
||||
andl $0xcfcfcfcf, %edx
|
||||
xorl %ecx, %ecx
|
||||
movb %al, %bl
|
||||
movb %ah, %cl
|
||||
rorl $4, %edx
|
||||
movl des_SPtrans(%ebx),%ebp
|
||||
movb %dl, %bl
|
||||
xorl %ebp, %esi
|
||||
movl 0x200+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %dh, %cl
|
||||
shrl $16, %eax
|
||||
movl 0x100+des_SPtrans(%ebx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movb %ah, %bl
|
||||
shrl $16, %edx
|
||||
movl 0x300+des_SPtrans(%ecx),%ebp
|
||||
xorl %ebp, %esi
|
||||
movl 24(%esp), %ebp
|
||||
movb %dh, %cl
|
||||
andl $0xff, %eax
|
||||
andl $0xff, %edx
|
||||
movl 0x600+des_SPtrans(%ebx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x700+des_SPtrans(%ecx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x400+des_SPtrans(%eax),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl 0x500+des_SPtrans(%edx),%ebx
|
||||
xorl %ebx, %esi
|
||||
movl %edi, %eax
|
||||
decl -8(%esp)
|
||||
movl %esi, %edi
|
||||
movl %eax, %esi
|
||||
jnz .L000start
|
||||
|
||||
/* FP */
|
||||
movl 20(%esp), %edx
|
||||
rorl $1, %edi
|
||||
movl %esi, %eax
|
||||
xorl %edi, %esi
|
||||
andl $0xaaaaaaaa, %esi
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edi
|
||||
|
||||
roll $23, %eax
|
||||
movl %eax, %esi
|
||||
xorl %edi, %eax
|
||||
andl $0x03fc03fc, %eax
|
||||
xorl %eax, %esi
|
||||
xorl %eax, %edi
|
||||
|
||||
roll $10, %esi
|
||||
movl %esi, %eax
|
||||
xorl %edi, %esi
|
||||
andl $0x33333333, %esi
|
||||
xorl %esi, %eax
|
||||
xorl %esi, %edi
|
||||
|
||||
roll $18, %edi
|
||||
movl %edi, %esi
|
||||
xorl %eax, %edi
|
||||
andl $0xfff0000f, %edi
|
||||
xorl %edi, %esi
|
||||
xorl %edi, %eax
|
||||
|
||||
roll $12, %esi
|
||||
movl %esi, %edi
|
||||
xorl %eax, %esi
|
||||
andl $0xf0f0f0f0, %esi
|
||||
xorl %esi, %edi
|
||||
xorl %esi, %eax
|
||||
|
||||
rorl $4, %eax
|
||||
movl %eax, (%edx)
|
||||
movl %edi, 4(%edx)
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %ebp
|
||||
ret
|
||||
.fcrypt_body_end:
|
||||
SIZE(fcrypt_body,.fcrypt_body_end-fcrypt_body)
|
||||
.ident "desasm.pl"
|
||||
@@ -1,35 +0,0 @@
|
||||
|
||||
#define TYPE(a,b) .type a,b
|
||||
#define SIZE(a,b) .size a,b
|
||||
|
||||
#ifdef OUT
|
||||
#define OK 1
|
||||
#define des_SPtrans _des_SPtrans
|
||||
#define fcrypt_body _fcrypt_body
|
||||
#define ALIGN 4
|
||||
#endif
|
||||
|
||||
#ifdef BSDI
|
||||
#define OK 1
|
||||
#define des_SPtrans _des_SPtrans
|
||||
#define fcrypt_body _fcrypt_body
|
||||
#define ALIGN 4
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#endif
|
||||
|
||||
#if defined(ELF) || defined(SOL)
|
||||
#define OK 1
|
||||
#define ALIGN 16
|
||||
#endif
|
||||
|
||||
#ifndef OK
|
||||
You need to define one of
|
||||
ELF - elf systems - linux-elf, NetBSD and DG-UX
|
||||
OUT - a.out systems - linux-a.out and FreeBSD
|
||||
SOL - solaris systems, which are elf with strange comment lines
|
||||
BSDI - a.out with a very primative version of as.
|
||||
#endif
|
||||
|
||||
#include "cx86-cpp.s"
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
begin 640 d-win32.obj
|
||||
M3`$"`/4&DC-`-@``#``````````N=&5X=```````````````W"$``&0```!`
|
||||
M(@`````````"```@`#!@+F1A=&$```#<(0````````````!`-@``````````
|
||||
M````````0``PP%535E>+="04,\F+!HM<)!R+?@3!P`2+\#/')?#P\/`S\#/X
|
||||
MP<<4B\<S_H'G#P#P_S/',_?!P`Z+^#/&)3,S,S,S^#/PP<86B\8S]X'F_`/\
|
||||
M`S/&,_[!P`F+\#/'):JJJJHS\#/XT<>#^P"+;"08#X2U!P``BT4`,]N+500S
|
||||
MQC/6)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+
|
||||
MJP`!```S_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[
|
||||
MBYD`!P``,_N+F``$```S^XN:``4``#/[BT4(,]N+50PSQS/7)?S\_/R!XL_/
|
||||
MS\^*V(K,P<H$BZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0
|
||||
MBZD``P``,_6+;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$
|
||||
M```S\XN:``4``#/SBT40,]N+510SQC/6)?S\_/R!XL_/S\^*V(K,P<H$BZL`
|
||||
M````BMHS_8NI``(``#/]BL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+;"08
|
||||
MBLXE_P```('B_P```(N;``8``#/[BYD`!P``,_N+F``$```S^XN:``4``#/[
|
||||
MBT48,]N+51PSQS/7)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS]8NI``(`
|
||||
M`#/UBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+;"08BLXE_P```('B_P``
|
||||
M`(N;``8``#/SBYD`!P``,_.+F``$```S\XN:``4``#/SBT4@,]N+520SQC/6
|
||||
M)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!
|
||||
M```S_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[BYD`
|
||||
M!P``,_N+F``$```S^XN:``4``#/[BT4H,]N+52PSQS/7)?S\_/R!XL_/S\^*
|
||||
MV(K,P<H$BZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0BZD`
|
||||
M`P``,_6+;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$```S
|
||||
M\XN:``4``#/SBT4P,]N+530SQC/6)?S\_/R!XL_/S\^*V(K,P<H$BZL`````
|
||||
MBMHS_8NI``(``#/]BL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+;"08BLXE
|
||||
M_P```('B_P```(N;``8``#/[BYD`!P``,_N+F``$```S^XN:``4``#/[BT4X
|
||||
M,]N+53PSQS/7)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS]8NI``(``#/U
|
||||
MBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+;"08BLXE_P```('B_P```(N;
|
||||
M``8``#/SBYD`!P``,_.+F``$```S\XN:``4``#/SBT5`,]N+540SQC/6)?S\
|
||||
M_/R!XL_/S\^*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!```S
|
||||
M_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[BYD`!P``
|
||||
M,_N+F``$```S^XN:``4``#/[BT5(,]N+54PSQS/7)?S\_/R!XL_/S\^*V(K,
|
||||
MP<H$BZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0BZD``P``
|
||||
M,_6+;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$```S\XN:
|
||||
M``4``#/SBT50,]N+550SQC/6)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS
|
||||
M_8NI``(``#/]BL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+;"08BLXE_P``
|
||||
M`('B_P```(N;``8``#/[BYD`!P``,_N+F``$```S^XN:``4``#/[BT58,]N+
|
||||
M55PSQS/7)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS]8NI``(``#/UBL[!
|
||||
MZ!"+JP`!```S]8K<P>H0BZD``P``,_6+;"08BLXE_P```('B_P```(N;``8`
|
||||
M`#/SBYD`!P``,_.+F``$```S\XN:``4``#/SBT5@,]N+560SQC/6)?S\_/R!
|
||||
MXL_/S\^*V(K,P<H$BZL`````BMHS_8NI``(``#/]BL[!Z!"+JP`!```S_8K<
|
||||
MP>H0BZD``P``,_V+;"08BLXE_P```('B_P```(N;``8``#/[BYD`!P``,_N+
|
||||
MF``$```S^XN:``4``#/[BT5H,]N+56PSQS/7)?S\_/R!XL_/S\^*V(K,P<H$
|
||||
MBZL`````BMHS]8NI``(``#/UBL[!Z!"+JP`!```S]8K<P>H0BZD``P``,_6+
|
||||
M;"08BLXE_P```('B_P```(N;``8``#/SBYD`!P``,_.+F``$```S\XN:``4`
|
||||
M`#/SBT5P,]N+570SQC/6)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS_8NI
|
||||
M``(``#/]BL[!Z!"+JP`!```S_8K<P>H0BZD``P``,_V+;"08BLXE_P```('B
|
||||
M_P```(N;``8``#/[BYD`!P``,_N+F``$```S^XN:``4``#/[BT5X,]N+57PS
|
||||
MQS/7)?S\_/R!XL_/S\^*V(K,P<H$BZL`````BMHS]8NI``(``#/UBL[!Z!"+
|
||||
MJP`!```S]8K<P>H0BZD``P``,_6+;"08BLXE_P```('B_P```(N;``8``#/S
|
||||
MBYD`!P``,_.+F``$```S\XN:``4``#/SZ;`'``"+17@SVXM5?#/&,]8E_/S\
|
||||
M_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]
|
||||
MBMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_````BYL`!@``,_N+F0`'```S
|
||||
M^XN8``0``#/[BYH`!0``,_N+17`SVXM5=#/',]<E_/S\_('BS\_/SXK8BLS!
|
||||
MR@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S
|
||||
M]8ML)!B*SB7_````@>+_````BYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`
|
||||
M!0``,_.+16@SVXM5;#/&,]8E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]
|
||||
MBZD``@``,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````
|
||||
M@>+_````BYL`!@``,_N+F0`'```S^XN8``0``#/[BYH`!0``,_N+16`SVXM5
|
||||
M9#/',]<E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H
|
||||
M$(NK``$``#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_````@>+_````BYL`!@``
|
||||
M,_.+F0`'```S\XN8``0``#/SBYH`!0``,_.+15@SVXM57#/&,]8E_/S\_('B
|
||||
MS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]BMS!
|
||||
MZA"+J0`#```S_8ML)!B*SB7_````@>+_````BYL`!@``,_N+F0`'```S^XN8
|
||||
M``0``#/[BYH`!0``,_N+15`SVXM55#/',]<E_/S\_('BS\_/SXK8BLS!R@2+
|
||||
MJP````"*VC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S]8ML
|
||||
M)!B*SB7_````@>+_````BYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`!0``
|
||||
M,_.+14@SVXM53#/&,]8E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD`
|
||||
M`@``,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_
|
||||
M````BYL`!@``,_N+F0`'```S^XN8``0``#/[BYH`!0``,_N+14`SVXM51#/'
|
||||
M,]<E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK
|
||||
M``$``#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_````@>+_````BYL`!@``,_.+
|
||||
MF0`'```S\XN8``0``#/SBYH`!0``,_.+13@SVXM5/#/&,]8E_/S\_('BS\_/
|
||||
MSXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]BMS!ZA"+
|
||||
MJ0`#```S_8ML)!B*SB7_````@>+_````BYL`!@``,_N+F0`'```S^XN8``0`
|
||||
M`#/[BYH`!0``,_N+13`SVXM5-#/',]<E_/S\_('BS\_/SXK8BLS!R@2+JP``
|
||||
M``"*VC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S]8ML)!B*
|
||||
MSB7_````@>+_````BYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`!0``,_.+
|
||||
M12@SVXM5+#/&,]8E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``
|
||||
M,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_````
|
||||
MBYL`!@``,_N+F0`'```S^XN8``0``#/[BYH`!0``,_N+12`SVXM5)#/',]<E
|
||||
M_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK``$`
|
||||
M`#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_````@>+_````BYL`!@``,_.+F0`'
|
||||
M```S\XN8``0``#/SBYH`!0``,_.+11@SVXM5'#/&,]8E_/S\_('BS\_/SXK8
|
||||
MBLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#
|
||||
M```S_8ML)!B*SB7_````@>+_````BYL`!@``,_N+F0`'```S^XN8``0``#/[
|
||||
MBYH`!0``,_N+11`SVXM5%#/',]<E_/S\_('BS\_/SXK8BLS!R@2+JP````"*
|
||||
MVC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_
|
||||
M````@>+_````BYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`!0``,_.+10@S
|
||||
MVXM5##/&,]8E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*
|
||||
MSL'H$(NK``$``#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_````BYL`
|
||||
M!@``,_N+F0`'```S^XN8``0``#/[BYH`!0``,_N+10`SVXM5!#/',]<E_/S\
|
||||
M_('BS\_/SXK8BLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK``$``#/U
|
||||
MBMS!ZA"+J0`#```S]8ML)!B*SB7_````@>+_````BYL`!@``,_.+F0`'```S
|
||||
M\XN8``0``#/SBYH`!0``,_.+5"04T<Z+QS/^@>>JJJJJ,\<S]\'`%XOX,\8E
|
||||
M_`/\`S/X,_#!QPJ+QS/^@><S,S,S,\<S]\'&$HO^,_"!Y@\`\/\S_C/&P<<,
|
||||
MB_<S^('G\/#P\#/W,\?!R`2)`HER!%]>6UW#55-65XM$)!0SR8LPBUPD','&
|
||||
M`XMX!,''`X/[`(ML)!@/A+4'``"+10`SVXM5!#/&,]8E_/S\_('BS\_/SXK8
|
||||
MBLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#
|
||||
M```S_8ML)!B*SB7_````@>+_````BYL`!@``,_N+F0`'```S^XN8``0``#/[
|
||||
MBYH`!0``,_N+10@SVXM5##/',]<E_/S\_('BS\_/SXK8BLS!R@2+JP````"*
|
||||
MVC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_
|
||||
M````@>+_````BYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`!0``,_.+11`S
|
||||
MVXM5%#/&,]8E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*
|
||||
MSL'H$(NK``$``#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_````BYL`
|
||||
M!@``,_N+F0`'```S^XN8``0``#/[BYH`!0``,_N+11@SVXM5'#/',]<E_/S\
|
||||
M_('BS\_/SXK8BLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK``$``#/U
|
||||
MBMS!ZA"+J0`#```S]8ML)!B*SB7_````@>+_````BYL`!@``,_.+F0`'```S
|
||||
M\XN8``0``#/SBYH`!0``,_.+12`SVXM5)#/&,]8E_/S\_('BS\_/SXK8BLS!
|
||||
MR@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#```S
|
||||
M_8ML)!B*SB7_````@>+_````BYL`!@``,_N+F0`'```S^XN8``0``#/[BYH`
|
||||
M!0``,_N+12@SVXM5+#/',]<E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/U
|
||||
MBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_````
|
||||
M@>+_````BYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`!0``,_.+13`SVXM5
|
||||
M-#/&,]8E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H
|
||||
M$(NK``$``#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_````BYL`!@``
|
||||
M,_N+F0`'```S^XN8``0``#/[BYH`!0``,_N+13@SVXM5/#/',]<E_/S\_('B
|
||||
MS\_/SXK8BLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!
|
||||
MZA"+J0`#```S]8ML)!B*SB7_````@>+_````BYL`!@``,_.+F0`'```S\XN8
|
||||
M``0``#/SBYH`!0``,_.+14`SVXM51#/&,]8E_/S\_('BS\_/SXK8BLS!R@2+
|
||||
MJP````"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#```S_8ML
|
||||
M)!B*SB7_````@>+_````BYL`!@``,_N+F0`'```S^XN8``0``#/[BYH`!0``
|
||||
M,_N+14@SVXM53#/',]<E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/UBZD`
|
||||
M`@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_````@>+_
|
||||
M````BYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`!0``,_.+15`SVXM55#/&
|
||||
M,]8E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK
|
||||
M``$``#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_````BYL`!@``,_N+
|
||||
MF0`'```S^XN8``0``#/[BYH`!0``,_N+15@SVXM57#/',]<E_/S\_('BS\_/
|
||||
MSXK8BLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+
|
||||
MJ0`#```S]8ML)!B*SB7_````@>+_````BYL`!@``,_.+F0`'```S\XN8``0`
|
||||
M`#/SBYH`!0``,_.+16`SVXM59#/&,]8E_/S\_('BS\_/SXK8BLS!R@2+JP``
|
||||
M``"*VC/]BZD``@``,_V*SL'H$(NK``$``#/]BMS!ZA"+J0`#```S_8ML)!B*
|
||||
MSB7_````@>+_````BYL`!@``,_N+F0`'```S^XN8``0``#/[BYH`!0``,_N+
|
||||
M16@SVXM5;#/',]<E_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/UBZD``@``
|
||||
M,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#```S]8ML)!B*SB7_````@>+_````
|
||||
MBYL`!@``,_.+F0`'```S\XN8``0``#/SBYH`!0``,_.+17`SVXM5=#/&,]8E
|
||||
M_/S\_('BS\_/SXK8BLS!R@2+JP````"*VC/]BZD``@``,_V*SL'H$(NK``$`
|
||||
M`#/]BMS!ZA"+J0`#```S_8ML)!B*SB7_````@>+_````BYL`!@``,_N+F0`'
|
||||
M```S^XN8``0``#/[BYH`!0``,_N+17@SVXM5?#/',]<E_/S\_('BS\_/SXK8
|
||||
MBLS!R@2+JP````"*VC/UBZD``@``,_6*SL'H$(NK``$``#/UBMS!ZA"+J0`#
|
||||
M```S]8ML)!B*SB7_````@>+_````BYL`!@``,_.+F0`'```S\XN8``0``#/S
|
||||
MBYH`!0``,_/IL`<``(M%>#/;BU5\,\8SUB7\_/S\@>+/S\_/BMB*S,'*!(NK
|
||||
M`````(K:,_V+J0`"```S_8K.P>@0BZL``0``,_V*W,'J$(NI``,``#/]BVPD
|
||||
M&(K.)?\```"!XO\```"+FP`&```S^XN9``<``#/[BY@`!```,_N+F@`%```S
|
||||
M^XM%<#/;BU5T,\<SUR7\_/S\@>+/S\_/BMB*S,'*!(NK`````(K:,_6+J0`"
|
||||
M```S]8K.P>@0BZL``0``,_6*W,'J$(NI``,``#/UBVPD&(K.)?\```"!XO\`
|
||||
M``"+FP`&```S\XN9``<``#/SBY@`!```,_.+F@`%```S\XM%:#/;BU5L,\8S
|
||||
MUB7\_/S\@>+/S\_/BMB*S,'*!(NK`````(K:,_V+J0`"```S_8K.P>@0BZL`
|
||||
M`0``,_V*W,'J$(NI``,``#/]BVPD&(K.)?\```"!XO\```"+FP`&```S^XN9
|
||||
M``<``#/[BY@`!```,_N+F@`%```S^XM%8#/;BU5D,\<SUR7\_/S\@>+/S\_/
|
||||
MBMB*S,'*!(NK`````(K:,_6+J0`"```S]8K.P>@0BZL``0``,_6*W,'J$(NI
|
||||
M``,``#/UBVPD&(K.)?\```"!XO\```"+FP`&```S\XN9``<``#/SBY@`!```
|
||||
M,_.+F@`%```S\XM%6#/;BU5<,\8SUB7\_/S\@>+/S\_/BMB*S,'*!(NK````
|
||||
M`(K:,_V+J0`"```S_8K.P>@0BZL``0``,_V*W,'J$(NI``,``#/]BVPD&(K.
|
||||
M)?\```"!XO\```"+FP`&```S^XN9``<``#/[BY@`!```,_N+F@`%```S^XM%
|
||||
M4#/;BU54,\<SUR7\_/S\@>+/S\_/BMB*S,'*!(NK`````(K:,_6+J0`"```S
|
||||
M]8K.P>@0BZL``0``,_6*W,'J$(NI``,``#/UBVPD&(K.)?\```"!XO\```"+
|
||||
MFP`&```S\XN9``<``#/SBY@`!```,_.+F@`%```S\XM%2#/;BU5,,\8SUB7\
|
||||
M_/S\@>+/S\_/BMB*S,'*!(NK`````(K:,_V+J0`"```S_8K.P>@0BZL``0``
|
||||
M,_V*W,'J$(NI``,``#/]BVPD&(K.)?\```"!XO\```"+FP`&```S^XN9``<`
|
||||
M`#/[BY@`!```,_N+F@`%```S^XM%0#/;BU5$,\<SUR7\_/S\@>+/S\_/BMB*
|
||||
MS,'*!(NK`````(K:,_6+J0`"```S]8K.P>@0BZL``0``,_6*W,'J$(NI``,`
|
||||
M`#/UBVPD&(K.)?\```"!XO\```"+FP`&```S\XN9``<``#/SBY@`!```,_.+
|
||||
MF@`%```S\XM%.#/;BU4\,\8SUB7\_/S\@>+/S\_/BMB*S,'*!(NK`````(K:
|
||||
M,_V+J0`"```S_8K.P>@0BZL``0``,_V*W,'J$(NI``,``#/]BVPD&(K.)?\`
|
||||
M``"!XO\```"+FP`&```S^XN9``<``#/[BY@`!```,_N+F@`%```S^XM%,#/;
|
||||
MBU4T,\<SUR7\_/S\@>+/S\_/BMB*S,'*!(NK`````(K:,_6+J0`"```S]8K.
|
||||
MP>@0BZL``0``,_6*W,'J$(NI``,``#/UBVPD&(K.)?\```"!XO\```"+FP`&
|
||||
M```S\XN9``<``#/SBY@`!```,_.+F@`%```S\XM%*#/;BU4L,\8SUB7\_/S\
|
||||
M@>+/S\_/BMB*S,'*!(NK`````(K:,_V+J0`"```S_8K.P>@0BZL``0``,_V*
|
||||
MW,'J$(NI``,``#/]BVPD&(K.)?\```"!XO\```"+FP`&```S^XN9``<``#/[
|
||||
MBY@`!```,_N+F@`%```S^XM%(#/;BU4D,\<SUR7\_/S\@>+/S\_/BMB*S,'*
|
||||
M!(NK`````(K:,_6+J0`"```S]8K.P>@0BZL``0``,_6*W,'J$(NI``,``#/U
|
||||
MBVPD&(K.)?\```"!XO\```"+FP`&```S\XN9``<``#/SBY@`!```,_.+F@`%
|
||||
M```S\XM%&#/;BU4<,\8SUB7\_/S\@>+/S\_/BMB*S,'*!(NK`````(K:,_V+
|
||||
MJ0`"```S_8K.P>@0BZL``0``,_V*W,'J$(NI``,``#/]BVPD&(K.)?\```"!
|
||||
MXO\```"+FP`&```S^XN9``<``#/[BY@`!```,_N+F@`%```S^XM%$#/;BU44
|
||||
M,\<SUR7\_/S\@>+/S\_/BMB*S,'*!(NK`````(K:,_6+J0`"```S]8K.P>@0
|
||||
MBZL``0``,_6*W,'J$(NI``,``#/UBVPD&(K.)?\```"!XO\```"+FP`&```S
|
||||
M\XN9``<``#/SBY@`!```,_.+F@`%```S\XM%"#/;BU4,,\8SUB7\_/S\@>+/
|
||||
MS\_/BMB*S,'*!(NK`````(K:,_V+J0`"```S_8K.P>@0BZL``0``,_V*W,'J
|
||||
M$(NI``,``#/]BVPD&(K.)?\```"!XO\```"+FP`&```S^XN9``<``#/[BY@`
|
||||
M!```,_N+F@`%```S^XM%`#/;BU4$,\<SUR7\_/S\@>+/S\_/BMB*S,'*!(NK
|
||||
M`````(K:,_6+J0`"```S]8K.P>@0BZL``0``,_6*W,'J$(NI``,``#/UBVPD
|
||||
M&(K.)?\```"!XO\```"+FP`&```S\XN9``<``#/SBY@`!```,_.+F@`%```S
|
||||
M\\'/`XM$)!3!S@.).(EP!%]>6UW#55-65XM<)!2+.XMS!,''!(O7,_Z!Y_#P
|
||||
M\/`SUS/WP<84B_XS\H'F#P#P_S/^,];!QPZ+]S/Z@><S,S,S,_<SU\'"%HOZ
|
||||
M,]:!XOP#_`,S^C/RP<<)B]<S_H'GJJJJJC/7,_?!R@/!S@*)<P2+1"08B1.+
|
||||
M?"0<BW0D(&H!4%/HW^___VH`5U/HUN___VH!5E/HS>___XL[@\0DBW,$P<8"
|
||||
MP<<#B\<S_H'GJJJJJC/',_?!P!>+^#/&)?P#_`,S^#/PP<<*B\<S_H'G,S,S
|
||||
M,S/',_?!QA*+_C/P@>8/`/#_,_XSQL''#(OW,_B!Y_#P\/`S]S/'P<@$B0.)
|
||||
M<P1?7EM=PU535E>+7"04BSN+<P3!QP2+US/^@>?P\/#P,]<S]\'&%(O^,_*!
|
||||
MY@\`\/\S_C/6P<<.B_<S^H'G,S,S,S/W,]?!PA:+^C/6@>+\`_P#,_HS\L''
|
||||
M"8O7,_Z!YZJJJJHSUS/WP<H#P<X"B7,$BW0D&(D3BWPD'(M$)"!J`%!3Z-_N
|
||||
M__]J`5=3Z-;N__]J`%93Z,WN__^+.X/$)(MS!,'&`L''`XO',_Z!YZJJJJHS
|
||||
MQS/WP<`7B_@SQB7\`_P#,_@S\,''"HO',_Z!YS,S,S,SQS/WP<82B_XS\('F
|
||||
M#P#P_S/^,\;!QPR+]S/X@>?P\/#P,_<SQ\'(!(D#B7,$7UY;7<.4````!P``
|
||||
M``8`G@````<````&`*L````'````!@"X````!P````8`T0````<````&`-D`
|
||||
M```'````!@#A````!P````8`Z0````<````&``\!```'````!@`9`0``!P``
|
||||
M``8`)@$```<````&`#,!```'````!@!,`0``!P````8`5`$```<````&`%P!
|
||||
M```'````!@!D`0``!P````8`B@$```<````&`)0!```'````!@"A`0``!P``
|
||||
M``8`K@$```<````&`,<!```'````!@#/`0``!P````8`UP$```<````&`-\!
|
||||
M```'````!@`%`@``!P````8`#P(```<````&`!P"```'````!@`I`@``!P``
|
||||
M``8`0@(```<````&`$H"```'````!@!2`@``!P````8`6@(```<````&`(`"
|
||||
M```'````!@"*`@``!P````8`EP(```<````&`*0"```'````!@"]`@``!P``
|
||||
M``8`Q0(```<````&`,T"```'````!@#5`@``!P````8`^P(```<````&``4#
|
||||
M```'````!@`2`P``!P````8`'P,```<````&`#@#```'````!@!``P``!P``
|
||||
M``8`2`,```<````&`%`#```'````!@!V`P``!P````8`@`,```<````&`(T#
|
||||
M```'````!@":`P``!P````8`LP,```<````&`+L#```'````!@##`P``!P``
|
||||
M``8`RP,```<````&`/$#```'````!@#[`P``!P````8`"`0```<````&`!4$
|
||||
M```'````!@`N!```!P````8`-@0```<````&`#X$```'````!@!&!```!P``
|
||||
M``8`;`0```<````&`'8$```'````!@"#!```!P````8`D`0```<````&`*D$
|
||||
M```'````!@"Q!```!P````8`N00```<````&`,$$```'````!@#G!```!P``
|
||||
M``8`\00```<````&`/X$```'````!@`+!0``!P````8`)`4```<````&`"P%
|
||||
M```'````!@`T!0``!P````8`/`4```<````&`&(%```'````!@!L!0``!P``
|
||||
M``8`>04```<````&`(8%```'````!@"?!0``!P````8`IP4```<````&`*\%
|
||||
M```'````!@"W!0``!P````8`W04```<````&`.<%```'````!@#T!0``!P``
|
||||
M``8``08```<````&`!H&```'````!@`B!@``!P````8`*@8```<````&`#(&
|
||||
M```'````!@!8!@``!P````8`8@8```<````&`&\&```'````!@!\!@``!P``
|
||||
M``8`E08```<````&`)T&```'````!@"E!@``!P````8`K08```<````&`-,&
|
||||
M```'````!@#=!@``!P````8`Z@8```<````&`/<&```'````!@`0!P``!P``
|
||||
M``8`&`<```<````&`"`'```'````!@`H!P``!P````8`3@<```<````&`%@'
|
||||
M```'````!@!E!P``!P````8`<@<```<````&`(L'```'````!@"3!P``!P``
|
||||
M``8`FP<```<````&`*,'```'````!@#)!P``!P````8`TP<```<````&`.`'
|
||||
M```'````!@#M!P``!P````8`!@@```<````&``X(```'````!@`6"```!P``
|
||||
M``8`'@@```<````&`$D(```'````!@!3"```!P````8`8`@```<````&`&T(
|
||||
M```'````!@"&"```!P````8`C@@```<````&`)8(```'````!@">"```!P``
|
||||
M``8`Q`@```<````&`,X(```'````!@#;"```!P````8`Z`@```<````&``$)
|
||||
M```'````!@`)"0``!P````8`$0D```<````&`!D)```'````!@`_"0``!P``
|
||||
M``8`20D```<````&`%8)```'````!@!C"0``!P````8`?`D```<````&`(0)
|
||||
M```'````!@","0``!P````8`E`D```<````&`+H)```'````!@#$"0``!P``
|
||||
M``8`T0D```<````&`-X)```'````!@#W"0``!P````8`_PD```<````&``<*
|
||||
M```'````!@`/"@``!P````8`-0H```<````&`#\*```'````!@!,"@``!P``
|
||||
M``8`60H```<````&`'(*```'````!@!Z"@``!P````8`@@H```<````&`(H*
|
||||
M```'````!@"P"@``!P````8`N@H```<````&`,<*```'````!@#4"@``!P``
|
||||
M``8`[0H```<````&`/4*```'````!@#]"@``!P````8`!0L```<````&`"L+
|
||||
M```'````!@`U"P``!P````8`0@L```<````&`$\+```'````!@!H"P``!P``
|
||||
M``8`<`L```<````&`'@+```'````!@"`"P``!P````8`I@L```<````&`+`+
|
||||
M```'````!@"]"P``!P````8`R@L```<````&`.,+```'````!@#K"P``!P``
|
||||
M``8`\PL```<````&`/L+```'````!@`A#```!P````8`*PP```<````&`#@,
|
||||
M```'````!@!%#```!P````8`7@P```<````&`&8,```'````!@!N#```!P``
|
||||
M``8`=@P```<````&`)P,```'````!@"F#```!P````8`LPP```<````&`,`,
|
||||
M```'````!@#9#```!P````8`X0P```<````&`.D,```'````!@#Q#```!P``
|
||||
M``8`%PT```<````&`"$-```'````!@`N#0``!P````8`.PT```<````&`%0-
|
||||
M```'````!@!<#0``!P````8`9`T```<````&`&P-```'````!@"2#0``!P``
|
||||
M``8`G`T```<````&`*D-```'````!@"V#0``!P````8`SPT```<````&`-<-
|
||||
M```'````!@#?#0``!P````8`YPT```<````&``T.```'````!@`7#@``!P``
|
||||
M``8`)`X```<````&`#$.```'````!@!*#@``!P````8`4@X```<````&`%H.
|
||||
M```'````!@!B#@``!P````8`B`X```<````&`)(.```'````!@"?#@``!P``
|
||||
M``8`K`X```<````&`,4.```'````!@#-#@``!P````8`U0X```<````&`-T.
|
||||
M```'````!@`##P``!P````8`#0\```<````&`!H/```'````!@`G#P``!P``
|
||||
M``8`0`\```<````&`$@/```'````!@!0#P``!P````8`6`\```<````&`'X/
|
||||
M```'````!@"(#P``!P````8`E0\```<````&`*(/```'````!@"[#P``!P``
|
||||
M``8`PP\```<````&`,L/```'````!@#3#P``!P````8`@Q````<````&`(T0
|
||||
M```'````!@":$```!P````8`IQ````<````&`,`0```'````!@#($```!P``
|
||||
M``8`T!````<````&`-@0```'````!@#^$```!P````8`"!$```<````&`!41
|
||||
M```'````!@`B$0``!P````8`.Q$```<````&`$,1```'````!@!+$0``!P``
|
||||
M``8`4Q$```<````&`'D1```'````!@"#$0``!P````8`D!$```<````&`)T1
|
||||
M```'````!@"V$0``!P````8`OA$```<````&`,81```'````!@#.$0``!P``
|
||||
M``8`]!$```<````&`/X1```'````!@`+$@``!P````8`&!(```<````&`#$2
|
||||
M```'````!@`Y$@``!P````8`01(```<````&`$D2```'````!@!O$@``!P``
|
||||
M``8`>1(```<````&`(82```'````!@"3$@``!P````8`K!(```<````&`+02
|
||||
M```'````!@"\$@``!P````8`Q!(```<````&`.H2```'````!@#T$@``!P``
|
||||
M``8``1,```<````&``X3```'````!@`G$P``!P````8`+Q,```<````&`#<3
|
||||
M```'````!@`_$P``!P````8`91,```<````&`&\3```'````!@!\$P``!P``
|
||||
M``8`B1,```<````&`*(3```'````!@"J$P``!P````8`LA,```<````&`+H3
|
||||
M```'````!@#@$P``!P````8`ZA,```<````&`/<3```'````!@`$%```!P``
|
||||
M``8`'10```<````&`"44```'````!@`M%```!P````8`-10```<````&`%L4
|
||||
M```'````!@!E%```!P````8`<A0```<````&`'\4```'````!@"8%```!P``
|
||||
M``8`H!0```<````&`*@4```'````!@"P%```!P````8`UA0```<````&`.`4
|
||||
M```'````!@#M%```!P````8`^A0```<````&`!,5```'````!@`;%0``!P``
|
||||
M``8`(Q4```<````&`"L5```'````!@!1%0``!P````8`6Q4```<````&`&@5
|
||||
M```'````!@!U%0``!P````8`CA4```<````&`)85```'````!@">%0``!P``
|
||||
M``8`IA4```<````&`,P5```'````!@#6%0``!P````8`XQ4```<````&`/`5
|
||||
M```'````!@`)%@``!P````8`$18```<````&`!D6```'````!@`A%@``!P``
|
||||
M``8`1Q8```<````&`%$6```'````!@!>%@``!P````8`:Q8```<````&`(06
|
||||
M```'````!@",%@``!P````8`E!8```<````&`)P6```'````!@#"%@``!P``
|
||||
M``8`S!8```<````&`-D6```'````!@#F%@``!P````8`_Q8```<````&``<7
|
||||
M```'````!@`/%P``!P````8`%Q<```<````&`#T7```'````!@!'%P``!P``
|
||||
M``8`5!<```<````&`&$7```'````!@!Z%P``!P````8`@A<```<````&`(H7
|
||||
M```'````!@"2%P``!P````8`N!<```<````&`,(7```'````!@#/%P``!P``
|
||||
M``8`W!<```<````&`/47```'````!@#]%P``!P````8`!1@```<````&``T8
|
||||
M```'````!@`X&```!P````8`0A@```<````&`$\8```'````!@!<&```!P``
|
||||
M``8`=1@```<````&`'T8```'````!@"%&```!P````8`C1@```<````&`+,8
|
||||
M```'````!@"]&```!P````8`RA@```<````&`-<8```'````!@#P&```!P``
|
||||
M``8`^!@```<````&```9```'````!@`(&0``!P````8`+AD```<````&`#@9
|
||||
M```'````!@!%&0``!P````8`4AD```<````&`&L9```'````!@!S&0``!P``
|
||||
M``8`>QD```<````&`(,9```'````!@"I&0``!P````8`LQD```<````&`,`9
|
||||
M```'````!@#-&0``!P````8`YAD```<````&`.X9```'````!@#V&0``!P``
|
||||
M``8`_AD```<````&`"0:```'````!@`N&@``!P````8`.QH```<````&`$@:
|
||||
M```'````!@!A&@``!P````8`:1H```<````&`'$:```'````!@!Y&@``!P``
|
||||
M``8`GQH```<````&`*D:```'````!@"V&@``!P````8`PQH```<````&`-P:
|
||||
M```'````!@#D&@``!P````8`[!H```<````&`/0:```'````!@`:&P``!P``
|
||||
M``8`)!L```<````&`#$;```'````!@`^&P``!P````8`5QL```<````&`%\;
|
||||
M```'````!@!G&P``!P````8`;QL```<````&`)4;```'````!@"?&P``!P``
|
||||
M``8`K!L```<````&`+D;```'````!@#2&P``!P````8`VAL```<````&`.(;
|
||||
M```'````!@#J&P``!P````8`$!P```<````&`!H<```'````!@`G'```!P``
|
||||
M``8`-!P```<````&`$T<```'````!@!5'```!P````8`71P```<````&`&4<
|
||||
M```'````!@"+'```!P````8`E1P```<````&`*(<```'````!@"O'```!P``
|
||||
M``8`R!P```<````&`-`<```'````!@#8'```!P````8`X!P```<````&``8=
|
||||
M```'````!@`0'0``!P````8`'1T```<````&`"H=```'````!@!#'0``!P``
|
||||
M``8`2QT```<````&`%,=```'````!@!;'0``!P````8`@1T```<````&`(L=
|
||||
M```'````!@"8'0``!P````8`I1T```<````&`+X=```'````!@#&'0``!P``
|
||||
M``8`SAT```<````&`-8=```'````!@#\'0``!P````8`!AX```<````&`!,>
|
||||
M```'````!@`@'@``!P````8`.1X```<````&`$$>```'````!@!)'@``!P``
|
||||
M``8`41X```<````&`'<>```'````!@"!'@``!P````8`CAX```<````&`)L>
|
||||
M```'````!@"T'@``!P````8`O!X```<````&`,0>```'````!@#,'@``!P``
|
||||
M``8`\AX```<````&`/P>```'````!@`)'P``!P````8`%A\```<````&`"\?
|
||||
M```'````!@`W'P``!P````8`/Q\```<````&`$<?```'````!@!M'P``!P``
|
||||
M``8`=Q\```<````&`(0?```'````!@"1'P``!P````8`JA\```<````&`+(?
|
||||
M```'````!@"Z'P``!P````8`PA\```<````&`"YF:6QE`````````/[_``!G
|
||||
M`BY<8W)Y<'1O7&1E<UQA<VU<9"UW:6XS,BYA<VT``````````"YT97AT````
|
||||
M``````$````#`=PA`````@```````````````"YD871A``````````(````#
|
||||
M`0`````````````````````````````$```````````````"```````1````
|
||||
M``````$`(``"```````>````/1````$`(``"```````L````W!\```$`(``"
|
||||
M```````Z````W"````$`(``"`$@```!?9&5S7U-0=')A;G,`7V1E<U]E;F-R
|
||||
M>7!T`%]D97-?96YC<GEP=#(`7V1E<U]E;F-R>7!T,P!?9&5S7V1E8W)Y<'0S
|
||||
!````
|
||||
`
|
||||
end
|
||||
@@ -1,308 +0,0 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# The inner loop instruction sequence and the IP/FP modifications are from
|
||||
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
#
|
||||
|
||||
$prog="des-som2.pl";
|
||||
|
||||
# base code is in microsft
|
||||
# op dest, source
|
||||
# format.
|
||||
#
|
||||
|
||||
require "desboth.pl";
|
||||
|
||||
if ( ($ARGV[0] eq "elf"))
|
||||
{ require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "a.out"))
|
||||
{ $aout=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "sol"))
|
||||
{ $sol=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "cpp"))
|
||||
{ $cpp=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "win32"))
|
||||
{ require "x86ms.pl"; }
|
||||
else
|
||||
{
|
||||
print STDERR <<"EOF";
|
||||
Pick one target type from
|
||||
elf - linux, FreeBSD etc
|
||||
a.out - old linux
|
||||
sol - x86 solaris
|
||||
cpp - format so x86unix.cpp can be used
|
||||
win32 - Windows 95/Windows NT
|
||||
EOF
|
||||
exit(1);
|
||||
}
|
||||
|
||||
&comment("Don't even think of reading this code");
|
||||
&comment("It was automatically generated by $prog");
|
||||
&comment("Which is a perl program used to generate the x86 assember for");
|
||||
&comment("any of elf, a.out, Win32, or Solaris");
|
||||
&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
|
||||
&comment("eric <eay\@cryptsoft.com>");
|
||||
&comment("The inner loop instruction sequence and the IP/FP modifications");
|
||||
&comment("are from Svend Olaf Mikkelsen <svolaf\@inet.uni-c.dk>");
|
||||
|
||||
&comment("");
|
||||
|
||||
&file("dx86xxxx");
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
|
||||
&des_encrypt("des_encrypt",1);
|
||||
&des_encrypt("des_encrypt2",0);
|
||||
|
||||
&des_encrypt3("des_encrypt3",1);
|
||||
&des_encrypt3("des_decrypt3",0);
|
||||
|
||||
&file_end();
|
||||
|
||||
sub des_encrypt
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
|
||||
&function_begin($name,3,"EXTRN _des_SPtrans:DWORD");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
&mov("eax",&wparam(0));
|
||||
&mov($R,&DWP(0,"eax","",0));
|
||||
&mov($L,&DWP(4,"eax","",0));
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
&comment("");
|
||||
&comment("IP");
|
||||
&IP_new($R,$L,"eax",3);
|
||||
# &comment("");
|
||||
# &comment("fixup rotate");
|
||||
# &rotl($R,3);
|
||||
# &rotl($L,3);
|
||||
}
|
||||
else
|
||||
{
|
||||
&comment("");
|
||||
&comment("fixup rotate");
|
||||
&rotl($R,3);
|
||||
&rotl($L,3);
|
||||
}
|
||||
|
||||
&comment("");
|
||||
&comment("load counter, key_schedule and enc flag");
|
||||
|
||||
# encrypting part
|
||||
|
||||
$ks="ebp";
|
||||
# &xor( "ebx", "ebx" );
|
||||
&mov("eax",&wparam(2)); # get encrypt flag
|
||||
&xor( "ecx", "ecx" );
|
||||
&cmp("eax","0");
|
||||
&mov( $ks, &wparam(1) );
|
||||
&je(&label("start_decrypt"));
|
||||
|
||||
for ($i=0; $i<16; $i+=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i+1));
|
||||
&D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
&jmp(&label("end"));
|
||||
|
||||
&set_label("start_decrypt");
|
||||
|
||||
for ($i=15; $i>0; $i-=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i-1));
|
||||
&D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
|
||||
&set_label("end");
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
# &comment("");
|
||||
# &comment("Fixup");
|
||||
# &rotr($L,3); # r
|
||||
# &rotr($R,3); # l
|
||||
&comment("");
|
||||
&comment("FP");
|
||||
&FP_new($R,$L,"eax",3);
|
||||
}
|
||||
else
|
||||
{
|
||||
&comment("");
|
||||
&comment("Fixup");
|
||||
&rotr($L,3); # r
|
||||
&rotr($R,3); # l
|
||||
}
|
||||
|
||||
&mov("eax",&wparam(0));
|
||||
&mov(&DWP(0,"eax","",0),$L);
|
||||
&mov(&DWP(4,"eax","",0),$R);
|
||||
|
||||
&function_end($name);
|
||||
}
|
||||
|
||||
sub D_ENCRYPT
|
||||
{
|
||||
local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
|
||||
|
||||
&mov( $u, &DWP(&n2a($S*4),$ks,"",0));
|
||||
&xor( $tmp1, $tmp1);
|
||||
&mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
|
||||
&xor( $u, $R);
|
||||
&xor( $t, $R);
|
||||
&and( $u, "0xfcfcfcfc" );
|
||||
&and( $t, "0xcfcfcfcf" );
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&rotr( $t, 4 );
|
||||
&mov( $ks, &DWP(" $desSP",$tmp1,"",0));
|
||||
&movb( &LB($tmp1), &LB($t) );
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks); ######
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&shr( $u, 16);
|
||||
&mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $ks); ######
|
||||
&movb( &LB($tmp1), &HB($u) );
|
||||
&shr( $t, 16);
|
||||
&mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP(24,"esp","",0)); ####
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&and( $u, "0xff" );
|
||||
&and( $t, "0xff" );
|
||||
&mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x400+$desSP",$u,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
}
|
||||
|
||||
sub PERM_OP
|
||||
{
|
||||
local($a,$b,$tt,$shift,$mask)=@_;
|
||||
|
||||
&mov( $tt, $a );
|
||||
&shr( $tt, $shift );
|
||||
&xor( $tt, $b );
|
||||
&and( $tt, $mask );
|
||||
&xor( $b, $tt );
|
||||
&shl( $tt, $shift );
|
||||
&xor( $a, $tt );
|
||||
}
|
||||
|
||||
sub IP
|
||||
{
|
||||
local($l,$r,$tt)=@_;
|
||||
|
||||
&PERM_OP($r,$l,$tt, 4,"0x0f0f0f0f");
|
||||
&PERM_OP($l,$r,$tt,16,"0x0000ffff");
|
||||
&PERM_OP($r,$l,$tt, 2,"0x33333333");
|
||||
&PERM_OP($l,$r,$tt, 8,"0x00ff00ff");
|
||||
&PERM_OP($r,$l,$tt, 1,"0x55555555");
|
||||
}
|
||||
|
||||
sub FP
|
||||
{
|
||||
local($l,$r,$tt)=@_;
|
||||
|
||||
&PERM_OP($l,$r,$tt, 1,"0x55555555");
|
||||
&PERM_OP($r,$l,$tt, 8,"0x00ff00ff");
|
||||
&PERM_OP($l,$r,$tt, 2,"0x33333333");
|
||||
&PERM_OP($r,$l,$tt,16,"0x0000ffff");
|
||||
&PERM_OP($l,$r,$tt, 4,"0x0f0f0f0f");
|
||||
}
|
||||
|
||||
sub n2a
|
||||
{
|
||||
sprintf("%d",$_[0]);
|
||||
}
|
||||
|
||||
# now has a side affect of rotating $a by $shift
|
||||
sub R_PERM_OP
|
||||
{
|
||||
local($a,$b,$tt,$shift,$mask,$last)=@_;
|
||||
|
||||
&rotl( $a, $shift ) if ($shift != 0);
|
||||
&mov( $tt, $b );
|
||||
&xor( $tt, $a );
|
||||
&and( $tt, $mask );
|
||||
if ($last eq $b)
|
||||
{
|
||||
&xor( $a, $tt );
|
||||
&xor( $b, $tt );
|
||||
}
|
||||
else
|
||||
{
|
||||
&xor( $b, $tt );
|
||||
&xor( $a, $tt );
|
||||
}
|
||||
&comment("");
|
||||
}
|
||||
|
||||
sub IP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l);
|
||||
&R_PERM_OP($r,$l,$tt,20,"0xfff0000f",$l);
|
||||
&R_PERM_OP($r,$l,$tt,14,"0x33333333",$r);
|
||||
&R_PERM_OP($l,$r,$tt,22,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
|
||||
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotr($l, 3-$lr); }
|
||||
else { &rotl($l, $lr-3); }
|
||||
}
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotr($r, 2-$lr); }
|
||||
else { &rotl($r, $lr-2); }
|
||||
}
|
||||
}
|
||||
|
||||
sub FP_new
|
||||
{
|
||||
local($r,$l,$tt,$lr)=@_;
|
||||
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotl($r, 2-$lr); }
|
||||
else { &rotr($r, $lr-2); }
|
||||
}
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotl($l, 3-$lr); }
|
||||
else { &rotr($l, $lr-3); }
|
||||
}
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r);
|
||||
&R_PERM_OP($l,$r,$tt,23,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt,10,"0x33333333",$l);
|
||||
&R_PERM_OP($r,$l,$tt,18,"0xfff0000f",$l);
|
||||
&R_PERM_OP($r,$l,$tt,12,"0xf0f0f0f0",$r);
|
||||
&rotr($l , 4);
|
||||
}
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# The inner loop instruction sequence and the IP/FP modifications are from
|
||||
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
#
|
||||
|
||||
$prog="des-som3.pl";
|
||||
|
||||
# base code is in microsft
|
||||
# op dest, source
|
||||
# format.
|
||||
#
|
||||
|
||||
require "desboth.pl";
|
||||
|
||||
if ( ($ARGV[0] eq "elf"))
|
||||
{ require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "a.out"))
|
||||
{ $aout=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "sol"))
|
||||
{ $sol=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "cpp"))
|
||||
{ $cpp=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "win32"))
|
||||
{ require "x86ms.pl"; }
|
||||
else
|
||||
{
|
||||
print STDERR <<"EOF";
|
||||
Pick one target type from
|
||||
elf - linux, FreeBSD etc
|
||||
a.out - old linux
|
||||
sol - x86 solaris
|
||||
cpp - format so x86unix.cpp can be used
|
||||
win32 - Windows 95/Windows NT
|
||||
EOF
|
||||
exit(1);
|
||||
}
|
||||
|
||||
&comment("Don't even think of reading this code");
|
||||
&comment("It was automatically generated by $prog");
|
||||
&comment("Which is a perl program used to generate the x86 assember for");
|
||||
&comment("any of elf, a.out, Win32, or Solaris");
|
||||
&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
|
||||
&comment("eric <eay\@cryptsoft.com>");
|
||||
&comment("The inner loop instruction sequence and the IP/FP modifications");
|
||||
&comment("are from Svend Olaf Mikkelsen <svolaf\@inet.uni-c.dk>");
|
||||
|
||||
&comment("");
|
||||
|
||||
&file("dx86xxxx");
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
|
||||
&des_encrypt("des_encrypt",1);
|
||||
&des_encrypt("des_encrypt2",0);
|
||||
|
||||
&des_encrypt3("des_encrypt3",1);
|
||||
&des_encrypt3("des_decrypt3",0);
|
||||
|
||||
&file_end();
|
||||
|
||||
sub des_encrypt
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
|
||||
&function_begin($name,3,EXTRN _des_SPtrans:DWORD");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
$ks="ebp";
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
&mov($R,&wparam(0));
|
||||
&xor( "ecx", "ecx" );
|
||||
&mov("eax",&DWP(0,$R,"",0));
|
||||
&mov("ebx",&wparam(2)); # get encrypt flag
|
||||
&mov($L,&DWP(4,$R,"",0));
|
||||
&comment("");
|
||||
&comment("IP");
|
||||
&IP_new("eax",$L,$R,3);
|
||||
}
|
||||
else
|
||||
{
|
||||
&mov("eax",&wparam(0));
|
||||
&xor( "ecx", "ecx" );
|
||||
&mov($R,&DWP(0,"eax","",0));
|
||||
&mov("ebx",&wparam(2)); # get encrypt flag
|
||||
&rotl($R,3);
|
||||
&mov($L,&DWP(4,"eax","",0));
|
||||
&rotl($L,3);
|
||||
}
|
||||
|
||||
&cmp("ebx","0");
|
||||
&mov( $ks, &wparam(1) );
|
||||
&je(&label("start_decrypt"));
|
||||
|
||||
for ($i=0; $i<16; $i+=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i+1));
|
||||
&D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
&jmp(&label("end"));
|
||||
|
||||
&set_label("start_decrypt");
|
||||
|
||||
for ($i=15; $i>0; $i-=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i-1));
|
||||
&D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
|
||||
&set_label("end");
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
&comment("");
|
||||
&comment("FP");
|
||||
&mov("edx",&wparam(0));
|
||||
&FP_new($L,$R,"eax",3);
|
||||
|
||||
&mov(&DWP(0,"edx","",0),"eax");
|
||||
&mov(&DWP(4,"edx","",0),$R);
|
||||
}
|
||||
else
|
||||
{
|
||||
&comment("");
|
||||
&comment("Fixup");
|
||||
&rotr($L,3); # r
|
||||
&mov("eax",&wparam(0));
|
||||
&rotr($R,3); # l
|
||||
&mov(&DWP(0,"eax","",0),$L);
|
||||
&mov(&DWP(4,"eax","",0),$R);
|
||||
}
|
||||
|
||||
|
||||
&function_end($name);
|
||||
}
|
||||
|
||||
sub D_ENCRYPT
|
||||
{
|
||||
local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
|
||||
|
||||
&mov( $u, &DWP(&n2a($S*4),$ks,"",0));
|
||||
&xor( $tmp1, $tmp1);
|
||||
&mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
|
||||
&xor( $u, $R);
|
||||
&xor( $t, $R);
|
||||
&and( $u, "0xfcfcfcfc" );
|
||||
&and( $t, "0xcfcfcfcf" );
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&rotr( $t, 4 );
|
||||
&mov( $ks, &DWP(" $desSP",$tmp1,"",0));
|
||||
&movb( &LB($tmp1), &LB($t) );
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks); ######
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&shr( $u, 16);
|
||||
&mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $ks); ######
|
||||
&movb( &LB($tmp1), &HB($u) );
|
||||
&shr( $t, 16);
|
||||
&mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP(24,"esp","",0)); ####
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&and( $u, "0xff" );
|
||||
&and( $t, "0xff" );
|
||||
&mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x400+$desSP",$u,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
}
|
||||
|
||||
sub n2a
|
||||
{
|
||||
sprintf("%d",$_[0]);
|
||||
}
|
||||
|
||||
# now has a side affect of rotating $a by $shift
|
||||
sub R_PERM_OP
|
||||
{
|
||||
local($a,$b,$tt,$shift,$mask,$last)=@_;
|
||||
|
||||
&rotl( $a, $shift ) if ($shift != 0);
|
||||
&mov( $tt, $a );
|
||||
&xor( $a, $b );
|
||||
&and( $a, $mask );
|
||||
if ($notlast eq $b)
|
||||
{
|
||||
&xor( $b, $a );
|
||||
&xor( $tt, $a );
|
||||
}
|
||||
else
|
||||
{
|
||||
&xor( $tt, $a );
|
||||
&xor( $b, $a );
|
||||
}
|
||||
&comment("");
|
||||
}
|
||||
|
||||
sub IP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l);
|
||||
&R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
|
||||
&R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
|
||||
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotr($tt, 3-$lr); }
|
||||
else { &rotl($tt, $lr-3); }
|
||||
}
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotr($r, 2-$lr); }
|
||||
else { &rotl($r, $lr-2); }
|
||||
}
|
||||
}
|
||||
|
||||
sub FP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotl($r, 2-$lr); }
|
||||
else { &rotr($r, $lr-2); }
|
||||
}
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotl($l, 3-$lr); }
|
||||
else { &rotr($l, $lr-3); }
|
||||
}
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r);
|
||||
&R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt,10,"0x33333333",$l);
|
||||
&R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r);
|
||||
&rotr($tt , 4);
|
||||
}
|
||||
|
||||
@@ -1,210 +0,0 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
$prog="des586.pl";
|
||||
|
||||
# base code is in microsft
|
||||
# op dest, source
|
||||
# format.
|
||||
#
|
||||
|
||||
# WILL NOT WORK ANYMORE WITH desboth.pl
|
||||
require "desboth.pl";
|
||||
|
||||
if ( ($ARGV[0] eq "elf"))
|
||||
{ require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "a.out"))
|
||||
{ $aout=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "sol"))
|
||||
{ $sol=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "cpp"))
|
||||
{ $cpp=1; require "x86unix.pl"; }
|
||||
elsif ( ($ARGV[0] eq "win32"))
|
||||
{ require "x86ms.pl"; }
|
||||
else
|
||||
{
|
||||
print STDERR <<"EOF";
|
||||
Pick one target type from
|
||||
elf - linux, FreeBSD etc
|
||||
a.out - old linux
|
||||
sol - x86 solaris
|
||||
cpp - format so x86unix.cpp can be used
|
||||
win32 - Windows 95/Windows NT
|
||||
EOF
|
||||
exit(1);
|
||||
}
|
||||
|
||||
&comment("Don't even think of reading this code");
|
||||
&comment("It was automatically generated by $prog");
|
||||
&comment("Which is a perl program used to generate the x86 assember for");
|
||||
&comment("any of elf, a.out, Win32, or Solaris");
|
||||
&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
|
||||
&comment("eric <eay\@cryptsoft.com>");
|
||||
&comment("");
|
||||
|
||||
&file("dx86xxxx");
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
|
||||
&des_encrypt("des_encrypt",1);
|
||||
&des_encrypt("des_encrypt2",0);
|
||||
|
||||
&des_encrypt3("des_encrypt3",1);
|
||||
&des_encrypt3("des_decrypt3",0);
|
||||
|
||||
&file_end();
|
||||
|
||||
sub des_encrypt
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
|
||||
&function_begin($name,3,"EXTRN _des_SPtrans:DWORD");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
&mov("eax",&wparam(0));
|
||||
&mov($R,&DWP(0,"eax","",0));
|
||||
&mov($L,&DWP(4,"eax","",0));
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
&comment("");
|
||||
&comment("IP");
|
||||
&IP($R,$L,"eax");
|
||||
}
|
||||
|
||||
&comment("");
|
||||
&comment("fixup rotate");
|
||||
&rotl($R,3);
|
||||
&rotl($L,3);
|
||||
|
||||
&comment("");
|
||||
&comment("load counter, key_schedule and enc flag");
|
||||
|
||||
# encrypting part
|
||||
|
||||
$ks="ebp";
|
||||
&xor( "ebx", "ebx" );
|
||||
&mov("eax",&wparam(2)); # get encrypt flag
|
||||
&xor( "ecx", "ecx" );
|
||||
&cmp("eax","0");
|
||||
&mov( $ks, &wparam(1) );
|
||||
&je(&label("start_decrypt"));
|
||||
|
||||
for ($i=0; $i<16; $i+=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i+1));
|
||||
&D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
&jmp(&label("end"));
|
||||
|
||||
&set_label("start_decrypt");
|
||||
|
||||
for ($i=15; $i>0; $i-=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i-1));
|
||||
&D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
|
||||
&set_label("end");
|
||||
|
||||
&comment("");
|
||||
&comment("Fixup");
|
||||
&rotr($L,3); # r
|
||||
&rotr($R,3); # l
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
&comment("");
|
||||
&comment("FP");
|
||||
&FP($R,$L,"eax");
|
||||
}
|
||||
|
||||
&mov("eax",&wparam(0));
|
||||
&mov(&DWP(0,"eax","",0),$L);
|
||||
&mov(&DWP(4,"eax","",0),$R);
|
||||
|
||||
&function_end($name);
|
||||
}
|
||||
|
||||
sub D_ENCRYPT
|
||||
{
|
||||
local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
|
||||
|
||||
&mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
|
||||
&mov( $u, &DWP(&n2a($S*4),$ks,"",0));
|
||||
&xor( $t, $R);
|
||||
&xor( $u, $R);
|
||||
&rotr( $t, 4 );
|
||||
&and( $u, "0xfcfcfcfc" );
|
||||
&and( $t, "0xfcfcfcfc" );
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&xor( $L, &DWP(" $desSP",$tmp1,"",0));
|
||||
&shr( $u, 16);
|
||||
&xor( $L, &DWP("0x200+$desSP",$tmp2,"",0));
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&xor( $L, &DWP("0x400+$desSP",$tmp1,"",0));
|
||||
&mov( $u, &DWP("0x600+$desSP",$tmp2,"",0));
|
||||
|
||||
&movb( &LB($tmp1), &LB($t) );
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&xor( $L, &DWP("0x100+$desSP",$tmp1,"",0));
|
||||
&shr( $t, 16);
|
||||
&xor( $u, &DWP("0x300+$desSP",$tmp2,"",0));
|
||||
&movb( &LB($tmp1), &LB($t) );
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&xor( $L, &DWP("0x500+$desSP",$tmp1,"",0));
|
||||
&xor( $u, &DWP("0x700+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $u);
|
||||
}
|
||||
|
||||
sub PERM_OP
|
||||
{
|
||||
local($a,$b,$tt,$shift,$mask)=@_;
|
||||
|
||||
&mov( $tt, $a );
|
||||
&shr( $tt, $shift );
|
||||
&xor( $tt, $b );
|
||||
&and( $tt, $mask );
|
||||
&xor( $b, $tt );
|
||||
&shl( $tt, $shift );
|
||||
&xor( $a, $tt );
|
||||
}
|
||||
|
||||
sub IP
|
||||
{
|
||||
local($l,$r,$tt)=@_;
|
||||
|
||||
&PERM_OP($r,$l,$tt, 4,"0x0f0f0f0f");
|
||||
&PERM_OP($l,$r,$tt,16,"0x0000ffff");
|
||||
&PERM_OP($r,$l,$tt, 2,"0x33333333");
|
||||
&PERM_OP($l,$r,$tt, 8,"0x00ff00ff");
|
||||
&PERM_OP($r,$l,$tt, 1,"0x55555555");
|
||||
}
|
||||
|
||||
sub FP
|
||||
{
|
||||
local($l,$r,$tt)=@_;
|
||||
|
||||
&PERM_OP($l,$r,$tt, 1,"0x55555555");
|
||||
&PERM_OP($r,$l,$tt, 8,"0x00ff00ff");
|
||||
&PERM_OP($l,$r,$tt, 2,"0x33333333");
|
||||
&PERM_OP($r,$l,$tt,16,"0x0000ffff");
|
||||
&PERM_OP($l,$r,$tt, 4,"0x0f0f0f0f");
|
||||
}
|
||||
|
||||
sub n2a
|
||||
{
|
||||
sprintf("%d",$_[0]);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
305
crypto/des/des
305
crypto/des/des
@@ -1,305 +0,0 @@
|
||||
/* crypto/des/des.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify des.org since des.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DES_H
|
||||
#define HEADER_DES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
|
||||
* %20 speed up (longs are 8 bytes, int's are 4). */
|
||||
#ifndef DES_LONG
|
||||
#define DES_LONG unsigned long
|
||||
#endif
|
||||
|
||||
typedef unsigned char des_cblock[8];
|
||||
typedef struct des_ks_struct
|
||||
{
|
||||
union {
|
||||
des_cblock _;
|
||||
/* make sure things are correct size on machines with
|
||||
* 8 byte longs */
|
||||
DES_LONG pad[2];
|
||||
} ks;
|
||||
#undef _
|
||||
#define _ ks._
|
||||
} des_key_schedule[16];
|
||||
|
||||
#define DES_KEY_SZ (sizeof(des_cblock))
|
||||
#define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
|
||||
|
||||
#define DES_ENCRYPT 1
|
||||
#define DES_DECRYPT 0
|
||||
|
||||
#define DES_CBC_MODE 0
|
||||
#define DES_PCBC_MODE 1
|
||||
|
||||
#define des_ecb2_encrypt(i,o,k1,k2,e) \
|
||||
des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
|
||||
|
||||
#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
|
||||
des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
|
||||
|
||||
#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
|
||||
des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
|
||||
|
||||
#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
#define C_Block des_cblock
|
||||
#define Key_schedule des_key_schedule
|
||||
#ifdef KERBEROS
|
||||
#define ENCRYPT DES_ENCRYPT
|
||||
#define DECRYPT DES_DECRYPT
|
||||
#endif
|
||||
#define KEY_SZ DES_KEY_SZ
|
||||
#define string_to_key des_string_to_key
|
||||
#define read_pw_string des_read_pw_string
|
||||
#define random_key des_random_key
|
||||
#define pcbc_encrypt des_pcbc_encrypt
|
||||
#define set_key des_set_key
|
||||
#define key_sched des_key_sched
|
||||
#define ecb_encrypt des_ecb_encrypt
|
||||
#define cbc_encrypt des_cbc_encrypt
|
||||
#define ncbc_encrypt des_ncbc_encrypt
|
||||
#define xcbc_encrypt des_xcbc_encrypt
|
||||
#define cbc_cksum des_cbc_cksum
|
||||
#define quad_cksum des_quad_cksum
|
||||
|
||||
/* For compatibility with the MIT lib - eay 20/05/92 */
|
||||
typedef des_key_schedule bit_64;
|
||||
#define des_fixup_key_parity des_set_odd_parity
|
||||
#define des_check_key_parity check_parity
|
||||
|
||||
extern int des_check_key; /* defaults to false */
|
||||
extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
|
||||
|
||||
/* The next line is used to disable full ANSI prototypes, if your
|
||||
* compiler has problems with the prototypes, make sure this line always
|
||||
* evaluates to true :-) */
|
||||
#if defined(MSDOS) || defined(__STDC__)
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
#ifndef NOPROTO
|
||||
char *des_options(void);
|
||||
void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
|
||||
des_key_schedule ks1,des_key_schedule ks2,
|
||||
des_key_schedule ks3, int enc);
|
||||
DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec);
|
||||
void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,
|
||||
des_cblock *inw,des_cblock *outw,int enc);
|
||||
void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule sk1,des_key_schedule sk2,
|
||||
des_cblock *ivec1,des_cblock *ivec2,int enc);
|
||||
void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void des_ecb_encrypt(des_cblock *input,des_cblock *output,
|
||||
des_key_schedule ks,int enc);
|
||||
void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
|
||||
void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
|
||||
void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int enc);
|
||||
void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
|
||||
void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int *num);
|
||||
|
||||
void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
|
||||
des_cblock (*out_white));
|
||||
|
||||
int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
char *des_fcrypt(const char *buf,const char *salt, char *ret);
|
||||
#ifdef PERL5
|
||||
char *des_crypt(const char *buf,const char *salt);
|
||||
#else
|
||||
/* some stupid compilers complain because I have declared char instead
|
||||
* of const char */
|
||||
#ifdef HEADER_DES_LOCL_H
|
||||
char *crypt(const char *buf,const char *salt);
|
||||
#else
|
||||
char *crypt();
|
||||
#endif
|
||||
#endif
|
||||
void des_ofb_encrypt(unsigned char *in,unsigned char *out,
|
||||
int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
|
||||
void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
|
||||
long length,int out_count,des_cblock *seed);
|
||||
void des_random_seed(des_cblock key);
|
||||
void des_random_key(des_cblock ret);
|
||||
int des_read_password(des_cblock *key,char *prompt,int verify);
|
||||
int des_read_2passwords(des_cblock *key1,des_cblock *key2,
|
||||
char *prompt,int verify);
|
||||
int des_read_pw_string(char *buf,int length,char *prompt,int verify);
|
||||
void des_set_odd_parity(des_cblock *key);
|
||||
int des_is_weak_key(des_cblock *key);
|
||||
int des_set_key(des_cblock *key,des_key_schedule schedule);
|
||||
int des_key_sched(des_cblock *key,des_key_schedule schedule);
|
||||
void des_string_to_key(char *str,des_cblock *key);
|
||||
void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
|
||||
void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
|
||||
void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int *num);
|
||||
int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify);
|
||||
|
||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
||||
void des_cblock_print_file(des_cblock *cb, FILE *fp);
|
||||
/* The following functions are not in the normal unix build or the
|
||||
* SSLeay build. When using the SSLeay build, use RAND_seed()
|
||||
* and RAND_bytes() instead. */
|
||||
int des_new_random_key(des_cblock *key);
|
||||
void des_init_random_number_generator(des_cblock *key);
|
||||
void des_set_random_generator_seed(des_cblock *key);
|
||||
void des_set_sequence_number(des_cblock new_sequence_number);
|
||||
void des_generate_random_block(des_cblock *block);
|
||||
|
||||
#else
|
||||
|
||||
char *des_options();
|
||||
void des_ecb3_encrypt();
|
||||
DES_LONG des_cbc_cksum();
|
||||
void des_cbc_encrypt();
|
||||
void des_ncbc_encrypt();
|
||||
void des_xcbc_encrypt();
|
||||
void des_3cbc_encrypt();
|
||||
void des_cfb_encrypt();
|
||||
void des_ede3_cfb64_encrypt();
|
||||
void des_ede3_ofb64_encrypt();
|
||||
void des_ecb_encrypt();
|
||||
void des_encrypt();
|
||||
void des_encrypt2();
|
||||
void des_encrypt3();
|
||||
void des_decrypt3();
|
||||
void des_ede3_cbc_encrypt();
|
||||
int des_enc_read();
|
||||
int des_enc_write();
|
||||
char *des_fcrypt();
|
||||
#ifdef PERL5
|
||||
char *des_crypt();
|
||||
#else
|
||||
char *crypt();
|
||||
#endif
|
||||
void des_ofb_encrypt();
|
||||
void des_pcbc_encrypt();
|
||||
DES_LONG des_quad_cksum();
|
||||
void des_random_seed();
|
||||
void des_random_key();
|
||||
int des_read_password();
|
||||
int des_read_2passwords();
|
||||
int des_read_pw_string();
|
||||
void des_set_odd_parity();
|
||||
int des_is_weak_key();
|
||||
int des_set_key();
|
||||
int des_key_sched();
|
||||
void des_string_to_key();
|
||||
void des_string_to_2keys();
|
||||
void des_cfb64_encrypt();
|
||||
void des_ofb64_encrypt();
|
||||
int des_read_pw();
|
||||
void des_xwhite_in2out();
|
||||
|
||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
||||
void des_cblock_print_file();
|
||||
/* The following functions are not in the normal unix build or the
|
||||
* SSLeay build. When using the SSLeay build, use RAND_seed()
|
||||
* and RAND_bytes() instead. */
|
||||
#ifdef FreeBSD
|
||||
int des_new_random_key();
|
||||
void des_init_random_number_generator();
|
||||
void des_set_random_generator_seed();
|
||||
void des_set_sequence_number();
|
||||
void des_generate_random_block();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,80 +0,0 @@
|
||||
#
|
||||
# SSLeay/crypto/md/Makefile
|
||||
#
|
||||
|
||||
DIR= md
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
INCLUDES=
|
||||
CFLAG=-g
|
||||
INSTALLTOP=/usr/local/ssl
|
||||
MAKE= make -f Makefile.ssl
|
||||
MAKEDEPEND= makedepend -f Makefile.ssl
|
||||
MAKEFILE= Makefile.ssl
|
||||
AR= ar r
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=md2test.c md5test.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=md2_dgst.c md5_dgst.c md2_one.c md5_one.c
|
||||
LIBOBJ=md2_dgst.o md5_dgst.o md2_one.o md5_one.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= md2.h md5.h
|
||||
HEADER= md5_locl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
sh $(TOP)/util/ranlib.sh $(LIB)
|
||||
@touch lib
|
||||
|
||||
files:
|
||||
perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
/bin/rm -f Makefile
|
||||
$(TOP)/util/point.sh Makefile.ssl Makefile ;
|
||||
$(TOP)/util/mklink.sh ../../include $(EXHEADER)
|
||||
$(TOP)/util/mklink.sh ../../test $(TEST)
|
||||
$(TOP)/util/mklink.sh ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@for i in $(EXHEADER) ; \
|
||||
do \
|
||||
(cp $$i $(INSTALLTOP)/include/$$i; \
|
||||
chmod 644 $(INSTALLTOP)/include/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
depend:
|
||||
$(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
errors:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
137
crypto/md/md2.c
137
crypto/md/md2.c
@@ -1,137 +0,0 @@
|
||||
/* crypto/md/md2.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "md2.h"
|
||||
|
||||
#define BUFSIZE 1024*16
|
||||
|
||||
#ifndef NOPROTO
|
||||
void do_fp(FILE *f);
|
||||
void pt(unsigned char *md);
|
||||
int read(int, void *, unsigned int);
|
||||
void exit(int);
|
||||
void perror(const char *);
|
||||
#else
|
||||
void do_fp();
|
||||
void pt();
|
||||
int read();
|
||||
void exit();
|
||||
void perror();
|
||||
#endif
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int i,err=0;
|
||||
FILE *IN;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
do_fp(stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
IN=fopen(argv[i],"r");
|
||||
if (IN == NULL)
|
||||
{
|
||||
perror(argv[i]);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
printf("MD2(%s)= ",argv[i]);
|
||||
do_fp(IN);
|
||||
fclose(IN);
|
||||
}
|
||||
}
|
||||
exit(err);
|
||||
return(err);
|
||||
}
|
||||
|
||||
void do_fp(f)
|
||||
FILE *f;
|
||||
{
|
||||
MD2_CTX c;
|
||||
unsigned char md[MD2_DIGEST_LENGTH];
|
||||
int fd,i;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
|
||||
fd=fileno(f);
|
||||
MD2_Init(&c);
|
||||
for (;;)
|
||||
{
|
||||
i=read(fd,buf,BUFSIZE);
|
||||
if (i <= 0) break;
|
||||
MD2_Update(&c,buf,(unsigned long)i);
|
||||
}
|
||||
MD2_Final(&(md[0]),&c);
|
||||
pt(md);
|
||||
}
|
||||
|
||||
void pt(md)
|
||||
unsigned char *md;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MD2_DIGEST_LENGTH; i++)
|
||||
printf("%02x",md[i]);
|
||||
printf("\n");
|
||||
}
|
||||
106
crypto/md/md2.h
106
crypto/md/md2.h
@@ -1,106 +0,0 @@
|
||||
/* crypto/md/md2.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify md2.org since md2.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HEADER_MD2_H
|
||||
#define HEADER_MD2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MD2_DIGEST_LENGTH 16
|
||||
#define MD2_BLOCK 16
|
||||
|
||||
#define MD2_INT unsigned int
|
||||
|
||||
typedef struct MD2state_st
|
||||
{
|
||||
int num;
|
||||
unsigned char data[MD2_BLOCK];
|
||||
MD2_INT cksm[MD2_BLOCK];
|
||||
MD2_INT state[MD2_BLOCK];
|
||||
} MD2_CTX;
|
||||
|
||||
#ifndef NOPROTO
|
||||
char *MD2_options(void);
|
||||
void MD2_Init(MD2_CTX *c);
|
||||
void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len);
|
||||
void MD2_Final(unsigned char *md, MD2_CTX *c);
|
||||
unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md);
|
||||
#else
|
||||
char *MD2_options();
|
||||
void MD2_Init();
|
||||
void MD2_Update();
|
||||
void MD2_Final();
|
||||
unsigned char *MD2();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,106 +0,0 @@
|
||||
/* crypto/md/md2.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify md2.org since md2.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HEADER_MD2_H
|
||||
#define HEADER_MD2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MD2_DIGEST_LENGTH 16
|
||||
#define MD2_BLOCK 16
|
||||
|
||||
#define MD2_INT unsigned int
|
||||
|
||||
typedef struct MD2state_st
|
||||
{
|
||||
int num;
|
||||
unsigned char data[MD2_BLOCK];
|
||||
MD2_INT cksm[MD2_BLOCK];
|
||||
MD2_INT state[MD2_BLOCK];
|
||||
} MD2_CTX;
|
||||
|
||||
#ifndef NOPROTO
|
||||
char *MD2_options(void);
|
||||
void MD2_Init(MD2_CTX *c);
|
||||
void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len);
|
||||
void MD2_Final(unsigned char *md, MD2_CTX *c);
|
||||
unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md);
|
||||
#else
|
||||
char *MD2_options();
|
||||
void MD2_Init();
|
||||
void MD2_Update();
|
||||
void MD2_Final();
|
||||
unsigned char *MD2();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,235 +0,0 @@
|
||||
/* crypto/md/md2_dgst.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "md2.h"
|
||||
|
||||
char *MD2_version="MD2 part of SSLeay 0.8.1b 29-Jun-1998";
|
||||
|
||||
/* Implemented from RFC1319 The MD2 Message-Digest Algorithm
|
||||
*/
|
||||
|
||||
#define UCHAR unsigned char
|
||||
|
||||
#ifndef NOPROTO
|
||||
static void md2_block(MD2_CTX *c, unsigned char *d);
|
||||
#else
|
||||
static void md2_block();
|
||||
#endif
|
||||
|
||||
/* The magic S table - I have converted it to hex since it is
|
||||
* basicaly just a random byte string. */
|
||||
static MD2_INT S[256]={
|
||||
0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01,
|
||||
0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
|
||||
0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C,
|
||||
0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA,
|
||||
0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16,
|
||||
0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12,
|
||||
0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49,
|
||||
0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A,
|
||||
0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F,
|
||||
0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21,
|
||||
0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27,
|
||||
0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03,
|
||||
0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1,
|
||||
0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6,
|
||||
0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6,
|
||||
0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1,
|
||||
0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20,
|
||||
0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02,
|
||||
0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6,
|
||||
0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F,
|
||||
0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A,
|
||||
0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26,
|
||||
0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09,
|
||||
0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52,
|
||||
0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA,
|
||||
0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A,
|
||||
0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D,
|
||||
0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39,
|
||||
0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4,
|
||||
0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A,
|
||||
0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A,
|
||||
0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14,
|
||||
};
|
||||
|
||||
char *MD2_options()
|
||||
{
|
||||
if (sizeof(MD2_INT) == 1)
|
||||
return("md2(char)");
|
||||
else
|
||||
return("md2(int)");
|
||||
}
|
||||
|
||||
void MD2_Init(c)
|
||||
MD2_CTX *c;
|
||||
{
|
||||
c->num=0;
|
||||
memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT));
|
||||
memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT));
|
||||
memset(c->data,0,MD2_BLOCK);
|
||||
}
|
||||
|
||||
void MD2_Update(c, data, len)
|
||||
MD2_CTX *c;
|
||||
register unsigned char *data;
|
||||
unsigned long len;
|
||||
{
|
||||
register UCHAR *p;
|
||||
|
||||
if (len == 0) return;
|
||||
|
||||
p=c->data;
|
||||
if (c->num != 0)
|
||||
{
|
||||
if ((c->num+len) >= MD2_BLOCK)
|
||||
{
|
||||
memcpy(&(p[c->num]),data,MD2_BLOCK-c->num);
|
||||
md2_block(c,c->data);
|
||||
data+=(MD2_BLOCK - c->num);
|
||||
len-=(MD2_BLOCK - c->num);
|
||||
c->num=0;
|
||||
/* drop through and do the rest */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&(p[c->num]),data,(int)len);
|
||||
/* data+=len; */
|
||||
c->num+=(int)len;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* we now can process the input data in blocks of MD2_BLOCK
|
||||
* chars and save the leftovers to c->data. */
|
||||
while (len >= MD2_BLOCK)
|
||||
{
|
||||
md2_block(c,data);
|
||||
data+=MD2_BLOCK;
|
||||
len-=MD2_BLOCK;
|
||||
}
|
||||
memcpy(p,data,(int)len);
|
||||
c->num=(int)len;
|
||||
}
|
||||
|
||||
static void md2_block(c, d)
|
||||
MD2_CTX *c;
|
||||
unsigned char *d;
|
||||
{
|
||||
register MD2_INT t,*sp1,*sp2;
|
||||
register int i,j;
|
||||
MD2_INT state[48];
|
||||
|
||||
sp1=c->state;
|
||||
sp2=c->cksm;
|
||||
j=sp2[MD2_BLOCK-1];
|
||||
for (i=0; i<16; i++)
|
||||
{
|
||||
state[i]=sp1[i];
|
||||
state[i+16]=t=d[i];
|
||||
state[i+32]=(t^sp1[i]);
|
||||
j=sp2[i]^=S[t^j];
|
||||
}
|
||||
t=0;
|
||||
for (i=0; i<18; i++)
|
||||
{
|
||||
for (j=0; j<48; j+=8)
|
||||
{
|
||||
t= state[j+ 0]^=S[t];
|
||||
t= state[j+ 1]^=S[t];
|
||||
t= state[j+ 2]^=S[t];
|
||||
t= state[j+ 3]^=S[t];
|
||||
t= state[j+ 4]^=S[t];
|
||||
t= state[j+ 5]^=S[t];
|
||||
t= state[j+ 6]^=S[t];
|
||||
t= state[j+ 7]^=S[t];
|
||||
}
|
||||
t=(t+i)&0xff;
|
||||
}
|
||||
memcpy(sp1,state,16*sizeof(MD2_INT));
|
||||
memset(state,0,48*sizeof(MD2_INT));
|
||||
}
|
||||
|
||||
void MD2_Final(md, c)
|
||||
unsigned char *md;
|
||||
MD2_CTX *c;
|
||||
{
|
||||
int i,v;
|
||||
register UCHAR *cp;
|
||||
register MD2_INT *p1,*p2;
|
||||
|
||||
cp=c->data;
|
||||
p1=c->state;
|
||||
p2=c->cksm;
|
||||
v=MD2_BLOCK-c->num;
|
||||
for (i=c->num; i<MD2_BLOCK; i++)
|
||||
cp[i]=(UCHAR)v;
|
||||
|
||||
md2_block(c,cp);
|
||||
|
||||
for (i=0; i<MD2_BLOCK; i++)
|
||||
cp[i]=(UCHAR)p2[i];
|
||||
md2_block(c,cp);
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
md[i]=(UCHAR)(p1[i]&0xff);
|
||||
memset((char *)&c,0,sizeof(c));
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/* crypto/md/md2_one.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "md2.h"
|
||||
|
||||
/* This is a separate file so that #defines in cryptlib.h can
|
||||
* map my MD functions to different names */
|
||||
|
||||
unsigned char *MD2(d, n, md)
|
||||
unsigned char *d;
|
||||
unsigned long n;
|
||||
unsigned char *md;
|
||||
{
|
||||
MD2_CTX c;
|
||||
static unsigned char m[MD2_DIGEST_LENGTH];
|
||||
|
||||
if (md == NULL) md=m;
|
||||
MD2_Init(&c);
|
||||
MD2_Update(&c,d,n);
|
||||
MD2_Final(md,&c);
|
||||
memset(&c,0,sizeof(c)); /* Security consideration */
|
||||
return(md);
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
/* crypto/md/md2test.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "md2.h"
|
||||
|
||||
char *test[]={
|
||||
"",
|
||||
"a",
|
||||
"abc",
|
||||
"message digest",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
||||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
||||
NULL,
|
||||
};
|
||||
|
||||
char *ret[]={
|
||||
"8350e5a3e24c153df2275c9f80692773",
|
||||
"32ec01ec4a6dac72c0ab96fb34c0b5d1",
|
||||
"da853b0d3f88d99b30283a69e6ded6bb",
|
||||
"ab4f496bfb2a530b219ff33031fe06b0",
|
||||
"4e8ddff3650292ab5a4108c3aa47940b",
|
||||
"da33def2a42df13975352846c30338cd",
|
||||
"d5976f79d83d3a0dc9806c3c66f3efd8",
|
||||
};
|
||||
|
||||
#ifndef NOPROTO
|
||||
static char *pt(unsigned char *md);
|
||||
#else
|
||||
static char *pt();
|
||||
#endif
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int i,err=0;
|
||||
char **P,**R;
|
||||
char *p;
|
||||
|
||||
P=test;
|
||||
R=ret;
|
||||
i=1;
|
||||
while (*P != NULL)
|
||||
{
|
||||
p=pt(MD2((unsigned char *)*P,(unsigned long)strlen(*P),NULL));
|
||||
if (strcmp(p,*R) != 0)
|
||||
{
|
||||
printf("error calculating MD2 on '%s'\n",*P);
|
||||
printf("got %s instead of %s\n",p,*R);
|
||||
err++;
|
||||
}
|
||||
else
|
||||
printf("test %d ok\n",i);
|
||||
i++;
|
||||
R++;
|
||||
P++;
|
||||
}
|
||||
exit(err);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static char *pt(md)
|
||||
unsigned char *md;
|
||||
{
|
||||
int i;
|
||||
static char buf[80];
|
||||
|
||||
for (i=0; i<MD2_DIGEST_LENGTH; i++)
|
||||
sprintf(&(buf[i*2]),"%02x",md[i]);
|
||||
return(buf);
|
||||
}
|
||||
135
crypto/md/md5.c
135
crypto/md/md5.c
@@ -1,135 +0,0 @@
|
||||
/* crypto/md/md5.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "md5.h"
|
||||
|
||||
#define BUFSIZE 1024*16
|
||||
|
||||
#ifndef NOPROTO
|
||||
void do_fp(FILE *f);
|
||||
void pt(unsigned char *md);
|
||||
int read(int, void *, unsigned int);
|
||||
#else
|
||||
void do_fp();
|
||||
void pt();
|
||||
int read();
|
||||
#endif
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i,err=0;
|
||||
FILE *IN;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
do_fp(stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
IN=fopen(argv[i],"r");
|
||||
if (IN == NULL)
|
||||
{
|
||||
perror(argv[i]);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
printf("MD5(%s)= ",argv[i]);
|
||||
do_fp(IN);
|
||||
fclose(IN);
|
||||
}
|
||||
}
|
||||
exit(err);
|
||||
}
|
||||
|
||||
void do_fp(f)
|
||||
FILE *f;
|
||||
{
|
||||
MD5_CTX c;
|
||||
unsigned char md[MD5_DIGEST_LENGTH];
|
||||
int fd;
|
||||
int i;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
|
||||
fd=fileno(f);
|
||||
MD5_Init(&c);
|
||||
for (;;)
|
||||
{
|
||||
i=read(fd,buf,BUFSIZE);
|
||||
if (i <= 0) break;
|
||||
MD5_Update(&c,buf,(unsigned long)i);
|
||||
}
|
||||
MD5_Final(&(md[0]),&c);
|
||||
pt(md);
|
||||
}
|
||||
|
||||
void pt(md)
|
||||
unsigned char *md;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MD5_DIGEST_LENGTH; i++)
|
||||
printf("%02x",md[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/* crypto/md/md5.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_MD5_H
|
||||
#define HEADER_MD5_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MD5_CBLOCK 64
|
||||
#define MD5_LBLOCK 16
|
||||
#define MD5_BLOCK 16
|
||||
#define MD5_LAST_BLOCK 56
|
||||
#define MD5_LENGTH_BLOCK 8
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct MD5state_st
|
||||
{
|
||||
unsigned long A,B,C,D;
|
||||
unsigned long Nl,Nh;
|
||||
unsigned long data[MD5_LBLOCK];
|
||||
int num;
|
||||
} MD5_CTX;
|
||||
|
||||
#ifndef NOPROTO
|
||||
void MD5_Init(MD5_CTX *c);
|
||||
void MD5_Update(MD5_CTX *c, unsigned char *data, unsigned long len);
|
||||
void MD5_Final(unsigned char *md, MD5_CTX *c);
|
||||
unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md);
|
||||
#else
|
||||
void MD5_Init();
|
||||
void MD5_Update();
|
||||
void MD5_Final();
|
||||
unsigned char *MD5();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,366 +0,0 @@
|
||||
/* crypto/md/md5_dgst.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "md5_locl.h"
|
||||
|
||||
char *MD5_version="MD5 part of SSLeay 0.8.1b 29-Jun-1998";
|
||||
|
||||
/* Implemented from RFC1321 The MD5 Message-Digest Algorithm
|
||||
*/
|
||||
|
||||
#define INIT_DATA_A (unsigned long)0x67452301L
|
||||
#define INIT_DATA_B (unsigned long)0xefcdab89L
|
||||
#define INIT_DATA_C (unsigned long)0x98badcfeL
|
||||
#define INIT_DATA_D (unsigned long)0x10325476L
|
||||
|
||||
#ifndef NOPROTO
|
||||
static void md5_block(MD5_CTX *c, unsigned long *p);
|
||||
#else
|
||||
static void md5_block();
|
||||
#endif
|
||||
|
||||
void MD5_Init(c)
|
||||
MD5_CTX *c;
|
||||
{
|
||||
c->A=INIT_DATA_A;
|
||||
c->B=INIT_DATA_B;
|
||||
c->C=INIT_DATA_C;
|
||||
c->D=INIT_DATA_D;
|
||||
c->Nl=0;
|
||||
c->Nh=0;
|
||||
c->num=0;
|
||||
}
|
||||
|
||||
void MD5_Update(c, data, len)
|
||||
MD5_CTX *c;
|
||||
register unsigned char *data;
|
||||
unsigned long len;
|
||||
{
|
||||
register ULONG *p;
|
||||
int sw,sc;
|
||||
ULONG l;
|
||||
|
||||
if (len == 0) return;
|
||||
|
||||
l=(c->Nl+(len<<3))&0xffffffffL;
|
||||
/* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
|
||||
* Wei Dai <weidai@eskimo.com> for pointing it out. */
|
||||
if (l < c->Nl) /* overflow */
|
||||
c->Nh++;
|
||||
c->Nh+=(len>>29);
|
||||
c->Nl=l;
|
||||
|
||||
if (c->num != 0)
|
||||
{
|
||||
p=c->data;
|
||||
sw=c->num>>2;
|
||||
sc=c->num&0x03;
|
||||
|
||||
if ((c->num+len) >= MD5_CBLOCK)
|
||||
{
|
||||
l= p[sw];
|
||||
p_c2l(data,l,sc);
|
||||
p[sw++]=l;
|
||||
for (; sw<MD5_LBLOCK; sw++)
|
||||
{
|
||||
c2l(data,l);
|
||||
p[sw]=l;
|
||||
}
|
||||
len-=(MD5_CBLOCK-c->num);
|
||||
|
||||
md5_block(c,p);
|
||||
c->num=0;
|
||||
/* drop through and do the rest */
|
||||
}
|
||||
else
|
||||
{
|
||||
int ew,ec;
|
||||
|
||||
c->num+=(int)len;
|
||||
if ((sc+len) < 4) /* ugly, add char's to a word */
|
||||
{
|
||||
l= p[sw];
|
||||
p_c2l_p(data,l,sc,len);
|
||||
p[sw]=l;
|
||||
}
|
||||
else
|
||||
{
|
||||
ew=(c->num>>2);
|
||||
ec=(c->num&0x03);
|
||||
l= p[sw];
|
||||
p_c2l(data,l,sc);
|
||||
p[sw++]=l;
|
||||
for (; sw < ew; sw++)
|
||||
{ c2l(data,l); p[sw]=l; }
|
||||
if (ec)
|
||||
{
|
||||
c2l_p(data,l,ec);
|
||||
p[sw]=l;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* we now can process the input data in blocks of MD5_CBLOCK
|
||||
* chars and save the leftovers to c->data. */
|
||||
p=c->data;
|
||||
while (len >= MD5_CBLOCK)
|
||||
{
|
||||
#if defined(L_ENDIAN) || defined(B_ENDIAN)
|
||||
memcpy(p,data,MD5_CBLOCK);
|
||||
data+=MD5_CBLOCK;
|
||||
#ifdef B_ENDIAN
|
||||
for (sw=(MD5_LBLOCK/4); sw; sw--)
|
||||
{
|
||||
Endian_Reverse32(p[0]);
|
||||
Endian_Reverse32(p[1]);
|
||||
Endian_Reverse32(p[2]);
|
||||
Endian_Reverse32(p[3]);
|
||||
p+=4;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
for (sw=(MD5_LBLOCK/4); sw; sw--)
|
||||
{
|
||||
c2l(data,l); *(p++)=l;
|
||||
c2l(data,l); *(p++)=l;
|
||||
c2l(data,l); *(p++)=l;
|
||||
c2l(data,l); *(p++)=l;
|
||||
}
|
||||
#endif
|
||||
p=c->data;
|
||||
md5_block(c,p);
|
||||
len-=MD5_CBLOCK;
|
||||
}
|
||||
sc=(int)len;
|
||||
c->num=sc;
|
||||
if (sc)
|
||||
{
|
||||
sw=sc>>2; /* words to copy */
|
||||
#ifdef L_ENDIAN
|
||||
p[sw]=0;
|
||||
memcpy(p,data,sc);
|
||||
#else
|
||||
sc&=0x03;
|
||||
for ( ; sw; sw--)
|
||||
{ c2l(data,l); *(p++)=l; }
|
||||
c2l_p(data,l,sc);
|
||||
*p=l;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void md5_block(c, X)
|
||||
MD5_CTX *c;
|
||||
register ULONG *X;
|
||||
{
|
||||
register ULONG A,B,C,D;
|
||||
|
||||
A=c->A;
|
||||
B=c->B;
|
||||
C=c->C;
|
||||
D=c->D;
|
||||
|
||||
/* Round 0 */
|
||||
R0(A,B,C,D,X[ 0], 7,0xd76aa478L);
|
||||
R0(D,A,B,C,X[ 1],12,0xe8c7b756L);
|
||||
R0(C,D,A,B,X[ 2],17,0x242070dbL);
|
||||
R0(B,C,D,A,X[ 3],22,0xc1bdceeeL);
|
||||
R0(A,B,C,D,X[ 4], 7,0xf57c0fafL);
|
||||
R0(D,A,B,C,X[ 5],12,0x4787c62aL);
|
||||
R0(C,D,A,B,X[ 6],17,0xa8304613L);
|
||||
R0(B,C,D,A,X[ 7],22,0xfd469501L);
|
||||
R0(A,B,C,D,X[ 8], 7,0x698098d8L);
|
||||
R0(D,A,B,C,X[ 9],12,0x8b44f7afL);
|
||||
R0(C,D,A,B,X[10],17,0xffff5bb1L);
|
||||
R0(B,C,D,A,X[11],22,0x895cd7beL);
|
||||
R0(A,B,C,D,X[12], 7,0x6b901122L);
|
||||
R0(D,A,B,C,X[13],12,0xfd987193L);
|
||||
R0(C,D,A,B,X[14],17,0xa679438eL);
|
||||
R0(B,C,D,A,X[15],22,0x49b40821L);
|
||||
/* Round 1 */
|
||||
R1(A,B,C,D,X[ 1], 5,0xf61e2562L);
|
||||
R1(D,A,B,C,X[ 6], 9,0xc040b340L);
|
||||
R1(C,D,A,B,X[11],14,0x265e5a51L);
|
||||
R1(B,C,D,A,X[ 0],20,0xe9b6c7aaL);
|
||||
R1(A,B,C,D,X[ 5], 5,0xd62f105dL);
|
||||
R1(D,A,B,C,X[10], 9,0x02441453L);
|
||||
R1(C,D,A,B,X[15],14,0xd8a1e681L);
|
||||
R1(B,C,D,A,X[ 4],20,0xe7d3fbc8L);
|
||||
R1(A,B,C,D,X[ 9], 5,0x21e1cde6L);
|
||||
R1(D,A,B,C,X[14], 9,0xc33707d6L);
|
||||
R1(C,D,A,B,X[ 3],14,0xf4d50d87L);
|
||||
R1(B,C,D,A,X[ 8],20,0x455a14edL);
|
||||
R1(A,B,C,D,X[13], 5,0xa9e3e905L);
|
||||
R1(D,A,B,C,X[ 2], 9,0xfcefa3f8L);
|
||||
R1(C,D,A,B,X[ 7],14,0x676f02d9L);
|
||||
R1(B,C,D,A,X[12],20,0x8d2a4c8aL);
|
||||
/* Round 2 */
|
||||
R2(A,B,C,D,X[ 5], 4,0xfffa3942L);
|
||||
R2(D,A,B,C,X[ 8],11,0x8771f681L);
|
||||
R2(C,D,A,B,X[11],16,0x6d9d6122L);
|
||||
R2(B,C,D,A,X[14],23,0xfde5380cL);
|
||||
R2(A,B,C,D,X[ 1], 4,0xa4beea44L);
|
||||
R2(D,A,B,C,X[ 4],11,0x4bdecfa9L);
|
||||
R2(C,D,A,B,X[ 7],16,0xf6bb4b60L);
|
||||
R2(B,C,D,A,X[10],23,0xbebfbc70L);
|
||||
R2(A,B,C,D,X[13], 4,0x289b7ec6L);
|
||||
R2(D,A,B,C,X[ 0],11,0xeaa127faL);
|
||||
R2(C,D,A,B,X[ 3],16,0xd4ef3085L);
|
||||
R2(B,C,D,A,X[ 6],23,0x04881d05L);
|
||||
R2(A,B,C,D,X[ 9], 4,0xd9d4d039L);
|
||||
R2(D,A,B,C,X[12],11,0xe6db99e5L);
|
||||
R2(C,D,A,B,X[15],16,0x1fa27cf8L);
|
||||
R2(B,C,D,A,X[ 2],23,0xc4ac5665L);
|
||||
/* Round 3 */
|
||||
R3(A,B,C,D,X[ 0], 6,0xf4292244L);
|
||||
R3(D,A,B,C,X[ 7],10,0x432aff97L);
|
||||
R3(C,D,A,B,X[14],15,0xab9423a7L);
|
||||
R3(B,C,D,A,X[ 5],21,0xfc93a039L);
|
||||
R3(A,B,C,D,X[12], 6,0x655b59c3L);
|
||||
R3(D,A,B,C,X[ 3],10,0x8f0ccc92L);
|
||||
R3(C,D,A,B,X[10],15,0xffeff47dL);
|
||||
R3(B,C,D,A,X[ 1],21,0x85845dd1L);
|
||||
R3(A,B,C,D,X[ 8], 6,0x6fa87e4fL);
|
||||
R3(D,A,B,C,X[15],10,0xfe2ce6e0L);
|
||||
R3(C,D,A,B,X[ 6],15,0xa3014314L);
|
||||
R3(B,C,D,A,X[13],21,0x4e0811a1L);
|
||||
R3(A,B,C,D,X[ 4], 6,0xf7537e82L);
|
||||
R3(D,A,B,C,X[11],10,0xbd3af235L);
|
||||
R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL);
|
||||
R3(B,C,D,A,X[ 9],21,0xeb86d391L);
|
||||
|
||||
c->A+=A&0xffffffffL;
|
||||
c->B+=B&0xffffffffL;
|
||||
c->C+=C&0xffffffffL;
|
||||
c->D+=D&0xffffffffL;
|
||||
}
|
||||
|
||||
void MD5_Final(md, c)
|
||||
unsigned char *md;
|
||||
MD5_CTX *c;
|
||||
{
|
||||
register int i,j;
|
||||
register ULONG l;
|
||||
register ULONG *p;
|
||||
static unsigned char end[4]={0x80,0x00,0x00,0x00};
|
||||
unsigned char *cp=end;
|
||||
|
||||
/* c->num should definitly have room for at least one more byte. */
|
||||
p=c->data;
|
||||
j=c->num;
|
||||
i=j>>2;
|
||||
|
||||
/* purify often complains about the following line as an
|
||||
* Uninitialized Memory Read. While this can be true, the
|
||||
* following p_c2l macro will reset l when that case is true.
|
||||
* This is because j&0x03 contains the number of 'valid' bytes
|
||||
* already in p[i]. If and only if j&0x03 == 0, the UMR will
|
||||
* occur but this is also the only time p_c2l will do
|
||||
* l= *(cp++) instead of l|= *(cp++)
|
||||
* Many thanks to Alex Tang <altitude@cic.net> for pickup this
|
||||
* 'potential bug' */
|
||||
#ifdef PURIFY
|
||||
if ((j&0x03) == 0) p[i]=0;
|
||||
#endif
|
||||
l=p[i];
|
||||
p_c2l(cp,l,j&0x03);
|
||||
p[i]=l;
|
||||
i++;
|
||||
/* i is the next 'undefined word' */
|
||||
if (c->num >= MD5_LAST_BLOCK)
|
||||
{
|
||||
for (; i<MD5_LBLOCK; i++)
|
||||
p[i]=0;
|
||||
md5_block(c,p);
|
||||
i=0;
|
||||
}
|
||||
for (; i<(MD5_LBLOCK-2); i++)
|
||||
p[i]=0;
|
||||
p[MD5_LBLOCK-2]=c->Nl;
|
||||
p[MD5_LBLOCK-1]=c->Nh;
|
||||
md5_block(c,p);
|
||||
cp=md;
|
||||
l=c->A; l2c(l,cp);
|
||||
l=c->B; l2c(l,cp);
|
||||
l=c->C; l2c(l,cp);
|
||||
l=c->D; l2c(l,cp);
|
||||
|
||||
/* clear stuff, md5_block may be leaving some stuff on the stack
|
||||
* but I'm not worried :-) */
|
||||
c->num=0;
|
||||
/* memset((char *)&c,0,sizeof(c));*/
|
||||
}
|
||||
|
||||
#ifdef undef
|
||||
int printit(l)
|
||||
unsigned long *l;
|
||||
{
|
||||
int i,ii;
|
||||
|
||||
for (i=0; i<2; i++)
|
||||
{
|
||||
for (ii=0; ii<8; ii++)
|
||||
{
|
||||
fprintf(stderr,"%08lx ",l[i*8+ii]);
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,190 +0,0 @@
|
||||
/* crypto/md/md5_locl.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "md5.h"
|
||||
|
||||
#define ULONG unsigned long
|
||||
#define UCHAR unsigned char
|
||||
#define UINT unsigned int
|
||||
|
||||
#if defined(NOCONST)
|
||||
#define const
|
||||
#endif
|
||||
|
||||
#undef c2l
|
||||
#define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \
|
||||
l|=(((unsigned long)(*((c)++)))<< 8), \
|
||||
l|=(((unsigned long)(*((c)++)))<<16), \
|
||||
l|=(((unsigned long)(*((c)++)))<<24))
|
||||
|
||||
#undef p_c2l
|
||||
#define p_c2l(c,l,n) { \
|
||||
switch (n) { \
|
||||
case 0: l =((unsigned long)(*((c)++))); \
|
||||
case 1: l|=((unsigned long)(*((c)++)))<< 8; \
|
||||
case 2: l|=((unsigned long)(*((c)++)))<<16; \
|
||||
case 3: l|=((unsigned long)(*((c)++)))<<24; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* NOTE the pointer is not incremented at the end of this */
|
||||
#undef c2l_p
|
||||
#define c2l_p(c,l,n) { \
|
||||
l=0; \
|
||||
(c)+=n; \
|
||||
switch (n) { \
|
||||
case 3: l =((unsigned long)(*(--(c))))<<16; \
|
||||
case 2: l|=((unsigned long)(*(--(c))))<< 8; \
|
||||
case 1: l|=((unsigned long)(*(--(c)))) ; \
|
||||
} \
|
||||
}
|
||||
|
||||
#undef p_c2l_p
|
||||
#define p_c2l_p(c,l,sc,len) { \
|
||||
switch (sc) \
|
||||
{ \
|
||||
case 0: l =((unsigned long)(*((c)++))); \
|
||||
if (--len == 0) break; \
|
||||
case 1: l|=((unsigned long)(*((c)++)))<< 8; \
|
||||
if (--len == 0) break; \
|
||||
case 2: l|=((unsigned long)(*((c)++)))<<16; \
|
||||
} \
|
||||
}
|
||||
|
||||
#undef l2c
|
||||
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>24)&0xff))
|
||||
|
||||
/* NOTE - c is not incremented as per l2c */
|
||||
#undef l2cn
|
||||
#define l2cn(l1,l2,c,n) { \
|
||||
c+=n; \
|
||||
switch (n) { \
|
||||
case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
|
||||
case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
|
||||
case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
|
||||
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
||||
case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
|
||||
case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
|
||||
case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
|
||||
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */
|
||||
#if defined(WIN32)
|
||||
/* 5 instructions with rotate instruction, else 9 */
|
||||
#define Endian_Reverse32(a) \
|
||||
{ \
|
||||
unsigned long l=(a); \
|
||||
(a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \
|
||||
}
|
||||
#else
|
||||
/* 6 instructions with rotate instruction, else 8 */
|
||||
#define Endian_Reverse32(a) \
|
||||
{ \
|
||||
unsigned long l=(a); \
|
||||
l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \
|
||||
(a)=ROTATE(l,16L); \
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
||||
#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
|
||||
*/
|
||||
|
||||
/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
|
||||
* simplified to the code below. Wei attributes these optimisations
|
||||
* to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
|
||||
*/
|
||||
#define F(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
|
||||
#define G(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
|
||||
#define H(x,y,z) ((x) ^ (y) ^ (z))
|
||||
#define I(x,y,z) (((x) | (~(z))) ^ (y))
|
||||
|
||||
#undef ROTATE
|
||||
#if defined(WIN32)
|
||||
#define ROTATE(a,n) _lrotl(a,n)
|
||||
#else
|
||||
#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
|
||||
#endif
|
||||
|
||||
|
||||
#define R0(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+F((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };\
|
||||
|
||||
#define R1(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+G((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
|
||||
#define R2(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+H((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
|
||||
#define R3(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+I((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
@@ -1,78 +0,0 @@
|
||||
/* crypto/md/md5_one.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "md5_locl.h"
|
||||
|
||||
unsigned char *MD5(d, n, md)
|
||||
unsigned char *d;
|
||||
unsigned long n;
|
||||
unsigned char *md;
|
||||
{
|
||||
MD5_CTX c;
|
||||
static unsigned char m[MD5_DIGEST_LENGTH];
|
||||
|
||||
if (md == NULL) md=m;
|
||||
MD5_Init(&c);
|
||||
MD5_Update(&c,d,n);
|
||||
MD5_Final(md,&c);
|
||||
memset(&c,0,sizeof(c)); /* security consideration */
|
||||
return(md);
|
||||
}
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/* crypto/md/md5test.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "md5.h"
|
||||
|
||||
char *test[]={
|
||||
"",
|
||||
"a",
|
||||
"abc",
|
||||
"message digest",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
||||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
||||
NULL,
|
||||
};
|
||||
|
||||
char *ret[]={
|
||||
"d41d8cd98f00b204e9800998ecf8427e",
|
||||
"0cc175b9c0f1b6a831c399e269772661",
|
||||
"900150983cd24fb0d6963f7d28e17f72",
|
||||
"f96b697d7cb7938d525a2f31aaf161d0",
|
||||
"c3fcd3d76192e4007dfb496cca67e13b",
|
||||
"d174ab98d277d9f5a5611c2c9f419d9f",
|
||||
"57edf4a22be3c955ac49da2e2107b67a",
|
||||
};
|
||||
|
||||
#ifndef NOPROTO
|
||||
static char *pt(unsigned char *md);
|
||||
#else
|
||||
static char *pt();
|
||||
#endif
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int i,err=0;
|
||||
unsigned char **P,**R;
|
||||
char *p;
|
||||
|
||||
P=(unsigned char **)test;
|
||||
R=(unsigned char **)ret;
|
||||
i=1;
|
||||
while (*P != NULL)
|
||||
{
|
||||
p=pt(MD5(*P,(unsigned long)strlen((char *)*P),NULL));
|
||||
if (strcmp(p,(char *)*R) != 0)
|
||||
{
|
||||
printf("error calculating MD5 on '%s'\n",*P);
|
||||
printf("got %s instead of %s\n",p,*R);
|
||||
err++;
|
||||
}
|
||||
else
|
||||
printf("test %d ok\n",i);
|
||||
i++;
|
||||
R++;
|
||||
P++;
|
||||
}
|
||||
exit(err);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static char *pt(md)
|
||||
unsigned char *md;
|
||||
{
|
||||
int i;
|
||||
static char buf[80];
|
||||
|
||||
for (i=0; i<MD5_DIGEST_LENGTH; i++)
|
||||
sprintf(&(buf[i*2]),"%02x",md[i]);
|
||||
return(buf);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
-----BEGIN PKCS7-----
|
||||
MIAGCSqGSIb3DQEHAqCAMIIC2QIBATEMMAoGCCqGSIb3DQIFMIAGCSqGSIb3DQEH
|
||||
AQAAoIIB7TCCAekwggFSAgEAMA0GCSqGSIb3DQEBBAUAMFsxCzAJBgNVBAYTAkFV
|
||||
MRMwEQYDVQQIEwpRdWVlbnNsYW5kMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0
|
||||
ZDEbMBkGA1UEAxMSVGVzdCBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0NloX
|
||||
DTk4MDYwOTEzNTc0NlowYzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xh
|
||||
bmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMSMwIQYDVQQDExpTZXJ2ZXIg
|
||||
dGVzdCBjZXJ0ICg1MTIgYml0KTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCfs8OE
|
||||
J5X/EjFSDxXvRhHErYDmNlsP3YDXYY3g/HJFCTT+VWZFQ0xol2r+qKCl3194/+7X
|
||||
ZLg/BMtv/yr+/rntAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAeEzEdgr2nChPcALL
|
||||
vY8gl/GIlpoAjPmKD+pLeGZI9s+SEX5u1q8nCrJ6ZzkfrRnqgI5Anmev9+qPZfdU
|
||||
bz5zdVSf4sUL9nX9ChXjK9NCJA3UzQHSFqhZErGUwGNkAHYHp2+zAdY6Ho6rmMzt
|
||||
g0CDu/sKR4qzm6REsQGS8kgpjz4xgcUwgcICAQEwYDBbMQswCQYDVQQGEwJBVTET
|
||||
MBEGA1UECBMKUXVlZW5zbGFuZDEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQx
|
||||
GzAZBgNVBAMTElRlc3QgQ0EgKDEwMjQgYml0KQIBADAKBggqhkiG9w0CBTANBgkq
|
||||
hkiG9w0BAQQFAARALnrxJiOX9XZf2D+3vL8SKMQmMq55LltomwOLGUru/q1uVXzi
|
||||
ARg7FSCegOpA1nunsTURMUGgrPXKK4XmL4IseQAAAAA=
|
||||
-----END PKCS7-----
|
||||
@@ -1,33 +0,0 @@
|
||||
-----BEGIN PKCS7-----
|
||||
MIAGCSqGSIb3DQEHAqCAMIIFsQIBATELMAkGBSsOAwIaBQAwgAYJKoZIhvcNAQcB
|
||||
AACgggQdMIICJTCCAc+gAwIBAgIBIjANBgkqhkiG9w0BAQQFADCBgjELMAkGA1UE
|
||||
BhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRow
|
||||
GAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEUMBIGA1UECxMLZGV2ZWxvcG1lbnQx
|
||||
GTAXBgNVBAMTEENyeXB0U29mdCBEZXYgQ0EwHhcNOTcwNjEzMTgxMDE3WhcNOTgw
|
||||
NjEzMTgxMDE3WjCBiDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx
|
||||
ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEU
|
||||
MBIGA1UECxMLSUlTIHRlc3RpbmcxDjAMBgNVBAMTBXRlc3QxMQ8wDQYJKoZIhvcN
|
||||
AQkBFgAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAxtWiv59VH42+rotrmFAyDxTc
|
||||
J2osFt5uy/zEllx3vvjtwewqQxGUOwf6cjqFOTrnpEdVvwywpEhIQ5364bJqIwID
|
||||
AQABoygwJjAkBglghkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0G
|
||||
CSqGSIb3DQEBBAUAA0EAMnYkNV2AdpeHPy/qlcdZx6MDGIJgrLhklhcn6Or6KiAP
|
||||
t9+nv9XdOGHyMyQr9ufsweuQfAgJ9yjKPZR2/adTjTCCAfAwggGaAgEAMA0GCSqG
|
||||
SIb3DQEBBAUAMIGCMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDER
|
||||
MA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRQw
|
||||
EgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UEAxMQQ3J5cHRTb2Z0IERldiBDQTAe
|
||||
Fw05NzAzMjIxMzM0MDRaFw05ODAzMjIxMzM0MDRaMIGCMQswCQYDVQQGEwJBVTET
|
||||
MBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoT
|
||||
EUNyeXB0U29mdCBQdHkgTHRkMRQwEgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UE
|
||||
AxMQQ3J5cHRTb2Z0IERldiBDQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDgDgKq
|
||||
IBuUMAJi4c8juAqEZ8f8FcuDWT+HcScvNztRJy9K8DnbGpiSrzzix4El6N4A7vbl
|
||||
crwn/0CZmQJguZpfAgMBAAEwDQYJKoZIhvcNAQEEBQADQQA0UUvxlXXe6wKkVukn
|
||||
ZoCyXbjlNsqt2rwbvfZEam6fQP3S7uq+o1Pnj+KDgE33WxWbQAA9h8fY1LWN7X3a
|
||||
yTm/MYIBbTCCAWkCAQEwgYgwgYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVl
|
||||
bnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0
|
||||
eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQg
|
||||
RGV2IENBAgEiMAkGBSsOAwIaBQCgfTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcB
|
||||
MCMGCSqGSIb3DQEJBDEWBBSUVhbGkNE+KGqpOK13+FkfOkaoizAcBgkqhkiG9w0B
|
||||
CQUxDxcNOTcwNzAxMDE0MzM0WjAeBgkqhkiG9w0BCQ8xETAPMA0GCCqGSIb3DQMC
|
||||
AgEoMA0GCSqGSIb3DQEBAQUABECa9Jpo4w/fZOc3Vy78wZFAVF8kvpn7il99Ldsr
|
||||
AQ4JiBmcfiSwEBBY6WuKT+/SYtFwZl1oXkTwB5AVCFIC/IFNAAAAAA==
|
||||
-----END PKCS7-----
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
cwd=`pwd`
|
||||
cd /tmp
|
||||
|
||||
if [ -s /bin/ranlib ] ; then
|
||||
RL=/bin/ranlib
|
||||
else if [ -s /usr/bin/ranlib ] ; then
|
||||
RL=/usr/bin/ranlib
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "x$RL" != "x" ]
|
||||
then
|
||||
case "$1" in
|
||||
/*)
|
||||
$RL "$1"
|
||||
;;
|
||||
*)
|
||||
$RL "$cwd/$1"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -1,195 +0,0 @@
|
||||
/* crypto/rc4/rc4_enc.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify rc4_enc.org since rc4_enc.c is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#include "rc4.h"
|
||||
|
||||
/* if this is defined data[i] is used instead of *data, this is a %20
|
||||
* speedup on x86 */
|
||||
#define RC4_INDEX
|
||||
|
||||
char *RC4_version="RC4 part of SSLeay 0.8.1b 29-Jun-1998";
|
||||
|
||||
char *RC4_options()
|
||||
{
|
||||
#ifdef RC4_INDEX
|
||||
if (sizeof(RC4_INT) == 1)
|
||||
return("rc4(idx,char)");
|
||||
else
|
||||
return("rc4(idx,int)");
|
||||
#else
|
||||
if (sizeof(RC4_INT) == 1)
|
||||
return("rc4(ptr,char)");
|
||||
else
|
||||
return("rc4(ptr,int)");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* RC4 as implemented from a posting from
|
||||
* Newsgroups: sci.crypt
|
||||
* From: sterndark@netcom.com (David Sterndark)
|
||||
* Subject: RC4 Algorithm revealed.
|
||||
* Message-ID: <sternCvKL4B.Hyy@netcom.com>
|
||||
* Date: Wed, 14 Sep 1994 06:35:31 GMT
|
||||
*/
|
||||
|
||||
void RC4_set_key(key, len, data)
|
||||
RC4_KEY *key;
|
||||
int len;
|
||||
register unsigned char *data;
|
||||
{
|
||||
register RC4_INT tmp;
|
||||
register int id1,id2;
|
||||
register RC4_INT *d;
|
||||
unsigned int i;
|
||||
|
||||
d= &(key->data[0]);
|
||||
for (i=0; i<256; i++)
|
||||
d[i]=i;
|
||||
key->x = 0;
|
||||
key->y = 0;
|
||||
id1=id2=0;
|
||||
|
||||
#define SK_LOOP(n) { \
|
||||
tmp=d[(n)]; \
|
||||
id2 = (data[id1] + tmp + id2) & 0xff; \
|
||||
if (++id1 == len) id1=0; \
|
||||
d[(n)]=d[id2]; \
|
||||
d[id2]=tmp; }
|
||||
|
||||
for (i=0; i < 256; i+=4)
|
||||
{
|
||||
SK_LOOP(i+0);
|
||||
SK_LOOP(i+1);
|
||||
SK_LOOP(i+2);
|
||||
SK_LOOP(i+3);
|
||||
}
|
||||
}
|
||||
|
||||
void RC4(key, len, indata, outdata)
|
||||
RC4_KEY *key;
|
||||
unsigned long len;
|
||||
unsigned char *indata;
|
||||
unsigned char *outdata;
|
||||
{
|
||||
register RC4_INT *d;
|
||||
register RC4_INT x,y,tx,ty;
|
||||
int i;
|
||||
|
||||
x=key->x;
|
||||
y=key->y;
|
||||
d=key->data;
|
||||
|
||||
#define LOOP(in,out) \
|
||||
x=((x+1)&0xff); \
|
||||
tx=d[x]; \
|
||||
y=(tx+y)&0xff; \
|
||||
d[x]=ty=d[y]; \
|
||||
d[y]=tx; \
|
||||
(out) = d[(tx+ty)&0xff]^ (in);
|
||||
|
||||
#ifndef RC4_INDEX
|
||||
#define RC4_LOOP(a,b,i) LOOP(*((a)++),*((b)++))
|
||||
#else
|
||||
#define RC4_LOOP(a,b,i) LOOP(a[i],b[i])
|
||||
#endif
|
||||
|
||||
i= -(int)len;
|
||||
i=(int)(len>>3L);
|
||||
if (i)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
RC4_LOOP(indata,outdata,0);
|
||||
RC4_LOOP(indata,outdata,1);
|
||||
RC4_LOOP(indata,outdata,2);
|
||||
RC4_LOOP(indata,outdata,3);
|
||||
RC4_LOOP(indata,outdata,4);
|
||||
RC4_LOOP(indata,outdata,5);
|
||||
RC4_LOOP(indata,outdata,6);
|
||||
RC4_LOOP(indata,outdata,7);
|
||||
#ifdef RC4_INDEX
|
||||
indata+=8;
|
||||
outdata+=8;
|
||||
#endif
|
||||
if (--i == 0) break;
|
||||
}
|
||||
}
|
||||
i=(int)len&0x07;
|
||||
if (i)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
RC4_LOOP(indata,outdata,0); if (--i == 0) break;
|
||||
RC4_LOOP(indata,outdata,1); if (--i == 0) break;
|
||||
RC4_LOOP(indata,outdata,2); if (--i == 0) break;
|
||||
RC4_LOOP(indata,outdata,3); if (--i == 0) break;
|
||||
RC4_LOOP(indata,outdata,4); if (--i == 0) break;
|
||||
RC4_LOOP(indata,outdata,5); if (--i == 0) break;
|
||||
RC4_LOOP(indata,outdata,6); if (--i == 0) break;
|
||||
}
|
||||
}
|
||||
key->x=x;
|
||||
key->y=y;
|
||||
}
|
||||
@@ -1,538 +0,0 @@
|
||||
/* crypto/rsa/rsa_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn.h"
|
||||
#include "rsa.h"
|
||||
#include "rand.h"
|
||||
|
||||
#ifndef NOPROTO
|
||||
static int RSA_eay_public_encrypt(int flen, unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,int padding);
|
||||
static int RSA_eay_private_encrypt(int flen, unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,int padding);
|
||||
static int RSA_eay_public_decrypt(int flen, unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,int padding);
|
||||
static int RSA_eay_private_decrypt(int flen, unsigned char *from,
|
||||
unsigned char *to, RSA *rsa,int padding);
|
||||
static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *i, RSA *rsa);
|
||||
#else
|
||||
static int RSA_eay_public_encrypt();
|
||||
static int RSA_eay_private_encrypt();
|
||||
static int RSA_eay_public_decrypt();
|
||||
static int RSA_eay_private_decrypt();
|
||||
static int RSA_eay_mod_exp();
|
||||
#endif
|
||||
|
||||
static RSA_METHOD rsa_pkcs1_eay_meth={
|
||||
"Eric Young's PKCS#1 RSA",
|
||||
RSA_eay_public_encrypt,
|
||||
RSA_eay_public_decrypt,
|
||||
RSA_eay_private_encrypt,
|
||||
RSA_eay_private_decrypt,
|
||||
RSA_eay_mod_exp,
|
||||
BN_mod_exp,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
RSA_METHOD *RSA_PKCS1_SSLeay()
|
||||
{
|
||||
return(&rsa_pkcs1_eay_meth);
|
||||
}
|
||||
|
||||
static int RSA_eay_public_encrypt(flen, from, to, rsa, padding)
|
||||
int flen;
|
||||
unsigned char *from;
|
||||
unsigned char *to;
|
||||
RSA *rsa;
|
||||
int padding;
|
||||
{
|
||||
BIGNUM *f=NULL,*ret=NULL;
|
||||
int i,j,k,num=0,r= -1;
|
||||
unsigned char *p;
|
||||
unsigned char *buf=NULL;
|
||||
BN_CTX *ctx=NULL;
|
||||
|
||||
if ( (padding != RSA_PKCS1_PADDING) &&
|
||||
(padding != RSA_SSLV23_PADDING))
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,RSA_R_UNKNOWN_PADDING_TYPE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx=BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
|
||||
num=BN_num_bytes(rsa->n);
|
||||
if (flen > (num-11))
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
buf=(unsigned char *)Malloc(num);
|
||||
if (buf == NULL)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
p=(unsigned char *)buf;
|
||||
|
||||
*(p++)=0;
|
||||
*(p++)=2; /* Public Key BT (Block Type) */
|
||||
|
||||
/* pad out with non-zero random data */
|
||||
j=num-3-flen;
|
||||
|
||||
RAND_bytes(p,j);
|
||||
for (i=0; i<j; i++)
|
||||
{
|
||||
if (*p == '\0')
|
||||
do {
|
||||
RAND_bytes(p,1);
|
||||
} while (*p == '\0');
|
||||
p++;
|
||||
}
|
||||
|
||||
if (padding == RSA_SSLV23_PADDING)
|
||||
memset(&(p[-8]),3,8);
|
||||
|
||||
*(p++)='\0';
|
||||
|
||||
memcpy(p,from,(unsigned int)flen);
|
||||
|
||||
f=BN_new();
|
||||
ret=BN_new();
|
||||
if ((f == NULL) || (ret == NULL)) goto err;
|
||||
|
||||
if (BN_bin2bn(buf,num,f) == NULL) goto err;
|
||||
if (!rsa->meth->bn_mod_exp(ret,f,rsa->e,rsa->n,ctx)) goto err;
|
||||
|
||||
/* put in leading 0 bytes if the number is less than the
|
||||
* length of the modulus */
|
||||
j=BN_num_bytes(ret);
|
||||
i=BN_bn2bin(ret,&(to[num-j]));
|
||||
for (k=0; k<(num-i); k++)
|
||||
to[k]=0;
|
||||
|
||||
r=num;
|
||||
err:
|
||||
if (ctx != NULL) BN_CTX_free(ctx);
|
||||
if (f != NULL) BN_free(f);
|
||||
if (ret != NULL) BN_free(ret);
|
||||
if (buf != NULL)
|
||||
{
|
||||
memset(buf,0,num);
|
||||
Free(buf);
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
static int RSA_eay_private_encrypt(flen, from, to, rsa, padding)
|
||||
int flen;
|
||||
unsigned char *from;
|
||||
unsigned char *to;
|
||||
RSA *rsa;
|
||||
int padding;
|
||||
{
|
||||
BIGNUM *f=NULL,*ret=NULL;
|
||||
int i,j,k,num=0,r= -1;
|
||||
unsigned char *p;
|
||||
unsigned char *buf=NULL;
|
||||
BN_CTX *ctx=NULL;
|
||||
|
||||
if (padding != RSA_PKCS1_PADDING)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_UNKNOWN_PADDING_TYPE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx=BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
|
||||
num=BN_num_bytes(rsa->n);
|
||||
if (flen > (num-11))
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
|
||||
goto err;
|
||||
}
|
||||
buf=(unsigned char *)Malloc(num);
|
||||
if (buf == NULL)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
p=buf;
|
||||
|
||||
*(p++)=0;
|
||||
*(p++)=1; /* Private Key BT (Block Type) */
|
||||
|
||||
/* padd out with 0xff data */
|
||||
j=num-3-flen;
|
||||
for (i=0; i<j; i++)
|
||||
*(p++)=0xff;
|
||||
*(p++)='\0';
|
||||
memcpy(p,from,(unsigned int)flen);
|
||||
ret=BN_new();
|
||||
f=BN_new();
|
||||
if ((ret == NULL) || (f == NULL)) goto err;
|
||||
if (BN_bin2bn(buf,num,f) == NULL) goto err;
|
||||
if ( (rsa->p != NULL) &&
|
||||
(rsa->q != NULL) &&
|
||||
(rsa->dmp1 != NULL) &&
|
||||
(rsa->dmq1 != NULL) &&
|
||||
(rsa->iqmp != NULL))
|
||||
{ if (!rsa->meth->rsa_mod_exp(ret,f,rsa)) goto err; }
|
||||
else
|
||||
{ if (!rsa->meth->bn_mod_exp(ret,f,rsa->d,rsa->n,ctx)) goto err; }
|
||||
|
||||
p=buf;
|
||||
BN_bn2bin(ret,p);
|
||||
|
||||
/* put in leading 0 bytes if the number is less than the
|
||||
* length of the modulus */
|
||||
j=BN_num_bytes(ret);
|
||||
i=BN_bn2bin(ret,&(to[num-j]));
|
||||
for (k=0; k<(num-i); k++)
|
||||
to[k]=0;
|
||||
|
||||
r=num;
|
||||
err:
|
||||
if (ctx != NULL) BN_CTX_free(ctx);
|
||||
if (ret != NULL) BN_free(ret);
|
||||
if (f != NULL) BN_free(f);
|
||||
if (buf != NULL)
|
||||
{
|
||||
memset(buf,0,num);
|
||||
Free(buf);
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
static int RSA_eay_private_decrypt(flen, from, to, rsa,padding)
|
||||
int flen;
|
||||
unsigned char *from;
|
||||
unsigned char *to;
|
||||
RSA *rsa;
|
||||
int padding;
|
||||
{
|
||||
BIGNUM *f=NULL,*ret=NULL;
|
||||
int i,j,num=0,r= -1;
|
||||
unsigned char *p;
|
||||
unsigned char *buf=NULL;
|
||||
BN_CTX *ctx=NULL;
|
||||
|
||||
if ((padding != RSA_PKCS1_PADDING) && (padding != RSA_SSLV23_PADDING))
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_UNKNOWN_PADDING_TYPE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx=BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
|
||||
num=BN_num_bytes(rsa->n);
|
||||
|
||||
buf=(unsigned char *)Malloc(num);
|
||||
if (buf == NULL)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* This check was for equallity but PGP does evil things
|
||||
* and chops off the top '0' bytes */
|
||||
if (flen > num)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* make data into a big number */
|
||||
ret=BN_new();
|
||||
f=BN_new();
|
||||
if ((ret == NULL) || (f == NULL)) goto err;
|
||||
if (BN_bin2bn(from,(int)flen,f) == NULL) goto err;
|
||||
/* do the decrypt */
|
||||
if ( (rsa->p != NULL) &&
|
||||
(rsa->q != NULL) &&
|
||||
(rsa->dmp1 != NULL) &&
|
||||
(rsa->dmq1 != NULL) &&
|
||||
(rsa->iqmp != NULL))
|
||||
{ if (!rsa->meth->rsa_mod_exp(ret,f,rsa)) goto err; }
|
||||
else
|
||||
{ if (!rsa->meth->bn_mod_exp(ret,f,rsa->d,rsa->n,ctx)) goto err; }
|
||||
|
||||
p=buf;
|
||||
BN_bn2bin(ret,p);
|
||||
|
||||
/* BT must be 02 */
|
||||
if (*(p++) != 02)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_BLOCK_TYPE_IS_NOT_02);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* scan over padding data */
|
||||
j=num-2; /* one for type and one for the prepended 0. */
|
||||
for (i=0; i<j; i++)
|
||||
if (*(p++) == 0) break;
|
||||
|
||||
if (i == j)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_NULL_BEFORE_BLOCK_MISSING);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (i < 8)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_BAD_PAD_BYTE_COUNT);
|
||||
goto err;
|
||||
}
|
||||
|
||||
#undef RSA_DEBUG
|
||||
#ifdef RSA_DEBUG
|
||||
{
|
||||
int z;
|
||||
unsigned char *q;
|
||||
q= &(p[-9]);
|
||||
fprintf(stderr,"\n");
|
||||
for (z=0; z<8; z++) fprintf(stderr,"%02X",q[z]);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (padding == RSA_SSLV23_PADDING)
|
||||
{
|
||||
int z;
|
||||
unsigned char *q;
|
||||
|
||||
/* -9 because we have jumped the '\0' */
|
||||
q= &(p[-9]);
|
||||
for (z=0; z<8; z++)
|
||||
{
|
||||
if (*(q++) != 0x03)
|
||||
break;
|
||||
}
|
||||
if (z == 8)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_SSLV3_ROLLBACK_ATTACK);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* skip over the '\0' */
|
||||
i++;
|
||||
j-=i;
|
||||
|
||||
/* output data */
|
||||
memcpy(to,p,(unsigned int)j);
|
||||
r=j;
|
||||
err:
|
||||
if (ctx != NULL) BN_CTX_free(ctx);
|
||||
if (f != NULL) BN_free(f);
|
||||
if (ret != NULL) BN_free(ret);
|
||||
if (buf != NULL)
|
||||
{
|
||||
memset(buf,0,num);
|
||||
Free(buf);
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
static int RSA_eay_public_decrypt(flen, from, to, rsa, padding)
|
||||
int flen;
|
||||
unsigned char *from;
|
||||
unsigned char *to;
|
||||
RSA *rsa;
|
||||
int padding;
|
||||
{
|
||||
BIGNUM *f=NULL,*ret=NULL;
|
||||
int i,j,num=0,r= -1;
|
||||
unsigned char *p;
|
||||
unsigned char *buf=NULL;
|
||||
BN_CTX *ctx=NULL;
|
||||
|
||||
if (padding != RSA_PKCS1_PADDING)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_UNKNOWN_PADDING_TYPE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx=BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
|
||||
num=BN_num_bytes(rsa->n);
|
||||
buf=(unsigned char *)Malloc(num);
|
||||
if (buf == NULL)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* This check was for equallity but PGP does evil things
|
||||
* and chops off the top '0' bytes */
|
||||
if (flen > num)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* make data into a big number */
|
||||
f=BN_new();
|
||||
ret=BN_new();
|
||||
if ((f == NULL) || (ret == NULL)) goto err;
|
||||
|
||||
if (BN_bin2bn(from,flen,f) == NULL) goto err;
|
||||
/* do the decrypt */
|
||||
if (!rsa->meth->bn_mod_exp(ret,f,rsa->e,rsa->n,ctx)) goto err;
|
||||
|
||||
p=buf;
|
||||
i=BN_bn2bin(ret,p);
|
||||
|
||||
/* BT must be 01 */
|
||||
if (*(p++) != 01)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_BLOCK_TYPE_IS_NOT_01);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* scan over padding data */
|
||||
j=num-2; /* one for type and one for the prepended 0. */
|
||||
for (i=0; i<j; i++)
|
||||
{
|
||||
if (*p != 0xff) /* should decrypt to 0xff */
|
||||
{
|
||||
if (*p == 0)
|
||||
{ p++; break; }
|
||||
else {
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_BAD_FIXED_HEADER_DECRYPT);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
if (i == j)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_NULL_BEFORE_BLOCK_MISSING);
|
||||
goto err;
|
||||
}
|
||||
if (i < 8)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_BAD_PAD_BYTE_COUNT);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* skip over the '\0' */
|
||||
i++;
|
||||
j-=i;
|
||||
|
||||
/* output data */
|
||||
memcpy(to,p,(unsigned int)j);
|
||||
r=j;
|
||||
err:
|
||||
if (ctx != NULL) BN_CTX_free(ctx);
|
||||
if (f != NULL) BN_free(f);
|
||||
if (ret != NULL) BN_free(ret);
|
||||
if (buf != NULL)
|
||||
{
|
||||
memset(buf,0,num);
|
||||
Free(buf);
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
static int RSA_eay_mod_exp(r0, I, rsa)
|
||||
BIGNUM *r0;
|
||||
BIGNUM *I;
|
||||
RSA *rsa;
|
||||
{
|
||||
BIGNUM *r1=NULL,*m1=NULL;
|
||||
int ret=0;
|
||||
BN_CTX *ctx;
|
||||
|
||||
if ((ctx=BN_CTX_new()) == NULL) goto err;
|
||||
m1=BN_new();
|
||||
r1=BN_new();
|
||||
if ((m1 == NULL) || (r1 == NULL)) goto err;
|
||||
|
||||
if (!BN_mod(r1,I,rsa->q,ctx)) goto err;
|
||||
if (!rsa->meth->bn_mod_exp(m1,r1,rsa->dmq1,rsa->q,ctx)) goto err;
|
||||
|
||||
if (!BN_mod(r1,I,rsa->p,ctx)) goto err;
|
||||
if (!rsa->meth->bn_mod_exp(r0,r1,rsa->dmp1,rsa->p,ctx)) goto err;
|
||||
|
||||
if (!BN_add(r1,r0,rsa->p)) goto err;
|
||||
if (!BN_sub(r0,r1,m1)) goto err;
|
||||
|
||||
if (!BN_mul(r1,r0,rsa->iqmp)) goto err;
|
||||
if (!BN_mod(r0,r1,rsa->p,ctx)) goto err;
|
||||
if (!BN_mul(r1,r0,rsa->q)) goto err;
|
||||
if (!BN_add(r0,r1,m1)) goto err;
|
||||
|
||||
ret=1;
|
||||
err:
|
||||
if (m1 != NULL) BN_free(m1);
|
||||
if (r1 != NULL) BN_free(r1);
|
||||
BN_CTX_free(ctx);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
465
crypto/x509/f
465
crypto/x509/f
@@ -1,465 +0,0 @@
|
||||
*** x509name.c Wed Jul 2 09:35:35 1997
|
||||
--- /home/eay/play/x Sat Jul 5 01:39:56 1997
|
||||
***************
|
||||
*** 1,202 ****
|
||||
! /* crypto/x509/x509name.c */
|
||||
! /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
! * All rights reserved.
|
||||
! *
|
||||
! * This package is an SSL implementation written
|
||||
! * by Eric Young (eay@cryptsoft.com).
|
||||
! * The implementation was written so as to conform with Netscapes SSL.
|
||||
! *
|
||||
! * This library is free for commercial and non-commercial use as long as
|
||||
! * the following conditions are aheared to. The following conditions
|
||||
! * apply to all code found in this distribution, be it the RC4, RSA,
|
||||
! * lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
! * included with this distribution is covered by the same copyright terms
|
||||
! * except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
! *
|
||||
! * Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
! * the code are not to be removed.
|
||||
! * If this package is used in a product, Eric Young should be given attribution
|
||||
! * as the author of the parts of the library used.
|
||||
! * This can be in the form of a textual message at program startup or
|
||||
! * in documentation (online or textual) provided with the package.
|
||||
! *
|
||||
! * Redistribution and use in source and binary forms, with or without
|
||||
! * modification, are permitted provided that the following conditions
|
||||
! * are met:
|
||||
! * 1. Redistributions of source code must retain the copyright
|
||||
! * notice, this list of conditions and the following disclaimer.
|
||||
! * 2. Redistributions in binary form must reproduce the above copyright
|
||||
! * notice, this list of conditions and the following disclaimer in the
|
||||
! * documentation and/or other materials provided with the distribution.
|
||||
! * 3. All advertising materials mentioning features or use of this software
|
||||
! * must display the following acknowledgement:
|
||||
! * "This product includes cryptographic software written by
|
||||
! * Eric Young (eay@cryptsoft.com)"
|
||||
! * The word 'cryptographic' can be left out if the rouines from the library
|
||||
! * being used are not cryptographic related :-).
|
||||
! * 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
! * the apps directory (application code) you must include an acknowledgement:
|
||||
! * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
! *
|
||||
! * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
! * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
! * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
! * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
! * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
! * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
! * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
! * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
! * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
! * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
! * SUCH DAMAGE.
|
||||
! *
|
||||
! * The licence and distribution terms for any publically available version or
|
||||
! * derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
! * copied and put under another distribution licence
|
||||
! * [including the GNU Public Licence.]
|
||||
! */
|
||||
!
|
||||
! #include <stdio.h>
|
||||
! #include "stack.h"
|
||||
! #include "cryptlib.h"
|
||||
! #include "asn1.h"
|
||||
! #include "objects.h"
|
||||
! #include "evp.h"
|
||||
! #include "x509.h"
|
||||
!
|
||||
! int X509_NAME_get_text_by_NID(name,nid,buf,len)
|
||||
! X509_NAME *name;
|
||||
! int nid;
|
||||
! char *buf;
|
||||
! int len;
|
||||
{
|
||||
ASN1_OBJECT *obj;
|
||||
|
||||
obj=OBJ_nid2obj(nid);
|
||||
! if (obj == NULL) return(-1);
|
||||
! return(X509_NAME_get_text_by_OBJ(name,obj,buf,len));
|
||||
}
|
||||
|
||||
- int X509_NAME_get_text_by_OBJ(name,obj,buf,len)
|
||||
- X509_NAME *name;
|
||||
- ASN1_OBJECT *obj;
|
||||
- char *buf;
|
||||
- int len;
|
||||
- {
|
||||
- int i;
|
||||
- ASN1_STRING *data;
|
||||
|
||||
! i=X509_NAME_get_index_by_OBJ(name,obj,0);
|
||||
! if (i < 0) return(-1);
|
||||
! data=X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i));
|
||||
! i=(data->length > (len-1))?(len-1):data->length;
|
||||
! if (buf == NULL) return(data->length);
|
||||
! memcpy(buf,data->data,i);
|
||||
! buf[i]='\0';
|
||||
! return(i);
|
||||
! }
|
||||
|
||||
! int X509_NAME_entry_count(name)
|
||||
! X509_NAME *name;
|
||||
{
|
||||
! if (name == NULL) return(0);
|
||||
! return(sk_num(name->entries));
|
||||
}
|
||||
|
||||
! int X509_NAME_get_index_by_NID(name,nid,oldpos)
|
||||
! X509_NAME *name;
|
||||
! int nid;
|
||||
! int oldpos;
|
||||
! {
|
||||
! ASN1_OBJECT *obj;
|
||||
|
||||
! obj=OBJ_nid2obj(nid);
|
||||
! if (obj == NULL) return(-2);
|
||||
! return(X509_NAME_get_index_by_OBJ(name,obj,oldpos));
|
||||
}
|
||||
|
||||
- int X509_NAME_get_index_by_OBJ(name,obj,oldpos)
|
||||
- X509_NAME *name;
|
||||
- ASN1_OBJECT *obj;
|
||||
- int oldpos;
|
||||
- {
|
||||
- int n;
|
||||
- X509_NAME_ENTRY *ne;
|
||||
- STACK *sk;
|
||||
|
||||
! if (name == NULL) return(-1);
|
||||
! if (oldpos < 0)
|
||||
! oldpos= -1;
|
||||
! sk=name->entries;
|
||||
! n=sk_num(sk);
|
||||
! for (oldpos++; oldpos < n; oldpos++)
|
||||
{
|
||||
! ne=(X509_NAME_ENTRY *)sk_value(sk,oldpos);
|
||||
! if (OBJ_cmp(ne->object,obj) == 0)
|
||||
! return(oldpos);
|
||||
}
|
||||
! return(-1);
|
||||
}
|
||||
|
||||
- X509_NAME_ENTRY *X509_NAME_get_entry(name,loc)
|
||||
- X509_NAME *name;
|
||||
- int loc;
|
||||
- {
|
||||
- if ( (name == NULL) || (sk_num(name->entries) <= loc) || (loc < 0))
|
||||
- return(NULL);
|
||||
- else
|
||||
- return((X509_NAME_ENTRY *)sk_value(name->entries,loc));
|
||||
- }
|
||||
|
||||
! X509_NAME_ENTRY *X509_NAME_delete_entry(name,loc)
|
||||
! X509_NAME *name;
|
||||
! int loc;
|
||||
{
|
||||
! X509_NAME_ENTRY *ret;
|
||||
! int i,j,n,set_prev,set_next;
|
||||
! STACK *sk;
|
||||
!
|
||||
! if ((name == NULL) || (sk_num(name->entries) <= loc) || (loc < 0))
|
||||
! return(NULL);
|
||||
! sk=name->entries;
|
||||
! ret=(X509_NAME_ENTRY *)sk_delete(sk,loc);
|
||||
! n=sk_num(sk);
|
||||
! name->modified=1;
|
||||
! if (loc == n) return(ret);
|
||||
!
|
||||
! /* else we need to fixup the set field */
|
||||
! if (loc != 0)
|
||||
! set_prev=((X509_NAME_ENTRY *)sk_value(sk,loc-1))->set;
|
||||
! else
|
||||
! set_prev=ret->set-1;
|
||||
! set_next=((X509_NAME_ENTRY *)sk_value(sk,loc))->set;
|
||||
|
||||
! /* set_prev is the previous set
|
||||
! * set is the current set
|
||||
! * set_next is the following
|
||||
! * prev 1 1 1 1 1 1 1 1
|
||||
! * set 1 1 2 2
|
||||
! * next 1 1 2 2 2 2 3 2
|
||||
! * so basically only if prev and next differ by 2, then
|
||||
! * re-number down by 1 */
|
||||
! if (set_prev+1 < set_next)
|
||||
! {
|
||||
! j=set_next-set_prev-1;
|
||||
! for (i=loc; i<n; i++)
|
||||
! ((X509_NAME_ENTRY *)sk_value(sk,loc-1))->set-=j;
|
||||
! }
|
||||
! return(ret);
|
||||
}
|
||||
|
||||
/* if set is -1, append to previous set, 0 'a new one', and 1,
|
||||
* prepend to the guy we are about to stomp on. */
|
||||
! int X509_NAME_add_entry(name,ne,loc,set)
|
||||
! X509_NAME *name;
|
||||
! X509_NAME_ENTRY *ne;
|
||||
! int loc;
|
||||
! int set;
|
||||
{
|
||||
! X509_NAME_ENTRY *new_name=NULL;
|
||||
int n,i,inc;
|
||||
STACK *sk;
|
||||
|
||||
--- 1,77 ----
|
||||
! X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
|
||||
! int type,unsigned char *bytes, int len)
|
||||
{
|
||||
ASN1_OBJECT *obj;
|
||||
|
||||
obj=OBJ_nid2obj(nid);
|
||||
! if (obj == NULL)
|
||||
! {
|
||||
! X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID,X509_R_UNKNOWN_NID);
|
||||
! return(NULL);
|
||||
! }
|
||||
! return(X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len));
|
||||
}
|
||||
|
||||
|
||||
! X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
|
||||
! ASN1_OBJECT *obj, int type,unsigned char *bytes,
|
||||
! int len)
|
||||
! {
|
||||
! X509_NAME_ENTRY *ret;
|
||||
|
||||
! if ((ne == NULL) || (*ne == NULL))
|
||||
{
|
||||
! if ((ret=X509_NAME_ENTRY_new()) == NULL)
|
||||
! return(NULL);
|
||||
}
|
||||
+ else
|
||||
+ ret= *ne;
|
||||
|
||||
! if (!X509_NAME_ENTRY_set_object(ret,obj))
|
||||
! goto err;
|
||||
! if (!X509_NAME_ENTRY_set_data(ret,type,bytes,len))
|
||||
! goto err;
|
||||
|
||||
! if ((ne != NULL) && (*ne == NULL)) *ne=ret;
|
||||
! return(ret);
|
||||
! err:
|
||||
! if ((ne == NULL) || (ret != *ne))
|
||||
! X509_NAME_ENTRY_free(ret);
|
||||
! return(NULL);
|
||||
}
|
||||
|
||||
|
||||
! int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj)
|
||||
! {
|
||||
! if ((ne == NULL) || (obj == NULL))
|
||||
{
|
||||
! X509err(X509_F_X509_NAME_ENTRY_SET_OBJECT,ERR_R_PASSED_NULL_PARAMETER);
|
||||
! return(0);
|
||||
}
|
||||
! ASN1_OBJECT_free(ne->object);
|
||||
! ne->object=OBJ_dup(obj);
|
||||
! return((ne->object == NULL)?0:1);
|
||||
}
|
||||
|
||||
|
||||
! int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne,int type,unsigned char *bytes,int len)
|
||||
{
|
||||
! int i;
|
||||
|
||||
! if ((ne == NULL) || ((bytes == NULL) && (len != 0))) return(0);
|
||||
! if (len < 0) len=strlen((char *)bytes);
|
||||
! i=ASN1_STRING_set(ne->value,bytes,len);
|
||||
! if (!i) return(0);
|
||||
! ne->value->type=ASN1_PRINTABLE_type(bytes,len);
|
||||
! return(1);
|
||||
}
|
||||
|
||||
/* if set is -1, append to previous set, 0 'a new one', and 1,
|
||||
* prepend to the guy we are about to stomp on. */
|
||||
! int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,int loc,int set)
|
||||
{
|
||||
! /* ERIC: renamed new to nenew for C++ users --tjh */
|
||||
! X509_NAME_ENTRY *nenew;
|
||||
int n,i,inc;
|
||||
STACK *sk;
|
||||
|
||||
***************
|
||||
*** 206,213 ****
|
||||
if (loc > n) loc=n;
|
||||
else if (loc < 0) loc=n;
|
||||
|
||||
- name->modified=1;
|
||||
-
|
||||
if (set == -1)
|
||||
{
|
||||
if (loc == 0)
|
||||
--- 81,86 ----
|
||||
***************
|
||||
*** 223,245 ****
|
||||
}
|
||||
else /* if (set >= 0) */
|
||||
{
|
||||
- inc=(set == 0)?1:0;
|
||||
if (loc >= n)
|
||||
{
|
||||
if (loc != 0)
|
||||
set=((X509_NAME_ENTRY *)
|
||||
! sk_value(sk,n-1))->set+1;
|
||||
else
|
||||
set=0;
|
||||
}
|
||||
else
|
||||
set=((X509_NAME_ENTRY *)sk_value(sk,loc))->set;
|
||||
}
|
||||
|
||||
! if ((new_name=X509_NAME_ENTRY_dup(ne)) == NULL)
|
||||
goto err;
|
||||
! new_name->set=set;
|
||||
! if (!sk_insert(sk,(char *)new_name,loc))
|
||||
{
|
||||
X509err(X509_F_X509_NAME_ADD_ENTRY,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
--- 96,122 ----
|
||||
}
|
||||
else /* if (set >= 0) */
|
||||
{
|
||||
if (loc >= n)
|
||||
{
|
||||
if (loc != 0)
|
||||
set=((X509_NAME_ENTRY *)
|
||||
! sk_value(sk,loc-1))->set+1;
|
||||
else
|
||||
set=0;
|
||||
}
|
||||
else
|
||||
set=((X509_NAME_ENTRY *)sk_value(sk,loc))->set;
|
||||
+ inc=(set == 0)?1:0;
|
||||
}
|
||||
|
||||
! if ((nenew=X509_NAME_ENTRY_dup(ne)) == NULL)
|
||||
goto err;
|
||||
! /* eric forgot to put this in when he cut the nice
|
||||
! * interface so that I don't have to do the icky things
|
||||
! * that req.c does --tjh :-)
|
||||
! */
|
||||
! nenew->set=set;
|
||||
! if (!sk_insert(sk,(char *)nenew,loc))
|
||||
{
|
||||
X509err(X509_F_X509_NAME_ADD_ENTRY,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
***************
|
||||
*** 252,357 ****
|
||||
}
|
||||
return(1);
|
||||
err:
|
||||
! if (new_name != NULL)
|
||||
X509_NAME_ENTRY_free(ne);
|
||||
return(0);
|
||||
- }
|
||||
-
|
||||
- X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(ne,nid,type,bytes,len)
|
||||
- X509_NAME_ENTRY **ne;
|
||||
- int nid;
|
||||
- int type;
|
||||
- unsigned char *bytes;
|
||||
- int len;
|
||||
- {
|
||||
- ASN1_OBJECT *obj;
|
||||
-
|
||||
- obj=OBJ_nid2obj(nid);
|
||||
- if (obj == NULL)
|
||||
- {
|
||||
- X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID,X509_R_UNKNOWN_NID);
|
||||
- return(NULL);
|
||||
- }
|
||||
- return(X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len));
|
||||
- }
|
||||
-
|
||||
- X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len)
|
||||
- X509_NAME_ENTRY **ne;
|
||||
- ASN1_OBJECT *obj;
|
||||
- int type;
|
||||
- unsigned char *bytes;
|
||||
- int len;
|
||||
- {
|
||||
- X509_NAME_ENTRY *ret;
|
||||
-
|
||||
- if ((ne == NULL) || (*ne == NULL))
|
||||
- {
|
||||
- if ((ret=X509_NAME_ENTRY_new()) == NULL)
|
||||
- return(NULL);
|
||||
- }
|
||||
- else
|
||||
- ret= *ne;
|
||||
-
|
||||
- if (!X509_NAME_ENTRY_set_object(ret,obj))
|
||||
- goto err;
|
||||
- if (!X509_NAME_ENTRY_set_data(ret,type,bytes,len))
|
||||
- goto err;
|
||||
-
|
||||
- if ((ne != NULL) && (*ne == NULL)) *ne=ret;
|
||||
- return(ret);
|
||||
- err:
|
||||
- if ((ne == NULL) || (ret != *ne))
|
||||
- X509_NAME_ENTRY_free(ret);
|
||||
- return(NULL);
|
||||
- }
|
||||
-
|
||||
- int X509_NAME_ENTRY_set_object(ne,obj)
|
||||
- X509_NAME_ENTRY *ne;
|
||||
- ASN1_OBJECT *obj;
|
||||
- {
|
||||
- if ((ne == NULL) || (obj == NULL))
|
||||
- {
|
||||
- X509err(X509_F_X509_NAME_ENTRY_SET_OBJECT,ERR_R_PASSED_NULL_PARAMETER);
|
||||
- return(0);
|
||||
- }
|
||||
- ASN1_OBJECT_free(ne->object);
|
||||
- ne->object=OBJ_dup(obj);
|
||||
- return((ne->object == NULL)?0:1);
|
||||
- }
|
||||
-
|
||||
- int X509_NAME_ENTRY_set_data(ne,type,bytes,len)
|
||||
- X509_NAME_ENTRY *ne;
|
||||
- int type;
|
||||
- unsigned char *bytes;
|
||||
- int len;
|
||||
- {
|
||||
- int i;
|
||||
-
|
||||
- if ((ne == NULL) || ((bytes == NULL) && (len != 0))) return(0);
|
||||
- if (len < 0) len=strlen((char *)bytes);
|
||||
- i=ASN1_STRING_set(ne->value,bytes,len);
|
||||
- if (!i) return(0);
|
||||
- if (type != V_ASN1_UNDEF)
|
||||
- {
|
||||
- if (type == V_ASN1_APP_CHOOSE)
|
||||
- ne->value->type=ASN1_PRINTABLE_type(bytes,len);
|
||||
- else
|
||||
- ne->value->type=type;
|
||||
- }
|
||||
- return(1);
|
||||
- }
|
||||
-
|
||||
- ASN1_OBJECT *X509_NAME_ENTRY_get_object(ne)
|
||||
- X509_NAME_ENTRY *ne;
|
||||
- {
|
||||
- if (ne == NULL) return(NULL);
|
||||
- return(ne->object);
|
||||
- }
|
||||
-
|
||||
- ASN1_STRING *X509_NAME_ENTRY_get_data(ne)
|
||||
- X509_NAME_ENTRY *ne;
|
||||
- {
|
||||
- if (ne == NULL) return(NULL);
|
||||
- return(ne->value);
|
||||
}
|
||||
|
||||
--- 129,136 ----
|
||||
}
|
||||
return(1);
|
||||
err:
|
||||
! if (nenew != NULL)
|
||||
X509_NAME_ENTRY_free(ne);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
If you specify a SSLv2 cipher, and the mode is SSLv23 and the server
|
||||
can talk SSLv3, it will claim there is no cipher since you should be
|
||||
using SSLv3.
|
||||
|
||||
When tracing debug stuff, remember BIO_s_socket() is different to
|
||||
BIO_s_connect().
|
||||
|
||||
BSD/OS assember is not working
|
||||
@@ -1,93 +0,0 @@
|
||||
echo=off
|
||||
|
||||
echo start testenc
|
||||
path=..\ms;%path%
|
||||
set ssleay=%1%
|
||||
set input=..\ms\testenc.bat
|
||||
set tmp1=..\ms\cipher.out
|
||||
set out1=..\ms\clear.out
|
||||
set cmp=perl ..\ms\cmp.pl
|
||||
|
||||
call tenc.bat enc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc4
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
echo OK
|
||||
del %out1%
|
||||
del %tmp1%
|
||||
:err
|
||||
|
||||
93
ms/clear.out
93
ms/clear.out
@@ -1,93 +0,0 @@
|
||||
echo=off
|
||||
|
||||
echo start testenc
|
||||
path=..\ms;%path%
|
||||
set ssleay=%1%
|
||||
set input=..\ms\testenc.bat
|
||||
set tmp1=..\ms\cipher.out
|
||||
set out1=..\ms\clear.out
|
||||
set cmp=perl ..\ms\cmp.pl
|
||||
|
||||
call tenc.bat enc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc4
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat des-ede3-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat idea-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat rc2-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-ecb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-cfb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-ofb
|
||||
if errorlevel 1 goto err
|
||||
|
||||
call tenc.bat bf-cbc
|
||||
if errorlevel 1 goto err
|
||||
|
||||
echo OK
|
||||
del %out1%
|
||||
del %tmp1%
|
||||
:err
|
||||
|
||||
@@ -1,440 +0,0 @@
|
||||
/* ssl/bio_ssl.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "bio.h"
|
||||
#include "err.h"
|
||||
#include "ssl.h"
|
||||
|
||||
#ifndef NOPROTO
|
||||
static int ssl_write(BIO *h,char *buf,int num);
|
||||
static int ssl_read(BIO *h,char *buf,int size);
|
||||
static int ssl_puts(BIO *h,char *str);
|
||||
static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int ssl_new(BIO *h);
|
||||
static int ssl_free(BIO *data);
|
||||
#else
|
||||
static int ssl_write();
|
||||
static int ssl_read();
|
||||
static int ssl_puts();
|
||||
static long ssl_ctrl();
|
||||
static int ssl_new();
|
||||
static int ssl_free();
|
||||
#endif
|
||||
|
||||
static BIO_METHOD methods_sslp=
|
||||
{
|
||||
BIO_TYPE_SSL,"ssl",
|
||||
ssl_write,
|
||||
ssl_read,
|
||||
ssl_puts,
|
||||
NULL, /* ssl_gets, */
|
||||
ssl_ctrl,
|
||||
ssl_new,
|
||||
ssl_free,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_f_ssl()
|
||||
{
|
||||
return(&methods_sslp);
|
||||
}
|
||||
|
||||
static int ssl_new(bi)
|
||||
BIO *bi;
|
||||
{
|
||||
bi->init=0;
|
||||
bi->ptr=NULL; /* The SSL structure */
|
||||
bi->flags=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int ssl_free(a)
|
||||
BIO *a;
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->ptr != NULL) SSL_shutdown((SSL *)a->ptr);
|
||||
if (a->shutdown)
|
||||
{
|
||||
if (a->init) SSL_free((SSL *)a->ptr);
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
a->ptr=NULL;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int ssl_read(b,out,outl)
|
||||
BIO *b;
|
||||
char *out;
|
||||
int outl;
|
||||
{
|
||||
int ret=1,dr,dw;
|
||||
int inflags,outflags;
|
||||
SSL *ssl;
|
||||
int retry_reason=0;
|
||||
|
||||
if (out == NULL) return(0);
|
||||
ssl=(SSL *)b->ptr;
|
||||
|
||||
inflags=outflags=b->flags;
|
||||
|
||||
dr=inflags&BIO_FLAGS_PROTOCOL_DELAYED_READ;
|
||||
dw=inflags&BIO_FLAGS_PROTOCOL_DELAYED_WRITE;
|
||||
|
||||
outflags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_WRITE|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ);
|
||||
|
||||
if (!SSL_is_init_finished(ssl))
|
||||
{
|
||||
ret=SSL_do_handshake(ssl);
|
||||
#if 0
|
||||
if (ret > 0)
|
||||
{
|
||||
outflags=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ|dw);
|
||||
ret= -1;
|
||||
goto end;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (ret > 0)
|
||||
ret=SSL_read(ssl,out,outl);
|
||||
|
||||
switch (SSL_get_error(ssl,ret))
|
||||
{
|
||||
case SSL_ERROR_NONE:
|
||||
if (ret <= 0) break;
|
||||
if (dw)
|
||||
outflags|=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY);
|
||||
break;
|
||||
case SSL_ERROR_WANT_READ:
|
||||
outflags=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ|dw);
|
||||
break;
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
outflags=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ|dw);
|
||||
break;
|
||||
case SSL_ERROR_WANT_X509_LOOKUP:
|
||||
outflags=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ|dw);
|
||||
retry_reason=BIO_RR_SSL_X509_LOOKUP;
|
||||
break;
|
||||
case SSL_ERROR_WANT_CONNECT:
|
||||
outflags=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ|dw);
|
||||
retry_reason=BIO_RR_CONNECT;
|
||||
break;
|
||||
case SSL_ERROR_SYSCALL:
|
||||
case SSL_ERROR_SSL:
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
b->retry_reason=retry_reason;
|
||||
b->flags=outflags;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int ssl_write(b,out,outl)
|
||||
BIO *b;
|
||||
char *out;
|
||||
int outl;
|
||||
{
|
||||
int ret,dr,dw;
|
||||
int inflags,outflags,retry_reason=0;
|
||||
SSL *ssl;
|
||||
|
||||
if (out == NULL) return(0);
|
||||
ssl=(SSL *)b->ptr;
|
||||
|
||||
inflags=outflags=b->flags;
|
||||
|
||||
dr=inflags&BIO_FLAGS_PROTOCOL_DELAYED_READ;
|
||||
dw=inflags&BIO_FLAGS_PROTOCOL_DELAYED_WRITE;
|
||||
|
||||
outflags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_WRITE|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ);
|
||||
|
||||
ret=SSL_do_handshake(ssl);
|
||||
if (ret > 0)
|
||||
ret=SSL_write(ssl,out,outl);
|
||||
|
||||
switch (SSL_get_error(ssl,ret))
|
||||
{
|
||||
case SSL_ERROR_NONE:
|
||||
if (ret <= 0) break;
|
||||
if (dr)
|
||||
outflags|=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY);
|
||||
break;
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
outflags=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_WRITE|dr);
|
||||
break;
|
||||
case SSL_ERROR_WANT_READ:
|
||||
outflags=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_WRITE|dr);
|
||||
break;
|
||||
case SSL_ERROR_WANT_X509_LOOKUP:
|
||||
outflags=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_WRITE|dr);
|
||||
retry_reason=BIO_RR_SSL_X509_LOOKUP;
|
||||
break;
|
||||
case SSL_ERROR_WANT_CONNECT:
|
||||
outflags=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY|
|
||||
BIO_FLAGS_PROTOCOL_DELAYED_READ|dw);
|
||||
retry_reason=BIO_RR_CONNECT;
|
||||
case SSL_ERROR_SYSCALL:
|
||||
case SSL_ERROR_SSL:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
b->retry_reason=retry_reason;
|
||||
b->flags=outflags;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long ssl_ctrl(b,cmd,num,ptr)
|
||||
BIO *b;
|
||||
int cmd;
|
||||
long num;
|
||||
char *ptr;
|
||||
{
|
||||
SSL **sslp,*ssl;
|
||||
BIO *dbio,*bio;
|
||||
long ret=1;
|
||||
|
||||
ssl=(SSL *)b->ptr;
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
SSL_shutdown(ssl);
|
||||
|
||||
if (ssl->handshake_func == ssl->method->ssl_connect)
|
||||
SSL_set_connect_state(ssl);
|
||||
else if (ssl->handshake_func == ssl->method->ssl_accept)
|
||||
SSL_set_accept_state(ssl);
|
||||
|
||||
SSL_clear(ssl);
|
||||
|
||||
if (b->next_bio != NULL)
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
else if (ssl->rbio != NULL)
|
||||
ret=BIO_ctrl(ssl->rbio,cmd,num,ptr);
|
||||
else
|
||||
ret=1;
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
case BIO_CTRL_INFO:
|
||||
ret=0;
|
||||
break;
|
||||
case BIO_C_SSL_MODE:
|
||||
if (num) /* client mode */
|
||||
SSL_set_connect_state(ssl);
|
||||
else
|
||||
SSL_set_accept_state(ssl);
|
||||
break;
|
||||
case BIO_C_SET_SSL:
|
||||
ssl_free(b);
|
||||
b->shutdown=(int)num;
|
||||
b->ptr=ptr;
|
||||
ssl=(SSL *)ptr;
|
||||
bio=SSL_get_rbio(ssl);
|
||||
if (bio != NULL)
|
||||
{
|
||||
if (b->next_bio != NULL)
|
||||
BIO_push(bio,b->next_bio);
|
||||
b->next_bio=bio;
|
||||
}
|
||||
b->init=1;
|
||||
break;
|
||||
case BIO_C_GET_SSL:
|
||||
if (ptr != NULL)
|
||||
{
|
||||
sslp=(SSL **)ptr;
|
||||
*sslp=ssl;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret=b->shutdown;
|
||||
break;
|
||||
case BIO_CTRL_SET_CLOSE:
|
||||
b->shutdown=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret=BIO_ctrl(ssl->wbio,cmd,num,ptr);
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
ret=SSL_pending(ssl);
|
||||
if (ret == 0)
|
||||
ret=BIO_pending(ssl->rbio);
|
||||
break;
|
||||
case BIO_CTRL_FLUSH:
|
||||
BIO_clear_retry_flags(b);
|
||||
ret=BIO_ctrl(ssl->wbio,cmd,num,ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
case BIO_CTRL_PUSH:
|
||||
if (b->next_bio != NULL)
|
||||
{
|
||||
SSL_set_bio(ssl,b->next_bio,b->next_bio);
|
||||
b->next_bio->references++;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_POP:
|
||||
/* ugly bit of a hack */
|
||||
if (ssl->rbio != ssl->wbio) /* we are in trouble :-( */
|
||||
{
|
||||
BIO_free_all(ssl->wbio);
|
||||
}
|
||||
ssl->wbio=NULL;
|
||||
ssl->rbio=NULL;
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
BIO_clear_retry_flags(b);
|
||||
|
||||
b->retry_reason=0;
|
||||
ret=(int)SSL_do_handshake(ssl);
|
||||
|
||||
switch (SSL_get_error(ssl,ret))
|
||||
{
|
||||
case SSL_ERROR_WANT_READ:
|
||||
BIO_set_flags(b,
|
||||
BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY);
|
||||
break;
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
BIO_set_flags(b,
|
||||
BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY);
|
||||
break;
|
||||
case SSL_ERROR_WANT_CONNECT:
|
||||
BIO_set_flags(b,
|
||||
BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY);
|
||||
b->retry_reason=b->next_bio->retry_reason;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
dbio=(BIO *)ptr;
|
||||
if (dbio->ptr != NULL)
|
||||
SSL_free((SSL *)dbio->ptr);
|
||||
dbio->ptr=(char *)SSL_dup(ssl);
|
||||
ret=(dbio->ptr != NULL);
|
||||
break;
|
||||
default:
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int ssl_puts(bp,str)
|
||||
BIO *bp;
|
||||
char *str;
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
n=strlen(str);
|
||||
ret=BIO_write(bp,str,n);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
BIO *BIO_new_ssl(ctx,client)
|
||||
SSL_CTX *ctx;
|
||||
int client;
|
||||
{
|
||||
BIO *ret;
|
||||
SSL *ssl;
|
||||
|
||||
if ((ret=BIO_new(BIO_f_ssl())) == NULL)
|
||||
return(NULL);
|
||||
if ((ssl=SSL_new(ctx)) == NULL)
|
||||
{
|
||||
BIO_free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
if (client)
|
||||
SSL_set_connect_state(ssl);
|
||||
else
|
||||
SSL_set_accept_state(ssl);
|
||||
|
||||
BIO_set_ssl(ret,ssl,BIO_CLOSE);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BIO_ssl_copy_session_id(t,f)
|
||||
BIO *t,*f;
|
||||
{
|
||||
t=BIO_find_type(t,BIO_TYPE_SSL);
|
||||
f=BIO_find_type(f,BIO_TYPE_SSL);
|
||||
if ((t == NULL) || (f == NULL))
|
||||
return(0);
|
||||
if ((t->ptr == NULL) || (f->ptr == NULL))
|
||||
return(0);
|
||||
SSL_copy_session_id((SSL *)t->ptr,(SSL *)f->ptr);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
for i in BUILD_SSLV23 BUILD_SSLV2 BUILD_SSLV3 BUILD_SSL_COMMON BUILD_SSL_BIO BUILD_SSL_OPTIONAL
|
||||
do
|
||||
time gcc -D$i -o $i.o -c -I. -I../include -O3 -fomit-frame-pointer ssl.c
|
||||
done
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
Must do a
|
||||
SSL_init_eay_ciphers();
|
||||
before calls to SSL_CTX_new()
|
||||
|
||||
SSL_CTX *SSL_CTX_new(void ) -> SSL_CTX *SSL_CTX_new(SSL_METHOD *meth);
|
||||
|
||||
SSL_CTX_set_cert_verify_cb -> the callback is now
|
||||
int callback(char *arg,SSL *s,X509 *xs,STACK *cert_chain);
|
||||
where the 'cert_chain' has been added.
|
||||
402
ssl/zz
402
ssl/zz
@@ -1,402 +0,0 @@
|
||||
/* ssl/s23_srvr.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "buffer.h"
|
||||
#include "rand.h"
|
||||
#include "objects.h"
|
||||
#include "evp.h"
|
||||
#include "ssl_locl.h"
|
||||
|
||||
#define BREAK break
|
||||
|
||||
#ifndef NOPROTO
|
||||
int ssl23_get_client_hello(SSL *s);
|
||||
#else
|
||||
int ssl23_get_client_hello();
|
||||
#endif
|
||||
|
||||
static SSL_METHOD *ssl23_get_server_method(ver)
|
||||
int ver;
|
||||
{
|
||||
if (ver == 2)
|
||||
return(SSLv2_server_method());
|
||||
else if (ver == 3)
|
||||
return(SSLv3_server_method());
|
||||
else
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
SSL_METHOD *SSLv23_server_method()
|
||||
{
|
||||
static int init=1;
|
||||
static SSL_METHOD SSLv23_server_data;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
memcpy((char *)&SSLv23_server_data,
|
||||
(char *)sslv23_base_method(),sizeof(SSL_METHOD));
|
||||
SSLv23_server_data.ssl_accept=ssl23_accept;
|
||||
SSLv23_server_data.get_ssl_method=ssl23_get_server_method;
|
||||
}
|
||||
return(&SSLv23_server_data);
|
||||
}
|
||||
|
||||
int ssl23_accept(s)
|
||||
SSL *s;
|
||||
{
|
||||
BUF_MEM *buf;
|
||||
unsigned long Time=time(NULL);
|
||||
void (*cb)()=NULL;
|
||||
int ret= -1;
|
||||
int new_state,state;
|
||||
|
||||
RAND_seed((unsigned char *)&Time,sizeof(Time));
|
||||
ERR_clear_error();
|
||||
errno=0;
|
||||
|
||||
if (s->info_callback != NULL)
|
||||
cb=s->info_callback;
|
||||
else if (s->ctx->info_callback != NULL)
|
||||
cb=s->ctx->info_callback;
|
||||
|
||||
if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
|
||||
s->in_handshake++;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
state=s->state;
|
||||
|
||||
switch(s->state)
|
||||
{
|
||||
case SSL_ST_BEFORE:
|
||||
case SSL_ST_ACCEPT:
|
||||
case SSL_ST_BEFORE|SSL_ST_ACCEPT:
|
||||
case SSL_ST_OK|SSL_ST_ACCEPT:
|
||||
|
||||
if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);
|
||||
|
||||
s->version=3;
|
||||
s->type=SSL_ST_ACCEPT;
|
||||
|
||||
if (s->init_buf == NULL)
|
||||
{
|
||||
if ((buf=BUF_MEM_new()) == NULL)
|
||||
{
|
||||
ret= -1;
|
||||
goto end;
|
||||
}
|
||||
if (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH))
|
||||
{
|
||||
ret= -1;
|
||||
goto end;
|
||||
}
|
||||
s->init_buf=buf;
|
||||
}
|
||||
|
||||
ssl3_init_finished_mac(s);
|
||||
|
||||
s->state=SSL23_ST_SR_CLNT_HELLO_A;
|
||||
s->ctx->sess_accept++;
|
||||
s->init_num=0;
|
||||
break;
|
||||
|
||||
case SSL23_ST_SR_CLNT_HELLO_A:
|
||||
case SSL23_ST_SR_CLNT_HELLO_B:
|
||||
|
||||
s->shutdown=0;
|
||||
ret=ssl23_get_client_hello(s);
|
||||
if (ret >= 0) cb=NULL;
|
||||
goto end;
|
||||
break;
|
||||
|
||||
default:
|
||||
SSLerr(SSL_F_SSL23_ACCEPT,SSL_R_UNKNOWN_STATE);
|
||||
ret= -1;
|
||||
goto end;
|
||||
/* break; */
|
||||
}
|
||||
|
||||
if ((cb != NULL) && (s->state != state))
|
||||
{
|
||||
new_state=s->state;
|
||||
s->state=state;
|
||||
cb(s,SSL_CB_ACCEPT_LOOP,1);
|
||||
s->state=new_state;
|
||||
}
|
||||
}
|
||||
end:
|
||||
if (cb != NULL)
|
||||
cb(s,SSL_CB_ACCEPT_EXIT,ret);
|
||||
s->in_handshake--;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
int ssl23_get_client_hello(s)
|
||||
SSL *s;
|
||||
{
|
||||
char buf[8];
|
||||
unsigned char *p,*d,*dd;
|
||||
unsigned int i;
|
||||
unsigned int csl,sil,cl;
|
||||
int n=0,j;
|
||||
BIO *bbio;
|
||||
int type=0;
|
||||
|
||||
/* read the initial header */
|
||||
if (s->state == SSL23_ST_SR_CLNT_HELLO_A)
|
||||
{
|
||||
if (!ssl3_setup_buffers(s)) goto err;
|
||||
|
||||
n=ssl23_read_bytes(s,7);
|
||||
if (n != 7) return(n);
|
||||
|
||||
p=s->packet;
|
||||
|
||||
memcpy(buf,p,n);
|
||||
|
||||
if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO))
|
||||
{
|
||||
/* SSLv2 header */
|
||||
if ((p[3] == 0x00) && (p[4] == 0x02))
|
||||
{
|
||||
/* SSLv2 */
|
||||
type=1;
|
||||
}
|
||||
else if ((p[3] == SSL3_VERSION_MAJOR) &&
|
||||
(p[4] == SSL3_VERSION_MINOR))
|
||||
{
|
||||
/* SSLv3 */
|
||||
s->state=SSL23_ST_SR_CLNT_HELLO_B;
|
||||
}
|
||||
}
|
||||
else if ((p[0] == SSL3_RT_HANDSHAKE) &&
|
||||
(p[1] == SSL3_VERSION_MAJOR) &&
|
||||
(p[2] == SSL3_VERSION_MINOR) &&
|
||||
(p[5] == SSL3_MT_CLIENT_HELLO))
|
||||
{
|
||||
/* true SSLv3 */
|
||||
type=3;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->state == SSL23_ST_SR_CLNT_HELLO_B)
|
||||
{
|
||||
/* we have a SSLv3 in a SSLv2 header */
|
||||
type=2;
|
||||
p=s->packet;
|
||||
n=((p[0]&0x7f)<<8)|p[1];
|
||||
if (n > (1024*4))
|
||||
{
|
||||
SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_LARGE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
j=ssl23_read_bytes(s,n+2);
|
||||
if (j <= 0) return(j);
|
||||
|
||||
ssl3_finish_mac(s,&(s->packet[2]),s->packet_length-2);
|
||||
|
||||
p=s->packet;
|
||||
p+=5;
|
||||
n2s(p,csl);
|
||||
n2s(p,sil);
|
||||
n2s(p,cl);
|
||||
d=(unsigned char *)s->init_buf->data;
|
||||
if ((csl+sil+cl+11) != s->packet_length)
|
||||
{
|
||||
SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_LENGTH_MISMATCH);
|
||||
goto err;
|
||||
}
|
||||
|
||||
*(d++)=SSL3_VERSION_MAJOR;
|
||||
*(d++)=SSL3_VERSION_MINOR;
|
||||
|
||||
/* lets populate the random area */
|
||||
/* get the chalenge_length */
|
||||
i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl;
|
||||
memset(d,0,SSL3_RANDOM_SIZE);
|
||||
memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i);
|
||||
d+=SSL3_RANDOM_SIZE;
|
||||
|
||||
/* no session-id reuse */
|
||||
*(d++)=0;
|
||||
|
||||
/* ciphers */
|
||||
j=0;
|
||||
dd=d;
|
||||
d+=2;
|
||||
for (i=0; i<csl; i+=3)
|
||||
{
|
||||
if (p[i] != 0) continue;
|
||||
*(d++)=p[i+1];
|
||||
*(d++)=p[i+2];
|
||||
j+=2;
|
||||
}
|
||||
s2n(j,dd);
|
||||
|
||||
/* compression */
|
||||
*(d++)=1;
|
||||
*(d++)=0;
|
||||
|
||||
i=(d-(unsigned char *)s->init_buf->data);
|
||||
|
||||
/* get the data reused from the init_buf */
|
||||
s->s3->tmp.reuse_message=1;
|
||||
s->s3->tmp.message_type=SSL3_MT_CLIENT_HELLO;
|
||||
s->s3->tmp.message_size=i;
|
||||
}
|
||||
|
||||
if (type == 1)
|
||||
{
|
||||
/* we are talking sslv2 */
|
||||
/* we need to clean up the SSLv3 setup and put in the
|
||||
* sslv2 stuff. */
|
||||
|
||||
if (s->s2 == NULL)
|
||||
{
|
||||
if (!ssl2_new(s))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
ssl2_clear(s);
|
||||
|
||||
if (s->s3 != NULL) ssl3_free(s);
|
||||
|
||||
if (!BUF_MEM_grow(s->init_buf,
|
||||
SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
|
||||
s->state=SSL2_ST_GET_CLIENT_HELLO_A;
|
||||
if (s->ctx->options & SSL_OP_MSIE_SSLV2_RSA_PADDING)
|
||||
s->s2->ssl2_rollback=0;
|
||||
else
|
||||
s->s2->ssl2_rollback=1;
|
||||
|
||||
/* setup the 5 bytes we have read so we get them from
|
||||
* the sslv2 buffer */
|
||||
s->rstate=SSL_ST_READ_HEADER;
|
||||
s->packet_length=n;
|
||||
s->packet= &(s->s2->rbuf[0]);
|
||||
memcpy(s->packet,buf,n);
|
||||
s->s2->rbuf_left=n;
|
||||
s->s2->rbuf_offs=0;
|
||||
|
||||
s->method=SSLv2_server_method();
|
||||
s->handshake_func=s->method->ssl_accept;
|
||||
}
|
||||
|
||||
if ((type == 2) || (type == 3))
|
||||
{
|
||||
/* we have sslv3 */
|
||||
|
||||
if (s->bbio == NULL)
|
||||
{
|
||||
bbio=BIO_new(BIO_f_buffer());
|
||||
if (bbio == NULL)
|
||||
goto err;
|
||||
s->bbio=bbio;
|
||||
}
|
||||
else
|
||||
bbio=s->bbio;
|
||||
BIO_reset(bbio);
|
||||
if (!BIO_set_write_buffer_size(bbio,16*1024))
|
||||
goto err;
|
||||
s->wbio=BIO_push(bbio,s->wbio);
|
||||
|
||||
/* we are in this state */
|
||||
s->state=SSL3_ST_SR_CLNT_HELLO_A;
|
||||
|
||||
if (type == 3)
|
||||
{
|
||||
/* put the 'n' bytes we have read into the input buffer
|
||||
* for SSLv3 */
|
||||
s->rstate=SSL_ST_READ_HEADER;
|
||||
s->packet_length=n;
|
||||
s->packet= &(s->s3->rbuf.buf[0]);
|
||||
memcpy(s->packet,buf,n);
|
||||
s->s3->rbuf.left=n;
|
||||
s->s3->rbuf.offset=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s->packet_length=0;
|
||||
s->s3->rbuf.left=0;
|
||||
s->s3->rbuf.offset=0;
|
||||
}
|
||||
|
||||
s->method=SSLv3_server_method();
|
||||
s->handshake_func=s->method->ssl_accept;
|
||||
}
|
||||
|
||||
if ((type < 1) || (type > 3))
|
||||
{
|
||||
/* bad, very bad */
|
||||
SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNKNOWN_PROTOCOL);
|
||||
goto err;
|
||||
}
|
||||
s->init_num=0;
|
||||
return(SSL_accept(s));
|
||||
err:
|
||||
return(-1);
|
||||
}
|
||||
|
||||
BIN
test/riptest
BIN
test/riptest
Binary file not shown.
Reference in New Issue
Block a user