aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssl/crypto/des
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/des')
-rw-r--r--crypto/openssl/crypto/des/FILES02
-rw-r--r--crypto/openssl/crypto/des/Makefile288
-rw-r--r--crypto/openssl/crypto/des/asm/des_enc.m41980
-rw-r--r--crypto/openssl/crypto/des/cfb64ede.c5
-rw-r--r--crypto/openssl/crypto/des/cfb_enc.c71
-rw-r--r--crypto/openssl/crypto/des/des.h8
-rw-r--r--crypto/openssl/crypto/des/des_enc.c8
-rw-r--r--crypto/openssl/crypto/des/des_locl.h4
-rw-r--r--crypto/openssl/crypto/des/des_old.c2
-rw-r--r--crypto/openssl/crypto/des/des_old.h10
-rw-r--r--crypto/openssl/crypto/des/des_opts.c4
-rw-r--r--crypto/openssl/crypto/des/destest.c18
-rw-r--r--crypto/openssl/crypto/des/ecb3_enc.c4
-rw-r--r--crypto/openssl/crypto/des/ede_cbcm_enc.c2
-rw-r--r--crypto/openssl/crypto/des/fcrypt.c3
-rw-r--r--crypto/openssl/crypto/des/read2pwd.c1
-rw-r--r--crypto/openssl/crypto/des/set_key.c8
-rw-r--r--crypto/openssl/crypto/des/speed.c4
-rw-r--r--crypto/openssl/crypto/des/str2key.c1
19 files changed, 2205 insertions, 218 deletions
diff --git a/crypto/openssl/crypto/des/FILES0 b/crypto/openssl/crypto/des/FILES0
index 1c2e1f75b96f..4c7ea2de7a06 100644
--- a/crypto/openssl/crypto/des/FILES0
+++ b/crypto/openssl/crypto/des/FILES0
@@ -8,7 +8,7 @@ README - What this package is.
VERSION - Which version this is and what was changed.
KERBEROS - Kerberos version 4 notes.
Makefile.PL - An old makefile to build with perl5, not current.
-Makefile - The SSLeay makefile
+Makefile.ssl - The SSLeay makefile
Makefile.uni - The normal unix makefile.
GNUmakefile - The makefile for use with glibc.
makefile.bc - A Borland C makefile
diff --git a/crypto/openssl/crypto/des/Makefile b/crypto/openssl/crypto/des/Makefile
index b6c2b9a8dfe0..523dfe38f27c 100644
--- a/crypto/openssl/crypto/des/Makefile
+++ b/crypto/openssl/crypto/des/Makefile
@@ -1,5 +1,5 @@
#
-# SSLeay/crypto/des/Makefile
+# OpenSSL/crypto/des/Makefile
#
DIR= des
@@ -8,11 +8,6 @@ CC= cc
CPP= $(CC) -E
INCLUDES=-I$(TOP) -I../../include
CFLAG=-g
-INSTALL_PREFIX=
-OPENSSLDIR= /usr/local/ssl
-INSTALLTOP=/usr/local/ssl
-MAKEDEPPROG= makedepend
-MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
MAKEFILE= Makefile
AR= ar r
RANLIB= ranlib
@@ -22,6 +17,7 @@ DES_ENC= des_enc.o fcrypt_b.o
CFLAGS= $(INCLUDES) $(CFLAG)
ASFLAGS= $(INCLUDES) $(ASFLAG)
+AFLAGS= $(ASFLAGS)
GENERAL=Makefile
TEST=destest.c
@@ -65,32 +61,24 @@ lib: $(LIBOBJ)
des: des.o cbc3_enc.o lib
$(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
-# elf
-asm/dx86-elf.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
- (cd asm; $(PERL) des-586.pl elf $(CFLAGS) > dx86-elf.s)
-
-asm/yx86-elf.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
- (cd asm; $(PERL) crypt586.pl elf $(CFLAGS) > yx86-elf.s)
-
+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
-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 | 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 ../perlasm/x86asm.pl ../perlasm/cbc.pl
- (cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp)
-
-asm/yx86unix.cpp: asm/crypt586.pl ../perlasm/x86asm.pl
- (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp)
+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 >> $(TOP)/MINFO
@@ -100,10 +88,12 @@ links:
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
-install: installs
-
-installs:
- @for i in $(EXHEADER) ; \
+# We need to use force because 'install' matches 'INSTALL' on case
+# insensitive systems
+FRC.install:
+install: FRC.install
+ @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
+ @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
do \
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
@@ -118,6 +108,7 @@ lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff
depend:
+ @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
dclean:
@@ -125,83 +116,77 @@ dclean:
mv -f Makefile.new $(MAKEFILE)
clean:
- rm -f asm/dx86unix.cpp asm/yx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
+ 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/crypto.h ../../include/openssl/des.h
-cbc_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-cbc_cksm.o: ../../include/openssl/opensslconf.h
-cbc_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
+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/crypto.h ../../include/openssl/des.h
-cbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-cbc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
-cbc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-cbc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-cbc_enc.o: ../../include/openssl/ui_compat.h cbc_enc.c des_locl.h ncbc_enc.c
-cfb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.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/opensslv.h ../../include/openssl/safestack.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/crypto.h ../../include/openssl/des.h
-cfb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-cfb64enc.o: ../../include/openssl/opensslconf.h
-cfb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.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/crypto.h
-cfb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
-cfb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
-cfb_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
-cfb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-cfb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-cfb_enc.o: cfb_enc.c des_locl.h
-des_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-des_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-des_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
-des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h ncbc_enc.c
-des_old.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-des_old.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-des_old.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.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/crypto.h ../../include/openssl/des.h
-des_old2.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-des_old2.o: ../../include/openssl/opensslconf.h
-des_old2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-des_old2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
-des_old2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-des_old2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-des_old2.o: des_old2.c
-ecb3_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-ecb3_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-ecb3_enc.o: ../../include/openssl/opensslconf.h
-ecb3_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
+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/safestack.h
-ecb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-ecb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-ecb_enc.o: des_locl.h des_ver.h ecb_enc.c spr.h
-ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.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/opensslv.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
@@ -210,10 +195,11 @@ 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/safestack.h
-enc_read.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-enc_read.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-enc_read.o: ../cryptlib.h des_locl.h enc_read.c
+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
@@ -224,91 +210,83 @@ 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/crypto.h ../../include/openssl/des.h
-fcrypt.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-fcrypt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
-fcrypt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-fcrypt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-fcrypt.o: ../../include/openssl/ui_compat.h des_locl.h fcrypt.c
-fcrypt_b.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-fcrypt_b.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-fcrypt_b.o: ../../include/openssl/opensslconf.h
-fcrypt_b.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
+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/crypto.h ../../include/openssl/des.h
-ofb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-ofb64ede.o: ../../include/openssl/opensslconf.h
-ofb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
+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/crypto.h ../../include/openssl/des.h
-ofb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-ofb64enc.o: ../../include/openssl/opensslconf.h
-ofb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
+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/crypto.h ../../include/openssl/des.h
-ofb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-ofb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
-ofb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-ofb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-ofb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ofb_enc.c
-pcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-pcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-pcbc_enc.o: ../../include/openssl/opensslconf.h
-pcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
+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/crypto.h ../../include/openssl/des.h
-qud_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-qud_cksm.o: ../../include/openssl/opensslconf.h
-qud_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
+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/crypto.h ../../include/openssl/des.h
-rand_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-rand_key.o: ../../include/openssl/opensslconf.h
-rand_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-rand_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
-rand_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-rand_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-rand_key.o: rand_key.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/safestack.h
-read2pwd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-read2pwd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-read2pwd.o: read2pwd.c
-rpc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-rpc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-rpc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
-rpc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-rpc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-rpc_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h rpc_des.h
-rpc_enc.o: rpc_enc.c
-set_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-set_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-set_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
-set_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-set_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-set_key.o: ../../include/openssl/ui_compat.h des_locl.h set_key.c
+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/safestack.h ../../include/openssl/stack.h
-str2key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-str2key.o: ../../include/openssl/ui_compat.h des_locl.h str2key.c
-xcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-xcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
-xcbc_enc.o: ../../include/openssl/opensslconf.h
-xcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.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/openssl/crypto/des/asm/des_enc.m4 b/crypto/openssl/crypto/des/asm/des_enc.m4
new file mode 100644
index 000000000000..f5b1928f99c4
--- /dev/null
+++ b/crypto/openssl/crypto/des/asm/des_enc.m4
@@ -0,0 +1,1980 @@
+! des_enc.m4
+! des_enc.S (generated from des_enc.m4)
+!
+! UltraSPARC assembler version of the LibDES/SSLeay/OpenSSL des_enc.c file.
+!
+! Version 1.0. 32-bit version.
+!
+! June 8, 2000.
+!
+! Version 2.0. 32/64-bit, PIC-ification, blended CPU adaptation
+! by Andy Polyakov.
+!
+! January 1, 2003.
+!
+! Assembler version: Copyright Svend Olaf Mikkelsen.
+!
+! Original C code: Copyright Eric A. Young.
+!
+! This code can be freely used by LibDES/SSLeay/OpenSSL users.
+!
+! The LibDES/SSLeay/OpenSSL copyright notices must be respected.
+!
+! This version can be redistributed.
+!
+! To expand the m4 macros: m4 -B 8192 des_enc.m4 > des_enc.S
+!
+! Global registers 1 to 5 are used. This is the same as done by the
+! cc compiler. The UltraSPARC load/store little endian feature is used.
+!
+! Instruction grouping often refers to one CPU cycle.
+!
+! Assemble through gcc: gcc -c -mcpu=ultrasparc -o des_enc.o des_enc.S
+!
+! Assemble through cc: cc -c -xarch=v8plusa -o des_enc.o des_enc.S
+!
+! Performance improvement according to './apps/openssl speed des'
+!
+! 32-bit build:
+! 23% faster than cc-5.2 -xarch=v8plus -xO5
+! 115% faster than gcc-3.2.1 -m32 -mcpu=ultrasparc -O5
+! 64-bit build:
+! 50% faster than cc-5.2 -xarch=v9 -xO5
+! 100% faster than gcc-3.2.1 -m64 -mcpu=ultrasparc -O5
+!
+
+.ident "des_enc.m4 2.1"
+
+#if defined(__SUNPRO_C) && defined(__sparcv9)
+# define ABI64 /* They've said -xarch=v9 at command line */
+#elif defined(__GNUC__) && defined(__arch64__)
+# define ABI64 /* They've said -m64 at command line */
+#endif
+
+#ifdef ABI64
+ .register %g2,#scratch
+ .register %g3,#scratch
+# define FRAME -192
+# define BIAS 2047
+# define LDPTR ldx
+# define STPTR stx
+# define ARG0 128
+# define ARGSZ 8
+# ifndef OPENSSL_SYSNAME_ULTRASPARC
+# define OPENSSL_SYSNAME_ULTRASPARC
+# endif
+#else
+# define FRAME -96
+# define BIAS 0
+# define LDPTR ld
+# define STPTR st
+# define ARG0 68
+# define ARGSZ 4
+#endif
+
+#define LOOPS 7
+
+#define global0 %g0
+#define global1 %g1
+#define global2 %g2
+#define global3 %g3
+#define global4 %g4
+#define global5 %g5
+
+#define local0 %l0
+#define local1 %l1
+#define local2 %l2
+#define local3 %l3
+#define local4 %l4
+#define local5 %l5
+#define local7 %l6
+#define local6 %l7
+
+#define in0 %i0
+#define in1 %i1
+#define in2 %i2
+#define in3 %i3
+#define in4 %i4
+#define in5 %i5
+#define in6 %i6
+#define in7 %i7
+
+#define out0 %o0
+#define out1 %o1
+#define out2 %o2
+#define out3 %o3
+#define out4 %o4
+#define out5 %o5
+#define out6 %o6
+#define out7 %o7
+
+#define stub stb
+
+changequote({,})
+
+
+! Macro definitions:
+
+
+! {ip_macro}
+!
+! The logic used in initial and final permutations is the same as in
+! the C code. The permutations are done with a clever shift, xor, and
+! technique.
+!
+! The macro also loads address sbox 1 to 5 to global 1 to 5, address
+! sbox 6 to local6, and addres sbox 8 to out3.
+!
+! Rotates the halfs 3 left to bring the sbox bits in convenient positions.
+!
+! Loads key first round from address in parameter 5 to out0, out1.
+!
+! After the the original LibDES initial permutation, the resulting left
+! is in the variable initially used for right and vice versa. The macro
+! implements the possibility to keep the halfs in the original registers.
+!
+! parameter 1 left
+! parameter 2 right
+! parameter 3 result left (modify in first round)
+! parameter 4 result right (use in first round)
+! parameter 5 key address
+! parameter 6 1/2 for include encryption/decryption
+! parameter 7 1 for move in1 to in3
+! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
+! parameter 9 1 for load ks3 and ks2 to in4 and in3
+
+define(ip_macro, {
+
+! {ip_macro}
+! $1 $2 $4 $3 $5 $6 $7 $8 $9
+
+ ld [out2+256], local1
+ srl $2, 4, local4
+
+ xor local4, $1, local4
+ ifelse($7,1,{mov in1, in3},{nop})
+
+ ld [out2+260], local2
+ and local4, local1, local4
+ ifelse($8,1,{mov in3, in4},{})
+ ifelse($8,2,{mov in4, in3},{})
+
+ ld [out2+280], out4 ! loop counter
+ sll local4, 4, local1
+ xor $1, local4, $1
+
+ ld [out2+264], local3
+ srl $1, 16, local4
+ xor $2, local1, $2
+
+ ifelse($9,1,{LDPTR KS3, in4},{})
+ xor local4, $2, local4
+ nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
+
+ ifelse($9,1,{LDPTR KS2, in3},{})
+ and local4, local2, local4
+ nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
+
+ sll local4, 16, local1
+ xor $2, local4, $2
+
+ srl $2, 2, local4
+ xor $1, local1, $1
+
+ sethi %hi(16711680), local5
+ xor local4, $1, local4
+
+ and local4, local3, local4
+ or local5, 255, local5
+
+ sll local4, 2, local2
+ xor $1, local4, $1
+
+ srl $1, 8, local4
+ xor $2, local2, $2
+
+ xor local4, $2, local4
+ add global1, 768, global4
+
+ and local4, local5, local4
+ add global1, 1024, global5
+
+ ld [out2+272], local7
+ sll local4, 8, local1
+ xor $2, local4, $2
+
+ srl $2, 1, local4
+ xor $1, local1, $1
+
+ ld [$5], out0 ! key 7531
+ xor local4, $1, local4
+ add global1, 256, global2
+
+ ld [$5+4], out1 ! key 8642
+ and local4, local7, local4
+ add global1, 512, global3
+
+ sll local4, 1, local1
+ xor $1, local4, $1
+
+ sll $1, 3, local3
+ xor $2, local1, $2
+
+ sll $2, 3, local2
+ add global1, 1280, local6 ! address sbox 8
+
+ srl $1, 29, local4
+ add global1, 1792, out3 ! address sbox 8
+
+ srl $2, 29, local1
+ or local4, local3, $4
+
+ or local2, local1, $3
+
+ ifelse($6, 1, {
+
+ ld [out2+284], local5 ! 0x0000FC00 used in the rounds
+ or local2, local1, $3
+ xor $4, out0, local1
+
+ call .des_enc.1
+ and local1, 252, local1
+
+ },{})
+
+ ifelse($6, 2, {
+
+ ld [out2+284], local5 ! 0x0000FC00 used in the rounds
+ or local2, local1, $3
+ xor $4, out0, local1
+
+ call .des_dec.1
+ and local1, 252, local1
+
+ },{})
+})
+
+
+! {rounds_macro}
+!
+! The logic used in the DES rounds is the same as in the C code,
+! except that calculations for sbox 1 and sbox 5 begin before
+! the previous round is finished.
+!
+! In each round one half (work) is modified based on key and the
+! other half (use).
+!
+! In this version we do two rounds in a loop repeated 7 times
+! and two rounds seperately.
+!
+! One half has the bits for the sboxes in the following positions:
+!
+! 777777xx555555xx333333xx111111xx
+!
+! 88xx666666xx444444xx222222xx8888
+!
+! The bits for each sbox are xor-ed with the key bits for that box.
+! The above xx bits are cleared, and the result used for lookup in
+! the sbox table. Each sbox entry contains the 4 output bits permuted
+! into 32 bits according to the P permutation.
+!
+! In the description of DES, left and right are switched after
+! each round, except after last round. In this code the original
+! left and right are kept in the same register in all rounds, meaning
+! that after the 16 rounds the result for right is in the register
+! originally used for left.
+!
+! parameter 1 first work (left in first round)
+! parameter 2 first use (right in first round)
+! parameter 3 enc/dec 1/-1
+! parameter 4 loop label
+! parameter 5 key address register
+! parameter 6 optional address for key next encryption/decryption
+! parameter 7 not empty for include retl
+!
+! also compares in2 to 8
+
+define(rounds_macro, {
+
+! {rounds_macro}
+! $1 $2 $3 $4 $5 $6 $7 $8 $9
+
+ xor $2, out0, local1
+
+ ld [out2+284], local5 ! 0x0000FC00
+ ba $4
+ and local1, 252, local1
+
+ .align 32
+
+$4:
+ ! local6 is address sbox 6
+ ! out3 is address sbox 8
+ ! out4 is loop counter
+
+ ld [global1+local1], local1
+ xor $2, out1, out1 ! 8642
+ xor $2, out0, out0 ! 7531
+ fmovs %f0, %f0 ! fxor used for alignment
+
+ srl out1, 4, local0 ! rotate 4 right
+ and out0, local5, local3 ! 3
+ 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
+
+ ld [global3+local3],local3 ! 3
+ sll out1, 28, out1 ! rotate
+ xor $1, local1, $1 ! 1 finished, local1 now sbox 7
+
+ ld [global2+local2], local2 ! 2
+ srl out0, 24, local1 ! 7
+ or out1, local0, out1 ! rotate
+
+ ldub [out2+local1], local1 ! 7 (and 0xFC)
+ srl out1, 24, local0 ! 8
+ and out1, local5, local4 ! 4
+
+ ldub [out2+local0], local0 ! 8 (and 0xFC)
+ srl local4, 8, local4 ! 4
+ xor $1, local2, $1 ! 2 finished local2 now sbox 6
+
+ ld [global4+local4],local4 ! 4
+ srl out1, 16, local2 ! 6
+ xor $1, local3, $1 ! 3 finished local3 now sbox 5
+
+ ld [out3+local0],local0 ! 8
+ and local2, 252, local2 ! 6
+ add global1, 1536, local5 ! address sbox 7
+
+ ld [local6+local2], local2 ! 6
+ srl out0, 16, local3 ! 5
+ xor $1, local4, $1 ! 4 finished
+
+ ld [local5+local1],local1 ! 7
+ and local3, 252, local3 ! 5
+ xor $1, local0, $1 ! 8 finished
+
+ ld [global5+local3],local3 ! 5
+ xor $1, local2, $1 ! 6 finished
+ subcc out4, 1, out4
+
+ ld [$5+$3*8+4], out0 ! key 8642 next round
+ xor $1, local7, local2 ! sbox 5 next round
+ xor $1, local1, $1 ! 7 finished
+
+ srl local2, 16, local2 ! sbox 5 next round
+ xor $1, local3, $1 ! 5 finished
+
+ ld [$5+$3*16+4], out1 ! key 8642 next round again
+ and local2, 252, local2 ! sbox5 next round
+! next round
+ xor $1, local7, local7 ! 7531
+
+ ld [global5+local2], local2 ! 5
+ srl local7, 24, local3 ! 7
+ xor $1, out0, out0 ! 8642
+
+ ldub [out2+local3], local3 ! 7 (and 0xFC)
+ srl out0, 4, local0 ! rotate 4 right
+ and local7, 252, local1 ! 1
+
+ sll out0, 28, out0 ! rotate
+ xor $2, local2, $2 ! 5 finished local2 used
+
+ srl local0, 8, local4 ! 4
+ and local0, 252, local2 ! 2
+ ld [local5+local3], local3 ! 7
+
+ srl local0, 16, local5 ! 6
+ or out0, local0, out0 ! rotate
+ ld [global2+local2], local2 ! 2
+
+ srl out0, 24, local0
+ ld [$5+$3*16], out0 ! key 7531 next round
+ and local4, 252, local4 ! 4
+
+ and local5, 252, local5 ! 6
+ ld [global4+local4], local4 ! 4
+ xor $2, local3, $2 ! 7 finished local3 used
+
+ and local0, 252, local0 ! 8
+ ld [local6+local5], local5 ! 6
+ xor $2, local2, $2 ! 2 finished local2 now sbox 3
+
+ srl local7, 8, local2 ! 3 start
+ ld [out3+local0], local0 ! 8
+ xor $2, local4, $2 ! 4 finished
+
+ and local2, 252, local2 ! 3
+ ld [global1+local1], local1 ! 1
+ xor $2, local5, $2 ! 6 finished local5 used
+
+ ld [global3+local2], local2 ! 3
+ xor $2, local0, $2 ! 8 finished
+ add $5, $3*16, $5 ! enc add 8, dec add -8 to key pointer
+
+ ld [out2+284], local5 ! 0x0000FC00
+ xor $2, out0, local4 ! sbox 1 next round
+ xor $2, local1, $2 ! 1 finished
+
+ xor $2, local2, $2 ! 3 finished
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bne,pt %icc, $4
+#else
+ bne $4
+#endif
+ and local4, 252, local1 ! sbox 1 next round
+
+! two rounds more:
+
+ ld [global1+local1], local1
+ xor $2, out1, out1
+ xor $2, out0, out0
+
+ srl out1, 4, local0 ! rotate
+ and out0, local5, local3
+
+ ld [$5+$3*8], local7 ! key 7531
+ srl local3, 8, local3
+ and local0, 252, local2
+
+ ld [global3+local3],local3
+ sll out1, 28, out1 ! rotate
+ xor $1, local1, $1 ! 1 finished, local1 now sbox 7
+
+ ld [global2+local2], local2
+ srl out0, 24, local1
+ or out1, local0, out1 ! rotate
+
+ ldub [out2+local1], local1
+ srl out1, 24, local0
+ and out1, local5, local4
+
+ ldub [out2+local0], local0
+ srl local4, 8, local4
+ xor $1, local2, $1 ! 2 finished local2 now sbox 6
+
+ ld [global4+local4],local4
+ srl out1, 16, local2
+ xor $1, local3, $1 ! 3 finished local3 now sbox 5
+
+ ld [out3+local0],local0
+ and local2, 252, local2
+ add global1, 1536, local5 ! address sbox 7
+
+ ld [local6+local2], local2
+ srl out0, 16, local3
+ xor $1, local4, $1 ! 4 finished
+
+ ld [local5+local1],local1
+ and local3, 252, local3
+ xor $1, local0, $1
+
+ ld [global5+local3],local3
+ xor $1, local2, $1 ! 6 finished
+ cmp in2, 8
+
+ ifelse($6,{}, {}, {ld [out2+280], out4}) ! loop counter
+ xor $1, local7, local2 ! sbox 5 next round
+ xor $1, local1, $1 ! 7 finished
+
+ ld [$5+$3*8+4], out0
+ srl local2, 16, local2 ! sbox 5 next round
+ xor $1, local3, $1 ! 5 finished
+
+ and local2, 252, local2
+! next round (two rounds more)
+ xor $1, local7, local7 ! 7531
+
+ ld [global5+local2], local2
+ srl local7, 24, local3
+ xor $1, out0, out0 ! 8642
+
+ ldub [out2+local3], local3
+ srl out0, 4, local0 ! rotate
+ and local7, 252, local1
+
+ sll out0, 28, out0 ! rotate
+ xor $2, local2, $2 ! 5 finished local2 used
+
+ srl local0, 8, local4
+ and local0, 252, local2
+ ld [local5+local3], local3
+
+ srl local0, 16, local5
+ or out0, local0, out0 ! rotate
+ ld [global2+local2], local2
+
+ srl out0, 24, local0
+ ifelse($6,{}, {}, {ld [$6], out0}) ! key next encryption/decryption
+ and local4, 252, local4
+
+ and local5, 252, local5
+ ld [global4+local4], local4
+ xor $2, local3, $2 ! 7 finished local3 used
+
+ and local0, 252, local0
+ ld [local6+local5], local5
+ xor $2, local2, $2 ! 2 finished local2 now sbox 3
+
+ srl local7, 8, local2 ! 3 start
+ ld [out3+local0], local0
+ xor $2, local4, $2
+
+ and local2, 252, local2
+ ld [global1+local1], local1
+ xor $2, local5, $2 ! 6 finished local5 used
+
+ ld [global3+local2], local2
+ srl $1, 3, local3
+ xor $2, local0, $2
+
+ ifelse($6,{}, {}, {ld [$6+4], out1}) ! key next encryption/decryption
+ sll $1, 29, local4
+ xor $2, local1, $2
+
+ ifelse($7,{}, {}, {retl})
+ xor $2, local2, $2
+})
+
+
+! {fp_macro}
+!
+! parameter 1 right (original left)
+! parameter 2 left (original right)
+! parameter 3 1 for optional store to [in0]
+! parameter 4 1 for load input/output address to local5/7
+!
+! The final permutation logic switches the halfes, meaning that
+! left and right ends up the the registers originally used.
+
+define(fp_macro, {
+
+! {fp_macro}
+! $1 $2 $3 $4 $5 $6 $7 $8 $9
+
+ ! initially undo the rotate 3 left done after initial permutation
+ ! original left is received shifted 3 right and 29 left in local3/4
+
+ sll $2, 29, local1
+ or local3, local4, $1
+
+ srl $2, 3, $2
+ sethi %hi(0x55555555), local2
+
+ or $2, local1, $2
+ or local2, %lo(0x55555555), local2
+
+ srl $2, 1, local3
+ sethi %hi(0x00ff00ff), local1
+ xor local3, $1, local3
+ or local1, %lo(0x00ff00ff), local1
+ and local3, local2, local3
+ sethi %hi(0x33333333), local4
+ sll local3, 1, local2
+
+ xor $1, local3, $1
+
+ srl $1, 8, local3
+ xor $2, local2, $2
+ xor local3, $2, local3
+ or local4, %lo(0x33333333), local4
+ and local3, local1, local3
+ sethi %hi(0x0000ffff), local1
+ sll local3, 8, local2
+
+ xor $2, local3, $2
+
+ srl $2, 2, local3
+ xor $1, local2, $1
+ xor local3, $1, local3
+ or local1, %lo(0x0000ffff), local1
+ and local3, local4, local3
+ sethi %hi(0x0f0f0f0f), local4
+ sll local3, 2, local2
+
+ ifelse($4,1, {LDPTR INPUT, local5})
+ xor $1, local3, $1
+
+ ifelse($4,1, {LDPTR OUTPUT, local7})
+ srl $1, 16, local3
+ xor $2, local2, $2
+ xor local3, $2, local3
+ or local4, %lo(0x0f0f0f0f), local4
+ and local3, local1, local3
+ sll local3, 16, local2
+
+ xor $2, local3, local1
+
+ srl local1, 4, local3
+ xor $1, local2, $1
+ xor local3, $1, local3
+ and local3, local4, local3
+ sll local3, 4, local2
+
+ xor $1, local3, $1
+
+ ! optional store:
+
+ ifelse($3,1, {st $1, [in0]})
+
+ xor local1, local2, $2
+
+ ifelse($3,1, {st $2, [in0+4]})
+
+})
+
+
+! {fp_ip_macro}
+!
+! Does initial permutation for next block mixed with
+! final permutation for current block.
+!
+! parameter 1 original left
+! parameter 2 original right
+! parameter 3 left ip
+! parameter 4 right ip
+! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
+! 2: mov in4 to in3
+!
+! also adds -8 to length in2 and loads loop counter to out4
+
+define(fp_ip_macro, {
+
+! {fp_ip_macro}
+! $1 $2 $3 $4 $5 $6 $7 $8 $9
+
+ define({temp1},{out4})
+ define({temp2},{local3})
+
+ define({ip1},{local1})
+ define({ip2},{local2})
+ define({ip4},{local4})
+ define({ip5},{local5})
+
+ ! $1 in local3, local4
+
+ ld [out2+256], ip1
+ sll out5, 29, temp1
+ or local3, local4, $1
+
+ srl out5, 3, $2
+ ifelse($5,2,{mov in4, in3})
+
+ ld [out2+272], ip5
+ srl $4, 4, local0
+ or $2, temp1, $2
+
+ srl $2, 1, temp1
+ xor temp1, $1, temp1
+
+ and temp1, ip5, temp1
+ xor local0, $3, local0
+
+ sll temp1, 1, temp2
+ xor $1, temp1, $1
+
+ and local0, ip1, local0
+ add in2, -8, in2
+
+ sll local0, 4, local7
+ xor $3, local0, $3
+
+ ld [out2+268], ip4
+ srl $1, 8, temp1
+ xor $2, temp2, $2
+ ld [out2+260], ip2
+ srl $3, 16, local0
+ xor $4, local7, $4
+ xor temp1, $2, temp1
+ xor local0, $4, local0
+ and temp1, ip4, temp1
+ and local0, ip2, local0
+ sll temp1, 8, temp2
+ xor $2, temp1, $2
+ sll local0, 16, local7
+ xor $4, local0, $4
+
+ srl $2, 2, temp1
+ xor $1, temp2, $1
+
+ ld [out2+264], temp2 ! ip3
+ srl $4, 2, local0
+ xor $3, local7, $3
+ xor temp1, $1, temp1
+ xor local0, $3, local0
+ and temp1, temp2, temp1
+ and local0, temp2, local0
+ sll temp1, 2, temp2
+ xor $1, temp1, $1
+ sll local0, 2, local7
+ xor $3, local0, $3
+
+ srl $1, 16, temp1
+ xor $2, temp2, $2
+ srl $3, 8, local0
+ xor $4, local7, $4
+ xor temp1, $2, temp1
+ xor local0, $4, local0
+ and temp1, ip2, temp1
+ and local0, ip4, local0
+ sll temp1, 16, temp2
+ xor $2, temp1, local4
+ sll local0, 8, local7
+ xor $4, local0, $4
+
+ srl $4, 1, local0
+ xor $3, local7, $3
+
+ srl local4, 4, temp1
+ xor local0, $3, local0
+
+ xor $1, temp2, $1
+ and local0, ip5, local0
+
+ sll local0, 1, local7
+ xor temp1, $1, temp1
+
+ xor $3, local0, $3
+ xor $4, local7, $4
+
+ sll $3, 3, local5
+ and temp1, ip1, temp1
+
+ sll temp1, 4, temp2
+ xor $1, temp1, $1
+
+ ifelse($5,1,{LDPTR KS2, in4})
+ sll $4, 3, local2
+ xor local4, temp2, $2
+
+ ! reload since used as temporar:
+
+ ld [out2+280], out4 ! loop counter
+
+ srl $3, 29, local0
+ ifelse($5,1,{add in4, 120, in4})
+
+ ifelse($5,1,{LDPTR KS1, in3})
+ srl $4, 29, local7
+
+ or local0, local5, $4
+ or local2, local7, $3
+
+})
+
+
+
+! {load_little_endian}
+!
+! parameter 1 address
+! parameter 2 destination left
+! parameter 3 destination right
+! parameter 4 temporar
+! parameter 5 label
+
+define(load_little_endian, {
+
+! {load_little_endian}
+! $1 $2 $3 $4 $5 $6 $7 $8 $9
+
+ ! first in memory to rightmost in register
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ andcc $1, 3, global0
+ bne,pn %icc, $5
+ nop
+
+ lda [$1] 0x88, $2
+ add $1, 4, $4
+
+ ba,pt %icc, $5a
+ lda [$4] 0x88, $3
+#endif
+
+$5:
+ ldub [$1+3], $2
+
+ ldub [$1+2], $4
+ sll $2, 8, $2
+ or $2, $4, $2
+
+ ldub [$1+1], $4
+ sll $2, 8, $2
+ or $2, $4, $2
+
+ ldub [$1+0], $4
+ sll $2, 8, $2
+ or $2, $4, $2
+
+
+ ldub [$1+3+4], $3
+
+ ldub [$1+2+4], $4
+ sll $3, 8, $3
+ or $3, $4, $3
+
+ ldub [$1+1+4], $4
+ sll $3, 8, $3
+ or $3, $4, $3
+
+ ldub [$1+0+4], $4
+ sll $3, 8, $3
+ or $3, $4, $3
+$5a:
+
+})
+
+
+! {load_little_endian_inc}
+!
+! parameter 1 address
+! parameter 2 destination left
+! parameter 3 destination right
+! parameter 4 temporar
+! parameter 4 label
+!
+! adds 8 to address
+
+define(load_little_endian_inc, {
+
+! {load_little_endian_inc}
+! $1 $2 $3 $4 $5 $6 $7 $8 $9
+
+ ! first in memory to rightmost in register
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ andcc $1, 3, global0
+ bne,pn %icc, $5
+ nop
+
+ lda [$1] 0x88, $2
+ add $1, 4, $1
+
+ lda [$1] 0x88, $3
+ ba,pt %icc, $5a
+ add $1, 4, $1
+#endif
+
+$5:
+ ldub [$1+3], $2
+
+ ldub [$1+2], $4
+ sll $2, 8, $2
+ or $2, $4, $2
+
+ ldub [$1+1], $4
+ sll $2, 8, $2
+ or $2, $4, $2
+
+ ldub [$1+0], $4
+ sll $2, 8, $2
+ or $2, $4, $2
+
+ ldub [$1+3+4], $3
+ add $1, 8, $1
+
+ ldub [$1+2+4-8], $4
+ sll $3, 8, $3
+ or $3, $4, $3
+
+ ldub [$1+1+4-8], $4
+ sll $3, 8, $3
+ or $3, $4, $3
+
+ ldub [$1+0+4-8], $4
+ sll $3, 8, $3
+ or $3, $4, $3
+$5a:
+
+})
+
+
+! {load_n_bytes}
+!
+! Loads 1 to 7 bytes little endian
+! Remaining bytes are zeroed.
+!
+! parameter 1 address
+! parameter 2 length
+! parameter 3 destination register left
+! parameter 4 destination register right
+! parameter 5 temp
+! parameter 6 temp2
+! parameter 7 label
+! parameter 8 return label
+
+define(load_n_bytes, {
+
+! {load_n_bytes}
+! $1 $2 $5 $6 $7 $8 $7 $8 $9
+
+$7.0: call .+8
+ sll $2, 2, $6
+
+ add %o7,$7.jmp.table-$7.0,$5
+
+ add $5, $6, $5
+ mov 0, $4
+
+ ld [$5], $5
+
+ jmp %o7+$5
+ mov 0, $3
+
+$7.7:
+ ldub [$1+6], $5
+ sll $5, 16, $5
+ or $3, $5, $3
+$7.6:
+ ldub [$1+5], $5
+ sll $5, 8, $5
+ or $3, $5, $3
+$7.5:
+ ldub [$1+4], $5
+ or $3, $5, $3
+$7.4:
+ ldub [$1+3], $5
+ sll $5, 24, $5
+ or $4, $5, $4
+$7.3:
+ ldub [$1+2], $5
+ sll $5, 16, $5
+ or $4, $5, $4
+$7.2:
+ ldub [$1+1], $5
+ sll $5, 8, $5
+ or $4, $5, $4
+$7.1:
+ ldub [$1+0], $5
+ ba $8
+ or $4, $5, $4
+
+ .align 4
+
+$7.jmp.table:
+ .word 0
+ .word $7.1-$7.0
+ .word $7.2-$7.0
+ .word $7.3-$7.0
+ .word $7.4-$7.0
+ .word $7.5-$7.0
+ .word $7.6-$7.0
+ .word $7.7-$7.0
+})
+
+
+! {store_little_endian}
+!
+! parameter 1 address
+! parameter 2 source left
+! parameter 3 source right
+! parameter 4 temporar
+
+define(store_little_endian, {
+
+! {store_little_endian}
+! $1 $2 $3 $4 $5 $6 $7 $8 $9
+
+ ! rightmost in register to first in memory
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ andcc $1, 3, global0
+ bne,pn %icc, $5
+ nop
+
+ sta $2, [$1] 0x88
+ add $1, 4, $4
+
+ ba,pt %icc, $5a
+ sta $3, [$4] 0x88
+#endif
+
+$5:
+ and $2, 255, $4
+ stub $4, [$1+0]
+
+ srl $2, 8, $4
+ and $4, 255, $4
+ stub $4, [$1+1]
+
+ srl $2, 16, $4
+ and $4, 255, $4
+ stub $4, [$1+2]
+
+ srl $2, 24, $4
+ stub $4, [$1+3]
+
+
+ and $3, 255, $4
+ stub $4, [$1+0+4]
+
+ srl $3, 8, $4
+ and $4, 255, $4
+ stub $4, [$1+1+4]
+
+ srl $3, 16, $4
+ and $4, 255, $4
+ stub $4, [$1+2+4]
+
+ srl $3, 24, $4
+ stub $4, [$1+3+4]
+
+$5a:
+
+})
+
+
+! {store_n_bytes}
+!
+! Stores 1 to 7 bytes little endian
+!
+! parameter 1 address
+! parameter 2 length
+! parameter 3 source register left
+! parameter 4 source register right
+! parameter 5 temp
+! parameter 6 temp2
+! parameter 7 label
+! parameter 8 return label
+
+define(store_n_bytes, {
+
+! {store_n_bytes}
+! $1 $2 $5 $6 $7 $8 $7 $8 $9
+
+$7.0: call .+8
+ sll $2, 2, $6
+
+ add %o7,$7.jmp.table-$7.0,$5
+
+ add $5, $6, $5
+
+ ld [$5], $5
+
+ jmp %o7+$5
+ nop
+
+$7.7:
+ srl $3, 16, $5
+ and $5, 0xff, $5
+ stub $5, [$1+6]
+$7.6:
+ srl $3, 8, $5
+ and $5, 0xff, $5
+ stub $5, [$1+5]
+$7.5:
+ and $3, 0xff, $5
+ stub $5, [$1+4]
+$7.4:
+ srl $4, 24, $5
+ stub $5, [$1+3]
+$7.3:
+ srl $4, 16, $5
+ and $5, 0xff, $5
+ stub $5, [$1+2]
+$7.2:
+ srl $4, 8, $5
+ and $5, 0xff, $5
+ stub $5, [$1+1]
+$7.1:
+ and $4, 0xff, $5
+
+
+ ba $8
+ stub $5, [$1]
+
+ .align 4
+
+$7.jmp.table:
+
+ .word 0
+ .word $7.1-$7.0
+ .word $7.2-$7.0
+ .word $7.3-$7.0
+ .word $7.4-$7.0
+ .word $7.5-$7.0
+ .word $7.6-$7.0
+ .word $7.7-$7.0
+})
+
+
+define(testvalue,{1})
+
+define(register_init, {
+
+! For test purposes:
+
+ sethi %hi(testvalue), local0
+ or local0, %lo(testvalue), local0
+
+ ifelse($1,{},{}, {mov local0, $1})
+ ifelse($2,{},{}, {mov local0, $2})
+ ifelse($3,{},{}, {mov local0, $3})
+ ifelse($4,{},{}, {mov local0, $4})
+ ifelse($5,{},{}, {mov local0, $5})
+ ifelse($6,{},{}, {mov local0, $6})
+ ifelse($7,{},{}, {mov local0, $7})
+ ifelse($8,{},{}, {mov local0, $8})
+
+ mov local0, local1
+ mov local0, local2
+ mov local0, local3
+ mov local0, local4
+ mov local0, local5
+ mov local0, local7
+ mov local0, local6
+ mov local0, out0
+ mov local0, out1
+ mov local0, out2
+ mov local0, out3
+ mov local0, out4
+ mov local0, out5
+ mov local0, global1
+ mov local0, global2
+ mov local0, global3
+ mov local0, global4
+ mov local0, global5
+
+})
+
+.section ".text"
+
+ .align 32
+
+.des_enc:
+
+ ! key address in3
+ ! loads key next encryption/decryption first round from [in4]
+
+ rounds_macro(in5, out5, 1, .des_enc.1, in3, in4, retl)
+
+
+ .align 32
+
+.des_dec:
+
+ ! implemented with out5 as first parameter to avoid
+ ! register exchange in ede modes
+
+ ! key address in4
+ ! loads key next encryption/decryption first round from [in3]
+
+ rounds_macro(out5, in5, -1, .des_dec.1, in4, in3, retl)
+
+
+
+! void DES_encrypt1(data, ks, enc)
+! *******************************
+
+ .align 32
+ .global DES_encrypt1
+ .type DES_encrypt1,#function
+
+DES_encrypt1:
+
+ save %sp, FRAME, %sp
+
+ call .PIC.me.up
+ mov .PIC.me.up-(.-4),out0
+
+ ld [in0], in5 ! left
+ cmp in2, 0 ! enc
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ be,pn %icc, .encrypt.dec ! enc/dec
+#else
+ be .encrypt.dec
+#endif
+ ld [in0+4], out5 ! right
+
+ ! parameter 6 1/2 for include encryption/decryption
+ ! parameter 7 1 for move in1 to in3
+ ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
+
+ ip_macro(in5, out5, in5, out5, in3, 0, 1, 1)
+
+ rounds_macro(in5, out5, 1, .des_encrypt1.1, in3, in4) ! in4 not used
+
+ fp_macro(in5, out5, 1) ! 1 for store to [in0]
+
+ ret
+ restore
+
+.encrypt.dec:
+
+ add in1, 120, in3 ! use last subkey for first round
+
+ ! parameter 6 1/2 for include encryption/decryption
+ ! parameter 7 1 for move in1 to in3
+ ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
+
+ ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include dec, ks in4
+
+ fp_macro(out5, in5, 1) ! 1 for store to [in0]
+
+ ret
+ restore
+
+.DES_encrypt1.end:
+ .size DES_encrypt1,.DES_encrypt1.end-DES_encrypt1
+
+
+! void DES_encrypt2(data, ks, enc)
+!*********************************
+
+ ! encrypts/decrypts without initial/final permutation
+
+ .align 32
+ .global DES_encrypt2
+ .type DES_encrypt2,#function
+
+DES_encrypt2:
+
+ save %sp, FRAME, %sp
+
+ call .PIC.me.up
+ mov .PIC.me.up-(.-4),out0
+
+ ! Set sbox address 1 to 6 and rotate halfs 3 left
+ ! Errors caught by destest? Yes. Still? *NO*
+
+ !sethi %hi(DES_SPtrans), global1 ! address sbox 1
+
+ !or global1, %lo(DES_SPtrans), global1 ! sbox 1
+
+ add global1, 256, global2 ! sbox 2
+ add global1, 512, global3 ! sbox 3
+
+ ld [in0], out5 ! right
+ add global1, 768, global4 ! sbox 4
+ add global1, 1024, global5 ! sbox 5
+
+ ld [in0+4], in5 ! left
+ add global1, 1280, local6 ! sbox 6
+ add global1, 1792, out3 ! sbox 8
+
+ ! rotate
+
+ sll in5, 3, local5
+ mov in1, in3 ! key address to in3
+
+ sll out5, 3, local7
+ srl in5, 29, in5
+
+ srl out5, 29, out5
+ add in5, local5, in5
+
+ add out5, local7, out5
+ cmp in2, 0
+
+ ! we use our own stackframe
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ be,pn %icc, .encrypt2.dec ! decryption
+#else
+ be .encrypt2.dec
+#endif
+ STPTR in0, [%sp+BIAS+ARG0+0*ARGSZ]
+
+ ld [in3], out0 ! key 7531 first round
+ mov LOOPS, out4 ! loop counter
+
+ ld [in3+4], out1 ! key 8642 first round
+ sethi %hi(0x0000FC00), local5
+
+ call .des_enc
+ mov in3, in4
+
+ ! rotate
+ sll in5, 29, in0
+ srl in5, 3, in5
+ sll out5, 29, in1
+ add in5, in0, in5
+ srl out5, 3, out5
+ LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
+ add out5, in1, out5
+ st in5, [in0]
+ st out5, [in0+4]
+
+ ret
+ restore
+
+
+.encrypt2.dec:
+
+ add in3, 120, in4
+
+ ld [in4], out0 ! key 7531 first round
+ mov LOOPS, out4 ! loop counter
+
+ ld [in4+4], out1 ! key 8642 first round
+ sethi %hi(0x0000FC00), local5
+
+ mov in5, local1 ! left expected in out5
+ mov out5, in5
+
+ call .des_dec
+ mov local1, out5
+
+.encrypt2.finish:
+
+ ! rotate
+ sll in5, 29, in0
+ srl in5, 3, in5
+ sll out5, 29, in1
+ add in5, in0, in5
+ srl out5, 3, out5
+ LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
+ add out5, in1, out5
+ st out5, [in0]
+ st in5, [in0+4]
+
+ ret
+ restore
+
+.DES_encrypt2.end:
+ .size DES_encrypt2, .DES_encrypt2.end-DES_encrypt2
+
+
+! void DES_encrypt3(data, ks1, ks2, ks3)
+! **************************************
+
+ .align 32
+ .global DES_encrypt3
+ .type DES_encrypt3,#function
+
+DES_encrypt3:
+
+ save %sp, FRAME, %sp
+
+ call .PIC.me.up
+ mov .PIC.me.up-(.-4),out0
+
+ ld [in0], in5 ! left
+ add in2, 120, in4 ! ks2
+
+ ld [in0+4], out5 ! right
+ mov in3, in2 ! save ks3
+
+ ! parameter 6 1/2 for include encryption/decryption
+ ! parameter 7 1 for mov in1 to in3
+ ! parameter 8 1 for mov in3 to in4
+ ! parameter 9 1 for load ks3 and ks2 to in4 and in3
+
+ ip_macro(in5, out5, in5, out5, in3, 1, 1, 0, 0)
+
+ call .des_dec
+ mov in2, in3 ! preload ks3
+
+ call .des_enc
+ nop
+
+ fp_macro(in5, out5, 1)
+
+ ret
+ restore
+
+.DES_encrypt3.end:
+ .size DES_encrypt3,.DES_encrypt3.end-DES_encrypt3
+
+
+! void DES_decrypt3(data, ks1, ks2, ks3)
+! **************************************
+
+ .align 32
+ .global DES_decrypt3
+ .type DES_decrypt3,#function
+
+DES_decrypt3:
+
+ save %sp, FRAME, %sp
+
+ call .PIC.me.up
+ mov .PIC.me.up-(.-4),out0
+
+ ld [in0], in5 ! left
+ add in3, 120, in4 ! ks3
+
+ ld [in0+4], out5 ! right
+ mov in2, in3 ! ks2
+
+ ! parameter 6 1/2 for include encryption/decryption
+ ! parameter 7 1 for mov in1 to in3
+ ! parameter 8 1 for mov in3 to in4
+ ! parameter 9 1 for load ks3 and ks2 to in4 and in3
+
+ ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 0)
+
+ call .des_enc
+ add in1, 120, in4 ! preload ks1
+
+ call .des_dec
+ nop
+
+ fp_macro(out5, in5, 1)
+
+ ret
+ restore
+
+.DES_decrypt3.end:
+ .size DES_decrypt3,.DES_decrypt3.end-DES_decrypt3
+
+ .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
+.PIC.DES_SPtrans:
+ .word %r_disp32(DES_SPtrans)
+
+! 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
+#if 1
+ ld [out0+(.PIC.DES_SPtrans-.PIC.me.up)],global1
+ add global1,(.PIC.DES_SPtrans-.PIC.me.up),global1
+ add global1,out0,global1
+#else
+# 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
+#endif
+ retl
+ add out0,.des_and-.PIC.me.up,out2
+
+! void DES_ncbc_encrypt(input, output, length, schedule, ivec, enc)
+! *****************************************************************
+
+
+ .align 32
+ .global DES_ncbc_encrypt
+ .type DES_ncbc_encrypt,#function
+
+DES_ncbc_encrypt:
+
+ save %sp, FRAME, %sp
+
+ define({INPUT}, { [%sp+BIAS+ARG0+0*ARGSZ] })
+ define({OUTPUT}, { [%sp+BIAS+ARG0+1*ARGSZ] })
+ define({IVEC}, { [%sp+BIAS+ARG0+4*ARGSZ] })
+
+ call .PIC.me.up
+ mov .PIC.me.up-(.-4),out0
+
+ cmp in5, 0 ! enc
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ be,pn %icc, .ncbc.dec
+#else
+ be .ncbc.dec
+#endif
+ STPTR in4, IVEC
+
+ ! addr left right temp label
+ load_little_endian(in4, in5, out5, local3, .LLE1) ! iv
+
+ addcc in2, -8, in2 ! bytes missing when first block done
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bl,pn %icc, .ncbc.enc.seven.or.less
+#else
+ bl .ncbc.enc.seven.or.less
+#endif
+ mov in3, in4 ! schedule
+
+.ncbc.enc.next.block:
+
+ load_little_endian(in0, out4, global4, local3, .LLE2) ! block
+
+.ncbc.enc.next.block_1:
+
+ xor in5, out4, in5 ! iv xor
+ xor out5, global4, out5 ! iv xor
+
+ ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
+ ip_macro(in5, out5, in5, out5, in3, 0, 0, 2)
+
+.ncbc.enc.next.block_2:
+
+!// call .des_enc ! compares in2 to 8
+! rounds inlined for alignment purposes
+
+ add global1, 768, global4 ! address sbox 4 since register used below
+
+ rounds_macro(in5, out5, 1, .ncbc.enc.1, in3, in4) ! include encryption ks in3
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bl,pn %icc, .ncbc.enc.next.block_fp
+#else
+ bl .ncbc.enc.next.block_fp
+#endif
+ add in0, 8, in0 ! input address
+
+ ! If 8 or more bytes are to be encrypted after this block,
+ ! we combine final permutation for this block with initial
+ ! permutation for next block. Load next block:
+
+ load_little_endian(in0, global3, global4, local5, .LLE12)
+
+ ! parameter 1 original left
+ ! parameter 2 original right
+ ! parameter 3 left ip
+ ! parameter 4 right ip
+ ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
+ ! 2: mov in4 to in3
+ !
+ ! also adds -8 to length in2 and loads loop counter to out4
+
+ fp_ip_macro(out0, out1, global3, global4, 2)
+
+ store_little_endian(in1, out0, out1, local3, .SLE10) ! block
+
+ ld [in3], out0 ! key 7531 first round next block
+ mov in5, local1
+ xor global3, out5, in5 ! iv xor next block
+
+ ld [in3+4], out1 ! key 8642
+ add global1, 512, global3 ! address sbox 3 since register used
+ xor global4, local1, out5 ! iv xor next block
+
+ ba .ncbc.enc.next.block_2
+ add in1, 8, in1 ! output adress
+
+.ncbc.enc.next.block_fp:
+
+ fp_macro(in5, out5)
+
+ store_little_endian(in1, in5, out5, local3, .SLE1) ! block
+
+ addcc in2, -8, in2 ! bytes missing when next block done
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bpos,pt %icc, .ncbc.enc.next.block ! also jumps if 0
+#else
+ bpos .ncbc.enc.next.block
+#endif
+ add in1, 8, in1
+
+.ncbc.enc.seven.or.less:
+
+ cmp in2, -8
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ ble,pt %icc, .ncbc.enc.finish
+#else
+ ble .ncbc.enc.finish
+#endif
+ nop
+
+ add in2, 8, local1 ! bytes to load
+
+ ! addr, length, dest left, dest right, temp, temp2, label, ret label
+ load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB1, .ncbc.enc.next.block_1)
+
+ ! Loads 1 to 7 bytes little endian to global4, out4
+
+
+.ncbc.enc.finish:
+
+ LDPTR IVEC, local4
+ store_little_endian(local4, in5, out5, local5, .SLE2) ! ivec
+
+ ret
+ restore
+
+
+.ncbc.dec:
+
+ STPTR in0, INPUT
+ cmp in2, 0 ! length
+ add in3, 120, in3
+
+ LDPTR IVEC, local7 ! ivec
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ ble,pn %icc, .ncbc.dec.finish
+#else
+ ble .ncbc.dec.finish
+#endif
+ mov in3, in4 ! schedule
+
+ STPTR in1, OUTPUT
+ mov in0, local5 ! input
+
+ load_little_endian(local7, in0, in1, local3, .LLE3) ! ivec
+
+.ncbc.dec.next.block:
+
+ load_little_endian(local5, in5, out5, local3, .LLE4) ! block
+
+ ! parameter 6 1/2 for include encryption/decryption
+ ! parameter 7 1 for mov in1 to in3
+ ! parameter 8 1 for mov in3 to in4
+
+ ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include decryprion ks in4
+
+ fp_macro(out5, in5, 0, 1) ! 1 for input and output address to local5/7
+
+ ! in2 is bytes left to be stored
+ ! in2 is compared to 8 in the rounds
+
+ xor out5, in0, out4 ! iv xor
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bl,pn %icc, .ncbc.dec.seven.or.less
+#else
+ bl .ncbc.dec.seven.or.less
+#endif
+ xor in5, in1, global4 ! iv xor
+
+ ! Load ivec next block now, since input and output address might be the same.
+
+ load_little_endian_inc(local5, in0, in1, local3, .LLE5) ! iv
+
+ store_little_endian(local7, out4, global4, local3, .SLE3)
+
+ STPTR local5, INPUT
+ add local7, 8, local7
+ addcc in2, -8, in2
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bg,pt %icc, .ncbc.dec.next.block
+#else
+ bg .ncbc.dec.next.block
+#endif
+ STPTR local7, OUTPUT
+
+
+.ncbc.dec.store.iv:
+
+ LDPTR IVEC, local4 ! ivec
+ store_little_endian(local4, in0, in1, local5, .SLE4)
+
+.ncbc.dec.finish:
+
+ ret
+ restore
+
+.ncbc.dec.seven.or.less:
+
+ load_little_endian_inc(local5, in0, in1, local3, .LLE13) ! ivec
+
+ store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB1, .ncbc.dec.store.iv)
+
+
+.DES_ncbc_encrypt.end:
+ .size DES_ncbc_encrypt, .DES_ncbc_encrypt.end-DES_ncbc_encrypt
+
+
+! void DES_ede3_cbc_encrypt(input, output, lenght, ks1, ks2, ks3, ivec, enc)
+! **************************************************************************
+
+
+ .align 32
+ .global DES_ede3_cbc_encrypt
+ .type DES_ede3_cbc_encrypt,#function
+
+DES_ede3_cbc_encrypt:
+
+ save %sp, FRAME, %sp
+
+ define({KS1}, { [%sp+BIAS+ARG0+3*ARGSZ] })
+ define({KS2}, { [%sp+BIAS+ARG0+4*ARGSZ] })
+ define({KS3}, { [%sp+BIAS+ARG0+5*ARGSZ] })
+
+ call .PIC.me.up
+ mov .PIC.me.up-(.-4),out0
+
+ LDPTR [%fp+BIAS+ARG0+7*ARGSZ], local3 ! enc
+ LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
+ cmp local3, 0 ! enc
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ be,pn %icc, .ede3.dec
+#else
+ be .ede3.dec
+#endif
+ STPTR in4, KS2
+
+ STPTR in5, KS3
+
+ load_little_endian(local4, in5, out5, local3, .LLE6) ! ivec
+
+ addcc in2, -8, in2 ! bytes missing after next block
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bl,pn %icc, .ede3.enc.seven.or.less
+#else
+ bl .ede3.enc.seven.or.less
+#endif
+ STPTR in3, KS1
+
+.ede3.enc.next.block:
+
+ load_little_endian(in0, out4, global4, local3, .LLE7)
+
+.ede3.enc.next.block_1:
+
+ LDPTR KS2, in4
+ xor in5, out4, in5 ! iv xor
+ xor out5, global4, out5 ! iv xor
+
+ LDPTR KS1, in3
+ add in4, 120, in4 ! for decryption we use last subkey first
+ nop
+
+ ip_macro(in5, out5, in5, out5, in3)
+
+.ede3.enc.next.block_2:
+
+ call .des_enc ! ks1 in3
+ nop
+
+ call .des_dec ! ks2 in4
+ LDPTR KS3, in3
+
+ call .des_enc ! ks3 in3 compares in2 to 8
+ nop
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bl,pn %icc, .ede3.enc.next.block_fp
+#else
+ bl .ede3.enc.next.block_fp
+#endif
+ add in0, 8, in0
+
+ ! If 8 or more bytes are to be encrypted after this block,
+ ! we combine final permutation for this block with initial
+ ! permutation for next block. Load next block:
+
+ load_little_endian(in0, global3, global4, local5, .LLE11)
+
+ ! parameter 1 original left
+ ! parameter 2 original right
+ ! parameter 3 left ip
+ ! parameter 4 right ip
+ ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
+ ! 2: mov in4 to in3
+ !
+ ! also adds -8 to length in2 and loads loop counter to out4
+
+ fp_ip_macro(out0, out1, global3, global4, 1)
+
+ store_little_endian(in1, out0, out1, local3, .SLE9) ! block
+
+ mov in5, local1
+ xor global3, out5, in5 ! iv xor next block
+
+ ld [in3], out0 ! key 7531
+ add global1, 512, global3 ! address sbox 3
+ xor global4, local1, out5 ! iv xor next block
+
+ ld [in3+4], out1 ! key 8642
+ add global1, 768, global4 ! address sbox 4
+ ba .ede3.enc.next.block_2
+ add in1, 8, in1
+
+.ede3.enc.next.block_fp:
+
+ fp_macro(in5, out5)
+
+ store_little_endian(in1, in5, out5, local3, .SLE5) ! block
+
+ addcc in2, -8, in2 ! bytes missing when next block done
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bpos,pt %icc, .ede3.enc.next.block
+#else
+ bpos .ede3.enc.next.block
+#endif
+ add in1, 8, in1
+
+.ede3.enc.seven.or.less:
+
+ cmp in2, -8
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ ble,pt %icc, .ede3.enc.finish
+#else
+ ble .ede3.enc.finish
+#endif
+ nop
+
+ add in2, 8, local1 ! bytes to load
+
+ ! addr, length, dest left, dest right, temp, temp2, label, ret label
+ load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB2, .ede3.enc.next.block_1)
+
+.ede3.enc.finish:
+
+ LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
+ store_little_endian(local4, in5, out5, local5, .SLE6) ! ivec
+
+ ret
+ restore
+
+.ede3.dec:
+
+ STPTR in0, INPUT
+ add in5, 120, in5
+
+ STPTR in1, OUTPUT
+ mov in0, local5
+ add in3, 120, in3
+
+ STPTR in3, KS1
+ cmp in2, 0
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ ble %icc, .ede3.dec.finish
+#else
+ ble .ede3.dec.finish
+#endif
+ STPTR in5, KS3
+
+ LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local7 ! iv
+ load_little_endian(local7, in0, in1, local3, .LLE8)
+
+.ede3.dec.next.block:
+
+ load_little_endian(local5, in5, out5, local3, .LLE9)
+
+ ! parameter 6 1/2 for include encryption/decryption
+ ! parameter 7 1 for mov in1 to in3
+ ! parameter 8 1 for mov in3 to in4
+ ! parameter 9 1 for load ks3 and ks2 to in4 and in3
+
+ ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 1) ! inc .des_dec ks3 in4
+
+ call .des_enc ! ks2 in3
+ LDPTR KS1, in4
+
+ call .des_dec ! ks1 in4
+ nop
+
+ fp_macro(out5, in5, 0, 1) ! 1 for input and output address local5/7
+
+ ! in2 is bytes left to be stored
+ ! in2 is compared to 8 in the rounds
+
+ xor out5, in0, out4
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bl,pn %icc, .ede3.dec.seven.or.less
+#else
+ bl .ede3.dec.seven.or.less
+#endif
+ xor in5, in1, global4
+
+ load_little_endian_inc(local5, in0, in1, local3, .LLE10) ! iv next block
+
+ store_little_endian(local7, out4, global4, local3, .SLE7) ! block
+
+ STPTR local5, INPUT
+ addcc in2, -8, in2
+ add local7, 8, local7
+
+#ifdef OPENSSL_SYSNAME_ULTRASPARC
+ bg,pt %icc, .ede3.dec.next.block
+#else
+ bg .ede3.dec.next.block
+#endif
+ STPTR local7, OUTPUT
+
+.ede3.dec.store.iv:
+
+ LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
+ store_little_endian(local4, in0, in1, local5, .SLE8) ! ivec
+
+.ede3.dec.finish:
+
+ ret
+ restore
+
+.ede3.dec.seven.or.less:
+
+ load_little_endian_inc(local5, in0, in1, local3, .LLE14) ! iv
+
+ store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB2, .ede3.dec.store.iv)
+
+
+.DES_ede3_cbc_encrypt.end:
+ .size DES_ede3_cbc_encrypt,.DES_ede3_cbc_encrypt.end-DES_ede3_cbc_encrypt
diff --git a/crypto/openssl/crypto/des/cfb64ede.c b/crypto/openssl/crypto/des/cfb64ede.c
index f422fef1d6cf..de34ecceb96d 100644
--- a/crypto/openssl/crypto/des/cfb64ede.c
+++ b/crypto/openssl/crypto/des/cfb64ede.c
@@ -57,6 +57,7 @@
*/
#include "des_locl.h"
+#include "e_os.h"
/* The input and output encrypted as though 64bit cfb mode is being
* used. The extra state information to record how much of the
@@ -151,8 +152,8 @@ void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out,
DES_cblock *ivec,int enc)
{
register DES_LONG d0,d1,v0,v1;
- register long l=length;
- register int num=numbits,n=(numbits+7)/8,i;
+ register unsigned long l=length,n=((unsigned int)numbits+7)/8;
+ register int num=numbits,i;
DES_LONG ti[2];
unsigned char *iv;
unsigned char ovec[16];
diff --git a/crypto/openssl/crypto/des/cfb_enc.c b/crypto/openssl/crypto/des/cfb_enc.c
index 03cabb223cdf..720f29a28e62 100644
--- a/crypto/openssl/crypto/des/cfb_enc.c
+++ b/crypto/openssl/crypto/des/cfb_enc.c
@@ -58,6 +58,7 @@
#include "e_os.h"
#include "des_locl.h"
+#include <assert.h>
/* The input and output are loaded in multiples of 8 bits.
* What this means is that if you hame numbits=12 and length=2
@@ -72,19 +73,29 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
int enc)
{
register DES_LONG d0,d1,v0,v1;
- register unsigned long l=length,n=(numbits+7)/8;
- register int num=numbits,i;
+ register unsigned long l=length;
+ register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8;
DES_LONG ti[2];
unsigned char *iv;
+#ifndef L_ENDIAN
unsigned char ovec[16];
+#else
+ unsigned int sh[4];
+ unsigned char *ovec=(unsigned char *)sh;
- if (num > 64) return;
+ /* I kind of count that compiler optimizes away this assertioni,*/
+ assert (sizeof(sh[0])==4); /* as this holds true for all, */
+ /* but 16-bit platforms... */
+
+#endif
+
+ if (numbits<=0 || numbits > 64) return;
iv = &(*ivec)[0];
c2l(iv,v0);
c2l(iv,v1);
if (enc)
{
- while (l >= n)
+ while (l >= (unsigned long)n)
{
l-=n;
ti[0]=v0;
@@ -98,35 +109,40 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
out+=n;
/* 30-08-94 - eay - changed because l>>32 and
* l<<32 are bad under gcc :-( */
- if (num == 32)
+ if (numbits == 32)
{ v0=v1; v1=d0; }
- else if (num == 64)
+ else if (numbits == 64)
{ v0=d0; v1=d1; }
else
{
+#ifndef L_ENDIAN
iv=&ovec[0];
l2c(v0,iv);
l2c(v1,iv);
l2c(d0,iv);
l2c(d1,iv);
- /* shift ovec left most of the bits... */
- memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
- /* now the remaining bits */
- if(num%8 != 0)
+#else
+ sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1;
+#endif
+ if (rem==0)
+ memmove(ovec,ovec+num,8);
+ else
for(i=0 ; i < 8 ; ++i)
- {
- ovec[i]<<=num%8;
- ovec[i]|=ovec[i+1]>>(8-num%8);
- }
+ ovec[i]=ovec[i+num]<<rem |
+ ovec[i+num+1]>>(8-rem);
+#ifdef L_ENDIAN
+ v0=sh[0], v1=sh[1];
+#else
iv=&ovec[0];
c2l(iv,v0);
c2l(iv,v1);
+#endif
}
}
}
else
{
- while (l >= n)
+ while (l >= (unsigned long)n)
{
l-=n;
ti[0]=v0;
@@ -136,29 +152,34 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
in+=n;
/* 30-08-94 - eay - changed because l>>32 and
* l<<32 are bad under gcc :-( */
- if (num == 32)
+ if (numbits == 32)
{ v0=v1; v1=d0; }
- else if (num == 64)
+ else if (numbits == 64)
{ v0=d0; v1=d1; }
else
{
+#ifndef L_ENDIAN
iv=&ovec[0];
l2c(v0,iv);
l2c(v1,iv);
l2c(d0,iv);
l2c(d1,iv);
- /* shift ovec left most of the bits... */
- memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
- /* now the remaining bits */
- if(num%8 != 0)
+#else
+ sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1;
+#endif
+ if (rem==0)
+ memmove(ovec,ovec+num,8);
+ else
for(i=0 ; i < 8 ; ++i)
- {
- ovec[i]<<=num%8;
- ovec[i]|=ovec[i+1]>>(8-num%8);
- }
+ ovec[i]=ovec[i+num]<<rem |
+ ovec[i+num+1]>>(8-rem);
+#ifdef L_ENDIAN
+ v0=sh[0], v1=sh[1];
+#else
iv=&ovec[0];
c2l(iv,v0);
c2l(iv,v1);
+#endif
}
d0^=ti[0];
d1^=ti[1];
diff --git a/crypto/openssl/crypto/des/des.h b/crypto/openssl/crypto/des/des.h
index c5df1c9c7b3c..3cbc2b568e91 100644
--- a/crypto/openssl/crypto/des/des.h
+++ b/crypto/openssl/crypto/des/des.h
@@ -59,13 +59,13 @@
#ifndef HEADER_NEW_DES_H
#define HEADER_NEW_DES_H
+#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES,
+ DES_LONG (via openssl/opensslconf.h */
+
#ifdef OPENSSL_NO_DES
#error DES is disabled.
#endif
-#include <openssl/opensslconf.h> /* DES_LONG */
-#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
-
#ifdef OPENSSL_BUILD_SHLIBCRYPTO
# undef OPENSSL_EXTERN
# define OPENSSL_EXTERN OPENSSL_EXPORT
@@ -128,7 +128,7 @@ OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */
#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)
const char *DES_options(void);
-void DES_ecb3_encrypt(const unsigned char *input, unsigned char *output,
+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,
diff --git a/crypto/openssl/crypto/des/des_enc.c b/crypto/openssl/crypto/des/des_enc.c
index 8dd30e2cb72a..1c37ab96d3de 100644
--- a/crypto/openssl/crypto/des/des_enc.c
+++ b/crypto/openssl/crypto/des/des_enc.c
@@ -58,8 +58,6 @@
#include "des_locl.h"
-#ifndef OPENSSL_FIPS
-
void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
{
register DES_LONG l,r,t,u;
@@ -289,12 +287,8 @@ void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
data[1]=r;
}
-#endif /* ndef OPENSSL_FIPS */
-
#ifndef DES_DEFAULT_OPTIONS
-#if !defined(OPENSSL_FIPS) || !defined(I386_ONLY)
-
#undef CBC_ENC_C__DONT_UPDATE_IV
#include "ncbc_enc.c" /* DES_ncbc_encrypt */
@@ -410,6 +404,4 @@ void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
tin[0]=tin[1]=0;
}
-#endif /* !defined(OPENSSL_FIPS) || !defined(I386_ONLY) */
-
#endif /* DES_DEFAULT_OPTIONS */
diff --git a/crypto/openssl/crypto/des/des_locl.h b/crypto/openssl/crypto/des/des_locl.h
index e44e8e98b250..4b9ecff23391 100644
--- a/crypto/openssl/crypto/des/des_locl.h
+++ b/crypto/openssl/crypto/des/des_locl.h
@@ -160,7 +160,7 @@
} \
}
-#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
+#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) || defined(__ICC)
#define ROTATE(a,n) (_lrotr(a,n))
#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
@@ -421,7 +421,7 @@
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);
diff --git a/crypto/openssl/crypto/des/des_old.c b/crypto/openssl/crypto/des/des_old.c
index 88e9802aad03..7e4cd7180d18 100644
--- a/crypto/openssl/crypto/des/des_old.c
+++ b/crypto/openssl/crypto/des/des_old.c
@@ -84,7 +84,7 @@ void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock
des_key_schedule ks1,des_key_schedule ks2,
des_key_schedule ks3, int enc)
{
- DES_ecb3_encrypt((const unsigned char *)input, (unsigned char *)output,
+ DES_ecb3_encrypt((const_DES_cblock *)input, output,
(DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
(DES_key_schedule *)ks3, enc);
}
diff --git a/crypto/openssl/crypto/des/des_old.h b/crypto/openssl/crypto/des/des_old.h
index 1d840b474a64..1b0620c3a2e1 100644
--- a/crypto/openssl/crypto/des/des_old.h
+++ b/crypto/openssl/crypto/des/des_old.h
@@ -91,6 +91,8 @@
#ifndef HEADER_DES_H
#define HEADER_DES_H
+#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */
+
#ifdef OPENSSL_NO_DES
#error DES is disabled.
#endif
@@ -103,8 +105,6 @@
#error <openssl/des_old.h> replaces <kerberos/des.h>.
#endif
-#include <openssl/opensslconf.h> /* DES_LONG */
-#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
#include <openssl/symhacks.h>
#ifdef OPENSSL_BUILD_SHLIBCRYPTO
@@ -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))
diff --git a/crypto/openssl/crypto/des/des_opts.c b/crypto/openssl/crypto/des/des_opts.c
index 79278b920eb0..2df82962c5ab 100644
--- a/crypto/openssl/crypto/des/des_opts.c
+++ b/crypto/openssl/crypto/des/des_opts.c
@@ -71,7 +71,11 @@
#include <io.h>
extern void exit();
#endif
+
+#ifndef OPENSSL_SYS_NETWARE
#include <signal.h>
+#endif
+
#ifndef _IRIX
#include <time.h>
#endif
diff --git a/crypto/openssl/crypto/des/destest.c b/crypto/openssl/crypto/des/destest.c
index e3e9d77f144e..64b92a34fe97 100644
--- a/crypto/openssl/crypto/des/destest.c
+++ b/crypto/openssl/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 */
@@ -333,7 +333,8 @@ static int cfb64_test(unsigned char *cfb_cipher);
static int ede_cfb64_test(unsigned char *cfb_cipher);
int main(int argc, char *argv[])
{
- int i,j,err=0;
+ int j,err=0;
+ unsigned int i;
des_cblock in,out,outin,iv3,iv2;
des_key_schedule ks,ks2,ks3;
unsigned char cbc_in[40];
@@ -391,7 +392,7 @@ int main(int argc, char *argv[])
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;
+ unsigned int n;
printf("des_ede3_cbcm_encrypt decrypt error\n");
for(n=0 ; n < i ; ++n)
@@ -439,8 +440,8 @@ int main(int argc, char *argv[])
memcpy(in,plain_data[i],8);
memset(out,0,8);
memset(outin,0,8);
- des_ecb2_encrypt(in,out,ks,ks2,DES_ENCRYPT);
- des_ecb2_encrypt(out,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)
{
@@ -540,7 +541,7 @@ int main(int argc, char *argv[])
if (memcmp(cbc_out,cbc3_ok,
(unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
{
- int n;
+ unsigned int n;
printf("des_ede3_cbc_encrypt encrypt error\n");
for(n=0 ; n < i ; ++n)
@@ -556,7 +557,7 @@ int main(int argc, char *argv[])
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)
{
- int n;
+ unsigned int n;
printf("des_ede3_cbc_encrypt decrypt error\n");
for(n=0 ; n < i ; ++n)
@@ -820,6 +821,9 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str);
err=1;
}
+#ifdef OPENSSL_SYS_NETWARE
+ if (err) printf("ERROR: %d\n", err);
+#endif
printf("\n");
return(err);
}
diff --git a/crypto/openssl/crypto/des/ecb3_enc.c b/crypto/openssl/crypto/des/ecb3_enc.c
index fa0c9c4d4fc6..c3437bc60621 100644
--- a/crypto/openssl/crypto/des/ecb3_enc.c
+++ b/crypto/openssl/crypto/des/ecb3_enc.c
@@ -58,13 +58,15 @@
#include "des_locl.h"
-void DES_ecb3_encrypt(const unsigned char *in, unsigned char *out,
+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;
DES_LONG ll[2];
+ const unsigned char *in = &(*input)[0];
+ unsigned char *out = &(*output)[0];
c2l(in,l0);
c2l(in,l1);
diff --git a/crypto/openssl/crypto/des/ede_cbcm_enc.c b/crypto/openssl/crypto/des/ede_cbcm_enc.c
index fa45aa272ba5..adfcb75cf387 100644
--- a/crypto/openssl/crypto/des/ede_cbcm_enc.c
+++ b/crypto/openssl/crypto/des/ede_cbcm_enc.c
@@ -68,6 +68,8 @@ http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz
*/
+#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_DESCBCM is defined */
+
#ifndef OPENSSL_NO_DESCBCM
#include "des_locl.h"
diff --git a/crypto/openssl/crypto/des/fcrypt.c b/crypto/openssl/crypto/des/fcrypt.c
index 2758c32656af..ccbdff250f70 100644
--- a/crypto/openssl/crypto/des/fcrypt.c
+++ b/crypto/openssl/crypto/des/fcrypt.c
@@ -58,9 +58,6 @@ static unsigned const char cov_2char[64]={
0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A
};
-void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
- DES_LONG Eswap0, DES_LONG Eswap1);
-
char *DES_crypt(const char *buf, const char *salt)
{
static char buff[14];
diff --git a/crypto/openssl/crypto/des/read2pwd.c b/crypto/openssl/crypto/des/read2pwd.c
index 3a63c4016ccf..ee6969f76eb5 100644
--- a/crypto/openssl/crypto/des/read2pwd.c
+++ b/crypto/openssl/crypto/des/read2pwd.c
@@ -112,6 +112,7 @@
#include <string.h>
#include <openssl/des.h>
#include <openssl/ui.h>
+#include <openssl/crypto.h>
int DES_read_password(DES_cblock *key, const char *prompt, int verify)
{
diff --git a/crypto/openssl/crypto/des/set_key.c b/crypto/openssl/crypto/des/set_key.c
index 8881d46a7ad6..55efe03f4233 100644
--- a/crypto/openssl/crypto/des/set_key.c
+++ b/crypto/openssl/crypto/des/set_key.c
@@ -65,8 +65,6 @@
*/
#include "des_locl.h"
-#ifndef OPENSSL_FIPS
-
OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */
static const unsigned char odd_parity[256]={
@@ -89,7 +87,7 @@ static const unsigned char odd_parity[256]={
void DES_set_odd_parity(DES_cblock *key)
{
- int i;
+ unsigned int i;
for (i=0; i<DES_KEY_SZ; i++)
(*key)[i]=odd_parity[(*key)[i]];
@@ -97,7 +95,7 @@ void DES_set_odd_parity(DES_cblock *key)
int DES_check_key_parity(const_DES_cblock *key)
{
- int i;
+ unsigned int i;
for (i=0; i<DES_KEY_SZ; i++)
{
@@ -407,5 +405,3 @@ void des_fixup_key_parity(des_cblock *key)
des_set_odd_parity(key);
}
*/
-
-#endif /* ndef OPENSSL_FIPS */
diff --git a/crypto/openssl/crypto/des/speed.c b/crypto/openssl/crypto/des/speed.c
index 48fc1d49fc24..1616f4b7c959 100644
--- a/crypto/openssl/crypto/des/speed.c
+++ b/crypto/openssl/crypto/des/speed.c
@@ -69,7 +69,11 @@
#include OPENSSL_UNISTD_IO
OPENSSL_DECLARE_EXIT
+#ifndef OPENSSL_SYS_NETWARE
#include <signal.h>
+#define crypt(c,s) (des_crypt((c),(s)))
+#endif
+
#ifndef _IRIX
#include <time.h>
#endif
diff --git a/crypto/openssl/crypto/des/str2key.c b/crypto/openssl/crypto/des/str2key.c
index 0373db469c9a..9c2054bda6b9 100644
--- a/crypto/openssl/crypto/des/str2key.c
+++ b/crypto/openssl/crypto/des/str2key.c
@@ -57,6 +57,7 @@
*/
#include "des_locl.h"
+#include <openssl/crypto.h>
void DES_string_to_key(const char *str, DES_cblock *key)
{