Libdes updated to 3.23

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@513 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Björn Groenvall
1996-05-07 14:19:43 +00:00
parent 5f52d8d91e
commit aec8b94b5c
36 changed files with 408 additions and 230 deletions

View File

@@ -14,7 +14,7 @@ MAKEFILE= Makefile.ssl
CFLAGS= $(INCLUDES) $(CFLAG) CFLAGS= $(INCLUDES) $(CFLAG)
GENERAL=Makefile GENERAL=Makefile des.org des_locl.org
TEST=destest.c TEST=destest.c
APPS= APPS=
@@ -25,11 +25,11 @@ 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 \ qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
str2key.c cfb64ede.c ofb64ede.c supp.c str2key.c cfb64ede.c ofb64ede.c supp.c
LIBOBJ= cbc3_enc.o cbc_cksm.o cbc_enc.o cfb64enc.o cfb_enc.o \ LIBOBJ= set_key.o ecb_enc.o ede_enc.o cbc_enc.o cbc3_enc.o \
ecb3_enc.o ecb_enc.o ede_enc.o enc_read.o enc_writ.o \ ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
fcrypt.o ncbc_enc.o ofb64enc.o ofb_enc.o pcbc_enc.o \ enc_read.o enc_writ.o fcrypt.o ncbc_enc.o ofb64enc.o \
qud_cksm.o rand_key.o read_pwd.o rpc_enc.o set_key.o \ ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
str2key.o cfb64ede.o ofb64ede.o supp.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o
SRC= $(LIBSRC) SRC= $(LIBSRC)
@@ -50,9 +50,9 @@ lib: $(LIBOBJ)
links: links:
/bin/rm -f Makefile /bin/rm -f Makefile
ln -s Makefile.ssl Makefile $(TOP)/util/point.sh Makefile.ssl Makefile ;
/bin/rm -f des.doc /bin/rm -f des.doc
ln -s ../../doc/des.doc . $(TOP)/util/point.sh ../../doc/des.doc . ;
$(TOP)/util/mklink.sh ../../include $(EXHEADER) $(TOP)/util/mklink.sh ../../include $(EXHEADER)
$(TOP)/util/mklink.sh ../../test $(TEST) $(TOP)/util/mklink.sh ../../test $(TEST)
$(TOP)/util/mklink.sh ../../apps $(APPS) $(TOP)/util/mklink.sh ../../apps $(APPS)
@@ -72,7 +72,7 @@ tags:
tests: tests:
lint: lint:
lint -DLINT -DPROTO $(INCLUDES) $(SRC)>fluff lint -DLINT $(INCLUDES) $(SRC)>fluff
depend: depend:
$(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
@@ -160,7 +160,7 @@ read_pwd.o: /usr/include/stdlib.h /usr/include/unistd.h
read_pwd.o: /usr/include/sys/types.h /usr/include/sys/machtypes.h read_pwd.o: /usr/include/sys/types.h /usr/include/sys/machtypes.h
read_pwd.o: /usr/include/sys/unistd.h des.h /usr/include/signal.h read_pwd.o: /usr/include/sys/unistd.h des.h /usr/include/signal.h
read_pwd.o: /usr/include/sys/signal.h /usr/include/string.h read_pwd.o: /usr/include/sys/signal.h /usr/include/string.h
read_pwd.o: /usr/include/setjmp.h /usr/include/sys/ioctl.h read_pwd.o: /usr/include/setjmp.h
rpc_enc.o: rpc_des.h des_locl.h /usr/include/stdio.h rpc_enc.o: rpc_des.h des_locl.h /usr/include/stdio.h
rpc_enc.o: /usr/include/sys/feature_tests.h /usr/include/stdlib.h rpc_enc.o: /usr/include/sys/feature_tests.h /usr/include/stdlib.h
rpc_enc.o: /usr/include/unistd.h /usr/include/sys/types.h rpc_enc.o: /usr/include/unistd.h /usr/include/sys/types.h

View File

@@ -7,6 +7,9 @@
# MSDOS - we all know what it is :-) # MSDOS - we all know what it is :-)
# read_pwd.c makes a reasonable guess at what is correct. # 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 OPTS0= -DRAND -DTERMIO #-DNOCONST
# Version 1.94 has changed the strings_to_key function so that it is # 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 # For other machines, experiment with changing the option and run
# ./speed to see which is faster. # ./speed to see which is faster.
# DO NOT TURN THIS OPTION ON WHEN COMPILING THIS CODE ON A 64 BIT MACHINE # 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) OPTS= $(OPTS0) $(OPTS1) $(OPTS2)
@@ -51,7 +56,8 @@ 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 \ GENERAL=COPYRIGHT FILES INSTALL Imakefile README VERSION Makefile \
times vms.com KERBEROS MODES.DES GNUmakefile des.man \ times vms.com KERBEROS MODES.DES GNUmakefile des.man \
DES.pm DES.pod DES.xs Makefile.PL Makefile.uni typemap t \ 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 DES= des.c
TESTING=destest.c speed.c rpw.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=version.h des.h des_locl.h podd.h sk.h spr.h rpc_des.h

View File

@@ -45,3 +45,4 @@ gcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines
(on a sun3/260 168 vs 336). It is a function of CPU on chip cache size. (on a sun3/260 168 vs 336). It is a function of CPU on chip cache size.
Eric Young (eay@mincom.oz.au or eay@psych.psy.uq.oz.au) Eric Young (eay@mincom.oz.au or eay@psych.psy.uq.oz.au)

View File

@@ -1,3 +1,17 @@
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>
for the patch.
Version 3.21 22/11/95 Version 3.21 22/11/95
After some emailing back and forth with After some emailing back and forth with
Colin Plumb <colin@nyx10.cs.du.edu>, I've tweaked a few things Colin Plumb <colin@nyx10.cs.du.edu>, I've tweaked a few things
@@ -310,3 +324,4 @@ Version 1.10 11/09/1990 eay
Still need to document des_enc_read and des_enc_write. Still need to document des_enc_read and des_enc_write.
Version 1.00 27/08/1990 eay Version 1.00 27/08/1990 eay

View File

@@ -47,16 +47,16 @@
#include "des_locl.h" #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 (*input);
des_cblock (*output); des_cblock (*output);
long length; long length;
des_key_schedule schedule; des_key_schedule schedule;
des_cblock (*ivec); des_cblock (*ivec);
{ {
register unsigned long tout0,tout1,tin0,tin1; register DES_LONG tout0,tout1,tin0,tin1;
register long l=length; register long l=length;
unsigned long tin[2]; DES_LONG tin[2];
unsigned char *in,*out,*iv; unsigned char *in,*out,*iv;
in=(unsigned char *)input; in=(unsigned char *)input;
@@ -77,7 +77,7 @@ des_cblock (*ivec);
tin0^=tout0; tin[0]=tin0; tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1; 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 */ /* fix 15/10/91 eay - thanks to keithr@sco.COM */
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];

View File

@@ -55,11 +55,11 @@ des_key_schedule schedule;
des_cblock (*ivec); des_cblock (*ivec);
int encrypt; int encrypt;
{ {
register unsigned long tin0,tin1; register DES_LONG tin0,tin1;
register unsigned long tout0,tout1,xor0,xor1; register DES_LONG tout0,tout1,xor0,xor1;
register unsigned char *in,*out; register unsigned char *in,*out;
register long l=length; register long l=length;
unsigned long tin[2]; DES_LONG tin[2];
unsigned char *iv; unsigned char *iv;
in=(unsigned char *)input; in=(unsigned char *)input;
@@ -81,7 +81,7 @@ int encrypt;
c2ln(in,tin0,tin1,l); c2ln(in,tin0,tin1,l);
tin0^=tout0; tin[0]=tin0; tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1; 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); tout0=tin[0]; l2c(tout0,out);
tout1=tin[1]; l2c(tout1,out); tout1=tin[1]; l2c(tout1,out);
} }
@@ -94,7 +94,7 @@ int encrypt;
{ {
c2l(in,tin0); tin[0]=tin0; c2l(in,tin0); tin[0]=tin0;
c2l(in,tin1); tin[1]=tin1; 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; tout0=tin[0]^xor0;
tout1=tin[1]^xor1; tout1=tin[1]^xor1;
if (l >= 8) if (l >= 8)

View File

@@ -1,4 +1,4 @@
/* lib/des/cfb64enc.c */ /* lib/des/cfb64ede.c */
/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) /* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
* All rights reserved. * All rights reserved.
* *
@@ -61,9 +61,9 @@ des_cblock (*ivec);
int *num; int *num;
int encrypt; int encrypt;
{ {
register unsigned long v0,v1; register DES_LONG v0,v1;
register long l=length,n=*num; register long l=length,n=*num;
unsigned long ti[2]; DES_LONG ti[2];
unsigned char *iv,c,cc; unsigned char *iv,c,cc;
iv=(unsigned char *)ivec; iv=(unsigned char *)ivec;
@@ -80,9 +80,9 @@ int encrypt;
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt2((unsigned long *)ti,ks1,DES_ENCRYPT); des_encrypt2((DES_LONG *)ti,ks1,DES_ENCRYPT);
des_encrypt2((unsigned long *)ti,ks2,DES_DECRYPT); des_encrypt2((DES_LONG *)ti,ks2,DES_DECRYPT);
des_encrypt2((unsigned long *)ti,ks3,DES_ENCRYPT); des_encrypt2((DES_LONG *)ti,ks3,DES_ENCRYPT);
v0=ti[0]; v0=ti[0];
v1=ti[1]; v1=ti[1];
@@ -112,9 +112,9 @@ int encrypt;
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt2((unsigned long *)ti,ks1,DES_ENCRYPT); des_encrypt2((DES_LONG *)ti,ks1,DES_ENCRYPT);
des_encrypt2((unsigned long *)ti,ks2,DES_DECRYPT); des_encrypt2((DES_LONG *)ti,ks2,DES_DECRYPT);
des_encrypt2((unsigned long *)ti,ks3,DES_ENCRYPT); des_encrypt2((DES_LONG *)ti,ks3,DES_ENCRYPT);
v0=ti[0]; v0=ti[0];
v1=ti[1]; v1=ti[1];

View File

@@ -61,9 +61,9 @@ des_cblock (*ivec);
int *num; int *num;
int encrypt; int encrypt;
{ {
register unsigned long v0,v1; register DES_LONG v0,v1;
register long l=length,n=*num; register long l=length,n=*num;
unsigned long ti[2]; DES_LONG ti[2];
unsigned char *iv,c,cc; unsigned char *iv,c,cc;
iv=(unsigned char *)ivec; iv=(unsigned char *)ivec;
@@ -75,7 +75,7 @@ int encrypt;
{ {
c2l(iv,v0); ti[0]=v0; c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1; c2l(iv,v1); ti[1]=v1;
des_encrypt((unsigned long *)ti, des_encrypt((DES_LONG *)ti,
schedule,DES_ENCRYPT); schedule,DES_ENCRYPT);
iv=(unsigned char *)ivec; iv=(unsigned char *)ivec;
v0=ti[0]; l2c(v0,iv); v0=ti[0]; l2c(v0,iv);
@@ -96,7 +96,7 @@ int encrypt;
{ {
c2l(iv,v0); ti[0]=v0; c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1; c2l(iv,v1); ti[1]=v1;
des_encrypt((unsigned long *)ti, des_encrypt((DES_LONG *)ti,
schedule,DES_ENCRYPT); schedule,DES_ENCRYPT);
iv=(unsigned char *)ivec; iv=(unsigned char *)ivec;
v0=ti[0]; l2c(v0,iv); v0=ti[0]; l2c(v0,iv);

View File

@@ -62,11 +62,11 @@ des_key_schedule schedule;
des_cblock (*ivec); des_cblock (*ivec);
int encrypt; int encrypt;
{ {
register unsigned long d0,d1,v0,v1,n=(numbits+7)/8; register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
register unsigned long mask0,mask1; register DES_LONG mask0,mask1;
register unsigned long l=length; register unsigned long l=length;
register int num=numbits; register int num=numbits;
unsigned long ti[2]; DES_LONG ti[2];
unsigned char *iv; unsigned char *iv;
if (num > 64) return; if (num > 64) return;
@@ -95,7 +95,7 @@ int encrypt;
l-=n; l-=n;
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT); des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n); c2ln(in,d0,d1,n);
in+=n; in+=n;
d0=(d0^ti[0])&mask0; d0=(d0^ti[0])&mask0;
@@ -127,7 +127,7 @@ int encrypt;
l-=n; l-=n;
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT); des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n); c2ln(in,d0,d1,n);
in+=n; in+=n;
/* 30-08-94 - eay - changed because l>>32 and /* 30-08-94 - eay - changed because l>>32 and

View File

@@ -80,7 +80,7 @@
#define srandom(s) srand(s) #define srandom(s) srand(s)
#endif #endif
#ifdef PROTO #ifndef NOPROTO
void usage(void); void usage(void);
void doencryption(void); void doencryption(void);
int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp); int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp);
@@ -113,7 +113,7 @@ int do_encrypt,longk=0;
FILE *DES_IN,*DES_OUT,*CKSUM_OUT; FILE *DES_IN,*DES_OUT,*CKSUM_OUT;
char uuname[200]; char uuname[200];
unsigned char uubuf[50]; unsigned char uubuf[50];
int uubufnum; int uubufnum=0;
#define INUUBUFN (45*100) #define INUUBUFN (45*100)
#define OUTUUBUF (65*100) #define OUTUUBUF (65*100)
unsigned char b[OUTUUBUF]; unsigned char b[OUTUUBUF];
@@ -625,8 +625,7 @@ void doencryption()
{ {
fputs("The file was not decrypted correctly.\n", fputs("The file was not decrypted correctly.\n",
stderr); stderr);
/*Exit=8; Exit=8;
goto problems;*/
last=0; last=0;
} }
l=l-8+last; l=l-8+last;
@@ -722,7 +721,7 @@ FILE *fp;
} }
} }
for (i=0; i<(num-INUUBUFN); i+=INUUBUFN) for (i=0; i<(((int)num)-INUUBUFN); i+=INUUBUFN)
{ {
j=uuencode(&(data[i]),INUUBUFN,b); j=uuencode(&(data[i]),INUUBUFN,b);
fwrite(b,1,(unsigned int)j,fp); fwrite(b,1,(unsigned int)j,fp);
@@ -827,9 +826,9 @@ FILE *fp;
return(tot); return(tot);
} }
#define ccc2l(c,l) (l =((unsigned long)(*((c)++)))<<16, \ #define ccc2l(c,l) (l =((DES_LONG)(*((c)++)))<<16, \
l|=((unsigned long)(*((c)++)))<< 8, \ l|=((DES_LONG)(*((c)++)))<< 8, \
l|=((unsigned long)(*((c)++)))) l|=((DES_LONG)(*((c)++))))
#define l2ccc(l,c) (*((c)++)=(unsigned char)(((l)>>16)&0xff), \ #define l2ccc(l,c) (*((c)++)=(unsigned char)(((l)>>16)&0xff), \
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
@@ -842,7 +841,7 @@ int num;
unsigned char *out; unsigned char *out;
{ {
int j,i,n,tot=0; int j,i,n,tot=0;
unsigned long l; DES_LONG l;
register unsigned char *p; register unsigned char *p;
p=out; p=out;
@@ -876,8 +875,8 @@ unsigned char *out;
{ {
int j,i,k; int j,i,k;
unsigned int n=0,space=0; unsigned int n=0,space=0;
unsigned long l; DES_LONG l;
unsigned long w,x,y,z; DES_LONG w,x,y,z;
unsigned int blank=(unsigned int)'\n'-' '; unsigned int blank=(unsigned int)'\n'-' ';
for (j=0; j<num; ) for (j=0; j<num; )

View File

@@ -202,8 +202,16 @@ des_cblock *ivec,
int enc); int enc);
Cipher Feedback Back mode of DES. This implementation 'feeds back' Cipher Feedback Back mode of DES. This implementation 'feeds back'
in numbit blocks. The input (and output) is in multiples of numbits in numbit blocks. The input (and output) is in multiples of numbits
bits. numbits needs to be a multiple of 8 bits. Length is the bits. numbits should to be a multiple of 8 bits. Length is the
number of bytes input. number of bytes input. If numbits is not a multiple of 8 bits,
the extra bits in the bytes will be considered padding. So if
numbits is 12, for each 2 input bytes, the 4 high bits of the
second byte will be ignored. So to encode 72 bits when using
a numbits of 12 take 12 bytes. To encode 72 bits when using
numbits of 9 will take 16 bytes. To encode 80 bits when using
numbits of 16 will take 10 bytes. etc, etc. This padding will
apply to both input and output.
void des_cfb64_encrypt( void des_cfb64_encrypt(
unsigned char *in, unsigned char *in,

View File

@@ -50,6 +50,12 @@
#include <stdio.h> #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 unsigned char des_cblock[8];
typedef struct des_ks_struct typedef struct des_ks_struct
{ {
@@ -57,7 +63,7 @@ typedef struct des_ks_struct
des_cblock _; des_cblock _;
/* make sure things are correct size on machines with /* make sure things are correct size on machines with
* 8 byte longs */ * 8 byte longs */
unsigned long pad[2]; DES_LONG pad[2];
} ks; } ks;
#undef _ #undef _
#define _ ks._ #define _ ks._
@@ -102,7 +108,7 @@ typedef struct des_ks_struct
#define quad_cksum des_quad_cksum #define quad_cksum des_quad_cksum
/* For compatibility with the MIT lib - eay 20/05/92 */ /* 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_fixup_key_parity des_set_odd_parity
#define des_check_key_parity check_parity #define des_check_key_parity check_parity
@@ -113,14 +119,13 @@ extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
* compiler has problems with the prototypes, make sure this line always * compiler has problems with the prototypes, make sure this line always
* evaluates to true :-) */ * evaluates to true :-) */
#if defined(MSDOS) || defined(__STDC__) #if defined(MSDOS) || defined(__STDC__)
#undef PROTO #undef NOPROTO
#define PROTO
#endif #endif
#ifdef PROTO #ifndef NOPROTO
void des_ecb3_encrypt(des_cblock *input,des_cblock *output, void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
des_key_schedule ks1,des_key_schedule ks2, des_key_schedule ks1,des_key_schedule ks2,
des_key_schedule ks3, int enc); 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); long length,des_key_schedule schedule,des_cblock *ivec);
void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length, void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,int enc); des_key_schedule schedule,des_cblock *ivec,int enc);
@@ -133,8 +138,8 @@ void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
long length,des_key_schedule schedule,des_cblock *ivec,int enc); long length,des_key_schedule schedule,des_cblock *ivec,int enc);
void des_ecb_encrypt(des_cblock *input,des_cblock *output, void des_ecb_encrypt(des_cblock *input,des_cblock *output,
des_key_schedule ks,int enc); des_key_schedule ks,int enc);
void des_encrypt(unsigned long *data,des_key_schedule ks, int enc); void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
void des_encrypt2(unsigned 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, void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
long length, des_key_schedule ks1, des_key_schedule ks2, long length, des_key_schedule ks1, des_key_schedule ks2,
des_key_schedule ks3, des_cblock *ivec, int enc); des_key_schedule ks3, des_cblock *ivec, int enc);
@@ -164,7 +169,7 @@ void des_ofb_encrypt(unsigned char *in,unsigned char *out,
int numbits,long length,des_key_schedule schedule,des_cblock *ivec); int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length, void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,int enc); 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); long length,int out_count,des_cblock *seed);
void des_random_seed(des_cblock key); void des_random_seed(des_cblock key);
void des_random_key(des_cblock ret); void des_random_key(des_cblock ret);
@@ -197,7 +202,7 @@ void des_generate_random_block(des_cblock *block);
#else #else
void des_ecb3_encrypt(); void des_ecb3_encrypt();
unsigned long des_cbc_cksum(); DES_LONG des_cbc_cksum();
void des_cbc_encrypt(); void des_cbc_encrypt();
void des_ncbc_encrypt(); void des_ncbc_encrypt();
void des_3cbc_encrypt(); void des_3cbc_encrypt();
@@ -217,7 +222,7 @@ char *crypt();
#endif #endif
void des_ofb_encrypt(); void des_ofb_encrypt();
void des_pcbc_encrypt(); void des_pcbc_encrypt();
unsigned long des_quad_cksum(); DES_LONG des_quad_cksum();
void des_random_seed(); void des_random_seed();
void des_random_key(); void des_random_key();
int des_read_password(); int des_read_password();

