diff options
Diffstat (limited to 'src/lib/libcrypto/ripemd/rmdtest.c')
-rw-r--r-- | src/lib/libcrypto/ripemd/rmdtest.c | 40 |
1 files changed, 25 insertions, 15 deletions
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 | ||
64 | char *test[]={ | 64 | #ifdef OPENSSL_NO_RIPEMD |
65 | int 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 | |||
77 | static 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 | ||
76 | char *ret[]={ | 89 | static 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 | ||
88 | static char *pt(unsigned char *md); | 100 | static char *pt(unsigned char *md); |
89 | #else | 101 | int main(int argc, char *argv[]) |
90 | static char *pt(); | ||
91 | #endif | ||
92 | |||
93 | int main(argc,argv) | ||
94 | int argc; | ||
95 | char *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 | ||
123 | static char *pt(md) | 134 | static char *pt(unsigned char *md) |
124 | unsigned 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 | |