diff options
Diffstat (limited to 'src/lib/libcrypto/ripemd/asm')
-rw-r--r-- | src/lib/libcrypto/ripemd/asm/rips.cpp | 82 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/asm/rmd-586.pl | 4 |
2 files changed, 84 insertions, 2 deletions
diff --git a/src/lib/libcrypto/ripemd/asm/rips.cpp b/src/lib/libcrypto/ripemd/asm/rips.cpp new file mode 100644 index 0000000000..f7a13677a9 --- /dev/null +++ b/src/lib/libcrypto/ripemd/asm/rips.cpp | |||
@@ -0,0 +1,82 @@ | |||
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 <openssl/ripemd.h> | ||
36 | |||
37 | #define ripemd160_block_x86 ripemd160_block_asm_host_order | ||
38 | |||
39 | extern "C" { | ||
40 | void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num); | ||
41 | } | ||
42 | |||
43 | void main(int argc,char *argv[]) | ||
44 | { | ||
45 | unsigned char buffer[64*256]; | ||
46 | RIPEMD160_CTX ctx; | ||
47 | unsigned long s1,s2,e1,e2; | ||
48 | unsigned char k[16]; | ||
49 | unsigned long data[2]; | ||
50 | unsigned char iv[8]; | ||
51 | int i,num=0,numm; | ||
52 | int j=0; | ||
53 | |||
54 | if (argc >= 2) | ||
55 | num=atoi(argv[1]); | ||
56 | |||
57 | if (num == 0) num=16; | ||
58 | if (num > 250) num=16; | ||
59 | numm=num+2; | ||
60 | #if 0 | ||
61 | num*=64; | ||
62 | numm*=64; | ||
63 | #endif | ||
64 | |||
65 | for (j=0; j<6; j++) | ||
66 | { | ||
67 | for (i=0; i<10; i++) /**/ | ||
68 | { | ||
69 | ripemd160_block_x86(&ctx,buffer,numm); | ||
70 | GetTSC(s1); | ||
71 | ripemd160_block_x86(&ctx,buffer,numm); | ||
72 | GetTSC(e1); | ||
73 | GetTSC(s2); | ||
74 | ripemd160_block_x86(&ctx,buffer,num); | ||
75 | GetTSC(e2); | ||
76 | ripemd160_block_x86(&ctx,buffer,num); | ||
77 | } | ||
78 | printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num*64, | ||
79 | e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); | ||
80 | } | ||
81 | } | ||
82 | |||
diff --git a/src/lib/libcrypto/ripemd/asm/rmd-586.pl b/src/lib/libcrypto/ripemd/asm/rmd-586.pl index 4f3c4c967f..0ab6f76bff 100644 --- a/src/lib/libcrypto/ripemd/asm/rmd-586.pl +++ b/src/lib/libcrypto/ripemd/asm/rmd-586.pl | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/usr/local/bin/perl | 1 | #!/usr/local/bin/perl |
2 | 2 | ||
3 | # Normal is the | 3 | # Normal is the |
4 | # ripemd160_block_asm_data_order(RIPEMD160_CTX *c, ULONG *X,int blocks); | 4 | # ripemd160_block_asm_host_order(RIPEMD160_CTX *c, ULONG *X,int blocks); |
5 | 5 | ||
6 | $normal=0; | 6 | $normal=0; |
7 | 7 | ||
@@ -56,7 +56,7 @@ $KR3=0x7A6D76E9; | |||
56 | 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11, | 56 | 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11, |
57 | ); | 57 | ); |
58 | 58 | ||
59 | &ripemd160_block("ripemd160_block_asm_data_order"); | 59 | &ripemd160_block("ripemd160_block_asm_host_order"); |
60 | &asm_finish(); | 60 | &asm_finish(); |
61 | 61 | ||
62 | sub Xv | 62 | sub Xv |