diff options
author | ryker <> | 1998-10-05 20:13:15 +0000 |
---|---|---|
committer | ryker <> | 1998-10-05 20:13:15 +0000 |
commit | 536c76cbb863bab152f19842ab88772c01e922c7 (patch) | |
tree | dfecec371a097b73d605aae665887946d9982219 /src/lib/libcrypto/sha/sha1s.cpp | |
download | openbsd-536c76cbb863bab152f19842ab88772c01e922c7.tar.gz openbsd-536c76cbb863bab152f19842ab88772c01e922c7.tar.bz2 openbsd-536c76cbb863bab152f19842ab88772c01e922c7.zip |
Import of SSLeay-0.9.0b with RSA and IDEA stubbed + OpenBSD build
functionality for shared libs.
Note that routines such as sslv2_init and friends that use RSA will
not work due to lack of RSA in this library.
Needs documentation and help from ports for easy upgrade to full
functionality where legally possible.
Diffstat (limited to 'src/lib/libcrypto/sha/sha1s.cpp')
-rw-r--r-- | src/lib/libcrypto/sha/sha1s.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/lib/libcrypto/sha/sha1s.cpp b/src/lib/libcrypto/sha/sha1s.cpp new file mode 100644 index 0000000000..0163377de6 --- /dev/null +++ b/src/lib/libcrypto/sha/sha1s.cpp | |||
@@ -0,0 +1,79 @@ | |||
1 | // | ||
2 | // gettsc.inl | ||
3 | // | ||
4 | // gives access to the Pentium's (secret) cycle counter | ||
5 | // | ||
6 | // This software was written by Leonard Janke (janke@unixg.ubc.ca) | ||
7 | // in 1996-7 and is entered, by him, into the public domain. | ||
8 | |||
9 | #if defined(__WATCOMC__) | ||
10 | void GetTSC(unsigned long&); | ||
11 | #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; | ||
12 | #elif defined(__GNUC__) | ||
13 | inline | ||
14 | void GetTSC(unsigned long& tsc) | ||
15 | { | ||
16 | asm volatile(".byte 15, 49\n\t" | ||
17 | : "=eax" (tsc) | ||
18 | : | ||
19 | : "%edx", "%eax"); | ||
20 | } | ||
21 | #elif defined(_MSC_VER) | ||
22 | inline | ||
23 | void GetTSC(unsigned long& tsc) | ||
24 | { | ||
25 | unsigned long a; | ||
26 | __asm _emit 0fh | ||
27 | __asm _emit 31h | ||
28 | __asm mov a, eax; | ||
29 | tsc=a; | ||
30 | } | ||
31 | #endif | ||
32 | |||
33 | #include <stdio.h> | ||
34 | #include <stdlib.h> | ||
35 | #include "sha.h" | ||
36 | |||
37 | extern "C" { | ||
38 | void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num); | ||
39 | } | ||
40 | |||
41 | void main(int argc,char *argv[]) | ||
42 | { | ||
43 | unsigned char buffer[64*256]; | ||
44 | SHA_CTX ctx; | ||
45 | unsigned long s1,s2,e1,e2; | ||
46 | unsigned char k[16]; | ||
47 | unsigned long data[2]; | ||
48 | unsigned char iv[8]; | ||
49 | int i,num=0,numm; | ||
50 | int j=0; | ||
51 | |||
52 | if (argc >= 2) | ||
53 | num=atoi(argv[1]); | ||
54 | |||
55 | if (num == 0) num=16; | ||
56 | if (num > 250) num=16; | ||
57 | numm=num+2; | ||
58 | num*=64; | ||
59 | numm*=64; | ||
60 | |||
61 | for (j=0; j<6; j++) | ||
62 | { | ||
63 | for (i=0; i<10; i++) /**/ | ||
64 | { | ||
65 | sha1_block_x86(&ctx,buffer,numm); | ||
66 | GetTSC(s1); | ||
67 | sha1_block_x86(&ctx,buffer,numm); | ||
68 | GetTSC(e1); | ||
69 | GetTSC(s2); | ||
70 | sha1_block_x86(&ctx,buffer,num); | ||
71 | GetTSC(e2); | ||
72 | sha1_block_x86(&ctx,buffer,num); | ||
73 | } | ||
74 | |||
75 | printf("sha1 (%d bytes) %d %d (%.2f)\n",num, | ||
76 | e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); | ||
77 | } | ||
78 | } | ||
79 | |||