diff options
Diffstat (limited to 'src/lib/libcrypto/md2')
-rw-r--r-- | src/lib/libcrypto/md2/md2.c | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/md2/md2.h | 18 | ||||
-rw-r--r-- | src/lib/libcrypto/md2/md2_dgst.c | 39 | ||||
-rw-r--r-- | src/lib/libcrypto/md2/md2_one.c | 23 | ||||
-rw-r--r-- | src/lib/libcrypto/md2/md2test.c | 36 |
5 files changed, 68 insertions, 68 deletions
diff --git a/src/lib/libcrypto/md2/md2.c b/src/lib/libcrypto/md2/md2.c index 7f3ab64a43..f4d6f62264 100644 --- a/src/lib/libcrypto/md2/md2.c +++ b/src/lib/libcrypto/md2/md2.c | |||
@@ -58,25 +58,15 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include "md2.h" | 61 | #include <openssl/md2.h> |
62 | 62 | ||
63 | #define BUFSIZE 1024*16 | 63 | #define BUFSIZE 1024*16 |
64 | 64 | ||
65 | #ifndef NOPROTO | ||
66 | void do_fp(FILE *f); | 65 | void do_fp(FILE *f); |
67 | void pt(unsigned char *md); | 66 | void pt(unsigned char *md); |
68 | int read(int, void *, unsigned int); | 67 | int read(int, void *, unsigned int); |
69 | void exit(int); | 68 | void exit(int); |
70 | #else | 69 | int main(int argc, char *argv[]) |
71 | void do_fp(); | ||
72 | void pt(); | ||
73 | int read(); | ||
74 | void exit(); | ||
75 | #endif | ||
76 | |||
77 | int main(argc, argv) | ||
78 | int argc; | ||
79 | char *argv[]; | ||
80 | { | 70 | { |
81 | int i,err=0; | 71 | int i,err=0; |
82 | FILE *IN; | 72 | FILE *IN; |
@@ -105,8 +95,7 @@ char *argv[]; | |||
105 | return(err); | 95 | return(err); |
106 | } | 96 | } |
107 | 97 | ||
108 | void do_fp(f) | 98 | void do_fp(FILE *f) |
109 | FILE *f; | ||
110 | { | 99 | { |
111 | MD2_CTX c; | 100 | MD2_CTX c; |
112 | unsigned char md[MD2_DIGEST_LENGTH]; | 101 | unsigned char md[MD2_DIGEST_LENGTH]; |
@@ -125,8 +114,7 @@ FILE *f; | |||
125 | pt(md); | 114 | pt(md); |
126 | } | 115 | } |
127 | 116 | ||
128 | void pt(md) | 117 | void pt(unsigned char *md) |
129 | unsigned char *md; | ||
130 | { | 118 | { |
131 | int i; | 119 | int i; |
132 | 120 | ||
diff --git a/src/lib/libcrypto/md2/md2.h b/src/lib/libcrypto/md2/md2.h index 0d3592506c..ad9241455c 100644 --- a/src/lib/libcrypto/md2/md2.h +++ b/src/lib/libcrypto/md2/md2.h | |||
@@ -59,11 +59,7 @@ | |||
59 | #ifndef HEADER_MD2_H | 59 | #ifndef HEADER_MD2_H |
60 | #define HEADER_MD2_H | 60 | #define HEADER_MD2_H |
61 | 61 | ||
62 | #ifdef __cplusplus | 62 | #ifdef OPENSSL_NO_MD2 |
63 | extern "C" { | ||
64 | #endif | ||
65 | |||
66 | #ifdef NO_MD2 | ||
67 | #error MD2 is disabled. | 63 | #error MD2 is disabled. |
68 | #endif | 64 | #endif |
69 | 65 | ||
@@ -71,6 +67,10 @@ extern "C" { | |||
71 | #define MD2_BLOCK 16 | 67 | #define MD2_BLOCK 16 |
72 | #include <openssl/opensslconf.h> /* MD2_INT */ | 68 | #include <openssl/opensslconf.h> /* MD2_INT */ |
73 | 69 | ||
70 | #ifdef __cplusplus | ||
71 | extern "C" { | ||
72 | #endif | ||
73 | |||
74 | typedef struct MD2state_st | 74 | typedef struct MD2state_st |
75 | { | 75 | { |
76 | int num; | 76 | int num; |
@@ -80,10 +80,10 @@ typedef struct MD2state_st | |||
80 | } MD2_CTX; | 80 | } MD2_CTX; |
81 | 81 | ||
82 | const char *MD2_options(void); | 82 | const char *MD2_options(void); |
83 | void MD2_Init(MD2_CTX *c); | 83 | int MD2_Init(MD2_CTX *c); |
84 | void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len); | 84 | int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len); |
85 | void MD2_Final(unsigned char *md, MD2_CTX *c); | 85 | int MD2_Final(unsigned char *md, MD2_CTX *c); |
86 | unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md); | 86 | unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md); |
87 | #ifdef __cplusplus | 87 | #ifdef __cplusplus |
88 | } | 88 | } |
89 | #endif | 89 | #endif |
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c index 5cbd36f3fe..e25dd00e02 100644 --- a/src/lib/libcrypto/md2/md2_dgst.c +++ b/src/lib/libcrypto/md2/md2_dgst.c | |||
@@ -59,23 +59,19 @@ | |||
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 | #include <openssl/opensslv.h> | ||
63 | 64 | ||
64 | char *MD2_version="MD2 part of SSLeay 0.9.0b 29-Jun-1998"; | 65 | const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT; |
65 | 66 | ||
66 | /* Implemented from RFC1319 The MD2 Message-Digest Algorithm | 67 | /* Implemented from RFC1319 The MD2 Message-Digest Algorithm |
67 | */ | 68 | */ |
68 | 69 | ||
69 | #define UCHAR unsigned char | 70 | #define UCHAR unsigned char |
70 | 71 | ||
71 | #ifndef NOPROTO | 72 | static void md2_block(MD2_CTX *c, const unsigned char *d); |
72 | static void md2_block(MD2_CTX *c, unsigned char *d); | ||
73 | #else | ||
74 | static void md2_block(); | ||
75 | #endif | ||
76 | |||
77 | /* The magic S table - I have converted it to hex since it is | 73 | /* The magic S table - I have converted it to hex since it is |
78 | * basicaly just a random byte string. */ | 74 | * basically just a random byte string. */ |
79 | static MD2_INT S[256]={ | 75 | static MD2_INT S[256]={ |
80 | 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, | 76 | 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, |
81 | 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, | 77 | 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, |
@@ -111,7 +107,7 @@ static MD2_INT S[256]={ | |||
111 | 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14, | 107 | 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14, |
112 | }; | 108 | }; |
113 | 109 | ||
114 | char *MD2_options() | 110 | const char *MD2_options(void) |
115 | { | 111 | { |
116 | if (sizeof(MD2_INT) == 1) | 112 | if (sizeof(MD2_INT) == 1) |
117 | return("md2(char)"); | 113 | return("md2(char)"); |
@@ -119,23 +115,20 @@ char *MD2_options() | |||
119 | return("md2(int)"); | 115 | return("md2(int)"); |
120 | } | 116 | } |
121 | 117 | ||
122 | void MD2_Init(c) | 118 | int MD2_Init(MD2_CTX *c) |
123 | MD2_CTX *c; | ||
124 | { | 119 | { |
125 | c->num=0; | 120 | c->num=0; |
126 | memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT)); | 121 | memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT)); |
127 | memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT)); | 122 | memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT)); |
128 | memset(c->data,0,MD2_BLOCK); | 123 | memset(c->data,0,MD2_BLOCK); |
124 | return 1; | ||
129 | } | 125 | } |
130 | 126 | ||
131 | void MD2_Update(c, data, len) | 127 | int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len) |
132 | MD2_CTX *c; | ||
133 | register unsigned char *data; | ||
134 | unsigned long len; | ||
135 | { | 128 | { |
136 | register UCHAR *p; | 129 | register UCHAR *p; |
137 | 130 | ||
138 | if (len == 0) return; | 131 | if (len == 0) return 1; |
139 | 132 | ||
140 | p=c->data; | 133 | p=c->data; |
141 | if (c->num != 0) | 134 | if (c->num != 0) |
@@ -154,7 +147,7 @@ unsigned long len; | |||
154 | memcpy(&(p[c->num]),data,(int)len); | 147 | memcpy(&(p[c->num]),data,(int)len); |
155 | /* data+=len; */ | 148 | /* data+=len; */ |
156 | c->num+=(int)len; | 149 | c->num+=(int)len; |
157 | return; | 150 | return 1; |
158 | } | 151 | } |
159 | } | 152 | } |
160 | /* we now can process the input data in blocks of MD2_BLOCK | 153 | /* we now can process the input data in blocks of MD2_BLOCK |
@@ -167,11 +160,10 @@ unsigned long len; | |||
167 | } | 160 | } |
168 | memcpy(p,data,(int)len); | 161 | memcpy(p,data,(int)len); |
169 | c->num=(int)len; | 162 | c->num=(int)len; |
163 | return 1; | ||
170 | } | 164 | } |
171 | 165 | ||
172 | static void md2_block(c, d) | 166 | static void md2_block(MD2_CTX *c, const unsigned char *d) |
173 | MD2_CTX *c; | ||
174 | unsigned char *d; | ||
175 | { | 167 | { |
176 | register MD2_INT t,*sp1,*sp2; | 168 | register MD2_INT t,*sp1,*sp2; |
177 | register int i,j; | 169 | register int i,j; |
@@ -207,9 +199,7 @@ unsigned char *d; | |||
207 | memset(state,0,48*sizeof(MD2_INT)); | 199 | memset(state,0,48*sizeof(MD2_INT)); |
208 | } | 200 | } |
209 | 201 | ||
210 | void MD2_Final(md, c) | 202 | int MD2_Final(unsigned char *md, MD2_CTX *c) |
211 | unsigned char *md; | ||
212 | MD2_CTX *c; | ||
213 | { | 203 | { |
214 | int i,v; | 204 | int i,v; |
215 | register UCHAR *cp; | 205 | register UCHAR *cp; |
@@ -231,5 +221,6 @@ MD2_CTX *c; | |||
231 | for (i=0; i<16; i++) | 221 | for (i=0; i<16; i++) |
232 | md[i]=(UCHAR)(p1[i]&0xff); | 222 | md[i]=(UCHAR)(p1[i]&0xff); |
233 | memset((char *)&c,0,sizeof(c)); | 223 | memset((char *)&c,0,sizeof(c)); |
224 | return 1; | ||
234 | } | 225 | } |
235 | 226 | ||
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c index 513bf62fdb..b12c37ce4d 100644 --- a/src/lib/libcrypto/md2/md2_one.c +++ b/src/lib/libcrypto/md2/md2_one.c | |||
@@ -58,22 +58,35 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "md2.h" | 61 | #include <openssl/md2.h> |
62 | 62 | ||
63 | /* This is a separate file so that #defines in cryptlib.h can | 63 | /* This is a separate file so that #defines in cryptlib.h can |
64 | * map my MD functions to different names */ | 64 | * map my MD functions to different names */ |
65 | 65 | ||
66 | unsigned char *MD2(d, n, md) | 66 | unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md) |
67 | unsigned char *d; | ||
68 | unsigned long n; | ||
69 | unsigned char *md; | ||
70 | { | 67 | { |
71 | MD2_CTX c; | 68 | MD2_CTX c; |
72 | static unsigned char m[MD2_DIGEST_LENGTH]; | 69 | static unsigned char m[MD2_DIGEST_LENGTH]; |
73 | 70 | ||
74 | if (md == NULL) md=m; | 71 | if (md == NULL) md=m; |
75 | MD2_Init(&c); | 72 | MD2_Init(&c); |
73 | #ifndef CHARSET_EBCDIC | ||
76 | MD2_Update(&c,d,n); | 74 | MD2_Update(&c,d,n); |
75 | #else | ||
76 | { | ||
77 | char temp[1024]; | ||
78 | unsigned long chunk; | ||
79 | |||
80 | while (n > 0) | ||
81 | { | ||
82 | chunk = (n > sizeof(temp)) ? sizeof(temp) : n; | ||
83 | ebcdic2ascii(temp, d, chunk); | ||
84 | MD2_Update(&c,temp,chunk); | ||
85 | n -= chunk; | ||
86 | d += chunk; | ||
87 | } | ||
88 | } | ||
89 | #endif | ||
77 | MD2_Final(md,&c); | 90 | MD2_Final(md,&c); |
78 | memset(&c,0,sizeof(c)); /* Security consideration */ | 91 | memset(&c,0,sizeof(c)); /* Security consideration */ |
79 | return(md); | 92 | return(md); |
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 | ||