summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md2
diff options
context:
space:
mode:
authorbeck <>2002-05-15 02:29:21 +0000
committerbeck <>2002-05-15 02:29:21 +0000
commitb64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch)
treefa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/md2
parente471e1ea98d673597b182ea85f29e30c97cd08b5 (diff)
downloadopenbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/md2')
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl16
-rw-r--r--src/lib/libcrypto/md2/md2.h8
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c13
-rw-r--r--src/lib/libcrypto/md2/md2test.c9
4 files changed, 26 insertions, 20 deletions
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
index 269628d739..05a77ae4a5 100644
--- a/src/lib/libcrypto/md2/Makefile.ssl
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -2,7 +2,7 @@
2# SSLeay/crypto/md/Makefile 2# SSLeay/crypto/md/Makefile
3# 3#
4 4
5DIR= md 5DIR= md2
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= 8INCLUDES=
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -80,11 +80,11 @@ clean:
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h 82md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
83md2_dgst.o: ../../include/openssl/opensslv.h 83md2_dgst.o: ../../include/openssl/opensslv.h md2_dgst.c
84md2_one.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 84md2_one.o: ../../e_os.h ../../include/openssl/bio.h
85md2_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 85md2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
86md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 86md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
87md2_one.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 87md2_one.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
88md2_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 88md2_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
89md2_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 89md2_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90md2_one.o: ../../include/openssl/symhacks.h ../cryptlib.h 90md2_one.o: ../../include/openssl/symhacks.h ../cryptlib.h md2_one.c
diff --git a/src/lib/libcrypto/md2/md2.h b/src/lib/libcrypto/md2/md2.h
index a00bd162b3..ad9241455c 100644
--- a/src/lib/libcrypto/md2/md2.h
+++ b/src/lib/libcrypto/md2/md2.h
@@ -59,7 +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 NO_MD2 62#ifdef OPENSSL_NO_MD2
63#error MD2 is disabled. 63#error MD2 is disabled.
64#endif 64#endif
65 65
@@ -80,9 +80,9 @@ typedef struct MD2state_st
80 } MD2_CTX; 80 } MD2_CTX;
81 81
82const char *MD2_options(void); 82const char *MD2_options(void);
83void MD2_Init(MD2_CTX *c); 83int MD2_Init(MD2_CTX *c);
84void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len); 84int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len);
85void MD2_Final(unsigned char *md, MD2_CTX *c); 85int MD2_Final(unsigned char *md, MD2_CTX *c);
86unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md); 86unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md);
87#ifdef __cplusplus 87#ifdef __cplusplus
88} 88}
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index 608baefa8f..e25dd00e02 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -115,19 +115,20 @@ const char *MD2_options(void)
115 return("md2(int)"); 115 return("md2(int)");
116 } 116 }
117 117
118void MD2_Init(MD2_CTX *c) 118int MD2_Init(MD2_CTX *c)
119 { 119 {
120 c->num=0; 120 c->num=0;
121 memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT)); 121 memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT));
122 memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT)); 122 memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT));
123 memset(c->data,0,MD2_BLOCK); 123 memset(c->data,0,MD2_BLOCK);
124 return 1;
124 } 125 }
125 126
126void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len) 127int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
127 { 128 {
128 register UCHAR *p; 129 register UCHAR *p;
129 130
130 if (len == 0) return; 131 if (len == 0) return 1;
131 132
132 p=c->data; 133 p=c->data;
133 if (c->num != 0) 134 if (c->num != 0)
@@ -146,7 +147,7 @@ void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
146 memcpy(&(p[c->num]),data,(int)len); 147 memcpy(&(p[c->num]),data,(int)len);
147 /* data+=len; */ 148 /* data+=len; */
148 c->num+=(int)len; 149 c->num+=(int)len;
149 return; 150 return 1;
150 } 151 }
151 } 152 }
152 /* 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
@@ -159,6 +160,7 @@ void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
159 } 160 }
160 memcpy(p,data,(int)len); 161 memcpy(p,data,(int)len);
161 c->num=(int)len; 162 c->num=(int)len;
163 return 1;
162 } 164 }
163 165
164static void md2_block(MD2_CTX *c, const unsigned char *d) 166static void md2_block(MD2_CTX *c, const unsigned char *d)
@@ -197,7 +199,7 @@ static void md2_block(MD2_CTX *c, const unsigned char *d)
197 memset(state,0,48*sizeof(MD2_INT)); 199 memset(state,0,48*sizeof(MD2_INT));
198 } 200 }
199 201
200void MD2_Final(unsigned char *md, MD2_CTX *c) 202int MD2_Final(unsigned char *md, MD2_CTX *c)
201 { 203 {
202 int i,v; 204 int i,v;
203 register UCHAR *cp; 205 register UCHAR *cp;
@@ -219,5 +221,6 @@ void MD2_Final(unsigned char *md, MD2_CTX *c)
219 for (i=0; i<16; i++) 221 for (i=0; i<16; i++)
220 md[i]=(UCHAR)(p1[i]&0xff); 222 md[i]=(UCHAR)(p1[i]&0xff);
221 memset((char *)&c,0,sizeof(c)); 223 memset((char *)&c,0,sizeof(c));
224 return 1;
222 } 225 }
223 226
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
index e3f4fb4c34..7d3664faf5 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -59,15 +59,16 @@
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 <openssl/md2.h>
62 63
63#ifdef NO_MD2 64#ifdef OPENSSL_NO_MD2
64int main(int argc, char *argv[]) 65int main(int argc, char *argv[])
65{ 66{
66 printf("No MD2 support\n"); 67 printf("No MD2 support\n");
67 return(0); 68 return(0);
68} 69}
69#else 70#else
70#include <openssl/md2.h> 71#include <openssl/evp.h>
71 72
72#ifdef CHARSET_EBCDIC 73#ifdef CHARSET_EBCDIC
73#include <openssl/ebcdic.h> 74#include <openssl/ebcdic.h>
@@ -100,13 +101,15 @@ int main(int argc, char *argv[])
100 int i,err=0; 101 int i,err=0;
101 char **P,**R; 102 char **P,**R;
102 char *p; 103 char *p;
104 unsigned char md[MD2_DIGEST_LENGTH];
103 105
104 P=test; 106 P=test;
105 R=ret; 107 R=ret;
106 i=1; 108 i=1;
107 while (*P != NULL) 109 while (*P != NULL)
108 { 110 {
109 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);
110 if (strcmp(p,*R) != 0) 113 if (strcmp(p,*R) != 0)
111 { 114 {
112 printf("error calculating MD2 on '%s'\n",*P); 115 printf("error calculating MD2 on '%s'\n",*P);