diff options
Diffstat (limited to 'crypto/des')
-rw-r--r-- | crypto/des/INSTALL | 2 | ||||
-rw-r--r-- | crypto/des/Makefile.ssl | 296 | ||||
-rw-r--r-- | crypto/des/asm/.cvsignore | 2 | ||||
-rw-r--r-- | crypto/des/asm/crypt586.pl | 5 | ||||
-rw-r--r-- | crypto/des/asm/des-586.pl | 274 | ||||
-rw-r--r-- | crypto/des/asm/des686.pl | 230 | ||||
-rw-r--r-- | crypto/des/asm/des_enc.m4 | 343 | ||||
-rw-r--r-- | crypto/des/cfb_enc.c | 4 | ||||
-rw-r--r-- | crypto/des/des-lib.com | 62 | ||||
-rw-r--r-- | crypto/des/des.h | 3 | ||||
-rw-r--r-- | crypto/des/des_enc.c | 17 | ||||
-rw-r--r-- | crypto/des/des_locl.h | 8 | ||||
-rw-r--r-- | crypto/des/des_old.c | 2 | ||||
-rw-r--r-- | crypto/des/des_old.h | 9 | ||||
-rw-r--r-- | crypto/des/des_ver.h | 4 | ||||
-rw-r--r-- | crypto/des/destest.c | 2 | ||||
-rw-r--r-- | crypto/des/ecb_enc.c | 7 | ||||
-rw-r--r-- | crypto/des/enc_read.c | 14 | ||||
-rw-r--r-- | crypto/des/enc_writ.c | 8 | ||||
-rw-r--r-- | crypto/des/fcrypt_b.c | 4 | ||||
-rw-r--r-- | crypto/des/set_key.c | 6 | ||||
-rw-r--r-- | crypto/des/times/usparc.cc | 2 | ||||
-rw-r--r-- | crypto/des/xcbc_enc.c | 6 |
23 files changed, 570 insertions, 740 deletions
diff --git a/crypto/des/INSTALL b/crypto/des/INSTALL index 32457d775c..8aebdfe110 100644 --- a/crypto/des/INSTALL +++ b/crypto/des/INSTALL @@ -25,7 +25,7 @@ and then you can use the 'DES_PTR' option. The file options.txt has the options listed for best speed on quite a few systems. Look and the options (UNROLL, PTR, RISC2 etc) and then -turn on the relevent option in the Makefile +turn on the relevant option in the Makefile. There are some special Makefile targets that make life easier. make cc - standard cc build diff --git a/crypto/des/Makefile.ssl b/crypto/des/Makefile.ssl deleted file mode 100644 index a0c1baa8ab..0000000000 --- a/crypto/des/Makefile.ssl +++ /dev/null @@ -1,296 +0,0 @@ -# -# SSLeay/crypto/des/Makefile -# - -DIR= des -TOP= ../.. -CC= cc -CPP= $(CC) -E -INCLUDES=-I$(TOP) -I../../include -CFLAG=-g -INSTALL_PREFIX= -OPENSSLDIR= /usr/local/ssl -INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl -MAKEDEPPROG= makedepend -MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) -MAKEFILE= Makefile.ssl -AR= ar r -RANLIB= ranlib -DES_ENC= des_enc.o fcrypt_b.o -# or use -#DES_ENC= dx86-elf.o yx86-elf.o - -CFLAGS= $(INCLUDES) $(CFLAG) -ASFLAGS= $(INCLUDES) $(ASFLAG) -AFLAGS= $(ASFLAGS) - -GENERAL=Makefile -TEST=destest.c -APPS= - -LIB=$(TOP)/libcrypto.a -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 rpc_enc.c set_key.c \ - des_enc.c fcrypt_b.c \ - xcbc_enc.c \ - str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c \ - read2pwd.c - -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 ofb64enc.o \ - ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ - ${DES_ENC} \ - fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \ - ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o - -SRC= $(LIBSRC) - -EXHEADER= des.h des_old.h -HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER) - -ALL= $(GENERAL) $(SRC) $(HEADER) - -top: - (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) - -all: lib - -lib: $(LIBOBJ) - $(AR) $(LIB) $(LIBOBJ) - $(RANLIB) $(LIB) || echo Never mind. - @touch lib - -des: des.o cbc3_enc.o lib - $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB) - -des_enc-sparc.S: asm/des_enc.m4 - m4 -B 8192 asm/des_enc.m4 > des_enc-sparc.S - -# ELF -dx86-elf.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl - (cd asm; $(PERL) des-586.pl elf $(CFLAGS) > ../$@) -yx86-elf.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl - (cd asm; $(PERL) crypt586.pl elf $(CFLAGS) > ../$@) -# COFF -dx86-cof.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl - (cd asm; $(PERL) des-586.pl coff $(CFLAGS) > ../$@) -yx86-cof.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl - (cd asm; $(PERL) crypt586.pl coff $(CFLAGS) > ../$@) -# a.out -dx86-out.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl - (cd asm; $(PERL) des-586.pl a.out $(CFLAGS) > ../$@) -yx86-out.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl - (cd asm; $(PERL) crypt586.pl a.out $(CFLAGS) > ../$@) - -files: - $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO - -links: - @sh $(TOP)/util/point.sh Makefile.ssl Makefile - @$(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: - @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ - do \ - (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ - chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ - done; - -tags: - ctags $(SRC) - -tests: - -lint: - lint -DLINT $(INCLUDES) $(SRC)>fluff - -depend: - $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) - -dclean: - $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new - mv -f Makefile.new $(MAKEFILE) - -clean: - rm -f *.s *.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/des_old.h -cbc_cksm.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -cbc_cksm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -cbc_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -cbc_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -cbc_cksm.o: cbc_cksm.c des_locl.h -cbc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -cbc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -cbc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -cbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -cbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -cbc_enc.o: cbc_enc.c des_locl.h ncbc_enc.c -cfb64ede.o: ../../e_os.h ../../include/openssl/des.h -cfb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h -cfb64ede.o: ../../include/openssl/opensslconf.h -cfb64ede.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -cfb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -cfb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -cfb64ede.o: cfb64ede.c des_locl.h -cfb64enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -cfb64enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -cfb64enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -cfb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -cfb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -cfb64enc.o: cfb64enc.c des_locl.h -cfb_enc.o: ../../e_os.h ../../include/openssl/des.h -cfb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h -cfb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/ossl_typ.h -cfb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -cfb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -cfb_enc.o: ../../include/openssl/ui_compat.h cfb_enc.c des_locl.h -des_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -des_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -des_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -des_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -des_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -des_enc.o: des_enc.c des_locl.h ncbc_enc.c -des_old.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -des_old.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -des_old.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h -des_old.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -des_old.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -des_old.o: ../../include/openssl/ui_compat.h des_old.c -des_old2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -des_old2.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -des_old2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h -des_old2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -des_old2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -des_old2.o: ../../include/openssl/ui_compat.h des_old2.c -ecb3_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -ecb3_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -ecb3_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -ecb3_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -ecb3_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -ecb3_enc.o: des_locl.h ecb3_enc.c -ecb_enc.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h -ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -ecb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -ecb_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h -ecb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -ecb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -ecb_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h ecb_enc.c -ecb_enc.o: spr.h -ede_cbcm_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -ede_cbcm_enc.o: ../../include/openssl/e_os2.h -ede_cbcm_enc.o: ../../include/openssl/opensslconf.h -ede_cbcm_enc.o: ../../include/openssl/ossl_typ.h -ede_cbcm_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -ede_cbcm_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -ede_cbcm_enc.o: ../../include/openssl/ui_compat.h des_locl.h ede_cbcm_enc.c -enc_read.o: ../../e_os.h ../../include/openssl/bio.h -enc_read.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -enc_read.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -enc_read.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -enc_read.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h -enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h -enc_read.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -enc_read.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -enc_read.o: ../../include/openssl/ui_compat.h ../cryptlib.h des_locl.h -enc_read.o: enc_read.c -enc_writ.o: ../../e_os.h ../../include/openssl/bio.h -enc_writ.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -enc_writ.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -enc_writ.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -enc_writ.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h -enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h -enc_writ.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h -enc_writ.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -enc_writ.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -enc_writ.o: ../cryptlib.h des_locl.h enc_writ.c -fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -fcrypt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -fcrypt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -fcrypt.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -fcrypt.o: des_locl.h fcrypt.c -fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -fcrypt_b.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -fcrypt_b.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -fcrypt_b.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -fcrypt_b.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -fcrypt_b.o: des_locl.h fcrypt_b.c -ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -ofb64ede.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -ofb64ede.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -ofb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -ofb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -ofb64ede.o: des_locl.h ofb64ede.c -ofb64enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -ofb64enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -ofb64enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -ofb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -ofb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -ofb64enc.o: des_locl.h ofb64enc.c -ofb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -ofb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -ofb_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -ofb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -ofb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -ofb_enc.o: des_locl.h ofb_enc.c -pcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -pcbc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -pcbc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -pcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -pcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -pcbc_enc.o: des_locl.h pcbc_enc.c -qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -qud_cksm.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -qud_cksm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -qud_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -qud_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -qud_cksm.o: des_locl.h qud_cksm.c -rand_key.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -rand_key.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -rand_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h -rand_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -rand_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -rand_key.o: ../../include/openssl/ui_compat.h rand_key.c -read2pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h -read2pwd.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h -read2pwd.o: ../../include/openssl/opensslconf.h -read2pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h -read2pwd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -read2pwd.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h -read2pwd.o: ../../include/openssl/ui_compat.h read2pwd.c -rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -rpc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -rpc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -rpc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -rpc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -rpc_enc.o: des_locl.h des_ver.h rpc_des.h rpc_enc.c -set_key.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -set_key.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -set_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -set_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -set_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -set_key.o: des_locl.h set_key.c -str2key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h -str2key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h -str2key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -str2key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -str2key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -str2key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -str2key.o: des_locl.h str2key.c -xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h -xcbc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h -xcbc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h -xcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -xcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h -xcbc_enc.o: des_locl.h xcbc_enc.c diff --git a/crypto/des/asm/.cvsignore b/crypto/des/asm/.cvsignore index c8436379e4..b92f40163e 100644 --- a/crypto/des/asm/.cvsignore +++ b/crypto/des/asm/.cvsignore @@ -3,3 +3,5 @@ yx86unix.cpp des_enc-sparc.S dx86-elf.s yx86-elf.s +*.flc +semantic.cache diff --git a/crypto/des/asm/crypt586.pl b/crypto/des/asm/crypt586.pl index 1d04ed6def..e36f7d44bd 100644 --- a/crypto/des/asm/crypt586.pl +++ b/crypto/des/asm/crypt586.pl @@ -6,7 +6,8 @@ # things perfect. # -push(@INC,"perlasm","../../perlasm"); +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +push(@INC,"${dir}","${dir}../../perlasm"); require "x86asm.pl"; &asm_init($ARGV[0],"crypt586.pl"); @@ -22,7 +23,7 @@ sub fcrypt_body { local($name,$do_ip)=@_; - &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); + &function_begin($name); &comment(""); &comment("Load the 2 words"); diff --git a/crypto/des/asm/des-586.pl b/crypto/des/asm/des-586.pl index b75d3c6b3a..5b5f39cebd 100644 --- a/crypto/des/asm/des-586.pl +++ b/crypto/des/asm/des-586.pl @@ -4,7 +4,8 @@ # Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> # -push(@INC,"perlasm","../../perlasm"); +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +push(@INC,"${dir}","${dir}../../perlasm"); require "x86asm.pl"; require "cbc.pl"; require "desboth.pl"; @@ -18,29 +19,110 @@ require "desboth.pl"; $L="edi"; $R="esi"; +$trans="ebp"; +$small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV)); +# one can discuss setting this variable to 1 unconditionally, as +# the folded loop is only 3% slower than unrolled, but >7 times smaller -&external_label("DES_SPtrans"); +&public_label("DES_SPtrans"); + +&DES_encrypt_internal(); +&DES_decrypt_internal(); &DES_encrypt("DES_encrypt1",1); &DES_encrypt("DES_encrypt2",0); &DES_encrypt3("DES_encrypt3",1); &DES_encrypt3("DES_decrypt3",0); &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); +&DES_SPtrans(); &asm_finish(); +sub DES_encrypt_internal() + { + &function_begin_B("_x86_DES_encrypt"); + + if ($small_footprint) + { + &lea("edx",&DWP(128,"ecx")); + &push("edx"); + &push("ecx"); + &set_label("eloop"); + &D_ENCRYPT(0,$L,$R,0,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + &comment(""); + &D_ENCRYPT(1,$R,$L,2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + &comment(""); + &add("ecx",16); + &cmp("ecx",&swtmp(1)); + &mov(&swtmp(0),"ecx"); + &jb(&label("eloop")); + &add("esp",8); + } + else + { + &push("ecx"); + for ($i=0; $i<16; $i+=2) + { + &comment("Round $i"); + &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + &comment("Round ".sprintf("%d",$i+1)); + &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + } + &add("esp",4); + } + &ret(); + + &function_end_B("_x86_DES_encrypt"); + } + +sub DES_decrypt_internal() + { + &function_begin_B("_x86_DES_decrypt"); + + if ($small_footprint) + { + &push("ecx"); + &lea("ecx",&DWP(128,"ecx")); + &push("ecx"); + &set_label("dloop"); + &D_ENCRYPT(0,$L,$R,-2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + &comment(""); + &D_ENCRYPT(1,$R,$L,-4,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + &comment(""); + &sub("ecx",16); + &cmp("ecx",&swtmp(1)); + &mov(&swtmp(0),"ecx"); + &ja(&label("dloop")); + &add("esp",8); + } + else + { + &push("ecx"); + for ($i=15; $i>0; $i-=2) + { + &comment("Round $i"); + &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + &comment("Round ".sprintf("%d",$i-1)); + &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); + } + &add("esp",4); + } + &ret(); + + &function_end_B("_x86_DES_decrypt"); + } + sub DES_encrypt { local($name,$do_ip)=@_; - &function_begin_B($name,"EXTRN _DES_SPtrans:DWORD"); + &function_begin_B($name); &push("esi"); &push("edi"); &comment(""); &comment("Load the 2 words"); - $trans="ebp"; if ($do_ip) { @@ -73,39 +155,20 @@ sub DES_encrypt } # PIC-ification:-) - &picmeup($trans,"DES_SPtrans"); - #if ($cpp) { &picmeup($trans,"DES_SPtrans"); } - #else { &lea($trans,&DWP("DES_SPtrans")); } + &call (&label("pic_point")); + &set_label("pic_point"); + &blindpop($trans); + &lea ($trans,&DWP(&label("DES_SPtrans")."-".&label("pic_point"),$trans)); &mov( "ecx", &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,$trans,"eax","ebx","ecx","edx"); - - &comment(""); - &comment("Round ".sprintf("%d",$i+1)); - &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"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,$trans,"eax","ebx","ecx","edx"); - &comment(""); - &comment("Round ".sprintf("%d",$i-1)); - &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx"); - } - - &set_label("end"); + &cmp("ebx","0"); + &je(&label("decrypt")); + &call("_x86_DES_encrypt"); + &jmp(&label("done")); + &set_label("decrypt"); + &call("_x86_DES_decrypt"); + &set_label("done"); if ($do_ip) { @@ -139,7 +202,7 @@ sub DES_encrypt sub D_ENCRYPT { - local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_; + local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t,$wp1)=@_; &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0)); &xor( $tmp1, $tmp1); @@ -166,7 +229,7 @@ sub D_ENCRYPT &and( $t, "0xff" ); &xor( $L, &DWP("0x600",$trans,$tmp1,0)); &xor( $L, &DWP("0x700",$trans,$tmp2,0)); - &mov( $tmp2, &wparam(1) ); + &mov( $tmp2, $wp1 ); &xor( $L, &DWP("0x400",$trans,$u,0)); &xor( $L, &DWP("0x500",$trans,$t,0)); } @@ -249,3 +312,142 @@ sub FP_new &rotr($tt , 4); } +sub DES_SPtrans + { + &set_label("DES_SPtrans",64); + &data_word(0x02080800, 0x00080000, 0x02000002, 0x02080802); + &data_word(0x02000000, 0x00080802, 0x00080002, 0x02000002); + &data_word(0x00080802, 0x02080800, 0x02080000, 0x00000802); + &data_word(0x02000802, 0x02000000, 0x00000000, 0x00080002); + &data_word(0x00080000, 0x00000002, 0x02000800, 0x00080800); + &data_word(0x02080802, 0x02080000, 0x00000802, 0x02000800); + &data_word(0x00000002, 0x00000800, 0x00080800, 0x02080002); + &data_word(0x00000800, 0x02000802, 0x02080002, 0x00000000); + &data_word(0x00000000, 0x02080802, 0x02000800, 0x00080002); + &data_word(0x02080800, 0x00080000, 0x00000802, 0x02000800); + &data_word(0x02080002, 0x00000800, 0x00080800, 0x02000002); + &data_word(0x00080802, 0x00000002, 0x02000002, 0x02080000); + &data_word(0x02080802, 0x00080800, 0x02080000, 0x02000802); + &data_word(0x02000000, 0x00000802, 0x00080002, 0x00000000); + &data_word(0x00080000, 0x02000000, 0x02000802, 0x02080800); + &data_word(0x00000002, 0x02080002, 0x00000800, 0x00080802); + # nibble 1 + &data_word(0x40108010, 0x00000000, 0x00108000, 0x40100000); + &data_word(0x40000010, 0x00008010, 0x40008000, 0x00108000); + &data_word(0x00008000, 0x40100010, 0x00000010, 0x40008000); + &data_word(0x00100010, 0x40108000, 0x40100000, 0x00000010); + &data_word(0x00100000, 0x40008010, 0x40100010, 0x00008000); + &data_word(0x00108010, 0x40000000, 0x00000000, 0x00100010); + &data_word(0x40008010, 0x00108010, 0x40108000, 0x40000010); + &data_word(0x40000000, 0x00100000, 0x00008010, 0x40108010); + &data_word(0x00100010, 0x40108000, 0x40008000, 0x00108010); + &data_word(0x40108010, 0x00100010, 0x40000010, 0x00000000); + &data_word(0x40000000, 0x00008010, 0x00100000, 0x40100010); + &data_word(0x00008000, 0x40000000, 0x00108010, 0x40008010); + &data_word(0x40108000, 0x00008000, 0x00000000, 0x40000010); + &data_word(0x00000010, 0x40108010, 0x00108000, 0x40100000); + &data_word(0x40100010, 0x00100000, 0x00008010, 0x40008000); + &data_word(0x40008010, 0x00000010, 0x40100000, 0x00108000); + # nibble 2 + &data_word(0x04000001, 0x04040100, 0x00000100, 0x04000101); + &data_word(0x00040001, 0x04000000, 0x04000101, 0x00040100); + &data_word(0x04000100, 0x00040000, 0x04040000, 0x00000001); + &data_word(0x04040101, 0x00000101, 0x00000001, 0x04040001); + &data_word(0x00000000, 0x00040001, 0x04040100, 0x00000100); + &data_word(0x00000101, 0x04040101, 0x00040000, 0x04000001); + &data_word(0x04040001, 0x04000100, 0x00040101, 0x04040000); + &data_word(0x00040100, 0x00000000, 0x04000000, 0x00040101); + &data_word(0x04040100, 0x00000100, 0x00000001, 0x00040000); + &data_word(0x00000101, 0x00040001, 0x04040000, 0x04000101); + &data_word(0x00000000, 0x04040100, 0x00040100, 0x04040001); + &data_word(0x00040001, 0x04000000, 0x04040101, 0x00000001); + &data_word(0x00040101, 0x04000001, 0x04000000, 0x04040101); + &data_word(0x00040000, 0x04000100, 0x04000101, 0x00040100); + &data_word(0x04000100, 0x00000000, 0x04040001, 0x00000101); + &data_word(0x04000001, 0x00040101, 0x00000100, 0x04040000); + # nibble 3 + &data_word(0x00401008, 0x10001000, 0x00000008, 0x10401008); + &data_word(0x00000000, 0x10400000, 0x10001008, 0x00400008); + &data_word(0x10401000, 0x10000008, 0x10000000, 0x00001008); + &data_word(0x10000008, 0x00401008, 0x00400000, 0x10000000); + &data_word(0x10400008, 0x00401000, 0x00001000, 0x00000008); + &data_word(0x00401000, 0x10001008, 0x10400000, 0x00001000); + &data_word(0x00001008, 0x00000000, 0x00400008, 0x10401000); + &data_word(0x10001000, 0x10400008, 0x10401008, 0x00400000); + &data_word(0x10400008, 0x00001008, 0x00400000, 0x10000008); + &data_word(0x00401000, 0x10001000, 0x00000008, 0x10400000); + &data_word(0x10001008, 0x00000000, 0x00001000, 0x00400008); + &data_word(0x00000000, 0x10400008, 0x10401000, 0x00001000); + &data_word(0x10000000, 0x10401008, 0x00401008, 0x00400000); + &data_word(0x10401008, 0x00000008, 0x10001000, 0x00401008); + &data_word(0x00400008, 0x00401000, 0x10400000, 0x10001008); + &data_word(0x00001008, 0x10000000, 0x10000008, 0x10401000); + # nibble 4 + &data_word(0x08000000, 0x00010000, 0x00000400, 0x08010420); + &data_word(0x08010020, 0x08000400, 0x00010420, 0x08010000); + &data_word(0x00010000, 0x00000020, 0x08000020, 0x00010400); + &data_word(0x08000420, 0x08010020, 0x08010400, 0x00000000); + &data_word(0x00010400, 0x08000000, 0x00010020, 0x00000420); + &data_word(0x08000400, 0x00010420, 0x00000000, 0x08000020); + &data_word(0x00000020, 0x08000420, 0x08010420, 0x00010020); + &data_word(0x08010000, 0x00000400, 0x00000420, 0x08010400); + &data_word(0x08010400, 0x08000420, 0x00010020, 0x08010000); + &data_word(0x00010000, 0x00000020, 0x08000020, 0x08000400); + &data_word(0x08000000, 0x00010400, 0x08010420, 0x00000000); + &data_word(0x00010420, 0x08000000, 0x00000400, 0x00010020); + &data_word(0x08000420, 0x00000400, 0x00000000, 0x08010420); + &data_word(0x08010020, 0x08010400, 0x00000420, 0x00010000); + &data_word(0x00010400, 0x08010020, 0x08000400, 0x00000420); + &data_word(0x00000020, 0x00010420, 0x08010000, 0x08000020); + # nibble 5 + &data_word(0x80000040, 0x00200040, 0x00000000, 0x80202000); + &data_word(0x00200040, 0x00002000, 0x80002040, 0x00200000); + &data_word(0x00002040, 0x80202040, 0x00202000, 0x80000000); + &data_word(0x80002000, 0x80000040, 0x80200000, 0x00202040); + &data_word(0x00200000, 0x80002040, 0x80200040, 0x00000000); + &data_word(0x00002000, 0x00000040, 0x80202000, 0x80200040); + &data_word(0x80202040, 0x80200000, 0x80000000, 0x00002040); + &data_word(0x00000040, 0x00202000, 0x00202040, 0x80002000); + &data_word(0x00002040, 0x80000000, 0x80002000, 0x00202040); + &data_word(0x80202000, 0x00200040, 0x00000000, 0x80002000); + &data_word(0x80000000, 0x00002000, 0x80200040, 0x00200000); + &data_word(0x00200040, 0x80202040, 0x00202000, 0x00000040); + &data_word(0x80202040, 0x00202000, 0x00200000, 0x80002040); + &data_word(0x80000040, 0x80200000, 0x00202040, 0x00000000); + &data_word(0x00002000, 0x80000040, 0x80002040, 0x80202000); + &data_word(0x80200000, 0x00002040, 0x00000040, 0x80200040); + # nibble 6 + &data_word(0x00004000, 0x00000200, 0x01000200, 0x01000004); + &data_word(0x01004204, 0x00004004, 0x00004200, 0x00000000); + &data_word(0x01000000, 0x01000204, 0x00000204, 0x01004000); + &data_word(0x00000004, 0x01004200, 0x01004000, 0x00000204); + &data_word(0x01000204, 0x00004000, 0x00004004, 0x01004204); + &data_word(0x00000000, 0x01000200, 0x01000004, 0x00004200); + &data_word(0x01004004, 0x00004204, 0x01004200, 0x00000004); + &data_word(0x00004204, 0x01004004, 0x00000200, 0x01000000); + &data_word(0x00004204, 0x01004000, 0x01004004, 0x00000204); + &data_word(0x00004000, 0x00000200, 0x01000000, 0x01004004); + &data_word(0x01000204, 0x00004204, 0x00004200, 0x00000000); + &data_word(0x00000200, 0x01000004, 0x00000004, 0x01000200); + &data_word(0x00000000, 0x01000204, 0x01000200, 0x00004200); + &data_word(0x00000204, 0x00004000, 0x01004204, 0x01000000); + &data_word(0x01004200, 0x00000004, 0x00004004, 0x01004204); + &data_word(0x01000004, 0x01004200, 0x01004000, 0x00004004); + # nibble 7 + &data_word(0x20800080, 0x20820000, 0x00020080, 0x00000000); + &data_word(0x20020000, 0x00800080, 0x20800000, 0x20820080); + &data_word(0x00000080, 0x20000000, 0x00820000, 0x00020080); + &data_word(0x00820080, 0x20020080, 0x20000080, 0x20800000); + &data_word(0x00020000, 0x00820080, 0x00800080, 0x20020000); + &data_word(0x20820080, 0x20000080, 0x00000000, 0x00820000); + &data_word(0x20000000, 0x00800000, 0x20020080, 0x20800080); + &data_word(0x00800000, 0x00020000, 0x20820000, 0x00000080); + &data_word(0x00800000, 0x00020000, 0x20000080, 0x20820080); + &data_word(0x00020080, 0x20000000, 0x00000000, 0x00820000); + &data_word(0x20800080, 0x20020080, 0x20020000, 0x00800080); + &data_word(0x20820000, 0x00000080, 0x00800080, 0x20020000); + &data_word(0x20820080, 0x00800000, 0x20800000, 0x20000080); + &data_word(0x00820000, 0x00020080, 0x20020080, 0x20800000); + &data_word(0x00000080, 0x20820000, 0x00820080, 0x00000000); + &data_word(0x20000000, 0x20800080, 0x00020000, 0x00820080); + } diff --git a/crypto/des/asm/des686.pl b/crypto/des/asm/des686.pl deleted file mode 100644 index d3ad5d5edd..0000000000 --- a/crypto/des/asm/des686.pl +++ /dev/null @@ -1,230 +0,0 @@ -#!/usr/local/bin/perl - -$prog="des686.pl"; - -# base code is in microsft -# op dest, source -# format. -# - -# WILL NOT WORK ANYMORE WITH desboth.pl -require "desboth.pl"; - -if ( ($ARGV[0] eq "elf")) - { require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "a.out")) - { $aout=1; require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "sol")) - { $sol=1; require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "cpp")) - { $cpp=1; require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "win32")) - { require "x86ms.pl"; } -else - { - print STDERR <<"EOF"; -Pick one target type from - elf - linux, FreeBSD etc - a.out - old linux - sol - x86 solaris - cpp - format so x86unix.cpp can be used - win32 - Windows 95/Windows NT -EOF - exit(1); - } - -&comment("Don't even think of reading this code"); -&comment("It was automatically generated by $prog"); -&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\@cryptsoft.com>"); -&comment(""); - -&file("dx86xxxx"); - -$L="edi"; -$R="esi"; - -&DES_encrypt("DES_encrypt1",1); -&DES_encrypt("DES_encrypt2",0); - -&DES_encrypt3("DES_encrypt3",1); -&DES_encrypt3("DES_decrypt3",0); - -&file_end(); - -sub DES_encrypt - { - local($name,$do_ip)=@_; - - &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); - - &comment(""); - &comment("Load the 2 words"); - &mov("eax",&wparam(0)); - &mov($L,&DWP(0,"eax","",0)); - &mov($R,&DWP(4,"eax","",0)); - - $ksp=&wparam(1); - - if ($do_ip) - { - &comment(""); - &comment("IP"); - &IP_new($L,$R,"eax"); - } - - &comment(""); - &comment("fixup rotate"); - &rotl($R,3); - &rotl($L,3); - &exch($L,$R); - - &comment(""); - &comment("load counter, key_schedule and enc flag"); - &mov("eax",&wparam(2)); # get encrypt flag - &mov("ebp",&wparam(1)); # get ks - &cmp("eax","0"); - &je(&label("start_decrypt")); - - # encrypting part - - for ($i=0; $i<16; $i+=2) - { - &comment(""); - &comment("Round $i"); - &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); - - &comment(""); - &comment("Round ".sprintf("%d",$i+1)); - &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); - } - &jmp(&label("end")); - - &set_label("start_decrypt"); - - for ($i=15; $i>0; $i-=2) - { - &comment(""); - &comment("Round $i"); - &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); - &comment(""); - &comment("Round ".sprintf("%d",$i-1)); - &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); - } - - &set_label("end"); - - &comment(""); - &comment("Fixup"); - &rotr($L,3); # r - &rotr($R,3); # l - - if ($do_ip) - { - &comment(""); - &comment("FP"); - &FP_new($R,$L,"eax"); - } - - &mov("eax",&wparam(0)); - &mov(&DWP(0,"eax","",0),$L); - &mov(&DWP(4,"eax","",0),$R); - - &function_end($name); - } - - -# The logic is to load R into 2 registers and operate on both at the same time. -# We also load the 2 R's into 2 more registers so we can do the 'move word down a byte' -# while also masking the other copy and doing a lookup. We then also accumulate the -# L value in 2 registers then combine them at the end. -sub D_ENCRYPT - { - local($L,$R,$S,$ks,$desSP,$u,$t,$tmp1,$tmp2,$tmp3)=@_; - - &mov( $u, &DWP(&n2a($S*4),$ks,"",0)); - &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0)); - &xor( $u, $R ); - &xor( $t, $R ); - &rotr( $t, 4 ); - - # the numbers at the end of the line are origional instruction order - &mov( $tmp2, $u ); # 1 2 - &mov( $tmp1, $t ); # 1 1 - &and( $tmp2, "0xfc" ); # 1 4 - &and( $tmp1, "0xfc" ); # 1 3 - &shr( $t, 8 ); # 1 5 - &xor( $L, &DWP("0x100+$desSP",$tmp1,"",0)); # 1 7 - &shr( $u, 8 ); # 1 6 - &mov( $tmp1, &DWP(" $desSP",$tmp2,"",0)); # 1 8 - - &mov( $tmp2, $u ); # 2 2 - &xor( $L, $tmp1 ); # 1 9 - &and( $tmp2, "0xfc" ); # 2 4 - &mov( $tmp1, $t ); # 2 1 - &and( $tmp1, "0xfc" ); # 2 3 - &shr( $t, 8 ); # 2 5 - &xor( $L, &DWP("0x300+$desSP",$tmp1,"",0)); # 2 7 - &shr( $u, 8 ); # 2 6 - &mov( $tmp1, &DWP("0x200+$desSP",$tmp2,"",0)); # 2 8 - &mov( $tmp2, $u ); # 3 2 - - &xor( $L, $tmp1 ); # 2 9 - &and( $tmp2, "0xfc" ); # 3 4 - - &mov( $tmp1, $t ); # 3 1 - &shr( $u, 8 ); # 3 6 - &and( $tmp1, "0xfc" ); # 3 3 - &shr( $t, 8 ); # 3 5 - &xor( $L, &DWP("0x500+$desSP",$tmp1,"",0)); # 3 7 - &mov( $tmp1, &DWP("0x400+$desSP",$tmp2,"",0)); # 3 8 - - &and( $t, "0xfc" ); # 4 1 - &xor( $L, $tmp1 ); # 3 9 - - &and( $u, "0xfc" ); # 4 2 - &xor( $L, &DWP("0x700+$desSP",$t,"",0)); # 4 3 - &xor( $L, &DWP("0x600+$desSP",$u,"",0)); # 4 4 - } - -sub PERM_OP - { - local($a,$b,$tt,$shift,$mask)=@_; - - &mov( $tt, $a ); - &shr( $tt, $shift ); - &xor( $tt, $b ); - &and( $tt, $mask ); - &xor( $b, $tt ); - &shl( $tt, $shift ); - &xor( $a, $tt ); - } - -sub IP_new - { - local($l,$r,$tt)=@_; - - &PERM_OP($r,$l,$tt, 4,"0x0f0f0f0f"); - &PERM_OP($l,$r,$tt,16,"0x0000ffff"); - &PERM_OP($r,$l,$tt, 2,"0x33333333"); - &PERM_OP($l,$r,$tt, 8,"0x00ff00ff"); - &PERM_OP($r,$l,$tt, 1,"0x55555555"); - } - -sub FP_new - { - local($l,$r,$tt)=@_; - - &PERM_OP($l,$r,$tt, 1,"0x55555555"); - &PERM_OP($r,$l,$tt, 8,"0x00ff00ff"); - &PERM_OP($l,$r,$tt, 2,"0x33333333"); - &PERM_OP($r,$l,$tt,16,"0x0000ffff"); - &PERM_OP($l,$r,$tt, 4,"0x0f0f0f0f"); - } - -sub n2a - { - sprintf("%d",$_[0]); - } diff --git a/crypto/des/asm/des_enc.m4 b/crypto/des/asm/des_enc.m4 index 8dccf46256..3280595478 100644 --- a/crypto/des/asm/des_enc.m4 +++ b/crypto/des/asm/des_enc.m4 @@ -43,7 +43,8 @@ ! 100% faster than gcc-3.2.1 -m64 -mcpu=ultrasparc -O5 ! -.ident "des_enc.m4 2.0" +.ident "des_enc.m4 2.1" +.file "des_enc-sparc.S" #if defined(__SUNPRO_C) && defined(__sparcv9) # define ABI64 /* They've said -xarch=v9 at command line */ @@ -315,16 +316,16 @@ $4: ld [global1+local1], local1 xor $2, out1, out1 ! 8642 xor $2, out0, out0 ! 7531 - fmovs %f0, %f0 ! fxor used for alignment + ! fmovs %f0, %f0 ! fxor used for alignment srl out1, 4, local0 ! rotate 4 right and out0, local5, local3 ! 3 - fmovs %f0, %f0 + ! fmovs %f0, %f0 ld [$5+$3*8], local7 ! key 7531 next round srl local3, 8, local3 ! 3 and local0, 252, local2 ! 2 - fmovs %f0, %f0 + ! fmovs %f0, %f0 ld [global3+local3],local3 ! 3 sll out1, 28, out1 ! rotate @@ -1179,8 +1180,11 @@ DES_encrypt1: save %sp, FRAME, %sp - call .PIC.me.up - mov .PIC.me.up-(.-4),out0 + sethi %hi(.PIC.DES_SPtrans-1f),global1 + or global1,%lo(.PIC.DES_SPtrans-1f),global1 +1: call .+8 + add %o7,global1,global1 + sub global1,.PIC.DES_SPtrans-.des_and,out2 ld [in0], in5 ! left cmp in2, 0 ! enc @@ -1237,8 +1241,11 @@ DES_encrypt2: save %sp, FRAME, %sp - call .PIC.me.up - mov .PIC.me.up-(.-4),out0 + sethi %hi(.PIC.DES_SPtrans-1f),global1 + or global1,%lo(.PIC.DES_SPtrans-1f),global1 +1: call .+8 + add %o7,global1,global1 + sub global1,.PIC.DES_SPtrans-.des_and,out2 ! Set sbox address 1 to 6 and rotate halfs 3 left ! Errors caught by destest? Yes. Still? *NO* @@ -1352,8 +1359,11 @@ DES_encrypt3: save %sp, FRAME, %sp - call .PIC.me.up - mov .PIC.me.up-(.-4),out0 + sethi %hi(.PIC.DES_SPtrans-1f),global1 + or global1,%lo(.PIC.DES_SPtrans-1f),global1 +1: call .+8 + add %o7,global1,global1 + sub global1,.PIC.DES_SPtrans-.des_and,out2 ld [in0], in5 ! left add in2, 120, in4 ! ks2 @@ -1394,8 +1404,11 @@ DES_decrypt3: save %sp, FRAME, %sp - call .PIC.me.up - mov .PIC.me.up-(.-4),out0 + sethi %hi(.PIC.DES_SPtrans-1f),global1 + or global1,%lo(.PIC.DES_SPtrans-1f),global1 +1: call .+8 + add %o7,global1,global1 + sub global1,.PIC.DES_SPtrans-.des_and,out2 ld [in0], in5 ! left add in3, 120, in4 ! ks3 @@ -1424,99 +1437,6 @@ DES_decrypt3: .DES_decrypt3.end: .size DES_decrypt3,.DES_decrypt3.end-DES_decrypt3 -! input: out0 offset between .PIC.me.up and caller -! output: out0 pointer to .PIC.me.up -! out2 pointer to .des_and -! global1 pointer to DES_SPtrans - .align 32 -.PIC.me.up: - add out0,%o7,out0 ! pointer to .PIC.me.up - -#ifdef OPENSSL_PIC - ! In case anybody wonders why this code is same for both ABI. - ! To start with it is not. Do note LDPTR below. But of course - ! you must be wondering why the rest of it does not contain - ! things like %hh, %hm and %lm. Well, those are needed only - ! if OpenSSL library *itself* will become larger than 4GB, - ! which is not going to happen any time soon. - sethi %hi(DES_SPtrans),global1 - or global1,%lo(DES_SPtrans),global1 - sethi %hi(_GLOBAL_OFFSET_TABLE_-(.PIC.me.up-.)),out2 - add global1,out0,global1 - add out2,%lo(_GLOBAL_OFFSET_TABLE_-(.PIC.me.up-.)),out2 - LDPTR [out2+global1],global1 -#elif 0 - setn DES_SPtrans,out2,global1 ! synthetic instruction ! -#elif defined(ABI64) - sethi %hh(DES_SPtrans),out2 - or out2,%hm(DES_SPtrans),out2 - sethi %lm(DES_SPtrans),global1 - or global1,%lo(DES_SPtrans),global1 - sllx out2,32,out2 - or out2,global1,global1 -#else - sethi %hi(DES_SPtrans),global1 - or global1,%lo(DES_SPtrans),global1 -#endif - - retl - add out0,.des_and-.PIC.me.up,out2 - - .align 256 - .type .des_and,#object - .size .des_and,284 - -.des_and: - -! This table is used for AND 0xFC when it is known that register -! bits 8-31 are zero. Makes it possible to do three arithmetic -! operations in one cycle. - - .byte 0, 0, 0, 0, 4, 4, 4, 4 - .byte 8, 8, 8, 8, 12, 12, 12, 12 - .byte 16, 16, 16, 16, 20, 20, 20, 20 - .byte 24, 24, 24, 24, 28, 28, 28, 28 - .byte 32, 32, 32, 32, 36, 36, 36, 36 - .byte 40, 40, 40, 40, 44, 44, 44, 44 - .byte 48, 48, 48, 48, 52, 52, 52, 52 - .byte 56, 56, 56, 56, 60, 60, 60, 60 - .byte 64, 64, 64, 64, 68, 68, 68, 68 - .byte 72, 72, 72, 72, 76, 76, 76, 76 - .byte 80, 80, 80, 80, 84, 84, 84, 84 - .byte 88, 88, 88, 88, 92, 92, 92, 92 - .byte 96, 96, 96, 96, 100, 100, 100, 100 - .byte 104, 104, 104, 104, 108, 108, 108, 108 - .byte 112, 112, 112, 112, 116, 116, 116, 116 - .byte 120, 120, 120, 120, 124, 124, 124, 124 - .byte 128, 128, 128, 128, 132, 132, 132, 132 - .byte 136, 136, 136, 136, 140, 140, 140, 140 - .byte 144, 144, 144, 144, 148, 148, 148, 148 - .byte 152, 152, 152, 152, 156, 156, 156, 156 - .byte 160, 160, 160, 160, 164, 164, 164, 164 - .byte 168, 168, 168, 168, 172, 172, 172, 172 - .byte 176, 176, 176, 176, 180, 180, 180, 180 - .byte 184, 184, 184, 184, 188, 188, 188, 188 - .byte 192, 192, 192, 192, 196, 196, 196, 196 - .byte 200, 200, 200, 200, 204, 204, 204, 204 - .byte 208, 208, 208, 208, 212, 212, 212, 212 - .byte 216, 216, 216, 216, 220, 220, 220, 220 - .byte 224, 224, 224, 224, 228, 228, 228, 228 - .byte 232, 232, 232, 232, 236, 236, 236, 236 - .byte 240, 240, 240, 240, 244, 244, 244, 244 - .byte 248, 248, 248, 248, 252, 252, 252, 252 - - ! 5 numbers for initil/final permutation - - .word 0x0f0f0f0f ! offset 256 - .word 0x0000ffff ! 260 - .word 0x33333333 ! 264 - .word 0x00ff00ff ! 268 - .word 0x55555555 ! 272 - - .word 0 ! 276 - .word LOOPS ! 280 - .word 0x0000FC00 ! 284 - ! void DES_ncbc_encrypt(input, output, length, schedule, ivec, enc) ! ***************************************************************** @@ -1533,8 +1453,11 @@ DES_ncbc_encrypt: define({OUTPUT}, { [%sp+BIAS+ARG0+1*ARGSZ] }) define({IVEC}, { [%sp+BIAS+ARG0+4*ARGSZ] }) - call .PIC.me.up - mov .PIC.me.up-(.-4),out0 + sethi %hi(.PIC.DES_SPtrans-1f),global1 + or global1,%lo(.PIC.DES_SPtrans-1f),global1 +1: call .+8 + add %o7,global1,global1 + sub global1,.PIC.DES_SPtrans-.des_and,out2 cmp in5, 0 ! enc @@ -1755,8 +1678,11 @@ DES_ede3_cbc_encrypt: define({KS2}, { [%sp+BIAS+ARG0+4*ARGSZ] }) define({KS3}, { [%sp+BIAS+ARG0+5*ARGSZ] }) - call .PIC.me.up - mov .PIC.me.up-(.-4),out0 + sethi %hi(.PIC.DES_SPtrans-1f),global1 + or global1,%lo(.PIC.DES_SPtrans-1f),global1 +1: call .+8 + add %o7,global1,global1 + sub global1,.PIC.DES_SPtrans-.des_and,out2 LDPTR [%fp+BIAS+ARG0+7*ARGSZ], local3 ! enc LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec @@ -1972,3 +1898,202 @@ DES_ede3_cbc_encrypt: .DES_ede3_cbc_encrypt.end: .size DES_ede3_cbc_encrypt,.DES_ede3_cbc_encrypt.end-DES_ede3_cbc_encrypt + + .align 256 + .type .des_and,#object + .size .des_and,284 + +.des_and: + +! This table is used for AND 0xFC when it is known that register +! bits 8-31 are zero. Makes it possible to do three arithmetic +! operations in one cycle. + + .byte 0, 0, 0, 0, 4, 4, 4, 4 + .byte 8, 8, 8, 8, 12, 12, 12, 12 + .byte 16, 16, 16, 16, 20, 20, 20, 20 + .byte 24, 24, 24, 24, 28, 28, 28, 28 + .byte 32, 32, 32, 32, 36, 36, 36, 36 + .byte 40, 40, 40, 40, 44, 44, 44, 44 + .byte 48, 48, 48, 48, 52, 52, 52, 52 + .byte 56, 56, 56, 56, 60, 60, 60, 60 + .byte 64, 64, 64, 64, 68, 68, 68, 68 + .byte 72, 72, 72, 72, 76, 76, 76, 76 + .byte 80, 80, 80, 80, 84, 84, 84, 84 + .byte 88, 88, 88, 88, 92, 92, 92, 92 + .byte 96, 96, 96, 96, 100, 100, 100, 100 + .byte 104, 104, 104, 104, 108, 108, 108, 108 + .byte 112, 112, 112, 112, 116, 116, 116, 116 + .byte 120, 120, 120, 120, 124, 124, 124, 124 + .byte 128, 128, 128, 128, 132, 132, 132, 132 + .byte 136, 136, 136, 136, 140, 140, 140, 140 + .byte 144, 144, 144, 144, 148, 148, 148, 148 + .byte 152, 152, 152, 152, 156, 156, 156, 156 + .byte 160, 160, 160, 160, 164, 164, 164, 164 + .byte 168, 168, 168, 168, 172, 172, 172, 172 + .byte 176, 176, 176, 176, 180, 180, 180, 180 + .byte 184, 184, 184, 184, 188, 188, 188, 188 + .byte 192, 192, 192, 192, 196, 196, 196, 196 + .byte 200, 200, 200, 200, 204, 204, 204, 204 + .byte 208, 208, 208, 208, 212, 212, 212, 212 + .byte 216, 216, 216, 216, 220, 220, 220, 220 + .byte 224, 224, 224, 224, 228, 228, 228, 228 + .byte 232, 232, 232, 232, 236, 236, 236, 236 + .byte 240, 240, 240, 240, 244, 244, 244, 244 + .byte 248, 248, 248, 248, 252, 252, 252, 252 + + ! 5 numbers for initil/final permutation + + .word 0x0f0f0f0f ! offset 256 + .word 0x0000ffff ! 260 + .word 0x33333333 ! 264 + .word 0x00ff00ff ! 268 + .word 0x55555555 ! 272 + + .word 0 ! 276 + .word LOOPS ! 280 + .word 0x0000FC00 ! 284 + + .global DES_SPtrans + .type DES_SPtrans,#object + .size DES_SPtrans,2048 +.align 64 +DES_SPtrans: +.PIC.DES_SPtrans: + ! nibble 0 + .word 0x02080800, 0x00080000, 0x02000002, 0x02080802 + .word 0x02000000, 0x00080802, 0x00080002, 0x02000002 + .word 0x00080802, 0x02080800, 0x02080000, 0x00000802 + .word 0x02000802, 0x02000000, 0x00000000, 0x00080002 + .word 0x00080000, 0x00000002, 0x02000800, 0x00080800 + .word 0x02080802, 0x02080000, 0x00000802, 0x02000800 + .word 0x00000002, 0x00000800, 0x00080800, 0x02080002 + .word 0x00000800, 0x02000802, 0x02080002, 0x00000000 + .word 0x00000000, 0x02080802, 0x02000800, 0x00080002 + .word 0x02080800, 0x00080000, 0x00000802, 0x02000800 + .word 0x02080002, 0x00000800, 0x00080800, 0x02000002 + .word 0x00080802, 0x00000002, 0x02000002, 0x02080000 + .word 0x02080802, 0x00080800, 0x02080000, 0x02000802 + .word 0x02000000, 0x00000802, 0x00080002, 0x00000000 + .word 0x00080000, 0x02000000, 0x02000802, 0x02080800 + .word 0x00000002, 0x02080002, 0x00000800, 0x00080802 + ! nibble 1 + .word 0x40108010, 0x00000000, 0x00108000, 0x40100000 + .word 0x40000010, 0x00008010, 0x40008000, 0x00108000 + .word 0x00008000, 0x40100010, 0x00000010, 0x40008000 + .word 0x00100010, 0x40108000, 0x40100000, 0x00000010 + .word 0x00100000, 0x40008010, 0x40100010, 0x00008000 + .word 0x00108010, 0x40000000, 0x00000000, 0x00100010 + .word 0x40008010, 0x00108010, 0x40108000, 0x40000010 + .word 0x40000000, 0x00100000, 0x00008010, 0x40108010 + .word 0x00100010, 0x40108000, 0x40008000, 0x00108010 + .word 0x40108010, 0x00100010, 0x40000010, 0x00000000 + .word 0x40000000, 0x00008010, 0x00100000, 0x40100010 + .word 0x00008000, 0x40000000, 0x00108010, 0x40008010 + .word 0x40108000, 0x00008000, 0x00000000, 0x40000010 + .word 0x00000010, 0x40108010, 0x00108000, 0x40100000 + .word 0x40100010, 0x00100000, 0x00008010, 0x40008000 + .word 0x40008010, 0x00000010, 0x40100000, 0x00108000 + ! nibble 2 + .word 0x04000001, 0x04040100, 0x00000100, 0x04000101 + .word 0x00040001, 0x04000000, 0x04000101, 0x00040100 + .word 0x04000100, 0x00040000, 0x04040000, 0x00000001 + .word 0x04040101, 0x00000101, 0x00000001, 0x04040001 + .word 0x00000000, 0x00040001, 0x04040100, 0x00000100 + .word 0x00000101, 0x04040101, 0x00040000, 0x04000001 + .word 0x04040001, 0x04000100, 0x00040101, 0x04040000 + .word 0x00040100, 0x00000000, 0x04000000, 0x00040101 + .word 0x04040100, 0x00000100, 0x00000001, 0x00040000 + .word 0x00000101, 0x00040001, 0x04040000, 0x04000101 + .word 0x00000000, 0x04040100, 0x00040100, 0x04040001 + .word 0x00040001, 0x04000000, 0x04040101, 0x00000001 + .word 0x00040101, 0x04000001, 0x04000000, 0x04040101 + .word 0x00040000, 0x04000100, 0x04000101, 0x00040100 + .word 0x04000100, 0x00000000, 0x04040001, 0x00000101 + .word 0x04000001, 0x00040101, 0x00000100, 0x04040000 + ! nibble 3 + .word 0x00401008, 0x10001000, 0x00000008, 0x10401008 + .word 0x00000000, 0x10400000, 0x10001008, 0x00400008 + .word 0x10401000, 0x10000008, 0x10000000, 0x00001008 + .word 0x10000008, 0x00401008, 0x00400000, 0x10000000 + .word 0x10400008, 0x00401000, 0x00001000, 0x00000008 + .word 0x00401000, 0x10001008, 0x10400000, 0x00001000 + .word 0x00001008, 0x00000000, 0x00400008, 0x10401000 + .word 0x10001000, 0x10400008, 0x10401008, 0x00400000 + .word 0x10400008, 0x00001008, 0x00400000, 0x10000008 + .word 0x00401000, 0x10001000, 0x00000008, 0x10400000 + .word 0x10001008, 0x00000000, 0x00001000, 0x00400008 + .word 0x00000000, 0x10400008, 0x10401000, 0x00001000 + .word 0x10000000, 0x10401008, 0x00401008, 0x00400000 + .word 0x10401008, 0x00000008, 0x10001000, 0x00401008 + .word 0x00400008, 0x00401000, 0x10400000, 0x10001008 + .word 0x00001008, 0x10000000, 0x10000008, 0x10401000 + ! nibble 4 + .word 0x08000000, 0x00010000, 0x00000400, 0x08010420 + .word 0x08010020, 0x08000400, 0x00010420, 0x08010000 + .word 0x00010000, 0x00000020, 0x08000020, 0x00010400 + .word 0x08000420, 0x08010020, 0x08010400, 0x00000000 + .word 0x00010400, 0x08000000, 0x00010020, 0x00000420 + .word 0x08000400, 0x00010420, 0x00000000, 0x08000020 + .word 0x00000020, 0x08000420, 0x08010420, 0x00010020 + .word 0x08010000, 0x00000400, 0x00000420, 0x08010400 + .word 0x08010400, 0x08000420, 0x00010020, 0x08010000 + .word 0x00010000, 0x00000020, 0x08000020, 0x08000400 + .word 0x08000000, 0x00010400, 0x08010420, 0x00000000 + .word 0x00010420, 0x08000000, 0x00000400, 0x00010020 + .word 0x08000420, 0x00000400, 0x00000000, 0x08010420 + .word 0x08010020, 0x08010400, 0x00000420, 0x00010000 + .word 0x00010400, 0x08010020, 0x08000400, 0x00000420 + .word 0x00000020, 0x00010420, 0x08010000, 0x08000020 + ! nibble 5 + .word 0x80000040, 0x00200040, 0x00000000, 0x80202000 + .word 0x00200040, 0x00002000, 0x80002040, 0x00200000 + .word 0x00002040, 0x80202040, 0x00202000, 0x80000000 + .word 0x80002000, 0x80000040, 0x80200000, 0x00202040 + .word 0x00200000, 0x80002040, 0x80200040, 0x00000000 + .word 0x00002000, 0x00000040, 0x80202000, 0x80200040 + .word 0x80202040, 0x80200000, 0x80000000, 0x00002040 + .word 0x00000040, 0x00202000, 0x00202040, 0x80002000 + .word 0x00002040, 0x80000000, 0x80002000, 0x00202040 + .word 0x80202000, 0x00200040, 0x00000000, 0x80002000 + .word 0x80000000, 0x00002000, 0x80200040, 0x00200000 + .word 0x00200040, 0x80202040, 0x00202000, 0x00000040 + .word 0x80202040, 0x00202000, 0x00200000, 0x80002040 + .word 0x80000040, 0x80200000, 0x00202040, 0x00000000 + .word 0x00002000, 0x80000040, 0x80002040, 0x80202000 + .word 0x80200000, 0x00002040, 0x00000040, 0x80200040 + ! nibble 6 + .word 0x00004000, 0x00000200, 0x01000200, 0x01000004 + .word 0x01004204, 0x00004004, 0x00004200, 0x00000000 + .word 0x01000000, 0x01000204, 0x00000204, 0x01004000 + .word 0x00000004, 0x01004200, 0x01004000, 0x00000204 + .word 0x01000204, 0x00004000, 0x00004004, 0x01004204 + .word 0x00000000, 0x01000200, 0x01000004, 0x00004200 + .word 0x01004004, 0x00004204, 0x01004200, 0x00000004 + .word 0x00004204, 0x01004004, 0x00000200, 0x01000000 + .word 0x00004204, 0x01004000, 0x01004004, 0x00000204 + .word 0x00004000, 0x00000200, 0x01000000, 0x01004004 + .word 0x01000204, 0x00004204, 0x00004200, 0x00000000 + .word 0x00000200, 0x01000004, 0x00000004, 0x01000200 + .word 0x00000000, 0x01000204, 0x01000200, 0x00004200 + .word 0x00000204, 0x00004000, 0x01004204, 0x01000000 + .word 0x01004200, 0x00000004, 0x00004004, 0x01004204 + .word 0x01000004, 0x01004200, 0x01004000, 0x00004004 + ! nibble 7 + .word 0x20800080, 0x20820000, 0x00020080, 0x00000000 + .word 0x20020000, 0x00800080, 0x20800000, 0x20820080 + .word 0x00000080, 0x20000000, 0x00820000, 0x00020080 + .word 0x00820080, 0x20020080, 0x20000080, 0x20800000 + .word 0x00020000, 0x00820080, 0x00800080, 0x20020000 + .word 0x20820080, 0x20000080, 0x00000000, 0x00820000 + .word 0x20000000, 0x00800000, 0x20020080, 0x20800080 + .word 0x00800000, 0x00020000, 0x20820000, 0x00000080 + .word 0x00800000, 0x00020000, 0x20000080, 0x20820080 + .word 0x00020080, 0x20000000, 0x00000000, 0x00820000 + .word 0x20800080, 0x20020080, 0x20020000, 0x00800080 + .word 0x20820000, 0x00000080, 0x00800080, 0x20020000 + .word 0x20820080, 0x00800000, 0x20800000, 0x20000080 + .word 0x00820000, 0x00020080, 0x20020080, 0x20800000 + .word 0x00000080, 0x20820000, 0x00820080, 0x00000000 + .word 0x20000000, 0x20800080, 0x00020000, 0x00820080 + diff --git a/crypto/des/cfb_enc.c b/crypto/des/cfb_enc.c index 6738e7c0e5..720f29a28e 100644 --- a/crypto/des/cfb_enc.c +++ b/crypto/des/cfb_enc.c @@ -125,7 +125,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1; #endif if (rem==0) - memcpy(ovec,ovec+num,8); + memmove(ovec,ovec+num,8); else for(i=0 ; i < 8 ; ++i) ovec[i]=ovec[i+num]<<rem | @@ -168,7 +168,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1; #endif if (rem==0) - memcpy (ovec,ovec+num,8); + memmove(ovec,ovec+num,8); else for(i=0 ; i < 8 ; ++i) ovec[i]=ovec[i+num]<<rem | diff --git a/crypto/des/des-lib.com b/crypto/des/des-lib.com index 34be66b808..c715bd2906 100644 --- a/crypto/des/des-lib.com +++ b/crypto/des/des-lib.com @@ -9,7 +9,7 @@ $! Changes by Richard Levitte <richard@levitte.org> $! $! This command files compiles and creates the $! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine -$! architecture of AXP or VAX. +$! architecture of ALPHA, IA64 or VAX. $! $! It was re-written to try to determine which "C" compiler to try to use $! or the user can specify a compiler in P3. @@ -53,25 +53,38 @@ $! $! $! Check Which Architecture We Are Using. $! -$ IF (F$GETSYI("CPU").GE.128) +$ IF (F$GETSYI("CPU").LT.128) $ THEN $! -$! The Architecture Is AXP. +$! The Architecture Is VAX $! -$ ARCH := AXP +$ ARCH := VAX $! $! Else... $! $ ELSE $! -$! The Architecture Is VAX. +$! The Architecture Is Alpha, IA64 or whatever comes in the future. $! -$ ARCH := VAX +$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE") +$ IF (ARCH .EQS. "") THEN ARCH = "UNK" $! $! End The Architecture Check. $! $ ENDIF $! +$! Define The OBJ Directory Name. +$! +$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES] +$! +$! Define The LIS Directory Name. +$! +$ LIS_DIR := SYS$DISK:[--.'ARCH'.LIS.CRYPTO.DES] +$! +$! Define The EXE Directory Name. +$! +$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES] +$! $! Check To Make Sure We Have Valid Command Line Parameters. $! $ GOSUB CHECK_OPTIONS @@ -80,10 +93,6 @@ $! Tell The User What Kind of Machine We Run On. $! $ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine." $! -$! Define The OBJ Directory Name. -$! -$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES] -$! $! Check To See If The Architecture Specific OBJ Directory Exists. $! $ IF (F$PARSE(OBJ_DIR).EQS."") @@ -97,10 +106,6 @@ $! End The Architecture Specific OBJ Directory Check. $! $ ENDIF $! -$! Define The LIS Directory Name. -$! -$ LIS_DIR := SYS$DISK:[--.'ARCH'.LIS.CRYPTO.DES] -$! $! Check To See If The Architecture Specific LIS Directory Exists. $! $ IF (F$PARSE(LIS_DIR).EQS."") @@ -114,10 +119,6 @@ $! End The Architecture Specific LIS Directory Check. $! $ ENDIF $! -$! Define The EXE Directory Name. -$! -$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES] -$! $! Check To See If The Architecture Specific Directory Exists. $! $ IF (F$PARSE(EXE_DIR).EQS."") @@ -630,7 +631,7 @@ $! $ IF (F$SEARCH(OPT_FILE).EQS."") $ THEN $! -$! Figure Out If We Need An AXP Or A VAX Linker Option File. +$! Figure Out If We Need An non-VAX Or A VAX Linker Option File. $! $ IF (F$GETSYI("CPU").LT.128) $ THEN @@ -650,19 +651,19 @@ $! Else... $! $ ELSE $! -$! Create The AXP Linker Option File. +$! Create The non-VAX Linker Option File. $! $ CREATE 'OPT_FILE' $DECK ! -! Default System Options File For AXP To Link Agianst +! Default System Options File For non-VAX To Link Agianst ! The Sharable C Runtime Library. ! SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE SYS$SHARE:CMA$OPEN_RTL/SHARE $EOD $! -$! End The VAX/AXP DEC C Option File Check. +$! End The DEC C Option File Check. $! $ ENDIF $! @@ -753,8 +754,9 @@ $ WRITE SYS$OUTPUT " DES_OPTS : To Compile Just The [.xxx.EXE.CRYTPO.DES $ WRITE SYS$OUTPUT "" $ WRITE SYS$OUTPUT " Where 'xxx' Stands For: " $ WRITE SYS$OUTPUT "" -$ WRITE SYS$OUTPUT " AXP : Alpha Architecture." -$ WRITE SYS$OUTPUT " VAX : VAX Architecture." +$ WRITE SYS$OUTPUT " ALPHA : Alpha Architecture." +$ WRITE SYS$OUTPUT " IA64 : IA64 Architecture." +$ WRITE SYS$OUTPUT " VAX : VAX Architecture." $ WRITE SYS$OUTPUT "" $! $! Time To EXIT. @@ -883,7 +885,7 @@ $ ELSE $! $! Check To See If We Have VAXC Or DECC. $! -$ IF (ARCH.EQS."AXP").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."") +$ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."") $ THEN $! $! Looks Like DECC, Set To Use DECC. @@ -1006,7 +1008,7 @@ $ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - $! $! Define The Linker Options File Name. $! -$ OPT_FILE = "SYS$DISK:[]VAX_DECC_OPTIONS.OPT" +$ OPT_FILE = "''EXE_DIR'VAX_DECC_OPTIONS.OPT" $! $! End DECC Check. $! @@ -1028,9 +1030,9 @@ $! $! Compile Using VAXC. $! $ CC = "CC" -$ IF ARCH.EQS."AXP" +$ IF ARCH.NES."VAX" $ THEN -$ WRITE SYS$OUTPUT "There is no VAX C on Alpha!" +$ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!" $ EXIT $ ENDIF $ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" @@ -1043,7 +1045,7 @@ $ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB] $! $! Define The Linker Options File Name. $! -$ OPT_FILE = "SYS$DISK:[]VAX_VAXC_OPTIONS.OPT" +$ OPT_FILE = "''EXE_DIR'VAX_VAXC_OPTIONS.OPT" $! $! End VAXC Check $! @@ -1068,7 +1070,7 @@ $ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'" + CCEXTRAFLAGS $! $! Define The Linker Options File Name. $! -$ OPT_FILE = "SYS$DISK:[]VAX_GNUC_OPTIONS.OPT" +$ OPT_FILE = "''EXE_DIR'VAX_GNUC_OPTIONS.OPT" $! $! End The GNU C Check. $! diff --git a/crypto/des/des.h b/crypto/des/des.h index 3cbc2b568e..92b6663599 100644 --- a/crypto/des/des.h +++ b/crypto/des/des.h @@ -195,9 +195,10 @@ 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); - +#if 0 void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, DES_cblock *out_white); +#endif int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, DES_cblock *iv); diff --git a/crypto/des/des_enc.c b/crypto/des/des_enc.c index 1c37ab96d3..828feba208 100644 --- a/crypto/des/des_enc.c +++ b/crypto/des/des_enc.c @@ -57,6 +57,7 @@ */ #include "des_locl.h" +#include "spr.h" void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) { @@ -107,12 +108,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l,r,28); /* 15 */ D_ENCRYPT(r,l,30); /* 16 */ #else - for (i=0; i<32; i+=8) + for (i=0; i<32; i+=4) { 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 */ } #endif } @@ -136,12 +135,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l,r, 2); /* 2 */ D_ENCRYPT(r,l, 0); /* 1 */ #else - for (i=30; i>0; i-=8) + for (i=30; i>0; i-=4) { D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(r,l,i-2); /* 15 */ - D_ENCRYPT(l,r,i-4); /* 14 */ - D_ENCRYPT(r,l,i-6); /* 13 */ } #endif } @@ -203,12 +200,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l,r,28); /* 15 */ D_ENCRYPT(r,l,30); /* 16 */ #else - for (i=0; i<32; i+=8) + for (i=0; i<32; i+=4) { 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 */ } #endif } @@ -232,12 +227,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l,r, 2); /* 2 */ D_ENCRYPT(r,l, 0); /* 1 */ #else - for (i=30; i>0; i-=8) + for (i=30; i>0; i-=4) { D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(r,l,i-2); /* 15 */ - D_ENCRYPT(l,r,i-4); /* 14 */ - D_ENCRYPT(r,l,i-6); /* 13 */ } #endif } diff --git a/crypto/des/des_locl.h b/crypto/des/des_locl.h index f992697b08..a3b512e9b0 100644 --- a/crypto/des/des_locl.h +++ b/crypto/des/des_locl.h @@ -61,7 +61,7 @@ #include <openssl/e_os2.h> -#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) +#if defined(OPENSSL_SYS_WIN32) #ifndef OPENSSL_SYS_MSDOS #define OPENSSL_SYS_MSDOS #endif @@ -421,8 +421,12 @@ PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ } -OPENSSL_EXTERN const DES_LONG DES_SPtrans[8][64]; +extern const DES_LONG DES_SPtrans[8][64]; void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, DES_LONG Eswap0, DES_LONG Eswap1); + +#ifdef OPENSSL_SMALL_FOOTPRINT +#undef DES_UNROLL +#endif #endif diff --git a/crypto/des/des_old.c b/crypto/des/des_old.c index 7e4cd7180d..7c33ed7a93 100644 --- a/crypto/des/des_old.c +++ b/crypto/des/des_old.c @@ -169,11 +169,13 @@ void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, (DES_key_schedule *)ks3, ivec, num); } +#if 0 /* broken code, preserved just in case anyone specifically looks for this */ void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), _ossl_old_des_cblock (*out_white)) { DES_xwhite_in2out(des_key, in_white, out_white); } +#endif int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched, _ossl_old_des_cblock *iv) diff --git a/crypto/des/des_old.h b/crypto/des/des_old.h index 8a238d1ce1..2b2c372354 100644 --- a/crypto/des/des_old.h +++ b/crypto/des/des_old.h @@ -116,6 +116,10 @@ extern "C" { #endif +#ifdef _ +#undef _ +#endif + typedef unsigned char _ossl_old_des_cblock[8]; typedef struct _ossl_old_des_ks_struct { @@ -171,9 +175,9 @@ typedef struct _ossl_old_des_ks_struct DES_enc_write((f),(b),(l),&(k),(iv)) #define des_fcrypt(b,s,r)\ DES_fcrypt((b),(s),(r)) +#if 0 #define des_crypt(b,s)\ DES_crypt((b),(s)) -#if 0 #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) #define crypt(b,s)\ DES_crypt((b),(s)) @@ -360,9 +364,10 @@ void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); - +#if 0 void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), _ossl_old_des_cblock (*out_white)); +#endif int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, _ossl_old_des_cblock *iv); diff --git a/crypto/des/des_ver.h b/crypto/des/des_ver.h index 379bbadda2..d1ada258a6 100644 --- a/crypto/des/des_ver.h +++ b/crypto/des/des_ver.h @@ -67,5 +67,5 @@ #define DES_version OSSL_DES_version #define libdes_version OSSL_libdes_version -OPENSSL_EXTERN const char *OSSL_DES_version; /* SSLeay version string */ -OPENSSL_EXTERN const char *OSSL_libdes_version; /* old libdes version string */ +OPENSSL_EXTERN const char OSSL_DES_version[]; /* SSLeay version string */ +OPENSSL_EXTERN const char OSSL_libdes_version[]; /* old libdes version string */ diff --git a/crypto/des/destest.c b/crypto/des/destest.c index 4584cf3004..64b92a34fe 100644 --- a/crypto/des/destest.c +++ b/crypto/des/destest.c @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) #else #include <openssl/des.h> -#define crypt(c,s) (des_crypt((c),(s))) +#define crypt(c,s) (DES_crypt((c),(s))) /* tisk tisk - the test keys don't all have odd parity :-( */ /* test data */ diff --git a/crypto/des/ecb_enc.c b/crypto/des/ecb_enc.c index 784aa5ba23..0684e769b3 100644 --- a/crypto/des/ecb_enc.c +++ b/crypto/des/ecb_enc.c @@ -58,12 +58,11 @@ #include "des_locl.h" #include "des_ver.h" -#include "spr.h" #include <openssl/opensslv.h> #include <openssl/bio.h> -OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT; -OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT; +OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT; +OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT; const char *DES_options(void) { @@ -92,7 +91,7 @@ const char *DES_options(void) #ifdef DES_UNROLL unroll="16"; #else - unroll="4"; + unroll="2"; #endif if (sizeof(DES_LONG) != sizeof(long)) size="int"; diff --git a/crypto/des/enc_read.c b/crypto/des/enc_read.c index c70fb686b8..edb6620d08 100644 --- a/crypto/des/enc_read.c +++ b/crypto/des/enc_read.c @@ -63,7 +63,7 @@ /* This has some uglies in it but it works - even over sockets. */ /*extern int errno;*/ -OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE; +OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode,DES_PCBC_MODE) /* @@ -87,6 +87,9 @@ OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE; int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, DES_cblock *iv) { +#if defined(OPENSSL_NO_POSIX_IO) + return(0); +#else /* data to be unencrypted */ int net_num=0; static unsigned char *net=NULL; @@ -147,7 +150,11 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, /* first - get the length */ while (net_num < HDRSIZE) { +#ifndef OPENSSL_SYS_WIN32 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); +#else + i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); +#endif #ifdef EINTR if ((i == -1) && (errno == EINTR)) continue; #endif @@ -169,7 +176,11 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, net_num=0; while (net_num < rnum) { +#ifndef OPENSSL_SYS_WIN32 i=read(fd,(void *)&(net[net_num]),rnum-net_num); +#else + i=_read(fd,(void *)&(net[net_num]),rnum-net_num); +#endif #ifdef EINTR if ((i == -1) && (errno == EINTR)) continue; #endif @@ -224,5 +235,6 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, } } return num; +#endif /* OPENSSL_NO_POSIX_IO */ } diff --git a/crypto/des/enc_writ.c b/crypto/des/enc_writ.c index af5b8c2349..2353ac1e89 100644 --- a/crypto/des/enc_writ.c +++ b/crypto/des/enc_writ.c @@ -80,6 +80,9 @@ int DES_enc_write(int fd, const void *_buf, int len, DES_key_schedule *sched, DES_cblock *iv) { +#if defined(OPENSSL_NO_POSIX_IO) + return (-1); +#else #ifdef _LIBC extern unsigned long time(); extern int write(); @@ -153,7 +156,11 @@ int DES_enc_write(int fd, const void *_buf, int len, { /* eay 26/08/92 I was not doing writing from where we * got up to. */ +#ifndef _WIN32 i=write(fd,(void *)&(outbuf[j]),outnum-j); +#else + i=_write(fd,(void *)&(outbuf[j]),outnum-j); +#endif if (i == -1) { #ifdef EINTR @@ -168,4 +175,5 @@ int DES_enc_write(int fd, const void *_buf, int len, } return(len); +#endif /* OPENSSL_NO_POSIX_IO */ } diff --git a/crypto/des/fcrypt_b.c b/crypto/des/fcrypt_b.c index 1390138787..8822816938 100644 --- a/crypto/des/fcrypt_b.c +++ b/crypto/des/fcrypt_b.c @@ -100,12 +100,10 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, #ifndef DES_UNROLL register int i; - for (i=0; i<32; i+=8) + for (i=0; i<32; i+=4) { 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 */ diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 55efe03f42..3004cc3ab3 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -65,7 +65,7 @@ */ #include "des_locl.h" -OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ +OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key,0) /* defaults to false */ static const unsigned char odd_parity[256]={ 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, @@ -115,7 +115,7 @@ int DES_check_key_parity(const_DES_cblock *key) * (and actual cblock values). */ #define NUM_WEAK_KEY 16 -static DES_cblock weak_keys[NUM_WEAK_KEY]={ +static const 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}, @@ -336,7 +336,7 @@ int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) void DES_set_key_unchecked(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}; + static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; register DES_LONG c,d,t,s,t2; register const unsigned char *in; register DES_LONG *k; diff --git a/crypto/des/times/usparc.cc b/crypto/des/times/usparc.cc index f6ec8e8831..0864285ef6 100644 --- a/crypto/des/times/usparc.cc +++ b/crypto/des/times/usparc.cc @@ -2,7 +2,7 @@ solaris 2.5.1 usparc 167mhz?? - SC4.0 cc -fast -Xa -xO5 For the ultra sparc, SunC 4.0 cc -fast -Xa -xO5, running 'des_opts' gives a speed of 475,000 des/s while 'speed' gives 417,000 des/s. -I belive the difference is tied up in optimisation that the compiler +I believe the difference is tied up in optimisation that the compiler is able to perform when the code is 'inlined'. For 'speed', the DES routines are being linked from a library. I'll record the higher speed since if performance is everything, you can always inline diff --git a/crypto/des/xcbc_enc.c b/crypto/des/xcbc_enc.c index 47246eb466..058cab6bce 100644 --- a/crypto/des/xcbc_enc.c +++ b/crypto/des/xcbc_enc.c @@ -60,7 +60,8 @@ /* RSA's DESX */ -static unsigned char desx_white_in2out[256]={ +#if 0 /* broken code, preserved just in case anyone specifically looks for this */ +static const unsigned char desx_white_in2out[256]={ 0xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, 0x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, 0x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36, @@ -98,7 +99,7 @@ void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, } out0=out[0]; - out1=out[i]; + out1=out[i]; /* BUG: out-of-bounds read */ for (i=0; i<8; i++) { out[i]=in[i]^desx_white_in2out[out0^out1]; @@ -106,6 +107,7 @@ void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, out1=(int)out[i&0x07]; } } +#endif void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *schedule, |