diff options
Diffstat (limited to 'src/lib/libcrypto/md2/md2test.c')
-rw-r--r-- | src/lib/libcrypto/md2/md2test.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c index 55924d44cd..7d3664faf5 100644 --- a/src/lib/libcrypto/md2/md2test.c +++ b/src/lib/libcrypto/md2/md2test.c | |||
@@ -59,9 +59,22 @@ | |||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include "md2.h" | 62 | #include <openssl/md2.h> |
63 | 63 | ||
64 | char *test[]={ | 64 | #ifdef OPENSSL_NO_MD2 |
65 | int main(int argc, char *argv[]) | ||
66 | { | ||
67 | printf("No MD2 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", |
@@ -72,7 +85,7 @@ char *test[]={ | |||
72 | NULL, | 85 | NULL, |
73 | }; | 86 | }; |
74 | 87 | ||
75 | char *ret[]={ | 88 | static char *ret[]={ |
76 | "8350e5a3e24c153df2275c9f80692773", | 89 | "8350e5a3e24c153df2275c9f80692773", |
77 | "32ec01ec4a6dac72c0ab96fb34c0b5d1", | 90 | "32ec01ec4a6dac72c0ab96fb34c0b5d1", |
78 | "da853b0d3f88d99b30283a69e6ded6bb", | 91 | "da853b0d3f88d99b30283a69e6ded6bb", |
@@ -82,26 +95,21 @@ char *ret[]={ | |||
82 | "d5976f79d83d3a0dc9806c3c66f3efd8", | 95 | "d5976f79d83d3a0dc9806c3c66f3efd8", |
83 | }; | 96 | }; |
84 | 97 | ||
85 | #ifndef NOPROTO | ||
86 | static char *pt(unsigned char *md); | 98 | static char *pt(unsigned char *md); |
87 | #else | 99 | int main(int argc, char *argv[]) |
88 | static char *pt(); | ||
89 | #endif | ||
90 | |||
91 | int main(argc,argv) | ||
92 | int argc; | ||
93 | char *argv[]; | ||
94 | { | 100 | { |
95 | int i,err=0; | 101 | int i,err=0; |
96 | char **P,**R; | 102 | char **P,**R; |
97 | char *p; | 103 | char *p; |
104 | unsigned char md[MD2_DIGEST_LENGTH]; | ||
98 | 105 | ||
99 | P=test; | 106 | P=test; |
100 | R=ret; | 107 | R=ret; |
101 | i=1; | 108 | i=1; |
102 | while (*P != NULL) | 109 | while (*P != NULL) |
103 | { | 110 | { |
104 | p=pt(MD2((unsigned char *)*P,(unsigned long)strlen(*P),NULL)); | 111 | EVP_Digest((unsigned char *)*P,(unsigned long)strlen(*P),md,NULL,EVP_md2(), NULL); |
112 | p=pt(md); | ||
105 | if (strcmp(p,*R) != 0) | 113 | if (strcmp(p,*R) != 0) |
106 | { | 114 | { |
107 | printf("error calculating MD2 on '%s'\n",*P); | 115 | printf("error calculating MD2 on '%s'\n",*P); |
@@ -118,8 +126,7 @@ char *argv[]; | |||
118 | return(0); | 126 | return(0); |
119 | } | 127 | } |
120 | 128 | ||
121 | static char *pt(md) | 129 | static char *pt(unsigned char *md) |
122 | unsigned char *md; | ||
123 | { | 130 | { |
124 | int i; | 131 | int i; |
125 | static char buf[80]; | 132 | static char buf[80]; |
@@ -128,3 +135,4 @@ unsigned char *md; | |||
128 | sprintf(&(buf[i*2]),"%02x",md[i]); | 135 | sprintf(&(buf[i*2]),"%02x",md[i]); |
129 | return(buf); | 136 | return(buf); |
130 | } | 137 | } |
138 | #endif | ||