This commit was generated by cvs2svn to compensate for changes in r50894,
which included commits to RCS files with non-trunk default branches.
This commit is contained in:
commit
056bcb03a1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=50895
@ -1,7 +1,7 @@
|
||||
Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
All rights reserved.
|
||||
|
||||
This package is an DES implementation written by Eric Young (eay@mincom.oz.au).
|
||||
This package is an DES implementation written by Eric Young (eay@cryptsoft.com).
|
||||
The implementation was written so as to conform with MIT's libdes.
|
||||
|
||||
This library is free for commercial and non-commercial use as long as
|
||||
@ -25,7 +25,7 @@ are met:
|
||||
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 product includes software developed by Eric Young (eay@cryptsoft.com)
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
|
@ -168,7 +168,7 @@ CODE:
|
||||
{
|
||||
des_cblock c;
|
||||
|
||||
des_3ecb_encrypt((des_cblock *)input,(des_cblock *)&c,
|
||||
des_ecb3_encrypt((des_cblock *)input,(des_cblock *)&c,
|
||||
*ks1,*ks2,encrypt);
|
||||
RETVAL= &c;
|
||||
}
|
||||
|
@ -30,13 +30,13 @@ turn on the relevent option in the Makefile
|
||||
There are some special Makefile targets that make life easier.
|
||||
make cc - standard cc build
|
||||
make gcc - standard gcc build
|
||||
make x86-elf - x86 assember (elf), linux-elf.
|
||||
make x86-out - x86 assember (a.out), FreeBSD
|
||||
make x86-solaris- x86 assember
|
||||
make x86-bsdi - x86 assember (a.out with primative assember).
|
||||
make x86-elf - x86 assembler (elf), linux-elf.
|
||||
make x86-out - x86 assembler (a.out), FreeBSD
|
||||
make x86-solaris- x86 assembler
|
||||
make x86-bsdi - x86 assembler (a.out with primative assembler).
|
||||
|
||||
If at all possible use the assember (for Windows NT/95, use
|
||||
asm/win32.obj to link with). The x86 assember is very very fast.
|
||||
If at all possible use the assembler (for Windows NT/95, use
|
||||
asm/win32.obj to link with). The x86 assembler is very very fast.
|
||||
|
||||
A make install will by default install
|
||||
libdes.a in /usr/local/lib/libdes.a
|
||||
|
@ -71,7 +71,7 @@ key. The reason for this is that an identical bit stream would be
|
||||
produced each time from the same parameters. This would be
|
||||
susceptible to a 'known plaintext' attack.
|
||||
|
||||
Triple ECB Mode (des_3ecb_encrypt())
|
||||
Triple ECB Mode (des_ecb3_encrypt())
|
||||
- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
|
||||
- As for ECB encryption but increases the effective key length to 112 bits.
|
||||
- If both keys are the same it is equivalent to encrypting once with
|
||||
|
250
crypto/libdes/Makefile.lit
Normal file
250
crypto/libdes/Makefile.lit
Normal file
@ -0,0 +1,250 @@
|
||||
# You must select the correct terminal control system to be used to
|
||||
# turn character echo off when reading passwords. There a 5 systems
|
||||
# SGTTY - the old BSD system
|
||||
# TERMIO - most system V boxes
|
||||
# TERMIOS - SGI (ala IRIX).
|
||||
# VMS - the DEC operating system
|
||||
# MSDOS - we all know what it is :-)
|
||||
# read_pwd.c makes a reasonable guess at what is correct.
|
||||
|
||||
# Targets
|
||||
# make - twidle the options yourself :-)
|
||||
# make cc - standard cc options
|
||||
# make gcc - standard gcc options
|
||||
# make x86-elf - linux-elf etc
|
||||
# make x86-out - linux-a.out, FreeBSD etc
|
||||
# make x86-solaris
|
||||
# make x86-bdsi
|
||||
|
||||
# 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= -DLIBDES_LIT -DRAND -DTERMIO #-DNOCONST
|
||||
|
||||
# Version 1.94 has changed the strings_to_key function so that it is
|
||||
# now compatible with MITs when the string is longer than 8 characters.
|
||||
# If you wish to keep the old version, uncomment the following line.
|
||||
# This will affect the -E/-D options on des(1).
|
||||
#OPTS1= -DOLD_STR_TO_KEY
|
||||
|
||||
# There are 4 possible performance options
|
||||
# -DDES_PTR
|
||||
# -DDES_RISC1
|
||||
# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
|
||||
# -DDES_UNROLL
|
||||
# after the initial build, run 'des_opts' to see which options are best
|
||||
# for your platform. There are some listed in options.txt
|
||||
#OPTS2= -DDES_PTR
|
||||
#OPTS3= -DDES_RISC1 # or DES_RISC2
|
||||
#OPTS4= -DDES_UNROLL
|
||||
|
||||
OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
|
||||
|
||||
MAKE=make -f Makefile
|
||||
#CC=cc
|
||||
#CFLAG= -O
|
||||
|
||||
CC=gcc
|
||||
#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
|
||||
CFLAG= -O3 -fomit-frame-pointer
|
||||
|
||||
CFLAGS=$(OPTS) $(CFLAG)
|
||||
CPP=$(CC) -E
|
||||
AS=as
|
||||
|
||||
# Assember version of des_encrypt*().
|
||||
DES_ENC=des_enc.o fcrypt_b.o # normal C version
|
||||
#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
|
||||
#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
|
||||
#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
|
||||
#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
|
||||
|
||||
LIBDIR=/usr/local/lib
|
||||
BINDIR=/usr/local/bin
|
||||
INCDIR=/usr/local/include
|
||||
MANDIR=/usr/local/man
|
||||
MAN1=1
|
||||
MAN3=3
|
||||
SHELL=/bin/sh
|
||||
OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
|
||||
OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
|
||||
xcbc_enc.o qud_cksm.o \
|
||||
cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
|
||||
enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
|
||||
rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
|
||||
|
||||
GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
|
||||
des.doc options.txt asm
|
||||
GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
|
||||
des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
|
||||
Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
|
||||
des.org des_locl.org
|
||||
TESTING_LIT= destest speed des_opts
|
||||
TESTING_FULL= rpw $(TESTING_LIT)
|
||||
TESTING_SRC_LIT=destest.c speed.c des_opts.c
|
||||
TESTING_SRC_FULL=rpw.c $(TESTING_SRC_LIT)
|
||||
HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
|
||||
HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
|
||||
LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
|
||||
LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c \
|
||||
cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
|
||||
enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
|
||||
rand_key.c rpc_enc.c str2key.c supp.c \
|
||||
xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
|
||||
|
||||
PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
|
||||
|
||||
OBJ= $(OBJ_LIT)
|
||||
GENERAL=$(GENERAL_LIT)
|
||||
TESTING=$(TESTING_LIT)
|
||||
TESTING_SRC=$(TESTING_SRC_LIT)
|
||||
HEADERS=$(HEADERS_LIT)
|
||||
LIBDES= $(LIBDES_LIT)
|
||||
|
||||
ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
|
||||
|
||||
DLIB= libdes.a
|
||||
|
||||
all: $(DLIB) $(TESTING)
|
||||
|
||||
cc:
|
||||
$(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
|
||||
|
||||
gcc:
|
||||
$(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-elf:
|
||||
$(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-out:
|
||||
$(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-solaris:
|
||||
$(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-bsdi:
|
||||
$(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
|
||||
|
||||
# elf
|
||||
asm/dx86-elf.o: asm/dx86unix.cpp
|
||||
$(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
|
||||
|
||||
asm/yx86-elf.o: asm/yx86unix.cpp
|
||||
$(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
|
||||
|
||||
# solaris
|
||||
asm/dx86-sol.o: asm/dx86unix.cpp
|
||||
$(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
|
||||
as -o asm/dx86-sol.o asm/dx86-sol.s
|
||||
rm -f asm/dx86-sol.s
|
||||
|
||||
asm/yx86-sol.o: asm/yx86unix.cpp
|
||||
$(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
|
||||
as -o asm/yx86-sol.o asm/yx86-sol.s
|
||||
rm -f asm/yx86-sol.s
|
||||
|
||||
# a.out
|
||||
asm/dx86-out.o: asm/dx86unix.cpp
|
||||
$(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
|
||||
|
||||
asm/yx86-out.o: asm/yx86unix.cpp
|
||||
$(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
|
||||
|
||||
# bsdi
|
||||
asm/dx86bsdi.o: asm/dx86unix.cpp
|
||||
$(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
|
||||
|
||||
asm/yx86bsdi.o: asm/yx86unix.cpp
|
||||
$(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
|
||||
|
||||
asm/dx86unix.cpp:
|
||||
(cd asm; perl des-586.pl cpp >dx86unix.cpp)
|
||||
|
||||
asm/yx86unix.cpp:
|
||||
(cd asm; perl crypt586.pl cpp >yx86unix.cpp)
|
||||
|
||||
test: all
|
||||
./destest
|
||||
|
||||
$(DLIB): $(OBJ)
|
||||
/bin/rm -f $(DLIB)
|
||||
ar cr $(DLIB) $(OBJ)
|
||||
-if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
|
||||
else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
|
||||
else exit 0; fi; fi
|
||||
|
||||
des_opts: des_opts.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
|
||||
|
||||
destest: destest.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o destest destest.o $(DLIB)
|
||||
|
||||
rpw: rpw.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
|
||||
|
||||
speed: speed.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o speed speed.o $(DLIB)
|
||||
|
||||
des: des.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o des des.o $(DLIB)
|
||||
|
||||
tags:
|
||||
ctags $(TESTING_SRC) $(LIBDES)
|
||||
|
||||
tar_lit:
|
||||
/bin/mv Makefile Makefile.tmp
|
||||
/bin/cp Makefile.lit Makefile
|
||||
tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \
|
||||
$(GENERAL_LIT) $(TESTING_SRC_LIT)
|
||||
/bin/rm -f Makefile
|
||||
/bin/mv Makefile.tmp Makefile
|
||||
|
||||
tar:
|
||||
tar chf libdes.tar $(ALL)
|
||||
|
||||
shar:
|
||||
shar $(ALL) >libdes.shar
|
||||
|
||||
depend:
|
||||
makedepend $(LIBDES) $(TESTING_SRC)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
|
||||
|
||||
dclean:
|
||||
sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
|
||||
mv -f Makefile.new Makefile
|
||||
|
||||
# Eric is probably going to choke when he next looks at this --tjh
|
||||
install:
|
||||
if test $(INSTALLTOP); then \
|
||||
echo SSL style install; \
|
||||
cp $(DLIB) $(INSTALLTOP)/lib; \
|
||||
if test -s /bin/ranlib; then \
|
||||
/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
|
||||
else \
|
||||
if test -s /usr/bin/ranlib; then \
|
||||
/usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
|
||||
fi; fi; \
|
||||
chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
|
||||
cp des.h $(INSTALLTOP)/include; \
|
||||
chmod 644 $(INSTALLTOP)/include/des.h; \
|
||||
else \
|
||||
echo Standalone install; \
|
||||
cp $(DLIB) $(LIBDIR)/$(DLIB); \
|
||||
if test -s /bin/ranlib; then \
|
||||
/bin/ranlib $(LIBDIR)/$(DLIB); \
|
||||
else \
|
||||
if test -s /usr/bin/ranlib; then \
|
||||
/usr/bin/ranlib $(LIBDIR)/$(DLIB); \
|
||||
fi; \
|
||||
fi; \
|
||||
chmod 644 $(LIBDIR)/$(DLIB); \
|
||||
cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
|
||||
chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
|
||||
cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \
|
||||
chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \
|
||||
cp des.h $(INCDIR)/des.h; \
|
||||
chmod 644 $(INCDIR)/des.h; \
|
||||
fi
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
@ -5,35 +5,42 @@
|
||||
DIR= des
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= cc -E
|
||||
INCLUDES=
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=-I../../include
|
||||
CFLAG=-g
|
||||
INSTALL_PREFIX=
|
||||
OPENSSLDIR= /usr/local/ssl
|
||||
INSTALLTOP=/usr/local/ssl
|
||||
MAKE= make -f Makefile.ssl
|
||||
MAKEDEPEND= makedepend -fMakefile.ssl
|
||||
MAKEDEPEND= $(TOP)/util/domd $(TOP)
|
||||
MAKEFILE= Makefile.ssl
|
||||
DES_ENC= des_enc.o
|
||||
AR= ar r
|
||||
DES_ENC= des_enc.o fcrypt_b.o
|
||||
# or use
|
||||
#DES_ENC= dx86-elf.o yx86-elf.o
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
|
||||
GENERAL=Makefile des.org des_locl.org
|
||||
GENERAL=Makefile
|
||||
TEST=destest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC= cbc3_enc.c cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
|
||||
ecb3_enc.c ecb_enc.c ede_enc.c enc_read.c enc_writ.c \
|
||||
fcrypt.c ncbc_enc.c ofb64enc.c ofb_enc.c pcbc_enc.c \
|
||||
LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
|
||||
ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
|
||||
fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
|
||||
qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
|
||||
xcbc_enc.c des_enc.c \
|
||||
str2key.c cfb64ede.c ofb64ede.c supp.c
|
||||
des_enc.c fcrypt_b.c read2pwd.c \
|
||||
fcrypt.c xcbc_enc.c \
|
||||
str2key.c cfb64ede.c ofb64ede.c supp.c ede_cbcm_enc.c
|
||||
|
||||
LIBOBJ= set_key.o ecb_enc.o ede_enc.o cbc_enc.o cbc3_enc.o \
|
||||
LIBOBJ= set_key.o ecb_enc.o cbc_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 \
|
||||
enc_read.o enc_writ.o ofb64enc.o \
|
||||
ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
|
||||
xcbc_enc.o ${DES_ENC} \
|
||||
read_pwd.o rpc_enc.o cbc_cksm.o supp.o
|
||||
${DES_ENC} read2pwd.o \
|
||||
fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o \
|
||||
ede_cbcm_enc.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
@ -48,41 +55,68 @@ top:
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
ar r $(LIB) $(LIBOBJ)
|
||||
sh $(TOP)/util/ranlib.sh $(LIB)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB)
|
||||
@touch lib
|
||||
|
||||
asm/dx86-elf.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
des: des.o cbc3_enc.o lib
|
||||
$(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
|
||||
|
||||
# elf
|
||||
asm/dx86-elf.o: asm/dx86unix.cpp
|
||||
$(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o
|
||||
|
||||
asm/dx86-sol.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
$(CPP) -DSOL asm/dx86unix.cpp | as -o asm/dx86-sol.o
|
||||
asm/yx86-elf.o: asm/yx86unix.cpp
|
||||
$(CPP) -DELF asm/yx86unix.cpp | as -o asm/yx86-elf.o
|
||||
|
||||
asm/dx86-out.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
# solaris
|
||||
asm/dx86-sol.o: asm/dx86unix.cpp
|
||||
$(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
|
||||
as -o asm/dx86-sol.o asm/dx86-sol.s
|
||||
rm -f asm/dx86-sol.s
|
||||
|
||||
asm/yx86-sol.o: asm/yx86unix.cpp
|
||||
$(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
|
||||
as -o asm/yx86-sol.o asm/yx86-sol.s
|
||||
rm -f asm/yx86-sol.s
|
||||
|
||||
# a.out
|
||||
asm/dx86-out.o: asm/dx86unix.cpp
|
||||
$(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
|
||||
|
||||
asm/dx86bsdi.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
$(CPP) -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o
|
||||
asm/yx86-out.o: asm/yx86unix.cpp
|
||||
$(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o
|
||||
|
||||
# bsdi
|
||||
asm/dx86bsdi.o: asm/dx86unix.cpp
|
||||
$(CPP) -DBSDI asm/dx86unix.cpp | sed 's/ :/:/' | as -o asm/dx86bsdi.o
|
||||
|
||||
asm/yx86bsdi.o: asm/yx86unix.cpp
|
||||
$(CPP) -DBSDI asm/yx86unix.cpp | sed 's/ :/:/' | as -o asm/yx86bsdi.o
|
||||
|
||||
asm/dx86unix.cpp: asm/des-586.pl
|
||||
(cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp)
|
||||
|
||||
asm/yx86unix.cpp: asm/crypt586.pl
|
||||
(cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp)
|
||||
|
||||
files:
|
||||
perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
|
||||
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
/bin/rm -f Makefile
|
||||
$(TOP)/util/point.sh Makefile.ssl Makefile ;
|
||||
/bin/rm -f 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)
|
||||
@$(TOP)/util/point.sh Makefile.ssl Makefile
|
||||
@$(TOP)/util/point.sh ../../perlasm asm/perlasm
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install: installs
|
||||
|
||||
installs:
|
||||
@for i in $(EXHEADER) ; \
|
||||
do \
|
||||
(cp $$i $(INSTALLTOP)/include/$$i; \
|
||||
chmod 644 $(INSTALLTOP)/include/$$i ) \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
@ -94,15 +128,81 @@ lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
depend:
|
||||
$(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
|
||||
$(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
errors:
|
||||
rm -f asm/dx86unix.cpp asm/yx86unix.cpp *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
cbc_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
cbc_cksm.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
cbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
cbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h ncbc_enc.c
|
||||
cfb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
cfb64ede.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
cfb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
cfb64enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
cfb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
cfb_enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
des_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
des_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_locl.h ncbc_enc.c
|
||||
ecb3_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
ecb3_enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
ecb_enc.o: des_locl.h spr.h
|
||||
ede_cbcm_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
ede_cbcm_enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
enc_read.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
|
||||
enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
enc_read.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h
|
||||
enc_read.o: ../cryptlib.h des_locl.h
|
||||
enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
|
||||
enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
enc_writ.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
|
||||
enc_writ.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h
|
||||
fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des.h
|
||||
fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/e_os2.h
|
||||
fcrypt.o: ../../include/openssl/opensslconf.h
|
||||
fcrypt.o: ../../include/openssl/opensslconf.h des_locl.h des_locl.h
|
||||
fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
fcrypt_b.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
ofb64ede.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
ofb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
ofb64enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
ofb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
ofb_enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
pcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
pcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
rand_key.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
|
||||
read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
read_pwd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h
|
||||
read_pwd.o: ../cryptlib.h des_locl.h
|
||||
rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h
|
||||
set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
set_key.o: ../../include/openssl/opensslconf.h des_locl.h podd.h sk.h
|
||||
str2key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
str2key.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
supp.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
supp.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
|
||||
xcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h
|
||||
|
@ -7,6 +7,15 @@
|
||||
# MSDOS - we all know what it is :-)
|
||||
# read_pwd.c makes a reasonable guess at what is correct.
|
||||
|
||||
# Targets
|
||||
# make - twidle the options yourself :-)
|
||||
# make cc - standard cc options
|
||||
# make gcc - standard gcc options
|
||||
# make x86-elf - linux-elf etc
|
||||
# make x86-out - linux-a.out, FreeBSD etc
|
||||
# make x86-solaris
|
||||
# make x86-bdsi
|
||||
|
||||
# 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.
|
||||
|
||||
@ -27,23 +36,29 @@ OPTS0= -DRAND -DTERMIO #-DNOCONST
|
||||
# for your platform. There are some listed in options.txt
|
||||
#OPTS2= -DDES_PTR
|
||||
#OPTS3= -DDES_RISC1 # or DES_RISC2
|
||||
OPTS4= -DDES_UNROLL
|
||||
#OPTS4= -DDES_UNROLL
|
||||
|
||||
OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
|
||||
|
||||
CC=cc
|
||||
CFLAGS= -D_HPUX_SOURCE -Aa +O2 $(OPTS) $(CFLAG)
|
||||
MAKE=make -f Makefile
|
||||
#CC=cc
|
||||
#CFLAG= -O
|
||||
|
||||
#CC=gcc
|
||||
#CFLAGS= -O3 -fomit-frame-pointer $(OPTS) $(CFLAG)
|
||||
CC=gcc
|
||||
#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
|
||||
CFLAG= -O3 -fomit-frame-pointer
|
||||
|
||||
CFLAGS=$(OPTS) $(CFLAG)
|
||||
CPP=$(CC) -E
|
||||
AS=as
|
||||
RANLIB=ranlib
|
||||
|
||||
DES_ENC=des_enc.o # normal C version
|
||||
#DES_ENC=asm/dx86-elf.o # elf format x86
|
||||
#DES_ENC=asm/dx86-out.o # a.out format x86
|
||||
#DES_ENC=asm/dx86-sol.o # solaris format x86
|
||||
#DES_ENC=asm/dx86bsdi.o # bsdi format x86
|
||||
# Assember version of des_encrypt*().
|
||||
DES_ENC=des_enc.o fcrypt_b.o # normal C version
|
||||
#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
|
||||
#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
|
||||
#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
|
||||
#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
|
||||
|
||||
LIBDIR=/usr/local/lib
|
||||
BINDIR=/usr/local/bin
|
||||
@ -52,148 +67,177 @@ MANDIR=/usr/local/man
|
||||
MAN1=1
|
||||
MAN3=3
|
||||
SHELL=/bin/sh
|
||||
OBJS= cbc3_enc.o cbc_cksm.o cbc_enc.o ncbc_enc.o pcbc_enc.o qud_cksm.o \
|
||||
cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o ecb_enc.o ede_enc.o \
|
||||
enc_read.o enc_writ.o fcrypt.o ofb64ede.o ofb64enc.o ofb_enc.o \
|
||||
rand_key.o read_pwd.o set_key.o rpc_enc.o str2key.o supp.o \
|
||||
$(DES_ENC) xcbc_enc.o
|
||||
OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
|
||||
OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
|
||||
xcbc_enc.o qud_cksm.o cbc3_enc.o \
|
||||
cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
|
||||
enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
|
||||
rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
|
||||
|
||||
GENERAL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
|
||||
GNUmakefile des.man DES.pm DES.pod DES.xs Makefile.PL \
|
||||
Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
|
||||
des.org des_locl.org
|
||||
DES= des.c
|
||||
TESTING=rpw.c $(TESTING_LIT)
|
||||
HEADERS= $(HEADERS_LIT) rpc_des.h
|
||||
LIBDES= cbc_cksm.c pcbc_enc.c qud_cksm.c \
|
||||
cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c cbc3_enc.c \
|
||||
enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
|
||||
rand_key.c rpc_enc.c str2key.c supp.c \
|
||||
xcbc_enc.c $(LIBDES_LIT) read_pwd.c
|
||||
|
||||
TESTING_LIT=destest.c speed.c des_opts.c
|
||||
GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
|
||||
des.doc options.txt asm
|
||||
GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
|
||||
des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
|
||||
Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
|
||||
des.org des_locl.org
|
||||
TESTING_LIT= destest speed des_opts
|
||||
TESTING_FULL= rpw des $(TESTING_LIT)
|
||||
TESTING_SRC_LIT=destest.c speed.c des_opts.c
|
||||
TESTING_SRC_FULL=rpw.c des.c $(TESTING_SRC_LIT)
|
||||
HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
|
||||
LIBDES_LIT=ede_enc.c cbc_enc.c ncbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c
|
||||
HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
|
||||
LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
|
||||
LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c cbc3_enc.c \
|
||||
cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
|
||||
enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
|
||||
rand_key.c rpc_enc.c str2key.c supp.c \
|
||||
xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
|
||||
|
||||
PERL= des.pl testdes.pl doIP doIP2 doPC1 doPC2 PC1 PC2 shifts.pl
|
||||
PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
|
||||
|
||||
ALL= $(GENERAL) $(DES) $(TESTING) $(LIBDES) $(PERL) $(HEADERS)
|
||||
OBJ= $(OBJ_FULL)
|
||||
GENERAL=$(GENERAL_FULL)
|
||||
TESTING=$(TESTING_FULL)
|
||||
TESTING_SRC=$(TESTING_SRC_FULL)
|
||||
HEADERS=$(HEADERS_FULL)
|
||||
LIBDES= $(LIBDES_FULL)
|
||||
|
||||
ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
|
||||
|
||||
DLIB= libdes.a
|
||||
|
||||
all: $(DLIB) destest rpw des speed des_opts
|
||||
all: $(DLIB) $(TESTING)
|
||||
|
||||
cc:
|
||||
make CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
|
||||
$(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
|
||||
|
||||
gcc:
|
||||
make CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
|
||||
$(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-elf:
|
||||
make DES_ENC=asm/dx86-elf.o CC=gcc CFLAGS="-DELF -O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
|
||||
$(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-out:
|
||||
make DES_ENC=asm/dx86-out.o CC=gcc CFLAGS="-DOUT -O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
|
||||
$(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-solaris:
|
||||
make DES_ENC=asm/dx86-sol.o CFLAGS="-DSOL -O $(OPTS) $(CFLAG)" all
|
||||
$(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
|
||||
|
||||
x86-bsdi:
|
||||
make DES_ENC=asm/dx86bsdi.o CC=gcc CFLAGS="-DBSDI -O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
|
||||
$(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
|
||||
|
||||
asm/dx86-elf.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
$(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o
|
||||
# elf
|
||||
asm/dx86-elf.o: asm/dx86unix.cpp
|
||||
$(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
|
||||
|
||||
asm/dx86-sol.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
$(CPP) -DSOL asm/dx86unix.cpp | as -o asm/dx86-sol.o
|
||||
asm/yx86-elf.o: asm/yx86unix.cpp
|
||||
$(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
|
||||
|
||||
asm/dx86-out.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
$(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
|
||||
# solaris
|
||||
asm/dx86-sol.o: asm/dx86unix.cpp
|
||||
$(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
|
||||
as -o asm/dx86-sol.o asm/dx86-sol.s
|
||||
rm -f asm/dx86-sol.s
|
||||
|
||||
asm/dx86bsdi.o: asm/dx86-cpp.s asm/dx86unix.cpp
|
||||
$(CPP) -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o
|
||||
asm/yx86-sol.o: asm/yx86unix.cpp
|
||||
$(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
|
||||
as -o asm/yx86-sol.o asm/yx86-sol.s
|
||||
rm -f asm/yx86-sol.s
|
||||
|
||||
# a.out
|
||||
asm/dx86-out.o: asm/dx86unix.cpp
|
||||
$(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
|
||||
|
||||
asm/yx86-out.o: asm/yx86unix.cpp
|
||||
$(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
|
||||
|
||||
# bsdi
|
||||
asm/dx86bsdi.o: asm/dx86unix.cpp
|
||||
$(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
|
||||
|
||||
asm/yx86bsdi.o: asm/yx86unix.cpp
|
||||
$(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
|
||||
|
||||
asm/dx86unix.cpp:
|
||||
(cd asm; perl des-586.pl cpp >dx86unix.cpp)
|
||||
|
||||
asm/yx86unix.cpp:
|
||||
(cd asm; perl crypt586.pl cpp >yx86unix.cpp)
|
||||
|
||||
test: all
|
||||
./destest
|
||||
|
||||
$(DLIB): $(OBJS)
|
||||
$(DLIB): $(OBJ)
|
||||
/bin/rm -f $(DLIB)
|
||||
ar cr $(DLIB) $(OBJS)
|
||||
-if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
|
||||
else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
|
||||
else exit 0; fi; fi
|
||||
ar cr $(DLIB) $(OBJ)
|
||||
$(RANLIB) $(DLIB)
|
||||
|
||||
des_opts: des_opts.o libdes.a
|
||||
$(CC) $(CFLAGS) -o des_opts des_opts.o libdes.a
|
||||
des_opts: des_opts.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
|
||||
|
||||
destest: destest.o libdes.a
|
||||
$(CC) $(CFLAGS) -o destest destest.o libdes.a
|
||||
destest: destest.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o destest destest.o $(DLIB)
|
||||
|
||||
rpw: rpw.o libdes.a
|
||||
$(CC) $(CFLAGS) -o rpw rpw.o libdes.a
|
||||
rpw: rpw.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
|
||||
|
||||
speed: speed.o libdes.a
|
||||
$(CC) $(CFLAGS) -o speed speed.o libdes.a
|
||||
speed: speed.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o speed speed.o $(DLIB)
|
||||
|
||||
des: des.o libdes.a
|
||||
$(CC) $(CFLAGS) -o des des.o libdes.a
|
||||
des: des.o $(DLIB)
|
||||
$(CC) $(CFLAGS) -o des des.o $(DLIB)
|
||||
|
||||
tags:
|
||||
ctags $(DES) $(TESTING) $(LIBDES)
|
||||
ctags $(TESTING_SRC) $(LIBDES)
|
||||
|
||||
tar_lit:
|
||||
/bin/mv Makefile Makefile.tmp
|
||||
/bin/cp Makefile.lit Makefile
|
||||
tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \
|
||||
$(GENERAL_LIT) $(TESTING_LIT)
|
||||
for i in $(HEADERS_LIT) $(LIBDES_LIT) $(GENERAL_LIT) $(TESTING_SRC_LIT) ;\
|
||||
do \
|
||||
n="$$n des/$$i"; \
|
||||
done; \
|
||||
( cd .. ; tar chf - $$n )| gzip > libdes-l.tgz
|
||||
/bin/rm -f Makefile
|
||||
/bin/mv Makefile.tmp Makefile
|
||||
|
||||
tar:
|
||||
tar chf libdes.tar $(ALL)
|
||||
mv Makefile Makefile.tmp
|
||||
/bin/cp Makefile.uni Makefile
|
||||
for i in $(ALL) ;\
|
||||
do \
|
||||
n="$$n des/$$i"; \
|
||||
done; \
|
||||
( cd .. ; tar chf - $$n )| gzip > libdes.tgz
|
||||
/bin/rm -f Makefile
|
||||
/bin/mv Makefile.tmp Makefile
|
||||
|
||||
shar:
|
||||
shar $(ALL) >libdes.shar
|
||||
|
||||
depend:
|
||||
makedepend $(LIBDES) $(DES) $(TESTING)
|
||||
makedepend $(LIBDES) $(TESTING_SRC)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o tags core rpw destest des speed $(DLIB) .nfs* *.old \
|
||||
*.bak destest rpw des_opts asm/*.o
|
||||
/bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
|
||||
|
||||
dclean:
|
||||
sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
|
||||
mv -f Makefile.new Makefile
|
||||
|
||||
# Eric is probably going to choke when he next looks at this --tjh
|
||||
install: $(DLIB) des
|
||||
install: des
|
||||
if test $(INSTALLTOP); then \
|
||||
echo SSL style install; \
|
||||
cp $(DLIB) $(INSTALLTOP)/lib; \
|
||||
if test -s /bin/ranlib; then \
|
||||
/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
|
||||
else \
|
||||
if test -s /usr/bin/ranlib; then \
|
||||
/usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
|
||||
fi; fi; \
|
||||
$(RANLIB) $(DLIB); \
|
||||
chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
|
||||
cp des.h $(INSTALLTOP)/include; \
|
||||
chmod 644 $(INSTALLTOP)/include/des.h; \
|
||||
cp des $(INSTALLTOP)/bin; \
|
||||
chmod 755 $(INSTALLTOP)/bin/des; \
|
||||
else \
|
||||
echo Standalone install; \
|
||||
cp $(DLIB) $(LIBDIR)/$(DLIB); \
|
||||
if test -s /bin/ranlib; then \
|
||||
/bin/ranlib $(LIBDIR)/$(DLIB); \
|
||||
else \
|
||||
if test -s /usr/bin/ranlib; then \
|
||||
/usr/bin/ranlib $(LIBDIR)/$(DLIB); \
|
||||
fi; \
|
||||
fi; \
|
||||
$(RANLIB) $(DLIB); \
|
||||
chmod 644 $(LIBDIR)/$(DLIB); \
|
||||
cp des $(BINDIR)/des; \
|
||||
chmod 711 $(BINDIR)/des; \
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
libdes, Version 4.01 13-Jan-97
|
||||
libdes, Version 4.01 10-Jan-97
|
||||
|
||||
Copyright (c) 1997, Eric Young
|
||||
All rights reserved.
|
||||
@ -50,5 +50,5 @@ It is worth noting that on sparc and Alpha CPUs, performance of the DES
|
||||
library can vary by upto %10 due to the positioning of files after application
|
||||
linkage.
|
||||
|
||||
Eric Young (eay@mincom.oz.au)
|
||||
Eric Young (eay@cryptsoft.com)
|
||||
|
||||
|
@ -1,8 +1,38 @@
|
||||
Version 4.01 14/01/97
|
||||
Even faster inner loop in the DES assember for x86 and a modification
|
||||
Fixed the weak key values which were wrong :-(
|
||||
Defining SIGACTION causes sigaction() to be used instead of signal().
|
||||
SIGUSR1/SIGUSR2 are no longer mapped in the read tty stuff because it
|
||||
can cause problems. This should hopefully not affect normal
|
||||
applications.
|
||||
|
||||
Version 4.04
|
||||
Fixed a few tests in destest. Also added x86 assember for
|
||||
des_ncbc_encrypt() which is the standard cbc mode function.
|
||||
This makes a very very large performace difference.
|
||||
Ariel Glenn ariel@columbia.edu reports that the terminal
|
||||
'turn echo off' can return (errno == EINVAL) under solaris
|
||||
when redirection is used. So I now catch that as well as ENOTTY.
|
||||
|
||||
|
||||
Version 4.03
|
||||
Left a static out of enc_write.c, which caused to buffer to be
|
||||
continiously malloc()ed. Does anyone use these functions? I keep
|
||||
on feeling like removing them since I only had these in there
|
||||
for a version of kerberised login. Anyway, this was pointed out
|
||||
by Theo de Raadt <deraadt@cvs.openbsd.org>
|
||||
The 'n' bit ofb code was wrong, it was not shifting the shift
|
||||
register. It worked correctly for n == 64. Thanks to
|
||||
Gigi Ankeny <Gigi.Ankeny@Eng.Sun.COM> for pointing this one out.
|
||||
|
||||
Version 4.02
|
||||
I was doing 'if (memcmp(weak_keys[i],key,sizeof(key)) == 0)'
|
||||
when checking for weak keys which is wrong :-(, pointed out by
|
||||
Markus F.X.J. Oberhumer <markus.oberhumer@jk.uni-linz.ac.at>.
|
||||
|
||||
Version 4.01
|
||||
Even faster inner loop in the DES assembler for x86 and a modification
|
||||
for IP/FP which is faster on x86. Both of these changes are
|
||||
from Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>. His
|
||||
changes make the assember run %40 faster on a pentium. This is just
|
||||
changes make the assembler run %40 faster on a pentium. This is just
|
||||
a case of getting the instruction sequence 'just right'.
|
||||
All credit to 'Svend' :-)
|
||||
Quite a few special x86 'make' targets.
|
||||
@ -10,9 +40,9 @@ Version 4.01 14/01/97
|
||||
|
||||
Version 4.00
|
||||
After a bit of a pause, I'll up the major version number since this
|
||||
is mostly a performace release. I've added x86 assember and
|
||||
is mostly a performace release. I've added x86 assembler and
|
||||
added more options for performance. A %28 speedup for gcc
|
||||
on a pentium and the assember is a %50 speedup.
|
||||
on a pentium and the assembler is a %50 speedup.
|
||||
MIPS CPU's, sparc and Alpha are the main CPU's with speedups.
|
||||
Run des_opts to work out which options should be used.
|
||||
DES_RISC1/DES_RISC2 use alternative inner loops which use
|
||||
@ -30,7 +60,7 @@ Version 3.26
|
||||
instead of L^=((..)|(..)|(..).. This should save a register at
|
||||
least.
|
||||
Assember for x86. The file to replace is des_enc.c, which is replaced
|
||||
by one of the assember files found in asm. Look at des/asm/readme
|
||||
by one of the assembler files found in asm. Look at des/asm/readme
|
||||
for more info.
|
||||
|
||||
/* Modification to fcrypt so it can be compiled to support
|
||||
|
204
crypto/libdes/asm/crypt586.pl
Normal file
204
crypto/libdes/asm/crypt586.pl
Normal file
@ -0,0 +1,204 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# The inner loop instruction sequence and the IP/FP modifications are from
|
||||
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
# I've added the stuff needed for crypt() but I've not worried about making
|
||||
# things perfect.
|
||||
#
|
||||
|
||||
push(@INC,"perlasm","../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
&asm_init($ARGV[0],"crypt586.pl");
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
|
||||
&external_label("des_SPtrans");
|
||||
&fcrypt_body("fcrypt_body");
|
||||
&asm_finish();
|
||||
|
||||
sub fcrypt_body
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
|
||||
&function_begin($name,"EXTRN _des_SPtrans:DWORD");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
$ks="ebp";
|
||||
|
||||
&xor( $L, $L);
|
||||
&xor( $R, $R);
|
||||
&mov($ks,&wparam(1));
|
||||
|
||||
&push(&DWC(25)); # add a variable
|
||||
|
||||
&set_label("start");
|
||||
for ($i=0; $i<16; $i+=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i+1));
|
||||
&D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
&mov("ebx", &swtmp(0));
|
||||
&mov("eax", $L);
|
||||
&dec("ebx");
|
||||
&mov($L, $R);
|
||||
&mov($R, "eax");
|
||||
&mov(&swtmp(0), "ebx");
|
||||
&jnz(&label("start"));
|
||||
|
||||
&comment("");
|
||||
&comment("FP");
|
||||
&mov("edx",&wparam(0));
|
||||
|
||||
&FP_new($R,$L,"eax",3);
|
||||
&mov(&DWP(0,"edx","",0),"eax");
|
||||
&mov(&DWP(4,"edx","",0),$L);
|
||||
|
||||
&pop("ecx"); # remove variable
|
||||
|
||||
&function_end($name);
|
||||
}
|
||||
|
||||
sub D_ENCRYPT
|
||||
{
|
||||
local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
|
||||
|
||||
&mov( $u, &wparam(2)); # 2
|
||||
&mov( $t, $R);
|
||||
&shr( $t, 16); # 1
|
||||
&mov( $tmp2, &wparam(3)); # 2
|
||||
&xor( $t, $R); # 1
|
||||
|
||||
&and( $u, $t); # 2
|
||||
&and( $t, $tmp2); # 2
|
||||
|
||||
&mov( $tmp1, $u);
|
||||
&shl( $tmp1, 16); # 1
|
||||
&mov( $tmp2, $t);
|
||||
&shl( $tmp2, 16); # 1
|
||||
&xor( $u, $tmp1); # 2
|
||||
&xor( $t, $tmp2); # 2
|
||||
&mov( $tmp1, &DWP(&n2a($S*4),$ks,"",0)); # 2
|
||||
&xor( $u, $tmp1);
|
||||
&mov( $tmp2, &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2
|
||||
&xor( $u, $R);
|
||||
&xor( $t, $R);
|
||||
&xor( $t, $tmp2);
|
||||
|
||||
&and( $u, "0xfcfcfcfc" ); # 2
|
||||
&xor( $tmp1, $tmp1); # 1
|
||||
&and( $t, "0xcfcfcfcf" ); # 2
|
||||
&xor( $tmp2, $tmp2);
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&rotr( $t, 4 );
|
||||
&mov( $ks, &DWP(" $desSP",$tmp1,"",0));
|
||||
&movb( &LB($tmp1), &LB($t) );
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks);
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&shr( $u, 16);
|
||||
&mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $ks);
|
||||
&movb( &LB($tmp1), &HB($u) );
|
||||
&shr( $t, 16);
|
||||
&mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &wparam(1));
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&and( $u, "0xff" );
|
||||
&and( $t, "0xff" );
|
||||
&mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x400+$desSP",$u,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
}
|
||||
|
||||
sub n2a
|
||||
{
|
||||
sprintf("%d",$_[0]);
|
||||
}
|
||||
|
||||
# now has a side affect of rotating $a by $shift
|
||||
sub R_PERM_OP
|
||||
{
|
||||
local($a,$b,$tt,$shift,$mask,$last)=@_;
|
||||
|
||||
&rotl( $a, $shift ) if ($shift != 0);
|
||||
&mov( $tt, $a );
|
||||
&xor( $a, $b );
|
||||
&and( $a, $mask );
|
||||
if ($notlast eq $b)
|
||||
{
|
||||
&xor( $b, $a );
|
||||
&xor( $tt, $a );
|
||||
}
|
||||
else
|
||||
{
|
||||
&xor( $tt, $a );
|
||||
&xor( $b, $a );
|
||||
}
|
||||
&comment("");
|
||||
}
|
||||
|
||||
sub IP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l);
|
||||
&R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
|
||||
&R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
|
||||
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotr($tt, 3-$lr); }
|
||||
else { &rotl($tt, $lr-3); }
|
||||
}
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotr($r, 2-$lr); }
|
||||
else { &rotl($r, $lr-2); }
|
||||
}
|
||||
}
|
||||
|
||||
sub FP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotl($r, 2-$lr); }
|
||||
else { &rotr($r, $lr-2); }
|
||||
}
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotl($l, 3-$lr); }
|
||||
else { &rotr($l, $lr-3); }
|
||||
}
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r);
|
||||
&R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt,10,"0x33333333",$l);
|
||||
&R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r);
|
||||
&rotr($tt , 4);
|
||||
}
|
||||
|
3132
crypto/libdes/asm/d-win32.asm
Normal file
3132
crypto/libdes/asm/d-win32.asm
Normal file
File diff suppressed because it is too large
Load Diff
253
crypto/libdes/asm/des-586.pl
Normal file
253
crypto/libdes/asm/des-586.pl
Normal file
@ -0,0 +1,253 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# The inner loop instruction sequence and the IP/FP modifications are from
|
||||
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
#
|
||||
|
||||
push(@INC,"perlasm","../../perlasm");
|
||||
require "x86asm.pl";
|
||||
require "cbc.pl";
|
||||
require "desboth.pl";
|
||||
|
||||
# base code is in microsft
|
||||
# op dest, source
|
||||
# format.
|
||||
#
|
||||
|
||||
&asm_init($ARGV[0],"des-586.pl");
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
|
||||
&external_label("des_SPtrans");
|
||||
&des_encrypt("des_encrypt",1);
|
||||
&des_encrypt("des_encrypt2",0);
|
||||
&des_encrypt3("des_encrypt3",1);
|
||||
&des_encrypt3("des_decrypt3",0);
|
||||
&cbc("des_ncbc_encrypt","des_encrypt","des_encrypt",0,4,5,3,5,-1);
|
||||
&cbc("des_ede3_cbc_encrypt","des_encrypt3","des_decrypt3",0,6,7,3,4,5);
|
||||
|
||||
&asm_finish();
|
||||
|
||||
sub des_encrypt
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
|
||||
&function_begin_B($name,"EXTRN _des_SPtrans:DWORD");
|
||||
|
||||
&push("esi");
|
||||
&push("edi");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
$ks="ebp";
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
&mov($R,&wparam(0));
|
||||
&xor( "ecx", "ecx" );
|
||||
|
||||
&push("ebx");
|
||||
&push("ebp");
|
||||
|
||||
&mov("eax",&DWP(0,$R,"",0));
|
||||
&mov("ebx",&wparam(2)); # get encrypt flag
|
||||
&mov($L,&DWP(4,$R,"",0));
|
||||
&comment("");
|
||||
&comment("IP");
|
||||
&IP_new("eax",$L,$R,3);
|
||||
}
|
||||
else
|
||||
{
|
||||
&mov("eax",&wparam(0));
|
||||
&xor( "ecx", "ecx" );
|
||||
|
||||
&push("ebx");
|
||||
&push("ebp");
|
||||
|
||||
&mov($R,&DWP(0,"eax","",0));
|
||||
&mov("ebx",&wparam(2)); # get encrypt flag
|
||||
&rotl($R,3);
|
||||
&mov($L,&DWP(4,"eax","",0));
|
||||
&rotl($L,3);
|
||||
}
|
||||
|
||||
&mov( $ks, &wparam(1) );
|
||||
&cmp("ebx","0");
|
||||
&je(&label("start_decrypt"));
|
||||
|
||||
for ($i=0; $i<16; $i+=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i+1));
|
||||
&D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
&jmp(&label("end"));
|
||||
|
||||
&set_label("start_decrypt");
|
||||
|
||||
for ($i=15; $i>0; $i-=2)
|
||||
{
|
||||
&comment("");
|
||||
&comment("Round $i");
|
||||
&D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
&comment("");
|
||||
&comment("Round ".sprintf("%d",$i-1));
|
||||
&D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
|
||||
}
|
||||
|
||||
&set_label("end");
|
||||
|
||||
if ($do_ip)
|
||||
{
|
||||
&comment("");
|
||||
&comment("FP");
|
||||
&mov("edx",&wparam(0));
|
||||
&FP_new($L,$R,"eax",3);
|
||||
|
||||
&mov(&DWP(0,"edx","",0),"eax");
|
||||
&mov(&DWP(4,"edx","",0),$R);
|
||||
}
|
||||
else
|
||||
{
|
||||
&comment("");
|
||||
&comment("Fixup");
|
||||
&rotr($L,3); # r
|
||||
&mov("eax",&wparam(0));
|
||||
&rotr($R,3); # l
|
||||
&mov(&DWP(0,"eax","",0),$L);
|
||||
&mov(&DWP(4,"eax","",0),$R);
|
||||
}
|
||||
|
||||
&pop("ebp");
|
||||
&pop("ebx");
|
||||
&pop("edi");
|
||||
&pop("esi");
|
||||
&ret();
|
||||
|
||||
&function_end_B($name);
|
||||
}
|
||||
|
||||
sub D_ENCRYPT
|
||||
{
|
||||
local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
|
||||
|
||||
&mov( $u, &DWP(&n2a($S*4),$ks,"",0));
|
||||
&xor( $tmp1, $tmp1);
|
||||
&mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
|
||||
&xor( $u, $R);
|
||||
&xor( $t, $R);
|
||||
&and( $u, "0xfcfcfcfc" );
|
||||
&and( $t, "0xcfcfcfcf" );
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&rotr( $t, 4 );
|
||||
&mov( $ks, &DWP(" $desSP",$tmp1,"",0));
|
||||
&movb( &LB($tmp1), &LB($t) );
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks); ######
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&shr( $u, 16);
|
||||
&mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $ks); ######
|
||||
&movb( &LB($tmp1), &HB($u) );
|
||||
&shr( $t, 16);
|
||||
&mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $ks);
|
||||
&mov( $ks, &wparam(1) );
|
||||
&movb( &LB($tmp2), &HB($t) );
|
||||
&and( $u, "0xff" );
|
||||
&and( $t, "0xff" );
|
||||
&mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x400+$desSP",$u,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
&mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
|
||||
&xor( $L, $tmp1);
|
||||
}
|
||||
|
||||
sub n2a
|
||||
{
|
||||
sprintf("%d",$_[0]);
|
||||
}
|
||||
|
||||
# now has a side affect of rotating $a by $shift
|
||||
sub R_PERM_OP
|
||||
{
|
||||
local($a,$b,$tt,$shift,$mask,$last)=@_;
|
||||
|
||||
&rotl( $a, $shift ) if ($shift != 0);
|
||||
&mov( $tt, $a );
|
||||
&xor( $a, $b );
|
||||
&and( $a, $mask );
|
||||
# This can never succeed, and besides it is difficult to see what the
|
||||
# idea was - Ben 13 Feb 99
|
||||
if (!$last eq $b)
|
||||
{
|
||||
&xor( $b, $a );
|
||||
&xor( $tt, $a );
|
||||
}
|
||||
else
|
||||
{
|
||||
&xor( $tt, $a );
|
||||
&xor( $b, $a );
|
||||
}
|
||||
&comment("");
|
||||
}
|
||||
|
||||
sub IP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l);
|
||||
&R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
|
||||
&R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
|
||||
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotr($tt, 3-$lr); }
|
||||
else { &rotl($tt, $lr-3); }
|
||||
}
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotr($r, 2-$lr); }
|
||||
else { &rotl($r, $lr-2); }
|
||||
}
|
||||
}
|
||||
|
||||
sub FP_new
|
||||
{
|
||||
local($l,$r,$tt,$lr)=@_;
|
||||
|
||||
if ($lr != 2)
|
||||
{
|
||||
if (($lr-2) < 0)
|
||||
{ &rotl($r, 2-$lr); }
|
||||
else { &rotr($r, $lr-2); }
|
||||
}
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
{ &rotl($l, 3-$lr); }
|
||||
else { &rotr($l, $lr-3); }
|
||||
}
|
||||
|
||||
&R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r);
|
||||
&R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt,10,"0x33333333",$l);
|
||||
&R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l);
|
||||
&R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r);
|
||||
&rotr($tt , 4);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ EOF
|
||||
&comment("Which is a perl program used to generate the x86 assember for");
|
||||
&comment("any of elf, a.out, Win32, or Solaris");
|
||||
&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
|
||||
&comment("eric <eay\@mincom.oz.au>");
|
||||
&comment("eric <eay\@cryptsoft.com>");
|
||||
&comment("");
|
||||
|
||||
&file("dx86xxxx");
|
||||
@ -58,7 +58,7 @@ sub des_encrypt
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
|
||||
&function_begin($name,3);
|
||||
&function_begin($name,"EXTRN _des_SPtrans:DWORD");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the 2 words");
|
||||
@ -72,7 +72,7 @@ sub des_encrypt
|
||||
{
|
||||
&comment("");
|
||||
&comment("IP");
|
||||
&IP($L,$R,"eax");
|
||||
&IP_new($L,$R,"eax");
|
||||
}
|
||||
|
||||
&comment("");
|
||||
@ -125,7 +125,7 @@ sub des_encrypt
|
||||
{
|
||||
&comment("");
|
||||
&comment("FP");
|
||||
&FP($R,$L,"eax");
|
||||
&FP_new($R,$L,"eax");
|
||||
}
|
||||
|
||||
&mov("eax",&wparam(0));
|
||||
@ -202,7 +202,7 @@ sub PERM_OP
|
||||
&xor( $a, $tt );
|
||||
}
|
||||
|
||||
sub IP
|
||||
sub IP_new
|
||||
{
|
||||
local($l,$r,$tt)=@_;
|
||||
|
||||
@ -213,7 +213,7 @@ sub IP
|
||||
&PERM_OP($r,$l,$tt, 1,"0x55555555");
|
||||
}
|
||||
|
||||
sub FP
|
||||
sub FP_new
|
||||
{
|
||||
local($l,$r,$tt)=@_;
|
||||
|
||||
|
@ -7,13 +7,20 @@ sub des_encrypt3
|
||||
{
|
||||
local($name,$enc)=@_;
|
||||
|
||||
&function_begin($name,4);
|
||||
&function_begin_B($name,"");
|
||||
&push("ebx");
|
||||
&mov("ebx",&wparam(0));
|
||||
|
||||
&push("ebp");
|
||||
&push("esi");
|
||||
|
||||
&push("edi");
|
||||
|
||||
&comment("");
|
||||
&comment("Load the data words");
|
||||
&mov("ebx",&wparam(0));
|
||||
&mov($L,&DWP(0,"ebx","",0));
|
||||
&mov($R,&DWP(4,"ebx","",0));
|
||||
&stack_push(3);
|
||||
|
||||
&comment("");
|
||||
&comment("IP");
|
||||
@ -37,21 +44,21 @@ sub des_encrypt3
|
||||
&mov("edi",&wparam(2));
|
||||
&mov("eax",&wparam(3));
|
||||
}
|
||||
&push(($enc)?"1":"0");
|
||||
&push("eax");
|
||||
&push("ebx");
|
||||
&mov(&swtmp(2), (DWC(($enc)?"1":"0")));
|
||||
&mov(&swtmp(1), "eax");
|
||||
&mov(&swtmp(0), "ebx");
|
||||
&call("des_encrypt2");
|
||||
&push(($enc)?"0":"1");
|
||||
&push("edi");
|
||||
&push("ebx");
|
||||
&mov(&swtmp(2), (DWC(($enc)?"0":"1")));
|
||||
&mov(&swtmp(1), "edi");
|
||||
&mov(&swtmp(0), "ebx");
|
||||
&call("des_encrypt2");
|
||||
&push(($enc)?"1":"0");
|
||||
&push("esi");
|
||||
&push("ebx");
|
||||
&mov(&swtmp(2), (DWC(($enc)?"1":"0")));
|
||||
&mov(&swtmp(1), "esi");
|
||||
&mov(&swtmp(0), "ebx");
|
||||
&call("des_encrypt2");
|
||||
|
||||
&stack_pop(3);
|
||||
&mov($L,&DWP(0,"ebx","",0));
|
||||
&add("esp",36);
|
||||
&mov($R,&DWP(4,"ebx","",0));
|
||||
|
||||
&comment("");
|
||||
@ -61,7 +68,12 @@ sub des_encrypt3
|
||||
&mov(&DWP(0,"ebx","",0),"eax");
|
||||
&mov(&DWP(4,"ebx","",0),$R);
|
||||
|
||||
&function_end($name);
|
||||
&pop("edi");
|
||||
&pop("esi");
|
||||
&pop("ebp");
|
||||
&pop("ebx");
|
||||
&ret();
|
||||
&function_end_B($name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +116,7 @@ functions into des_enc.c because it does make a massive performance
|
||||
difference on some boxes to have the functions code located close to
|
||||
the des_encrypt2() function.
|
||||
|
||||
9 Jan 1996 - des-som2.pl is now the correct perl script to use for
|
||||
9 Jan 1997 - des-som2.pl is now the correct perl script to use for
|
||||
pentiums. It contains an inner loop from
|
||||
Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> which does raw ecb DES calls at
|
||||
273,000 per second. He had a previous version at 250,000 and the best
|
||||
@ -126,5 +126,6 @@ to keep both functional units of the pentium going.
|
||||
We may have lost the ugly register usage restrictions when x86 went 32 bit
|
||||
but for the pentium it has been replaced by evil instruction ordering tricks.
|
||||
|
||||
13 Jan 1996 - des-som3.pl, more optimizations from Svend Olaf.
|
||||
13 Jan 1997 - des-som3.pl, more optimizations from Svend Olaf.
|
||||
raw DES at 281,000 per second on a pentium 100.
|
||||
|
||||
|
929
crypto/libdes/asm/y-win32.asm
Normal file
929
crypto/libdes/asm/y-win32.asm
Normal file
@ -0,0 +1,929 @@
|
||||
; Don't even think of reading this code
|
||||
; It was automatically generated by crypt586.pl
|
||||
; Which is a perl program used to generate the x86 assember for
|
||||
; any of elf, a.out, BSDI,Win32, or Solaris
|
||||
; eric <eay@cryptsoft.com>
|
||||
;
|
||||
TITLE crypt586.asm
|
||||
.386
|
||||
.model FLAT
|
||||
_TEXT SEGMENT
|
||||
PUBLIC _fcrypt_body
|
||||
EXTRN _des_SPtrans:DWORD
|
||||
_fcrypt_body PROC NEAR
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
;
|
||||
; Load the 2 words
|
||||
xor edi, edi
|
||||
xor esi, esi
|
||||
mov ebp, DWORD PTR 24[esp]
|
||||
push 25
|
||||
L000start:
|
||||
;
|
||||
; Round 0
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR [ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 4[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 1
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 8[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 12[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 2
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 16[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 20[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 3
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 24[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 28[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 4
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 32[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 36[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 5
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 40[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 44[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 6
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 48[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 52[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 7
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 56[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 60[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 8
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 64[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 68[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 9
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 72[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 76[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 10
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 80[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 84[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 11
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 88[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 92[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 12
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 96[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 100[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 13
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 104[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 108[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
;
|
||||
; Round 14
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, esi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, esi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 112[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 116[ebp]
|
||||
xor eax, esi
|
||||
xor edx, esi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor edi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor edi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor edi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor edi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor edi, ebx
|
||||
;
|
||||
; Round 15
|
||||
mov eax, DWORD PTR 32[esp]
|
||||
mov edx, edi
|
||||
shr edx, 16
|
||||
mov ecx, DWORD PTR 36[esp]
|
||||
xor edx, edi
|
||||
and eax, edx
|
||||
and edx, ecx
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
mov ecx, edx
|
||||
shl ecx, 16
|
||||
xor eax, ebx
|
||||
xor edx, ecx
|
||||
mov ebx, DWORD PTR 120[ebp]
|
||||
xor eax, ebx
|
||||
mov ecx, DWORD PTR 124[ebp]
|
||||
xor eax, edi
|
||||
xor edx, edi
|
||||
xor edx, ecx
|
||||
and eax, 0fcfcfcfch
|
||||
xor ebx, ebx
|
||||
and edx, 0cfcfcfcfh
|
||||
xor ecx, ecx
|
||||
mov bl, al
|
||||
mov cl, ah
|
||||
ror edx, 4
|
||||
mov ebp, DWORD PTR _des_SPtrans[ebx]
|
||||
mov bl, dl
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
|
||||
xor esi, ebp
|
||||
mov cl, dh
|
||||
shr eax, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
|
||||
xor esi, ebp
|
||||
mov bl, ah
|
||||
shr edx, 16
|
||||
mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
|
||||
xor esi, ebp
|
||||
mov ebp, DWORD PTR 28[esp]
|
||||
mov cl, dh
|
||||
and eax, 0ffh
|
||||
and edx, 0ffh
|
||||
mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
|
||||
xor esi, ebx
|
||||
mov ebx, DWORD PTR [esp]
|
||||
mov eax, edi
|
||||
dec ebx
|
||||
mov edi, esi
|
||||
mov esi, eax
|
||||
mov DWORD PTR [esp],ebx
|
||||
jnz L000start
|
||||
;
|
||||
; FP
|
||||
mov edx, DWORD PTR 24[esp]
|
||||
ror edi, 1
|
||||
mov eax, esi
|
||||
xor esi, edi
|
||||
and esi, 0aaaaaaaah
|
||||
xor eax, esi
|
||||
xor edi, esi
|
||||
;
|
||||
rol eax, 23
|
||||
mov esi, eax
|
||||
xor eax, edi
|
||||
and eax, 003fc03fch
|
||||
xor esi, eax
|
||||
xor edi, eax
|
||||
;
|
||||
rol esi, 10
|
||||
mov eax, esi
|
||||
xor esi, edi
|
||||
and esi, 033333333h
|
||||
xor eax, esi
|
||||
xor edi, esi
|
||||
;
|
||||
rol edi, 18
|
||||
mov esi, edi
|
||||
xor edi, eax
|
||||
and edi, 0fff0000fh
|
||||
xor esi, edi
|
||||
xor eax, edi
|
||||
;
|
||||
rol esi, 12
|
||||
mov edi, esi
|
||||
xor esi, eax
|
||||
and esi, 0f0f0f0f0h
|
||||
xor edi, esi
|
||||
xor eax, esi
|
||||
;
|
||||
ror eax, 4
|
||||
mov DWORD PTR [edx],eax
|
||||
mov DWORD PTR 4[edx],edi
|
||||
pop ecx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
_fcrypt_body ENDP
|
||||
_TEXT ENDS
|
||||
END
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/cbc3_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,28 +58,22 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
/* HAS BUGS? DON'T USE */
|
||||
void des_3cbc_encrypt(input, output, length, ks1, ks2, iv1, iv2, encrypt)
|
||||
des_cblock (*input);
|
||||
des_cblock (*output);
|
||||
long length;
|
||||
des_key_schedule ks1;
|
||||
des_key_schedule ks2;
|
||||
des_cblock (*iv1);
|
||||
des_cblock (*iv2);
|
||||
int encrypt;
|
||||
/* HAS BUGS? DON'T USE - this is only present for use in des.c */
|
||||
void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
|
||||
des_key_schedule ks1, des_key_schedule ks2, des_cblock *iv1,
|
||||
des_cblock *iv2, int enc)
|
||||
{
|
||||
int off=((int)length-1)/8;
|
||||
long l8=((length+7)/8)*8;
|
||||
des_cblock niv1,niv2;
|
||||
|
||||
if (encrypt == DES_ENCRYPT)
|
||||
if (enc == DES_ENCRYPT)
|
||||
{
|
||||
des_cbc_encrypt(input,output,length,ks1,iv1,encrypt);
|
||||
des_cbc_encrypt(input,output,length,ks1,iv1,enc);
|
||||
if (length >= sizeof(des_cblock))
|
||||
memcpy(niv1,output[off],sizeof(des_cblock));
|
||||
des_cbc_encrypt(output,output,l8,ks2,iv1,!encrypt);
|
||||
des_cbc_encrypt(output,output,l8,ks1,iv2, encrypt);
|
||||
des_cbc_encrypt(output,output,l8,ks2,iv1,!enc);
|
||||
des_cbc_encrypt(output,output,l8,ks1,iv2, enc);
|
||||
if (length >= sizeof(des_cblock))
|
||||
memcpy(niv2,output[off],sizeof(des_cblock));
|
||||
}
|
||||
@ -87,11 +81,11 @@ int encrypt;
|
||||
{
|
||||
if (length >= sizeof(des_cblock))
|
||||
memcpy(niv2,input[off],sizeof(des_cblock));
|
||||
des_cbc_encrypt(input,output,l8,ks1,iv2,encrypt);
|
||||
des_cbc_encrypt(output,output,l8,ks2,iv1,!encrypt);
|
||||
des_cbc_encrypt(input,output,l8,ks1,iv2,enc);
|
||||
des_cbc_encrypt(output,output,l8,ks2,iv1,!enc);
|
||||
if (length >= sizeof(des_cblock))
|
||||
memcpy(niv1,output[off],sizeof(des_cblock));
|
||||
des_cbc_encrypt(output,output,length,ks1,iv1, encrypt);
|
||||
des_cbc_encrypt(output,output,length,ks1,iv1, enc);
|
||||
}
|
||||
memcpy(*iv1,niv1,sizeof(des_cblock));
|
||||
memcpy(*iv2,niv2,sizeof(des_cblock));
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/cbc_cksm.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,21 +58,15 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
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);
|
||||
DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,
|
||||
long length,
|
||||
des_key_schedule schedule, const_des_cblock *ivec)
|
||||
{
|
||||
register DES_LONG tout0,tout1,tin0,tin1;
|
||||
register long l=length;
|
||||
DES_LONG tin[2];
|
||||
unsigned char *in,*out,*iv;
|
||||
|
||||
in=(unsigned char *)input;
|
||||
out=(unsigned char *)output;
|
||||
iv=(unsigned char *)ivec;
|
||||
unsigned char *out = &(*output)[0];
|
||||
const unsigned char *iv = &(*ivec)[0];
|
||||
|
||||
c2l(iv,tout0);
|
||||
c2l(iv,tout1);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/cbc_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -56,80 +56,6 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
void des_cbc_encrypt(input, output, length, schedule, ivec, encrypt)
|
||||
des_cblock (*input);
|
||||
des_cblock (*output);
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
int encrypt;
|
||||
{
|
||||
register DES_LONG tin0,tin1;
|
||||
register DES_LONG tout0,tout1,xor0,xor1;
|
||||
register unsigned char *in,*out;
|
||||
register long l=length;
|
||||
DES_LONG tin[2];
|
||||
unsigned char *iv;
|
||||
|
||||
in=(unsigned char *)input;
|
||||
out=(unsigned char *)output;
|
||||
iv=(unsigned char *)ivec;
|
||||
|
||||
if (encrypt)
|
||||
{
|
||||
c2l(iv,tout0);
|
||||
c2l(iv,tout1);
|
||||
for (l-=8; l>=0; l-=8)
|
||||
{
|
||||
c2l(in,tin0);
|
||||
c2l(in,tin1);
|
||||
tin0^=tout0; tin[0]=tin0;
|
||||
tin1^=tout1; tin[1]=tin1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
|
||||
tout0=tin[0]; l2c(tout0,out);
|
||||
tout1=tin[1]; l2c(tout1,out);
|
||||
}
|
||||
if (l != -8)
|
||||
{
|
||||
c2ln(in,tin0,tin1,l+8);
|
||||
tin0^=tout0; tin[0]=tin0;
|
||||
tin1^=tout1; tin[1]=tin1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
|
||||
tout0=tin[0]; l2c(tout0,out);
|
||||
tout1=tin[1]; l2c(tout1,out);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c2l(iv,xor0);
|
||||
c2l(iv,xor1);
|
||||
for (l-=8; l>=0; l-=8)
|
||||
{
|
||||
c2l(in,tin0); tin[0]=tin0;
|
||||
c2l(in,tin1); tin[1]=tin1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
|
||||
tout0=tin[0]^xor0;
|
||||
tout1=tin[1]^xor1;
|
||||
l2c(tout0,out);
|
||||
l2c(tout1,out);
|
||||
xor0=tin0;
|
||||
xor1=tin1;
|
||||
}
|
||||
if (l != -8)
|
||||
{
|
||||
c2l(in,tin0); tin[0]=tin0;
|
||||
c2l(in,tin1); tin[1]=tin1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
|
||||
tout0=tin[0]^xor0;
|
||||
tout1=tin[1]^xor1;
|
||||
l2cn(tout0,tout1,out,l+8);
|
||||
/* xor0=tin0;
|
||||
xor1=tin1; */
|
||||
}
|
||||
}
|
||||
tin0=tin1=tout0=tout1=xor0=xor1=0;
|
||||
tin[0]=tin[1]=0;
|
||||
}
|
||||
#define CBC_ENC_C__DONT_UPDATE_IV
|
||||
|
||||
#include "ncbc_enc.c" /* des_cbc_encrypt */
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/cfb64ede.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -63,14 +63,9 @@
|
||||
* 64bit block we have used is contained in *num;
|
||||
*/
|
||||
|
||||
void des_ede3_cfb64_encrypt(in, out, length, ks1,ks2,ks3, ivec, num, encrypt)
|
||||
unsigned char *in;
|
||||
unsigned char *out;
|
||||
long length;
|
||||
des_key_schedule ks1,ks2,ks3;
|
||||
des_cblock (*ivec);
|
||||
int *num;
|
||||
int encrypt;
|
||||
void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int *num, int enc)
|
||||
{
|
||||
register DES_LONG v0,v1;
|
||||
register long l=length;
|
||||
@ -78,8 +73,8 @@ int encrypt;
|
||||
DES_LONG ti[2];
|
||||
unsigned char *iv,c,cc;
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
if (encrypt)
|
||||
iv=&(*ivec)[0];
|
||||
if (enc)
|
||||
{
|
||||
while (l--)
|
||||
{
|
||||
@ -90,14 +85,14 @@ int encrypt;
|
||||
|
||||
ti[0]=v0;
|
||||
ti[1]=v1;
|
||||
des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3);
|
||||
des_encrypt3(ti,ks1,ks2,ks3);
|
||||
v0=ti[0];
|
||||
v1=ti[1];
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
l2c(v0,iv);
|
||||
l2c(v1,iv);
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
}
|
||||
c= *(in++)^iv[n];
|
||||
*(out++)=c;
|
||||
@ -116,14 +111,14 @@ int encrypt;
|
||||
|
||||
ti[0]=v0;
|
||||
ti[1]=v1;
|
||||
des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3);
|
||||
des_encrypt3(ti,ks1,ks2,ks3);
|
||||
v0=ti[0];
|
||||
v1=ti[1];
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
l2c(v0,iv);
|
||||
l2c(v1,iv);
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
}
|
||||
cc= *(in++);
|
||||
c=iv[n];
|
||||
@ -137,15 +132,10 @@ int encrypt;
|
||||
}
|
||||
|
||||
#ifdef undef /* MACRO */
|
||||
void des_ede2_cfb64_encrypt(in, out, length, ks1,ks2, ivec, num, encrypt)
|
||||
unsigned char *in;
|
||||
unsigned char *out;
|
||||
long length;
|
||||
des_key_schedule ks1,ks2;
|
||||
des_cblock (*ivec);
|
||||
int *num;
|
||||
int encrypt;
|
||||
void des_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule ks1, des_key_schedule ks2, des_cblock (*ivec),
|
||||
int *num, int enc)
|
||||
{
|
||||
des_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,encrypt);
|
||||
des_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/cfb64enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -63,14 +63,9 @@
|
||||
* 64bit block we have used is contained in *num;
|
||||
*/
|
||||
|
||||
void des_cfb64_encrypt(in, out, length, schedule, ivec, num, encrypt)
|
||||
unsigned char *in;
|
||||
unsigned char *out;
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
int *num;
|
||||
int encrypt;
|
||||
void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule schedule, des_cblock *ivec,
|
||||
int *num, int enc)
|
||||
{
|
||||
register DES_LONG v0,v1;
|
||||
register long l=length;
|
||||
@ -78,8 +73,8 @@ int encrypt;
|
||||
DES_LONG ti[2];
|
||||
unsigned char *iv,c,cc;
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
if (encrypt)
|
||||
iv = &(*ivec)[0];
|
||||
if (enc)
|
||||
{
|
||||
while (l--)
|
||||
{
|
||||
@ -87,12 +82,11 @@ int encrypt;
|
||||
{
|
||||
c2l(iv,v0); ti[0]=v0;
|
||||
c2l(iv,v1); ti[1]=v1;
|
||||
des_encrypt((DES_LONG *)ti,
|
||||
schedule,DES_ENCRYPT);
|
||||
iv=(unsigned char *)ivec;
|
||||
des_encrypt(ti,schedule,DES_ENCRYPT);
|
||||
iv = &(*ivec)[0];
|
||||
v0=ti[0]; l2c(v0,iv);
|
||||
v0=ti[1]; l2c(v0,iv);
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
}
|
||||
c= *(in++)^iv[n];
|
||||
*(out++)=c;
|
||||
@ -108,12 +102,11 @@ int encrypt;
|
||||
{
|
||||
c2l(iv,v0); ti[0]=v0;
|
||||
c2l(iv,v1); ti[1]=v1;
|
||||
des_encrypt((DES_LONG *)ti,
|
||||
schedule,DES_ENCRYPT);
|
||||
iv=(unsigned char *)ivec;
|
||||
des_encrypt(ti,schedule,DES_ENCRYPT);
|
||||
iv = &(*ivec)[0];
|
||||
v0=ti[0]; l2c(v0,iv);
|
||||
v0=ti[1]; l2c(v0,iv);
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
}
|
||||
cc= *(in++);
|
||||
c=iv[n];
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/cfb_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -64,14 +64,8 @@
|
||||
* the second. The second 12 bits will come from the 3rd and half the 4th
|
||||
* byte.
|
||||
*/
|
||||
void des_cfb_encrypt(in, out, numbits, length, schedule, ivec, encrypt)
|
||||
unsigned char *in;
|
||||
unsigned char *out;
|
||||
int numbits;
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
int encrypt;
|
||||
void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
|
||||
long length, des_key_schedule schedule, des_cblock *ivec, int enc)
|
||||
{
|
||||
register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
|
||||
register DES_LONG mask0,mask1;
|
||||
@ -93,13 +87,13 @@ int encrypt;
|
||||
if (num == 32)
|
||||
mask0=0xffffffffL;
|
||||
else mask0=(1L<<num)-1;
|
||||
mask1=0x00000000;
|
||||
mask1=0x00000000L;
|
||||
}
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
c2l(iv,v0);
|
||||
c2l(iv,v1);
|
||||
if (encrypt)
|
||||
if (enc)
|
||||
{
|
||||
while (l >= n)
|
||||
{
|
||||
@ -163,7 +157,7 @@ int encrypt;
|
||||
out+=n;
|
||||
}
|
||||
}
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
l2c(v0,iv);
|
||||
l2c(v1,iv);
|
||||
v0=v1=d0=d1=ti[0]=ti[1]=0;
|
||||
|
1003
crypto/libdes/des-lib.com
Normal file
1003
crypto/libdes/des-lib.com
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
||||
/* crypto/des/des.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -56,17 +56,20 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#ifndef MSDOS
|
||||
#ifndef VMS
|
||||
#include <openssl/opensslconf.h>
|
||||
#include OPENSSL_UNISTD
|
||||
#else /* VMS */
|
||||
#ifdef __DECC
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
#else /* not __DECC */
|
||||
#include <math.h>
|
||||
#endif /* __DECC */
|
||||
#endif /* VMS */
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
@ -76,21 +79,19 @@
|
||||
#ifdef VMS
|
||||
#include <types.h>
|
||||
#include <stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#else
|
||||
#ifndef _IRIX
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include "des.h"
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#ifndef HAVE_RANDOM
|
||||
#define random rand
|
||||
#define srandom(s) srand(s)
|
||||
#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef NOPROTO
|
||||
void usage(void);
|
||||
void doencryption(void);
|
||||
int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp);
|
||||
@ -98,18 +99,11 @@ void uufwriteEnd(FILE *fp);
|
||||
int uufread(unsigned char *out,int size,unsigned int num,FILE *fp);
|
||||
int uuencode(unsigned char *in,int num,unsigned char *out);
|
||||
int uudecode(unsigned char *in,int num,unsigned char *out);
|
||||
#else
|
||||
void usage();
|
||||
void doencryption();
|
||||
int uufwrite();
|
||||
void uufwriteEnd();
|
||||
int uufread();
|
||||
int uuencode();
|
||||
int uudecode();
|
||||
#endif
|
||||
|
||||
void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule sk1,des_key_schedule sk2,
|
||||
des_cblock *ivec1,des_cblock *ivec2,int enc);
|
||||
#ifdef VMS
|
||||
#define EXIT(a) exit(a&0x10000000)
|
||||
#define EXIT(a) exit(a&0x10000000L)
|
||||
#else
|
||||
#define EXIT(a) exit(a)
|
||||
#endif
|
||||
@ -133,9 +127,7 @@ char cksumname[200]="";
|
||||
|
||||
int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error;
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
struct stat ins,outs;
|
||||
@ -326,7 +318,7 @@ char **argv;
|
||||
EXIT(0);
|
||||
}
|
||||
|
||||
void usage()
|
||||
void usage(void)
|
||||
{
|
||||
char **u;
|
||||
static const char *Usage[]={
|
||||
@ -352,7 +344,7 @@ void usage()
|
||||
"-3 : encrypt using tripple DES encryption. This uses 2 keys",
|
||||
" generated from the input key. If the input key is less",
|
||||
" than 8 characters long, this is equivelent to normal",
|
||||
" encryption. Default is tripple cbc, -b makes it tripple ecb.",
|
||||
" encryption. Default is triple cbc, -b makes it triple ecb.",
|
||||
NULL
|
||||
};
|
||||
for (u=(char **)Usage; *u; u++)
|
||||
@ -364,17 +356,15 @@ NULL
|
||||
EXIT(1);
|
||||
}
|
||||
|
||||
void doencryption()
|
||||
void doencryption(void)
|
||||
{
|
||||
#ifdef _LIBC
|
||||
extern int srandom();
|
||||
extern int random();
|
||||
extern unsigned long time();
|
||||
#endif
|
||||
|
||||
register int i;
|
||||
des_key_schedule ks,ks2;
|
||||
unsigned char iv[8],iv2[8];
|
||||
des_cblock iv,iv2;
|
||||
char *p;
|
||||
int num=0,j,k,l,rem,ll,len,last,ex=0;
|
||||
des_cblock kk,k2;
|
||||
@ -387,8 +377,8 @@ void doencryption()
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
if ( (( buf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL) ||
|
||||
((obuf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL))
|
||||
if ( (( buf=Malloc(BUFSIZE+8)) == NULL) ||
|
||||
((obuf=Malloc(BUFSIZE+8)) == NULL))
|
||||
{
|
||||
fputs("Not enough memory\n",stderr);
|
||||
Exit=10;
|
||||
@ -435,19 +425,19 @@ void doencryption()
|
||||
else
|
||||
k2[i-8]=k;
|
||||
}
|
||||
des_set_key((C_Block *)k2,ks2);
|
||||
des_set_key(&k2,ks2);
|
||||
memset(k2,0,sizeof(k2));
|
||||
}
|
||||
else if (longk || flag3)
|
||||
{
|
||||
if (flag3)
|
||||
{
|
||||
des_string_to_2keys(key,(C_Block *)kk,(C_Block *)k2);
|
||||
des_set_key((C_Block *)k2,ks2);
|
||||
des_string_to_2keys(key,&kk,&k2);
|
||||
des_set_key(&k2,ks2);
|
||||
memset(k2,0,sizeof(k2));
|
||||
}
|
||||
else
|
||||
des_string_to_key(key,(C_Block *)kk);
|
||||
des_string_to_key(key,&kk);
|
||||
}
|
||||
else
|
||||
for (i=0; i<KEYSIZ; i++)
|
||||
@ -465,7 +455,7 @@ void doencryption()
|
||||
kk[i]=key[i]|0x80;
|
||||
}
|
||||
|
||||
des_set_key((C_Block *)kk,ks);
|
||||
des_set_key(&kk,ks);
|
||||
memset(key,0,sizeof(key));
|
||||
memset(kk,0,sizeof(kk));
|
||||
/* woops - A bug that does not showup under unix :-( */
|
||||
@ -493,9 +483,8 @@ void doencryption()
|
||||
len=l-rem;
|
||||
if (feof(DES_IN))
|
||||
{
|
||||
srandom((unsigned int)time(NULL));
|
||||
for (i=7-rem; i>0; i--)
|
||||
buf[l++]=random()&0xff;
|
||||
RAND_bytes(buf + l++, 1);
|
||||
buf[l++]=rem;
|
||||
ex=1;
|
||||
len+=rem;
|
||||
@ -505,8 +494,8 @@ void doencryption()
|
||||
|
||||
if (cflag)
|
||||
{
|
||||
des_cbc_cksum((C_Block *)buf,(C_Block *)cksum,
|
||||
(long)len,ks,(C_Block *)cksum);
|
||||
des_cbc_cksum(buf,&cksum,
|
||||
(long)len,ks,&cksum);
|
||||
if (!eflag)
|
||||
{
|
||||
if (feof(DES_IN)) break;
|
||||
@ -534,16 +523,16 @@ void doencryption()
|
||||
(unsigned int)rem);
|
||||
des_3cbc_encrypt(
|
||||
(des_cblock *)buf,(des_cblock *)obuf,
|
||||
(long)l,ks,ks2,(des_cblock *)iv,
|
||||
(des_cblock *)iv2,do_encrypt);
|
||||
(long)l,ks,ks2,&iv,
|
||||
&iv2,do_encrypt);
|
||||
if (rem) memcpy(&(buf[l]),tmpbuf,
|
||||
(unsigned int)rem);
|
||||
}
|
||||
else
|
||||
{
|
||||
des_cbc_encrypt(
|
||||
(des_cblock *)buf,(des_cblock *)obuf,
|
||||
(long)l,ks,(des_cblock *)iv,do_encrypt);
|
||||
buf,obuf,
|
||||
(long)l,ks,&iv,do_encrypt);
|
||||
if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
|
||||
}
|
||||
if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem);
|
||||
@ -609,14 +598,14 @@ void doencryption()
|
||||
{
|
||||
des_3cbc_encrypt(
|
||||
(des_cblock *)buf,(des_cblock *)obuf,
|
||||
(long)l,ks,ks2,(des_cblock *)iv,
|
||||
(des_cblock *)iv2,do_encrypt);
|
||||
(long)l,ks,ks2,&iv,
|
||||
&iv2,do_encrypt);
|
||||
}
|
||||
else
|
||||
{
|
||||
des_cbc_encrypt(
|
||||
(des_cblock *)buf,(des_cblock *)obuf,
|
||||
(long)l,ks,(des_cblock *)iv,do_encrypt);
|
||||
buf,obuf,
|
||||
(long)l,ks,&iv,do_encrypt);
|
||||
if (l >= 8) memcpy(iv,&(buf[l-8]),8);
|
||||
}
|
||||
|
||||
@ -641,9 +630,9 @@ void doencryption()
|
||||
l=l-8+last;
|
||||
}
|
||||
i=0;
|
||||
if (cflag) des_cbc_cksum((C_Block *)obuf,
|
||||
(C_Block *)cksum,(long)l/8*8,ks,
|
||||
(C_Block *)cksum);
|
||||
if (cflag) des_cbc_cksum(obuf,
|
||||
(des_cblock *)cksum,(long)l/8*8,ks,
|
||||
(des_cblock *)cksum);
|
||||
while (i != l)
|
||||
{
|
||||
j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT);
|
||||
@ -691,15 +680,8 @@ void doencryption()
|
||||
if (Exit) EXIT(Exit);
|
||||
}
|
||||
|
||||
int uufwrite(data, size, num, fp)
|
||||
unsigned char *data;
|
||||
int size;
|
||||
unsigned int num;
|
||||
FILE *fp;
|
||||
|
||||
/* We ignore this parameter but it should be > ~50 I believe */
|
||||
|
||||
|
||||
/* We ignore this parameter but it should be > ~50 I believe */
|
||||
int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp)
|
||||
{
|
||||
int i,j,left,rem,ret=num;
|
||||
static int start=1;
|
||||
@ -752,8 +734,7 @@ FILE *fp;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void uufwriteEnd(fp)
|
||||
FILE *fp;
|
||||
void uufwriteEnd(FILE *fp)
|
||||
{
|
||||
int j;
|
||||
static const char *end=" \nend\n";
|
||||
@ -769,11 +750,8 @@ FILE *fp;
|
||||
fwrite(end,1,strlen(end),fp);
|
||||
}
|
||||
|
||||
int uufread(out, size, num, fp)
|
||||
unsigned char *out;
|
||||
int size; /* should always be > ~ 60; I actually ignore this parameter :-) */
|
||||
unsigned int num;
|
||||
FILE *fp;
|
||||
/* int size: should always be > ~ 60; I actually ignore this parameter :-) */
|
||||
int uufread(unsigned char *out, int size, unsigned int num, FILE *fp)
|
||||
{
|
||||
int i,j,tot;
|
||||
static int done=0;
|
||||
@ -845,10 +823,7 @@ FILE *fp;
|
||||
*((c)++)=(unsigned char)(((l) )&0xff))
|
||||
|
||||
|
||||
int uuencode(in, num, out)
|
||||
unsigned char *in;
|
||||
int num;
|
||||
unsigned char *out;
|
||||
int uuencode(unsigned char *in, int num, unsigned char *out)
|
||||
{
|
||||
int j,i,n,tot=0;
|
||||
DES_LONG l;
|
||||
@ -878,10 +853,7 @@ unsigned char *out;
|
||||
return(tot);
|
||||
}
|
||||
|
||||
int uudecode(in, num, out)
|
||||
unsigned char *in;
|
||||
int num;
|
||||
unsigned char *out;
|
||||
int uudecode(unsigned char *in, int num, unsigned char *out)
|
||||
{
|
||||
int j,i,k;
|
||||
unsigned int n=0,space=0;
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/des.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -63,39 +63,35 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef NO_DES
|
||||
#error DES is disabled.
|
||||
#endif
|
||||
|
||||
#ifdef _KERBEROS_DES_H
|
||||
#error <openssl/des.h> replaces <kerberos/des.h>.
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef DES_LIB_FUNCTION
|
||||
#if defined(__BORLANDC__)
|
||||
#define DES_LIB_FUNCTION /* not-ready-definition-yet */
|
||||
#elif defined(_MSC_VER)
|
||||
#define DES_LIB_FUNCTION /* not-ready-definition-yet2 */
|
||||
#else
|
||||
#define DES_LIB_FUNCTION
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
#if defined(__alpha) || defined(__sparcv9)
|
||||
#define DES_LONG unsigned int
|
||||
#else /* Not a 64 bit machine */
|
||||
#define DES_LONG unsigned long
|
||||
#endif
|
||||
#endif
|
||||
#include <openssl/opensslconf.h> /* DES_LONG */
|
||||
#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
|
||||
|
||||
typedef unsigned char des_cblock[8];
|
||||
typedef /* const */ unsigned char const_des_cblock[8];
|
||||
/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock *
|
||||
* and const_des_cblock * are incompatible pointer types.
|
||||
* I haven't seen that warning on other systems ... I'll look
|
||||
* what the standard says. */
|
||||
|
||||
|
||||
typedef struct des_ks_struct
|
||||
{
|
||||
union {
|
||||
des_cblock _;
|
||||
des_cblock cblock;
|
||||
/* make sure things are correct size on machines with
|
||||
* 8 byte longs */
|
||||
DES_LONG pad[2];
|
||||
DES_LONG deslong[2];
|
||||
} ks;
|
||||
#undef _
|
||||
#define _ ks._
|
||||
int weak_key;
|
||||
} des_key_schedule[16];
|
||||
|
||||
#define DES_KEY_SZ (sizeof(des_cblock))
|
||||
@ -119,189 +115,133 @@ typedef struct des_ks_struct
|
||||
#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
#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
|
||||
#define random_key des_random_key
|
||||
#define pcbc_encrypt des_pcbc_encrypt
|
||||
#define set_key des_set_key
|
||||
#define key_sched des_key_sched
|
||||
#define ecb_encrypt des_ecb_encrypt
|
||||
#define cbc_encrypt des_cbc_encrypt
|
||||
#define ncbc_encrypt des_ncbc_encrypt
|
||||
#define xcbc_encrypt des_xcbc_encrypt
|
||||
#define cbc_cksum des_cbc_cksum
|
||||
#define quad_cksum des_quad_cksum
|
||||
OPENSSL_EXTERN int des_check_key; /* defaults to false */
|
||||
OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */
|
||||
OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */
|
||||
|
||||
const char *des_options(void);
|
||||
void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
|
||||
des_key_schedule ks1,des_key_schedule ks2,
|
||||
des_key_schedule ks3, int enc);
|
||||
DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock *output,
|
||||
long length,des_key_schedule schedule,
|
||||
const_des_cblock *ivec);
|
||||
/* des_cbc_encrypt does not update the IV! Use des_ncbc_encrypt instead. */
|
||||
void des_cbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,
|
||||
int enc);
|
||||
void des_ncbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,
|
||||
int enc);
|
||||
void des_xcbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,
|
||||
const_des_cblock *inw,const_des_cblock *outw,int enc);
|
||||
void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,
|
||||
int enc);
|
||||
void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
|
||||
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_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void des_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,
|
||||
des_key_schedule ks1,des_key_schedule ks2,
|
||||
des_key_schedule ks3,des_cblock *ivec,int enc);
|
||||
void des_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
|
||||
long length,
|
||||
des_key_schedule ks1,des_key_schedule ks2,
|
||||
des_key_schedule ks3,
|
||||
des_cblock *ivec1,des_cblock *ivec2,
|
||||
int enc);
|
||||
void des_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
|
||||
long length,des_key_schedule ks1,
|
||||
des_key_schedule ks2,des_key_schedule ks3,
|
||||
des_cblock *ivec,int *num,int enc);
|
||||
void des_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
|
||||
long length,des_key_schedule ks1,
|
||||
des_key_schedule ks2,des_key_schedule ks3,
|
||||
des_cblock *ivec,int *num);
|
||||
|
||||
void des_xwhite_in2out(const_des_cblock *des_key,const_des_cblock *in_white,
|
||||
des_cblock *out_white);
|
||||
|
||||
int des_enc_read(int fd,void *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
int des_enc_write(int fd,const void *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
char *des_fcrypt(const char *buf,const char *salt, char *ret);
|
||||
char *des_crypt(const char *buf,const char *salt);
|
||||
#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT)
|
||||
char *crypt(const char *buf,const char *salt);
|
||||
#endif
|
||||
void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec);
|
||||
void des_pcbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,
|
||||
int enc);
|
||||
DES_LONG des_quad_cksum(const unsigned char *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);
|
||||
int des_read_password(des_cblock *key,const char *prompt,int verify);
|
||||
int des_read_2passwords(des_cblock *key1,des_cblock *key2,
|
||||
const char *prompt,int verify);
|
||||
int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
|
||||
void des_set_odd_parity(des_cblock *key);
|
||||
int des_is_weak_key(const_des_cblock *key);
|
||||
int des_set_key(const_des_cblock *key,des_key_schedule schedule);
|
||||
int des_key_sched(const_des_cblock *key,des_key_schedule schedule);
|
||||
void des_string_to_key(const char *str,des_cblock *key);
|
||||
void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2);
|
||||
void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int *num,
|
||||
int enc);
|
||||
void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int *num);
|
||||
int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
|
||||
|
||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
||||
void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
|
||||
|
||||
/* The following definitions provide compatibility with the MIT Kerberos
|
||||
* library. The des_key_schedule structure is not binary compatible. */
|
||||
|
||||
#define _KERBEROS_DES_H
|
||||
|
||||
#define KRBDES_ENCRYPT DES_ENCRYPT
|
||||
#define KRBDES_DECRYPT DES_DECRYPT
|
||||
|
||||
#ifdef KERBEROS
|
||||
# define ENCRYPT DES_ENCRYPT
|
||||
# define DECRYPT DES_DECRYPT
|
||||
#endif
|
||||
|
||||
#ifndef NCOMPAT
|
||||
# define C_Block des_cblock
|
||||
# define Key_schedule des_key_schedule
|
||||
# define KEY_SZ DES_KEY_SZ
|
||||
# define string_to_key des_string_to_key
|
||||
# define read_pw_string des_read_pw_string
|
||||
# define random_key des_random_key
|
||||
# define pcbc_encrypt des_pcbc_encrypt
|
||||
# define set_key des_set_key
|
||||
# define key_sched des_key_sched
|
||||
# define ecb_encrypt des_ecb_encrypt
|
||||
# define cbc_encrypt des_cbc_encrypt
|
||||
# define ncbc_encrypt des_ncbc_encrypt
|
||||
# define xcbc_encrypt des_xcbc_encrypt
|
||||
# define cbc_cksum des_cbc_cksum
|
||||
# define quad_cksum des_quad_cksum
|
||||
#endif
|
||||
|
||||
/* For compatibility with the MIT lib - eay 20/05/92 */
|
||||
typedef des_key_schedule bit_64;
|
||||
#define des_fixup_key_parity des_set_odd_parity
|
||||
#define des_check_key_parity check_parity
|
||||
|
||||
extern int des_check_key; /* defaults to false */
|
||||
extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
|
||||
|
||||
#ifdef cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The next line is used to disable full ANSI prototypes, if your
|
||||
* compiler has problems with the prototypes, make sure this line always
|
||||
* evaluates to true :-) */
|
||||
#if defined(MSDOS) || defined(__STDC__)
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
#ifndef NOPROTO
|
||||
char *DES_LIB_FUNCTION des_options(void);
|
||||
void DES_LIB_FUNCTION des_ecb3_encrypt(des_cblock *input,des_cblock *output,
|
||||
des_key_schedule ks1,des_key_schedule ks2,
|
||||
des_key_schedule ks3, int enc);
|
||||
DES_LONG DES_LIB_FUNCTION des_cbc_cksum(des_cblock *input,des_cblock *output,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec);
|
||||
void DES_LIB_FUNCTION des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void DES_LIB_FUNCTION des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void DES_LIB_FUNCTION des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,
|
||||
des_cblock *inw,des_cblock *outw,int enc);
|
||||
void DES_LIB_FUNCTION des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule sk1,des_key_schedule sk2,
|
||||
des_cblock *ivec1,des_cblock *ivec2,int enc);
|
||||
void DES_LIB_FUNCTION des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void DES_LIB_FUNCTION des_ecb_encrypt(des_cblock *input,des_cblock *output,
|
||||
des_key_schedule ks,int enc);
|
||||
void DES_LIB_FUNCTION des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
|
||||
void DES_LIB_FUNCTION des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
|
||||
void DES_LIB_FUNCTION des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void DES_LIB_FUNCTION des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void DES_LIB_FUNCTION 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);
|
||||
void DES_LIB_FUNCTION des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int *num, int encrypt);
|
||||
void DES_LIB_FUNCTION des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int *num);
|
||||
|
||||
int DES_LIB_FUNCTION des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
int DES_LIB_FUNCTION des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
char *DES_LIB_FUNCTION des_fcrypt(const char *buf,const char *salt, char *ret);
|
||||
#ifdef PERL5
|
||||
char *des_crypt(const char *buf,const char *salt);
|
||||
#else
|
||||
/* some stupid compilers complain because I have declared char instead
|
||||
* of const char */
|
||||
#ifdef HEADER_DES_LOCL_H
|
||||
char *DES_LIB_FUNCTION crypt(const char *buf,const char *salt);
|
||||
#else
|
||||
char *crypt();
|
||||
#endif
|
||||
#endif
|
||||
void DES_LIB_FUNCTION des_ofb_encrypt(unsigned char *in,unsigned char *out,
|
||||
int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
|
||||
void DES_LIB_FUNCTION des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
DES_LONG DES_LIB_FUNCTION des_quad_cksum(des_cblock *input,des_cblock *output,
|
||||
long length,int out_count,des_cblock *seed);
|
||||
void DES_LIB_FUNCTION des_random_seed(des_cblock key);
|
||||
void DES_LIB_FUNCTION des_random_key(des_cblock ret);
|
||||
int DES_LIB_FUNCTION des_read_password(des_cblock *key,char *prompt,int verify);
|
||||
int DES_LIB_FUNCTION des_read_2passwords(des_cblock *key1,des_cblock *key2,
|
||||
char *prompt,int verify);
|
||||
int DES_LIB_FUNCTION des_read_pw_string(char *buf,int length,char *prompt,int verify);
|
||||
void DES_LIB_FUNCTION des_set_odd_parity(des_cblock *key);
|
||||
int DES_LIB_FUNCTION des_is_weak_key(des_cblock *key);
|
||||
int DES_LIB_FUNCTION des_set_key(des_cblock *key,des_key_schedule schedule);
|
||||
int DES_LIB_FUNCTION des_key_sched(des_cblock *key,des_key_schedule schedule);
|
||||
void DES_LIB_FUNCTION des_string_to_key(char *str,des_cblock *key);
|
||||
void DES_LIB_FUNCTION des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
|
||||
void DES_LIB_FUNCTION des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
|
||||
void DES_LIB_FUNCTION des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int *num);
|
||||
|
||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
||||
void DES_LIB_FUNCTION des_cblock_print_file(des_cblock *cb, FILE *fp);
|
||||
/* 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. */
|
||||
int DES_LIB_FUNCTION des_new_random_key(des_cblock *key);
|
||||
void DES_LIB_FUNCTION des_init_random_number_generator(des_cblock *key);
|
||||
void DES_LIB_FUNCTION des_set_random_generator_seed(des_cblock *key);
|
||||
void DES_LIB_FUNCTION des_set_sequence_number(des_cblock new_sequence_number);
|
||||
void DES_LIB_FUNCTION des_generate_random_block(des_cblock *block);
|
||||
void DES_LIB_FUNCTION des_rand_data(unsigned char *data, int size);
|
||||
|
||||
#else
|
||||
|
||||
char *des_options();
|
||||
void des_ecb3_encrypt();
|
||||
DES_LONG des_cbc_cksum();
|
||||
void des_cbc_encrypt();
|
||||
void des_ncbc_encrypt();
|
||||
void des_xcbc_encrypt();
|
||||
void des_3cbc_encrypt();
|
||||
void des_cfb_encrypt();
|
||||
void des_ede3_cfb64_encrypt();
|
||||
void des_ede3_ofb64_encrypt();
|
||||
void des_ecb_encrypt();
|
||||
void des_encrypt();
|
||||
void des_encrypt2();
|
||||
void des_encrypt3();
|
||||
void des_decrypt3();
|
||||
void des_ede3_cbc_encrypt();
|
||||
int des_enc_read();
|
||||
int des_enc_write();
|
||||
char *des_fcrypt();
|
||||
#ifdef PERL5
|
||||
char *des_crypt();
|
||||
#else
|
||||
char *crypt();
|
||||
#endif
|
||||
void des_ofb_encrypt();
|
||||
void des_pcbc_encrypt();
|
||||
DES_LONG des_quad_cksum();
|
||||
void des_random_seed();
|
||||
void des_random_key();
|
||||
int des_read_password();
|
||||
int des_read_2passwords();
|
||||
int des_read_pw_string();
|
||||
void des_set_odd_parity();
|
||||
int des_is_weak_key();
|
||||
int des_set_key();
|
||||
int des_key_sched();
|
||||
void des_string_to_key();
|
||||
void des_string_to_2keys();
|
||||
void des_cfb64_encrypt();
|
||||
void des_ofb64_encrypt();
|
||||
|
||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
||||
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. */
|
||||
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();
|
||||
void des_rand_data();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -183,4 +183,4 @@ with 424 null bytes. To get around this problem, use the -u option
|
||||
to uuencode the data before it is send to the VMS system.
|
||||
.SH AUTHOR
|
||||
.LP
|
||||
Eric Young (eay@mincom.oz.au or eay@psych.psy.uq.oz.au)
|
||||
Eric Young (eay@cryptsoft.com)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/local/bin/perl
|
||||
# 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@cryptsoft.com
|
||||
#
|
||||
# Copyright (C) 1993 Eric Young
|
||||
#
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
package des;
|
||||
|
||||
eval("usr integer;") if (int($]) > 4);
|
||||
eval("use integer;") if (int($]) > 4);
|
||||
|
||||
# The following 8 arrays are used in des_set_key
|
||||
@skb0=(
|
||||
|
67
crypto/libdes/des3s.cpp
Normal file
67
crypto/libdes/des3s.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// gettsc.inl
|
||||
//
|
||||
// gives access to the Pentium's (secret) cycle counter
|
||||
//
|
||||
// This software was written by Leonard Janke (janke@unixg.ubc.ca)
|
||||
// in 1996-7 and is entered, by him, into the public domain.
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
void GetTSC(unsigned long&);
|
||||
#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
|
||||
#elif defined(__GNUC__)
|
||||
inline
|
||||
void GetTSC(unsigned long& tsc)
|
||||
{
|
||||
asm volatile(".byte 15, 49\n\t"
|
||||
: "=eax" (tsc)
|
||||
:
|
||||
: "%edx", "%eax");
|
||||
}
|
||||
#elif defined(_MSC_VER)
|
||||
inline
|
||||
void GetTSC(unsigned long& tsc)
|
||||
{
|
||||
unsigned long a;
|
||||
__asm _emit 0fh
|
||||
__asm _emit 31h
|
||||
__asm mov a, eax;
|
||||
tsc=a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/des.h>
|
||||
|
||||
void main(int argc,char *argv[])
|
||||
{
|
||||
des_key_schedule key1,key2,key3;
|
||||
unsigned long s1,s2,e1,e2;
|
||||
unsigned long data[2];
|
||||
int i,j;
|
||||
|
||||
for (j=0; j<6; j++)
|
||||
{
|
||||
for (i=0; i<1000; i++) /**/
|
||||
{
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
GetTSC(s1);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
GetTSC(e1);
|
||||
GetTSC(s2);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
GetTSC(e2);
|
||||
des_encrypt3(&data[0],key1,key2,key3);
|
||||
}
|
||||
|
||||
printf("des %d %d (%d)\n",
|
||||
e1-s1,e2-s2,((e2-s2)-(e1-s1)));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
des_read_password, des_read_2password,
|
||||
des_string_to_key, des_string_to_2key, des_read_pw_string,
|
||||
des_random_key, des_set_key,
|
||||
des_key_sched, des_ecb_encrypt, des_3ecb_encrypt, des_cbc_encrypt,
|
||||
des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt,
|
||||
des_3cbc_encrypt,
|
||||
des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt,
|
||||
des_cbc_cksum, des_quad_cksum,
|
||||
@ -56,7 +56,7 @@ des_cblock *output;
|
||||
des_key_schedule schedule;
|
||||
int encrypt;
|
||||
.PP
|
||||
.B int des_3ecb_encrypt(input,output,ks1,ks2,encrypt)
|
||||
.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt)
|
||||
des_cblock *input;
|
||||
des_cblock *output;
|
||||
des_key_schedule ks1,ks2;
|
||||
@ -206,7 +206,7 @@ converts a string into a valid des key.
|
||||
.I des_string_to_2key
|
||||
converts a string into 2 valid des keys.
|
||||
This routine is best suited for used to generate keys for use with
|
||||
.I des_3ecb_encrypt.
|
||||
.I des_ecb3_encrypt.
|
||||
.PP
|
||||
.I des_random_key
|
||||
returns a random key that is made of a combination of process id,
|
||||
@ -274,7 +274,7 @@ is decrypted into the
|
||||
Input and output may overlap.
|
||||
No meaningful value is returned.
|
||||
.PP
|
||||
.I des_3ecb_encrypt
|
||||
.I des_ecb3_encrypt
|
||||
encrypts/decrypts the
|
||||
.I input
|
||||
block by using triple ecb DES encryption.
|
||||
@ -505,4 +505,4 @@ general cryptographic library that amonst other things implements
|
||||
netscapes SSL protocoll. The most recent version can be found in
|
||||
SSLeay distributions.
|
||||
.SH AUTHOR
|
||||
Eric Young (eay@mincom.oz.au or eay@psych.psy.uq.oz.au)
|
||||
Eric Young (eay@cryptsoft.com)
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/des_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,14 +58,11 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
void des_encrypt(data, ks, encrypt)
|
||||
DES_LONG *data;
|
||||
des_key_schedule ks;
|
||||
int encrypt;
|
||||
void des_encrypt(DES_LONG *data, des_key_schedule ks, int enc)
|
||||
{
|
||||
register DES_LONG l,r,t,u;
|
||||
#ifdef DES_PTR
|
||||
register unsigned char *des_SP=(unsigned char *)des_SPtrans;
|
||||
register const unsigned char *des_SP=(const unsigned char *)des_SPtrans;
|
||||
#endif
|
||||
#ifndef DES_UNROLL
|
||||
register int i;
|
||||
@ -87,10 +84,10 @@ int encrypt;
|
||||
r=ROTATE(r,29)&0xffffffffL;
|
||||
l=ROTATE(l,29)&0xffffffffL;
|
||||
|
||||
s=(DES_LONG *)ks;
|
||||
s=ks->ks.deslong;
|
||||
/* I don't know if it is worth the effort of loop unrolling the
|
||||
* inner loop */
|
||||
if (encrypt)
|
||||
if (enc)
|
||||
{
|
||||
#ifdef DES_UNROLL
|
||||
D_ENCRYPT(l,r, 0); /* 1 */
|
||||
@ -159,14 +156,11 @@ int encrypt;
|
||||
l=r=t=u=0;
|
||||
}
|
||||
|
||||
void des_encrypt2(data, ks, encrypt)
|
||||
DES_LONG *data;
|
||||
des_key_schedule ks;
|
||||
int encrypt;
|
||||
void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
|
||||
{
|
||||
register DES_LONG l,r,t,u;
|
||||
#ifdef DES_PTR
|
||||
register unsigned char *des_SP=(unsigned char *)des_SPtrans;
|
||||
register const unsigned char *des_SP=(const unsigned char *)des_SPtrans;
|
||||
#endif
|
||||
#ifndef DES_UNROLL
|
||||
register int i;
|
||||
@ -183,13 +177,13 @@ int encrypt;
|
||||
* Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
|
||||
* for pointing this out. */
|
||||
/* clear the top bits on machines with 8byte longs */
|
||||
r=ROTATE(r,29)&0xffffffff;
|
||||
l=ROTATE(l,29)&0xffffffff;
|
||||
r=ROTATE(r,29)&0xffffffffL;
|
||||
l=ROTATE(l,29)&0xffffffffL;
|
||||
|
||||
s=(DES_LONG *)ks;
|
||||
s=ks->ks.deslong;
|
||||
/* I don't know if it is worth the effort of loop unrolling the
|
||||
* inner loop */
|
||||
if (encrypt)
|
||||
if (enc)
|
||||
{
|
||||
#ifdef DES_UNROLL
|
||||
D_ENCRYPT(l,r, 0); /* 1 */
|
||||
@ -248,16 +242,13 @@ int encrypt;
|
||||
#endif
|
||||
}
|
||||
/* rotate and clear the top bits on machines with 8byte longs */
|
||||
data[0]=ROTATE(l,3)&0xffffffff;
|
||||
data[1]=ROTATE(r,3)&0xffffffff;
|
||||
data[0]=ROTATE(l,3)&0xffffffffL;
|
||||
data[1]=ROTATE(r,3)&0xffffffffL;
|
||||
l=r=t=u=0;
|
||||
}
|
||||
|
||||
void des_encrypt3(data,ks1,ks2,ks3)
|
||||
DES_LONG *data;
|
||||
des_key_schedule ks1;
|
||||
des_key_schedule ks2;
|
||||
des_key_schedule ks3;
|
||||
void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3)
|
||||
{
|
||||
register DES_LONG l,r;
|
||||
|
||||
@ -276,11 +267,8 @@ des_key_schedule ks3;
|
||||
data[1]=r;
|
||||
}
|
||||
|
||||
void des_decrypt3(data,ks1,ks2,ks3)
|
||||
DES_LONG *data;
|
||||
des_key_schedule ks1;
|
||||
des_key_schedule ks2;
|
||||
des_key_schedule ks3;
|
||||
void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3)
|
||||
{
|
||||
register DES_LONG l,r;
|
||||
|
||||
@ -299,3 +287,120 @@ des_key_schedule ks3;
|
||||
data[1]=r;
|
||||
}
|
||||
|
||||
#ifndef DES_DEFAULT_OPTIONS
|
||||
|
||||
#undef CBC_ENC_C__DONT_UPDATE_IV
|
||||
#include "ncbc_enc.c" /* des_ncbc_encrypt */
|
||||
|
||||
void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int enc)
|
||||
{
|
||||
register DES_LONG tin0,tin1;
|
||||
register DES_LONG tout0,tout1,xor0,xor1;
|
||||
register const unsigned char *in;
|
||||
unsigned char *out;
|
||||
register long l=length;
|
||||
DES_LONG tin[2];
|
||||
unsigned char *iv;
|
||||
|
||||
in=input;
|
||||
out=output;
|
||||
iv = &(*ivec)[0];
|
||||
|
||||
if (enc)
|
||||
{
|
||||
c2l(iv,tout0);
|
||||
c2l(iv,tout1);
|
||||
for (l-=8; l>=0; l-=8)
|
||||
{
|
||||
c2l(in,tin0);
|
||||
c2l(in,tin1);
|
||||
tin0^=tout0;
|
||||
tin1^=tout1;
|
||||
|
||||
tin[0]=tin0;
|
||||
tin[1]=tin1;
|
||||
des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
|
||||
tout0=tin[0];
|
||||
tout1=tin[1];
|
||||
|
||||
l2c(tout0,out);
|
||||
l2c(tout1,out);
|
||||
}
|
||||
if (l != -8)
|
||||
{
|
||||
c2ln(in,tin0,tin1,l+8);
|
||||
tin0^=tout0;
|
||||
tin1^=tout1;
|
||||
|
||||
tin[0]=tin0;
|
||||
tin[1]=tin1;
|
||||
des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
|
||||
tout0=tin[0];
|
||||
tout1=tin[1];
|
||||
|
||||
l2c(tout0,out);
|
||||
l2c(tout1,out);
|
||||
}
|
||||
iv = &(*ivec)[0];
|
||||
l2c(tout0,iv);
|
||||
l2c(tout1,iv);
|
||||
}
|
||||
else
|
||||
{
|
||||
register DES_LONG t0,t1;
|
||||
|
||||
c2l(iv,xor0);
|
||||
c2l(iv,xor1);
|
||||
for (l-=8; l>=0; l-=8)
|
||||
{
|
||||
c2l(in,tin0);
|
||||
c2l(in,tin1);
|
||||
|
||||
t0=tin0;
|
||||
t1=tin1;
|
||||
|
||||
tin[0]=tin0;
|
||||
tin[1]=tin1;
|
||||
des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
|
||||
tout0=tin[0];
|
||||
tout1=tin[1];
|
||||
|
||||
tout0^=xor0;
|
||||
tout1^=xor1;
|
||||
l2c(tout0,out);
|
||||
l2c(tout1,out);
|
||||
xor0=t0;
|
||||
xor1=t1;
|
||||
}
|
||||
if (l != -8)
|
||||
{
|
||||
c2l(in,tin0);
|
||||
c2l(in,tin1);
|
||||
|
||||
t0=tin0;
|
||||
t1=tin1;
|
||||
|
||||
tin[0]=tin0;
|
||||
tin[1]=tin1;
|
||||
des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
|
||||
tout0=tin[0];
|
||||
tout1=tin[1];
|
||||
|
||||
tout0^=xor0;
|
||||
tout1^=xor1;
|
||||
l2cn(tout0,tout1,out,l+8);
|
||||
xor0=t0;
|
||||
xor1=t1;
|
||||
}
|
||||
|
||||
iv = &(*ivec)[0];
|
||||
l2c(xor0,iv);
|
||||
l2c(xor1,iv);
|
||||
}
|
||||
tin0=tin1=tout0=tout1=xor0=xor1=0;
|
||||
tin[0]=tin[1]=0;
|
||||
}
|
||||
|
||||
#endif /* DES_DEFAULT_OPTIONS */
|
||||
|
@ -1,32 +1,9 @@
|
||||
#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 */
|
||||
|
||||
/* crypto/des/des_locl.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -34,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -54,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -79,14 +56,6 @@
|
||||
* [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
|
||||
|
||||
@ -98,126 +67,28 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include "des.h"
|
||||
|
||||
#ifndef DES_DEFAULT_OPTIONS
|
||||
/* the following is tweaked from a config script, that is why it is a
|
||||
* protected undef/define */
|
||||
#ifndef DES_PTR
|
||||
#undef DES_PTR
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#ifndef MSDOS
|
||||
#if !defined(VMS) || defined(__DECC)
|
||||
#include OPENSSL_UNISTD
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
/* This helps C compiler generate the correct code for multiple functional
|
||||
* units. It reduces register dependancies at the expense of 2 more
|
||||
* registers */
|
||||
#ifndef DES_RISC1
|
||||
#undef DES_RISC1
|
||||
#endif
|
||||
|
||||
#ifndef DES_RISC2
|
||||
#undef DES_RISC2
|
||||
#endif
|
||||
|
||||
#if defined(DES_RISC1) && defined(DES_RISC2)
|
||||
YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
#endif
|
||||
|
||||
/* Unroll the inner loop, this sometimes helps, sometimes hinders.
|
||||
* Very mucy CPU dependant */
|
||||
#ifndef DES_UNROLL
|
||||
#undef DES_UNROLL
|
||||
#endif
|
||||
|
||||
/* These default values were supplied by
|
||||
* Peter Gutman <pgut001@cs.auckland.ac.nz>
|
||||
* They are only used if nothing else has been defined */
|
||||
#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
|
||||
/* Special defines which change the way the code is built depending on the
|
||||
CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
|
||||
even newer MIPS CPU's, but at the moment one size fits all for
|
||||
optimization options. Older Sparc's work better with only UNROLL, but
|
||||
there's no way to tell at compile time what it is you're running on */
|
||||
|
||||
#if defined( sun ) /* Newer Sparc's */
|
||||
#define DES_PTR
|
||||
#define DES_RISC1
|
||||
#define DES_UNROLL
|
||||
#elif defined( __ultrix ) /* Older MIPS */
|
||||
#define DES_PTR
|
||||
#define DES_RISC2
|
||||
#define DES_UNROLL
|
||||
#elif defined( __osf1__ ) /* Alpha */
|
||||
#define DES_PTR
|
||||
#define DES_RISC2
|
||||
#elif defined ( _AIX ) /* RS6000 */
|
||||
/* Unknown */
|
||||
#elif defined( __hpux ) /* HP-PA */
|
||||
#define DES_UNROLL
|
||||
#elif defined( __aux ) /* 68K */
|
||||
/* Unknown */
|
||||
#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
|
||||
#define DES_UNROLL
|
||||
#elif defined( __sgi ) /* Newer MIPS */
|
||||
#define DES_PTR
|
||||
#define DES_RISC2
|
||||
#define DES_UNROLL
|
||||
#elif defined( i386 ) /* x86 boxes, should be gcc */
|
||||
#define DES_PTR
|
||||
#define DES_RISC1
|
||||
#define DES_UNROLL
|
||||
#endif /* Systems-specific speed defines */
|
||||
#endif
|
||||
|
||||
#endif /* DES_DEFAULT_OPTIONS */
|
||||
#include <openssl/des.h>
|
||||
|
||||
#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#ifndef RAND
|
||||
#define RAND
|
||||
#endif
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
|
||||
#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) || defined(WIN32)
|
||||
#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef RAND
|
||||
#define RAND
|
||||
#endif
|
||||
|
||||
#ifdef linux
|
||||
#undef RAND
|
||||
#endif
|
||||
|
||||
#ifdef MSDOS
|
||||
#define getpid() 2
|
||||
#define RAND
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
|
||||
#if defined(NOCONST)
|
||||
#define const
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
|
||||
#ifdef RAND
|
||||
#define srandom(s) srand(s)
|
||||
#define random rand
|
||||
#endif
|
||||
|
||||
#define ITERATIONS 16
|
||||
#define HALF_ITERATIONS 8
|
||||
|
||||
@ -328,24 +199,24 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
u2&=0xfc; \
|
||||
t=ROTATE(t,4); \
|
||||
u>>=16L; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
|
||||
LL^= *(const DES_LONG *)(des_SP +u1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
|
||||
u3=(int)(u>>8L); \
|
||||
u1=(int)u&0xfc; \
|
||||
u3&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+u3); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x400+u1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x600+u3); \
|
||||
u2=(int)t>>8L; \
|
||||
u1=(int)t&0xfc; \
|
||||
u2&=0xfc; \
|
||||
t>>=16L; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
|
||||
u3=(int)t>>8L; \
|
||||
u1=(int)t&0xfc; \
|
||||
u3&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+u3); }
|
||||
LL^= *(const DES_LONG *)(des_SP+0x500+u1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x700+u3); }
|
||||
#endif
|
||||
#ifdef DES_RISC2
|
||||
#define D_ENCRYPT(LL,R,S) { \
|
||||
@ -355,39 +226,39 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
u1=(int)u&0xfc; \
|
||||
u2&=0xfc; \
|
||||
t=ROTATE(t,4); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
|
||||
LL^= *(const DES_LONG *)(des_SP +u1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
|
||||
s1=(int)(u>>16L); \
|
||||
s2=(int)(u>>24L); \
|
||||
s1&=0xfc; \
|
||||
s2&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+s1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+s2); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x400+s1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x600+s2); \
|
||||
u2=(int)t>>8L; \
|
||||
u1=(int)t&0xfc; \
|
||||
u2&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
|
||||
s1=(int)(t>>16L); \
|
||||
s2=(int)(t>>24L); \
|
||||
s1&=0xfc; \
|
||||
s2&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+s1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+s2); }
|
||||
LL^= *(const DES_LONG *)(des_SP+0x500+s1); \
|
||||
LL^= *(const DES_LONG *)(des_SP+0x700+s2); }
|
||||
#endif
|
||||
#else
|
||||
#define D_ENCRYPT(LL,R,S) { \
|
||||
LOAD_DATA_tmp(R,S,u,t,E0,E1); \
|
||||
t=ROTATE(t,4); \
|
||||
LL^= \
|
||||
*(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24L)&0xfc)); }
|
||||
*(const DES_LONG *)(des_SP +((u )&0xfc))^ \
|
||||
*(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \
|
||||
*(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \
|
||||
*(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \
|
||||
*(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \
|
||||
*(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \
|
||||
*(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \
|
||||
*(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); }
|
||||
#endif
|
||||
|
||||
#else /* original version */
|
||||
@ -530,6 +401,8 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
|
||||
}
|
||||
|
||||
extern const DES_LONG des_SPtrans[8][64];
|
||||
OPENSSL_EXTERN const DES_LONG des_SPtrans[8][64];
|
||||
|
||||
void fcrypt_body(DES_LONG *out,des_key_schedule ks,
|
||||
DES_LONG Eswap0, DES_LONG Eswap1);
|
||||
#endif
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/des_opts.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -59,19 +59,19 @@
|
||||
/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
|
||||
* This is for machines with 64k code segment size restrictions. */
|
||||
|
||||
#ifndef MSDOS
|
||||
#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
|
||||
#define TIMES
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef MSDOS
|
||||
#include <unistd.h>
|
||||
#include <openssl/e_os2.h>
|
||||
#include OPENSSL_UNISTD
|
||||
#else
|
||||
#include <io.h>
|
||||
extern void exit();
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#ifndef VMS
|
||||
#ifndef _IRIX
|
||||
#include <time.h>
|
||||
#endif
|
||||
@ -79,25 +79,27 @@ extern void exit();
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
#else /* VMS */
|
||||
#include <types.h>
|
||||
struct tms {
|
||||
time_t tms_utime;
|
||||
time_t tms_stime;
|
||||
time_t tms_uchild; /* I dunno... */
|
||||
time_t tms_uchildsys; /* so these names are a guess :-) */
|
||||
}
|
||||
|
||||
/* Depending on the VMS version, the tms structure is perhaps defined.
|
||||
The __TMS macro will show if it was. If it wasn't defined, we should
|
||||
undefine TIMES, since that tells the rest of the program how things
|
||||
should be handled. -- Richard Levitte */
|
||||
#if defined(VMS) && defined(__DECC) && !defined(__TMS)
|
||||
#undef TIMES
|
||||
#endif
|
||||
|
||||
#ifndef TIMES
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#ifdef sun
|
||||
|
||||
#if defined(sun) || defined(__ultrix)
|
||||
#define _POSIX_SOURCE
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "des.h"
|
||||
#include <openssl/des.h>
|
||||
#include "spr.h"
|
||||
|
||||
#define DES_DEFAULT_OPTIONS
|
||||
@ -315,26 +317,21 @@ struct tms {
|
||||
|
||||
/* The following if from times(3) man page. It may need to be changed */
|
||||
#ifndef HZ
|
||||
#ifndef CLK_TCK
|
||||
#ifndef VMS
|
||||
#define HZ 100.0
|
||||
#else /* VMS */
|
||||
#define HZ 100.0
|
||||
#endif
|
||||
#else /* CLK_TCK */
|
||||
#define HZ ((double)CLK_TCK)
|
||||
#endif
|
||||
# ifndef CLK_TCK
|
||||
# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
|
||||
# define HZ 100.0
|
||||
# else /* _BSD_CLK_TCK_ */
|
||||
# define HZ ((double)_BSD_CLK_TCK_)
|
||||
# endif
|
||||
# else /* CLK_TCK */
|
||||
# define HZ ((double)CLK_TCK)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define BUFSIZE ((long)1024)
|
||||
long run=0;
|
||||
|
||||
#ifndef NOPROTO
|
||||
double Time_F(int s);
|
||||
#else
|
||||
double Time_F();
|
||||
#endif
|
||||
|
||||
#ifdef SIGALRM
|
||||
#if defined(__STDC__) || defined(sgi)
|
||||
#define SIGRETTYPE void
|
||||
@ -342,14 +339,8 @@ double Time_F();
|
||||
#define SIGRETTYPE int
|
||||
#endif
|
||||
|
||||
#ifndef NOPROTO
|
||||
SIGRETTYPE sig_done(int sig);
|
||||
#else
|
||||
SIGRETTYPE sig_done();
|
||||
#endif
|
||||
|
||||
SIGRETTYPE sig_done(sig)
|
||||
int sig;
|
||||
SIGRETTYPE sig_done(int sig)
|
||||
{
|
||||
signal(SIGALRM,sig_done);
|
||||
run=0;
|
||||
@ -362,8 +353,7 @@ int sig;
|
||||
#define START 0
|
||||
#define STOP 1
|
||||
|
||||
double Time_F(s)
|
||||
int s;
|
||||
double Time_F(int s)
|
||||
{
|
||||
double ret;
|
||||
#ifdef TIMES
|
||||
@ -421,9 +411,7 @@ int s;
|
||||
fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
|
||||
tm[index]*8,1.0e6/tm[index]);
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
long count;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
@ -450,13 +438,13 @@ char **argv;
|
||||
fprintf(stderr,"program when this computer is idle.\n");
|
||||
#endif
|
||||
|
||||
des_set_key((C_Block *)key,sch);
|
||||
des_set_key((C_Block *)key2,sch2);
|
||||
des_set_key((C_Block *)key3,sch3);
|
||||
des_set_key(&key,sch);
|
||||
des_set_key(&key2,sch2);
|
||||
des_set_key(&key3,sch3);
|
||||
|
||||
#ifndef SIGALRM
|
||||
fprintf(stderr,"First we calculate the approximate speed ...\n");
|
||||
des_set_key((C_Block *)key,sch);
|
||||
des_set_key(&key,sch);
|
||||
count=10;
|
||||
do {
|
||||
long i;
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/des_ver.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -56,5 +56,6 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
extern char *DES_version; /* SSLeay version string */
|
||||
extern char *libdes_version; /* old libdes version string */
|
||||
#include <openssl/e_os2.h>
|
||||
OPENSSL_EXTERN char *DES_version; /* SSLeay version string */
|
||||
OPENSSL_EXTERN char *libdes_version; /* old libdes version string */
|
||||
|
67
crypto/libdes/dess.cpp
Normal file
67
crypto/libdes/dess.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// gettsc.inl
|
||||
//
|
||||
// gives access to the Pentium's (secret) cycle counter
|
||||
//
|
||||
// This software was written by Leonard Janke (janke@unixg.ubc.ca)
|
||||
// in 1996-7 and is entered, by him, into the public domain.
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
void GetTSC(unsigned long&);
|
||||
#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
|
||||
#elif defined(__GNUC__)
|
||||
inline
|
||||
void GetTSC(unsigned long& tsc)
|
||||
{
|
||||
asm volatile(".byte 15, 49\n\t"
|
||||
: "=eax" (tsc)
|
||||
:
|
||||
: "%edx", "%eax");
|
||||
}
|
||||
#elif defined(_MSC_VER)
|
||||
inline
|
||||
void GetTSC(unsigned long& tsc)
|
||||
{
|
||||
unsigned long a;
|
||||
__asm _emit 0fh
|
||||
__asm _emit 31h
|
||||
__asm mov a, eax;
|
||||
tsc=a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/des.h>
|
||||
|
||||
void main(int argc,char *argv[])
|
||||
{
|
||||
des_key_schedule key;
|
||||
unsigned long s1,s2,e1,e2;
|
||||
unsigned long data[2];
|
||||
int i,j;
|
||||
|
||||
for (j=0; j<6; j++)
|
||||
{
|
||||
for (i=0; i<1000; i++) /**/
|
||||
{
|
||||
des_encrypt(&data[0],key,1);
|
||||
GetTSC(s1);
|
||||
des_encrypt(&data[0],key,1);
|
||||
des_encrypt(&data[0],key,1);
|
||||
des_encrypt(&data[0],key,1);
|
||||
GetTSC(e1);
|
||||
GetTSC(s2);
|
||||
des_encrypt(&data[0],key,1);
|
||||
des_encrypt(&data[0],key,1);
|
||||
des_encrypt(&data[0],key,1);
|
||||
des_encrypt(&data[0],key,1);
|
||||
GetTSC(e2);
|
||||
des_encrypt(&data[0],key,1);
|
||||
}
|
||||
|
||||
printf("des %d %d (%d)\n",
|
||||
e1-s1,e2-s2,((e2-s2)-(e1-s1)));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/destest.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -56,10 +56,6 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(WIN16) || defined(WINDOWS)
|
||||
#ifndef MSDOS
|
||||
#define MSDOS
|
||||
@ -68,15 +64,28 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
#ifndef MSDOS
|
||||
#if !defined(VMS) || defined(__DECC)
|
||||
#include <openssl/opensslconf.h>
|
||||
#include OPENSSL_UNISTD
|
||||
#endif /* VMS */
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "des.h"
|
||||
#ifdef NO_DES
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("No DES support\n");
|
||||
return(0);
|
||||
}
|
||||
#else
|
||||
#include <openssl/des.h>
|
||||
|
||||
#if defined(PERL5) || defined(__FreeBSD__)
|
||||
#define crypt(c,s) (des_crypt((c),(s)))
|
||||
#endif
|
||||
|
||||
/* tisk tisk - the test keys don't all have odd parity :-( */
|
||||
/* test data */
|
||||
@ -228,7 +237,16 @@ static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
|
||||
static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
|
||||
static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
|
||||
static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
|
||||
static char cbc_data[40]="7654321 Now is the time for ";
|
||||
/* Changed the following text constant to binary so it will work on ebcdic
|
||||
* machines :-) */
|
||||
/* static char cbc_data[40]="7654321 Now is the time for \0001"; */
|
||||
static unsigned char cbc_data[40]={
|
||||
0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20,
|
||||
0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74,
|
||||
0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20,
|
||||
0x66,0x6F,0x72,0x20,0x00,0x31,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
};
|
||||
|
||||
static unsigned char cbc_ok[32]={
|
||||
0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4,
|
||||
@ -294,44 +312,80 @@ static unsigned char ofb_cipher[24]=
|
||||
DES_LONG cbc_cksum_ret=0xB462FEF7L;
|
||||
unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
|
||||
|
||||
#ifndef NOPROTO
|
||||
static char *pt(unsigned char *p);
|
||||
static int cfb_test(int bits, unsigned char *cfb_cipher);
|
||||
static int cfb64_test(unsigned char *cfb_cipher);
|
||||
static int ede_cfb64_test(unsigned char *cfb_cipher);
|
||||
#else
|
||||
static char *pt();
|
||||
static int cfb_test();
|
||||
static int cfb64_test();
|
||||
static int ede_cfb64_test();
|
||||
#endif
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i,j,err=0;
|
||||
des_cblock in,out,outin,iv3;
|
||||
des_cblock in,out,outin,iv3,iv2;
|
||||
des_key_schedule ks,ks2,ks3;
|
||||
unsigned char cbc_in[40];
|
||||
unsigned char cbc_out[40];
|
||||
DES_LONG cs;
|
||||
unsigned char cret[8];
|
||||
#ifdef _CRAY
|
||||
struct {
|
||||
int a:32;
|
||||
int b:32;
|
||||
} lqret[2];
|
||||
#else
|
||||
unsigned char qret[4][4],cret[8];
|
||||
DES_LONG lqret[4];
|
||||
#endif
|
||||
int num;
|
||||
char *str;
|
||||
|
||||
#ifndef NO_DESCBCM
|
||||
printf("Doing cbcm\n");
|
||||
if ((j=des_key_sched(&cbc_key,ks)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
}
|
||||
if ((j=des_key_sched(&cbc2_key,ks2)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
}
|
||||
if ((j=des_key_sched(&cbc3_key,ks3)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
}
|
||||
memset(cbc_out,0,40);
|
||||
memset(cbc_in,0,40);
|
||||
i=strlen((char *)cbc_data)+1;
|
||||
/* i=((i+7)/8)*8; */
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
memset(iv2,'\0',sizeof iv2);
|
||||
|
||||
des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,&iv2,
|
||||
DES_ENCRYPT);
|
||||
des_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,ks,ks2,ks3,
|
||||
&iv3,&iv2,DES_ENCRYPT);
|
||||
/* if (memcmp(cbc_out,cbc3_ok,
|
||||
(unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
|
||||
{
|
||||
printf("des_ede3_cbc_encrypt encrypt error\n");
|
||||
err=1;
|
||||
}
|
||||
*/
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
memset(iv2,'\0',sizeof iv2);
|
||||
des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,&iv2,DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
|
||||
{
|
||||
int n;
|
||||
|
||||
printf("des_ede3_cbcm_encrypt decrypt error\n");
|
||||
for(n=0 ; n < i ; ++n)
|
||||
printf(" %02x",cbc_data[n]);
|
||||
printf("\n");
|
||||
for(n=0 ; n < i ; ++n)
|
||||
printf(" %02x",cbc_in[n]);
|
||||
printf("\n");
|
||||
err=1;
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("Doing ecb\n");
|
||||
for (i=0; i<NUM_TESTS; i++)
|
||||
{
|
||||
if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0)
|
||||
if ((j=des_key_sched(&key_data[i],ks)) != 0)
|
||||
{
|
||||
printf("Key error %2d:%d\n",i+1,j);
|
||||
err=1;
|
||||
@ -339,8 +393,8 @@ char *argv[];
|
||||
memcpy(in,plain_data[i],8);
|
||||
memset(out,0,8);
|
||||
memset(outin,0,8);
|
||||
des_ecb_encrypt((C_Block *)in,(C_Block *)out,ks,DES_ENCRYPT);
|
||||
des_ecb_encrypt((C_Block *)out,(C_Block *)outin,ks,DES_DECRYPT);
|
||||
des_ecb_encrypt(&in,&out,ks,DES_ENCRYPT);
|
||||
des_ecb_encrypt(&out,&outin,ks,DES_DECRYPT);
|
||||
|
||||
if (memcmp(out,cipher_data[i],8) != 0)
|
||||
{
|
||||
@ -361,17 +415,17 @@ char *argv[];
|
||||
printf("Doing ede ecb\n");
|
||||
for (i=0; i<(NUM_TESTS-1); i++)
|
||||
{
|
||||
if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0)
|
||||
if ((j=des_key_sched(&key_data[i],ks)) != 0)
|
||||
{
|
||||
err=1;
|
||||
printf("Key error %2d:%d\n",i+1,j);
|
||||
}
|
||||
if ((j=des_key_sched((C_Block *)(key_data[i+1]),ks2)) != 0)
|
||||
if ((j=des_key_sched(&key_data[i+1],ks2)) != 0)
|
||||
{
|
||||
printf("Key error %2d:%d\n",i+2,j);
|
||||
err=1;
|
||||
}
|
||||
if ((j=des_key_sched((C_Block *)(key_data[i+2]),ks3)) != 0)
|
||||
if ((j=des_key_sched(&key_data[i+2],ks3)) != 0)
|
||||
{
|
||||
printf("Key error %2d:%d\n",i+3,j);
|
||||
err=1;
|
||||
@ -379,10 +433,8 @@ char *argv[];
|
||||
memcpy(in,plain_data[i],8);
|
||||
memset(out,0,8);
|
||||
memset(outin,0,8);
|
||||
des_ecb2_encrypt((C_Block *)in,(C_Block *)out,ks,ks2,
|
||||
DES_ENCRYPT);
|
||||
des_ecb2_encrypt((C_Block *)out,(C_Block *)outin,ks,ks2,
|
||||
DES_DECRYPT);
|
||||
des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT);
|
||||
des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT);
|
||||
|
||||
if (memcmp(out,cipher_ecb2[i],8) != 0)
|
||||
{
|
||||
@ -401,21 +453,22 @@ char *argv[];
|
||||
#endif
|
||||
|
||||
printf("Doing cbc\n");
|
||||
if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
|
||||
if ((j=des_key_sched(&cbc_key,ks)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
}
|
||||
memset(cbc_out,0,40);
|
||||
memset(cbc_in,0,40);
|
||||
des_cbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
|
||||
(long)strlen((char *)cbc_data)+1,ks,
|
||||
(C_Block *)cbc_iv,DES_ENCRYPT);
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
|
||||
&iv3,DES_ENCRYPT);
|
||||
if (memcmp(cbc_out,cbc_ok,32) != 0)
|
||||
printf("cbc_encrypt encrypt error\n");
|
||||
des_cbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in,
|
||||
(long)strlen((char *)cbc_data)+1,ks,
|
||||
(C_Block *)cbc_iv,DES_DECRYPT);
|
||||
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
|
||||
&iv3,DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0)
|
||||
{
|
||||
printf("cbc_encrypt decrypt error\n");
|
||||
@ -424,7 +477,7 @@ char *argv[];
|
||||
|
||||
#ifndef LIBDES_LIT
|
||||
printf("Doing desx cbc\n");
|
||||
if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
|
||||
if ((j=des_key_sched(&cbc_key,ks)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
@ -432,20 +485,16 @@ char *argv[];
|
||||
memset(cbc_out,0,40);
|
||||
memset(cbc_in,0,40);
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
des_xcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
|
||||
(long)strlen((char *)cbc_data)+1,ks,
|
||||
(C_Block *)iv3,
|
||||
(C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_ENCRYPT);
|
||||
des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
|
||||
&iv3,&cbc2_key,&cbc3_key, DES_ENCRYPT);
|
||||
if (memcmp(cbc_out,xcbc_ok,32) != 0)
|
||||
{
|
||||
printf("des_xcbc_encrypt encrypt error\n");
|
||||
}
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
des_xcbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in,
|
||||
(long)strlen((char *)cbc_data)+1,ks,
|
||||
(C_Block *)iv3,
|
||||
(C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,32) != 0)
|
||||
des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
|
||||
&iv3,&cbc2_key,&cbc3_key, DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
|
||||
{
|
||||
printf("des_xcbc_encrypt decrypt error\n");
|
||||
err=1;
|
||||
@ -453,17 +502,17 @@ char *argv[];
|
||||
#endif
|
||||
|
||||
printf("Doing ede cbc\n");
|
||||
if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
|
||||
if ((j=des_key_sched(&cbc_key,ks)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
}
|
||||
if ((j=des_key_sched((C_Block *)cbc2_key,ks2)) != 0)
|
||||
if ((j=des_key_sched(&cbc2_key,ks2)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
}
|
||||
if ((j=des_key_sched((C_Block *)cbc3_key,ks3)) != 0)
|
||||
if ((j=des_key_sched(&cbc3_key,ks3)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
@ -471,14 +520,12 @@ char *argv[];
|
||||
memset(cbc_out,0,40);
|
||||
memset(cbc_in,0,40);
|
||||
i=strlen((char *)cbc_data)+1;
|
||||
i=((i+7)/8)*8;
|
||||
/* i=((i+7)/8)*8; */
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
|
||||
des_ede3_cbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
|
||||
16L,ks,ks2,ks3,(C_Block *)iv3,DES_ENCRYPT);
|
||||
des_ede3_cbc_encrypt((C_Block *)&(cbc_data[16]),
|
||||
(C_Block *)&(cbc_out[16]),
|
||||
(long)i-16,ks,ks2,ks3,(C_Block *)iv3,DES_ENCRYPT);
|
||||
des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,DES_ENCRYPT);
|
||||
des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3,
|
||||
&iv3,DES_ENCRYPT);
|
||||
if (memcmp(cbc_out,cbc3_ok,
|
||||
(unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
|
||||
{
|
||||
@ -487,9 +534,8 @@ char *argv[];
|
||||
}
|
||||
|
||||
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
|
||||
des_ede3_cbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in,
|
||||
(long)i,ks,ks2,ks3,(C_Block *)iv3,DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,strlen(cbc_data)+1) != 0)
|
||||
des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
|
||||
{
|
||||
printf("des_ede3_cbc_encrypt decrypt error\n");
|
||||
err=1;
|
||||
@ -497,23 +543,23 @@ char *argv[];
|
||||
|
||||
#ifndef LIBDES_LIT
|
||||
printf("Doing pcbc\n");
|
||||
if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
|
||||
if ((j=des_key_sched(&cbc_key,ks)) != 0)
|
||||
{
|
||||
printf("Key error %d\n",j);
|
||||
err=1;
|
||||
}
|
||||
memset(cbc_out,0,40);
|
||||
memset(cbc_in,0,40);
|
||||
des_pcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
|
||||
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_ENCRYPT);
|
||||
des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
|
||||
&cbc_iv,DES_ENCRYPT);
|
||||
if (memcmp(cbc_out,pcbc_ok,32) != 0)
|
||||
{
|
||||
printf("pcbc_encrypt encrypt error\n");
|
||||
err=1;
|
||||
}
|
||||
des_pcbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in,
|
||||
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,32) != 0)
|
||||
des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,&cbc_iv,
|
||||
DES_DECRYPT);
|
||||
if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
|
||||
{
|
||||
printf("pcbc_encrypt decrypt error\n");
|
||||
err=1;
|
||||
@ -537,7 +583,7 @@ char *argv[];
|
||||
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
|
||||
for (i=0; i<sizeof(plain); i++)
|
||||
des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]),
|
||||
8,(long)1,ks,(C_Block *)cfb_tmp,DES_ENCRYPT);
|
||||
8,1,ks,&cfb_tmp,DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0)
|
||||
{
|
||||
printf("cfb_encrypt small encrypt error\n");
|
||||
@ -547,7 +593,7 @@ char *argv[];
|
||||
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
|
||||
for (i=0; i<sizeof(plain); i++)
|
||||
des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]),
|
||||
8,(long)1,ks,(C_Block *)cfb_tmp,DES_DECRYPT);
|
||||
8,1,ks,&cfb_tmp,DES_DECRYPT);
|
||||
if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
|
||||
{
|
||||
printf("cfb_encrypt small decrypt error\n");
|
||||
@ -560,34 +606,44 @@ char *argv[];
|
||||
printf("done\n");
|
||||
|
||||
printf("Doing ofb\n");
|
||||
des_key_sched((C_Block *)ofb_key,ks);
|
||||
des_key_sched(&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);
|
||||
des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
|
||||
if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
|
||||
{
|
||||
printf("ofb_encrypt encrypt error\n");
|
||||
printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
|
||||
ofb_buf1[8+0], ofb_buf1[8+1], ofb_buf1[8+2], ofb_buf1[8+3],
|
||||
ofb_buf1[8+4], ofb_buf1[8+5], ofb_buf1[8+6], ofb_buf1[8+7]);
|
||||
printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
|
||||
ofb_buf1[8+0], ofb_cipher[8+1], ofb_cipher[8+2], ofb_cipher[8+3],
|
||||
ofb_buf1[8+4], ofb_cipher[8+5], ofb_cipher[8+6], ofb_cipher[8+7]);
|
||||
err=1;
|
||||
}
|
||||
memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
|
||||
des_ofb_encrypt(ofb_buf1,ofb_buf2,64,(long)sizeof(ofb_buf1)/8,ks,
|
||||
(C_Block *)ofb_tmp);
|
||||
des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,&ofb_tmp);
|
||||
if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
|
||||
{
|
||||
printf("ofb_encrypt decrypt error\n");
|
||||
printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
|
||||
ofb_buf2[8+0], ofb_buf2[8+1], ofb_buf2[8+2], ofb_buf2[8+3],
|
||||
ofb_buf2[8+4], ofb_buf2[8+5], ofb_buf2[8+6], ofb_buf2[8+7]);
|
||||
printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
|
||||
plain[8+0], plain[8+1], plain[8+2], plain[8+3],
|
||||
plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
|
||||
err=1;
|
||||
}
|
||||
|
||||
printf("Doing ofb64\n");
|
||||
des_key_sched((C_Block *)ofb_key,ks);
|
||||
des_key_sched(&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));
|
||||
num=0;
|
||||
for (i=0; i<sizeof(plain); i++)
|
||||
{
|
||||
des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,
|
||||
(C_Block *)ofb_tmp,&num);
|
||||
des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,&ofb_tmp,
|
||||
&num);
|
||||
}
|
||||
if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
|
||||
{
|
||||
@ -596,8 +652,7 @@ char *argv[];
|
||||
}
|
||||
memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
|
||||
num=0;
|
||||
des_ofb64_encrypt(ofb_buf1,ofb_buf2,(long)sizeof(ofb_buf1),ks,
|
||||
(C_Block *)ofb_tmp,&num);
|
||||
des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,&num);
|
||||
if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
|
||||
{
|
||||
printf("ofb64_encrypt decrypt error\n");
|
||||
@ -605,7 +660,7 @@ char *argv[];
|
||||
}
|
||||
|
||||
printf("Doing ede_ofb64\n");
|
||||
des_key_sched((C_Block *)ofb_key,ks);
|
||||
des_key_sched(&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));
|
||||
@ -613,7 +668,7 @@ char *argv[];
|
||||
for (i=0; i<sizeof(plain); i++)
|
||||
{
|
||||
des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,ks,
|
||||
(C_Block *)ofb_tmp,&num);
|
||||
&ofb_tmp,&num);
|
||||
}
|
||||
if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
|
||||
{
|
||||
@ -622,8 +677,8 @@ char *argv[];
|
||||
}
|
||||
memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
|
||||
num=0;
|
||||
des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,(long)sizeof(ofb_buf1),ks,
|
||||
ks,ks,(C_Block *)ofb_tmp,&num);
|
||||
des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,
|
||||
ks,ks,&ofb_tmp,&num);
|
||||
if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
|
||||
{
|
||||
printf("ede_ofb64_encrypt decrypt error\n");
|
||||
@ -631,9 +686,8 @@ char *argv[];
|
||||
}
|
||||
|
||||
printf("Doing cbc_cksum\n");
|
||||
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);
|
||||
des_key_sched(&cbc_key,ks);
|
||||
cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
|
||||
if (cs != cbc_cksum_ret)
|
||||
{
|
||||
printf("bad return value (%08lX), should be %08lX\n",
|
||||
@ -647,82 +701,84 @@ char *argv[];
|
||||
}
|
||||
|
||||
printf("Doing quad_cksum\n");
|
||||
cs=quad_cksum((C_Block *)cbc_data,(C_Block *)lqret,
|
||||
(long)strlen(cbc_data),2,(C_Block *)cbc_iv);
|
||||
/* This is obviously done this way especially to puzzle me. Although
|
||||
quad_cksum returns up to 4 groups of 8 bytes, this test gets it to
|
||||
produce 2 groups then treats them as 4 groups of 4 bytes.
|
||||
Ben 13 Feb 1999 */
|
||||
cs=quad_cksum(cbc_data,(des_cblock *)qret,strlen((char *)cbc_data),2,
|
||||
&cbc_iv);
|
||||
|
||||
{ /* Big-endian fix */
|
||||
static DES_LONG l=1;
|
||||
static unsigned char *c=(unsigned char *)&l;
|
||||
DES_LONG ll;
|
||||
|
||||
j=sizeof(lqret[0])-4;
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
lqret[i]=0;
|
||||
memcpy(&(lqret[i]),&(qret[i][0]),4);
|
||||
if (!c[0] && (j > 0))
|
||||
lqret[i]=lqret[i]>>(j*8); /* For Cray */
|
||||
}
|
||||
|
||||
if (!c[0])
|
||||
{
|
||||
ll=lqret[0]^lqret[3];
|
||||
lqret[0]^=ll;
|
||||
lqret[3]^=ll;
|
||||
ll=lqret[1]^lqret[2];
|
||||
lqret[1]^=ll;
|
||||
lqret[2]^=ll;
|
||||
}
|
||||
}
|
||||
if (cs != 0x70d7a63aL)
|
||||
{
|
||||
printf("quad_cksum error, ret %08lx should be 70d7a63a\n",
|
||||
(unsigned long)cs);
|
||||
err=1;
|
||||
}
|
||||
#ifdef _CRAY
|
||||
if (lqret[0].a != 0x327eba8dL)
|
||||
{
|
||||
printf("quad_cksum error, out[0] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[0].a,0x327eba8dL);
|
||||
err=1;
|
||||
}
|
||||
if (lqret[0].b != 0x201a49ccL)
|
||||
{
|
||||
printf("quad_cksum error, out[1] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[0].b,0x201a49ccL);
|
||||
err=1;
|
||||
}
|
||||
if (lqret[1].a != 0x70d7a63aL)
|
||||
{
|
||||
printf("quad_cksum error, out[2] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[1].a,0x70d7a63aL);
|
||||
err=1;
|
||||
}
|
||||
if (lqret[1].b != 0x501c2c26L)
|
||||
{
|
||||
printf("quad_cksum error, out[3] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[1].b,0x501c2c26L);
|
||||
err=1;
|
||||
}
|
||||
#else
|
||||
if (lqret[0] != 0x327eba8dL)
|
||||
{
|
||||
printf("quad_cksum error, out[0] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[0],0x327eba8dL);
|
||||
(unsigned long)lqret[0],0x327eba8dUL);
|
||||
err=1;
|
||||
}
|
||||
if (lqret[1] != 0x201a49ccL)
|
||||
{
|
||||
printf("quad_cksum error, out[1] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[1],0x201a49ccL);
|
||||
(unsigned long)lqret[1],0x201a49ccUL);
|
||||
err=1;
|
||||
}
|
||||
if (lqret[2] != 0x70d7a63aL)
|
||||
{
|
||||
printf("quad_cksum error, out[2] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[2],0x70d7a63aL);
|
||||
(unsigned long)lqret[2],0x70d7a63aUL);
|
||||
err=1;
|
||||
}
|
||||
if (lqret[3] != 0x501c2c26L)
|
||||
{
|
||||
printf("quad_cksum error, out[3] %08lx is not %08lx\n",
|
||||
(unsigned long)lqret[3],0x501c2c26L);
|
||||
(unsigned long)lqret[3],0x501c2c26UL);
|
||||
err=1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
printf("input word alignment test");
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
printf(" %d",i);
|
||||
des_cbc_encrypt((C_Block *)&(cbc_out[i]),(C_Block *)cbc_in,
|
||||
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,
|
||||
DES_ENCRYPT);
|
||||
des_ncbc_encrypt(&(cbc_out[i]),cbc_in,
|
||||
strlen((char *)cbc_data)+1,ks,
|
||||
&cbc_iv,DES_ENCRYPT);
|
||||
}
|
||||
printf("\noutput word alignment test");
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
printf(" %d",i);
|
||||
des_cbc_encrypt((C_Block *)cbc_out,(C_Block *)&(cbc_in[i]),
|
||||
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,
|
||||
DES_ENCRYPT);
|
||||
des_ncbc_encrypt(cbc_out,&(cbc_in[i]),
|
||||
strlen((char *)cbc_data)+1,ks,
|
||||
&cbc_iv,DES_ENCRYPT);
|
||||
}
|
||||
printf("\n");
|
||||
printf("fast crypt test ");
|
||||
@ -743,8 +799,7 @@ char *argv[];
|
||||
return(0);
|
||||
}
|
||||
|
||||
static char *pt(p)
|
||||
unsigned char *p;
|
||||
static char *pt(unsigned char *p)
|
||||
{
|
||||
static char bufs[10][20];
|
||||
static int bnum=0;
|
||||
@ -765,17 +820,15 @@ unsigned char *p;
|
||||
|
||||
#ifndef LIBDES_LIT
|
||||
|
||||
static int cfb_test(bits, cfb_cipher)
|
||||
int bits;
|
||||
unsigned char *cfb_cipher;
|
||||
static int cfb_test(int bits, unsigned char *cfb_cipher)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
int i,err=0;
|
||||
|
||||
des_key_sched((C_Block *)cfb_key,ks);
|
||||
des_key_sched(&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);
|
||||
des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
|
||||
DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
|
||||
{
|
||||
err=1;
|
||||
@ -784,8 +837,8 @@ unsigned char *cfb_cipher;
|
||||
printf("%s\n",pt(&(cfb_buf1[i])));
|
||||
}
|
||||
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
|
||||
des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,(long)sizeof(plain),ks,
|
||||
(C_Block *)cfb_tmp,DES_DECRYPT);
|
||||
des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,&cfb_tmp,
|
||||
DES_DECRYPT);
|
||||
if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
|
||||
{
|
||||
err=1;
|
||||
@ -796,20 +849,17 @@ unsigned char *cfb_cipher;
|
||||
return(err);
|
||||
}
|
||||
|
||||
static int cfb64_test(cfb_cipher)
|
||||
unsigned char *cfb_cipher;
|
||||
static int cfb64_test(unsigned char *cfb_cipher)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
int err=0,i,n;
|
||||
|
||||
des_key_sched((C_Block *)cfb_key,ks);
|
||||
des_key_sched(&cfb_key,ks);
|
||||
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
|
||||
n=0;
|
||||
des_cfb64_encrypt(plain,cfb_buf1,(long)12,ks,
|
||||
(C_Block *)cfb_tmp,&n,DES_ENCRYPT);
|
||||
des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
|
||||
(long)sizeof(plain)-12,ks,
|
||||
(C_Block *)cfb_tmp,&n,DES_ENCRYPT);
|
||||
des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
|
||||
des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks,
|
||||
&cfb_tmp,&n,DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
|
||||
{
|
||||
err=1;
|
||||
@ -819,11 +869,9 @@ unsigned char *cfb_cipher;
|
||||
}
|
||||
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
|
||||
n=0;
|
||||
des_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,
|
||||
(C_Block *)cfb_tmp,&n,DES_DECRYPT);
|
||||
des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT);
|
||||
des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
|
||||
(long)sizeof(plain)-17,ks,
|
||||
(C_Block *)cfb_tmp,&n,DES_DECRYPT);
|
||||
sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT);
|
||||
if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
|
||||
{
|
||||
err=1;
|
||||
@ -834,20 +882,19 @@ unsigned char *cfb_cipher;
|
||||
return(err);
|
||||
}
|
||||
|
||||
static int ede_cfb64_test(cfb_cipher)
|
||||
unsigned char *cfb_cipher;
|
||||
static int ede_cfb64_test(unsigned char *cfb_cipher)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
int err=0,i,n;
|
||||
|
||||
des_key_sched((C_Block *)cfb_key,ks);
|
||||
des_key_sched(&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,
|
||||
(C_Block *)cfb_tmp,&n,DES_ENCRYPT);
|
||||
des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
|
||||
DES_ENCRYPT);
|
||||
des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
|
||||
(long)sizeof(plain)-12,ks,ks,ks,
|
||||
(C_Block *)cfb_tmp,&n,DES_ENCRYPT);
|
||||
sizeof(plain)-12,ks,ks,ks,
|
||||
&cfb_tmp,&n,DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
|
||||
{
|
||||
err=1;
|
||||
@ -858,10 +905,10 @@ unsigned char *cfb_cipher;
|
||||
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
|
||||
n=0;
|
||||
des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks,
|
||||
(C_Block *)cfb_tmp,&n,DES_DECRYPT);
|
||||
&cfb_tmp,&n,DES_DECRYPT);
|
||||
des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
|
||||
(long)sizeof(plain)-17,ks,ks,ks,
|
||||
(C_Block *)cfb_tmp,&n,DES_DECRYPT);
|
||||
sizeof(plain)-17,ks,ks,ks,
|
||||
&cfb_tmp,&n,DES_DECRYPT);
|
||||
if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
|
||||
{
|
||||
err=1;
|
||||
@ -873,4 +920,4 @@ unsigned char *cfb_cipher;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/ecb3_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,25 +58,20 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
void des_ecb3_encrypt(input, output, ks1, ks2, ks3, encrypt)
|
||||
des_cblock (*input);
|
||||
des_cblock (*output);
|
||||
des_key_schedule ks1;
|
||||
des_key_schedule ks2;
|
||||
des_key_schedule ks3;
|
||||
int encrypt;
|
||||
void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
|
||||
des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3,
|
||||
int enc)
|
||||
{
|
||||
register DES_LONG l0,l1;
|
||||
register unsigned char *in,*out;
|
||||
DES_LONG ll[2];
|
||||
const unsigned char *in = &(*input)[0];
|
||||
unsigned char *out = &(*output)[0];
|
||||
|
||||
in=(unsigned char *)input;
|
||||
out=(unsigned char *)output;
|
||||
c2l(in,l0);
|
||||
c2l(in,l1);
|
||||
ll[0]=l0;
|
||||
ll[1]=l1;
|
||||
if (encrypt)
|
||||
if (enc)
|
||||
des_encrypt3(ll,ks1,ks2,ks3);
|
||||
else
|
||||
des_decrypt3(ll,ks1,ks2,ks3);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/ecb_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,20 +58,20 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
#include "spr.h"
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
char *libdes_version="libdes v 4.01 - 13-Jan-1997 - eay";
|
||||
char *DES_version="DES part of SSLeay 0.6.6 14-Jan-1997";
|
||||
OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT;
|
||||
OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
char *des_options()
|
||||
const char *des_options(void)
|
||||
{
|
||||
static int init=1;
|
||||
static char buf[32];
|
||||
|
||||
if (init)
|
||||
{
|
||||
char *ptr,*unroll,*risc,*size;
|
||||
const char *ptr,*unroll,*risc,*size;
|
||||
|
||||
init=0;
|
||||
#ifdef DES_PTR
|
||||
ptr="ptr";
|
||||
#else
|
||||
@ -97,26 +97,24 @@ char *des_options()
|
||||
else
|
||||
size="long";
|
||||
sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size);
|
||||
init=0;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
|
||||
|
||||
void des_ecb_encrypt(input, output, ks, encrypt)
|
||||
des_cblock (*input);
|
||||
des_cblock (*output);
|
||||
des_key_schedule ks;
|
||||
int encrypt;
|
||||
void des_ecb_encrypt(const_des_cblock *input, des_cblock *output,
|
||||
des_key_schedule ks,
|
||||
int enc)
|
||||
{
|
||||
register DES_LONG l;
|
||||
register unsigned char *in,*out;
|
||||
DES_LONG ll[2];
|
||||
const unsigned char *in = &(*input)[0];
|
||||
unsigned char *out = &(*output)[0];
|
||||
|
||||
in=(unsigned char *)input;
|
||||
out=(unsigned char *)output;
|
||||
c2l(in,l); ll[0]=l;
|
||||
c2l(in,l); ll[1]=l;
|
||||
des_encrypt(ll,ks,encrypt);
|
||||
des_encrypt(ll,ks,enc);
|
||||
l=ll[0]; l2c(l,out);
|
||||
l=ll[1]; l2c(l,out);
|
||||
l=ll[0]=ll[1]=0;
|
||||
|
197
crypto/libdes/ede_cbcm_enc.c
Normal file
197
crypto/libdes/ede_cbcm_enc.c
Normal file
@ -0,0 +1,197 @@
|
||||
/* ede_cbcm_enc.c */
|
||||
/* Written by Ben Laurie <ben@algroup.co.uk> for the OpenSSL
|
||||
* project 13 Feb 1999.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* 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 above 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 acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This is an implementation of Triple DES Cipher Block Chaining with Output
|
||||
Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom).
|
||||
|
||||
Note that there is a known attack on this by Biham and Knudsen but it takes
|
||||
a lot of work:
|
||||
|
||||
http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NO_DESCBCM
|
||||
#include "des_locl.h"
|
||||
|
||||
void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2,
|
||||
int enc)
|
||||
{
|
||||
register DES_LONG tin0,tin1;
|
||||
register DES_LONG tout0,tout1,xor0,xor1,m0,m1;
|
||||
register long l=length;
|
||||
DES_LONG tin[2];
|
||||
unsigned char *iv1,*iv2;
|
||||
|
||||
iv1 = &(*ivec1)[0];
|
||||
iv2 = &(*ivec2)[0];
|
||||
|
||||
if (enc)
|
||||
{
|
||||
c2l(iv1,m0);
|
||||
c2l(iv1,m1);
|
||||
c2l(iv2,tout0);
|
||||
c2l(iv2,tout1);
|
||||
for (l-=8; l>=-7; l-=8)
|
||||
{
|
||||
tin[0]=m0;
|
||||
tin[1]=m1;
|
||||
des_encrypt(tin,ks3,1);
|
||||
m0=tin[0];
|
||||
m1=tin[1];
|
||||
|
||||
if(l < 0)
|
||||
{
|
||||
c2ln(in,tin0,tin1,l+8);
|
||||
}
|
||||
else
|
||||
{
|
||||
c2l(in,tin0);
|
||||
c2l(in,tin1);
|
||||
}
|
||||
tin0^=tout0;
|
||||
tin1^=tout1;
|
||||
|
||||
tin[0]=tin0;
|
||||
tin[1]=tin1;
|
||||
des_encrypt(tin,ks1,1);
|
||||
tin[0]^=m0;
|
||||
tin[1]^=m1;
|
||||
des_encrypt(tin,ks2,0);
|
||||
tin[0]^=m0;
|
||||
tin[1]^=m1;
|
||||
des_encrypt(tin,ks1,1);
|
||||
tout0=tin[0];
|
||||
tout1=tin[1];
|
||||
|
||||
l2c(tout0,out);
|
||||
l2c(tout1,out);
|
||||
}
|
||||
iv1=&(*ivec1)[0];
|
||||
l2c(m0,iv1);
|
||||
l2c(m1,iv1);
|
||||
|
||||
iv2=&(*ivec2)[0];
|
||||
l2c(tout0,iv2);
|
||||
l2c(tout1,iv2);
|
||||
}
|
||||
else
|
||||
{
|
||||
register DES_LONG t0,t1;
|
||||
|
||||
c2l(iv1,m0);
|
||||
c2l(iv1,m1);
|
||||
c2l(iv2,xor0);
|
||||
c2l(iv2,xor1);
|
||||
for (l-=8; l>=-7; l-=8)
|
||||
{
|
||||
tin[0]=m0;
|
||||
tin[1]=m1;
|
||||
des_encrypt(tin,ks3,1);
|
||||
m0=tin[0];
|
||||
m1=tin[1];
|
||||
|
||||
c2l(in,tin0);
|
||||
c2l(in,tin1);
|
||||
|
||||
t0=tin0;
|
||||
t1=tin1;
|
||||
|
||||
tin[0]=tin0;
|
||||
tin[1]=tin1;
|
||||
des_encrypt(tin,ks1,0);
|
||||
tin[0]^=m0;
|
||||
tin[1]^=m1;
|
||||
des_encrypt(tin,ks2,1);
|
||||
tin[0]^=m0;
|
||||
tin[1]^=m1;
|
||||
des_encrypt(tin,ks1,0);
|
||||
tout0=tin[0];
|
||||
tout1=tin[1];
|
||||
|
||||
tout0^=xor0;
|
||||
tout1^=xor1;
|
||||
if(l < 0)
|
||||
{
|
||||
l2cn(tout0,tout1,out,l+8);
|
||||
}
|
||||
else
|
||||
{
|
||||
l2c(tout0,out);
|
||||
l2c(tout1,out);
|
||||
}
|
||||
xor0=t0;
|
||||
xor1=t1;
|
||||
}
|
||||
|
||||
iv1=&(*ivec1)[0];
|
||||
l2c(m0,iv1);
|
||||
l2c(m1,iv1);
|
||||
|
||||
iv2=&(*ivec2)[0];
|
||||
l2c(xor0,iv2);
|
||||
l2c(xor1,iv2);
|
||||
}
|
||||
tin0=tin1=tout0=tout1=xor0=xor1=0;
|
||||
tin[0]=tin[1]=0;
|
||||
}
|
||||
#endif
|
@ -1,68 +1,18 @@
|
||||
/* crypto/des/fcrypt.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library 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 cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@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.]
|
||||
*/
|
||||
|
||||
/* NOCW */
|
||||
#include <stdio.h>
|
||||
#ifdef _OSD_POSIX
|
||||
#ifndef CHARSET_EBCDIC
|
||||
#define CHARSET_EBCDIC 1
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CHARSET_EBCDIC
|
||||
#include <openssl/ebcdic.h>
|
||||
#endif
|
||||
|
||||
/* Eric Young.
|
||||
* This version of crypt has been developed from my MIT compatable
|
||||
/* This version of crypt has been developed from my MIT compatable
|
||||
* DES library.
|
||||
* The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
|
||||
* eay@mincom.oz.au or eay@psych.psy.uq.oz.au
|
||||
* Eric Young (eay@cryptsoft.com)
|
||||
*/
|
||||
|
||||
/* Modification by Jens Kupferschmidt (Cu)
|
||||
@ -73,193 +23,7 @@
|
||||
* defined 24.
|
||||
*/
|
||||
|
||||
#define FCRYPT_MOD(R,u,t,E0,E1,tmp) \
|
||||
u=R>>16; \
|
||||
t=R^u; \
|
||||
u=t&E0; t=t&E1; \
|
||||
tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
|
||||
tmp=(t<<16); t^=R^s[S+1]; t^=tmp
|
||||
|
||||
#define DES_FCRYPT
|
||||
#include "des_locl.h"
|
||||
#undef DES_FCRYPT
|
||||
|
||||
#undef PERM_OP
|
||||
#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
|
||||
(b)^=(t),\
|
||||
(a)^=((t)<<(n)))
|
||||
|
||||
#undef HPERM_OP
|
||||
#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
|
||||
(a)=(a)^(t)^(t>>(16-(n))))\
|
||||
|
||||
#ifdef PARA
|
||||
#define STATIC
|
||||
#else
|
||||
#define STATIC static
|
||||
#endif
|
||||
|
||||
/* It is really only FreeBSD that still suffers from MD5 based crypts */
|
||||
#ifdef __FreeBSD__
|
||||
#define MD5_CRYPT_SUPPORT 1
|
||||
#endif
|
||||
#if MD5_CRYPT_SUPPORT
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <md5.h>
|
||||
|
||||
static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
|
||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
static void
|
||||
to64(s, v, n)
|
||||
char *s;
|
||||
unsigned long v;
|
||||
int n;
|
||||
{
|
||||
while (--n >= 0) {
|
||||
*s++ = itoa64[v&0x3f];
|
||||
v >>= 6;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* UNIX password
|
||||
*
|
||||
* Use MD5 for what it is best at...
|
||||
*/
|
||||
|
||||
static
|
||||
char *
|
||||
crypt_md5(pw, salt)
|
||||
register const char *pw;
|
||||
register const char *salt;
|
||||
{
|
||||
static char *magic = "$1$"; /*
|
||||
* This string is magic for
|
||||
* this algorithm. Having
|
||||
* it this way, we can get
|
||||
* get better later on
|
||||
*/
|
||||
static char passwd[120], *p;
|
||||
static const char *sp,*ep;
|
||||
unsigned char final[16];
|
||||
int sl,pl,i,j;
|
||||
MD5_CTX ctx,ctx1;
|
||||
unsigned long l;
|
||||
|
||||
/* Refine the Salt first */
|
||||
sp = salt;
|
||||
|
||||
/* If it starts with the magic string, then skip that */
|
||||
if(!strncmp(sp,magic,strlen(magic)))
|
||||
sp += strlen(magic);
|
||||
|
||||
/* It stops at the first '$', max 8 chars */
|
||||
for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
|
||||
continue;
|
||||
|
||||
/* get the length of the true salt */
|
||||
sl = ep - sp;
|
||||
|
||||
MD5Init(&ctx);
|
||||
|
||||
/* The password first, since that is what is most unknown */
|
||||
MD5Update(&ctx,pw,strlen(pw));
|
||||
|
||||
/* Then our magic string */
|
||||
MD5Update(&ctx,magic,strlen(magic));
|
||||
|
||||
/* Then the raw salt */
|
||||
MD5Update(&ctx,sp,sl);
|
||||
|
||||
/* Then just as many characters of the MD5(pw,salt,pw) */
|
||||
MD5Init(&ctx1);
|
||||
MD5Update(&ctx1,pw,strlen(pw));
|
||||
MD5Update(&ctx1,sp,sl);
|
||||
MD5Update(&ctx1,pw,strlen(pw));
|
||||
MD5Final(final,&ctx1);
|
||||
for(pl = strlen(pw); pl > 0; pl -= 16)
|
||||
MD5Update(&ctx,final,pl>16 ? 16 : pl);
|
||||
|
||||
/* Don't leave anything around in vm they could use. */
|
||||
memset(final,0,sizeof final);
|
||||
|
||||
/* Then something really weird... */
|
||||
for (j=0,i = strlen(pw); i ; i >>= 1)
|
||||
if(i&1)
|
||||
MD5Update(&ctx, final+j, 1);
|
||||
else
|
||||
MD5Update(&ctx, pw+j, 1);
|
||||
|
||||
/* Now make the output string */
|
||||
snprintf (passwd, sizeof(passwd),
|
||||
"%s%.*s$", magic, sl, sp);
|
||||
|
||||
MD5Final(final,&ctx);
|
||||
|
||||
/*
|
||||
* and now, just to make sure things don't run too fast
|
||||
* On a 60 Mhz Pentium this takes 34 msec, so you would
|
||||
* need 30 seconds to build a 1000 entry dictionary...
|
||||
*/
|
||||
for(i=0;i<1000;i++) {
|
||||
MD5Init(&ctx1);
|
||||
if(i & 1)
|
||||
MD5Update(&ctx1,pw,strlen(pw));
|
||||
else
|
||||
MD5Update(&ctx1,final,16);
|
||||
|
||||
if(i % 3)
|
||||
MD5Update(&ctx1,sp,sl);
|
||||
|
||||
if(i % 7)
|
||||
MD5Update(&ctx1,pw,strlen(pw));
|
||||
|
||||
if(i & 1)
|
||||
MD5Update(&ctx1,final,16);
|
||||
else
|
||||
MD5Update(&ctx1,pw,strlen(pw));
|
||||
MD5Final(final,&ctx1);
|
||||
}
|
||||
|
||||
p = passwd + strlen(passwd);
|
||||
|
||||
l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p,l,4); p += 4;
|
||||
l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p,l,4); p += 4;
|
||||
l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p,l,4); p += 4;
|
||||
l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p,l,4); p += 4;
|
||||
l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p,l,4); p += 4;
|
||||
l = final[11] ; to64(p,l,2); p += 2;
|
||||
*p = '\0';
|
||||
|
||||
/* Don't leave anything around in vm they could use. */
|
||||
memset(final,0,sizeof final);
|
||||
|
||||
return passwd;
|
||||
}
|
||||
#endif /* MD5_CRYPT_SUPPORT */
|
||||
|
||||
#ifndef NOPROTO
|
||||
|
||||
STATIC int fcrypt_body(DES_LONG *out0, DES_LONG *out1,
|
||||
des_key_schedule ks, DES_LONG Eswap0, DES_LONG Eswap1);
|
||||
|
||||
#else
|
||||
|
||||
STATIC int fcrypt_body();
|
||||
|
||||
#endif
|
||||
|
||||
/* Added more values to handle illegal salt values the way normal
|
||||
* crypt() implementations do. The patch was sent by
|
||||
@ -295,43 +59,55 @@ static unsigned const char cov_2char[64]={
|
||||
0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A
|
||||
};
|
||||
|
||||
#ifndef NOPROTO
|
||||
#ifdef PERL5
|
||||
char *des_crypt(const char *buf,const char *salt);
|
||||
#else
|
||||
char *crypt(const char *buf,const char *salt);
|
||||
#endif
|
||||
#else
|
||||
#ifdef PERL5
|
||||
char *des_crypt();
|
||||
#else
|
||||
char *crypt();
|
||||
#endif
|
||||
void fcrypt_body(DES_LONG *out,des_key_schedule ks,
|
||||
DES_LONG Eswap0, DES_LONG Eswap1);
|
||||
|
||||
#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT)
|
||||
char *crypt(const char *buf, const char *salt)
|
||||
{
|
||||
return(des_crypt(buf, salt));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PERL5
|
||||
char *des_crypt(buf,salt)
|
||||
#else
|
||||
char *crypt(buf,salt)
|
||||
#endif
|
||||
const char *buf;
|
||||
const char *salt;
|
||||
char *des_crypt(const char *buf, const char *salt)
|
||||
{
|
||||
static char buff[14];
|
||||
|
||||
#if MD5_CRYPT_SUPPORT
|
||||
if (!strncmp(salt, "$1$", 3))
|
||||
return crypt_md5(buf, salt);
|
||||
#endif
|
||||
|
||||
#ifndef CHARSET_EBCDIC
|
||||
return(des_fcrypt(buf,salt,buff));
|
||||
#else
|
||||
char e_salt[2+1];
|
||||
char e_buf[32+1]; /* replace 32 by 8 ? */
|
||||
char *ret;
|
||||
|
||||
/* Copy at most 2 chars of salt */
|
||||
if ((e_salt[0] = salt[0]) != '\0')
|
||||
e_salt[1] = salt[1];
|
||||
|
||||
/* Copy at most 32 chars of password */
|
||||
strncpy (e_buf, buf, sizeof(e_buf));
|
||||
|
||||
/* Make sure we have a delimiter */
|
||||
e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0';
|
||||
|
||||
/* Convert the e_salt to ASCII, as that's what des_fcrypt works on */
|
||||
ebcdic2ascii(e_salt, e_salt, sizeof e_salt);
|
||||
|
||||
/* Convert the cleartext password to ASCII */
|
||||
ebcdic2ascii(e_buf, e_buf, sizeof e_buf);
|
||||
|
||||
/* Encrypt it (from/to ASCII) */
|
||||
ret = des_fcrypt(e_buf,e_salt,buff);
|
||||
|
||||
/* Convert the result back to EBCDIC */
|
||||
ascii2ebcdic(ret, ret, strlen(ret));
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
char *des_fcrypt(buf,salt,ret)
|
||||
const char *buf;
|
||||
const char *salt;
|
||||
char *ret;
|
||||
char *des_fcrypt(const char *buf, const char *salt, char *ret)
|
||||
{
|
||||
unsigned int i,j,x,y;
|
||||
DES_LONG Eswap0,Eswap1;
|
||||
@ -350,10 +126,17 @@ char *ret;
|
||||
* crypt to "*". This was found when replacing the crypt in
|
||||
* our shared libraries. People found that the disbled
|
||||
* accounts effectivly had no passwd :-(. */
|
||||
#ifndef CHARSET_EBCDIC
|
||||
x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
|
||||
Eswap0=con_salt[x]<<2;
|
||||
x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
|
||||
Eswap1=con_salt[x]<<6;
|
||||
#else
|
||||
x=ret[0]=((salt[0] == '\0')?os_toascii['A']:salt[0]);
|
||||
Eswap0=con_salt[x]<<2;
|
||||
x=ret[1]=((salt[1] == '\0')?os_toascii['A']:salt[1]);
|
||||
Eswap1=con_salt[x]<<6;
|
||||
#endif
|
||||
|
||||
/* EAY
|
||||
r=strlen(buf);
|
||||
@ -368,8 +151,8 @@ r=(r+7)/8;
|
||||
for (; i<8; i++)
|
||||
key[i]=0;
|
||||
|
||||
des_set_key((des_cblock *)(key),ks);
|
||||
fcrypt_body(&(out[0]),&(out[1]),ks,Eswap0,Eswap1);
|
||||
des_set_key(&key,ks);
|
||||
fcrypt_body(&(out[0]),ks,Eswap0,Eswap1);
|
||||
|
||||
ll=out[0]; l2c(ll,b);
|
||||
ll=out[1]; l2c(ll,b);
|
||||
@ -396,73 +179,3 @@ r=(r+7)/8;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
STATIC int fcrypt_body(out0, out1, ks, Eswap0, Eswap1)
|
||||
DES_LONG *out0;
|
||||
DES_LONG *out1;
|
||||
des_key_schedule ks;
|
||||
DES_LONG Eswap0;
|
||||
DES_LONG Eswap1;
|
||||
{
|
||||
register DES_LONG l,r,t,u;
|
||||
#ifdef DES_PTR
|
||||
register unsigned char *des_SP=(unsigned char *)des_SPtrans;
|
||||
#endif
|
||||
register DES_LONG *s;
|
||||
register int j;
|
||||
register DES_LONG E0,E1;
|
||||
|
||||
l=0;
|
||||
r=0;
|
||||
|
||||
s=(DES_LONG *)ks;
|
||||
E0=Eswap0;
|
||||
E1=Eswap1;
|
||||
|
||||
for (j=0; j<25; j++)
|
||||
{
|
||||
#ifdef DES_UNROLL
|
||||
register int i;
|
||||
|
||||
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
|
||||
D_ENCRYPT(l,r, 0); /* 1 */
|
||||
D_ENCRYPT(r,l, 2); /* 2 */
|
||||
D_ENCRYPT(l,r, 4); /* 3 */
|
||||
D_ENCRYPT(r,l, 6); /* 4 */
|
||||
D_ENCRYPT(l,r, 8); /* 5 */
|
||||
D_ENCRYPT(r,l,10); /* 6 */
|
||||
D_ENCRYPT(l,r,12); /* 7 */
|
||||
D_ENCRYPT(r,l,14); /* 8 */
|
||||
D_ENCRYPT(l,r,16); /* 9 */
|
||||
D_ENCRYPT(r,l,18); /* 10 */
|
||||
D_ENCRYPT(l,r,20); /* 11 */
|
||||
D_ENCRYPT(r,l,22); /* 12 */
|
||||
D_ENCRYPT(l,r,24); /* 13 */
|
||||
D_ENCRYPT(r,l,26); /* 14 */
|
||||
D_ENCRYPT(l,r,28); /* 15 */
|
||||
D_ENCRYPT(r,l,30); /* 16 */
|
||||
#endif
|
||||
t=l;
|
||||
l=r;
|
||||
r=t;
|
||||
}
|
||||
l=ROTATE(l,3)&0xffffffffL;
|
||||
r=ROTATE(r,3)&0xffffffffL;
|
||||
|
||||
PERM_OP(l,r,t, 1,0x55555555L);
|
||||
PERM_OP(r,l,t, 8,0x00ff00ffL);
|
||||
PERM_OP(l,r,t, 2,0x33333333L);
|
||||
PERM_OP(r,l,t,16,0x0000ffffL);
|
||||
PERM_OP(l,r,t, 4,0x0f0f0f0fL);
|
||||
|
||||
*out0=r;
|
||||
*out1=l;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
145
crypto/libdes/fcrypt_b.c
Normal file
145
crypto/libdes/fcrypt_b.c
Normal file
@ -0,0 +1,145 @@
|
||||
/* crypto/des/fcrypt_b.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library 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 cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* 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.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* This version of crypt has been developed from my MIT compatable
|
||||
* DES library.
|
||||
* The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
|
||||
* Eric Young (eay@cryptsoft.com)
|
||||
*/
|
||||
|
||||
#define DES_FCRYPT
|
||||
#include "des_locl.h"
|
||||
#undef DES_FCRYPT
|
||||
|
||||
#undef PERM_OP
|
||||
#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
|
||||
(b)^=(t),\
|
||||
(a)^=((t)<<(n)))
|
||||
|
||||
#undef HPERM_OP
|
||||
#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
|
||||
(a)=(a)^(t)^(t>>(16-(n))))\
|
||||
|
||||
void fcrypt_body(DES_LONG *out, des_key_schedule ks, DES_LONG Eswap0,
|
||||
DES_LONG Eswap1)
|
||||
{
|
||||
register DES_LONG l,r,t,u;
|
||||
#ifdef DES_PTR
|
||||
register const unsigned char *des_SP=(const unsigned char *)des_SPtrans;
|
||||
#endif
|
||||
register DES_LONG *s;
|
||||
register int j;
|
||||
register DES_LONG E0,E1;
|
||||
|
||||
l=0;
|
||||
r=0;
|
||||
|
||||
s=(DES_LONG *)ks;
|
||||
E0=Eswap0;
|
||||
E1=Eswap1;
|
||||
|
||||
for (j=0; j<25; j++)
|
||||
{
|
||||
#ifdef DES_UNROLL
|
||||
register int i;
|
||||
|
||||
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); /* 1 */
|
||||
D_ENCRYPT(r,l,i+6); /* 2 */
|
||||
}
|
||||
#else
|
||||
D_ENCRYPT(l,r, 0); /* 1 */
|
||||
D_ENCRYPT(r,l, 2); /* 2 */
|
||||
D_ENCRYPT(l,r, 4); /* 3 */
|
||||
D_ENCRYPT(r,l, 6); /* 4 */
|
||||
D_ENCRYPT(l,r, 8); /* 5 */
|
||||
D_ENCRYPT(r,l,10); /* 6 */
|
||||
D_ENCRYPT(l,r,12); /* 7 */
|
||||
D_ENCRYPT(r,l,14); /* 8 */
|
||||
D_ENCRYPT(l,r,16); /* 9 */
|
||||
D_ENCRYPT(r,l,18); /* 10 */
|
||||
D_ENCRYPT(l,r,20); /* 11 */
|
||||
D_ENCRYPT(r,l,22); /* 12 */
|
||||
D_ENCRYPT(l,r,24); /* 13 */
|
||||
D_ENCRYPT(r,l,26); /* 14 */
|
||||
D_ENCRYPT(l,r,28); /* 15 */
|
||||
D_ENCRYPT(r,l,30); /* 16 */
|
||||
#endif
|
||||
|
||||
t=l;
|
||||
l=r;
|
||||
r=t;
|
||||
}
|
||||
l=ROTATE(l,3)&0xffffffffL;
|
||||
r=ROTATE(r,3)&0xffffffffL;
|
||||
|
||||
PERM_OP(l,r,t, 1,0x55555555L);
|
||||
PERM_OP(r,l,t, 8,0x00ff00ffL);
|
||||
PERM_OP(l,r,t, 2,0x33333333L);
|
||||
PERM_OP(r,l,t,16,0x0000ffffL);
|
||||
PERM_OP(l,r,t, 4,0x0f0f0f0fL);
|
||||
|
||||
out[0]=r;
|
||||
out[1]=l;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/ncbc_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,26 +58,23 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
void des_ncbc_encrypt(input, output, length, schedule, ivec, encrypt)
|
||||
des_cblock (*input);
|
||||
des_cblock (*output);
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
int encrypt;
|
||||
#ifdef CBC_ENC_C__DONT_UPDATE_IV
|
||||
void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int enc)
|
||||
#else
|
||||
void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int enc)
|
||||
#endif
|
||||
{
|
||||
register DES_LONG tin0,tin1;
|
||||
register DES_LONG tout0,tout1,xor0,xor1;
|
||||
register unsigned char *in,*out;
|
||||
register long l=length;
|
||||
DES_LONG tin[2];
|
||||
unsigned char *iv;
|
||||
|
||||
in=(unsigned char *)input;
|
||||
out=(unsigned char *)output;
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
|
||||
if (encrypt)
|
||||
if (enc)
|
||||
{
|
||||
c2l(iv,tout0);
|
||||
c2l(iv,tout1);
|
||||
@ -100,9 +97,11 @@ int encrypt;
|
||||
tout0=tin[0]; l2c(tout0,out);
|
||||
tout1=tin[1]; l2c(tout1,out);
|
||||
}
|
||||
iv=(unsigned char *)ivec;
|
||||
#ifndef CBC_ENC_C__DONT_UPDATE_IV
|
||||
iv = &(*ivec)[0];
|
||||
l2c(tout0,iv);
|
||||
l2c(tout1,iv);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -128,14 +127,17 @@ int encrypt;
|
||||
tout0=tin[0]^xor0;
|
||||
tout1=tin[1]^xor1;
|
||||
l2cn(tout0,tout1,out,l+8);
|
||||
#ifndef CBC_ENC_C__DONT_UPDATE_IV
|
||||
xor0=tin0;
|
||||
xor1=tin1;
|
||||
#endif
|
||||
}
|
||||
iv=(unsigned char *)ivec;
|
||||
#ifndef CBC_ENC_C__DONT_UPDATE_IV
|
||||
iv = &(*ivec)[0];
|
||||
l2c(xor0,iv);
|
||||
l2c(xor1,iv);
|
||||
#endif
|
||||
}
|
||||
tin0=tin1=tout0=tout1=xor0=xor1=0;
|
||||
tin[0]=tin[1]=0;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/ofb64ede.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -62,13 +62,10 @@
|
||||
* used. The extra state information to record how much of the
|
||||
* 64bit block we have used is contained in *num;
|
||||
*/
|
||||
void des_ede3_ofb64_encrypt(in, out, length, k1,k2,k3, ivec, num)
|
||||
register unsigned char *in;
|
||||
register unsigned char *out;
|
||||
long length;
|
||||
des_key_schedule k1,k2,k3;
|
||||
des_cblock (*ivec);
|
||||
int *num;
|
||||
void des_ede3_ofb64_encrypt(register const unsigned char *in,
|
||||
register unsigned char *out, long length, des_key_schedule k1,
|
||||
des_key_schedule k2, des_key_schedule k3, des_cblock *ivec,
|
||||
int *num)
|
||||
{
|
||||
register DES_LONG v0,v1;
|
||||
register int n= *num;
|
||||
@ -79,7 +76,7 @@ int *num;
|
||||
unsigned char *iv;
|
||||
int save=0;
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
c2l(iv,v0);
|
||||
c2l(iv,v1);
|
||||
ti[0]=v0;
|
||||
@ -91,9 +88,9 @@ int *num;
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
ti[0]=v0;
|
||||
ti[1]=v1;
|
||||
des_encrypt3((DES_LONG *)ti,k1,k2,k3);
|
||||
/* ti[0]=v0; */
|
||||
/* ti[1]=v1; */
|
||||
des_encrypt3(ti,k1,k2,k3);
|
||||
v0=ti[0];
|
||||
v1=ti[1];
|
||||
|
||||
@ -109,7 +106,7 @@ int *num;
|
||||
{
|
||||
/* v0=ti[0];
|
||||
v1=ti[1];*/
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
l2c(v0,iv);
|
||||
l2c(v1,iv);
|
||||
}
|
||||
@ -118,13 +115,9 @@ int *num;
|
||||
}
|
||||
|
||||
#ifdef undef /* MACRO */
|
||||
void des_ede2_ofb64_encrypt(in, out, length, k1,k2, ivec, num)
|
||||
register unsigned char *in;
|
||||
register unsigned char *out;
|
||||
long length;
|
||||
des_key_schedule k1,k2;
|
||||
des_cblock (*ivec);
|
||||
int *num;
|
||||
void des_ede2_ofb64_encrypt(register unsigned char *in,
|
||||
register unsigned char *out, long length, des_key_schedule k1,
|
||||
des_key_schedule k2, des_cblock (*ivec), int *num)
|
||||
{
|
||||
des_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/ofb64enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -62,37 +62,33 @@
|
||||
* used. The extra state information to record how much of the
|
||||
* 64bit block we have used is contained in *num;
|
||||
*/
|
||||
void des_ofb64_encrypt(in, out, length, schedule, ivec, num)
|
||||
register unsigned char *in;
|
||||
register unsigned char *out;
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
int *num;
|
||||
void des_ofb64_encrypt(register const unsigned char *in,
|
||||
register unsigned char *out, long length, des_key_schedule schedule,
|
||||
des_cblock *ivec, int *num)
|
||||
{
|
||||
register DES_LONG v0,v1,t;
|
||||
register int n= *num;
|
||||
register long l=length;
|
||||
des_cblock d;
|
||||
register char *dp;
|
||||
register unsigned char *dp;
|
||||
DES_LONG ti[2];
|
||||
unsigned char *iv;
|
||||
int save=0;
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
c2l(iv,v0);
|
||||
c2l(iv,v1);
|
||||
ti[0]=v0;
|
||||
ti[1]=v1;
|
||||
dp=(char *)d;
|
||||
dp=d;
|
||||
l2c(v0,dp);
|
||||
l2c(v1,dp);
|
||||
while (l--)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
|
||||
dp=(char *)d;
|
||||
des_encrypt(ti,schedule,DES_ENCRYPT);
|
||||
dp=d;
|
||||
t=ti[0]; l2c(t,dp);
|
||||
t=ti[1]; l2c(t,dp);
|
||||
save++;
|
||||
@ -104,7 +100,7 @@ int *num;
|
||||
{
|
||||
v0=ti[0];
|
||||
v1=ti[1];
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
l2c(v0,iv);
|
||||
l2c(v1,iv);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/ofb_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -64,15 +64,10 @@
|
||||
* the second. The second 12 bits will come from the 3rd and half the 4th
|
||||
* byte.
|
||||
*/
|
||||
void des_ofb_encrypt(in, out, numbits, length, schedule, ivec)
|
||||
unsigned char *in;
|
||||
unsigned char *out;
|
||||
int numbits;
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
|
||||
long length, des_key_schedule schedule, des_cblock *ivec)
|
||||
{
|
||||
register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
|
||||
register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8;
|
||||
register DES_LONG mask0,mask1;
|
||||
register long l=length;
|
||||
register int num=numbits;
|
||||
@ -94,29 +89,46 @@ des_cblock (*ivec);
|
||||
mask0=0xffffffffL;
|
||||
else
|
||||
mask0=(1L<<num)-1;
|
||||
mask1=0x00000000;
|
||||
mask1=0x00000000L;
|
||||
}
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
c2l(iv,v0);
|
||||
c2l(iv,v1);
|
||||
ti[0]=v0;
|
||||
ti[1]=v1;
|
||||
while (l-- > 0)
|
||||
{
|
||||
ti[0]=v0;
|
||||
ti[1]=v1;
|
||||
des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
|
||||
vv0=ti[0];
|
||||
vv1=ti[1];
|
||||
c2ln(in,d0,d1,n);
|
||||
in+=n;
|
||||
d0=(d0^ti[0])&mask0;
|
||||
d1=(d1^ti[1])&mask1;
|
||||
d0=(d0^vv0)&mask0;
|
||||
d1=(d1^vv1)&mask1;
|
||||
l2cn(d0,d1,out,n);
|
||||
out+=n;
|
||||
|
||||
if (num == 32)
|
||||
{ v0=v1; v1=vv0; }
|
||||
else if (num == 64)
|
||||
{ v0=vv0; v1=vv1; }
|
||||
else if (num > 32) /* && num != 64 */
|
||||
{
|
||||
v0=((v1>>(num-32))|(vv0<<(64-num)))&0xffffffffL;
|
||||
v1=((vv0>>(num-32))|(vv1<<(64-num)))&0xffffffffL;
|
||||
}
|
||||
v0=ti[0];
|
||||
v1=ti[1];
|
||||
iv=(unsigned char *)ivec;
|
||||
else /* num < 32 */
|
||||
{
|
||||
v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL;
|
||||
v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL;
|
||||
}
|
||||
}
|
||||
iv = &(*ivec)[0];
|
||||
l2c(v0,iv);
|
||||
l2c(v1,iv);
|
||||
v0=v1=d0=d1=ti[0]=ti[1]=0;
|
||||
v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0;
|
||||
}
|
||||
|
||||
|
39
crypto/libdes/options.txt
Normal file
39
crypto/libdes/options.txt
Normal file
@ -0,0 +1,39 @@
|
||||
Note that the UNROLL option makes the 'inner' des loop unroll all 16 rounds
|
||||
instead of the default 4.
|
||||
RISC1 and RISC2 are 2 alternatives for the inner loop and
|
||||
PTR means to use pointers arithmatic instead of arrays.
|
||||
|
||||
FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - assembler 577,000 4620k/s
|
||||
IRIX 6.2 - R10000 195mhz - cc (-O3 -n32) - UNROLL RISC2 PTR 496,000 3968k/s
|
||||
solaris 2.5.1 usparc 167mhz?? - SC4.0 - UNROLL RISC1 PTR [1] 459,400 3672k/s
|
||||
FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - UNROLL RISC1 433,000 3468k/s
|
||||
solaris 2.5.1 usparc 167mhz?? - gcc 2.7.2 - UNROLL 380,000 3041k/s
|
||||
linux - pentium 100mhz - gcc 2.7.0 - assembler 281,000 2250k/s
|
||||
NT 4.0 - pentium 100mhz - VC 4.2 - assembler 281,000 2250k/s
|
||||
AIX 4.1? - PPC604 100mhz - cc - UNROLL 275,000 2200k/s
|
||||
IRIX 5.3 - R4400 200mhz - gcc 2.6.3 - UNROLL RISC2 PTR 235,300 1882k/s
|
||||
IRIX 5.3 - R4400 200mhz - cc - UNROLL RISC2 PTR 233,700 1869k/s
|
||||
NT 4.0 - pentium 100mhz - VC 4.2 - UNROLL RISC1 PTR 191,000 1528k/s
|
||||
DEC Alpha 165mhz?? - cc - RISC2 PTR [2] 181,000 1448k/s
|
||||
linux - pentium 100mhz - gcc 2.7.0 - UNROLL RISC1 PTR 158,500 1268k/s
|
||||
HPUX 10 - 9000/887 - cc - UNROLL [3] 148,000 1190k/s
|
||||
solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2 - UNROLL 123,600 989k/s
|
||||
IRIX 5.3 - R4000 100mhz - cc - UNROLL RISC2 PTR 101,000 808k/s
|
||||
DGUX - 88100 50mhz(?) - gcc 2.6.3 - UNROLL 81,000 648k/s
|
||||
solaris 2.4 486 50mhz - gcc 2.6.3 - assembler 65,000 522k/s
|
||||
HPUX 10 - 9000/887 - k&r cc (default compiler) - UNROLL PTR 76,000 608k/s
|
||||
solaris 2.4 486 50mhz - gcc 2.6.3 - UNROLL RISC2 43,500 344k/s
|
||||
AIX - old slow one :-) - cc - 39,000 312k/s
|
||||
|
||||
Notes.
|
||||
[1] For the ultra sparc, SunC 4.0
|
||||
cc -xtarget=ultra -xarch=v8plus -Xa -xO5, running 'des_opts'
|
||||
gives a speed of 344,000 des/s while 'speed' gives 459,000 des/s.
|
||||
I'll record the higher since it is coming from the library but it
|
||||
is all rather weird.
|
||||
[2] Similar to the ultra sparc ([1]), 181,000 for 'des_opts' vs 175,000.
|
||||
[3] I was unable to get access to this machine when it was not heavily loaded.
|
||||
As such, my timing program was never able to get more that %30 of the CPU.
|
||||
This would cause the program to give much lower speed numbers because
|
||||
it would be 'fighting' to stay in the cache with the other CPU burning
|
||||
processes.
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/pcbc_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,23 +58,19 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
void des_pcbc_encrypt(input, output, length, schedule, ivec, encrypt)
|
||||
des_cblock (*input);
|
||||
des_cblock (*output);
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
int encrypt;
|
||||
void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
|
||||
long length, des_key_schedule schedule, des_cblock *ivec, int enc)
|
||||
{
|
||||
register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;
|
||||
DES_LONG tin[2];
|
||||
unsigned char *in,*out,*iv;
|
||||
const unsigned char *in;
|
||||
unsigned char *out,*iv;
|
||||
|
||||
in=(unsigned char *)input;
|
||||
out=(unsigned char *)output;
|
||||
iv=(unsigned char *)ivec;
|
||||
in=input;
|
||||
out=output;
|
||||
iv = &(*ivec)[0];
|
||||
|
||||
if (encrypt)
|
||||
if (enc)
|
||||
{
|
||||
c2l(iv,xor0);
|
||||
c2l(iv,xor1);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/podd.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/qud_cksm.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -73,36 +73,24 @@
|
||||
/* Got the value MIT uses via brute force :-) 2/10/90 eay */
|
||||
#define NOISE ((DES_LONG)83653421L)
|
||||
|
||||
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);
|
||||
{
|
||||
DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[],
|
||||
long length, int out_count, des_cblock *seed)
|
||||
{
|
||||
DES_LONG z0,z1,t0,t1;
|
||||
int i;
|
||||
long l;
|
||||
#ifdef _CRAY
|
||||
typedef struct {
|
||||
unsigned int a:32;
|
||||
unsigned int b:32;
|
||||
} XXX;
|
||||
#else
|
||||
typedef DES_LONG XXX;
|
||||
#endif
|
||||
unsigned char *cp;
|
||||
XXX *lp;
|
||||
const unsigned char *cp;
|
||||
unsigned char *lp;
|
||||
|
||||
if (out_count < 1) out_count=1;
|
||||
lp=(XXX*)output;
|
||||
lp = &(output[0])[0];
|
||||
|
||||
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++)
|
||||
{
|
||||
cp=(unsigned char *)input;
|
||||
cp=input;
|
||||
l=length;
|
||||
while (l > 0)
|
||||
{
|
||||
@ -126,18 +114,27 @@ DES_LONG des_quad_cksum(input, output, length, out_count, seed)
|
||||
}
|
||||
if (lp != NULL)
|
||||
{
|
||||
/* The MIT library assumes that the checksum is
|
||||
* composed of 2*out_count 32 bit ints */
|
||||
#ifdef _CRAY
|
||||
lp->a = z0;
|
||||
lp->b = z1;
|
||||
lp++;
|
||||
#else
|
||||
*lp++ = (XXX)z0;
|
||||
*lp++ = (XXX)z1;
|
||||
#endif
|
||||
/* I believe I finally have things worked out.
|
||||
* The MIT library assumes that the checksum
|
||||
* is one huge number and it is returned in a
|
||||
* host dependant byte order.
|
||||
*/
|
||||
static DES_LONG ltmp=1;
|
||||
static unsigned char *c=(unsigned char *)<mp;
|
||||
|
||||
if (c[0])
|
||||
{
|
||||
l2c(z0,lp);
|
||||
l2c(z1,lp);
|
||||
}
|
||||
else
|
||||
{
|
||||
lp = &(output[out_count-i-1])[0];
|
||||
l2n(z1,lp);
|
||||
l2n(z0,lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(z0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/rand_key.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -62,17 +62,13 @@
|
||||
static int seed=0;
|
||||
static des_cblock init;
|
||||
|
||||
void des_random_seed(key)
|
||||
des_cblock key;
|
||||
void des_random_seed(des_cblock *key)
|
||||
{
|
||||
memcpy(init,key,sizeof(des_cblock));
|
||||
memcpy(&init,key,sizeof(des_cblock));
|
||||
seed=1;
|
||||
}
|
||||
|
||||
/* Old source */
|
||||
/*
|
||||
void des_random_key(ret)
|
||||
unsigned char *ret;
|
||||
void des_random_key(des_cblock *ret)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
static DES_LONG c=0;
|
||||
@ -83,7 +79,7 @@ unsigned char *ret;
|
||||
DES_LONG t;
|
||||
int i;
|
||||
|
||||
#if defined(MSDOS) || defined(WIN32)
|
||||
#ifdef MSDOS
|
||||
pid=1;
|
||||
#else
|
||||
if (!pid) pid=getpid();
|
||||
@ -103,19 +99,16 @@ unsigned char *ret;
|
||||
t=(DES_LONG)((pid)|((c++)<<16));
|
||||
l2c(t,p);
|
||||
|
||||
des_set_odd_parity((des_cblock *)data);
|
||||
des_set_key((des_cblock *)data,ks);
|
||||
des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
|
||||
(long)sizeof(key),ks,(des_cblock *)data);
|
||||
des_set_odd_parity(&data);
|
||||
des_set_key(&data,ks);
|
||||
des_cbc_cksum(key,&key,sizeof(key),ks,&data);
|
||||
|
||||
des_set_odd_parity((des_cblock *)key);
|
||||
des_set_key((des_cblock *)key,ks);
|
||||
des_cbc_cksum((des_cblock *)key,(des_cblock *)data,
|
||||
(long)sizeof(key),ks,(des_cblock *)key);
|
||||
des_set_odd_parity(&key);
|
||||
des_set_key(&key,ks);
|
||||
des_cbc_cksum(key,&data,sizeof(key),ks,&key);
|
||||
|
||||
memcpy(ret,data,sizeof(key));
|
||||
memset(key,0,sizeof(key));
|
||||
memset(ks,0,sizeof(ks));
|
||||
t=0;
|
||||
}
|
||||
*/
|
||||
|
84
crypto/libdes/read2pwd.c
Normal file
84
crypto/libdes/read2pwd.c
Normal file
@ -0,0 +1,84 @@
|
||||
/* crypto/des/read2pwd.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library 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 cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* 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.]
|
||||
*/
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
int des_read_password(des_cblock *key, const char *prompt, int verify)
|
||||
{
|
||||
int ok;
|
||||
char buf[BUFSIZ],buff[BUFSIZ];
|
||||
|
||||
if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
|
||||
des_string_to_key(buf,key);
|
||||
memset(buf,0,BUFSIZ);
|
||||
memset(buff,0,BUFSIZ);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt,
|
||||
int verify)
|
||||
{
|
||||
int ok;
|
||||
char buf[BUFSIZ],buff[BUFSIZ];
|
||||
|
||||
if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
|
||||
des_string_to_2keys(buf,key1,key2);
|
||||
memset(buf,0,BUFSIZ);
|
||||
memset(buff,0,BUFSIZ);
|
||||
return(ok);
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/read_pwd.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -56,6 +56,23 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32)
|
||||
#include <openssl/opensslconf.h>
|
||||
#include OPENSSL_UNISTD
|
||||
/* If unistd.h defines _POSIX_VERSION, we conclude that we
|
||||
* are on a POSIX system and have sigaction and termios. */
|
||||
#if defined(_POSIX_VERSION)
|
||||
|
||||
# define SIGACTION
|
||||
# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
|
||||
# define TERMIOS
|
||||
# endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* #define SIGACTION */ /* Define this if you have sigaction() */
|
||||
|
||||
#ifdef WIN16TTY
|
||||
#undef WIN16
|
||||
#undef _WINDOWS
|
||||
@ -64,11 +81,26 @@
|
||||
|
||||
/* 06-Apr-92 Luke Brennan Support for VMS */
|
||||
#include "des_locl.h"
|
||||
#include "cryptlib.h"
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef VMS /* prototypes for sys$whatever */
|
||||
#include <starlet.h>
|
||||
#ifdef __DECC
|
||||
#pragma message disable DOLLARID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN_CONSOLE_BUG
|
||||
#include <windows.h>
|
||||
#include <wincon.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* There are 5 types of terminal interface supported,
|
||||
* TERMIO, TERMIOS, VMS, MSDOS and SGTTY
|
||||
*/
|
||||
@ -86,10 +118,14 @@
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
#undef TERMIOS
|
||||
#define TERMIO
|
||||
#undef SGTTY
|
||||
#endif
|
||||
|
||||
#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS)
|
||||
#undef TERMIOS
|
||||
#undef TERMIO
|
||||
#define SGTTY
|
||||
#endif
|
||||
|
||||
@ -142,82 +178,34 @@ struct IOSB {
|
||||
#define NX509_SIG 32
|
||||
#endif
|
||||
|
||||
#ifndef NOPROTO
|
||||
static void read_till_nl(FILE *);
|
||||
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);
|
||||
#if defined(MSDOS) && !defined(WIN16)
|
||||
static int noecho_fgets(char *buf, int size, FILE *tty);
|
||||
#endif
|
||||
#ifdef SIGACTION
|
||||
static struct sigaction savsig[NX509_SIG];
|
||||
#else
|
||||
static void read_till_nl();
|
||||
static int read_pw();
|
||||
static void recsig();
|
||||
static void pushsig();
|
||||
static void popsig();
|
||||
#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])();
|
||||
static void (*savsig[NX509_SIG])(int );
|
||||
#endif
|
||||
static jmp_buf save;
|
||||
|
||||
int des_read_password(key, prompt, verify)
|
||||
des_cblock (*key);
|
||||
char *prompt;
|
||||
int verify;
|
||||
{
|
||||
int ok;
|
||||
char buf[BUFSIZ],buff[BUFSIZ];
|
||||
|
||||
if ((ok=read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
|
||||
des_string_to_key(buf,key);
|
||||
memset(buf,0,BUFSIZ);
|
||||
memset(buff,0,BUFSIZ);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
int des_read_2passwords(key1, key2, prompt, verify)
|
||||
des_cblock (*key1);
|
||||
des_cblock (*key2);
|
||||
char *prompt;
|
||||
int verify;
|
||||
{
|
||||
int ok;
|
||||
char buf[BUFSIZ],buff[BUFSIZ];
|
||||
|
||||
if ((ok=read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
|
||||
des_string_to_2keys(buf,key1,key2);
|
||||
memset(buf,0,BUFSIZ);
|
||||
memset(buff,0,BUFSIZ);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
int des_read_pw_string(buf, length, prompt, verify)
|
||||
char *buf;
|
||||
int length;
|
||||
char *prompt;
|
||||
int verify;
|
||||
int des_read_pw_string(char *buf, int length, const char *prompt,
|
||||
int verify)
|
||||
{
|
||||
char buff[BUFSIZ];
|
||||
int ret;
|
||||
|
||||
ret=read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
|
||||
ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
|
||||
memset(buff,0,BUFSIZ);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#ifndef WIN16
|
||||
|
||||
static void read_till_nl(in)
|
||||
FILE *in;
|
||||
static void read_till_nl(FILE *in)
|
||||
{
|
||||
#define SIZE 4
|
||||
char buf[SIZE+1];
|
||||
@ -229,12 +217,8 @@ FILE *in;
|
||||
|
||||
|
||||
/* return 0 if ok, 1 (or -1) otherwise */
|
||||
static int read_pw(buf, buff, size, prompt, verify)
|
||||
char *buf;
|
||||
char *buff;
|
||||
int size;
|
||||
char *prompt;
|
||||
int verify;
|
||||
int des_read_pw(char *buf, char *buff, int size, const char *prompt,
|
||||
int verify)
|
||||
{
|
||||
#ifdef VMS
|
||||
struct IOSB iosb;
|
||||
@ -247,17 +231,28 @@ int verify;
|
||||
TTY_STRUCT tty_orig,tty_new;
|
||||
#endif
|
||||
#endif
|
||||
int number=5;
|
||||
int ok=0;
|
||||
int ps=0;
|
||||
int is_a_tty=1;
|
||||
|
||||
FILE *tty=NULL;
|
||||
int number;
|
||||
int ok;
|
||||
/* statics are simply to avoid warnings about longjmp clobbering
|
||||
things */
|
||||
static int ps;
|
||||
int is_a_tty;
|
||||
static FILE *tty;
|
||||
char *p;
|
||||
|
||||
#ifdef __CYGWIN32__
|
||||
tty = stdin;
|
||||
#elif !defined(MSDOS)
|
||||
if (setjmp(save))
|
||||
{
|
||||
ok=0;
|
||||
goto error;
|
||||
}
|
||||
|
||||
number=5;
|
||||
ok=0;
|
||||
ps=0;
|
||||
is_a_tty=1;
|
||||
tty=NULL;
|
||||
|
||||
#ifndef MSDOS
|
||||
if ((tty=fopen("/dev/tty","r")) == NULL)
|
||||
tty=stdin;
|
||||
#else /* MSDOS */
|
||||
@ -272,25 +267,27 @@ int verify;
|
||||
if (errno == ENOTTY)
|
||||
is_a_tty=0;
|
||||
else
|
||||
#endif
|
||||
#ifdef EINVAL
|
||||
/* Ariel Glenn ariel@columbia.edu reports that solaris
|
||||
* can return EINVAL instead. This should be ok */
|
||||
if (errno == EINVAL)
|
||||
is_a_tty=0;
|
||||
else
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
|
||||
#endif
|
||||
#ifdef VMS
|
||||
status = SYS$ASSIGN(&terminal,&channel,0,0);
|
||||
status = sys$assign(&terminal,&channel,0,0);
|
||||
if (status != SS$_NORMAL)
|
||||
return(-1);
|
||||
status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
|
||||
status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
|
||||
if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
|
||||
return(-1);
|
||||
#endif
|
||||
|
||||
if (setjmp(save))
|
||||
{
|
||||
ok=0;
|
||||
goto error;
|
||||
}
|
||||
pushsig();
|
||||
ps=1;
|
||||
|
||||
@ -306,7 +303,7 @@ int verify;
|
||||
tty_new[0] = tty_orig[0];
|
||||
tty_new[1] = tty_orig[1] | TT$M_NOECHO;
|
||||
tty_new[2] = tty_orig[2];
|
||||
status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
|
||||
status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
|
||||
if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
|
||||
return(-1);
|
||||
#endif
|
||||
@ -357,26 +354,21 @@ int verify;
|
||||
#endif
|
||||
#ifdef VMS
|
||||
if (ps >= 2)
|
||||
status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0
|
||||
status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
|
||||
,tty_orig,12,0,0,0,0);
|
||||
#endif
|
||||
|
||||
if (ps >= 1) popsig();
|
||||
if (stdin != tty) fclose(tty);
|
||||
#ifdef VMS
|
||||
status = SYS$DASSGN(channel);
|
||||
status = sys$dassgn(channel);
|
||||
#endif
|
||||
return(!ok);
|
||||
}
|
||||
|
||||
#else /* WIN16 */
|
||||
|
||||
static int read_pw(buf, buff, size, prompt, verify)
|
||||
char *buf;
|
||||
char *buff;
|
||||
int size;
|
||||
char *prompt;
|
||||
int verify;
|
||||
int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
|
||||
{
|
||||
memset(buf,0,size);
|
||||
memset(buff,0,size);
|
||||
@ -385,28 +377,61 @@ int verify;
|
||||
|
||||
#endif
|
||||
|
||||
static void pushsig()
|
||||
static void pushsig(void)
|
||||
{
|
||||
int i;
|
||||
#ifdef SIGACTION
|
||||
struct sigaction sa;
|
||||
|
||||
memset(&sa,0,sizeof sa);
|
||||
sa.sa_handler=recsig;
|
||||
#endif
|
||||
|
||||
for (i=1; i<NX509_SIG; i++)
|
||||
{
|
||||
#ifdef SIGUSR1
|
||||
if (i == SIGUSR1)
|
||||
continue;
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
if (i == SIGUSR2)
|
||||
continue;
|
||||
#endif
|
||||
#ifdef SIGACTION
|
||||
sigaction(i,&sa,&savsig[i]);
|
||||
#else
|
||||
savsig[i]=signal(i,recsig);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SIGWINCH
|
||||
signal(SIGWINCH,SIG_DFL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void popsig()
|
||||
static void popsig(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=1; i<NX509_SIG; i++)
|
||||
{
|
||||
#ifdef SIGUSR1
|
||||
if (i == SIGUSR1)
|
||||
continue;
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
if (i == SIGUSR2)
|
||||
continue;
|
||||
#endif
|
||||
#ifdef SIGACTION
|
||||
sigaction(i,&savsig[i],NULL);
|
||||
#else
|
||||
signal(i,savsig[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void recsig(i)
|
||||
int i;
|
||||
static void recsig(int i)
|
||||
{
|
||||
longjmp(save,1);
|
||||
#ifdef LINT
|
||||
@ -415,10 +440,7 @@ int i;
|
||||
}
|
||||
|
||||
#if defined(MSDOS) && !defined(WIN16)
|
||||
static int noecho_fgets(buf,size,tty)
|
||||
char *buf;
|
||||
int size;
|
||||
FILE *tty;
|
||||
static int noecho_fgets(char *buf, int size, FILE *tty)
|
||||
{
|
||||
int i;
|
||||
char *p;
|
||||
@ -445,6 +467,18 @@ FILE *tty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WIN_CONSOLE_BUG
|
||||
/* Win95 has several evil console bugs: one of these is that the
|
||||
* last character read using getch() is passed to the next read: this is
|
||||
* usually a CR so this can be trouble. No STDIO fix seems to work but
|
||||
* flushing the console appears to do the trick.
|
||||
*/
|
||||
{
|
||||
HANDLE inh;
|
||||
inh = GetStdHandle(STD_INPUT_HANDLE);
|
||||
FlushConsoleInputBuffer(inh);
|
||||
}
|
||||
#endif
|
||||
return(strlen(buf));
|
||||
}
|
||||
#endif
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/rpc_des.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/rpc_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -60,32 +60,23 @@
|
||||
#include "des_locl.h"
|
||||
#include "des_ver.h"
|
||||
|
||||
#ifndef NOPROTO
|
||||
int _des_crypt(char *buf,int len,struct desparams *desp);
|
||||
#else
|
||||
int _des_crypt();
|
||||
#endif
|
||||
|
||||
int _des_crypt(buf, len, desp)
|
||||
char *buf;
|
||||
int len;
|
||||
struct desparams *desp;
|
||||
int _des_crypt(char *buf, int len, struct desparams *desp)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
int enc;
|
||||
|
||||
des_set_key((des_cblock *)desp->des_key,ks);
|
||||
des_set_key(&desp->des_key,ks);
|
||||
enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT;
|
||||
|
||||
if (desp->des_mode == CBC)
|
||||
des_ecb_encrypt((des_cblock *)desp->UDES.UDES_buf,
|
||||
(des_cblock *)desp->UDES.UDES_buf,ks,enc);
|
||||
des_ecb_encrypt((const_des_cblock *)desp->UDES.UDES_buf,
|
||||
(des_cblock *)desp->UDES.UDES_buf,ks,
|
||||
enc);
|
||||
else
|
||||
{
|
||||
des_ncbc_encrypt((des_cblock *)desp->UDES.UDES_buf,
|
||||
(des_cblock *)desp->UDES.UDES_buf,
|
||||
(long)len,ks,
|
||||
(des_cblock *)desp->des_ivec,enc);
|
||||
des_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,
|
||||
len,ks,&desp->des_ivec,enc);
|
||||
#ifdef undef
|
||||
/* len will always be %8 if called from common_crypt
|
||||
* in secure_rpc.
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/rpw.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -56,21 +56,16 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include "des.h"
|
||||
#include <openssl/des.h>
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
des_cblock k,k1;
|
||||
int i;
|
||||
|
||||
printf("read passwd\n");
|
||||
if ((i=des_read_password((C_Block *)k,"Enter password:",0)) == 0)
|
||||
if ((i=des_read_password(&k,"Enter password:",0)) == 0)
|
||||
{
|
||||
printf("password = ");
|
||||
for (i=0; i<8; i++)
|
||||
@ -80,7 +75,7 @@ char *argv[];
|
||||
printf("error %d\n",i);
|
||||
printf("\n");
|
||||
printf("read 2passwds and verify\n");
|
||||
if ((i=des_read_2passwords((C_Block *)k,(C_Block *)k1,
|
||||
if ((i=des_read_2passwords(&k,&k1,
|
||||
"Enter verified password:",1)) == 0)
|
||||
{
|
||||
printf("password1 = ");
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/set_key.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -67,16 +67,10 @@
|
||||
#include "podd.h"
|
||||
#include "sk.h"
|
||||
|
||||
#ifndef NOPROTO
|
||||
static int check_parity(des_cblock (*key));
|
||||
#else
|
||||
static int check_parity();
|
||||
#endif
|
||||
static int check_parity(const_des_cblock *key);
|
||||
OPENSSL_GLOBAL int des_check_key=0;
|
||||
|
||||
int des_check_key=0;
|
||||
|
||||
void des_set_odd_parity(key)
|
||||
des_cblock (*key);
|
||||
void des_set_odd_parity(des_cblock *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -84,8 +78,7 @@ des_cblock (*key);
|
||||
(*key)[i]=odd_parity[(*key)[i]];
|
||||
}
|
||||
|
||||
static int check_parity(key)
|
||||
des_cblock (*key);
|
||||
static int check_parity(const_des_cblock *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -111,8 +104,8 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
|
||||
/* weak keys */
|
||||
{0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
|
||||
{0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
|
||||
{0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F},
|
||||
{0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0},
|
||||
{0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E},
|
||||
{0xE0,0xE0,0xE0,0xE0,0xF1,0xF1,0xF1,0xF1},
|
||||
/* semi-weak keys */
|
||||
{0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE},
|
||||
{0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01},
|
||||
@ -127,8 +120,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
|
||||
{0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
|
||||
{0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
|
||||
|
||||
int des_is_weak_key(key)
|
||||
des_cblock (*key);
|
||||
int des_is_weak_key(const_des_cblock *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -136,8 +128,10 @@ des_cblock (*key);
|
||||
/* Added == 0 to comparision, I obviously don't run
|
||||
* this section very often :-(, thanks to
|
||||
* engineering@MorningStar.Com for the fix
|
||||
* eay 93/06/29 */
|
||||
if (memcmp(weak_keys[i],key,sizeof(key)) == 0) return(1);
|
||||
* eay 93/06/29
|
||||
* Another problem, I was comparing only the first 4
|
||||
* bytes, 97/03/18 */
|
||||
if (memcmp(weak_keys[i],key,sizeof(des_cblock)) == 0) return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -155,13 +149,11 @@ des_cblock (*key);
|
||||
* return -1 if key parity error,
|
||||
* return -2 if illegal weak key.
|
||||
*/
|
||||
int des_set_key(key, schedule)
|
||||
des_cblock (*key);
|
||||
des_key_schedule schedule;
|
||||
int des_set_key(const_des_cblock *key, des_key_schedule schedule)
|
||||
{
|
||||
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,t2;
|
||||
register unsigned char *in;
|
||||
register const unsigned char *in;
|
||||
register DES_LONG *k;
|
||||
register int i;
|
||||
|
||||
@ -174,8 +166,8 @@ des_key_schedule schedule;
|
||||
return(-2);
|
||||
}
|
||||
|
||||
k=(DES_LONG *)schedule;
|
||||
in=(unsigned char *)key;
|
||||
k = &schedule->ks.deslong[0];
|
||||
in = &(*key)[0];
|
||||
|
||||
c2l(in,c);
|
||||
c2l(in,d);
|
||||
@ -236,9 +228,7 @@ des_key_schedule schedule;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int des_key_sched(key, schedule)
|
||||
des_cblock (*key);
|
||||
des_key_schedule schedule;
|
||||
int des_key_sched(const_des_cblock *key, des_key_schedule schedule)
|
||||
{
|
||||
return(des_set_key(key,schedule));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#/usr/local/bin/perl
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
sub lab_shift
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/sk.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/speed.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -59,87 +59,71 @@
|
||||
/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
|
||||
/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(MSDOS) && !defined(WIN32)
|
||||
#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
|
||||
#define TIMES
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
#include OPENSSL_UNISTD_IO
|
||||
OPENSSL_DECLARE_EXIT
|
||||
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_TIME_H
|
||||
#ifndef _IRIX
|
||||
#include <time.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#ifdef TIMES
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
#include <types.h>
|
||||
struct tms {
|
||||
time_t tms_utime;
|
||||
time_t tms_stime;
|
||||
time_t tms_uchild; /* I dunno... */
|
||||
time_t tms_uchildsys; /* so these names are a guess :-) */
|
||||
}
|
||||
/* Depending on the VMS version, the tms structure is perhaps defined.
|
||||
The __TMS macro will show if it was. If it wasn't defined, we should
|
||||
undefine TIMES, since that tells the rest of the program how things
|
||||
should be handled. -- Richard Levitte */
|
||||
#if defined(VMS) && defined(__DECC) && !defined(__TMS)
|
||||
#undef TIMES
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIMEB_H
|
||||
#ifndef TIMES
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#if defined(sun) || defined(__ultrix)
|
||||
#define _POSIX_SOURCE
|
||||
#include <limits.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "des.h"
|
||||
#include <openssl/des.h>
|
||||
|
||||
/* The following if from times(3) man page. It may need to be changed */
|
||||
#ifndef HZ
|
||||
#ifndef CLK_TCK
|
||||
#ifndef VMS
|
||||
#define HZ 100.0
|
||||
#else /* VMS */
|
||||
#define HZ 100.0
|
||||
#endif
|
||||
#else /* CLK_TCK */
|
||||
#define HZ ((double)CLK_TCK)
|
||||
#endif
|
||||
# ifndef CLK_TCK
|
||||
# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
|
||||
# define HZ 100.0
|
||||
# else /* _BSD_CLK_TCK_ */
|
||||
# define HZ ((double)_BSD_CLK_TCK_)
|
||||
# endif
|
||||
# else /* CLK_TCK */
|
||||
# define HZ ((double)CLK_TCK)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define BUFSIZE ((long)1024)
|
||||
long run=0;
|
||||
|
||||
#ifndef NOPROTO
|
||||
double Time_F(int s);
|
||||
#else
|
||||
double Time_F();
|
||||
#endif
|
||||
|
||||
#ifdef SIGALRM
|
||||
#if defined(__STDC__) || defined(sgi)
|
||||
#if defined(__STDC__) || defined(sgi) || defined(_AIX)
|
||||
#define SIGRETTYPE void
|
||||
#else
|
||||
#define SIGRETTYPE int
|
||||
#endif
|
||||
|
||||
#ifndef NOPROTO
|
||||
SIGRETTYPE sig_done(int sig);
|
||||
#else
|
||||
SIGRETTYPE sig_done();
|
||||
#endif
|
||||
|
||||
SIGRETTYPE sig_done(sig)
|
||||
int sig;
|
||||
SIGRETTYPE sig_done(int sig)
|
||||
{
|
||||
signal(SIGALRM,sig_done);
|
||||
run=0;
|
||||
@ -152,8 +136,7 @@ int sig;
|
||||
#define START 0
|
||||
#define STOP 1
|
||||
|
||||
double Time_F(s)
|
||||
int s;
|
||||
double Time_F(int s)
|
||||
{
|
||||
double ret;
|
||||
#ifdef TIMES
|
||||
@ -183,15 +166,13 @@ int s;
|
||||
{
|
||||
ftime(&tend);
|
||||
i=(long)tend.millitm-(long)tstart.millitm;
|
||||
ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
|
||||
ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
|
||||
return((ret == 0.0)?1e-6:ret);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
long count;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
@ -209,12 +190,12 @@ char **argv;
|
||||
printf("program when this computer is idle.\n");
|
||||
#endif
|
||||
|
||||
des_set_key((C_Block *)key2,sch2);
|
||||
des_set_key((C_Block *)key3,sch3);
|
||||
des_set_key(&key2,sch2);
|
||||
des_set_key(&key3,sch3);
|
||||
|
||||
#ifndef SIGALRM
|
||||
printf("First we calculate the approximate speed ...\n");
|
||||
des_set_key((C_Block *)key,sch);
|
||||
des_set_key(&key,sch);
|
||||
count=10;
|
||||
do {
|
||||
long i;
|
||||
@ -244,7 +225,7 @@ char **argv;
|
||||
|
||||
Time_F(START);
|
||||
for (count=0,run=1; COND(ca); count++)
|
||||
des_set_key((C_Block *)key,sch);
|
||||
des_set_key(&key,sch);
|
||||
d=Time_F(STOP);
|
||||
printf("%ld set_key's in %.2f seconds\n",count,d);
|
||||
a=((double)COUNT(ca))/d;
|
||||
@ -276,8 +257,8 @@ char **argv;
|
||||
#endif
|
||||
Time_F(START);
|
||||
for (count=0,run=1; COND(cc); count++)
|
||||
des_ncbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]),
|
||||
(C_Block *)&(key[0]),DES_ENCRYPT);
|
||||
des_ncbc_encrypt(buf,buf,BUFSIZE,&(sch[0]),
|
||||
&key,DES_ENCRYPT);
|
||||
d=Time_F(STOP);
|
||||
printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n",
|
||||
count,BUFSIZE,d);
|
||||
@ -293,11 +274,11 @@ char **argv;
|
||||
#endif
|
||||
Time_F(START);
|
||||
for (count=0,run=1; COND(cd); count++)
|
||||
des_ede3_cbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,
|
||||
des_ede3_cbc_encrypt(buf,buf,BUFSIZE,
|
||||
&(sch[0]),
|
||||
&(sch2[0]),
|
||||
&(sch3[0]),
|
||||
(C_Block *)&(key[0]),
|
||||
&key,
|
||||
DES_ENCRYPT);
|
||||
d=Time_F(STOP);
|
||||
printf("%ld des_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n",
|
||||
@ -317,11 +298,11 @@ char **argv;
|
||||
printf("%ld crypts in %.2f second\n",count,e);
|
||||
e=((double)COUNT(ce))/e;
|
||||
|
||||
printf("set_key per sec = %12.2f (%5.1fuS)\n",a,1.0e6/a);
|
||||
printf("DES raw ecb bytes per sec = %12.2f (%5.1fuS)\n",b,8.0e6/b);
|
||||
printf("DES cbc bytes per sec = %12.2f (%5.1fuS)\n",c,8.0e6/c);
|
||||
printf("DES ede cbc bytes per sec = %12.2f (%5.1fuS)\n",d,8.0e6/d);
|
||||
printf("crypt per sec = %12.2f (%5.1fuS)\n",e,1.0e6/e);
|
||||
printf("set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
|
||||
printf("DES raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
|
||||
printf("DES cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
|
||||
printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d);
|
||||
printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e);
|
||||
exit(0);
|
||||
#if defined(LINT) || defined(MSDOS)
|
||||
return(0);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/spr.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
const DES_LONG des_SPtrans[8][64]={
|
||||
OPENSSL_GLOBAL const DES_LONG des_SPtrans[8][64]={
|
||||
{
|
||||
/* nibble 0 */
|
||||
0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L,
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/str2key.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -58,11 +58,9 @@
|
||||
|
||||
#include "des_locl.h"
|
||||
|
||||
extern int des_check_key;
|
||||
OPENSSL_EXTERN int des_check_key;
|
||||
|
||||
void des_string_to_key(str, key)
|
||||
char *str;
|
||||
des_cblock (*key);
|
||||
void des_string_to_key(const char *str, des_cblock *key)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
int i,length;
|
||||
@ -89,21 +87,17 @@ des_cblock (*key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
des_set_odd_parity((des_cblock *)key);
|
||||
des_set_odd_parity(key);
|
||||
i=des_check_key;
|
||||
des_check_key=0;
|
||||
des_set_key((des_cblock *)key,ks);
|
||||
des_set_key(key,ks);
|
||||
des_check_key=i;
|
||||
des_cbc_cksum((des_cblock *)str,(des_cblock *)key,(long)length,ks,
|
||||
(des_cblock *)key);
|
||||
des_cbc_cksum((unsigned char*)str,key,length,ks,key);
|
||||
memset(ks,0,sizeof(ks));
|
||||
des_set_odd_parity((des_cblock *)key);
|
||||
des_set_odd_parity(key);
|
||||
}
|
||||
|
||||
void des_string_to_2keys(str, key1, key2)
|
||||
char *str;
|
||||
des_cblock (*key1);
|
||||
des_cblock (*key2);
|
||||
void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
int i,length;
|
||||
@ -154,16 +148,14 @@ des_cblock (*key2);
|
||||
}
|
||||
if (length <= 8) memcpy(key2,key1,8);
|
||||
#endif
|
||||
des_set_odd_parity((des_cblock *)key1);
|
||||
des_set_odd_parity((des_cblock *)key2);
|
||||
des_set_odd_parity(key1);
|
||||
des_set_odd_parity(key2);
|
||||
i=des_check_key;
|
||||
des_check_key=0;
|
||||
des_set_key((des_cblock *)key1,ks);
|
||||
des_cbc_cksum((des_cblock *)str,(des_cblock *)key1,(long)length,ks,
|
||||
(des_cblock *)key1);
|
||||
des_set_key((des_cblock *)key2,ks);
|
||||
des_cbc_cksum((des_cblock *)str,(des_cblock *)key2,(long)length,ks,
|
||||
(des_cblock *)key2);
|
||||
des_set_key(key1,ks);
|
||||
des_cbc_cksum((unsigned char*)str,key1,length,ks,key1);
|
||||
des_set_key(key2,ks);
|
||||
des_cbc_cksum((unsigned char*)str,key2,length,ks,key2);
|
||||
des_check_key=i;
|
||||
memset(ks,0,sizeof(ks));
|
||||
des_set_odd_parity(key1);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/supp.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -87,18 +87,16 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: supp.c,v 1.4 1997/06/22 10:14:07 bg Exp $
|
||||
* $Id: supp.c,v 1.5 1999/05/16 12:25:45 bodo Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "des_locl.h"
|
||||
|
||||
void des_cblock_print_file(cb, fp)
|
||||
des_cblock *cb;
|
||||
FILE *fp;
|
||||
void des_cblock_print_file(const_des_cblock *cb, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
unsigned int *p = (unsigned int *)cb;
|
||||
const unsigned int *p = (const unsigned int *)cb;
|
||||
|
||||
fprintf(fp, " 0x { ");
|
||||
for (i = 0; i < 8; i++) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* crypto/des/xcbc_enc.c */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@mincom.oz.au).
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
@ -11,7 +11,7 @@
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@mincom.oz.au).
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
@ -31,12 +31,12 @@
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@mincom.oz.au)"
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@mincom.oz.au)"
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@ -79,18 +79,14 @@ static unsigned char desx_white_in2out[256]={
|
||||
0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB,
|
||||
};
|
||||
|
||||
void des_xwhite_in2out(des_key,in_white,out_white)
|
||||
des_cblock (*des_key);
|
||||
des_cblock (*in_white);
|
||||
des_cblock (*out_white);
|
||||
void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white,
|
||||
des_cblock *out_white)
|
||||
{
|
||||
unsigned char *key,*in,*out;
|
||||
int out0,out1;
|
||||
int i;
|
||||
|
||||
key=(unsigned char *)des_key;
|
||||
in=(unsigned char *)in_white;
|
||||
out=(unsigned char *)out_white;
|
||||
const unsigned char *key = &(*des_key)[0];
|
||||
const unsigned char *in = &(*in_white)[0];
|
||||
unsigned char *out = &(*out_white)[0];
|
||||
|
||||
out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0;
|
||||
out0=out1=0;
|
||||
@ -111,36 +107,28 @@ des_cblock (*out_white);
|
||||
}
|
||||
}
|
||||
|
||||
void des_xcbc_encrypt(input, output, length, schedule, ivec, inw,outw,encrypt)
|
||||
des_cblock (*input);
|
||||
des_cblock (*output);
|
||||
long length;
|
||||
des_key_schedule schedule;
|
||||
des_cblock (*ivec);
|
||||
des_cblock (*inw);
|
||||
des_cblock (*outw);
|
||||
int encrypt;
|
||||
void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule schedule, des_cblock *ivec,
|
||||
const_des_cblock *inw, const_des_cblock *outw, int enc)
|
||||
{
|
||||
register DES_LONG tin0,tin1;
|
||||
register DES_LONG tout0,tout1,xor0,xor1;
|
||||
register DES_LONG inW0,inW1,outW0,outW1;
|
||||
register unsigned char *in,*out;
|
||||
register const unsigned char *in2;
|
||||
register long l=length;
|
||||
DES_LONG tin[2];
|
||||
unsigned char *iv;
|
||||
|
||||
in=(unsigned char *)inw;
|
||||
c2l(in,inW0);
|
||||
c2l(in,inW1);
|
||||
in=(unsigned char *)outw;
|
||||
c2l(in,outW0);
|
||||
c2l(in,outW1);
|
||||
in2 = &(*inw)[0];
|
||||
c2l(in2,inW0);
|
||||
c2l(in2,inW1);
|
||||
in2 = &(*outw)[0];
|
||||
c2l(in2,outW0);
|
||||
c2l(in2,outW1);
|
||||
|
||||
in=(unsigned char *)input;
|
||||
out=(unsigned char *)output;
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
|
||||
if (encrypt)
|
||||
if (enc)
|
||||
{
|
||||
c2l(iv,tout0);
|
||||
c2l(iv,tout1);
|
||||
@ -150,7 +138,7 @@ int encrypt;
|
||||
c2l(in,tin1);
|
||||
tin0^=tout0^inW0; tin[0]=tin0;
|
||||
tin1^=tout1^inW1; tin[1]=tin1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
|
||||
des_encrypt(tin,schedule,DES_ENCRYPT);
|
||||
tout0=tin[0]^outW0; l2c(tout0,out);
|
||||
tout1=tin[1]^outW1; l2c(tout1,out);
|
||||
}
|
||||
@ -159,11 +147,11 @@ int encrypt;
|
||||
c2ln(in,tin0,tin1,l+8);
|
||||
tin0^=tout0^inW0; tin[0]=tin0;
|
||||
tin1^=tout1^inW1; tin[1]=tin1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
|
||||
des_encrypt(tin,schedule,DES_ENCRYPT);
|
||||
tout0=tin[0]^outW0; l2c(tout0,out);
|
||||
tout1=tin[1]^outW1; l2c(tout1,out);
|
||||
}
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
l2c(tout0,iv);
|
||||
l2c(tout1,iv);
|
||||
}
|
||||
@ -175,7 +163,7 @@ int encrypt;
|
||||
{
|
||||
c2l(in,tin0); tin[0]=tin0^outW0;
|
||||
c2l(in,tin1); tin[1]=tin1^outW1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
|
||||
des_encrypt(tin,schedule,DES_DECRYPT);
|
||||
tout0=tin[0]^xor0^inW0;
|
||||
tout1=tin[1]^xor1^inW1;
|
||||
l2c(tout0,out);
|
||||
@ -187,7 +175,7 @@ int encrypt;
|
||||
{
|
||||
c2l(in,tin0); tin[0]=tin0^outW0;
|
||||
c2l(in,tin1); tin[1]=tin1^outW1;
|
||||
des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
|
||||
des_encrypt(tin,schedule,DES_DECRYPT);
|
||||
tout0=tin[0]^xor0^inW0;
|
||||
tout1=tin[1]^xor1^inW1;
|
||||
l2cn(tout0,tout1,out,l+8);
|
||||
@ -195,7 +183,7 @@ int encrypt;
|
||||
xor1=tin1;
|
||||
}
|
||||
|
||||
iv=(unsigned char *)ivec;
|
||||
iv = &(*ivec)[0];
|
||||
l2c(xor0,iv);
|
||||
l2c(xor1,iv);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
des_read_password, des_read_2password,
|
||||
des_string_to_key, des_string_to_2key, des_read_pw_string,
|
||||
des_random_key, des_set_key,
|
||||
des_key_sched, des_ecb_encrypt, des_3ecb_encrypt, des_cbc_encrypt,
|
||||
des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt,
|
||||
des_3cbc_encrypt,
|
||||
des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt,
|
||||
des_cbc_cksum, des_quad_cksum,
|
||||
@ -56,7 +56,7 @@ des_cblock *output;
|
||||
des_key_schedule schedule;
|
||||
int encrypt;
|
||||
.PP
|
||||
.B int des_3ecb_encrypt(input,output,ks1,ks2,encrypt)
|
||||
.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt)
|
||||
des_cblock *input;
|
||||
des_cblock *output;
|
||||
des_key_schedule ks1,ks2;
|
||||
@ -206,7 +206,7 @@ converts a string into a valid des key.
|
||||
.I des_string_to_2key
|
||||
converts a string into 2 valid des keys.
|
||||
This routine is best suited for used to generate keys for use with
|
||||
.I des_3ecb_encrypt.
|
||||
.I des_ecb3_encrypt.
|
||||
.PP
|
||||
.I des_random_key
|
||||
returns a random key that is made of a combination of process id,
|
||||
@ -274,7 +274,7 @@ is decrypted into the
|
||||
Input and output may overlap.
|
||||
No meaningful value is returned.
|
||||
.PP
|
||||
.I des_3ecb_encrypt
|
||||
.I des_ecb3_encrypt
|
||||
encrypts/decrypts the
|
||||
.I input
|
||||
block by using triple ecb DES encryption.
|
||||
@ -505,4 +505,4 @@ general cryptographic library that amonst other things implements
|
||||
netscapes SSL protocoll. The most recent version can be found in
|
||||
SSLeay distributions.
|
||||
.SH AUTHOR
|
||||
Eric Young (eay@mincom.oz.au or eay@psych.psy.uq.oz.au)
|
||||
Eric Young (eay@cryptsoft.com)
|
||||
|
Loading…
Reference in New Issue
Block a user