From aad1d64cb5a8d9b503d9199642363dc1e92d2f9b Mon Sep 17 00:00:00 2001 From: markm Date: Tue, 28 Jan 2003 21:43:22 +0000 Subject: Vendor import of OpenSSL release 0.9.7. This release includes support for AES and OpenBSD's hardware crypto. --- crypto/openssl/crypto/mdc2/Makefile.ssl | 29 ++++++++++++++++++----------- crypto/openssl/crypto/mdc2/mdc2.h | 10 +++++----- crypto/openssl/crypto/mdc2/mdc2_one.c | 2 +- crypto/openssl/crypto/mdc2/mdc2dgst.c | 25 ++++++++++++++----------- crypto/openssl/crypto/mdc2/mdc2test.c | 30 ++++++++++++++++++------------ 5 files changed, 56 insertions(+), 40 deletions(-) (limited to 'crypto/openssl/crypto/mdc2') diff --git a/crypto/openssl/crypto/mdc2/Makefile.ssl b/crypto/openssl/crypto/mdc2/Makefile.ssl index 4b1b3e3..387d7f8 100644 --- a/crypto/openssl/crypto/mdc2/Makefile.ssl +++ b/crypto/openssl/crypto/mdc2/Makefile.ssl @@ -11,7 +11,8 @@ INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl MAKE= make -f Makefile.ssl -MAKEDEPEND= $(TOP)/util/domd $(TOP) +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) MAKEFILE= Makefile.ssl AR= ar r @@ -39,8 +40,7 @@ all: lib lib: $(LIBOBJ) $(AR) $(LIB) $(LIBOBJ) - @echo You may get an error following this line. Please ignore. - - $(RANLIB) $(LIB) + $(RANLIB) $(LIB) || echo Never mind. @touch lib files: @@ -68,7 +68,7 @@ lint: lint -DLINT $(INCLUDES) $(SRC)>fluff depend: - $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) dclean: $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new @@ -79,13 +79,20 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. -mdc2_one.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h -mdc2_one.o: ../../include/openssl/crypto.h ../../include/openssl/des.h -mdc2_one.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -mdc2_one.o: ../../include/openssl/err.h ../../include/openssl/lhash.h -mdc2_one.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h +mdc2_one.o: ../../e_os.h ../../include/openssl/bio.h +mdc2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h +mdc2_one.o: ../../include/openssl/des.h ../../include/openssl/des_old.h +mdc2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +mdc2_one.o: ../../include/openssl/lhash.h ../../include/openssl/mdc2.h +mdc2_one.o: ../../include/openssl/opensslconf.h mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h mdc2_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -mdc2_one.o: ../cryptlib.h -mdc2dgst.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h +mdc2_one.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +mdc2_one.o: ../cryptlib.h mdc2_one.c +mdc2dgst.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +mdc2dgst.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h +mdc2dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +mdc2dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +mdc2dgst.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +mdc2dgst.o: mdc2dgst.c diff --git a/crypto/openssl/crypto/mdc2/mdc2.h b/crypto/openssl/crypto/mdc2/mdc2.h index 5da8da7..793a8a0 100644 --- a/crypto/openssl/crypto/mdc2/mdc2.h +++ b/crypto/openssl/crypto/mdc2/mdc2.h @@ -65,7 +65,7 @@ extern "C" { #endif -#ifdef NO_MDC2 +#ifdef OPENSSL_NO_MDC2 #error MDC2 is disabled. #endif @@ -76,14 +76,14 @@ typedef struct mdc2_ctx_st { int num; unsigned char data[MDC2_BLOCK]; - des_cblock h,hh; + DES_cblock h,hh; int pad_type; /* either 1 or 2, default 1 */ } MDC2_CTX; -void MDC2_Init(MDC2_CTX *c); -void MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len); -void MDC2_Final(unsigned char *md, MDC2_CTX *c); +int MDC2_Init(MDC2_CTX *c); +int MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len); +int MDC2_Final(unsigned char *md, MDC2_CTX *c); unsigned char *MDC2(const unsigned char *d, unsigned long n, unsigned char *md); diff --git a/crypto/openssl/crypto/mdc2/mdc2_one.c b/crypto/openssl/crypto/mdc2/mdc2_one.c index 6cd141b..37f06c8 100644 --- a/crypto/openssl/crypto/mdc2/mdc2_one.c +++ b/crypto/openssl/crypto/mdc2/mdc2_one.c @@ -69,7 +69,7 @@ unsigned char *MDC2(const unsigned char *d, unsigned long n, unsigned char *md) MDC2_Init(&c); MDC2_Update(&c,d,n); MDC2_Final(md,&c); - memset(&c,0,sizeof(c)); /* security consideration */ + OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ return(md); } diff --git a/crypto/openssl/crypto/mdc2/mdc2dgst.c b/crypto/openssl/crypto/mdc2/mdc2dgst.c index 84c6c45..32daa9b 100644 --- a/crypto/openssl/crypto/mdc2/mdc2dgst.c +++ b/crypto/openssl/crypto/mdc2/mdc2dgst.c @@ -75,15 +75,16 @@ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len); -void MDC2_Init(MDC2_CTX *c) +int MDC2_Init(MDC2_CTX *c) { c->num=0; c->pad_type=1; memset(&(c->h[0]),0x52,MDC2_BLOCK); memset(&(c->hh[0]),0x25,MDC2_BLOCK); + return 1; } -void MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) +int MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) { int i,j; @@ -95,7 +96,7 @@ void MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) /* partial block */ memcpy(&(c->data[i]),in,(int)len); c->num+=(int)len; - return; + return 1; } else { @@ -116,6 +117,7 @@ void MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) memcpy(&(c->data[0]),&(in[i]),j); c->num=j; } + return 1; } static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len) @@ -123,7 +125,7 @@ static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len) register DES_LONG tin0,tin1; register DES_LONG ttin0,ttin1; DES_LONG d[2],dd[2]; - des_key_schedule k; + DES_key_schedule k; unsigned char *p; unsigned int i; @@ -134,13 +136,13 @@ static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len) c->h[0]=(c->h[0]&0x9f)|0x40; c->hh[0]=(c->hh[0]&0x9f)|0x20; - des_set_odd_parity(&c->h); - des_set_key_unchecked(&c->h,k); - des_encrypt1(d,k,1); + DES_set_odd_parity(&c->h); + DES_set_key_unchecked(&c->h,&k); + DES_encrypt1(d,&k,1); - des_set_odd_parity(&c->hh); - des_set_key_unchecked(&c->hh,k); - des_encrypt1(dd,k,1); + DES_set_odd_parity(&c->hh); + DES_set_key_unchecked(&c->hh,&k); + DES_encrypt1(dd,&k,1); ttin0=tin0^dd[0]; ttin1=tin1^dd[1]; @@ -156,7 +158,7 @@ static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len) } } -void MDC2_Final(unsigned char *md, MDC2_CTX *c) +int MDC2_Final(unsigned char *md, MDC2_CTX *c) { int i,j; @@ -171,6 +173,7 @@ void MDC2_Final(unsigned char *md, MDC2_CTX *c) } memcpy(md,(char *)c->h,MDC2_BLOCK); memcpy(&(md[MDC2_BLOCK]),(char *)c->hh,MDC2_BLOCK); + return 1; } #undef TEST diff --git a/crypto/openssl/crypto/mdc2/mdc2test.c b/crypto/openssl/crypto/mdc2/mdc2test.c index 46c25ae..c9abe99 100644 --- a/crypto/openssl/crypto/mdc2/mdc2test.c +++ b/crypto/openssl/crypto/mdc2/mdc2test.c @@ -60,17 +60,20 @@ #include #include -#if defined(NO_DES) && !defined(NO_MDC2) -#define NO_MDC2 +#include "../e_os.h" + +#if defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_MDC2) +#define OPENSSL_NO_MDC2 #endif -#ifdef NO_MDC2 +#ifdef OPENSSL_NO_MDC2 int main(int argc, char *argv[]) { printf("No MDC2 support\n"); return(0); } #else +#include #include #ifdef CHARSET_EBCDIC @@ -92,16 +95,17 @@ int main(int argc, char *argv[]) int ret=0; unsigned char md[MDC2_DIGEST_LENGTH]; int i; - MDC2_CTX c; + EVP_MD_CTX c; static char *text="Now is the time for all "; #ifdef CHARSET_EBCDIC ebcdic2ascii(text,text,strlen(text)); #endif - MDC2_Init(&c); - MDC2_Update(&c,(unsigned char *)text,strlen(text)); - MDC2_Final(&(md[0]),&c); + EVP_MD_CTX_init(&c); + EVP_DigestInit_ex(&c,EVP_mdc2(), NULL); + EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text)); + EVP_DigestFinal_ex(&c,&(md[0]),NULL); if (memcmp(md,pad1,MDC2_DIGEST_LENGTH) != 0) { @@ -116,10 +120,11 @@ int main(int argc, char *argv[]) else printf("pad1 - ok\n"); - MDC2_Init(&c); - c.pad_type=2; - MDC2_Update(&c,(unsigned char *)text,strlen(text)); - MDC2_Final(&(md[0]),&c); + EVP_DigestInit_ex(&c,EVP_mdc2(), NULL); + /* FIXME: use a ctl function? */ + ((MDC2_CTX *)c.md_data)->pad_type=2; + EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text)); + EVP_DigestFinal_ex(&c,&(md[0]),NULL); if (memcmp(md,pad2,MDC2_DIGEST_LENGTH) != 0) { @@ -134,7 +139,8 @@ int main(int argc, char *argv[]) else printf("pad2 - ok\n"); - exit(ret); + EVP_MD_CTX_cleanup(&c); + EXIT(ret); return(ret); } #endif -- cgit v1.1