View File

@@ -1,6 +1,12 @@
#!/usr/local/bin/perl #!/usr/local/bin/perl
# Copyright (C) 1993 Eric Young
# des.pl - eric young 22/11/1991 eay@mincom.oz.au or eay@psych.psy.uq.oz.au # 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 # 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 :-). # versions of perl but I could be wrong since I have not tested it yet :-).
# #
@@ -25,7 +31,7 @@
# $outbytes= &des_ecb_encrypt(*ks,1,$data); # $outbytes= &des_ecb_encrypt(*ks,1,$data);
# @enc =unpack("C8",$outbytes); # @enc =unpack("C8",$outbytes);
# #
package des; package des;
# The following 8 arrays are used in des_set_key # The following 8 arrays are used in des_set_key
@@ -375,8 +381,8 @@ sub main'des_set_key
$skb6[ ($d>>15)&0x3f ]| $skb6[ ($d>>15)&0x3f ]|
$skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)]; $skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)];
push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff); push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff);
$s= ($s>>16)|($t&0xffff0000) ; $s= (($s>>16)&0x0000ffff)|($t&0xffff0000) ;
push(@ks,(($s<<4)|($s>>28))&0xffffffff); push(@ks,(($s<<4)|(($s>>28)&0xf))&0xffffffff);
} }
@ks; @ks;
} }
@@ -390,23 +396,23 @@ sub doPC1
$b^=($t<<4); $a^=$t; $b^=($t<<4); $a^=$t;
# do $a first # do $a first
$t=(($a<<18)^$a)&0xcccc0000; $t=(($a<<18)^$a)&0xcccc0000;
$a=$a^$t^($t>>18); $a=$a^$t^(($t>>18)&0x00003fff);
$t=(($a<<17)^$a)&0xaaaa0000; $t=(($a<<17)^$a)&0xaaaa0000;
$a=$a^$t^($t>>17); $a=$a^$t^(($t>>17)&0x00007fff);
$t=(($a<< 8)^$a)&0x00ff0000; $t=(($a<< 8)^$a)&0x00ff0000;
$a=$a^$t^($t>> 8); $a=$a^$t^(($t>> 8)&0x00ffffff);
$t=(($a<<17)^$a)&0xaaaa0000; $t=(($a<<17)^$a)&0xaaaa0000;
$a=$a^$t^($t>>17); $a=$a^$t^(($t>>17)&0x00007fff);
# now do $b # now do $b
$t=(($b<<24)^$b)&0xff000000; $t=(($b<<24)^$b)&0xff000000;
$b=$b^$t^($t>>24); $b=$b^$t^(($t>>24)&0x000000ff);
$t=(($b<< 8)^$b)&0x00ff0000; $t=(($b<< 8)^$b)&0x00ff0000;
$b=$b^$t^($t>> 8); $b=$b^$t^($t>> 8);
$t=(($b<<14)^$b)&0x33330000; $t=(($b<<14)^$b)&0x33330000;
$b=$b^$t^($t>>14); $b=$b^$t^($t>>14);
$b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55); $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; $a&=0x0fffffff;
} }
@@ -472,10 +478,10 @@ sub main'des_ecb_encrypt
{ {
for ($i=0; $i<32; $i+=4) for ($i=0; $i<32; $i+=4)
{ {
$t=(($r<<1)|($r>>31))&0xffffffff; $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff;
$u=$t^$ks[$i ]; $u=$t^$ks[$i ];
$t=$t^$ks[$i+1]; $t=$t^$ks[$i+1];
$t=(($t>>4)|($t<<28))&0xffffffff; $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
$l^= $SP1[ $t &0x3f]| $l^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]| $SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]| $SP5[($t>>16)&0x3f]|
@@ -485,10 +491,10 @@ sub main'des_ecb_encrypt
$SP4[($u>>16)&0x3f]| $SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f]; $SP6[($u>>24)&0x3f];
$t=(($l<<1)|($l>>31))&0xffffffff; $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
$u=$t^$ks[$i+2]; $u=$t^$ks[$i+2];
$t=$t^$ks[$i+3]; $t=$t^$ks[$i+3];
$t=(($t>>4)|($t<<28))&0xffffffff; $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
$r^= $SP1[ $t &0x3f]| $r^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]| $SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]| $SP5[($t>>16)&0x3f]|
@@ -503,10 +509,10 @@ sub main'des_ecb_encrypt
{ {
for ($i=30; $i>0; $i-=4) for ($i=30; $i>0; $i-=4)
{ {
$t=(($r<<1)|($r>>31))&0xffffffff; $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff;
$u=$t^$ks[$i ]; $u=$t^$ks[$i ];
$t=$t^$ks[$i+1]; $t=$t^$ks[$i+1];
$t=(($t>>4)|($t<<28))&0xffffffff; $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
$l^= $SP1[ $t &0x3f]| $l^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]| $SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]| $SP5[($t>>16)&0x3f]|
@@ -516,10 +522,10 @@ sub main'des_ecb_encrypt
$SP4[($u>>16)&0x3f]| $SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f]; $SP6[($u>>24)&0x3f];
$t=(($l<<1)|($l>>31))&0xffffffff; $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
$u=$t^$ks[$i-2]; $u=$t^$ks[$i-2];
$t=$t^$ks[$i-1]; $t=$t^$ks[$i-1];
$t=(($t>>4)|($t<<28))&0xffffffff; $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
$r^= $SP1[ $t &0x3f]| $r^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]| $SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]| $SP5[($t>>16)&0x3f]|
@@ -531,6 +537,12 @@ sub main'des_ecb_encrypt
} }
} }
&doFP(*l,*r); &doFP(*l,*r);
pack("C8",$l&0xff,$l>>8,$l>>16,$l>>24, pack("C8",$l&0xff,
$r&0xff,$r>>8,$r>>16,$r>>24); ($l>> 8)&0x00ffffff,
($l>>16)&0x0000ffff,
($l>>24)&0x000000ff,
$r&0xff,
($r>> 8)&0x00ffffff,
($r>>16)&0x0000ffff,
($r>>24)&0x000000ff);
} }

