summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md2
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/md2')
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl93
-rw-r--r--src/lib/libcrypto/md2/md2.h12
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c12
-rw-r--r--src/lib/libcrypto/md2/md2_one.c2
-rw-r--r--src/lib/libcrypto/md2/md2test.c6
5 files changed, 109 insertions, 16 deletions
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
new file mode 100644
index 0000000000..3206924c90
--- /dev/null
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -0,0 +1,93 @@
1#
2# SSLeay/crypto/md/Makefile
3#
4
5DIR= md2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=md2test.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=md2_dgst.c md2_one.c
27LIBOBJ=md2_dgst.o md2_one.o
28
29SRC= $(LIBSRC)
30
31EXHEADER= md2.h
32HEADER= $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
72
73dclean:
74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82md2_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
83md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
84md2_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
85md2_dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
86md2_dgst.o: md2_dgst.c
87md2_one.o: ../../e_os.h ../../include/openssl/bio.h
88md2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
89md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
90md2_one.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
91md2_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
92md2_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
93md2_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 a46120e7d4..d0ef9da08e 100644
--- a/src/lib/libcrypto/md2/md2.h
+++ b/src/lib/libcrypto/md2/md2.h
@@ -59,14 +59,13 @@
59#ifndef HEADER_MD2_H 59#ifndef HEADER_MD2_H
60#define HEADER_MD2_H 60#define HEADER_MD2_H
61 61
62#include <openssl/opensslconf.h> /* OPENSSL_NO_MD2, MD2_INT */
63#ifdef OPENSSL_NO_MD2 62#ifdef OPENSSL_NO_MD2
64#error MD2 is disabled. 63#error MD2 is disabled.
65#endif 64#endif
66#include <stddef.h>
67 65
68#define MD2_DIGEST_LENGTH 16 66#define MD2_DIGEST_LENGTH 16
69#define MD2_BLOCK 16 67#define MD2_BLOCK 16
68#include <openssl/opensslconf.h> /* MD2_INT */
70 69
71#ifdef __cplusplus 70#ifdef __cplusplus
72extern "C" { 71extern "C" {
@@ -74,17 +73,20 @@ extern "C" {
74 73
75typedef struct MD2state_st 74typedef struct MD2state_st
76 { 75 {
77 unsigned int num; 76 int num;
78 unsigned char data[MD2_BLOCK]; 77 unsigned char data[MD2_BLOCK];
79 MD2_INT cksm[MD2_BLOCK]; 78 MD2_INT cksm[MD2_BLOCK];
80 MD2_INT state[MD2_BLOCK]; 79 MD2_INT state[MD2_BLOCK];
81 } MD2_CTX; 80 } MD2_CTX;
82 81
83const char *MD2_options(void); 82const char *MD2_options(void);
83#ifdef OPENSSL_FIPS
84int private_MD2_Init(MD2_CTX *c);
85#endif
84int MD2_Init(MD2_CTX *c); 86int MD2_Init(MD2_CTX *c);
85int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); 87int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len);
86int MD2_Final(unsigned char *md, MD2_CTX *c); 88int MD2_Final(unsigned char *md, MD2_CTX *c);
87unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); 89unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md);
88#ifdef __cplusplus 90#ifdef __cplusplus
89} 91}
90#endif 92#endif
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index 6f68b25c6a..8124acd687 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -62,8 +62,10 @@
62#include <openssl/md2.h> 62#include <openssl/md2.h>
63#include <openssl/opensslv.h> 63#include <openssl/opensslv.h>
64#include <openssl/crypto.h> 64#include <openssl/crypto.h>
65#include <openssl/fips.h>
66#include <openssl/err.h>
65 67
66const char MD2_version[]="MD2" OPENSSL_VERSION_PTEXT; 68const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
67 69
68/* Implemented from RFC1319 The MD2 Message-Digest Algorithm 70/* Implemented from RFC1319 The MD2 Message-Digest Algorithm
69 */ 71 */
@@ -116,7 +118,7 @@ const char *MD2_options(void)
116 return("md2(int)"); 118 return("md2(int)");
117 } 119 }
118 120
119int MD2_Init(MD2_CTX *c) 121FIPS_NON_FIPS_MD_Init(MD2)
120 { 122 {
121 c->num=0; 123 c->num=0;
122 memset(c->state,0,sizeof c->state); 124 memset(c->state,0,sizeof c->state);
@@ -125,7 +127,7 @@ int MD2_Init(MD2_CTX *c)
125 return 1; 127 return 1;
126 } 128 }
127 129
128int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len) 130int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
129 { 131 {
130 register UCHAR *p; 132 register UCHAR *p;
131 133
@@ -145,7 +147,7 @@ int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len)
145 } 147 }
146 else 148 else
147 { 149 {
148 memcpy(&(p[c->num]),data,len); 150 memcpy(&(p[c->num]),data,(int)len);
149 /* data+=len; */ 151 /* data+=len; */
150 c->num+=(int)len; 152 c->num+=(int)len;
151 return 1; 153 return 1;
@@ -159,7 +161,7 @@ int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len)
159 data+=MD2_BLOCK; 161 data+=MD2_BLOCK;
160 len-=MD2_BLOCK; 162 len-=MD2_BLOCK;
161 } 163 }
162 memcpy(p,data,len); 164 memcpy(p,data,(int)len);
163 c->num=(int)len; 165 c->num=(int)len;
164 return 1; 166 return 1;
165 } 167 }
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c
index f7fef5cc0a..8c36ba5779 100644
--- a/src/lib/libcrypto/md2/md2_one.c
+++ b/src/lib/libcrypto/md2/md2_one.c
@@ -63,7 +63,7 @@
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
66unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md) 66unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md)
67 { 67 {
68 MD2_CTX c; 68 MD2_CTX c;
69 static unsigned char m[MD2_DIGEST_LENGTH]; 69 static unsigned char m[MD2_DIGEST_LENGTH];
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
index db5f5bc6d2..9c1e28b6ce 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -110,7 +110,7 @@ int main(int argc, char *argv[])
110 i=1; 110 i=1;
111 while (*P != NULL) 111 while (*P != NULL)
112 { 112 {
113 EVP_Digest((unsigned char *)*P,strlen(*P),md,NULL,EVP_md2(), NULL); 113 EVP_Digest((unsigned char *)*P,(unsigned long)strlen(*P),md,NULL,EVP_md2(), NULL);
114 p=pt(md); 114 p=pt(md);
115 if (strcmp(p,*R) != 0) 115 if (strcmp(p,*R) != 0)
116 { 116 {
@@ -124,11 +124,7 @@ int main(int argc, char *argv[])
124 R++; 124 R++;
125 P++; 125 P++;
126 } 126 }
127#ifdef OPENSSL_SYS_NETWARE
128 if (err) printf("ERROR: %d\n", err);
129#endif
130 EXIT(err); 127 EXIT(err);
131 return err;
132 } 128 }
133 129
134static char *pt(unsigned char *md) 130static char *pt(unsigned char *md)