summaryrefslogtreecommitdiffstats
path: root/secure/lib
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>1996-07-28 08:18:06 +0000
committermarkm <markm@FreeBSD.org>1996-07-28 08:18:06 +0000
commit5313ba6bbed76bbe085937a5a042d87f2a5e601f (patch)
tree66628770810a6be62cfef66613534cbaedaecdf5 /secure/lib
parentac425672272c2be2c8ff171a3ae8851e8219740f (diff)
downloadFreeBSD-src-5313ba6bbed76bbe085937a5a042d87f2a5e601f.zip
FreeBSD-src-5313ba6bbed76bbe085937a5a042d87f2a5e601f.tar.gz
Latest libdes from Eric Young. Mainly code beautification.
Diffstat (limited to 'secure/lib')
-rw-r--r--secure/lib/libdes/COPYRIGHT2
-rw-r--r--secure/lib/libdes/FILES2
-rw-r--r--secure/lib/libdes/GNUmakefile2
-rw-r--r--secure/lib/libdes/Makefile.ssl23
-rw-r--r--secure/lib/libdes/Makefile.uni12
-rw-r--r--secure/lib/libdes/VERSION12
-rw-r--r--secure/lib/libdes/cbc3_enc.c6
-rw-r--r--secure/lib/libdes/cbc_cksm.c12
-rw-r--r--secure/lib/libdes/cbc_enc.c14
-rw-r--r--secure/lib/libdes/cfb64ede.c23
-rw-r--r--secure/lib/libdes/cfb64enc.c15
-rw-r--r--secure/lib/libdes/cfb_enc.c14
-rw-r--r--secure/lib/libdes/des.c22
-rw-r--r--secure/lib/libdes/des.h39
-rwxr-xr-xsecure/lib/libdes/des.pl62
-rw-r--r--secure/lib/libdes/des_locl.h95
-rw-r--r--secure/lib/libdes/des_ver.h49
-rw-r--r--secure/lib/libdes/destest.c69
-rw-r--r--secure/lib/libdes/ecb3_enc.c8
-rw-r--r--secure/lib/libdes/ecb_enc.c84
-rw-r--r--secure/lib/libdes/ede_enc.c24
-rw-r--r--secure/lib/libdes/enc_read.c46
-rw-r--r--secure/lib/libdes/enc_writ.c19
-rw-r--r--secure/lib/libdes/fcrypt.c159
-rw-r--r--secure/lib/libdes/ncbc_enc.c14
-rw-r--r--secure/lib/libdes/new_rkey.c8
-rw-r--r--secure/lib/libdes/ofb64ede.c14
-rw-r--r--secure/lib/libdes/ofb64enc.c10
-rw-r--r--secure/lib/libdes/ofb_enc.c12
-rw-r--r--secure/lib/libdes/pcbc_enc.c12
-rw-r--r--secure/lib/libdes/podd.h4
-rw-r--r--secure/lib/libdes/qud_cksm.c32
-rw-r--r--secure/lib/libdes/rand_key.c12
-rw-r--r--secure/lib/libdes/read_pwd.c61
-rw-r--r--secure/lib/libdes/rpc_des.h9
-rw-r--r--secure/lib/libdes/rpc_enc.c8
-rw-r--r--secure/lib/libdes/rpw.c4
-rw-r--r--secure/lib/libdes/set_key.c13
-rwxr-xr-xsecure/lib/libdes/shifts.pl2
-rw-r--r--secure/lib/libdes/sk.h6
-rw-r--r--secure/lib/libdes/speed.c8
-rw-r--r--secure/lib/libdes/spr.h6
-rw-r--r--secure/lib/libdes/str2key.c4
-rw-r--r--secure/lib/libdes/supp.c4
-rwxr-xr-xsecure/lib/libdes/testdes.pl2
-rw-r--r--secure/lib/libdes/times43
46 files changed, 689 insertions, 412 deletions
diff --git a/secure/lib/libdes/COPYRIGHT b/secure/lib/libdes/COPYRIGHT
index dc789d4..32f8fb0 100644
--- a/secure/lib/libdes/COPYRIGHT
+++ b/secure/lib/libdes/COPYRIGHT
@@ -1,4 +1,4 @@
-Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
All rights reserved.
This package is an DES implementation written by Eric Young (eay@mincom.oz.au).
diff --git a/secure/lib/libdes/FILES b/secure/lib/libdes/FILES
index f8b0c81..4c7ea2d 100644
--- a/secure/lib/libdes/FILES
+++ b/secure/lib/libdes/FILES
@@ -58,7 +58,7 @@ des_locl.h - Internal libdes.a header file.
podd.h - Odd parity tables - used in des_set_key().
sk.h - Lookup tables used in des_set_key().
spr.h - What is left of the S tables - used in ecb_encrypt().
-version.h - header file for the external definition of the
+des_ver.h - header file for the external definition of the
version string.
des.doc - SSLeay documentation for the library.
diff --git a/secure/lib/libdes/GNUmakefile b/secure/lib/libdes/GNUmakefile
index 6372d08..5863b90 100644
--- a/secure/lib/libdes/GNUmakefile
+++ b/secure/lib/libdes/GNUmakefile
@@ -21,7 +21,7 @@ routines:= $(destest)
distribute:= ARTISTIC COPYRIGHT FILES INSTALL Imakefile README VERSION \
GNUmakefile times vms.com KERBEROS MODES.DES \
des.man des_crypt.man \
- version.h des_locl.h podd.h sk.h spr.h \
+ des_ver.h des_locl.h podd.h sk.h spr.h \
des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl \
des.doc makefile.bc
diff --git a/secure/lib/libdes/Makefile.ssl b/secure/lib/libdes/Makefile.ssl
index dec4456..d0546c6 100644
--- a/secure/lib/libdes/Makefile.ssl
+++ b/secure/lib/libdes/Makefile.ssl
@@ -14,7 +14,7 @@ MAKEFILE= Makefile.ssl
CFLAGS= $(INCLUDES) $(CFLAG)
-GENERAL=Makefile
+GENERAL=Makefile des.org des_locl.org
TEST=destest.c
APPS=
@@ -25,16 +25,16 @@ LIBSRC= cbc3_enc.c cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
str2key.c cfb64ede.c ofb64ede.c supp.c
-LIBOBJ= cbc3_enc.o cbc_cksm.o cbc_enc.o cfb64enc.o cfb_enc.o \
- ecb3_enc.o ecb_enc.o ede_enc.o enc_read.o enc_writ.o \
- fcrypt.o ncbc_enc.o ofb64enc.o ofb_enc.o pcbc_enc.o \
- qud_cksm.o rand_key.o read_pwd.o rpc_enc.o set_key.o \
- str2key.o cfb64ede.o ofb64ede.o supp.o
+LIBOBJ= set_key.o ecb_enc.o ede_enc.o cbc_enc.o cbc3_enc.o \
+ ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
+ enc_read.o enc_writ.o fcrypt.o ncbc_enc.o ofb64enc.o \
+ ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
+ read_pwd.o rpc_enc.o cbc_cksm.o supp.o
SRC= $(LIBSRC)
EXHEADER= des.h
-HEADER= des_locl.h rpc_des.h podd.h sk.h spr.h version.h $(EXHEADER)
+HEADER= des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h $(EXHEADER)
ALL= $(GENERAL) $(SRC) $(HEADER)
@@ -48,11 +48,14 @@ lib: $(LIBOBJ)
$(TOP)/util/ranlib.sh $(LIB)
@touch lib
+files:
+ perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
+
links:
/bin/rm -f Makefile
- $(TOP)/util/point.sh Makefile.ssl Makefile
+ $(TOP)/util/point.sh Makefile.ssl Makefile ;
/bin/rm -f des.doc
- $(TOP)/util/point.sh ../../doc/des.doc .
+ $(TOP)/util/point.sh ../../doc/des.doc des.doc ;
$(TOP)/util/mklink.sh ../../include $(EXHEADER)
$(TOP)/util/mklink.sh ../../test $(TEST)
$(TOP)/util/mklink.sh ../../apps $(APPS)
@@ -78,7 +81,7 @@ depend:
$(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
dclean:
- sed -e '/^# DO NOT DELETE THIS LINE/ q' $(MAKEFILE) >Makefile.new
+ perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
mv -f Makefile.new $(MAKEFILE)
clean:
diff --git a/secure/lib/libdes/Makefile.uni b/secure/lib/libdes/Makefile.uni
index 972a845..33f959f 100644
--- a/secure/lib/libdes/Makefile.uni
+++ b/secure/lib/libdes/Makefile.uni
@@ -7,6 +7,9 @@
# MSDOS - we all know what it is :-)
# read_pwd.c makes a reasonable guess at what is correct.
+# If you are on a DEC Alpha, edit des.h and change the DES_LONG
+# define to 'unsigned int'. I have seen this give a %20 speedup.
+
OPTS0= -DRAND -DTERMIO #-DNOCONST
# Version 1.94 has changed the strings_to_key function so that it is
@@ -26,7 +29,9 @@ OPTS0= -DRAND -DTERMIO #-DNOCONST
# For other machines, experiment with changing the option and run
# ./speed to see which is faster.
# DO NOT TURN THIS OPTION ON WHEN COMPILING THIS CODE ON A 64 BIT MACHINE
-#OPTS2= -DDES_USE_PTR
+# 12-Apr-1996 - It appears to be broken and I'm not bothering to fix
+# it right now, so don't use this option :-)
+#OPTS2= -DDES_PTR
OPTS= $(OPTS0) $(OPTS1) $(OPTS2)
@@ -51,10 +56,11 @@ OBJS= cbc3_enc.o cbc_cksm.o cbc_enc.o ncbc_enc.o pcbc_enc.o qud_cksm.o \
GENERAL=COPYRIGHT FILES INSTALL Imakefile README VERSION Makefile \
times vms.com KERBEROS MODES.DES GNUmakefile des.man \
DES.pm DES.pod DES.xs Makefile.PL Makefile.uni typemap t \
- des_crypt.man Makefile.ssl des.doc makefile.bc
+ des_crypt.man Makefile.ssl des.doc makefile.bc des.org \
+ des_locl.org
DES= des.c
TESTING=destest.c speed.c rpw.c
-HEADERS=version.h des.h des_locl.h podd.h sk.h spr.h rpc_des.h
+HEADERS=des_ver.h des.h des_locl.h podd.h sk.h spr.h rpc_des.h
LIBDES= cbc3_enc.c cbc_cksm.c cbc_enc.c ncbc_enc.c pcbc_enc.c qud_cksm.c \
cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c ede_enc.c \
enc_read.c enc_writ.c fcrypt.c ofb64ede.c ofb64enc.c ofb_enc.c \
diff --git a/secure/lib/libdes/VERSION b/secure/lib/libdes/VERSION
index 5d25ddc..864eda3 100644
--- a/secure/lib/libdes/VERSION
+++ b/secure/lib/libdes/VERSION
@@ -1,3 +1,15 @@
+Version 3.24 20/04/95
+ The DES_PTR macro option checked and used by SSLeay configuration
+
+Version 3.23 11/04/95
+ Added DES_LONG. If defined to 'unsigned int' on the DEC Alpha,
+ it gives a %20 speedup :-)
+ Fixed the problem with des.pl under perl5. The patches were
+ sent by Ed Kubaitis (ejk@uiuc.edu).
+ if fcrypt.c, changed values to handle illegal salt values the way
+ normal crypt() implementations do. Some programs apparently use
+ them :-(. The patch was sent by Bjorn Gronvall <bg@sics.se>
+
Version 3.22 29/11/95
Bug in des(1), an error with the uuencoding stuff when the
'data' is small, thanks to Geoff Keating <keagchon@mehta.anu.edu.au>
diff --git a/secure/lib/libdes/cbc3_enc.c b/secure/lib/libdes/cbc3_enc.c
index 11aa3ff..a7b53ad 100644
--- a/secure/lib/libdes/cbc3_enc.c
+++ b/secure/lib/libdes/cbc3_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/cbc3_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/cbc3_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -58,7 +58,7 @@ des_cblock (*iv1);
des_cblock (*iv2);
int encrypt;
{
- int off=(length-1)/8;
+ int off=((int)length-1)/8;
long l8=((length+7)/8)*8;
des_cblock niv1,niv2;
diff --git a/secure/lib/libdes/cbc_cksm.c b/secure/lib/libdes/cbc_cksm.c
index 9088c73..e56c8eb 100644
--- a/secure/lib/libdes/cbc_cksm.c
+++ b/secure/lib/libdes/cbc_cksm.c
@@ -1,5 +1,5 @@
-/* lib/des/cbc_cksm.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/cbc_cksm.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -47,16 +47,16 @@
#include "des_locl.h"
-unsigned long des_cbc_cksum(input, output, length, schedule, ivec)
+DES_LONG des_cbc_cksum(input, output, length, schedule, ivec)
des_cblock (*input);
des_cblock (*output);
long length;
des_key_schedule schedule;
des_cblock (*ivec);
{
- register unsigned long tout0,tout1,tin0,tin1;
+ register DES_LONG tout0,tout1,tin0,tin1;
register long l=length;
- unsigned long tin[2];
+ DES_LONG tin[2];
unsigned char *in,*out,*iv;
in=(unsigned char *)input;
@@ -77,7 +77,7 @@ des_cblock (*ivec);
tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1;
- des_encrypt((unsigned long *)tin,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
/* fix 15/10/91 eay - thanks to keithr@sco.COM */
tout0=tin[0];
tout1=tin[1];
diff --git a/secure/lib/libdes/cbc_enc.c b/secure/lib/libdes/cbc_enc.c
index c0cdef8..415bcd2 100644
--- a/secure/lib/libdes/cbc_enc.c
+++ b/secure/lib/libdes/cbc_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/cbc_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/cbc_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -55,11 +55,11 @@ des_key_schedule schedule;
des_cblock (*ivec);
int encrypt;
{
- register unsigned long tin0,tin1;
- register unsigned long tout0,tout1,xor0,xor1;
+ register DES_LONG tin0,tin1;
+ register DES_LONG tout0,tout1,xor0,xor1;
register unsigned char *in,*out;
register long l=length;
- unsigned long tin[2];
+ DES_LONG tin[2];
unsigned char *iv;
in=(unsigned char *)input;
@@ -81,7 +81,7 @@ int encrypt;
c2ln(in,tin0,tin1,l);
tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1;
- des_encrypt((unsigned long *)tin,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
tout0=tin[0]; l2c(tout0,out);
tout1=tin[1]; l2c(tout1,out);
}
@@ -94,7 +94,7 @@ int encrypt;
{
c2l(in,tin0); tin[0]=tin0;
c2l(in,tin1); tin[1]=tin1;
- des_encrypt((unsigned long *)tin,schedule,DES_DECRYPT);
+ des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0;
tout1=tin[1]^xor1;
if (l >= 8)
diff --git a/secure/lib/libdes/cfb64ede.c b/secure/lib/libdes/cfb64ede.c
index 93af817..f56c87c 100644
--- a/secure/lib/libdes/cfb64ede.c
+++ b/secure/lib/libdes/cfb64ede.c
@@ -1,5 +1,5 @@
-/* lib/des/cfb64ede.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/cfb64ede.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -61,9 +61,10 @@ des_cblock (*ivec);
int *num;
int encrypt;
{
- register unsigned long v0,v1;
- register long l=length,n=*num;
- unsigned long ti[2];
+ register DES_LONG v0,v1;
+ register long l=length;
+ register int n=*num;
+ DES_LONG ti[2];
unsigned char *iv,c,cc;
iv=(unsigned char *)ivec;
@@ -80,9 +81,9 @@ int encrypt;
ti[0]=v0;
ti[1]=v1;
- des_encrypt2((unsigned long *)ti,ks1,DES_ENCRYPT);
- des_encrypt2((unsigned long *)ti,ks2,DES_DECRYPT);
- des_encrypt2((unsigned long *)ti,ks3,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)ti,ks1,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)ti,ks2,DES_DECRYPT);
+ des_encrypt2((DES_LONG *)ti,ks3,DES_ENCRYPT);
v0=ti[0];
v1=ti[1];
@@ -112,9 +113,9 @@ int encrypt;
ti[0]=v0;
ti[1]=v1;
- des_encrypt2((unsigned long *)ti,ks1,DES_ENCRYPT);
- des_encrypt2((unsigned long *)ti,ks2,DES_DECRYPT);
- des_encrypt2((unsigned long *)ti,ks3,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)ti,ks1,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)ti,ks2,DES_DECRYPT);
+ des_encrypt2((DES_LONG *)ti,ks3,DES_ENCRYPT);
v0=ti[0];
v1=ti[1];
diff --git a/secure/lib/libdes/cfb64enc.c b/secure/lib/libdes/cfb64enc.c
index 35875f3..60c8511 100644
--- a/secure/lib/libdes/cfb64enc.c
+++ b/secure/lib/libdes/cfb64enc.c
@@ -1,5 +1,5 @@
-/* lib/des/cfb64enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/cfb64enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -61,9 +61,10 @@ des_cblock (*ivec);
int *num;
int encrypt;
{
- register unsigned long v0,v1;
- register long l=length,n=*num;
- unsigned long ti[2];
+ register DES_LONG v0,v1;
+ register long l=length;
+ register int n=*num;
+ DES_LONG ti[2];
unsigned char *iv,c,cc;
iv=(unsigned char *)ivec;
@@ -75,7 +76,7 @@ int encrypt;
{
c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1;
- des_encrypt((unsigned long *)ti,
+ des_encrypt((DES_LONG *)ti,
schedule,DES_ENCRYPT);
iv=(unsigned char *)ivec;
v0=ti[0]; l2c(v0,iv);
@@ -96,7 +97,7 @@ int encrypt;
{
c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1;
- des_encrypt((unsigned long *)ti,
+ des_encrypt((DES_LONG *)ti,
schedule,DES_ENCRYPT);
iv=(unsigned char *)ivec;
v0=ti[0]; l2c(v0,iv);
diff --git a/secure/lib/libdes/cfb_enc.c b/secure/lib/libdes/cfb_enc.c
index 33002d1..a2875a5 100644
--- a/secure/lib/libdes/cfb_enc.c
+++ b/secure/lib/libdes/cfb_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/cfb_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/cfb_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -62,11 +62,11 @@ des_key_schedule schedule;
des_cblock (*ivec);
int encrypt;
{
- register unsigned long d0,d1,v0,v1,n=(numbits+7)/8;
- register unsigned long mask0,mask1;
+ register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
+ register DES_LONG mask0,mask1;
register unsigned long l=length;
register int num=numbits;
- unsigned long ti[2];
+ DES_LONG ti[2];
unsigned char *iv;
if (num > 64) return;
@@ -95,7 +95,7 @@ int encrypt;
l-=n;
ti[0]=v0;
ti[1]=v1;
- des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n);
in+=n;
d0=(d0^ti[0])&mask0;
@@ -127,7 +127,7 @@ int encrypt;
l-=n;
ti[0]=v0;
ti[1]=v1;
- des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n);
in+=n;
/* 30-08-94 - eay - changed because l>>32 and
diff --git a/secure/lib/libdes/des.c b/secure/lib/libdes/des.c
index ca5505b..5e349dc 100644
--- a/secure/lib/libdes/des.c
+++ b/secure/lib/libdes/des.c
@@ -1,5 +1,5 @@
-/* lib/des/des.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/des.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -55,7 +55,7 @@
#endif
#include <time.h>
-#include "version.h"
+#include "des_ver.h"
#ifdef VMS
#include <types.h>
@@ -247,7 +247,7 @@ char **argv;
if (vflag)
{
#ifndef _Windows
- fprintf(stderr,"des(1) built with %s\n",DES_version);
+ fprintf(stderr,"des(1) built with %s\n",libdes_version);
#endif
EXIT(1);
}
@@ -255,7 +255,7 @@ char **argv;
}
#ifndef _Windows
- if (vflag) fprintf(stderr,"des(1) built with %s\n",DES_version);
+ if (vflag) fprintf(stderr,"des(1) built with %s\n",libdes_version);
#endif
if ( (in != NULL) &&
(out != NULL) &&
@@ -826,9 +826,9 @@ FILE *fp;
return(tot);
}
-#define ccc2l(c,l) (l =((unsigned long)(*((c)++)))<<16, \
- l|=((unsigned long)(*((c)++)))<< 8, \
- l|=((unsigned long)(*((c)++))))
+#define ccc2l(c,l) (l =((DES_LONG)(*((c)++)))<<16, \
+ l|=((DES_LONG)(*((c)++)))<< 8, \
+ l|=((DES_LONG)(*((c)++))))
#define l2ccc(l,c) (*((c)++)=(unsigned char)(((l)>>16)&0xff), \
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
@@ -841,7 +841,7 @@ int num;
unsigned char *out;
{
int j,i,n,tot=0;
- unsigned long l;
+ DES_LONG l;
register unsigned char *p;
p=out;
@@ -875,8 +875,8 @@ unsigned char *out;
{
int j,i,k;
unsigned int n=0,space=0;
- unsigned long l;
- unsigned long w,x,y,z;
+ DES_LONG l;
+ DES_LONG w,x,y,z;
unsigned int blank=(unsigned int)'\n'-' ';
for (j=0; j<num; )
diff --git a/secure/lib/libdes/des.h b/secure/lib/libdes/des.h
index 87e68a6..f0615f1 100644
--- a/secure/lib/libdes/des.h
+++ b/secure/lib/libdes/des.h
@@ -1,5 +1,5 @@
/* lib/des/des.h */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -48,8 +48,18 @@
#ifndef HEADER_DES_H
#define HEADER_DES_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdio.h>
+/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
+ * %20 speed up (longs are 8 bytes, int's are 4). */
+#ifndef DES_LONG
+#define DES_LONG unsigned long
+#endif
+
typedef unsigned char des_cblock[8];
typedef struct des_ks_struct
{
@@ -57,7 +67,7 @@ typedef struct des_ks_struct
des_cblock _;
/* make sure things are correct size on machines with
* 8 byte longs */
- unsigned long pad[2];
+ DES_LONG pad[2];
} ks;
#undef _
#define _ ks._
@@ -86,8 +96,10 @@ typedef struct des_ks_struct
#define C_Block des_cblock
#define Key_schedule des_key_schedule
+#ifdef KERBEROS
#define ENCRYPT DES_ENCRYPT
#define DECRYPT DES_DECRYPT
+#endif
#define KEY_SZ DES_KEY_SZ
#define string_to_key des_string_to_key
#define read_pw_string des_read_pw_string
@@ -102,7 +114,7 @@ typedef struct des_ks_struct
#define quad_cksum des_quad_cksum
/* For compatibility with the MIT lib - eay 20/05/92 */
-typedef struct des_key_schedule bit_64;
+typedef des_key_schedule bit_64;
#define des_fixup_key_parity des_set_odd_parity
#define des_check_key_parity check_parity
@@ -116,10 +128,11 @@ extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
#undef NOPROTO
#endif
#ifndef NOPROTO
+char *des_options(void);
void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
des_key_schedule ks1,des_key_schedule ks2,
des_key_schedule ks3, int enc);
-unsigned long des_cbc_cksum(des_cblock *input,des_cblock *output,
+DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
long length,des_key_schedule schedule,des_cblock *ivec);
void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,int enc);
@@ -132,8 +145,8 @@ void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
long length,des_key_schedule schedule,des_cblock *ivec,int enc);
void des_ecb_encrypt(des_cblock *input,des_cblock *output,
des_key_schedule ks,int enc);
-void des_encrypt(unsigned long *data,des_key_schedule ks, int enc);
-void des_encrypt2(unsigned long *data,des_key_schedule ks, int enc);
+void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
+void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
long length, des_key_schedule ks1, des_key_schedule ks2,
des_key_schedule ks3, des_cblock *ivec, int enc);
@@ -163,7 +176,7 @@ void des_ofb_encrypt(unsigned char *in,unsigned char *out,
int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,int enc);
-unsigned long des_quad_cksum(des_cblock *input,des_cblock *output,
+DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
long length,int out_count,des_cblock *seed);
void des_random_seed(des_cblock key);
void des_random_key(des_cblock ret);
@@ -195,8 +208,9 @@ void des_generate_random_block(des_cblock *block);
#else
+char *des_options();
void des_ecb3_encrypt();
-unsigned long des_cbc_cksum();
+DES_LONG des_cbc_cksum();
void des_cbc_encrypt();
void des_ncbc_encrypt();
void des_3cbc_encrypt();
@@ -216,7 +230,7 @@ char *crypt();
#endif
void des_ofb_encrypt();
void des_pcbc_encrypt();
-unsigned long des_quad_cksum();
+DES_LONG des_quad_cksum();
void des_random_seed();
void des_random_key();
int des_read_password();
@@ -236,11 +250,18 @@ void des_cblock_print_file();
/* The following functions are not in the normal unix build or the
* SSLeay build. When using the SSLeay build, use RAND_seed()
* and RAND_bytes() instead. */
+#ifdef FreeBSD
int des_new_random_key();
void des_init_random_number_generator();
void des_set_random_generator_seed();
void des_set_sequence_number();
void des_generate_random_block();
+#endif
+
+#endif
+#ifdef __cplusplus
+}
#endif
+
#endif
diff --git a/secure/lib/libdes/des.pl b/secure/lib/libdes/des.pl
index 5ba5a9b..d80e7cb 100755
--- a/secure/lib/libdes/des.pl
+++ b/secure/lib/libdes/des.pl
@@ -1,6 +1,12 @@
-#!/usr/local/bin/perl
-# Copyright (C) 1993 Eric Young
+#!/usr/bin/perl
# des.pl - eric young 22/11/1991 eay@mincom.oz.au or eay@psych.psy.uq.oz.au
+#
+# Copyright (C) 1993 Eric Young
+#
+# 11 April 1996 - patched to circumvent Perl 5 (through 5.002) problem
+# with sign-extension on right shift operations.
+# Ed Kubaitis - ejk@uiuc.edu
+#
# eay - 92/08/31 - I think I have fixed all problems for 64bit
# versions of perl but I could be wrong since I have not tested it yet :-).
#
@@ -25,9 +31,11 @@
# $outbytes= &des_ecb_encrypt(*ks,1,$data);
# @enc =unpack("C8",$outbytes);
#
-
+
package des;
+eval("usr integer;") if (int($]) > 4);
+
# The following 8 arrays are used in des_set_key
@skb0=(
# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6
@@ -375,8 +383,8 @@ sub main'des_set_key
$skb6[ ($d>>15)&0x3f ]|
$skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)];
push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff);
- $s= ($s>>16)|($t&0xffff0000) ;
- push(@ks,(($s<<4)|($s>>28))&0xffffffff);
+ $s= (($s>>16)&0x0000ffff)|($t&0xffff0000) ;
+ push(@ks,(($s<<4)|(($s>>28)&0xf))&0xffffffff);
}
@ks;
}
@@ -390,23 +398,23 @@ sub doPC1
$b^=($t<<4); $a^=$t;
# do $a first
$t=(($a<<18)^$a)&0xcccc0000;
- $a=$a^$t^($t>>18);
+ $a=$a^$t^(($t>>18)&0x00003fff);
$t=(($a<<17)^$a)&0xaaaa0000;
- $a=$a^$t^($t>>17);
+ $a=$a^$t^(($t>>17)&0x00007fff);
$t=(($a<< 8)^$a)&0x00ff0000;
- $a=$a^$t^($t>> 8);
+ $a=$a^$t^(($t>> 8)&0x00ffffff);
$t=(($a<<17)^$a)&0xaaaa0000;
- $a=$a^$t^($t>>17);
+ $a=$a^$t^(($t>>17)&0x00007fff);
# now do $b
$t=(($b<<24)^$b)&0xff000000;
- $b=$b^$t^($t>>24);
+ $b=$b^$t^(($t>>24)&0x000000ff);
$t=(($b<< 8)^$b)&0x00ff0000;
- $b=$b^$t^($t>> 8);
+ $b=$b^$t^(($t>> 8)&0x00ffffff);
$t=(($b<<14)^$b)&0x33330000;
- $b=$b^$t^($t>>14);
+ $b=$b^$t^(($t>>14)&0x0003ffff);
$b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55);
- $b=($b>>8)|(($a&0xf0000000)>>4);
+ $b=(($b>>8)&0x00ffffff)|((($a&0xf0000000)>>4)&0x0fffffff);
$a&=0x0fffffff;
}
@@ -472,10 +480,12 @@ sub main'des_ecb_encrypt
{
for ($i=0; $i<32; $i+=4)
{
- $t=(($r<<1)|($r>>31))&0xffffffff;
+ $t=((($r&0x7fffffff)<<1)|(($r>>31)&0x00000001));
$u=$t^$ks[$i ];
$t=$t^$ks[$i+1];
- $t=(($t>>4)|($t<<28))&0xffffffff;
+ $t2=(($t&0x0000000f)<<28);
+
+ $t=((($t>>4)&0x0fffffff)|(($t&0x0000000f)<<28));
$l^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
@@ -485,10 +495,10 @@ sub main'des_ecb_encrypt
$SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f];
- $t=(($l<<1)|($l>>31))&0xffffffff;
+ $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
$u=$t^$ks[$i+2];
$t=$t^$ks[$i+3];
- $t=(($t>>4)|($t<<28))&0xffffffff;
+ $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
$r^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
@@ -503,10 +513,10 @@ sub main'des_ecb_encrypt
{
for ($i=30; $i>0; $i-=4)
{
- $t=(($r<<1)|($r>>31))&0xffffffff;
+ $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff;
$u=$t^$ks[$i ];
$t=$t^$ks[$i+1];
- $t=(($t>>4)|($t<<28))&0xffffffff;
+ $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
$l^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
@@ -516,10 +526,10 @@ sub main'des_ecb_encrypt
$SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f];
- $t=(($l<<1)|($l>>31))&0xffffffff;
+ $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
$u=$t^$ks[$i-2];
$t=$t^$ks[$i-1];
- $t=(($t>>4)|($t<<28))&0xffffffff;
+ $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
$r^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
@@ -531,6 +541,12 @@ sub main'des_ecb_encrypt
}
}
&doFP(*l,*r);
- pack("C8",$l&0xff,$l>>8,$l>>16,$l>>24,
- $r&0xff,$r>>8,$r>>16,$r>>24);
+ pack("C8",$l&0xff,
+ ($l>> 8)&0x00ffffff,
+ ($l>>16)&0x0000ffff,
+ ($l>>24)&0x000000ff,
+ $r&0xff,
+ ($r>> 8)&0x00ffffff,
+ ($r>>16)&0x0000ffff,
+ ($r>>24)&0x000000ff);
}
diff --git a/secure/lib/libdes/des_locl.h b/secure/lib/libdes/des_locl.h
index 80a4ccd..87a2b4a 100644
--- a/secure/lib/libdes/des_locl.h
+++ b/secure/lib/libdes/des_locl.h
@@ -1,5 +1,5 @@
/* lib/des/des_locl.h */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -44,9 +44,23 @@
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
+/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
+ *
+ * Always modify des_locl.org since des_locl.h is automatically generated from
+ * it during SSLeay configuration.
+ *
+ * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
+ */
#ifndef HEADER_DES_LOCL_H
#define HEADER_DES_LOCL_H
+
+#if defined(WIN32) || defined(WIN16)
+#ifndef MSDOS
+#define MSDOS
+#endif
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#ifndef MSDOS
@@ -56,12 +70,13 @@
/* the following is tweaked from a config script, that is why it is a
* protected undef/define */
-#ifndef DES_USE_PTR
-#undef DES_USE_PTR
+#ifndef DES_PTR
+#undef DES_PTR
#endif
#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
#include <stdlib.h>
+#include <errno.h>
#include <time.h>
#include <io.h>
#ifndef RAND
@@ -84,7 +99,6 @@
#ifdef MSDOS
#define getpid() 2
-extern int errno;
#define RAND
#undef NOPROTO
#endif
@@ -109,24 +123,24 @@ extern int errno;
#define MAXWRITE (1024*16)
#define BSIZE (MAXWRITE+4)
-#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<<24L)
+#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
+ l|=((DES_LONG)(*((c)++)))<< 8L, \
+ l|=((DES_LONG)(*((c)++)))<<16L, \
+ l|=((DES_LONG)(*((c)++)))<<24L)
/* NOTE - c is not incremented as per c2l */
#define c2ln(c,l1,l2,n) { \
c+=n; \
l1=l2=0; \
switch (n) { \
- case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
- case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
- case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
- case 5: l2|=((unsigned long)(*(--(c)))); \
- case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
- case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
- case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
- case 1: l1|=((unsigned long)(*(--(c)))); \
+ case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
+ case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
+ case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
+ case 5: l2|=((DES_LONG)(*(--(c)))); \
+ case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
+ case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
+ case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
+ case 1: l1|=((DES_LONG)(*(--(c)))); \
} \
}
@@ -139,10 +153,10 @@ extern int errno;
* when faced with machines with 8 byte longs. */
#define HDRSIZE 4
-#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
- l|=((unsigned long)(*((c)++)))<<16L, \
- l|=((unsigned long)(*((c)++)))<< 8L, \
- l|=((unsigned long)(*((c)++))))
+#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
+ l|=((DES_LONG)(*((c)++)))<<16L, \
+ l|=((DES_LONG)(*((c)++)))<< 8L, \
+ l|=((DES_LONG)(*((c)++))))
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
@@ -164,26 +178,35 @@ extern int errno;
} \
}
+#if defined(WIN32)
+#define ROTATE(a,n) (_lrotr(a,n))
+#else
+#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
+#endif
+
/* The changes to this macro may help or hinder, depending on the
* compiler and the achitecture. gcc2 always seems to do well :-).
* Inspired by Dana How <how@isl.stanford.edu>
- * DO NOT use the alternative version on machines with 8 byte longs. */
-#ifdef DES_USR_PTR
+ * DO NOT use the alternative version on machines with 8 byte longs.
+ * It does not seem to work on the Alpha, even when DES_LONG is 4
+ * bytes, probably an issue of accessing non-word aligned objects :-( */
+#ifdef DES_PTR
+
#define D_ENCRYPT(L,R,S) { \
u=((R^s[S ])<<2); \
t= R^s[S+1]; \
- t=((t>>2)+(t<<30)); \
- L^= \
- *(unsigned long *)(des_SP+0x0100+((t )&0xfc))+ \
- *(unsigned long *)(des_SP+0x0300+((t>> 8)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0500+((t>>16)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0700+((t>>24)&0xfc))+ \
- *(unsigned long *)(des_SP+ ((u )&0xfc))+ \
- *(unsigned long *)(des_SP+0x0200+((u>> 8)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0400+((u>>16)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0600+((u>>24)&0xfc)); }
+ t=ROTATE(t,2); \
+ L^= (\
+ *(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24)&0xfc))); }
#else /* original version */
-#ifdef MSDOS
+#ifdef undef
#define D_ENCRYPT(L,R,S) \
U.l=R^s[S+1]; \
T.s[0]=((U.s[0]>>4)|(U.s[1]<<12))&0x3f3f; \
@@ -201,7 +224,7 @@ extern int errno;
#define D_ENCRYPT(Q,R,S) {\
u=(R^s[S ]); \
t=R^s[S+1]; \
- t=((t>>4L)+(t<<28L)); \
+ t=ROTATE(t,4); \
Q^= des_SPtrans[1][(t )&0x3f]| \
des_SPtrans[3][(t>> 8L)&0x3f]| \
des_SPtrans[5][(t>>16L)&0x3f]| \
@@ -256,7 +279,7 @@ extern int errno;
#define IP(l,r) \
{ \
- register unsigned long tt; \
+ register DES_LONG tt; \
PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
PERM_OP(l,r,tt,16,0x0000ffffL); \
PERM_OP(r,l,tt, 2,0x33333333L); \
@@ -266,7 +289,7 @@ extern int errno;
#define FP(l,r) \
{ \
- register unsigned long tt; \
+ register DES_LONG tt; \
PERM_OP(l,r,tt, 1,0x55555555L); \
PERM_OP(r,l,tt, 8,0x00ff00ffL); \
PERM_OP(l,r,tt, 2,0x33333333L); \
diff --git a/secure/lib/libdes/des_ver.h b/secure/lib/libdes/des_ver.h
new file mode 100644
index 0000000..b895af8
--- /dev/null
+++ b/secure/lib/libdes/des_ver.h
@@ -0,0 +1,49 @@
+/* crypto/des/des_ver.h */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
+ * All rights reserved.
+ *
+ * This file is part of an SSL implementation written
+ * by Eric Young (eay@mincom.oz.au).
+ * The implementation was written so as to conform with Netscapes SSL
+ * specification. This library and applications are
+ * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
+ * as long as the following conditions are aheared to.
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed. If this code is used in a product,
+ * Eric Young should be given attribution as the author of the parts used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Eric Young (eay@mincom.oz.au)
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+extern char *DES_version; /* SSLeay version string */
+extern char *libdes_version; /* old libdes version string */
diff --git a/secure/lib/libdes/destest.c b/secure/lib/libdes/destest.c
index fec3990..9b04a5d 100644
--- a/secure/lib/libdes/destest.c
+++ b/secure/lib/libdes/destest.c
@@ -1,5 +1,5 @@
-/* lib/des/destest.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/destest.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -45,6 +45,12 @@
* [including the GNU Public Licence.]
*/
+#if defined(WIN32) || defined(WIN16) || defined(WINDOWS)
+#ifndef MSDOS
+#define MSDOS
+#endif
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#ifndef MSDOS
@@ -261,7 +267,7 @@ static unsigned char ofb_cipher[24]=
0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
};
-unsigned long cbc_cksum_ret=0xB462FEF7L;
+DES_LONG cbc_cksum_ret=0xB462FEF7L;
unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
#ifndef NOPROTO
@@ -285,16 +291,16 @@ char *argv[];
des_key_schedule ks,ks2,ks3;
unsigned char cbc_in[40];
unsigned char cbc_out[40];
- unsigned long cs;
+ DES_LONG cs;
unsigned char qret[4][4],cret[8];
- unsigned long lqret[4];
+ DES_LONG lqret[4];
int num;
char *str;
printf("Doing ecb\n");
for (i=0; i<NUM_TESTS; i++)
{
- if ((j=key_sched((C_Block *)(key_data[i]),ks)) != 0)
+ if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0)
{
printf("Key error %2d:%d\n",i+1,j);
err=1;
@@ -323,17 +329,17 @@ char *argv[];
printf("Doing ede ecb\n");
for (i=0; i<(NUM_TESTS-1); i++)
{
- if ((j=key_sched((C_Block *)(key_data[i]),ks)) != 0)
+ if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0)
{
err=1;
printf("Key error %2d:%d\n",i+1,j);
}
- if ((j=key_sched((C_Block *)(key_data[i+1]),ks2)) != 0)
+ if ((j=des_key_sched((C_Block *)(key_data[i+1]),ks2)) != 0)
{
printf("Key error %2d:%d\n",i+2,j);
err=1;
}
- if ((j=key_sched((C_Block *)(key_data[i+2]),ks3)) != 0)
+ if ((j=des_key_sched((C_Block *)(key_data[i+2]),ks3)) != 0)
{
printf("Key error %2d:%d\n",i+3,j);
err=1;
@@ -362,7 +368,7 @@ char *argv[];
}
printf("Doing cbc\n");
- if ((j=key_sched((C_Block *)cbc_key,ks)) != 0)
+ if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
{
printf("Key error %d\n",j);
err=1;
@@ -384,17 +390,17 @@ char *argv[];
}
printf("Doing ede cbc\n");
- if ((j=key_sched((C_Block *)cbc_key,ks)) != 0)
+ if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
{
printf("Key error %d\n",j);
err=1;
}
- if ((j=key_sched((C_Block *)cbc2_key,ks2)) != 0)
+ if ((j=des_key_sched((C_Block *)cbc2_key,ks2)) != 0)
{
printf("Key error %d\n",j);
err=1;
}
- if ((j=key_sched((C_Block *)cbc3_key,ks3)) != 0)
+ if ((j=des_key_sched((C_Block *)cbc3_key,ks3)) != 0)
{
printf("Key error %d\n",j);
err=1;
@@ -427,7 +433,7 @@ char *argv[];
}
printf("Doing pcbc\n");
- if ((j=key_sched((C_Block *)cbc_key,ks)) != 0)
+ if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
{
printf("Key error %d\n",j);
err=1;
@@ -490,7 +496,7 @@ char *argv[];
printf("done\n");
printf("Doing ofb\n");
- key_sched((C_Block *)ofb_key,ks);
+ des_key_sched((C_Block *)ofb_key,ks);
memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
des_ofb_encrypt(plain,ofb_buf1,64,(long)sizeof(plain)/8,ks,
(C_Block *)ofb_tmp);
@@ -509,7 +515,7 @@ char *argv[];
}
printf("Doing ofb64\n");
- key_sched((C_Block *)ofb_key,ks);
+ des_key_sched((C_Block *)ofb_key,ks);
memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
memset(ofb_buf1,0,sizeof(ofb_buf1));
memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -535,7 +541,7 @@ char *argv[];
}
printf("Doing ede_ofb64\n");
- key_sched((C_Block *)ofb_key,ks);
+ des_key_sched((C_Block *)ofb_key,ks);
memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
memset(ofb_buf1,0,sizeof(ofb_buf1));
memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -561,13 +567,13 @@ char *argv[];
}
printf("Doing cbc_cksum\n");
- key_sched((C_Block *)cbc_key,ks);
- cs=cbc_cksum((C_Block *)cbc_data,(C_Block *)cret,
+ des_key_sched((C_Block *)cbc_key,ks);
+ cs=des_cbc_cksum((C_Block *)cbc_data,(C_Block *)cret,
(long)strlen(cbc_data),ks,(C_Block *)cbc_iv);
if (cs != cbc_cksum_ret)
{
printf("bad return value (%08lX), should be %08lX\n",
- cs,cbc_cksum_ret);
+ (unsigned long)cs,(unsigned long)cbc_cksum_ret);
err=1;
}
if (memcmp(cret,cbc_cksum_data,8) != 0)
@@ -585,9 +591,9 @@ char *argv[];
memcpy(&(lqret[i]),&(qret[i][0]),4);
}
{ /* Big-endian fix */
- static unsigned long l=1;
+ static DES_LONG l=1;
static unsigned char *c=(unsigned char *)&l;
- unsigned long ll;
+ DES_LONG ll;
if (!c[0])
{
@@ -601,31 +607,32 @@ char *argv[];
}
if (cs != 0x70d7a63aL)
{
- printf("quad_cksum error, ret %08lx should be 70d7a63a\n",cs);
+ printf("quad_cksum error, ret %08lx should be 70d7a63a\n",
+ (unsigned long)cs);
err=1;
}
if (lqret[0] != 0x327eba8dL)
{
printf("quad_cksum error, out[0] %08lx is not %08lx\n",
- lqret[0],0x327eba8dL);
+ (unsigned long)lqret[0],0x327eba8dL);
err=1;
}
if (lqret[1] != 0x201a49ccL)
{
printf("quad_cksum error, out[1] %08lx is not %08lx\n",
- lqret[1],0x201a49ccL);
+ (unsigned long)lqret[1],0x201a49ccL);
err=1;
}
if (lqret[2] != 0x70d7a63aL)
{
printf("quad_cksum error, out[2] %08lx is not %08lx\n",
- lqret[2],0x70d7a63aL);
+ (unsigned long)lqret[2],0x70d7a63aL);
err=1;
}
if (lqret[3] != 0x501c2c26L)
{
printf("quad_cksum error, out[3] %08lx is not %08lx\n",
- lqret[3],0x501c2c26L);
+ (unsigned long)lqret[3],0x501c2c26L);
err=1;
}
@@ -661,9 +668,7 @@ char *argv[];
}
printf("\n");
exit(err);
-#ifdef LINT
return(0);
-#endif
}
static char *pt(p)
@@ -693,7 +698,7 @@ unsigned char *cfb_cipher;
des_key_schedule ks;
int i,err=0;
- key_sched((C_Block *)cfb_key,ks);
+ des_key_sched((C_Block *)cfb_key,ks);
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
des_cfb_encrypt(plain,cfb_buf1,bits,(long)sizeof(plain),ks,
(C_Block *)cfb_tmp,DES_ENCRYPT);
@@ -723,7 +728,7 @@ unsigned char *cfb_cipher;
des_key_schedule ks;
int err=0,i,n;
- key_sched((C_Block *)cfb_key,ks);
+ des_key_sched((C_Block *)cfb_key,ks);
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
n=0;
des_cfb64_encrypt(plain,cfb_buf1,(long)12,ks,
@@ -761,7 +766,7 @@ unsigned char *cfb_cipher;
des_key_schedule ks;
int err=0,i,n;
- key_sched((C_Block *)cfb_key,ks);
+ des_key_sched((C_Block *)cfb_key,ks);
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
n=0;
des_ede3_cfb64_encrypt(plain,cfb_buf1,(long)12,ks,ks,ks,
diff --git a/secure/lib/libdes/ecb3_enc.c b/secure/lib/libdes/ecb3_enc.c
index ca0ac17..030770c 100644
--- a/secure/lib/libdes/ecb3_enc.c
+++ b/secure/lib/libdes/ecb3_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/ecb3_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/ecb3_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -55,9 +55,9 @@ des_key_schedule ks2;
des_key_schedule ks3;
int encrypt;
{
- register unsigned long l0,l1;
+ register DES_LONG l0,l1;
register unsigned char *in,*out;
- unsigned long ll[2];
+ DES_LONG ll[2];
in=(unsigned char *)input;
out=(unsigned char *)output;
diff --git a/secure/lib/libdes/ecb_enc.c b/secure/lib/libdes/ecb_enc.c
index d7eaa96..a39c6ed 100644
--- a/secure/lib/libdes/ecb_enc.c
+++ b/secure/lib/libdes/ecb_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/ecb_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/ecb_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -48,7 +48,24 @@
#include "des_locl.h"
#include "spr.h"
-const char *DES_version="libdes v 3.22 - 95/11/29 - eay";
+char *libdes_version="libdes v 3.24 - 20-Apr-1996 - eay";
+char *DES_version="DES part of SSLeay 0.6.1 12-Jul-1996";
+
+char *des_options()
+ {
+#ifdef DES_PTR
+ if (sizeof(DES_LONG) != sizeof(long))
+ return("des(ptr,int)");
+ else
+ return("des(ptr,long)");
+#else
+ if (sizeof(DES_LONG) != sizeof(long))
+ return("des(idx,int)");
+ else
+ return("des(idx,long)");
+#endif
+ }
+
void des_ecb_encrypt(input, output, ks, encrypt)
des_cblock (*input);
@@ -56,38 +73,38 @@ des_cblock (*output);
des_key_schedule ks;
int encrypt;
{
- register unsigned long l0,l1;
+ register DES_LONG l;
register unsigned char *in,*out;
- unsigned long ll[2];
+ DES_LONG ll[2];
in=(unsigned char *)input;
out=(unsigned char *)output;
- c2l(in,l0); ll[0]=l0;
- c2l(in,l1); ll[1]=l1;
+ c2l(in,l); ll[0]=l;
+ c2l(in,l); ll[1]=l;
des_encrypt(ll,ks,encrypt);
- l0=ll[0]; l2c(l0,out);
- l1=ll[1]; l2c(l1,out);
- l0=l1=ll[0]=ll[1]=0;
+ l=ll[0]; l2c(l,out);
+ l=ll[1]; l2c(l,out);
+ l=ll[0]=ll[1]=0;
}
void des_encrypt(data, ks, encrypt)
-unsigned long *data;
+DES_LONG *data;
des_key_schedule ks;
int encrypt;
{
- register unsigned long l,r,t,u;
-#ifdef DES_USE_PTR
+ register DES_LONG l,r,t,u;
+#ifdef DES_PTR
register unsigned char *des_SP=(unsigned char *)des_SPtrans;
#endif
-#ifdef MSDOS
+#ifdef undef
union fudge {
- unsigned long l;
+ DES_LONG l;
unsigned short s[2];
unsigned char c[4];
} U,T;
#endif
register int i;
- register unsigned long *s;
+ register DES_LONG *s;
u=data[0];
r=data[1];
@@ -106,23 +123,28 @@ int encrypt;
l&=0xffffffffL;
r&=0xffffffffL;
- s=(unsigned long *)ks;
+ s=(DES_LONG *)ks;
/* I don't know if it is worth the effort of loop unrolling the
- * inner loop */
+ * inner loop
+ */
if (encrypt)
{
- for (i=0; i<32; i+=4)
+ for (i=0; i<32; i+=8)
{
D_ENCRYPT(l,r,i+0); /* 1 */
D_ENCRYPT(r,l,i+2); /* 2 */
+ D_ENCRYPT(l,r,i+4); /* 3 */
+ D_ENCRYPT(r,l,i+6); /* 4 */
}
}
else
{
- for (i=30; i>0; i-=4)
+ for (i=30; i>0; i-=8)
{
D_ENCRYPT(l,r,i-0); /* 16 */
D_ENCRYPT(r,l,i-2); /* 15 */
+ D_ENCRYPT(l,r,i-4); /* 14 */
+ D_ENCRYPT(r,l,i-6); /* 13 */
}
}
l=(l>>1)|(l<<31);
@@ -138,23 +160,23 @@ int encrypt;
}
void des_encrypt2(data, ks, encrypt)
-unsigned long *data;
+DES_LONG *data;
des_key_schedule ks;
int encrypt;
{
- register unsigned long l,r,t,u;
-#ifdef DES_USE_PTR
+ register DES_LONG l,r,t,u;
+#ifdef DES_PTR
register unsigned char *des_SP=(unsigned char *)des_SPtrans;
#endif
-#ifdef MSDOS
+#ifdef undef
union fudge {
- unsigned long l;
+ DES_LONG l;
unsigned short s[2];
unsigned char c[4];
} U,T;
#endif
register int i;
- register unsigned long *s;
+ register DES_LONG *s;
u=data[0];
r=data[1];
@@ -172,23 +194,27 @@ int encrypt;
l&=0xffffffffL;
r&=0xffffffffL;
- s=(unsigned long *)ks;
+ s=(DES_LONG *)ks;
/* I don't know if it is worth the effort of loop unrolling the
* inner loop */
if (encrypt)
{
- for (i=0; i<32; i+=4)
+ for (i=0; i<32; i+=8)
{
D_ENCRYPT(l,r,i+0); /* 1 */
D_ENCRYPT(r,l,i+2); /* 2 */
+ D_ENCRYPT(l,r,i+4); /* 3 */
+ D_ENCRYPT(r,l,i+6); /* 4 */
}
}
else
{
- for (i=30; i>0; i-=4)
+ for (i=30; i>0; i-=8)
{
D_ENCRYPT(l,r,i-0); /* 16 */
D_ENCRYPT(r,l,i-2); /* 15 */
+ D_ENCRYPT(l,r,i-4); /* 14 */
+ D_ENCRYPT(r,l,i-6); /* 13 */
}
}
l=(l>>1)|(l<<31);
diff --git a/secure/lib/libdes/ede_enc.c b/secure/lib/libdes/ede_enc.c
index 5084e94..c8a9e80 100644
--- a/secure/lib/libdes/ede_enc.c
+++ b/secure/lib/libdes/ede_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/ede_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/ede_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -57,11 +57,11 @@ des_key_schedule ks3;
des_cblock (*ivec);
int encrypt;
{
- register unsigned long tin0,tin1;
- register unsigned long tout0,tout1,xor0,xor1;
+ register DES_LONG tin0,tin1;
+ register DES_LONG tout0,tout1,xor0,xor1;
register unsigned char *in,*out;
register long l=length;
- unsigned long tin[2];
+ DES_LONG tin[2];
unsigned char *iv;
in=(unsigned char *)input;
@@ -88,9 +88,9 @@ int encrypt;
tin[0]=tin0;
tin[1]=tin1;
- des_encrypt2((unsigned long *)tin,ks1,DES_ENCRYPT);
- des_encrypt2((unsigned long *)tin,ks2,DES_DECRYPT);
- des_encrypt2((unsigned long *)tin,ks3,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)tin,ks1,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)tin,ks2,DES_DECRYPT);
+ des_encrypt2((DES_LONG *)tin,ks3,DES_ENCRYPT);
tout0=tin[0];
tout1=tin[1];
@@ -109,7 +109,7 @@ int encrypt;
c2l(iv,xor1);
for (; l>0; l-=8)
{
- register unsigned long t0,t1;
+ register DES_LONG t0,t1;
c2l(in,tin0);
c2l(in,tin1);
@@ -120,9 +120,9 @@ int encrypt;
tin[0]=tin0;
tin[1]=tin1;
- des_encrypt2((unsigned long *)tin,ks3,DES_DECRYPT);
- des_encrypt2((unsigned long *)tin,ks2,DES_ENCRYPT);
- des_encrypt2((unsigned long *)tin,ks1,DES_DECRYPT);
+ des_encrypt2((DES_LONG *)tin,ks3,DES_DECRYPT);
+ des_encrypt2((DES_LONG *)tin,ks2,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)tin,ks1,DES_DECRYPT);
tout0=tin[0];
tout1=tin[1];
diff --git a/secure/lib/libdes/enc_read.c b/secure/lib/libdes/enc_read.c
index 11a6c5a..00989d2 100644
--- a/secure/lib/libdes/enc_read.c
+++ b/secure/lib/libdes/enc_read.c
@@ -1,5 +1,5 @@
-/* lib/des/enc_read.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/enc_read.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -50,7 +50,7 @@
#include "des_locl.h"
/* This has some uglies in it but it works - even over sockets. */
-extern int errno;
+/*extern int errno;*/
int des_rw_mode=DES_PCBC_MODE;
int des_enc_read(fd, buf, len, sched, iv)
@@ -62,17 +62,33 @@ des_cblock (*iv);
{
/* data to be unencrypted */
int net_num=0;
- unsigned char net[BSIZE];
+ static unsigned char *net=NULL;
/* extra unencrypted data
* for when a block of 100 comes in but is des_read one byte at
* a time. */
- static char unnet[BSIZE];
+ static char *unnet=NULL;
static int unnet_start=0;
static int unnet_left=0;
+ static char *tmpbuf=NULL;
int i;
long num=0,rnum;
unsigned char *p;
+ if (tmpbuf == NULL)
+ {
+ tmpbuf=(char *)malloc(BSIZE);
+ if (tmpbuf == NULL) return(-1);
+ }
+ if (net == NULL)
+ {
+ net=(unsigned char *)malloc(BSIZE);
+ if (net == NULL) return(-1);
+ }
+ if (unnet == NULL)
+ {
+ unnet=(char *)malloc(BSIZE);
+ if (unnet == NULL) return(-1);
+ }
/* left over data from last decrypt */
if (unnet_left != 0)
{
@@ -102,7 +118,6 @@ des_cblock (*iv);
if (len > MAXWRITE) len=MAXWRITE;
/* first - get the length */
- net_num=0;
while (net_num < HDRSIZE)
{
i=read(fd,&(net[net_num]),(unsigned int)HDRSIZE-net_num);
@@ -113,7 +128,7 @@ des_cblock (*iv);
/* we now have at net_num bytes in net */
p=net;
- num=0;
+ /* num=0; */
n2l(p,num);
/* num should be rounded up to the next group of eight
* we make sure that we have read a multiple of 8 bytes from the net.
@@ -135,14 +150,14 @@ des_cblock (*iv);
if (len < num)
{
if (des_rw_mode & DES_PCBC_MODE)
- pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
+ des_pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
num,sched,iv,DES_DECRYPT);
else
- cbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
+ des_cbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
num,sched,iv,DES_DECRYPT);
memcpy(buf,unnet,(unsigned int)len);
unnet_start=len;
- unnet_left=num-len;
+ unnet_left=(int)num-len;
/* The following line is done because we return num
* as the number of bytes read. */
@@ -157,14 +172,13 @@ des_cblock (*iv);
* FIXED - Should be ok now 18-9-90 - eay */
if (len < rnum)
{
- char tmpbuf[BSIZE];
if (des_rw_mode & DES_PCBC_MODE)
- pcbc_encrypt((des_cblock *)net,
+ des_pcbc_encrypt((des_cblock *)net,
(des_cblock *)tmpbuf,
num,sched,iv,DES_DECRYPT);
else
- cbc_encrypt((des_cblock *)net,
+ des_cbc_encrypt((des_cblock *)net,
(des_cblock *)tmpbuf,
num,sched,iv,DES_DECRYPT);
@@ -175,15 +189,15 @@ des_cblock (*iv);
else
{
if (des_rw_mode & DES_PCBC_MODE)
- pcbc_encrypt((des_cblock *)net,
+ des_pcbc_encrypt((des_cblock *)net,
(des_cblock *)buf,num,sched,iv,
DES_DECRYPT);
else
- cbc_encrypt((des_cblock *)net,
+ des_cbc_encrypt((des_cblock *)net,
(des_cblock *)buf,num,sched,iv,
DES_DECRYPT);
}
}
- return(num);
+ return((int)num);
}
diff --git a/secure/lib/libdes/enc_writ.c b/secure/lib/libdes/enc_writ.c
index e0d5075..0b7a50b 100644
--- a/secure/lib/libdes/enc_writ.c
+++ b/secure/lib/libdes/enc_writ.c
@@ -1,5 +1,5 @@
-/* lib/des/enc_writ.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/enc_writ.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -65,11 +65,16 @@ des_cblock (*iv);
long rnum;
int i,j,k,outnum;
- char outbuf[BSIZE+HDRSIZE];
+ char *outbuf=NULL;
char shortbuf[8];
char *p;
static int start=1;
+ if (outbuf == NULL)
+ {
+ outbuf=(char *)malloc(BSIZE+HDRSIZE);
+ if (outbuf == NULL) return(-1);
+ }
/* If we are sending less than 8 bytes, the same char will look
* the same if we don't pad it out with random bytes */
if (start)
@@ -114,14 +119,16 @@ des_cblock (*iv);
}
if (des_rw_mode & DES_PCBC_MODE)
- pcbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]),
+ des_pcbc_encrypt((des_cblock *)p,
+ (des_cblock *)&(outbuf[HDRSIZE]),
(long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
else
- cbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]),
+ des_cbc_encrypt((des_cblock *)p,
+ (des_cblock *)&(outbuf[HDRSIZE]),
(long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
/* output */
- outnum=rnum+HDRSIZE;
+ outnum=(int)rnum+HDRSIZE;
for (j=0; j<outnum; j+=i)
{
diff --git a/secure/lib/libdes/fcrypt.c b/secure/lib/libdes/fcrypt.c
index 71960b6..85080ea 100644
--- a/secure/lib/libdes/fcrypt.c
+++ b/secure/lib/libdes/fcrypt.c
@@ -1,5 +1,5 @@
-/* lib/des/fcrypt.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/fcrypt.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -54,41 +54,29 @@
* eay@mincom.oz.au or eay@psych.psy.uq.oz.au
*/
-#if !defined(_LIBC) || defined(NOCONST)
+#ifndef HEADER_DES_LOCL_H
+
+#if defined(NOCONST)
#define const
#endif
-typedef unsigned char des_cblock[8];
-
-typedef struct des_ks_struct
- {
- union {
- des_cblock _;
- /* make sure things are correct size on machines with
- * 8 byte longs */
- unsigned long pad[2];
- } ks;
-#define _ ks._
- } des_key_schedule[16];
-
-#define DES_KEY_SZ (sizeof(des_cblock))
-#define DES_ENCRYPT 1
-#define DES_DECRYPT 0
+/* I now assume that you have des.h available */
+#include "des.h"
#define ITERATIONS 16
#define HALF_ITERATIONS 8
-#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
- l|=((unsigned long)(*((c)++)))<< 8, \
- l|=((unsigned long)(*((c)++)))<<16, \
- l|=((unsigned long)(*((c)++)))<<24)
+#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
+ l|=((DES_LONG)(*((c)++)))<< 8, \
+ l|=((DES_LONG)(*((c)++)))<<16, \
+ l|=((DES_LONG)(*((c)++)))<<24)
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
*((c)++)=(unsigned char)(((l)>>24)&0xff))
-static const unsigned long SPtrans[8][64]={
+static const DES_LONG des_SPtrans[8][64]={
{
/* nibble 0 */
0x00820200L, 0x00020000L, 0x80800000L, 0x80820200L,
@@ -233,7 +221,7 @@ static const unsigned long SPtrans[8][64]={
0x00208000L, 0x00008020L, 0x08008020L, 0x08200000L,
0x00000020L, 0x08208000L, 0x00208020L, 0x00000000L,
0x08000000L, 0x08200020L, 0x00008000L, 0x00208020L}};
-static const unsigned long skb[8][64]={
+static const DES_LONG skb[8][64]={
{
/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000L,0x00000010L,0x20000000L,0x20000010L,
@@ -388,27 +376,37 @@ static const unsigned long skb[8][64]={
#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
(a)=(a)^(t)^(t>>(16-(n))))\
-static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
+#endif
#ifndef NOPROTO
-static int body(unsigned long *out0, unsigned long *out1,
- des_key_schedule ks, unsigned long Eswap0, unsigned long Eswap1);
-static int des_set_key(des_cblock (*key), des_key_schedule schedule);
+static int body(DES_LONG *out0, DES_LONG *out1,
+ des_key_schedule ks, DES_LONG Eswap0, DES_LONG Eswap1);
+#ifndef HEADER_DES_LOCL_H
+static int fcrypt_set_key(des_cblock (*key), des_key_schedule schedule);
+#endif
+
#else
+
static int body();
-static int des_set_key();
+#ifndef HEADER_DES_LOCL_H
+static int fcrypt_set_key();
+#endif
#endif
-static int des_set_key(key, schedule)
+#ifdef HEADER_DES_LOCL_H
+#define fcrypt_set_key(a,b) des_set_key(a,b)
+#else
+static int fcrypt_set_key(key, schedule)
des_cblock (*key);
des_key_schedule schedule;
{
- register unsigned long c,d,t,s;
+ static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
+ register DES_LONG c,d,t,s;
register unsigned char *in;
- register unsigned long *k;
+ register DES_LONG *k;
register int i;
- k=(unsigned long *)schedule;
+ k=(DES_LONG *)schedule;
in=(unsigned char *)key;
c2l(in,c);
@@ -456,6 +454,7 @@ des_key_schedule schedule;
}
return(0);
}
+#endif
/******************************************************************
* modified stuff for crypt.
@@ -466,8 +465,8 @@ des_key_schedule schedule;
* Inspired by Dana How <how@isl.stanford.edu>
* DO NOT use the alternative version on machines with 8 byte longs.
*/
-#ifdef DES_USE_PTR
-#define D_ENCRYPT(L,R,S) \
+#ifdef DES_PTR
+#define CR_ENCRYPT(L,R,S) \
t=(R^(R>>16)); \
u=(t&E0); \
t=(t&E1); \
@@ -475,39 +474,43 @@ des_key_schedule schedule;
t=(t^(t<<16))^R^s[S+1]; \
t=(t>>2)|(t<<30); \
L^= \
- *(unsigned long *)(des_SP+0x0100+((t )&0xfc))+ \
- *(unsigned long *)(des_SP+0x0300+((t>> 8)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0500+((t>>16)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0700+((t>>24)&0xfc))+ \
- *(unsigned long *)(des_SP+ ((u )&0xfc))+ \
- *(unsigned long *)(des_SP+0x0200+((u>> 8)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0400+((u>>16)&0xfc))+ \
- *(unsigned long *)(des_SP+0x0600+((u>>24)&0xfc));
+ *(DES_LONG *)((unsigned char *)des_SP+0x0100+((t )&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x0300+((t>> 8)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x0500+((t>>16)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x0700+((t>>24)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+ ((u )&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x0200+((u>> 8)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x0400+((u>>16)&0xfc))+ \
+ *(DES_LONG *)((unsigned char *)des_SP+0x0600+((u>>24)&0xfc));
#else /* original version */
-#define D_ENCRYPT(L,R,S) \
+#define CR_ENCRYPT(L,R,S) \
t=(R^(R>>16)); \
u=(t&E0); \
t=(t&E1); \
u=(u^(u<<16))^R^s[S ]; \
t=(t^(t<<16))^R^s[S+1]; \
t=(t>>4)|(t<<28); \
- L^= SPtrans[1][(t )&0x3f]| \
- SPtrans[3][(t>> 8)&0x3f]| \
- SPtrans[5][(t>>16)&0x3f]| \
- SPtrans[7][(t>>24)&0x3f]| \
- SPtrans[0][(u )&0x3f]| \
- SPtrans[2][(u>> 8)&0x3f]| \
- SPtrans[4][(u>>16)&0x3f]| \
- SPtrans[6][(u>>24)&0x3f];
+ L^= des_SPtrans[1][(t )&0x3f]| \
+ des_SPtrans[3][(t>> 8)&0x3f]| \
+ des_SPtrans[5][(t>>16)&0x3f]| \
+ des_SPtrans[7][(t>>24)&0x3f]| \
+ des_SPtrans[0][(u )&0x3f]| \
+ des_SPtrans[2][(u>> 8)&0x3f]| \
+ des_SPtrans[4][(u>>16)&0x3f]| \
+ des_SPtrans[6][(u>>24)&0x3f];
#endif
+/* Added more values to handle illegal salt values the way normal
+ * crypt() implementations do. The patch was sent by
+ * Bjorn Gronvall <bg@sics.se>
+ */
static unsigned const char con_salt[128]={
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
+0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,
+0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1,
+0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,
+0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,
+0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,
+0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x00,0x01,
0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
0x0A,0x0B,0x05,0x06,0x07,0x08,0x09,0x0A,
0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,
@@ -517,7 +520,7 @@ static unsigned const char con_salt[128]={
0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,
0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,
0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,
-0x3D,0x3E,0x3F,0x00,0x00,0x00,0x00,0x00,
+0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44,
};
static unsigned const char cov_2char[64]={
@@ -535,7 +538,7 @@ static unsigned const char cov_2char[64]={
#ifdef PERL5
char *des_crypt(char *buf,char *salt);
#else
-char *crypt(char *buf,char *salt);
+char *crypt(const char *buf,const char *salt);
#endif
#else
#ifdef PERL5
@@ -550,12 +553,12 @@ char *des_crypt(buf,salt)
#else
char *crypt(buf,salt)
#endif
-char *buf;
-char *salt;
+const char *buf;
+const char *salt;
{
unsigned int i,j,x,y;
- unsigned long Eswap0=0,Eswap1=0;
- unsigned long out[2],ll;
+ DES_LONG Eswap0,Eswap1;
+ DES_LONG out[2],ll;
des_cblock key;
des_key_schedule ks;
static unsigned char buff[20];
@@ -585,7 +588,7 @@ char *salt;
for (; i<8; i++)
key[i]=0;
- des_set_key((des_cblock *)(key),ks);
+ fcrypt_set_key((des_cblock *)(key),ks);
body(&(out[0]),&(out[1]),ks,Eswap0,Eswap1);
ll=out[0]; l2c(ll,b);
@@ -614,24 +617,24 @@ char *salt;
}
static int body(out0, out1, ks, Eswap0, Eswap1)
-unsigned long *out0;
-unsigned long *out1;
+DES_LONG *out0;
+DES_LONG *out1;
des_key_schedule ks;
-unsigned long Eswap0;
-unsigned long Eswap1;
+DES_LONG Eswap0;
+DES_LONG Eswap1;
{
- register unsigned long l,r,t,u;
-#ifdef DES_USE_PTR
- register unsigned char *des_SP=(unsigned char *)SPtrans;
+ register DES_LONG l,r,t,u;
+#ifdef DES_PTR
+ register unsigned char *des_SP=(unsigned char *)des_SPtrans;
#endif
- register unsigned long *s;
+ register DES_LONG *s;
register int i,j;
- register unsigned long E0,E1;
+ register DES_LONG E0,E1;
l=0;
r=0;
- s=(unsigned long *)ks;
+ s=(DES_LONG *)ks;
E0=Eswap0;
E1=Eswap1;
@@ -639,8 +642,8 @@ unsigned long Eswap1;
{
for (i=0; i<(ITERATIONS*2); i+=4)
{
- D_ENCRYPT(l,r, i); /* 1 */
- D_ENCRYPT(r,l, i+2); /* 2 */
+ CR_ENCRYPT(l,r, i); /* 1 */
+ CR_ENCRYPT(r,l, i+2); /* 2 */
}
t=l;
l=r;
diff --git a/secure/lib/libdes/ncbc_enc.c b/secure/lib/libdes/ncbc_enc.c
index d307ae4..4595dcb 100644
--- a/secure/lib/libdes/ncbc_enc.c
+++ b/secure/lib/libdes/ncbc_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/ncbc_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/ncbc_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -55,11 +55,11 @@ des_key_schedule schedule;
des_cblock (*ivec);
int encrypt;
{
- register unsigned long tin0,tin1;
- register unsigned long tout0,tout1,xor0,xor1;
+ register DES_LONG tin0,tin1;
+ register DES_LONG tout0,tout1,xor0,xor1;
register unsigned char *in,*out;
register long l=length;
- unsigned long tin[2];
+ DES_LONG tin[2];
unsigned char *iv;
in=(unsigned char *)input;
@@ -81,7 +81,7 @@ int encrypt;
c2ln(in,tin0,tin1,l);
tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1;
- des_encrypt((unsigned long *)tin,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
tout0=tin[0]; l2c(tout0,out);
tout1=tin[1]; l2c(tout1,out);
}
@@ -97,7 +97,7 @@ int encrypt;
{
c2l(in,tin0); tin[0]=tin0;
c2l(in,tin1); tin[1]=tin1;
- des_encrypt((unsigned long *)tin,schedule,DES_DECRYPT);
+ des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0;
tout1=tin[1]^xor1;
if (l >= 8)
diff --git a/secure/lib/libdes/new_rkey.c b/secure/lib/libdes/new_rkey.c
index 65aa056..cfad517 100644
--- a/secure/lib/libdes/new_rkey.c
+++ b/secure/lib/libdes/new_rkey.c
@@ -1,5 +1,5 @@
-/* lib/des/new_rkey.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/new_rkey.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -84,7 +84,7 @@
* few changes since it need to compile on all version of unix and
* there were a few things that would not :-) */
-#incldue <stdio.h>
+#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/param.h>
@@ -95,7 +95,7 @@
/* This counter keeps track of the pseudo-random sequence */
static union {
- unsigned long ul0, ul1;
+ DES_LONG ul0, ul1;
unsigned char uc[8];
} counter;
diff --git a/secure/lib/libdes/ofb64ede.c b/secure/lib/libdes/ofb64ede.c
index 3868e76..8923b5f 100644
--- a/secure/lib/libdes/ofb64ede.c
+++ b/secure/lib/libdes/ofb64ede.c
@@ -1,5 +1,5 @@
-/* lib/des/ofb64ede.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/ofb64ede.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -59,12 +59,12 @@ des_key_schedule k1,k2,k3;
des_cblock (*ivec);
int *num;
{
- register unsigned long v0,v1;
+ register DES_LONG v0,v1;
register int n=*num;
register long l=length;
des_cblock d;
register char *dp;
- unsigned long ti[2];
+ DES_LONG ti[2];
unsigned char *iv;
int save=0;
@@ -84,9 +84,9 @@ int *num;
ti[0]=v0;
ti[1]=v1;
- des_encrypt2((unsigned long *)ti,k1,DES_ENCRYPT);
- des_encrypt2((unsigned long *)ti,k2,DES_DECRYPT);
- des_encrypt2((unsigned long *)ti,k3,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)ti,k1,DES_ENCRYPT);
+ des_encrypt2((DES_LONG *)ti,k2,DES_DECRYPT);
+ des_encrypt2((DES_LONG *)ti,k3,DES_ENCRYPT);
v0=ti[0];
v1=ti[1];
diff --git a/secure/lib/libdes/ofb64enc.c b/secure/lib/libdes/ofb64enc.c
index bc8dd8c..bb4937a 100644
--- a/secure/lib/libdes/ofb64enc.c
+++ b/secure/lib/libdes/ofb64enc.c
@@ -1,5 +1,5 @@
-/* lib/des/ofb64enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/ofb64enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -59,12 +59,12 @@ des_key_schedule schedule;
des_cblock (*ivec);
int *num;
{
- register unsigned long v0,v1,t;
+ register DES_LONG v0,v1,t;
register int n=*num;
register long l=length;
des_cblock d;
register char *dp;
- unsigned long ti[2];
+ DES_LONG ti[2];
unsigned char *iv;
int save=0;
@@ -80,7 +80,7 @@ int *num;
{
if (n == 0)
{
- des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
dp=(char *)d;
t=ti[0]; l2c(t,dp);
t=ti[1]; l2c(t,dp);
diff --git a/secure/lib/libdes/ofb_enc.c b/secure/lib/libdes/ofb_enc.c
index e95cadd..27b3691 100644
--- a/secure/lib/libdes/ofb_enc.c
+++ b/secure/lib/libdes/ofb_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/ofb_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/ofb_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -61,11 +61,11 @@ long length;
des_key_schedule schedule;
des_cblock (*ivec);
{
- register unsigned long d0,d1,v0,v1,n=(numbits+7)/8;
- register unsigned long mask0,mask1;
+ register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
+ register DES_LONG mask0,mask1;
register long l=length;
register int num=numbits;
- unsigned long ti[2];
+ DES_LONG ti[2];
unsigned char *iv;
if (num > 64) return;
@@ -93,7 +93,7 @@ des_cblock (*ivec);
ti[1]=v1;
while (l-- > 0)
{
- des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n);
in+=n;
d0=(d0^ti[0])&mask0;
diff --git a/secure/lib/libdes/pcbc_enc.c b/secure/lib/libdes/pcbc_enc.c
index b17a6d7..1271d02 100644
--- a/secure/lib/libdes/pcbc_enc.c
+++ b/secure/lib/libdes/pcbc_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/pcbc_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/pcbc_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -55,8 +55,8 @@ des_key_schedule schedule;
des_cblock (*ivec);
int encrypt;
{
- register unsigned long sin0,sin1,xor0,xor1,tout0,tout1;
- unsigned long tin[2];
+ register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;
+ DES_LONG tin[2];
unsigned char *in,*out,*iv;
in=(unsigned char *)input;
@@ -78,7 +78,7 @@ int encrypt;
c2ln(in,sin0,sin1,length);
tin[0]=sin0^xor0;
tin[1]=sin1^xor1;
- des_encrypt((unsigned long *)tin,schedule,DES_ENCRYPT);
+ des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
tout0=tin[0];
tout1=tin[1];
xor0=sin0^tout0;
@@ -96,7 +96,7 @@ int encrypt;
c2l(in,sin1);
tin[0]=sin0;
tin[1]=sin1;
- des_encrypt((unsigned long *)tin,schedule,DES_DECRYPT);
+ des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0;
tout1=tin[1]^xor1;
if (length >= 8)
diff --git a/secure/lib/libdes/podd.h b/secure/lib/libdes/podd.h
index 96846d2..420fc43 100644
--- a/secure/lib/libdes/podd.h
+++ b/secure/lib/libdes/podd.h
@@ -1,5 +1,5 @@
-/* lib/des/podd.h */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/podd.h */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
diff --git a/secure/lib/libdes/qud_cksm.c b/secure/lib/libdes/qud_cksm.c
index e2c6ffd..dc74c94 100644
--- a/secure/lib/libdes/qud_cksm.c
+++ b/secure/lib/libdes/qud_cksm.c
@@ -1,5 +1,5 @@
-/* lib/des/qud_cksm.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/qud_cksm.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -53,33 +53,33 @@
#include "des_locl.h"
/* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */
-#define B0(a) (((unsigned long)(a)))
-#define B1(a) (((unsigned long)(a))<<8)
-#define B2(a) (((unsigned long)(a))<<16)
-#define B3(a) (((unsigned long)(a))<<24)
+#define Q_B0(a) (((DES_LONG)(a)))
+#define Q_B1(a) (((DES_LONG)(a))<<8)
+#define Q_B2(a) (((DES_LONG)(a))<<16)
+#define Q_B3(a) (((DES_LONG)(a))<<24)
/* used to scramble things a bit */
/* Got the value MIT uses via brute force :-) 2/10/90 eay */
-#define NOISE ((unsigned long)83653421L)
+#define NOISE ((DES_LONG)83653421L)
-unsigned long des_quad_cksum(input, output, length, out_count, seed)
+DES_LONG des_quad_cksum(input, output, length, out_count, seed)
des_cblock (*input);
des_cblock (*output);
long length;
int out_count;
des_cblock (*seed);
{
- unsigned long z0,z1,t0,t1;
+ DES_LONG z0,z1,t0,t1;
int i;
- long l=0;
+ long l;
unsigned char *cp;
unsigned char *lp;
if (out_count < 1) out_count=1;
lp=(unsigned char *)output;
- z0=B0((*seed)[0])|B1((*seed)[1])|B2((*seed)[2])|B3((*seed)[3]);
- z1=B0((*seed)[4])|B1((*seed)[5])|B2((*seed)[6])|B3((*seed)[7]);
+ z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]);
+ z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]);
for (i=0; ((i<4)&&(i<out_count)); i++)
{
@@ -89,12 +89,12 @@ des_cblock (*seed);
{
if (l > 1)
{
- t0= (unsigned long)(*(cp++));
- t0|=(unsigned long)B1(*(cp++));
+ t0= (DES_LONG)(*(cp++));
+ t0|=(DES_LONG)Q_B1(*(cp++));
l--;
}
else
- t0= (unsigned long)(*(cp++));
+ t0= (DES_LONG)(*(cp++));
l--;
/* add */
t0+=z0;
@@ -112,7 +112,7 @@ des_cblock (*seed);
* is one huge number and it is returned in a
* host dependant byte order.
*/
- static unsigned long ltmp=1;
+ static DES_LONG ltmp=1;
static unsigned char *c=(unsigned char *)&ltmp;
if (c[0])
diff --git a/secure/lib/libdes/rand_key.c b/secure/lib/libdes/rand_key.c
index c4c4caa..4d20201 100644
--- a/secure/lib/libdes/rand_key.c
+++ b/secure/lib/libdes/rand_key.c
@@ -1,5 +1,5 @@
-/* lib/des/rand_key.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/rand_key.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -62,12 +62,12 @@ void des_random_key(ret)
unsigned char *ret;
{
des_key_schedule ks;
- static unsigned long c=0;
+ static DES_LONG c=0;
static unsigned short pid=0;
static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
des_cblock key;
unsigned char *p;
- unsigned long t;
+ DES_LONG t;
int i;
#ifdef MSDOS
@@ -85,9 +85,9 @@ unsigned char *ret;
}
seed=0;
}
- t=(unsigned long)time(NULL);
+ t=(DES_LONG)time(NULL);
l2c(t,p);
- t=(unsigned long)((pid)|((c++)<<16));
+ t=(DES_LONG)((pid)|((c++)<<16));
l2c(t,p);
des_set_odd_parity((des_cblock *)data);
diff --git a/secure/lib/libdes/read_pwd.c b/secure/lib/libdes/read_pwd.c
index bebad0c..275f732 100644
--- a/secure/lib/libdes/read_pwd.c
+++ b/secure/lib/libdes/read_pwd.c
@@ -1,5 +1,5 @@
-/* lib/des/read_pwd.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/read_pwd.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -45,6 +45,12 @@
* [including the GNU Public Licence.]
*/
+#ifdef WIN16TTY
+#undef WIN16
+#undef _WINDOWS
+#include <graph.h>
+#endif
+
/* 06-Apr-92 Luke Brennan Support for VMS */
#include "des_locl.h"
#include <signal.h>
@@ -55,12 +61,18 @@
* TERMIO, TERMIOS, VMS, MSDOS and SGTTY
*/
-#if defined(sgi) || defined(__sgi)
+#if defined(__sgi) && !defined(TERMIOS)
#define TERMIOS
#undef TERMIO
#undef SGTTY
#endif
+#if defined(linux) && !defined(TERMIO)
+#undef TERMIOS
+#define TERMIO
+#undef SGTTY
+#endif
+
#ifdef _LIBC
#define TERMIO
#endif
@@ -93,7 +105,7 @@
#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
#endif
-#ifndef _LIBC
+#if !defined(_LIBC) && !defined(MSDOS)
#include <sys/ioctl.h>
#endif
@@ -124,7 +136,7 @@ static int read_pw(char *buf, char *buff, int size, char *prompt, int verify);
static void recsig(int);
static void pushsig(void);
static void popsig(void);
-#ifdef MSDOS
+#if defined(MSDOS) && !defined(WIN16)
static int noecho_fgets(char *buf, int size, FILE *tty);
#endif
#else
@@ -133,12 +145,16 @@ static int read_pw();
static void recsig();
static void pushsig();
static void popsig();
-#ifdef MSDOS
+#if defined(MSDOS) && !defined(WIN16)
static int noecho_fgets();
#endif
#endif
+#ifndef NOPROTO
+static void (*savsig[NX509_SIG])(int );
+#else
static void (*savsig[NX509_SIG])();
+#endif
static jmp_buf save;
int des_read_password(key, prompt, verify)
@@ -186,6 +202,8 @@ int verify;
return(ret);
}
+#ifndef WIN16
+
static void read_till_nl(in)
FILE *in;
{
@@ -197,6 +215,7 @@ FILE *in;
} while (strchr(buf,'\n') == NULL);
}
+
/* return 0 if ok, 1 (or -1) otherwise */
static int read_pw(buf, buff, size, prompt, verify)
char *buf;
@@ -278,12 +297,13 @@ int verify;
buf[0]='\0';
fgets(buf,size,tty);
if (feof(tty)) goto error;
+ if (ferror(tty)) goto error;
if ((p=(char *)strchr(buf,'\n')) != NULL)
*p='\0';
else read_till_nl(tty);
if (verify)
{
- fprintf(stderr,"\nVerifying password %s",prompt);
+ fprintf(stderr,"\nVerifying password - %s",prompt);
fflush(stderr);
buff[0]='\0';
fgets(buff,size,tty);
@@ -305,6 +325,9 @@ int verify;
error:
fprintf(stderr,"\n");
+#ifdef DEBUG
+ perror("fgets(tty)");
+#endif
/* What can we do if there is an error? */
#if defined(TTY_set) && !defined(VMS)
if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
@@ -323,6 +346,22 @@ error:
return(!ok);
}
+#else /* WIN16 */
+
+static int read_pw(buf, buff, size, prompt, verify)
+char *buf;
+char *buff;
+int size;
+char *prompt;
+int verify;
+ {
+ memset(buf,0,size);
+ memset(buff,0,size);
+ return(0);
+ }
+
+#endif
+
static void pushsig()
{
int i;
@@ -348,13 +387,13 @@ int i;
#endif
}
-#ifdef MSDOS
+#if defined(MSDOS) && !defined(WIN16)
static int noecho_fgets(buf,size,tty)
char *buf;
int size;
FILE *tty;
{
- int i,n;
+ int i;
char *p;
p=buf;
@@ -366,7 +405,11 @@ FILE *tty;
break;
}
size--;
+#ifdef WIN16TTY
+ i=_inchar();
+#else
i=getch();
+#endif
if (i == '\r') i='\n';
*(p++)=i;
if (i == '\n')
diff --git a/secure/lib/libdes/rpc_des.h b/secure/lib/libdes/rpc_des.h
index e316b78..0b0bbf5 100644
--- a/secure/lib/libdes/rpc_des.h
+++ b/secure/lib/libdes/rpc_des.h
@@ -1,5 +1,5 @@
-/* lib/des/rpc_des.h */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/rpc_des.h */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -83,6 +83,11 @@
#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */
#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */
+#ifdef HEADER_DES_H
+#undef ENCRYPT
+#undef DECRYPT
+#endif
+
enum desdir { ENCRYPT, DECRYPT };
enum desmode { CBC, ECB };
diff --git a/secure/lib/libdes/rpc_enc.c b/secure/lib/libdes/rpc_enc.c
index b9b3898..d674865 100644
--- a/secure/lib/libdes/rpc_enc.c
+++ b/secure/lib/libdes/rpc_enc.c
@@ -1,5 +1,5 @@
-/* lib/des/rpc_enc.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/rpc_enc.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -47,7 +47,7 @@
#include "rpc_des.h"
#include "des_locl.h"
-#include "version.h"
+#include "des_ver.h"
#ifndef NOPROTO
int _des_crypt(char *buf,int len,struct desparams *desp);
@@ -60,7 +60,7 @@ char *buf;
int len;
struct desparams *desp;
{
- Key_schedule ks;
+ des_key_schedule ks;
int enc;
des_set_key((des_cblock *)desp->des_key,ks);
diff --git a/secure/lib/libdes/rpw.c b/secure/lib/libdes/rpw.c
index 2213a56..69c6b84 100644
--- a/secure/lib/libdes/rpw.c
+++ b/secure/lib/libdes/rpw.c
@@ -1,5 +1,5 @@
-/* lib/des/rpw.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/rpw.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
diff --git a/secure/lib/libdes/set_key.c b/secure/lib/libdes/set_key.c
index 209a07d..8365ee4 100644
--- a/secure/lib/libdes/set_key.c
+++ b/secure/lib/libdes/set_key.c
@@ -1,5 +1,5 @@
-/* lib/des/set_key.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/set_key.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -140,8 +140,6 @@ des_cblock (*key);
#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
(a)=(a)^(t)^(t>>(16-(n))))
-static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
-
/* return 0 if key parity is odd (correct),
* return -1 if key parity error,
* return -2 if illegal weak key.
@@ -150,9 +148,10 @@ int des_set_key(key, schedule)
des_cblock (*key);
des_key_schedule schedule;
{
- register unsigned long c,d,t,s;
+ static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
+ register DES_LONG c,d,t,s;
register unsigned char *in;
- register unsigned long *k;
+ register DES_LONG *k;
register int i;
if (des_check_key)
@@ -164,7 +163,7 @@ des_key_schedule schedule;
return(-2);
}
- k=(unsigned long *)schedule;
+ k=(DES_LONG *)schedule;
in=(unsigned char *)key;
c2l(in,c);
diff --git a/secure/lib/libdes/shifts.pl b/secure/lib/libdes/shifts.pl
index 3c4039e..2865f56 100755
--- a/secure/lib/libdes/shifts.pl
+++ b/secure/lib/libdes/shifts.pl
@@ -1,4 +1,4 @@
-sub lab_shift
+#!/usr/bin/perl
{
local(*a,$n)=@_;
local(@r,$i,$j,$k,$d,@z);
diff --git a/secure/lib/libdes/sk.h b/secure/lib/libdes/sk.h
index e5997d9..217c8ab 100644
--- a/secure/lib/libdes/sk.h
+++ b/secure/lib/libdes/sk.h
@@ -1,5 +1,5 @@
-/* lib/des/sk.h */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/sk.h */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -45,7 +45,7 @@
* [including the GNU Public Licence.]
*/
-static const unsigned long des_skb[8][64]={
+static const DES_LONG des_skb[8][64]={
{
/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000L,0x00000010L,0x20000000L,0x20000010L,
diff --git a/secure/lib/libdes/speed.c b/secure/lib/libdes/speed.c
index ee517b1..583c0a9 100644
--- a/secure/lib/libdes/speed.c
+++ b/secure/lib/libdes/speed.c
@@ -1,5 +1,5 @@
-/* lib/des/speed.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/speed.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -197,7 +197,7 @@ char **argv;
des_set_key((C_Block *)key3,sch3);
#ifndef SIGALRM
- printf("First we calculate the aproximate speed ...\n");
+ printf("First we calculate the approximate speed ...\n");
des_set_key((C_Block *)key,sch);
count=10;
do {
@@ -257,7 +257,7 @@ char **argv;
#endif
Time_F(START);
for (count=0,run=1; COND(cc); count++)
- des_cbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]),
+ des_ncbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]),
(C_Block *)&(key[0]),DES_ENCRYPT);
d=Time_F(STOP);
printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n",
diff --git a/secure/lib/libdes/spr.h b/secure/lib/libdes/spr.h
index d9b81ce..58cc130 100644
--- a/secure/lib/libdes/spr.h
+++ b/secure/lib/libdes/spr.h
@@ -1,5 +1,5 @@
-/* lib/des/spr.h */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/spr.h */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
@@ -45,7 +45,7 @@
* [including the GNU Public Licence.]
*/
-static const unsigned long des_SPtrans[8][64]={
+static const DES_LONG des_SPtrans[8][64]={
{
/* nibble 0 */
0x00820200L, 0x00020000L, 0x80800000L, 0x80820200L,
diff --git a/secure/lib/libdes/str2key.c b/secure/lib/libdes/str2key.c
index 278ba0f..af889d7 100644
--- a/secure/lib/libdes/str2key.c
+++ b/secure/lib/libdes/str2key.c
@@ -1,5 +1,5 @@
-/* lib/des/str2key.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/str2key.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
diff --git a/secure/lib/libdes/supp.c b/secure/lib/libdes/supp.c
index 8cd9289..0c959cc 100644
--- a/secure/lib/libdes/supp.c
+++ b/secure/lib/libdes/supp.c
@@ -1,5 +1,5 @@
-/* lib/des/supp.c */
-/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
+/* crypto/des/supp.c */
+/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This file is part of an SSL implementation written
diff --git a/secure/lib/libdes/testdes.pl b/secure/lib/libdes/testdes.pl
index 01a165a..67fbd47 100755
--- a/secure/lib/libdes/testdes.pl
+++ b/secure/lib/libdes/testdes.pl
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl
+#!/usr/bin/perl
# des.pl tesing code
diff --git a/secure/lib/libdes/times b/secure/lib/libdes/times
index 86d10a0..f5080ef 100644
--- a/secure/lib/libdes/times
+++ b/secure/lib/libdes/times
@@ -1,3 +1,32 @@
+existing library on a DEC 3000/500
+set_key per sec = 256294.06 ( 3.9uS)
+DES ecb bytes per sec = 3553694.40 ( 2.3uS)
+DES cbc bytes per sec = 3661004.80 ( 2.2uS)
+DES ede cbc bytes per sec = 1353115.99 ( 5.9uS)
+crypt per sec = 16829.40 ( 59.4uS)
+
+Intel P6/200 (NEXTSTEP) - cc -O3 (cc: gcc 2.5.8)
+set_key per sec = 219220.82 ( 4.6uS)
+DES ecb bytes per sec = 2438014.04 ( 3.3uS)
+DES cbc bytes per sec = 2467648.85 ( 3.2uS)
+DES ede cbc bytes per sec = 942121.58 ( 8.5uS)
+crypt per sec = 11398.73 ( 87.7uS)
+
+# DECstation Alpha 3000 Model 700 AXP / OSF1 V3.0
+# gcc 2.6.3 / Young libdes 3.21
+set_key per sec = 149369.74 ( 6.7uS)
+DES ecb bytes per sec = 2011976.68 ( 4.0uS)
+DES cbc bytes per sec = 2002245.35 ( 4.0uS)
+DES ede cbc bytes per sec = 793677.19 ( 10.1uS)
+crypt per sec = 9244.52 (108.2uS)
+
+# Sun Ultra I gcc 2.7.2 / Young libdes 3.21
+set_key per sec = 147172.22 ( 6.8uS)
+DES ecb bytes per sec = 1815054.70 ( 4.4uS)
+DES cbc bytes per sec = 1829405.18 ( 4.4uS)
+DES ede cbc bytes per sec = 714490.23 ( 11.2uS)
+crypt per sec = 8896.24 (112.4uS)
+
SGI Challenge (MIPS R4400 200mhz) - gcc -O2
set_key per sec = 114141.13 ( 8.8uS)
DES ecb bytes per sec = 1573472.84 ( 5.1uS)
@@ -22,6 +51,20 @@ DES ecb bytes per sec = 1338138.45 ( 6.0uS)
DES cbc bytes per sec = 1356515.84 ( 5.9uS)
crypt per sec = 6223.92 (160.7uS)
+Intel P5/133 (NEXTSTEP) - cc -O3 (cc: gcc 2.5.8)
+set_key per sec = 81923.10 ( 12.2uS)
+DES ecb bytes per sec = 1104711.61 ( 7.2uS)
+DES cbc bytes per sec = 1091536.05 ( 7.3uS)
+DES ede cbc bytes per sec = 410502.62 ( 19.5uS)
+crypt per sec = 4849.60 (206.2uS)
+
+Sun SPARC 20 (NEXTSTEP) - cc -O3 (cc: gcc 2.5.8)
+set_key per sec = 60973.05 ( 16.4uS)
+DES ecb bytes per sec = 806032.15 ( 9.9uS)
+DES cbc bytes per sec = 801534.95 ( 10.0uS)
+DES ede cbc bytes per sec = 298799.73 ( 26.8uS)
+crypt per sec = 3678.42 (271.9uS)
+
SGI Indy (MIPS R4600 133mhz) -cc -O2
set_key per sec = 88470.54 ( 11.3uS)
DES ecb bytes per sec = 1023040.33 ( 7.8uS)
OpenPOWER on IntegriCloud