From 58964a492275ca9a59a0cd9c8155cb2491b4b909 Mon Sep 17 00:00:00 2001 From: "Ralf S. Engelschall" Date: Mon, 21 Dec 1998 10:56:39 +0000 Subject: Import of old SSLeay release: SSLeay 0.9.0b --- times/x86/bfs.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++ times/x86/casts.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++ times/x86/des3s.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++ times/x86/dess.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++ times/x86/md5s.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ times/x86/rc4s.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ times/x86/sha1s.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 498 insertions(+) create mode 100644 times/x86/bfs.cpp create mode 100644 times/x86/casts.cpp create mode 100644 times/x86/des3s.cpp create mode 100644 times/x86/dess.cpp create mode 100644 times/x86/md5s.cpp create mode 100644 times/x86/rc4s.cpp create mode 100644 times/x86/sha1s.cpp (limited to 'times/x86') diff --git a/times/x86/bfs.cpp b/times/x86/bfs.cpp new file mode 100644 index 0000000000..272ed2f978 --- /dev/null +++ b/times/x86/bfs.cpp @@ -0,0 +1,67 @@ +// +// gettsc.inl +// +// gives access to the Pentium's (secret) cycle counter +// +// This software was written by Leonard Janke (janke@unixg.ubc.ca) +// in 1996-7 and is entered, by him, into the public domain. + +#if defined(__WATCOMC__) +void GetTSC(unsigned long&); +#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; +#elif defined(__GNUC__) +inline +void GetTSC(unsigned long& tsc) +{ + asm volatile(".byte 15, 49\n\t" + : "=eax" (tsc) + : + : "%edx", "%eax"); +} +#elif defined(_MSC_VER) +inline +void GetTSC(unsigned long& tsc) +{ + unsigned long a; + __asm _emit 0fh + __asm _emit 31h + __asm mov a, eax; + tsc=a; +} +#endif + +#include +#include +#include "blowfish.h" + +void main(int argc,char *argv[]) + { + BF_KEY key; + unsigned long s1,s2,e1,e2; + unsigned long data[2]; + int i,j; + + for (j=0; j<6; j++) + { + for (i=0; i<1000; i++) /**/ + { + BF_encrypt(&data[0],&key); + GetTSC(s1); + BF_encrypt(&data[0],&key); + BF_encrypt(&data[0],&key); + BF_encrypt(&data[0],&key); + GetTSC(e1); + GetTSC(s2); + BF_encrypt(&data[0],&key); + BF_encrypt(&data[0],&key); + BF_encrypt(&data[0],&key); + BF_encrypt(&data[0],&key); + GetTSC(e2); + BF_encrypt(&data[0],&key); + } + + printf("blowfish %d %d (%d)\n", + e1-s1,e2-s2,((e2-s2)-(e1-s1))); + } + } + diff --git a/times/x86/casts.cpp b/times/x86/casts.cpp new file mode 100644 index 0000000000..7f524da57b --- /dev/null +++ b/times/x86/casts.cpp @@ -0,0 +1,67 @@ +// +// gettsc.inl +// +// gives access to the Pentium's (secret) cycle counter +// +// This software was written by Leonard Janke (janke@unixg.ubc.ca) +// in 1996-7 and is entered, by him, into the public domain. + +#if defined(__WATCOMC__) +void GetTSC(unsigned long&); +#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; +#elif defined(__GNUC__) +inline +void GetTSC(unsigned long& tsc) +{ + asm volatile(".byte 15, 49\n\t" + : "=eax" (tsc) + : + : "%edx", "%eax"); +} +#elif defined(_MSC_VER) +inline +void GetTSC(unsigned long& tsc) +{ + unsigned long a; + __asm _emit 0fh + __asm _emit 31h + __asm mov a, eax; + tsc=a; +} +#endif + +#include +#include +#include "cast.h" + +void main(int argc,char *argv[]) + { + CAST_KEY key; + unsigned long s1,s2,e1,e2; + unsigned long data[2]; + int i,j; + + for (j=0; j<6; j++) + { + for (i=0; i<1000; i++) /**/ + { + CAST_encrypt(&data[0],&key); + GetTSC(s1); + CAST_encrypt(&data[0],&key); + CAST_encrypt(&data[0],&key); + CAST_encrypt(&data[0],&key); + GetTSC(e1); + GetTSC(s2); + CAST_encrypt(&data[0],&key); + CAST_encrypt(&data[0],&key); + CAST_encrypt(&data[0],&key); + CAST_encrypt(&data[0],&key); + GetTSC(e2); + CAST_encrypt(&data[0],&key); + } + + printf("cast %d %d (%d)\n", + e1-s1,e2-s2,((e2-s2)-(e1-s1))); + } + } + diff --git a/times/x86/des3s.cpp b/times/x86/des3s.cpp new file mode 100644 index 0000000000..9aff6494d9 --- /dev/null +++ b/times/x86/des3s.cpp @@ -0,0 +1,67 @@ +// +// gettsc.inl +// +// gives access to the Pentium's (secret) cycle counter +// +// This software was written by Leonard Janke (janke@unixg.ubc.ca) +// in 1996-7 and is entered, by him, into the public domain. + +#if defined(__WATCOMC__) +void GetTSC(unsigned long&); +#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; +#elif defined(__GNUC__) +inline +void GetTSC(unsigned long& tsc) +{ + asm volatile(".byte 15, 49\n\t" + : "=eax" (tsc) + : + : "%edx", "%eax"); +} +#elif defined(_MSC_VER) +inline +void GetTSC(unsigned long& tsc) +{ + unsigned long a; + __asm _emit 0fh + __asm _emit 31h + __asm mov a, eax; + tsc=a; +} +#endif + +#include +#include +#include "des.h" + +void main(int argc,char *argv[]) + { + des_key_schedule key1,key2,key3; + unsigned long s1,s2,e1,e2; + unsigned long data[2]; + int i,j; + + for (j=0; j<6; j++) + { + for (i=0; i<1000; i++) /**/ + { + des_encrypt3(&data[0],key1,key2,key3); + GetTSC(s1); + des_encrypt3(&data[0],key1,key2,key3); + des_encrypt3(&data[0],key1,key2,key3); + des_encrypt3(&data[0],key1,key2,key3); + GetTSC(e1); + GetTSC(s2); + des_encrypt3(&data[0],key1,key2,key3); + des_encrypt3(&data[0],key1,key2,key3); + des_encrypt3(&data[0],key1,key2,key3); + des_encrypt3(&data[0],key1,key2,key3); + GetTSC(e2); + des_encrypt3(&data[0],key1,key2,key3); + } + + printf("des %d %d (%d)\n", + e1-s1,e2-s2,((e2-s2)-(e1-s1))); + } + } + diff --git a/times/x86/dess.cpp b/times/x86/dess.cpp new file mode 100644 index 0000000000..7fb5987314 --- /dev/null +++ b/times/x86/dess.cpp @@ -0,0 +1,67 @@ +// +// gettsc.inl +// +// gives access to the Pentium's (secret) cycle counter +// +// This software was written by Leonard Janke (janke@unixg.ubc.ca) +// in 1996-7 and is entered, by him, into the public domain. + +#if defined(__WATCOMC__) +void GetTSC(unsigned long&); +#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; +#elif defined(__GNUC__) +inline +void GetTSC(unsigned long& tsc) +{ + asm volatile(".byte 15, 49\n\t" + : "=eax" (tsc) + : + : "%edx", "%eax"); +} +#elif defined(_MSC_VER) +inline +void GetTSC(unsigned long& tsc) +{ + unsigned long a; + __asm _emit 0fh + __asm _emit 31h + __asm mov a, eax; + tsc=a; +} +#endif + +#include +#include +#include "des.h" + +void main(int argc,char *argv[]) + { + des_key_schedule key; + unsigned long s1,s2,e1,e2; + unsigned long data[2]; + int i,j; + + for (j=0; j<6; j++) + { + for (i=0; i<1000; i++) /**/ + { + des_encrypt(&data[0],key,1); + GetTSC(s1); + des_encrypt(&data[0],key,1); + des_encrypt(&data[0],key,1); + des_encrypt(&data[0],key,1); + GetTSC(e1); + GetTSC(s2); + des_encrypt(&data[0],key,1); + des_encrypt(&data[0],key,1); + des_encrypt(&data[0],key,1); + des_encrypt(&data[0],key,1); + GetTSC(e2); + des_encrypt(&data[0],key,1); + } + + printf("des %d %d (%d)\n", + e1-s1,e2-s2,((e2-s2)-(e1-s1))); + } + } + diff --git a/times/x86/md5s.cpp b/times/x86/md5s.cpp new file mode 100644 index 0000000000..ef8e175df0 --- /dev/null +++ b/times/x86/md5s.cpp @@ -0,0 +1,78 @@ +// +// gettsc.inl +// +// gives access to the Pentium's (secret) cycle counter +// +// This software was written by Leonard Janke (janke@unixg.ubc.ca) +// in 1996-7 and is entered, by him, into the public domain. + +#if defined(__WATCOMC__) +void GetTSC(unsigned long&); +#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; +#elif defined(__GNUC__) +inline +void GetTSC(unsigned long& tsc) +{ + asm volatile(".byte 15, 49\n\t" + : "=eax" (tsc) + : + : "%edx", "%eax"); +} +#elif defined(_MSC_VER) +inline +void GetTSC(unsigned long& tsc) +{ + unsigned long a; + __asm _emit 0fh + __asm _emit 31h + __asm mov a, eax; + tsc=a; +} +#endif + +#include +#include +#include "md5.h" + +extern "C" { +void md5_block_x86(MD5_CTX *ctx, unsigned char *buffer,int num); +} + +void main(int argc,char *argv[]) + { + unsigned char buffer[64*256]; + MD5_CTX ctx; + unsigned long s1,s2,e1,e2; + unsigned char k[16]; + unsigned long data[2]; + unsigned char iv[8]; + int i,num=0,numm; + int j=0; + + if (argc >= 2) + num=atoi(argv[1]); + + if (num == 0) num=16; + if (num > 250) num=16; + numm=num+2; + num*=64; + numm*=64; + + for (j=0; j<6; j++) + { + for (i=0; i<10; i++) /**/ + { + md5_block_x86(&ctx,buffer,numm); + GetTSC(s1); + md5_block_x86(&ctx,buffer,numm); + GetTSC(e1); + GetTSC(s2); + md5_block_x86(&ctx,buffer,num); + GetTSC(e2); + md5_block_x86(&ctx,buffer,num); + } + printf("md5 (%d bytes) %d %d (%.2f)\n",num, + e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); + } + } + diff --git a/times/x86/rc4s.cpp b/times/x86/rc4s.cpp new file mode 100644 index 0000000000..39f1727dd3 --- /dev/null +++ b/times/x86/rc4s.cpp @@ -0,0 +1,73 @@ +// +// gettsc.inl +// +// gives access to the Pentium's (secret) cycle counter +// +// This software was written by Leonard Janke (janke@unixg.ubc.ca) +// in 1996-7 and is entered, by him, into the public domain. + +#if defined(__WATCOMC__) +void GetTSC(unsigned long&); +#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; +#elif defined(__GNUC__) +inline +void GetTSC(unsigned long& tsc) +{ + asm volatile(".byte 15, 49\n\t" + : "=eax" (tsc) + : + : "%edx", "%eax"); +} +#elif defined(_MSC_VER) +inline +void GetTSC(unsigned long& tsc) +{ + unsigned long a; + __asm _emit 0fh + __asm _emit 31h + __asm mov a, eax; + tsc=a; +} +#endif + +#include +#include +#include "rc4.h" + +void main(int argc,char *argv[]) + { + unsigned char buffer[1024]; + RC4_KEY ctx; + unsigned long s1,s2,e1,e2; + unsigned char k[16]; + unsigned long data[2]; + unsigned char iv[8]; + int i,num=64,numm; + int j=0; + + if (argc >= 2) + num=atoi(argv[1]); + + if (num == 0) num=256; + if (num > 1024-16) num=1024-16; + numm=num+8; + + for (j=0; j<6; j++) + { + for (i=0; i<10; i++) /**/ + { + RC4(&ctx,numm,buffer,buffer); + GetTSC(s1); + RC4(&ctx,numm,buffer,buffer); + GetTSC(e1); + GetTSC(s2); + RC4(&ctx,num,buffer,buffer); + GetTSC(e2); + RC4(&ctx,num,buffer,buffer); + } + + printf("RC4 (%d bytes) %d %d (%d) - 8 bytes\n",num, + e1-s1,e2-s2,(e1-s1)-(e2-s2)); + } + } + diff --git a/times/x86/sha1s.cpp b/times/x86/sha1s.cpp new file mode 100644 index 0000000000..0163377de6 --- /dev/null +++ b/times/x86/sha1s.cpp @@ -0,0 +1,79 @@ +// +// gettsc.inl +// +// gives access to the Pentium's (secret) cycle counter +// +// This software was written by Leonard Janke (janke@unixg.ubc.ca) +// in 1996-7 and is entered, by him, into the public domain. + +#if defined(__WATCOMC__) +void GetTSC(unsigned long&); +#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; +#elif defined(__GNUC__) +inline +void GetTSC(unsigned long& tsc) +{ + asm volatile(".byte 15, 49\n\t" + : "=eax" (tsc) + : + : "%edx", "%eax"); +} +#elif defined(_MSC_VER) +inline +void GetTSC(unsigned long& tsc) +{ + unsigned long a; + __asm _emit 0fh + __asm _emit 31h + __asm mov a, eax; + tsc=a; +} +#endif + +#include +#include +#include "sha.h" + +extern "C" { +void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num); +} + +void main(int argc,char *argv[]) + { + unsigned char buffer[64*256]; + SHA_CTX ctx; + unsigned long s1,s2,e1,e2; + unsigned char k[16]; + unsigned long data[2]; + unsigned char iv[8]; + int i,num=0,numm; + int j=0; + + if (argc >= 2) + num=atoi(argv[1]); + + if (num == 0) num=16; + if (num > 250) num=16; + numm=num+2; + num*=64; + numm*=64; + + for (j=0; j<6; j++) + { + for (i=0; i<10; i++) /**/ + { + sha1_block_x86(&ctx,buffer,numm); + GetTSC(s1); + sha1_block_x86(&ctx,buffer,numm); + GetTSC(e1); + GetTSC(s2); + sha1_block_x86(&ctx,buffer,num); + GetTSC(e2); + sha1_block_x86(&ctx,buffer,num); + } + + printf("sha1 (%d bytes) %d %d (%.2f)\n",num, + e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); + } + } + -- cgit v1.2.3