summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md2
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/md2
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/md2')
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl40
-rw-r--r--src/lib/libcrypto/md2/md2.c20
-rw-r--r--src/lib/libcrypto/md2/md2.h (renamed from src/lib/libcrypto/md2/md2.org)29
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c28
-rw-r--r--src/lib/libcrypto/md2/md2_one.c23
-rw-r--r--src/lib/libcrypto/md2/md2test.c27
6 files changed, 77 insertions, 90 deletions
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
index d8e7200c83..67ce450788 100644
--- a/src/lib/libcrypto/md2/Makefile.ssl
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -7,9 +7,11 @@ TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= 8INCLUDES=
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
10INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl 14MAKEDEPEND= $(TOP)/util/domd $(TOP)
13MAKEFILE= Makefile.ssl 15MAKEFILE= Makefile.ssl
14AR= ar r 16AR= ar r
15 17
@@ -20,7 +22,7 @@ TEST=md2test.c
20APPS= 22APPS=
21 23
22LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
23LIBSRC=md2_dgst.c md5_one.c 25LIBSRC=md2_dgst.c md2_one.c
24LIBOBJ=md2_dgst.o md2_one.o 26LIBOBJ=md2_dgst.o md2_one.o
25 27
26SRC= $(LIBSRC) 28SRC= $(LIBSRC)
@@ -37,24 +39,23 @@ all: lib
37 39
38lib: $(LIBOBJ) 40lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ) 41 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB) 42 $(RANLIB) $(LIB)
41 @touch lib 43 @touch lib
42 44
43files: 45files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 46 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45 47
46links: 48links:
47 /bin/rm -f Makefile 49 @$(TOP)/util/point.sh Makefile.ssl Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ; 50 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER) 51 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
50 $(TOP)/util/mklink.sh ../../test $(TEST) 52 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52 53
53install: 54install:
54 @for i in $(EXHEADER) ; \ 55 @for i in $(EXHEADER) ; \
55 do \ 56 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \ 57 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \ 58 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
58 done; 59 done;
59 60
60tags: 61tags:
@@ -66,15 +67,22 @@ lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff 67 lint -DLINT $(INCLUDES) $(SRC)>fluff
67 68
68depend: 69depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) 70 $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
70 71
71dclean: 72dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 73 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE) 74 mv -f Makefile.new $(MAKEFILE)
74 75
75clean: 76clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 77 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79 78
80# DO NOT DELETE THIS LINE -- make depend depends on it. 79# DO NOT DELETE THIS LINE -- make depend depends on it.
80
81md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
82md2_dgst.o: ../../include/openssl/opensslv.h
83md2_one.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
84md2_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
85md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
86md2_one.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
87md2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h
88md2_one.o: ../cryptlib.h
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
66void do_fp(FILE *f); 65void do_fp(FILE *f);
67void pt(unsigned char *md); 66void pt(unsigned char *md);
68int read(int, void *, unsigned int); 67int read(int, void *, unsigned int);
69void exit(int); 68void exit(int);
70#else 69int main(int argc, char *argv[])
71void do_fp();
72void pt();
73int read();
74void exit();
75#endif
76
77int main(argc, argv)
78int argc;
79char *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
108void do_fp(f) 98void do_fp(FILE *f)
109FILE *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
128void pt(md) 117void pt(unsigned char *md)
129unsigned char *md;
130 { 118 {
131 int i; 119 int i;
132 120
diff --git a/src/lib/libcrypto/md2/md2.org b/src/lib/libcrypto/md2/md2.h
index 9f39933790..0d3592506c 100644
--- a/src/lib/libcrypto/md2/md2.org
+++ b/src/lib/libcrypto/md2/md2.h
@@ -1,4 +1,4 @@
1/* crypto/md/md2.org */ 1/* crypto/md/md2.h */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,15 +56,6 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify md2.org since md2.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67
68#ifndef HEADER_MD2_H 59#ifndef HEADER_MD2_H
69#define HEADER_MD2_H 60#define HEADER_MD2_H
70 61
@@ -72,10 +63,13 @@
72extern "C" { 63extern "C" {
73#endif 64#endif
74 65
66#ifdef NO_MD2
67#error MD2 is disabled.
68#endif
69
75#define MD2_DIGEST_LENGTH 16 70#define MD2_DIGEST_LENGTH 16
76#define MD2_BLOCK 16 71#define MD2_BLOCK 16
77 72#include <openssl/opensslconf.h> /* MD2_INT */
78#define MD2_INT unsigned int
79 73
80typedef struct MD2state_st 74typedef struct MD2state_st
81 { 75 {
@@ -85,20 +79,11 @@ typedef struct MD2state_st
85 MD2_INT state[MD2_BLOCK]; 79 MD2_INT state[MD2_BLOCK];
86 } MD2_CTX; 80 } MD2_CTX;
87 81
88#ifndef NOPROTO 82const char *MD2_options(void);
89char *MD2_options(void);
90void MD2_Init(MD2_CTX *c); 83void MD2_Init(MD2_CTX *c);
91void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len); 84void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len);
92void MD2_Final(unsigned char *md, MD2_CTX *c); 85void MD2_Final(unsigned char *md, MD2_CTX *c);
93unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md); 86unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md);
94#else
95char *MD2_options();
96void MD2_Init();
97void MD2_Update();
98void MD2_Final();
99unsigned char *MD2();
100#endif
101
102#ifdef __cplusplus 87#ifdef __cplusplus
103} 88}
104#endif 89#endif
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index 5cbd36f3fe..c7d8d6aef5 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -59,21 +59,17 @@
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
64char *MD2_version="MD2 part of SSLeay 0.9.0b 29-Jun-1998"; 65const 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
72static void md2_block(MD2_CTX *c, unsigned char *d); 72static void md2_block(MD2_CTX *c, unsigned char *d);
73#else
74static 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 * basicaly just a random byte string. */
79static MD2_INT S[256]={ 75static MD2_INT S[256]={
@@ -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
114char *MD2_options() 110const 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,8 +115,7 @@ char *MD2_options()
119 return("md2(int)"); 115 return("md2(int)");
120 } 116 }
121 117
122void MD2_Init(c) 118void MD2_Init(MD2_CTX *c)
123MD2_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));
@@ -128,10 +123,7 @@ MD2_CTX *c;
128 memset(c->data,0,MD2_BLOCK); 123 memset(c->data,0,MD2_BLOCK);
129 } 124 }
130 125
131void MD2_Update(c, data, len) 126void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len)
132MD2_CTX *c;
133register unsigned char *data;
134unsigned long len;
135 { 127 {
136 register UCHAR *p; 128 register UCHAR *p;
137 129
@@ -169,9 +161,7 @@ unsigned long len;
169 c->num=(int)len; 161 c->num=(int)len;
170 } 162 }
171 163
172static void md2_block(c, d) 164static void md2_block(MD2_CTX *c, unsigned char *d)
173MD2_CTX *c;
174unsigned char *d;
175 { 165 {
176 register MD2_INT t,*sp1,*sp2; 166 register MD2_INT t,*sp1,*sp2;
177 register int i,j; 167 register int i,j;
@@ -207,9 +197,7 @@ unsigned char *d;
207 memset(state,0,48*sizeof(MD2_INT)); 197 memset(state,0,48*sizeof(MD2_INT));
208 } 198 }
209 199
210void MD2_Final(md, c) 200void MD2_Final(unsigned char *md, MD2_CTX *c)
211unsigned char *md;
212MD2_CTX *c;
213 { 201 {
214 int i,v; 202 int i,v;
215 register UCHAR *cp; 203 register UCHAR *cp;
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c
index 513bf62fdb..7157299d95 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
66unsigned char *MD2(d, n, md) 66unsigned char *MD2(unsigned char *d, unsigned long n, unsigned char *md)
67unsigned char *d;
68unsigned long n;
69unsigned 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..461d124957 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -59,7 +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
63#ifdef NO_MD2
64int main(int argc, char *argv[])
65{
66 printf("No MD2 support\n");
67 return(0);
68}
69#else
70#include <openssl/md2.h>
71
72#ifdef CHARSET_EBCDIC
73#include <openssl/ebcdic.h>
74#endif
63 75
64char *test[]={ 76char *test[]={
65 "", 77 "",
@@ -82,15 +94,8 @@ char *ret[]={
82 "d5976f79d83d3a0dc9806c3c66f3efd8", 94 "d5976f79d83d3a0dc9806c3c66f3efd8",
83 }; 95 };
84 96
85#ifndef NOPROTO
86static char *pt(unsigned char *md); 97static char *pt(unsigned char *md);
87#else 98int main(int argc, char *argv[])
88static char *pt();
89#endif
90
91int main(argc,argv)
92int argc;
93char *argv[];
94 { 99 {
95 int i,err=0; 100 int i,err=0;
96 char **P,**R; 101 char **P,**R;
@@ -118,8 +123,7 @@ char *argv[];
118 return(0); 123 return(0);
119 } 124 }
120 125
121static char *pt(md) 126static char *pt(unsigned char *md)
122unsigned char *md;
123 { 127 {
124 int i; 128 int i;
125 static char buf[80]; 129 static char buf[80];
@@ -128,3 +132,4 @@ unsigned char *md;
128 sprintf(&(buf[i*2]),"%02x",md[i]); 132 sprintf(&(buf[i*2]),"%02x",md[i]);
129 return(buf); 133 return(buf);
130 } 134 }
135#endif