View File

@@ -1,26 +1,3 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
/*
if (we have termios.h)
define TERMIOS
else if (we have termio.h)
define TERMIO
*/
#ifdef HAVE_TERMIOS_H
#define TERMIOS
#else /* !HAVE_TERMIOS_H */
#ifdef HAVE_TERMIO_H
#define TERMIO
#endif
#endif /* !HAVE_TERMIOS_H */
#endif /* HAVE_CONFIG_H */
/* lib/des/des_locl.h */ /* lib/des/des_locl.h */
/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) /* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
* All rights reserved. * All rights reserved.
@@ -77,19 +54,28 @@
#endif #endif
#include "des.h" #include "des.h"
/* 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
*/
/* the following is tweaked from a config script, that is why it is a /* the following is tweaked from a config script, that is why it is a
* protected undef/define */ * protected undef/define */
#ifndef DES_USE_PTR #ifndef DES_PTR
#undef DES_USE_PTR #undef DES_PTR
#endif #endif
#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */ #ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <io.h> #include <io.h>
#ifndef RAND
#define RAND #define RAND
#undef PROTO #endif
#define PROTO #undef NOPROTO
#endif #endif
#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) #if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
@@ -100,12 +86,15 @@
#define RAND #define RAND
#endif #endif
#ifdef linux
#undef RAND
#endif
#ifdef MSDOS #ifdef MSDOS
#define getpid() 2 #define getpid() 2
extern int errno; extern int errno;
#define RAND #define RAND
#undef PROTO #undef NOPROTO
#define PROTO
#endif #endif
#if defined(NOCONST) #if defined(NOCONST)
@@ -113,8 +102,7 @@ extern int errno;
#endif #endif
#ifdef __STDC__ #ifdef __STDC__
#undef PROTO #undef NOPROTO
#define PROTO
#endif #endif
#ifdef RAND #ifdef RAND
@@ -129,24 +117,24 @@ extern int errno;
#define MAXWRITE (1024*16) #define MAXWRITE (1024*16)
#define BSIZE (MAXWRITE+4) #define BSIZE (MAXWRITE+4)
#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((DES_LONG)(*((c)++)))<< 8L, \
l|=((unsigned long)(*((c)++)))<<16L, \ l|=((DES_LONG)(*((c)++)))<<16L, \
l|=((unsigned long)(*((c)++)))<<24L) l|=((DES_LONG)(*((c)++)))<<24L)
/* NOTE - c is not incremented as per c2l */ /* NOTE - c is not incremented as per c2l */
#define c2ln(c,l1,l2,n) { \ #define c2ln(c,l1,l2,n) { \
c+=n; \ c+=n; \
l1=l2=0; \ l1=l2=0; \
switch (n) { \ switch (n) { \
case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
case 5: l2|=((unsigned long)(*(--(c)))); \ case 5: l2|=((DES_LONG)(*(--(c)))); \
case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
case 1: l1|=((unsigned long)(*(--(c)))); \ case 1: l1|=((DES_LONG)(*(--(c)))); \
} \ } \
} }
@@ -159,10 +147,10 @@ extern int errno;
* when faced with machines with 8 byte longs. */ * when faced with machines with 8 byte longs. */
#define HDRSIZE 4 #define HDRSIZE 4
#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ #define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
l|=((unsigned long)(*((c)++)))<<16L, \ l|=((DES_LONG)(*((c)++)))<<16L, \
l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((DES_LONG)(*((c)++)))<< 8L, \
l|=((unsigned long)(*((c)++)))) l|=((DES_LONG)(*((c)++))))
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
@@ -187,21 +175,24 @@ extern int errno;
/* The changes to this macro may help or hinder, depending on the /* The changes to this macro may help or hinder, depending on the
* compiler and the achitecture. gcc2 always seems to do well :-). * compiler and the achitecture. gcc2 always seems to do well :-).
* Inspired by Dana How <how@isl.stanford.edu> * Inspired by Dana How <how@isl.stanford.edu>
* DO NOT use the alternative version on machines with 8 byte longs. */ * DO NOT use the alternative version on machines with 8 byte longs.
#ifdef DES_USR_PTR * 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) { \ #define D_ENCRYPT(L,R,S) { \
u=((R^s[S ])<<2); \ u=((R^s[S ])<<2); \
t= R^s[S+1]; \ t= R^s[S+1]; \
t=((t>>2)+(t<<30)); \ t=((t>>2)+(t<<30)); \
L^= \ L^= (\
*(unsigned long *)(des_SP+0x0100+((t )&0xfc))+ \ *(DES_LONG *)(&(des_SPtrans[1][0])+((t )&0xfc))+ \
*(unsigned long *)(des_SP+0x0300+((t>> 8)&0xfc))+ \ *(DES_LONG *)(&(des_SPtrans[3][0])+((t>> 8)&0xfc))+ \
*(unsigned long *)(des_SP+0x0500+((t>>16)&0xfc))+ \ *(DES_LONG *)(&(des_SPtrans[5][0])+((t>>16)&0xfc))+ \
*(unsigned long *)(des_SP+0x0700+((t>>24)&0xfc))+ \ *(DES_LONG *)(&(des_SPtrans[7][0])+((t>>24)&0xfc))+ \
*(unsigned long *)(des_SP+ ((u )&0xfc))+ \ *(DES_LONG *)(&(des_SPtrans[0][0])+((u )&0xfc))+ \
*(unsigned long *)(des_SP+0x0200+((u>> 8)&0xfc))+ \ *(DES_LONG *)(&(des_SPtrans[2][0])+((u>> 8)&0xfc))+ \
*(unsigned long *)(des_SP+0x0400+((u>>16)&0xfc))+ \ *(DES_LONG *)(&(des_SPtrans[4][0])+((u>>16)&0xfc))+ \
*(unsigned long *)(des_SP+0x0600+((u>>24)&0xfc)); } *(DES_LONG *)(&(des_SPtrans[6][0])+((u>>24)&0xfc))); }
#else /* original version */ #else /* original version */
#ifdef MSDOS #ifdef MSDOS
#define D_ENCRYPT(L,R,S) \ #define D_ENCRYPT(L,R,S) \
@@ -276,7 +267,7 @@ extern int errno;
#define IP(l,r) \ #define IP(l,r) \
{ \ { \
register unsigned long tt; \ register DES_LONG tt; \
PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
PERM_OP(l,r,tt,16,0x0000ffffL); \ PERM_OP(l,r,tt,16,0x0000ffffL); \
PERM_OP(r,l,tt, 2,0x33333333L); \ PERM_OP(r,l,tt, 2,0x33333333L); \
@@ -286,7 +277,7 @@ extern int errno;
#define FP(l,r) \ #define FP(l,r) \
{ \ { \
register unsigned long tt; \ register DES_LONG tt; \
PERM_OP(l,r,tt, 1,0x55555555L); \ PERM_OP(l,r,tt, 1,0x55555555L); \
PERM_OP(r,l,tt, 8,0x00ff00ffL); \ PERM_OP(r,l,tt, 8,0x00ff00ffL); \
PERM_OP(l,r,tt, 2,0x33333333L); \ PERM_OP(l,r,tt, 2,0x33333333L); \

View File

@@ -261,10 +261,10 @@ static unsigned char ofb_cipher[24]=
0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 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}; unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
#ifdef PROTO #ifndef NOPROTO
static char *pt(unsigned char *p); static char *pt(unsigned char *p);
static int cfb_test(int bits, unsigned char *cfb_cipher); static int cfb_test(int bits, unsigned char *cfb_cipher);
static int cfb64_test(unsigned char *cfb_cipher); static int cfb64_test(unsigned char *cfb_cipher);
@@ -285,9 +285,9 @@ char *argv[];
des_key_schedule ks,ks2,ks3; des_key_schedule ks,ks2,ks3;
unsigned char cbc_in[40]; unsigned char cbc_in[40];
unsigned char cbc_out[40]; unsigned char cbc_out[40];
unsigned long cs; DES_LONG cs;
unsigned char qret[4][4],cret[8]; unsigned char qret[4][4],cret[8];
unsigned long lqret[4]; DES_LONG lqret[4];
int num; int num;
char *str; char *str;
@@ -585,9 +585,9 @@ char *argv[];
memcpy(&(lqret[i]),&(qret[i][0]),4); memcpy(&(lqret[i]),&(qret[i][0]),4);
} }
{ /* Big-endian fix */ { /* Big-endian fix */
static unsigned long l=1; static DES_LONG l=1;
static unsigned char *c=(unsigned char *)&l; static unsigned char *c=(unsigned char *)&l;
unsigned long ll; DES_LONG ll;
if (!c[0]) if (!c[0])
{ {

View File

@@ -55,9 +55,9 @@ des_key_schedule ks2;
des_key_schedule ks3; des_key_schedule ks3;
int encrypt; int encrypt;
{ {
register unsigned long l0,l1; register DES_LONG l0,l1;
register unsigned char *in,*out; register unsigned char *in,*out;
unsigned long ll[2]; DES_LONG ll[2];
in=(unsigned char *)input; in=(unsigned char *)input;
out=(unsigned char *)output; out=(unsigned char *)output;

View File

@@ -48,7 +48,7 @@
#include "des_locl.h" #include "des_locl.h"
#include "spr.h" #include "spr.h"
const char *DES_version="libdes v 3.21 - 95/11/21 - eay"; const char *DES_version="libdes v 3.22 - 95/11/29 - eay";
void des_ecb_encrypt(input, output, ks, encrypt) void des_ecb_encrypt(input, output, ks, encrypt)
des_cblock (*input); des_cblock (*input);
@@ -56,38 +56,38 @@ des_cblock (*output);
des_key_schedule ks; des_key_schedule ks;
int encrypt; int encrypt;
{ {
register unsigned long l0,l1; register DES_LONG l;
register unsigned char *in,*out; register unsigned char *in,*out;
unsigned long ll[2]; DES_LONG ll[2];
in=(unsigned char *)input; in=(unsigned char *)input;
out=(unsigned char *)output; out=(unsigned char *)output;
c2l(in,l0); ll[0]=l0; c2l(in,l); ll[0]=l;
c2l(in,l1); ll[1]=l1; c2l(in,l); ll[1]=l;
des_encrypt(ll,ks,encrypt); des_encrypt(ll,ks,encrypt);
l0=ll[0]; l2c(l0,out); l=ll[0]; l2c(l,out);
l1=ll[1]; l2c(l1,out); l=ll[1]; l2c(l,out);
l0=l1=ll[0]=ll[1]=0; l=ll[0]=ll[1]=0;
} }
void des_encrypt(data, ks, encrypt) void des_encrypt(data, ks, encrypt)
unsigned long *data; DES_LONG *data;
des_key_schedule ks; des_key_schedule ks;
int encrypt; int encrypt;
{ {
register unsigned long l,r,t,u; register DES_LONG l,r,t,u;
#ifdef DES_USE_PTR #ifdef DES_USE_PTR
register unsigned char *des_SP=(unsigned char *)des_SPtrans; register unsigned char *des_SP=(unsigned char *)des_SPtrans;
#endif #endif
#ifdef MSDOS #ifdef MSDOS
union fudge { union fudge {
unsigned long l; DES_LONG l;
unsigned short s[2]; unsigned short s[2];
unsigned char c[4]; unsigned char c[4];
} U,T; } U,T;
#endif #endif
register int i; register int i;
register unsigned long *s; register DES_LONG *s;
u=data[0]; u=data[0];
r=data[1]; r=data[1];
@@ -106,7 +106,7 @@ int encrypt;
l&=0xffffffffL; l&=0xffffffffL;
r&=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 /* I don't know if it is worth the effort of loop unrolling the
* inner loop */ * inner loop */
if (encrypt) if (encrypt)
@@ -138,23 +138,23 @@ int encrypt;
} }
void des_encrypt2(data, ks, encrypt) void des_encrypt2(data, ks, encrypt)
unsigned long *data; DES_LONG *data;
des_key_schedule ks; des_key_schedule ks;
int encrypt; int encrypt;
{ {
register unsigned long l,r,t,u; register DES_LONG l,r,t,u;
#ifdef DES_USE_PTR #ifdef DES_USE_PTR
register unsigned char *des_SP=(unsigned char *)des_SPtrans; register unsigned char *des_SP=(unsigned char *)des_SPtrans;
#endif #endif
#ifdef MSDOS #ifdef MSDOS
union fudge { union fudge {
unsigned long l; DES_LONG l;
unsigned short s[2]; unsigned short s[2];
unsigned char c[4]; unsigned char c[4];
} U,T; } U,T;
#endif #endif
register int i; register int i;
register unsigned long *s; register DES_LONG *s;
u=data[0]; u=data[0];
r=data[1]; r=data[1];
@@ -172,7 +172,7 @@ int encrypt;
l&=0xffffffffL; l&=0xffffffffL;
r&=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 /* I don't know if it is worth the effort of loop unrolling the
* inner loop */ * inner loop */
if (encrypt) if (encrypt)

View File

@@ -57,11 +57,11 @@ des_key_schedule ks3;
des_cblock (*ivec); des_cblock (*ivec);
int encrypt; int encrypt;
{ {
register unsigned long tin0,tin1; register DES_LONG tin0,tin1;
register unsigned long tout0,tout1,xor0,xor1; register DES_LONG tout0,tout1,xor0,xor1;
register unsigned char *in,*out; register unsigned char *in,*out;
register long l=length; register long l=length;
unsigned long tin[2]; DES_LONG tin[2];
unsigned char *iv; unsigned char *iv;
in=(unsigned char *)input; in=(unsigned char *)input;
@@ -88,9 +88,9 @@ int encrypt;
tin[0]=tin0; tin[0]=tin0;
tin[1]=tin1; tin[1]=tin1;
des_encrypt2((unsigned long *)tin,ks1,DES_ENCRYPT); des_encrypt2((DES_LONG *)tin,ks1,DES_ENCRYPT);
des_encrypt2((unsigned long *)tin,ks2,DES_DECRYPT); des_encrypt2((DES_LONG *)tin,ks2,DES_DECRYPT);
des_encrypt2((unsigned long *)tin,ks3,DES_ENCRYPT); des_encrypt2((DES_LONG *)tin,ks3,DES_ENCRYPT);
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];
@@ -109,7 +109,7 @@ int encrypt;
c2l(iv,xor1); c2l(iv,xor1);
for (; l>0; l-=8) for (; l>0; l-=8)
{ {
register unsigned long t0,t1; register DES_LONG t0,t1;
c2l(in,tin0); c2l(in,tin0);
c2l(in,tin1); c2l(in,tin1);
@@ -120,9 +120,9 @@ int encrypt;
tin[0]=tin0; tin[0]=tin0;
tin[1]=tin1; tin[1]=tin1;
des_encrypt2((unsigned long *)tin,ks3,DES_DECRYPT); des_encrypt2((DES_LONG *)tin,ks3,DES_DECRYPT);
des_encrypt2((unsigned long *)tin,ks2,DES_ENCRYPT); des_encrypt2((DES_LONG *)tin,ks2,DES_ENCRYPT);
des_encrypt2((unsigned long *)tin,ks1,DES_DECRYPT); des_encrypt2((DES_LONG *)tin,ks1,DES_DECRYPT);
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];

View File

@@ -390,7 +390,7 @@ static const unsigned long skb[8][64]={
static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
#ifdef PROTO #ifndef NOPROTO
static int body(unsigned long *out0, unsigned long *out1, static int body(unsigned long *out0, unsigned long *out1,
des_key_schedule ks, unsigned long Eswap0, unsigned long Eswap1); des_key_schedule ks, unsigned long Eswap0, unsigned long Eswap1);
static int des_set_key(des_cblock (*key), des_key_schedule schedule); static int des_set_key(des_cblock (*key), des_key_schedule schedule);
@@ -501,6 +501,10 @@ des_key_schedule schedule;
SPtrans[6][(u>>24)&0x3f]; SPtrans[6][(u>>24)&0x3f];
#endif #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]={ static unsigned const char con_salt[128]={
0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9, 0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,
0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1, 0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1,
@@ -531,7 +535,7 @@ static unsigned const char cov_2char[64]={
0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A
}; };
#ifdef PROTO #ifndef NOPROTO
#ifdef PERL5 #ifdef PERL5
char *des_crypt(char *buf,char *salt); char *des_crypt(char *buf,char *salt);
#else #else

View File

@@ -7,7 +7,7 @@ TLIB = tlib /0 /C
# note: the -3 flag produces code for 386, 486, Pentium etc; omit it for 286s # note: the -3 flag produces code for 386, 486, Pentium etc; omit it for 286s
OPTIMIZE= -3 -O2 OPTIMIZE= -3 -O2
#WINDOWS= -W #WINDOWS= -W
CFLAGS = -c -ml -d $(OPTIMIZE) $(WINDOWS) -DMSDOS -DPROTO CFLAGS = -c -ml -d $(OPTIMIZE) $(WINDOWS) -DMSDOS
LFLAGS = -ml $(WINDOWS) LFLAGS = -ml $(WINDOWS)
.c.obj: .c.obj:

View File

@@ -55,11 +55,11 @@ des_key_schedule schedule;
des_cblock (*ivec); des_cblock (*ivec);
int encrypt; int encrypt;
{ {
register unsigned long tin0,tin1; register DES_LONG tin0,tin1;
register unsigned long tout0,tout1,xor0,xor1; register DES_LONG tout0,tout1,xor0,xor1;
register unsigned char *in,*out; register unsigned char *in,*out;
register long l=length; register long l=length;
unsigned long tin[2]; DES_LONG tin[2];
unsigned char *iv; unsigned char *iv;
in=(unsigned char *)input; in=(unsigned char *)input;
@@ -81,7 +81,7 @@ int encrypt;
c2ln(in,tin0,tin1,l); c2ln(in,tin0,tin1,l);
tin0^=tout0; tin[0]=tin0; tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1; 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); tout0=tin[0]; l2c(tout0,out);
tout1=tin[1]; l2c(tout1,out); tout1=tin[1]; l2c(tout1,out);
} }
@@ -97,7 +97,7 @@ int encrypt;
{ {
c2l(in,tin0); tin[0]=tin0; c2l(in,tin0); tin[0]=tin0;
c2l(in,tin1); tin[1]=tin1; 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; tout0=tin[0]^xor0;
tout1=tin[1]^xor1; tout1=tin[1]^xor1;
if (l >= 8) if (l >= 8)

View File

@@ -1,4 +1,4 @@
/* lib/des/ofb64enc.c */ /* lib/des/ofb64ede.c */
/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) /* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
* All rights reserved. * All rights reserved.
* *
@@ -59,12 +59,12 @@ des_key_schedule k1,k2,k3;
des_cblock (*ivec); des_cblock (*ivec);
int *num; int *num;
{ {
register unsigned long v0,v1; register DES_LONG v0,v1;
register int n=*num; register int n=*num;
register long l=length; register long l=length;
des_cblock d; des_cblock d;
register char *dp; register char *dp;
unsigned long ti[2]; DES_LONG ti[2];
unsigned char *iv; unsigned char *iv;
int save=0; int save=0;
@@ -84,9 +84,9 @@ int *num;
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt2((unsigned long *)ti,k1,DES_ENCRYPT); des_encrypt2((DES_LONG *)ti,k1,DES_ENCRYPT);
des_encrypt2((unsigned long *)ti,k2,DES_DECRYPT); des_encrypt2((DES_LONG *)ti,k2,DES_DECRYPT);
des_encrypt2((unsigned long *)ti,k3,DES_ENCRYPT); des_encrypt2((DES_LONG *)ti,k3,DES_ENCRYPT);
v0=ti[0]; v0=ti[0];
v1=ti[1]; v1=ti[1];

View File

@@ -59,12 +59,12 @@ des_key_schedule schedule;
des_cblock (*ivec); des_cblock (*ivec);
int *num; int *num;
{ {
register unsigned long v0,v1,t; register DES_LONG v0,v1,t;
register int n=*num; register int n=*num;
register long l=length; register long l=length;
des_cblock d; des_cblock d;
register char *dp; register char *dp;
unsigned long ti[2]; DES_LONG ti[2];
unsigned char *iv; unsigned char *iv;
int save=0; int save=0;
@@ -80,7 +80,7 @@ int *num;
{ {
if (n == 0) if (n == 0)
{ {
des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT); des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
dp=(char *)d; dp=(char *)d;
t=ti[0]; l2c(t,dp); t=ti[0]; l2c(t,dp);
t=ti[1]; l2c(t,dp); t=ti[1]; l2c(t,dp);

View File

@@ -61,11 +61,11 @@ long length;
des_key_schedule schedule; des_key_schedule schedule;
des_cblock (*ivec); des_cblock (*ivec);
{ {
register unsigned long d0,d1,v0,v1,n=(numbits+7)/8; register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
register unsigned long mask0,mask1; register DES_LONG mask0,mask1;
register long l=length; register long l=length;
register int num=numbits; register int num=numbits;
unsigned long ti[2]; DES_LONG ti[2];
unsigned char *iv; unsigned char *iv;
if (num > 64) return; if (num > 64) return;
@@ -93,7 +93,7 @@ des_cblock (*ivec);
ti[1]=v1; ti[1]=v1;
while (l-- > 0) while (l-- > 0)
{ {
des_encrypt((unsigned long *)ti,schedule,DES_ENCRYPT); des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n); c2ln(in,d0,d1,n);
in+=n; in+=n;
d0=(d0^ti[0])&mask0; d0=(d0^ti[0])&mask0;

View File

@@ -55,8 +55,8 @@ des_key_schedule schedule;
des_cblock (*ivec); des_cblock (*ivec);
int encrypt; int encrypt;
{ {
register unsigned long sin0,sin1,xor0,xor1,tout0,tout1; register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;
unsigned long tin[2]; DES_LONG tin[2];
unsigned char *in,*out,*iv; unsigned char *in,*out,*iv;
in=(unsigned char *)input; in=(unsigned char *)input;
@@ -78,7 +78,7 @@ int encrypt;
c2ln(in,sin0,sin1,length); c2ln(in,sin0,sin1,length);
tin[0]=sin0^xor0; tin[0]=sin0^xor0;
tin[1]=sin1^xor1; tin[1]=sin1^xor1;
des_encrypt((unsigned long *)tin,schedule,DES_ENCRYPT); des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];
xor0=sin0^tout0; xor0=sin0^tout0;
@@ -96,7 +96,7 @@ int encrypt;
c2l(in,sin1); c2l(in,sin1);
tin[0]=sin0; tin[0]=sin0;
tin[1]=sin1; tin[1]=sin1;
des_encrypt((unsigned long *)tin,schedule,DES_DECRYPT); des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0; tout0=tin[0]^xor0;
tout1=tin[1]^xor1; tout1=tin[1]^xor1;
if (length >= 8) if (length >= 8)

View File

@@ -53,23 +53,23 @@
#include "des_locl.h" #include "des_locl.h"
/* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */ /* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */
#define B0(a) (((unsigned long)(a))) #define B0(a) (((DES_LONG)(a)))
#define B1(a) (((unsigned long)(a))<<8) #define B1(a) (((DES_LONG)(a))<<8)
#define B2(a) (((unsigned long)(a))<<16) #define B2(a) (((DES_LONG)(a))<<16)
#define B3(a) (((unsigned long)(a))<<24) #define B3(a) (((DES_LONG)(a))<<24)
/* used to scramble things a bit */ /* used to scramble things a bit */
/* Got the value MIT uses via brute force :-) 2/10/90 eay */ /* 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 (*input);
des_cblock (*output); des_cblock (*output);
long length; long length;
int out_count; int out_count;
des_cblock (*seed); des_cblock (*seed);
{ {
unsigned long z0,z1,t0,t1; DES_LONG z0,z1,t0,t1;
int i; int i;
long l=0; long l=0;
unsigned char *cp; unsigned char *cp;
@@ -89,12 +89,12 @@ des_cblock (*seed);
{ {
if (l > 1) if (l > 1)
{ {
t0= (unsigned long)(*(cp++)); t0= (DES_LONG)(*(cp++));
t0|=(unsigned long)B1(*(cp++)); t0|=(DES_LONG)B1(*(cp++));
l--; l--;
} }
else else
t0= (unsigned long)(*(cp++)); t0= (DES_LONG)(*(cp++));
l--; l--;
/* add */ /* add */
t0+=z0; t0+=z0;
@@ -112,7 +112,7 @@ des_cblock (*seed);
* is one huge number and it is returned in a * is one huge number and it is returned in a
* host dependant byte order. * host dependant byte order.
*/ */
static unsigned long ltmp=1; static DES_LONG ltmp=1;
static unsigned char *c=(unsigned char *)&ltmp; static unsigned char *c=(unsigned char *)&ltmp;
if (c[0]) if (c[0])

View File

@@ -62,12 +62,12 @@ void des_random_key(ret)
unsigned char *ret; unsigned char *ret;
{ {
des_key_schedule ks; des_key_schedule ks;
static unsigned long c=0; static DES_LONG c=0;
static unsigned short pid=0; static unsigned short pid=0;
static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
des_cblock key; des_cblock key;
unsigned char *p; unsigned char *p;
unsigned long t; DES_LONG t;
int i; int i;
#ifdef MSDOS #ifdef MSDOS
@@ -85,9 +85,9 @@ unsigned char *ret;
} }
seed=0; seed=0;
} }
t=(unsigned long)time(NULL); t=(DES_LONG)time(NULL);
l2c(t,p); l2c(t,p);
t=(unsigned long)((pid)|((c++)<<16)); t=(DES_LONG)((pid)|((c++)<<16));
l2c(t,p); l2c(t,p);
des_set_odd_parity((des_cblock *)data); des_set_odd_parity((des_cblock *)data);

View File

@@ -93,7 +93,7 @@
#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
#endif #endif
#ifndef _LIBC #if !defined(_LIBC) && !defined(MSDOS)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
@@ -118,7 +118,7 @@ struct IOSB {
#define NX509_SIG 32 #define NX509_SIG 32
#endif #endif
#ifdef PROTO #ifndef NOPROTO
static void read_till_nl(FILE *); static void read_till_nl(FILE *);
static int read_pw(char *buf, char *buff, int size, char *prompt, int verify); static int read_pw(char *buf, char *buff, int size, char *prompt, int verify);
static void recsig(int); static void recsig(int);

View File

@@ -1,3 +1,50 @@
/* lib/des/rpc_des.h */
/* Copyright (C) 1995 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.]
*/
/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */ /* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for

View File

@@ -49,7 +49,7 @@
#include "des_locl.h" #include "des_locl.h"
#include "version.h" #include "version.h"
#ifdef PROTO #ifndef NOPROTO
int _des_crypt(char *buf,int len,struct desparams *desp); int _des_crypt(char *buf,int len,struct desparams *desp);
#else #else
int _des_crypt(); int _des_crypt();

View File

@@ -56,7 +56,7 @@
#include "podd.h" #include "podd.h"
#include "sk.h" #include "sk.h"
#ifdef PROTO #ifndef NOPROTO
static int check_parity(des_cblock (*key)); static int check_parity(des_cblock (*key));
#else #else
static int check_parity(); static int check_parity();
@@ -150,9 +150,9 @@ int des_set_key(key, schedule)
des_cblock (*key); des_cblock (*key);
des_key_schedule schedule; des_key_schedule schedule;
{ {
register unsigned long c,d,t,s; register DES_LONG c,d,t,s;
register unsigned char *in; register unsigned char *in;
register unsigned long *k; register DES_LONG *k;
register int i; register int i;
if (des_check_key) if (des_check_key)
@@ -164,7 +164,7 @@ des_key_schedule schedule;
return(-2); return(-2);
} }
k=(unsigned long *)schedule; k=(DES_LONG *)schedule;
in=(unsigned char *)key; in=(unsigned char *)key;
c2l(in,c); c2l(in,c);

View File

@@ -45,7 +45,7 @@
* [including the GNU Public Licence.] * [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 */ /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000L,0x00000010L,0x20000000L,0x20000010L, 0x00000000L,0x00000010L,0x20000000L,0x20000010L,

View File

@@ -103,7 +103,7 @@ struct tms {
#define BUFSIZE ((long)1024*8) #define BUFSIZE ((long)1024*8)
long run=0; long run=0;
#ifdef PROTO #ifndef NOPROTO
double Time_F(int s); double Time_F(int s);
#else #else
double Time_F(); double Time_F();
@@ -116,7 +116,7 @@ double Time_F();
#define SIGRETTYPE int #define SIGRETTYPE int
#endif #endif
#ifdef PROTO #ifndef NOPROTO
SIGRETTYPE sig_done(int sig); SIGRETTYPE sig_done(int sig);
#else #else
SIGRETTYPE sig_done(); SIGRETTYPE sig_done();

View File

@@ -45,7 +45,7 @@
* [including the GNU Public Licence.] * [including the GNU Public Licence.]
*/ */
static const unsigned long des_SPtrans[8][64]={ static const DES_LONG des_SPtrans[8][64]={
{ {
/* nibble 0 */ /* nibble 0 */
0x00820200L, 0x00020000L, 0x80800000L, 0x80820200L, 0x00820200L, 0x00020000L, 0x80800000L, 0x80820200L,

View File

@@ -1,3 +1,50 @@
/* lib/des/supp.c */
/* Copyright (C) 1995 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.]
*/
/* /*
* Copyright (c) 1995 * Copyright (c) 1995
* Mark Murray. All rights reserved. * Mark Murray. All rights reserved.

View File

@@ -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 SGI Challenge (MIPS R4400 200mhz) - gcc -O2
set_key per sec = 114141.13 ( 8.8uS) set_key per sec = 114141.13 ( 8.8uS)
DES ecb bytes per sec = 1573472.84 ( 5.1uS) 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) DES cbc bytes per sec = 1356515.84 ( 5.9uS)
crypt per sec = 6223.92 (160.7uS) 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 SGI Indy (MIPS R4600 133mhz) -cc -O2
set_key per sec = 88470.54 ( 11.3uS) set_key per sec = 88470.54 ( 11.3uS)
DES ecb bytes per sec = 1023040.33 ( 7.8uS) DES ecb bytes per sec = 1023040.33 ( 7.8uS)