summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ripemd
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:52 +0000
committermarkus <>2002-09-05 12:51:52 +0000
commit5514995a9d5ed91db089875adb509c7781357c0e (patch)
tree2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/ripemd
parentfd9566423b542798f5c8b06e68101a9ea5bb9885 (diff)
downloadopenbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz
openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2
openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/ripemd')
-rw-r--r--src/lib/libcrypto/ripemd/asm/rips.cpp8
-rw-r--r--src/lib/libcrypto/ripemd/rmd160.c18
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c40
3 files changed, 36 insertions, 30 deletions
diff --git a/src/lib/libcrypto/ripemd/asm/rips.cpp b/src/lib/libcrypto/ripemd/asm/rips.cpp
index 78a933c448..f7a13677a9 100644
--- a/src/lib/libcrypto/ripemd/asm/rips.cpp
+++ b/src/lib/libcrypto/ripemd/asm/rips.cpp
@@ -32,7 +32,9 @@ void GetTSC(unsigned long& tsc)
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include "ripemd.h" 35#include <openssl/ripemd.h>
36
37#define ripemd160_block_x86 ripemd160_block_asm_host_order
36 38
37extern "C" { 39extern "C" {
38void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num); 40void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num);
@@ -55,8 +57,10 @@ void main(int argc,char *argv[])
55 if (num == 0) num=16; 57 if (num == 0) num=16;
56 if (num > 250) num=16; 58 if (num > 250) num=16;
57 numm=num+2; 59 numm=num+2;
60#if 0
58 num*=64; 61 num*=64;
59 numm*=64; 62 numm*=64;
63#endif
60 64
61 for (j=0; j<6; j++) 65 for (j=0; j<6; j++)
62 { 66 {
@@ -71,7 +75,7 @@ void main(int argc,char *argv[])
71 GetTSC(e2); 75 GetTSC(e2);
72 ripemd160_block_x86(&ctx,buffer,num); 76 ripemd160_block_x86(&ctx,buffer,num);
73 } 77 }
74 printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num, 78 printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num*64,
75 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); 79 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
76 } 80 }
77 } 81 }
diff --git a/src/lib/libcrypto/ripemd/rmd160.c b/src/lib/libcrypto/ripemd/rmd160.c
index 3fa1b8096e..4f8b88a18a 100644
--- a/src/lib/libcrypto/ripemd/rmd160.c
+++ b/src/lib/libcrypto/ripemd/rmd160.c
@@ -58,23 +58,17 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include "ripemd.h" 61#include <openssl/ripemd.h>
62 62
63#define BUFSIZE 1024*16 63#define BUFSIZE 1024*16
64 64
65#ifndef NOPROTO
66void do_fp(FILE *f); 65void do_fp(FILE *f);
67void pt(unsigned char *md); 66void pt(unsigned char *md);
67#ifndef _OSD_POSIX
68int read(int, void *, unsigned int); 68int read(int, void *, unsigned int);
69#else
70void do_fp();
71void pt();
72int read();
73#endif 69#endif
74 70
75int main(argc, argv) 71int main(int argc, char **argv)
76int argc;
77char **argv;
78 { 72 {
79 int i,err=0; 73 int i,err=0;
80 FILE *IN; 74 FILE *IN;
@@ -102,8 +96,7 @@ char **argv;
102 exit(err); 96 exit(err);
103 } 97 }
104 98
105void do_fp(f) 99void do_fp(FILE *f)
106FILE *f;
107 { 100 {
108 RIPEMD160_CTX c; 101 RIPEMD160_CTX c;
109 unsigned char md[RIPEMD160_DIGEST_LENGTH]; 102 unsigned char md[RIPEMD160_DIGEST_LENGTH];
@@ -123,8 +116,7 @@ FILE *f;
123 pt(md); 116 pt(md);
124 } 117 }
125 118
126void pt(md) 119void pt(unsigned char *md)
127unsigned char *md;
128 { 120 {
129 int i; 121 int i;
130 122
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c
index 6a0297f975..19e9741db2 100644
--- a/src/lib/libcrypto/ripemd/rmdtest.c
+++ b/src/lib/libcrypto/ripemd/rmdtest.c
@@ -59,9 +59,22 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62#include "ripemd.h" 62#include <openssl/ripemd.h>
63 63
64char *test[]={ 64#ifdef OPENSSL_NO_RIPEMD
65int main(int argc, char *argv[])
66{
67 printf("No ripemd support\n");
68 return(0);
69}
70#else
71#include <openssl/evp.h>
72
73#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h>
75#endif
76
77static char *test[]={
65 "", 78 "",
66 "a", 79 "a",
67 "abc", 80 "abc",
@@ -73,7 +86,7 @@ char *test[]={
73 NULL, 86 NULL,
74 }; 87 };
75 88
76char *ret[]={ 89static char *ret[]={
77 "9c1185a5c5e9fc54612808977ee8f548b2258d31", 90 "9c1185a5c5e9fc54612808977ee8f548b2258d31",
78 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", 91 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",
79 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", 92 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
@@ -84,26 +97,24 @@ char *ret[]={
84 "9b752e45573d4b39f4dbd3323cab82bf63326bfb", 97 "9b752e45573d4b39f4dbd3323cab82bf63326bfb",
85 }; 98 };
86 99
87#ifndef NOPROTO
88static char *pt(unsigned char *md); 100static char *pt(unsigned char *md);
89#else 101int main(int argc, char *argv[])
90static char *pt();
91#endif
92
93int main(argc,argv)
94int argc;
95char *argv[];
96 { 102 {
97 int i,err=0; 103 int i,err=0;
98 unsigned char **P,**R; 104 unsigned char **P,**R;
99 char *p; 105 char *p;
106 unsigned char md[RIPEMD160_DIGEST_LENGTH];
100 107
101 P=(unsigned char **)test; 108 P=(unsigned char **)test;
102 R=(unsigned char **)ret; 109 R=(unsigned char **)ret;
103 i=1; 110 i=1;
104 while (*P != NULL) 111 while (*P != NULL)
105 { 112 {
106 p=pt(RIPEMD160(&(P[0][0]),(unsigned long)strlen((char *)*P),NULL)); 113#ifdef CHARSET_EBCDIC
114 ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P));
115#endif
116 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL);
117 p=pt(md);
107 if (strcmp(p,(char *)*R) != 0) 118 if (strcmp(p,(char *)*R) != 0)
108 { 119 {
109 printf("error calculating RIPEMD160 on '%s'\n",*P); 120 printf("error calculating RIPEMD160 on '%s'\n",*P);
@@ -120,8 +131,7 @@ char *argv[];
120 return(0); 131 return(0);
121 } 132 }
122 133
123static char *pt(md) 134static char *pt(unsigned char *md)
124unsigned char *md;
125 { 135 {
126 int i; 136 int i;
127 static char buf[80]; 137 static char buf[80];
@@ -130,4 +140,4 @@ unsigned char *md;
130 sprintf(&(buf[i*2]),"%02x",md[i]); 140 sprintf(&(buf[i*2]),"%02x",md[i]);
131 return(buf); 141 return(buf);
132 } 142 }
133 143#endif