+++ /dev/null
-/* 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);
- }
-
+++ /dev/null
------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-----
+++ /dev/null
------BEGIN CERTIFICATE REQUEST-----
-MIIBGzCBxgIBADBjMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDEa
-MBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxIzAhBgNVBAMTGkNsaWVudCB0ZXN0
-IGNlcnQgKDUxMiBiaXQpMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALtv55QyzG6i
-2PlwZ1pah7++Gv8L5j6Hnyr/uTZE1NLG0ABDDexmq/R4KedLjFEIYjocDui+IXs6
-2NNtXrT8odkCAwEAATANBgkqhkiG9w0BAQQFAANBAC5JBTeji7RosqMaUIDzIW13
-oO6+kPhx9fXSpMFHIsY3aH92Milkov/2A4SuZTcnv/P6+8klmS0EaiUKcRzak4E=
------END CERTIFICATE REQUEST-----
+++ /dev/null
------BEGIN X509 CRL-----
-MIIBDjCBuTANBgkqhkiG9w0BAQQFADBgMQswCQYDVQQGEwJBVTEMMAoGA1UECBMD
-UUxEMRkwFwYDVQQKExBNaW5jb20gUHR5LiBMdGQuMQswCQYDVQQLEwJDUzEbMBkG
-A1UEAxMSU1NMZWF5IGRlbW8gc2VydmVyFw05NzA3MDkwMDAwMjJaFw05NzA4MDgw
-MDAwMjJaMCgwEgIBARcNOTUxMDA5MjMzMjA1WjASAgEDFw05NTEyMDEwMTAwMDBa
-MA0GCSqGSIb3DQEBBAUAA0EAcEBIWVZPXxSlLMPPLfBi4s0N3lzTgskZkgO6pjZi
-oQRwh5vi5zFqDNQteGx7RTHpUYntgyoAZ87FZE0GOJgBaQ==
------END X509 CRL-----
+++ /dev/null
------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-----
+++ /dev/null
------BEGIN PRIVACY-ENHANCED MESSAGE-----
-MIAGCSqGSIb3DQEHBqCAMIACAQAwgAYJKoZIhvcNAQcBMBEGBSsOAwIHBAifqtdy
-x6uIMYCCARgvFzJtOZBn773DtmXlx037ck3giqnV0WC0QAx5f+fesAiGaxMqWcir
-r9XvT0nT0LgSQ/8tiLCDBEKdyCNgdcJAduy3D0r2sb5sNTT0TyL9uydG3w55vTnW
-aPbCPCWLudArI1UHDZbnoJICrVehxG/sYX069M8v6VO8PsJS7//hh1yM+0nekzQ5
-l1p0j7uWKu4W0csrlGqhLvEJanj6dQAGSTNCOoH3jzEXGQXntgesk8poFPfHdtj0
-5RH4MuJRajDmoEjlrNcnGl/BdHAd2JaCo6uZWGcnGAgVJ/TVfSVSwN5nlCK87tXl
-nL7DJwaPRYwxb3mnPKNq7ATiJPf5u162MbwxrddmiE7e3sST7naSN+GS0ateY5X7
-AAAAAAAAAAA=
------END PRIVACY-ENHANCED MESSAGE-----
-
+++ /dev/null
------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-----
-
+++ /dev/null
------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-----
+++ /dev/null
-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
-
+++ /dev/null
- 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-----
+++ /dev/null
-/* 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);
- }
-
+++ /dev/null
-/* 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);
- }
-
+++ /dev/null
- /* 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"
+++ /dev/null
- ; 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
+++ /dev/null
- .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"
+++ /dev/null
- .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"
+++ /dev/null
- .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"
+++ /dev/null
- .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"
+++ /dev/null
- 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
+++ /dev/null
-/* 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);
- }
+++ /dev/null
-/* 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
- }
-
+++ /dev/null
-/* 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);
- }
-
+++ /dev/null
-#!/usr/local/bin/perl
-
-
-for ($i=0; $i<256; $i++)
- {
- for ($j=0; $j<256; $j++)
- {
- $a0=$i&0x0f;
- $a1=($i>>4)&0x0f;
- $b0=$j&0x0f;
- $b1=($j>>4)&0x0f;
-
- $a0b0=$a0*$b0;
- $a1b1=$a1*$b1;
-
- $a01=$a0-$a1;
- $b10=$b1-$b0;
- $a01b10=$a01*$b10;
-
- if ($a01b10 < 0)
- {
- $neg=1;
- $a01b10= -$a01b10;
- }
- $t=($a0b0>>4)+($a0b0&0x0f)+($a1b1&0x0f);
- if ($neg)
- { $t-=($a01b10&0x0f); }
- else { $t+=($a01b10&0x0f); }
- printf("%02X %s%02X %02X\n",$a1b1,($neg)?"-":" ",$a01b10,$a0b0)
- if ($t < 0)
- }
- }
+++ /dev/null
-/* 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);
- }
+++ /dev/null
-/* 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);
- }
+++ /dev/null
-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
+++ /dev/null
-/* 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");
- }
- }
+++ /dev/null
------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-----
+++ /dev/null
------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-----
+++ /dev/null
-/* 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;
- }