summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/des')
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl126
-rw-r--r--src/lib/libcrypto/des/Makefile.uni20
-rw-r--r--src/lib/libcrypto/des/VERSION1
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl4
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl4
-rw-r--r--src/lib/libcrypto/des/asm/des686.pl2
-rw-r--r--src/lib/libcrypto/des/asm/desboth.pl8
-rw-r--r--src/lib/libcrypto/des/asm/dx86unix.cpp3202
-rw-r--r--src/lib/libcrypto/des/asm/yx86unix.cpp976
-rw-r--r--src/lib/libcrypto/des/cbc3_enc.c12
-rw-r--r--src/lib/libcrypto/des/cbc_cksm.c16
-rw-r--r--src/lib/libcrypto/des/cbc_enc.c78
-rw-r--r--src/lib/libcrypto/des/cfb64ede.c36
-rw-r--r--src/lib/libcrypto/des/cfb64enc.c27
-rw-r--r--src/lib/libcrypto/des/cfb_enc.c14
-rw-r--r--src/lib/libcrypto/des/des-lib.com1003
-rw-r--r--src/lib/libcrypto/des/des.c121
-rw-r--r--src/lib/libcrypto/des/des.h249
-rw-r--r--src/lib/libcrypto/des/des.org301
-rw-r--r--src/lib/libcrypto/des/des.pl2
-rw-r--r--src/lib/libcrypto/des/des3s.cpp2
-rw-r--r--src/lib/libcrypto/des/des_enc.c140
-rw-r--r--src/lib/libcrypto/des/des_locl.h (renamed from src/lib/libcrypto/des/des_locl.org)172
-rw-r--r--src/lib/libcrypto/des/des_opts.c62
-rw-r--r--src/lib/libcrypto/des/des_ver.h5
-rw-r--r--src/lib/libcrypto/des/dess.cpp2
-rw-r--r--src/lib/libcrypto/des/destest.c295
-rw-r--r--src/lib/libcrypto/des/ecb3_enc.c15
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c24
-rw-r--r--src/lib/libcrypto/des/ede_cbcm_enc.c197
-rw-r--r--src/lib/libcrypto/des/ede_enc.c190
-rw-r--r--src/lib/libcrypto/des/enc_read.c84
-rw-r--r--src/lib/libcrypto/des/enc_writ.c62
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c9
-rw-r--r--src/lib/libcrypto/des/ncbc_enc.c41
-rw-r--r--src/lib/libcrypto/des/ofb64ede.c27
-rw-r--r--src/lib/libcrypto/des/ofb64enc.c22
-rw-r--r--src/lib/libcrypto/des/ofb_enc.c13
-rw-r--r--src/lib/libcrypto/des/pcbc_enc.c18
-rw-r--r--src/lib/libcrypto/des/qud_cksm.c16
-rw-r--r--src/lib/libcrypto/des/rand_key.c22
-rw-r--r--src/lib/libcrypto/des/ranlib.sh23
-rw-r--r--src/lib/libcrypto/des/read2pwd.c12
-rw-r--r--src/lib/libcrypto/des/read_pwd.c145
-rw-r--r--src/lib/libcrypto/des/rpc_enc.c23
-rw-r--r--src/lib/libcrypto/des/rpw.c10
-rw-r--r--src/lib/libcrypto/des/set_key.c36
-rw-r--r--src/lib/libcrypto/des/shifts.pl2
-rw-r--r--src/lib/libcrypto/des/speed.c77
-rw-r--r--src/lib/libcrypto/des/spr.h2
-rw-r--r--src/lib/libcrypto/des/str2key.c34
-rw-r--r--src/lib/libcrypto/des/supp.c8
-rw-r--r--src/lib/libcrypto/des/testdes.pl2
-rw-r--r--src/lib/libcrypto/des/vms.com90
-rw-r--r--src/lib/libcrypto/des/xcbc_enc.c56
55 files changed, 2247 insertions, 5893 deletions
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
index 78b5189ee3..09fdd07305 100644
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -6,11 +6,13 @@ DIR= des
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES= 9INCLUDES=-I../../include
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
11INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
14MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
15AR= ar r 17AR= ar r
16DES_ENC= des_enc.o fcrypt_b.o 18DES_ENC= des_enc.o fcrypt_b.o
@@ -19,7 +21,7 @@ DES_ENC= des_enc.o fcrypt_b.o
19 21
20CFLAGS= $(INCLUDES) $(CFLAG) 22CFLAGS= $(INCLUDES) $(CFLAG)
21 23
22GENERAL=Makefile des.org des_locl.org 24GENERAL=Makefile
23TEST=destest.c 25TEST=destest.c
24APPS= 26APPS=
25 27
@@ -30,14 +32,15 @@ LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
30 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ 32 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
31 des_enc.c fcrypt_b.c read2pwd.c \ 33 des_enc.c fcrypt_b.c read2pwd.c \
32 fcrypt.c xcbc_enc.c \ 34 fcrypt.c xcbc_enc.c \
33 str2key.c cfb64ede.c ofb64ede.c supp.c 35 str2key.c cfb64ede.c ofb64ede.c supp.c ede_cbcm_enc.c
34 36
35LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ 37LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
36 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ 38 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
37 enc_read.o enc_writ.o ofb64enc.o \ 39 enc_read.o enc_writ.o ofb64enc.o \
38 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ 40 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
39 ${DES_ENC} read2pwd.o \ 41 ${DES_ENC} read2pwd.o \
40 fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o 42 fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o \
43 ede_cbcm_enc.o
41 44
42SRC= $(LIBSRC) 45SRC= $(LIBSRC)
43 46
@@ -53,9 +56,12 @@ all: lib
53 56
54lib: $(LIBOBJ) 57lib: $(LIBOBJ)
55 $(AR) $(LIB) $(LIBOBJ) 58 $(AR) $(LIB) $(LIBOBJ)
56 sh $(TOP)/util/ranlib.sh $(LIB) 59 $(RANLIB) $(LIB)
57 @touch lib 60 @touch lib
58 61
62des: des.o cbc3_enc.o lib
63 $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
64
59# elf 65# elf
60asm/dx86-elf.o: asm/dx86unix.cpp 66asm/dx86-elf.o: asm/dx86unix.cpp
61 $(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o 67 $(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o
@@ -83,38 +89,34 @@ asm/yx86-out.o: asm/yx86unix.cpp
83 89
84# bsdi 90# bsdi
85asm/dx86bsdi.o: asm/dx86unix.cpp 91asm/dx86bsdi.o: asm/dx86unix.cpp
86 $(CPP) -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o 92 $(CPP) -DBSDI asm/dx86unix.cpp | sed 's/ :/:/' | as -o asm/dx86bsdi.o
87 93
88asm/yx86bsdi.o: asm/yx86unix.cpp 94asm/yx86bsdi.o: asm/yx86unix.cpp
89 $(CPP) -DBSDI asm/yx86unix.cpp | as -o asm/yx86bsdi.o 95 $(CPP) -DBSDI asm/yx86unix.cpp | sed 's/ :/:/' | as -o asm/yx86bsdi.o
90 96
91asm/dx86unix.cpp: 97asm/dx86unix.cpp: asm/des-586.pl
92 (cd asm; perl des-586.pl cpp >dx86unix.cpp) 98 (cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp)
93 99
94asm/yx86unix.cpp: 100asm/yx86unix.cpp: asm/crypt586.pl
95 (cd asm; perl crypt586.pl cpp >yx86unix.cpp) 101 (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp)
96 102
97files: 103files:
98 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 104 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
99 105
100links: 106links:
101 /bin/rm -f Makefile 107 @$(TOP)/util/point.sh Makefile.ssl Makefile
102 $(TOP)/util/point.sh Makefile.ssl Makefile 108 @$(TOP)/util/point.sh ../../perlasm asm/perlasm
103 /bin/rm -f des.doc 109 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
104 /bin/rm -fr asm/perlasm 110 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
105 $(TOP)/util/point.sh ../../perlasm asm/perlasm 111 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
106 $(TOP)/util/point.sh ../../doc/des.doc des.doc
107 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
108 $(TOP)/util/mklink.sh ../../test $(TEST)
109 $(TOP)/util/mklink.sh ../../apps $(APPS)
110 112
111install: installs 113install: installs
112 114
113installs: 115installs:
114 @for i in $(EXHEADER) ; \ 116 @for i in $(EXHEADER) ; \
115 do \ 117 do \
116 (cp $$i $(INSTALLTOP)/include/$$i; \ 118 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
117 chmod 644 $(INSTALLTOP)/include/$$i ); \ 119 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
118 done; 120 done;
119 121
120tags: 122tags:
@@ -126,15 +128,81 @@ lint:
126 lint -DLINT $(INCLUDES) $(SRC)>fluff 128 lint -DLINT $(INCLUDES) $(SRC)>fluff
127 129
128depend: 130depend:
129 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) 131 $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
130 132
131dclean: 133dclean:
132 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 134 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
133 mv -f Makefile.new $(MAKEFILE) 135 mv -f Makefile.new $(MAKEFILE)
134 136
135clean: 137clean:
136 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 138 rm -f asm/dx86unix.cpp asm/yx86unix.cpp *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
137
138errors:
139 139
140# DO NOT DELETE THIS LINE -- make depend depends on it. 140# DO NOT DELETE THIS LINE -- make depend depends on it.
141
142cbc_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
143cbc_cksm.o: ../../include/openssl/opensslconf.h des_locl.h
144cbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
145cbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h ncbc_enc.c
146cfb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
147cfb64ede.o: ../../include/openssl/opensslconf.h des_locl.h
148cfb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
149cfb64enc.o: ../../include/openssl/opensslconf.h des_locl.h
150cfb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
151cfb_enc.o: ../../include/openssl/opensslconf.h des_locl.h
152des_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
153des_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_locl.h ncbc_enc.c
154ecb3_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
155ecb3_enc.o: ../../include/openssl/opensslconf.h des_locl.h
156ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
157ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
158ecb_enc.o: des_locl.h spr.h
159ede_cbcm_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
160ede_cbcm_enc.o: ../../include/openssl/opensslconf.h des_locl.h
161enc_read.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
162enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
163enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
164enc_read.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
165enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h
166enc_read.o: ../cryptlib.h des_locl.h
167enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
168enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
169enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
170enc_writ.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
171enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
172enc_writ.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h
173fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des.h
174fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/e_os2.h
175fcrypt.o: ../../include/openssl/opensslconf.h
176fcrypt.o: ../../include/openssl/opensslconf.h des_locl.h des_locl.h
177fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
178fcrypt_b.o: ../../include/openssl/opensslconf.h des_locl.h
179ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
180ofb64ede.o: ../../include/openssl/opensslconf.h des_locl.h
181ofb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
182ofb64enc.o: ../../include/openssl/opensslconf.h des_locl.h
183ofb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
184ofb_enc.o: ../../include/openssl/opensslconf.h des_locl.h
185pcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
186pcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h
187qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
188qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h
189rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
190rand_key.o: ../../include/openssl/opensslconf.h des_locl.h
191read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
192read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h
193read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
194read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
195read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
196read_pwd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
197read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h
198read_pwd.o: ../cryptlib.h des_locl.h
199rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
200rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h
201set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
202set_key.o: ../../include/openssl/opensslconf.h des_locl.h podd.h sk.h
203str2key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
204str2key.o: ../../include/openssl/opensslconf.h des_locl.h
205supp.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
206supp.o: ../../include/openssl/opensslconf.h des_locl.h
207xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
208xcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h
diff --git a/src/lib/libcrypto/des/Makefile.uni b/src/lib/libcrypto/des/Makefile.uni
index 8f1759748a..ec19d75b81 100644
--- a/src/lib/libcrypto/des/Makefile.uni
+++ b/src/lib/libcrypto/des/Makefile.uni
@@ -51,6 +51,7 @@ CFLAG= -O3 -fomit-frame-pointer
51CFLAGS=$(OPTS) $(CFLAG) 51CFLAGS=$(OPTS) $(CFLAG)
52CPP=$(CC) -E 52CPP=$(CC) -E
53AS=as 53AS=as
54RANLIB=ranlib
54 55
55# Assember version of des_encrypt*(). 56# Assember version of des_encrypt*().
56DES_ENC=des_enc.o fcrypt_b.o # normal C version 57DES_ENC=des_enc.o fcrypt_b.o # normal C version
@@ -169,9 +170,7 @@ test: all
169$(DLIB): $(OBJ) 170$(DLIB): $(OBJ)
170 /bin/rm -f $(DLIB) 171 /bin/rm -f $(DLIB)
171 ar cr $(DLIB) $(OBJ) 172 ar cr $(DLIB) $(OBJ)
172 -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \ 173 $(RANLIB) $(DLIB)
173 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
174 else exit 0; fi; fi
175 174
176des_opts: des_opts.o $(DLIB) 175des_opts: des_opts.o $(DLIB)
177 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB) 176 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
@@ -231,25 +230,14 @@ install: des
231 if test $(INSTALLTOP); then \ 230 if test $(INSTALLTOP); then \
232 echo SSL style install; \ 231 echo SSL style install; \
233 cp $(DLIB) $(INSTALLTOP)/lib; \ 232 cp $(DLIB) $(INSTALLTOP)/lib; \
234 if test -s /bin/ranlib; then \ 233 $(RANLIB) $(DLIB); \
235 /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
236 else \
237 if test -s /usr/bin/ranlib; then \
238 /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
239 fi; fi; \
240 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \ 234 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
241 cp des.h $(INSTALLTOP)/include; \ 235 cp des.h $(INSTALLTOP)/include; \
242 chmod 644 $(INSTALLTOP)/include/des.h; \ 236 chmod 644 $(INSTALLTOP)/include/des.h; \
243 else \ 237 else \
244 echo Standalone install; \ 238 echo Standalone install; \
245 cp $(DLIB) $(LIBDIR)/$(DLIB); \ 239 cp $(DLIB) $(LIBDIR)/$(DLIB); \
246 if test -s /bin/ranlib; then \ 240 $(RANLIB) $(DLIB); \
247 /bin/ranlib $(LIBDIR)/$(DLIB); \
248 else \
249 if test -s /usr/bin/ranlib; then \
250 /usr/bin/ranlib $(LIBDIR)/$(DLIB); \
251 fi; \
252 fi; \
253 chmod 644 $(LIBDIR)/$(DLIB); \ 241 chmod 644 $(LIBDIR)/$(DLIB); \
254 cp des $(BINDIR)/des; \ 242 cp des $(BINDIR)/des; \
255 chmod 711 $(BINDIR)/des; \ 243 chmod 711 $(BINDIR)/des; \
diff --git a/src/lib/libcrypto/des/VERSION b/src/lib/libcrypto/des/VERSION
index f62d8bdac0..c7d01542bc 100644
--- a/src/lib/libcrypto/des/VERSION
+++ b/src/lib/libcrypto/des/VERSION
@@ -1,3 +1,4 @@
1 Fixed the weak key values which were wrong :-(
1 Defining SIGACTION causes sigaction() to be used instead of signal(). 2 Defining SIGACTION causes sigaction() to be used instead of signal().
2 SIGUSR1/SIGUSR2 are no longer mapped in the read tty stuff because it 3 SIGUSR1/SIGUSR2 are no longer mapped in the read tty stuff because it
3 can cause problems. This should hopefully not affect normal 4 can cause problems. This should hopefully not affect normal
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl
index 297e38dec8..197c413ea6 100644
--- a/src/lib/libcrypto/des/asm/crypt586.pl
+++ b/src/lib/libcrypto/des/asm/crypt586.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2# 2#
3# The inner loop instruction sequence and the IP/FP modifications are from 3# The inner loop instruction sequence and the IP/FP modifications are from
4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> 4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
@@ -32,7 +32,7 @@ sub fcrypt_body
32 &xor( $R, $R); 32 &xor( $R, $R);
33 &mov($ks,&wparam(1)); 33 &mov($ks,&wparam(1));
34 34
35 &push(25); # add a variable 35 &push(&DWC(25)); # add a variable
36 36
37 &set_label("start"); 37 &set_label("start");
38 for ($i=0; $i<16; $i+=2) 38 for ($i=0; $i<16; $i+=2)
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
index 7f2e09fa7a..f054071077 100644
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ b/src/lib/libcrypto/des/asm/des-586.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2# 2#
3# The inner loop instruction sequence and the IP/FP modifications are from 3# The inner loop instruction sequence and the IP/FP modifications are from
4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> 4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
@@ -187,6 +187,8 @@ sub R_PERM_OP
187 &mov( $tt, $a ); 187 &mov( $tt, $a );
188 &xor( $a, $b ); 188 &xor( $a, $b );
189 &and( $a, $mask ); 189 &and( $a, $mask );
190 # This can never succeed, and besides it is difficult to see what the
191 # idea was - Ben 13 Feb 99
190 if (!$last eq $b) 192 if (!$last eq $b)
191 { 193 {
192 &xor( $b, $a ); 194 &xor( $b, $a );
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl
index cf1a82fb5c..77dc5b51cd 100644
--- a/src/lib/libcrypto/des/asm/des686.pl
+++ b/src/lib/libcrypto/des/asm/des686.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3$prog="des686.pl"; 3$prog="des686.pl";
4 4
diff --git a/src/lib/libcrypto/des/asm/desboth.pl b/src/lib/libcrypto/des/asm/desboth.pl
index 8f939953a6..d5106414db 100644
--- a/src/lib/libcrypto/des/asm/desboth.pl
+++ b/src/lib/libcrypto/des/asm/desboth.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3$L="edi"; 3$L="edi";
4$R="esi"; 4$R="esi";
@@ -44,15 +44,15 @@ sub des_encrypt3
44 &mov("edi",&wparam(2)); 44 &mov("edi",&wparam(2));
45 &mov("eax",&wparam(3)); 45 &mov("eax",&wparam(3));
46 } 46 }
47 &mov(&swtmp(2), (($enc)?"1":"0")); 47 &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
48 &mov(&swtmp(1), "eax"); 48 &mov(&swtmp(1), "eax");
49 &mov(&swtmp(0), "ebx"); 49 &mov(&swtmp(0), "ebx");
50 &call("des_encrypt2"); 50 &call("des_encrypt2");
51 &mov(&swtmp(2), (($enc)?"0":"1")); 51 &mov(&swtmp(2), (DWC(($enc)?"0":"1")));
52 &mov(&swtmp(1), "edi"); 52 &mov(&swtmp(1), "edi");
53 &mov(&swtmp(0), "ebx"); 53 &mov(&swtmp(0), "ebx");
54 &call("des_encrypt2"); 54 &call("des_encrypt2");
55 &mov(&swtmp(2), (($enc)?"1":"0")); 55 &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
56 &mov(&swtmp(1), "esi"); 56 &mov(&swtmp(1), "esi");
57 &mov(&swtmp(0), "ebx"); 57 &mov(&swtmp(0), "ebx");
58 &call("des_encrypt2"); 58 &call("des_encrypt2");
diff --git a/src/lib/libcrypto/des/asm/dx86unix.cpp b/src/lib/libcrypto/des/asm/dx86unix.cpp
deleted file mode 100644
index 6fca9afa16..0000000000
--- a/src/lib/libcrypto/des/asm/dx86unix.cpp
+++ /dev/null
@@ -1,3202 +0,0 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define des_SPtrans _des_SPtrans
13#define des_encrypt _des_encrypt
14#define des_encrypt2 _des_encrypt2
15#define des_encrypt3 _des_encrypt3
16#define des_decrypt3 _des_decrypt3
17#define des_ncbc_encrypt _des_ncbc_encrypt
18#define des_ede3_cbc_encrypt _des_ede3_cbc_encrypt
19
20#endif
21
22#ifdef OUT
23#define OK 1
24#define ALIGN 4
25#endif
26
27#ifdef BSDI
28#define OK 1
29#define ALIGN 4
30#undef SIZE
31#undef TYPE
32#define SIZE(a,b)
33#define TYPE(a,b)
34#endif
35
36#if defined(ELF) || defined(SOL)
37#define OK 1
38#define ALIGN 16
39#endif
40
41#ifndef OK
42You need to define one of
43ELF - elf systems - linux-elf, NetBSD and DG-UX
44OUT - a.out systems - linux-a.out and FreeBSD
45SOL - solaris systems, which are elf with strange comment lines
46BSDI - a.out with a very primative version of as.
47#endif
48
49/* Let the Assembler begin :-) */
50 /* Don't even think of reading this code */
51 /* It was automatically generated by des-586.pl */
52 /* Which is a perl program used to generate the x86 assember for */
53 /* any of elf, a.out, BSDI,Win32, or Solaris */
54 /* eric <eay@cryptsoft.com> */
55
56 .file "des-586.s"
57 .version "01.01"
58gcc2_compiled.:
59.text
60 .align ALIGN
61.globl des_encrypt
62 TYPE(des_encrypt,@function)
63des_encrypt:
64 pushl %esi
65 pushl %edi
66
67 /* Load the 2 words */
68 movl 12(%esp), %esi
69 xorl %ecx, %ecx
70 pushl %ebx
71 pushl %ebp
72 movl (%esi), %eax
73 movl 28(%esp), %ebx
74 movl 4(%esi), %edi
75
76 /* IP */
77 roll $4, %eax
78 movl %eax, %esi
79 xorl %edi, %eax
80 andl $0xf0f0f0f0, %eax
81 xorl %eax, %esi
82 xorl %eax, %edi
83
84 roll $20, %edi
85 movl %edi, %eax
86 xorl %esi, %edi
87 andl $0xfff0000f, %edi
88 xorl %edi, %eax
89 xorl %edi, %esi
90
91 roll $14, %eax
92 movl %eax, %edi
93 xorl %esi, %eax
94 andl $0x33333333, %eax
95 xorl %eax, %edi
96 xorl %eax, %esi
97
98 roll $22, %esi
99 movl %esi, %eax
100 xorl %edi, %esi
101 andl $0x03fc03fc, %esi
102 xorl %esi, %eax
103 xorl %esi, %edi
104
105 roll $9, %eax
106 movl %eax, %esi
107 xorl %edi, %eax
108 andl $0xaaaaaaaa, %eax
109 xorl %eax, %esi
110 xorl %eax, %edi
111
112.byte 209
113.byte 199 /* roll $1 %edi */
114 movl 24(%esp), %ebp
115 cmpl $0, %ebx
116 je .L000start_decrypt
117
118 /* Round 0 */
119 movl (%ebp), %eax
120 xorl %ebx, %ebx
121 movl 4(%ebp), %edx
122 xorl %esi, %eax
123 xorl %esi, %edx
124 andl $0xfcfcfcfc, %eax
125 andl $0xcfcfcfcf, %edx
126 movb %al, %bl
127 movb %ah, %cl
128 rorl $4, %edx
129 movl des_SPtrans(%ebx),%ebp
130 movb %dl, %bl
131 xorl %ebp, %edi
132 movl 0x200+des_SPtrans(%ecx),%ebp
133 xorl %ebp, %edi
134 movb %dh, %cl
135 shrl $16, %eax
136 movl 0x100+des_SPtrans(%ebx),%ebp
137 xorl %ebp, %edi
138 movb %ah, %bl
139 shrl $16, %edx
140 movl 0x300+des_SPtrans(%ecx),%ebp
141 xorl %ebp, %edi
142 movl 24(%esp), %ebp
143 movb %dh, %cl
144 andl $0xff, %eax
145 andl $0xff, %edx
146 movl 0x600+des_SPtrans(%ebx),%ebx
147 xorl %ebx, %edi
148 movl 0x700+des_SPtrans(%ecx),%ebx
149 xorl %ebx, %edi
150 movl 0x400+des_SPtrans(%eax),%ebx
151 xorl %ebx, %edi
152 movl 0x500+des_SPtrans(%edx),%ebx
153 xorl %ebx, %edi
154
155 /* Round 1 */
156 movl 8(%ebp), %eax
157 xorl %ebx, %ebx
158 movl 12(%ebp), %edx
159 xorl %edi, %eax
160 xorl %edi, %edx
161 andl $0xfcfcfcfc, %eax
162 andl $0xcfcfcfcf, %edx
163 movb %al, %bl
164 movb %ah, %cl
165 rorl $4, %edx
166 movl des_SPtrans(%ebx),%ebp
167 movb %dl, %bl
168 xorl %ebp, %esi
169 movl 0x200+des_SPtrans(%ecx),%ebp
170 xorl %ebp, %esi
171 movb %dh, %cl
172 shrl $16, %eax
173 movl 0x100+des_SPtrans(%ebx),%ebp
174 xorl %ebp, %esi
175 movb %ah, %bl
176 shrl $16, %edx
177 movl 0x300+des_SPtrans(%ecx),%ebp
178 xorl %ebp, %esi
179 movl 24(%esp), %ebp
180 movb %dh, %cl
181 andl $0xff, %eax
182 andl $0xff, %edx
183 movl 0x600+des_SPtrans(%ebx),%ebx
184 xorl %ebx, %esi
185 movl 0x700+des_SPtrans(%ecx),%ebx
186 xorl %ebx, %esi
187 movl 0x400+des_SPtrans(%eax),%ebx
188 xorl %ebx, %esi
189 movl 0x500+des_SPtrans(%edx),%ebx
190 xorl %ebx, %esi
191
192 /* Round 2 */
193 movl 16(%ebp), %eax
194 xorl %ebx, %ebx
195 movl 20(%ebp), %edx
196 xorl %esi, %eax
197 xorl %esi, %edx
198 andl $0xfcfcfcfc, %eax
199 andl $0xcfcfcfcf, %edx
200 movb %al, %bl
201 movb %ah, %cl
202 rorl $4, %edx
203 movl des_SPtrans(%ebx),%ebp
204 movb %dl, %bl
205 xorl %ebp, %edi
206 movl 0x200+des_SPtrans(%ecx),%ebp
207 xorl %ebp, %edi
208 movb %dh, %cl
209 shrl $16, %eax
210 movl 0x100+des_SPtrans(%ebx),%ebp
211 xorl %ebp, %edi
212 movb %ah, %bl
213 shrl $16, %edx
214 movl 0x300+des_SPtrans(%ecx),%ebp
215 xorl %ebp, %edi
216 movl 24(%esp), %ebp
217 movb %dh, %cl
218 andl $0xff, %eax
219 andl $0xff, %edx
220 movl 0x600+des_SPtrans(%ebx),%ebx
221 xorl %ebx, %edi
222 movl 0x700+des_SPtrans(%ecx),%ebx
223 xorl %ebx, %edi
224 movl 0x400+des_SPtrans(%eax),%ebx
225 xorl %ebx, %edi
226 movl 0x500+des_SPtrans(%edx),%ebx
227 xorl %ebx, %edi
228
229 /* Round 3 */
230 movl 24(%ebp), %eax
231 xorl %ebx, %ebx
232 movl 28(%ebp), %edx
233 xorl %edi, %eax
234 xorl %edi, %edx
235 andl $0xfcfcfcfc, %eax
236 andl $0xcfcfcfcf, %edx
237 movb %al, %bl
238 movb %ah, %cl
239 rorl $4, %edx
240 movl des_SPtrans(%ebx),%ebp
241 movb %dl, %bl
242 xorl %ebp, %esi
243 movl 0x200+des_SPtrans(%ecx),%ebp
244 xorl %ebp, %esi
245 movb %dh, %cl
246 shrl $16, %eax
247 movl 0x100+des_SPtrans(%ebx),%ebp
248 xorl %ebp, %esi
249 movb %ah, %bl
250 shrl $16, %edx
251 movl 0x300+des_SPtrans(%ecx),%ebp
252 xorl %ebp, %esi
253 movl 24(%esp), %ebp
254 movb %dh, %cl
255 andl $0xff, %eax
256 andl $0xff, %edx
257 movl 0x600+des_SPtrans(%ebx),%ebx
258 xorl %ebx, %esi
259 movl 0x700+des_SPtrans(%ecx),%ebx
260 xorl %ebx, %esi
261 movl 0x400+des_SPtrans(%eax),%ebx
262 xorl %ebx, %esi
263 movl 0x500+des_SPtrans(%edx),%ebx
264 xorl %ebx, %esi
265
266 /* Round 4 */
267 movl 32(%ebp), %eax
268 xorl %ebx, %ebx
269 movl 36(%ebp), %edx
270 xorl %esi, %eax
271 xorl %esi, %edx
272 andl $0xfcfcfcfc, %eax
273 andl $0xcfcfcfcf, %edx
274 movb %al, %bl
275 movb %ah, %cl
276 rorl $4, %edx
277 movl des_SPtrans(%ebx),%ebp
278 movb %dl, %bl
279 xorl %ebp, %edi
280 movl 0x200+des_SPtrans(%ecx),%ebp
281 xorl %ebp, %edi
282 movb %dh, %cl
283 shrl $16, %eax
284 movl 0x100+des_SPtrans(%ebx),%ebp
285 xorl %ebp, %edi
286 movb %ah, %bl
287 shrl $16, %edx
288 movl 0x300+des_SPtrans(%ecx),%ebp
289 xorl %ebp, %edi
290 movl 24(%esp), %ebp
291 movb %dh, %cl
292 andl $0xff, %eax
293 andl $0xff, %edx
294 movl 0x600+des_SPtrans(%ebx),%ebx
295 xorl %ebx, %edi
296 movl 0x700+des_SPtrans(%ecx),%ebx
297 xorl %ebx, %edi
298 movl 0x400+des_SPtrans(%eax),%ebx
299 xorl %ebx, %edi
300 movl 0x500+des_SPtrans(%edx),%ebx
301 xorl %ebx, %edi
302
303 /* Round 5 */
304 movl 40(%ebp), %eax
305 xorl %ebx, %ebx
306 movl 44(%ebp), %edx
307 xorl %edi, %eax
308 xorl %edi, %edx
309 andl $0xfcfcfcfc, %eax
310 andl $0xcfcfcfcf, %edx
311 movb %al, %bl
312 movb %ah, %cl
313 rorl $4, %edx
314 movl des_SPtrans(%ebx),%ebp
315 movb %dl, %bl
316 xorl %ebp, %esi
317 movl 0x200+des_SPtrans(%ecx),%ebp
318 xorl %ebp, %esi
319 movb %dh, %cl
320 shrl $16, %eax
321 movl 0x100+des_SPtrans(%ebx),%ebp
322 xorl %ebp, %esi
323 movb %ah, %bl
324 shrl $16, %edx
325 movl 0x300+des_SPtrans(%ecx),%ebp
326 xorl %ebp, %esi
327 movl 24(%esp), %ebp
328 movb %dh, %cl
329 andl $0xff, %eax
330 andl $0xff, %edx
331 movl 0x600+des_SPtrans(%ebx),%ebx
332 xorl %ebx, %esi
333 movl 0x700+des_SPtrans(%ecx),%ebx
334 xorl %ebx, %esi
335 movl 0x400+des_SPtrans(%eax),%ebx
336 xorl %ebx, %esi
337 movl 0x500+des_SPtrans(%edx),%ebx
338 xorl %ebx, %esi
339
340 /* Round 6 */
341 movl 48(%ebp), %eax
342 xorl %ebx, %ebx
343 movl 52(%ebp), %edx
344 xorl %esi, %eax
345 xorl %esi, %edx
346 andl $0xfcfcfcfc, %eax
347 andl $0xcfcfcfcf, %edx
348 movb %al, %bl
349 movb %ah, %cl
350 rorl $4, %edx
351 movl des_SPtrans(%ebx),%ebp
352 movb %dl, %bl
353 xorl %ebp, %edi
354 movl 0x200+des_SPtrans(%ecx),%ebp
355 xorl %ebp, %edi
356 movb %dh, %cl
357 shrl $16, %eax
358 movl 0x100+des_SPtrans(%ebx),%ebp
359 xorl %ebp, %edi
360 movb %ah, %bl
361 shrl $16, %edx
362 movl 0x300+des_SPtrans(%ecx),%ebp
363 xorl %ebp, %edi
364 movl 24(%esp), %ebp
365 movb %dh, %cl
366 andl $0xff, %eax
367 andl $0xff, %edx
368 movl 0x600+des_SPtrans(%ebx),%ebx
369 xorl %ebx, %edi
370 movl 0x700+des_SPtrans(%ecx),%ebx
371 xorl %ebx, %edi
372 movl 0x400+des_SPtrans(%eax),%ebx
373 xorl %ebx, %edi
374 movl 0x500+des_SPtrans(%edx),%ebx
375 xorl %ebx, %edi
376
377 /* Round 7 */
378 movl 56(%ebp), %eax
379 xorl %ebx, %ebx
380 movl 60(%ebp), %edx
381 xorl %edi, %eax
382 xorl %edi, %edx
383 andl $0xfcfcfcfc, %eax
384 andl $0xcfcfcfcf, %edx
385 movb %al, %bl
386 movb %ah, %cl
387 rorl $4, %edx
388 movl des_SPtrans(%ebx),%ebp
389 movb %dl, %bl
390 xorl %ebp, %esi
391 movl 0x200+des_SPtrans(%ecx),%ebp
392 xorl %ebp, %esi
393 movb %dh, %cl
394 shrl $16, %eax
395 movl 0x100+des_SPtrans(%ebx),%ebp
396 xorl %ebp, %esi
397 movb %ah, %bl
398 shrl $16, %edx
399 movl 0x300+des_SPtrans(%ecx),%ebp
400 xorl %ebp, %esi
401 movl 24(%esp), %ebp
402 movb %dh, %cl
403 andl $0xff, %eax
404 andl $0xff, %edx
405 movl 0x600+des_SPtrans(%ebx),%ebx
406 xorl %ebx, %esi
407 movl 0x700+des_SPtrans(%ecx),%ebx
408 xorl %ebx, %esi
409 movl 0x400+des_SPtrans(%eax),%ebx
410 xorl %ebx, %esi
411 movl 0x500+des_SPtrans(%edx),%ebx
412 xorl %ebx, %esi
413
414 /* Round 8 */
415 movl 64(%ebp), %eax
416 xorl %ebx, %ebx
417 movl 68(%ebp), %edx
418 xorl %esi, %eax
419 xorl %esi, %edx
420 andl $0xfcfcfcfc, %eax
421 andl $0xcfcfcfcf, %edx
422 movb %al, %bl
423 movb %ah, %cl
424 rorl $4, %edx
425 movl des_SPtrans(%ebx),%ebp
426 movb %dl, %bl
427 xorl %ebp, %edi
428 movl 0x200+des_SPtrans(%ecx),%ebp
429 xorl %ebp, %edi
430 movb %dh, %cl
431 shrl $16, %eax
432 movl 0x100+des_SPtrans(%ebx),%ebp
433 xorl %ebp, %edi
434 movb %ah, %bl
435 shrl $16, %edx
436 movl 0x300+des_SPtrans(%ecx),%ebp
437 xorl %ebp, %edi
438 movl 24(%esp), %ebp
439 movb %dh, %cl
440 andl $0xff, %eax
441 andl $0xff, %edx
442 movl 0x600+des_SPtrans(%ebx),%ebx
443 xorl %ebx, %edi
444 movl 0x700+des_SPtrans(%ecx),%ebx
445 xorl %ebx, %edi
446 movl 0x400+des_SPtrans(%eax),%ebx
447 xorl %ebx, %edi
448 movl 0x500+des_SPtrans(%edx),%ebx
449 xorl %ebx, %edi
450
451 /* Round 9 */
452 movl 72(%ebp), %eax
453 xorl %ebx, %ebx
454 movl 76(%ebp), %edx
455 xorl %edi, %eax
456 xorl %edi, %edx
457 andl $0xfcfcfcfc, %eax
458 andl $0xcfcfcfcf, %edx
459 movb %al, %bl
460 movb %ah, %cl
461 rorl $4, %edx
462 movl des_SPtrans(%ebx),%ebp
463 movb %dl, %bl
464 xorl %ebp, %esi
465 movl 0x200+des_SPtrans(%ecx),%ebp
466 xorl %ebp, %esi
467 movb %dh, %cl
468 shrl $16, %eax
469 movl 0x100+des_SPtrans(%ebx),%ebp
470 xorl %ebp, %esi
471 movb %ah, %bl
472 shrl $16, %edx
473 movl 0x300+des_SPtrans(%ecx),%ebp
474 xorl %ebp, %esi
475 movl 24(%esp), %ebp
476 movb %dh, %cl
477 andl $0xff, %eax
478 andl $0xff, %edx
479 movl 0x600+des_SPtrans(%ebx),%ebx
480 xorl %ebx, %esi
481 movl 0x700+des_SPtrans(%ecx),%ebx
482 xorl %ebx, %esi
483 movl 0x400+des_SPtrans(%eax),%ebx
484 xorl %ebx, %esi
485 movl 0x500+des_SPtrans(%edx),%ebx
486 xorl %ebx, %esi
487
488 /* Round 10 */
489 movl 80(%ebp), %eax
490 xorl %ebx, %ebx
491 movl 84(%ebp), %edx
492 xorl %esi, %eax
493 xorl %esi, %edx
494 andl $0xfcfcfcfc, %eax
495 andl $0xcfcfcfcf, %edx
496 movb %al, %bl
497 movb %ah, %cl
498 rorl $4, %edx
499 movl des_SPtrans(%ebx),%ebp
500 movb %dl, %bl
501 xorl %ebp, %edi
502 movl 0x200+des_SPtrans(%ecx),%ebp
503 xorl %ebp, %edi
504 movb %dh, %cl
505 shrl $16, %eax
506 movl 0x100+des_SPtrans(%ebx),%ebp
507 xorl %ebp, %edi
508 movb %ah, %bl
509 shrl $16, %edx
510 movl 0x300+des_SPtrans(%ecx),%ebp
511 xorl %ebp, %edi
512 movl 24(%esp), %ebp
513 movb %dh, %cl
514 andl $0xff, %eax
515 andl $0xff, %edx
516 movl 0x600+des_SPtrans(%ebx),%ebx
517 xorl %ebx, %edi
518 movl 0x700+des_SPtrans(%ecx),%ebx
519 xorl %ebx, %edi
520 movl 0x400+des_SPtrans(%eax),%ebx
521 xorl %ebx, %edi
522 movl 0x500+des_SPtrans(%edx),%ebx
523 xorl %ebx, %edi
524
525 /* Round 11 */
526 movl 88(%ebp), %eax
527 xorl %ebx, %ebx
528 movl 92(%ebp), %edx
529 xorl %edi, %eax
530 xorl %edi, %edx
531 andl $0xfcfcfcfc, %eax
532 andl $0xcfcfcfcf, %edx
533 movb %al, %bl
534 movb %ah, %cl
535 rorl $4, %edx
536 movl des_SPtrans(%ebx),%ebp
537 movb %dl, %bl
538 xorl %ebp, %esi
539 movl 0x200+des_SPtrans(%ecx),%ebp
540 xorl %ebp, %esi
541 movb %dh, %cl
542 shrl $16, %eax
543 movl 0x100+des_SPtrans(%ebx),%ebp
544 xorl %ebp, %esi
545 movb %ah, %bl
546 shrl $16, %edx
547 movl 0x300+des_SPtrans(%ecx),%ebp
548 xorl %ebp, %esi
549 movl 24(%esp), %ebp
550 movb %dh, %cl
551 andl $0xff, %eax
552 andl $0xff, %edx
553 movl 0x600+des_SPtrans(%ebx),%ebx
554 xorl %ebx, %esi
555 movl 0x700+des_SPtrans(%ecx),%ebx
556 xorl %ebx, %esi
557 movl 0x400+des_SPtrans(%eax),%ebx
558 xorl %ebx, %esi
559 movl 0x500+des_SPtrans(%edx),%ebx
560 xorl %ebx, %esi
561
562 /* Round 12 */
563 movl 96(%ebp), %eax
564 xorl %ebx, %ebx
565 movl 100(%ebp), %edx
566 xorl %esi, %eax
567 xorl %esi, %edx
568 andl $0xfcfcfcfc, %eax
569 andl $0xcfcfcfcf, %edx
570 movb %al, %bl
571 movb %ah, %cl
572 rorl $4, %edx
573 movl des_SPtrans(%ebx),%ebp
574 movb %dl, %bl
575 xorl %ebp, %edi
576 movl 0x200+des_SPtrans(%ecx),%ebp
577 xorl %ebp, %edi
578 movb %dh, %cl
579 shrl $16, %eax
580 movl 0x100+des_SPtrans(%ebx),%ebp
581 xorl %ebp, %edi
582 movb %ah, %bl
583 shrl $16, %edx
584 movl 0x300+des_SPtrans(%ecx),%ebp
585 xorl %ebp, %edi
586 movl 24(%esp), %ebp
587 movb %dh, %cl
588 andl $0xff, %eax
589 andl $0xff, %edx
590 movl 0x600+des_SPtrans(%ebx),%ebx
591 xorl %ebx, %edi
592 movl 0x700+des_SPtrans(%ecx),%ebx
593 xorl %ebx, %edi
594 movl 0x400+des_SPtrans(%eax),%ebx
595 xorl %ebx, %edi
596 movl 0x500+des_SPtrans(%edx),%ebx
597 xorl %ebx, %edi
598
599 /* Round 13 */
600 movl 104(%ebp), %eax
601 xorl %ebx, %ebx
602 movl 108(%ebp), %edx
603 xorl %edi, %eax
604 xorl %edi, %edx
605 andl $0xfcfcfcfc, %eax
606 andl $0xcfcfcfcf, %edx
607 movb %al, %bl
608 movb %ah, %cl
609 rorl $4, %edx
610 movl des_SPtrans(%ebx),%ebp
611 movb %dl, %bl
612 xorl %ebp, %esi
613 movl 0x200+des_SPtrans(%ecx),%ebp
614 xorl %ebp, %esi
615 movb %dh, %cl
616 shrl $16, %eax
617 movl 0x100+des_SPtrans(%ebx),%ebp
618 xorl %ebp, %esi
619 movb %ah, %bl
620 shrl $16, %edx
621 movl 0x300+des_SPtrans(%ecx),%ebp
622 xorl %ebp, %esi
623 movl 24(%esp), %ebp
624 movb %dh, %cl
625 andl $0xff, %eax
626 andl $0xff, %edx
627 movl 0x600+des_SPtrans(%ebx),%ebx
628 xorl %ebx, %esi
629 movl 0x700+des_SPtrans(%ecx),%ebx
630 xorl %ebx, %esi
631 movl 0x400+des_SPtrans(%eax),%ebx
632 xorl %ebx, %esi
633 movl 0x500+des_SPtrans(%edx),%ebx
634 xorl %ebx, %esi
635
636 /* Round 14 */
637 movl 112(%ebp), %eax
638 xorl %ebx, %ebx
639 movl 116(%ebp), %edx
640 xorl %esi, %eax
641 xorl %esi, %edx
642 andl $0xfcfcfcfc, %eax
643 andl $0xcfcfcfcf, %edx
644 movb %al, %bl
645 movb %ah, %cl
646 rorl $4, %edx
647 movl des_SPtrans(%ebx),%ebp
648 movb %dl, %bl
649 xorl %ebp, %edi
650 movl 0x200+des_SPtrans(%ecx),%ebp
651 xorl %ebp, %edi
652 movb %dh, %cl
653 shrl $16, %eax
654 movl 0x100+des_SPtrans(%ebx),%ebp
655 xorl %ebp, %edi
656 movb %ah, %bl
657 shrl $16, %edx
658 movl 0x300+des_SPtrans(%ecx),%ebp
659 xorl %ebp, %edi
660 movl 24(%esp), %ebp
661 movb %dh, %cl
662 andl $0xff, %eax
663 andl $0xff, %edx
664 movl 0x600+des_SPtrans(%ebx),%ebx
665 xorl %ebx, %edi
666 movl 0x700+des_SPtrans(%ecx),%ebx
667 xorl %ebx, %edi
668 movl 0x400+des_SPtrans(%eax),%ebx
669 xorl %ebx, %edi
670 movl 0x500+des_SPtrans(%edx),%ebx
671 xorl %ebx, %edi
672
673 /* Round 15 */
674 movl 120(%ebp), %eax
675 xorl %ebx, %ebx
676 movl 124(%ebp), %edx
677 xorl %edi, %eax
678 xorl %edi, %edx
679 andl $0xfcfcfcfc, %eax
680 andl $0xcfcfcfcf, %edx
681 movb %al, %bl
682 movb %ah, %cl
683 rorl $4, %edx
684 movl des_SPtrans(%ebx),%ebp
685 movb %dl, %bl
686 xorl %ebp, %esi
687 movl 0x200+des_SPtrans(%ecx),%ebp
688 xorl %ebp, %esi
689 movb %dh, %cl
690 shrl $16, %eax
691 movl 0x100+des_SPtrans(%ebx),%ebp
692 xorl %ebp, %esi
693 movb %ah, %bl
694 shrl $16, %edx
695 movl 0x300+des_SPtrans(%ecx),%ebp
696 xorl %ebp, %esi
697 movl 24(%esp), %ebp
698 movb %dh, %cl
699 andl $0xff, %eax
700 andl $0xff, %edx
701 movl 0x600+des_SPtrans(%ebx),%ebx
702 xorl %ebx, %esi
703 movl 0x700+des_SPtrans(%ecx),%ebx
704 xorl %ebx, %esi
705 movl 0x400+des_SPtrans(%eax),%ebx
706 xorl %ebx, %esi
707 movl 0x500+des_SPtrans(%edx),%ebx
708 xorl %ebx, %esi
709 jmp .L001end
710.L000start_decrypt:
711
712 /* Round 15 */
713 movl 120(%ebp), %eax
714 xorl %ebx, %ebx
715 movl 124(%ebp), %edx
716 xorl %esi, %eax
717 xorl %esi, %edx
718 andl $0xfcfcfcfc, %eax
719 andl $0xcfcfcfcf, %edx
720 movb %al, %bl
721 movb %ah, %cl
722 rorl $4, %edx
723 movl des_SPtrans(%ebx),%ebp
724 movb %dl, %bl
725 xorl %ebp, %edi
726 movl 0x200+des_SPtrans(%ecx),%ebp
727 xorl %ebp, %edi
728 movb %dh, %cl
729 shrl $16, %eax
730 movl 0x100+des_SPtrans(%ebx),%ebp
731 xorl %ebp, %edi
732 movb %ah, %bl
733 shrl $16, %edx
734 movl 0x300+des_SPtrans(%ecx),%ebp
735 xorl %ebp, %edi
736 movl 24(%esp), %ebp
737 movb %dh, %cl
738 andl $0xff, %eax
739 andl $0xff, %edx
740 movl 0x600+des_SPtrans(%ebx),%ebx
741 xorl %ebx, %edi
742 movl 0x700+des_SPtrans(%ecx),%ebx
743 xorl %ebx, %edi
744 movl 0x400+des_SPtrans(%eax),%ebx
745 xorl %ebx, %edi
746 movl 0x500+des_SPtrans(%edx),%ebx
747 xorl %ebx, %edi
748
749 /* Round 14 */
750 movl 112(%ebp), %eax
751 xorl %ebx, %ebx
752 movl 116(%ebp), %edx
753 xorl %edi, %eax
754 xorl %edi, %edx
755 andl $0xfcfcfcfc, %eax
756 andl $0xcfcfcfcf, %edx
757 movb %al, %bl
758 movb %ah, %cl
759 rorl $4, %edx
760 movl des_SPtrans(%ebx),%ebp
761 movb %dl, %bl
762 xorl %ebp, %esi
763 movl 0x200+des_SPtrans(%ecx),%ebp
764 xorl %ebp, %esi
765 movb %dh, %cl
766 shrl $16, %eax
767 movl 0x100+des_SPtrans(%ebx),%ebp
768 xorl %ebp, %esi
769 movb %ah, %bl
770 shrl $16, %edx
771 movl 0x300+des_SPtrans(%ecx),%ebp
772 xorl %ebp, %esi
773 movl 24(%esp), %ebp
774 movb %dh, %cl
775 andl $0xff, %eax
776 andl $0xff, %edx
777 movl 0x600+des_SPtrans(%ebx),%ebx
778 xorl %ebx, %esi
779 movl 0x700+des_SPtrans(%ecx),%ebx
780 xorl %ebx, %esi
781 movl 0x400+des_SPtrans(%eax),%ebx
782 xorl %ebx, %esi
783 movl 0x500+des_SPtrans(%edx),%ebx
784 xorl %ebx, %esi
785
786 /* Round 13 */
787 movl 104(%ebp), %eax
788 xorl %ebx, %ebx
789 movl 108(%ebp), %edx
790 xorl %esi, %eax
791 xorl %esi, %edx
792 andl $0xfcfcfcfc, %eax
793 andl $0xcfcfcfcf, %edx
794 movb %al, %bl
795 movb %ah, %cl
796 rorl $4, %edx
797 movl des_SPtrans(%ebx),%ebp
798 movb %dl, %bl
799 xorl %ebp, %edi
800 movl 0x200+des_SPtrans(%ecx),%ebp
801 xorl %ebp, %edi
802 movb %dh, %cl
803 shrl $16, %eax
804 movl 0x100+des_SPtrans(%ebx),%ebp
805 xorl %ebp, %edi
806 movb %ah, %bl
807 shrl $16, %edx
808 movl 0x300+des_SPtrans(%ecx),%ebp
809 xorl %ebp, %edi
810 movl 24(%esp), %ebp
811 movb %dh, %cl
812 andl $0xff, %eax
813 andl $0xff, %edx
814 movl 0x600+des_SPtrans(%ebx),%ebx
815 xorl %ebx, %edi
816 movl 0x700+des_SPtrans(%ecx),%ebx
817 xorl %ebx, %edi
818 movl 0x400+des_SPtrans(%eax),%ebx
819 xorl %ebx, %edi
820 movl 0x500+des_SPtrans(%edx),%ebx
821 xorl %ebx, %edi
822
823 /* Round 12 */
824 movl 96(%ebp), %eax
825 xorl %ebx, %ebx
826 movl 100(%ebp), %edx
827 xorl %edi, %eax
828 xorl %edi, %edx
829 andl $0xfcfcfcfc, %eax
830 andl $0xcfcfcfcf, %edx
831 movb %al, %bl
832 movb %ah, %cl
833 rorl $4, %edx
834 movl des_SPtrans(%ebx),%ebp
835 movb %dl, %bl
836 xorl %ebp, %esi
837 movl 0x200+des_SPtrans(%ecx),%ebp
838 xorl %ebp, %esi
839 movb %dh, %cl
840 shrl $16, %eax
841 movl 0x100+des_SPtrans(%ebx),%ebp
842 xorl %ebp, %esi
843 movb %ah, %bl
844 shrl $16, %edx
845 movl 0x300+des_SPtrans(%ecx),%ebp
846 xorl %ebp, %esi
847 movl 24(%esp), %ebp
848 movb %dh, %cl
849 andl $0xff, %eax
850 andl $0xff, %edx
851 movl 0x600+des_SPtrans(%ebx),%ebx
852 xorl %ebx, %esi
853 movl 0x700+des_SPtrans(%ecx),%ebx
854 xorl %ebx, %esi
855 movl 0x400+des_SPtrans(%eax),%ebx
856 xorl %ebx, %esi
857 movl 0x500+des_SPtrans(%edx),%ebx
858 xorl %ebx, %esi
859
860 /* Round 11 */
861 movl 88(%ebp), %eax
862 xorl %ebx, %ebx
863 movl 92(%ebp), %edx
864 xorl %esi, %eax
865 xorl %esi, %edx
866 andl $0xfcfcfcfc, %eax
867 andl $0xcfcfcfcf, %edx
868 movb %al, %bl
869 movb %ah, %cl
870 rorl $4, %edx
871 movl des_SPtrans(%ebx),%ebp
872 movb %dl, %bl
873 xorl %ebp, %edi
874 movl 0x200+des_SPtrans(%ecx),%ebp
875 xorl %ebp, %edi
876 movb %dh, %cl
877 shrl $16, %eax
878 movl 0x100+des_SPtrans(%ebx),%ebp
879 xorl %ebp, %edi
880 movb %ah, %bl
881 shrl $16, %edx
882 movl 0x300+des_SPtrans(%ecx),%ebp
883 xorl %ebp, %edi
884 movl 24(%esp), %ebp
885 movb %dh, %cl
886 andl $0xff, %eax
887 andl $0xff, %edx
888 movl 0x600+des_SPtrans(%ebx),%ebx
889 xorl %ebx, %edi
890 movl 0x700+des_SPtrans(%ecx),%ebx
891 xorl %ebx, %edi
892 movl 0x400+des_SPtrans(%eax),%ebx
893 xorl %ebx, %edi
894 movl 0x500+des_SPtrans(%edx),%ebx
895 xorl %ebx, %edi
896
897 /* Round 10 */
898 movl 80(%ebp), %eax
899 xorl %ebx, %ebx
900 movl 84(%ebp), %edx
901 xorl %edi, %eax
902 xorl %edi, %edx
903 andl $0xfcfcfcfc, %eax
904 andl $0xcfcfcfcf, %edx
905 movb %al, %bl
906 movb %ah, %cl
907 rorl $4, %edx
908 movl des_SPtrans(%ebx),%ebp
909 movb %dl, %bl
910 xorl %ebp, %esi
911 movl 0x200+des_SPtrans(%ecx),%ebp
912 xorl %ebp, %esi
913 movb %dh, %cl
914 shrl $16, %eax
915 movl 0x100+des_SPtrans(%ebx),%ebp
916 xorl %ebp, %esi
917 movb %ah, %bl
918 shrl $16, %edx
919 movl 0x300+des_SPtrans(%ecx),%ebp
920 xorl %ebp, %esi
921 movl 24(%esp), %ebp
922 movb %dh, %cl
923 andl $0xff, %eax
924 andl $0xff, %edx
925 movl 0x600+des_SPtrans(%ebx),%ebx
926 xorl %ebx, %esi
927 movl 0x700+des_SPtrans(%ecx),%ebx
928 xorl %ebx, %esi
929 movl 0x400+des_SPtrans(%eax),%ebx
930 xorl %ebx, %esi
931 movl 0x500+des_SPtrans(%edx),%ebx
932 xorl %ebx, %esi
933
934 /* Round 9 */
935 movl 72(%ebp), %eax
936 xorl %ebx, %ebx
937 movl 76(%ebp), %edx
938 xorl %esi, %eax
939 xorl %esi, %edx
940 andl $0xfcfcfcfc, %eax
941 andl $0xcfcfcfcf, %edx
942 movb %al, %bl
943 movb %ah, %cl
944 rorl $4, %edx
945 movl des_SPtrans(%ebx),%ebp
946 movb %dl, %bl
947 xorl %ebp, %edi
948 movl 0x200+des_SPtrans(%ecx),%ebp
949 xorl %ebp, %edi
950 movb %dh, %cl
951 shrl $16, %eax
952 movl 0x100+des_SPtrans(%ebx),%ebp
953 xorl %ebp, %edi
954 movb %ah, %bl
955 shrl $16, %edx
956 movl 0x300+des_SPtrans(%ecx),%ebp
957 xorl %ebp, %edi
958 movl 24(%esp), %ebp
959 movb %dh, %cl
960 andl $0xff, %eax
961 andl $0xff, %edx
962 movl 0x600+des_SPtrans(%ebx),%ebx
963 xorl %ebx, %edi
964 movl 0x700+des_SPtrans(%ecx),%ebx
965 xorl %ebx, %edi
966 movl 0x400+des_SPtrans(%eax),%ebx
967 xorl %ebx, %edi
968 movl 0x500+des_SPtrans(%edx),%ebx
969 xorl %ebx, %edi
970
971 /* Round 8 */
972 movl 64(%ebp), %eax
973 xorl %ebx, %ebx
974 movl 68(%ebp), %edx
975 xorl %edi, %eax
976 xorl %edi, %edx
977 andl $0xfcfcfcfc, %eax
978 andl $0xcfcfcfcf, %edx
979 movb %al, %bl
980 movb %ah, %cl
981 rorl $4, %edx
982 movl des_SPtrans(%ebx),%ebp
983 movb %dl, %bl
984 xorl %ebp, %esi
985 movl 0x200+des_SPtrans(%ecx),%ebp
986 xorl %ebp, %esi
987 movb %dh, %cl
988 shrl $16, %eax
989 movl 0x100+des_SPtrans(%ebx),%ebp
990 xorl %ebp, %esi
991 movb %ah, %bl
992 shrl $16, %edx
993 movl 0x300+des_SPtrans(%ecx),%ebp
994 xorl %ebp, %esi
995 movl 24(%esp), %ebp
996 movb %dh, %cl
997 andl $0xff, %eax
998 andl $0xff, %edx
999 movl 0x600+des_SPtrans(%ebx),%ebx
1000 xorl %ebx, %esi
1001 movl 0x700+des_SPtrans(%ecx),%ebx
1002 xorl %ebx, %esi
1003 movl 0x400+des_SPtrans(%eax),%ebx
1004 xorl %ebx, %esi
1005 movl 0x500+des_SPtrans(%edx),%ebx
1006 xorl %ebx, %esi
1007
1008 /* Round 7 */
1009 movl 56(%ebp), %eax
1010 xorl %ebx, %ebx
1011 movl 60(%ebp), %edx
1012 xorl %esi, %eax
1013 xorl %esi, %edx
1014 andl $0xfcfcfcfc, %eax
1015 andl $0xcfcfcfcf, %edx
1016 movb %al, %bl
1017 movb %ah, %cl
1018 rorl $4, %edx
1019 movl des_SPtrans(%ebx),%ebp
1020 movb %dl, %bl
1021 xorl %ebp, %edi
1022 movl 0x200+des_SPtrans(%ecx),%ebp
1023 xorl %ebp, %edi
1024 movb %dh, %cl
1025 shrl $16, %eax
1026 movl 0x100+des_SPtrans(%ebx),%ebp
1027 xorl %ebp, %edi
1028 movb %ah, %bl
1029 shrl $16, %edx
1030 movl 0x300+des_SPtrans(%ecx),%ebp
1031 xorl %ebp, %edi
1032 movl 24(%esp), %ebp
1033 movb %dh, %cl
1034 andl $0xff, %eax
1035 andl $0xff, %edx
1036 movl 0x600+des_SPtrans(%ebx),%ebx
1037 xorl %ebx, %edi
1038 movl 0x700+des_SPtrans(%ecx),%ebx
1039 xorl %ebx, %edi
1040 movl 0x400+des_SPtrans(%eax),%ebx
1041 xorl %ebx, %edi
1042 movl 0x500+des_SPtrans(%edx),%ebx
1043 xorl %ebx, %edi
1044
1045 /* Round 6 */
1046 movl 48(%ebp), %eax
1047 xorl %ebx, %ebx
1048 movl 52(%ebp), %edx
1049 xorl %edi, %eax
1050 xorl %edi, %edx
1051 andl $0xfcfcfcfc, %eax
1052 andl $0xcfcfcfcf, %edx
1053 movb %al, %bl
1054 movb %ah, %cl
1055 rorl $4, %edx
1056 movl des_SPtrans(%ebx),%ebp
1057 movb %dl, %bl
1058 xorl %ebp, %esi
1059 movl 0x200+des_SPtrans(%ecx),%ebp
1060 xorl %ebp, %esi
1061 movb %dh, %cl
1062 shrl $16, %eax
1063 movl 0x100+des_SPtrans(%ebx),%ebp
1064 xorl %ebp, %esi
1065 movb %ah, %bl
1066 shrl $16, %edx
1067 movl 0x300+des_SPtrans(%ecx),%ebp
1068 xorl %ebp, %esi
1069 movl 24(%esp), %ebp
1070 movb %dh, %cl
1071 andl $0xff, %eax
1072 andl $0xff, %edx
1073 movl 0x600+des_SPtrans(%ebx),%ebx
1074 xorl %ebx, %esi
1075 movl 0x700+des_SPtrans(%ecx),%ebx
1076 xorl %ebx, %esi
1077 movl 0x400+des_SPtrans(%eax),%ebx
1078 xorl %ebx, %esi
1079 movl 0x500+des_SPtrans(%edx),%ebx
1080 xorl %ebx, %esi
1081
1082 /* Round 5 */
1083 movl 40(%ebp), %eax
1084 xorl %ebx, %ebx
1085 movl 44(%ebp), %edx
1086 xorl %esi, %eax
1087 xorl %esi, %edx
1088 andl $0xfcfcfcfc, %eax
1089 andl $0xcfcfcfcf, %edx
1090 movb %al, %bl
1091 movb %ah, %cl
1092 rorl $4, %edx
1093 movl des_SPtrans(%ebx),%ebp
1094 movb %dl, %bl
1095 xorl %ebp, %edi
1096 movl 0x200+des_SPtrans(%ecx),%ebp
1097 xorl %ebp, %edi
1098 movb %dh, %cl
1099 shrl $16, %eax
1100 movl 0x100+des_SPtrans(%ebx),%ebp
1101 xorl %ebp, %edi
1102 movb %ah, %bl
1103 shrl $16, %edx
1104 movl 0x300+des_SPtrans(%ecx),%ebp
1105 xorl %ebp, %edi
1106 movl 24(%esp), %ebp
1107 movb %dh, %cl
1108 andl $0xff, %eax
1109 andl $0xff, %edx
1110 movl 0x600+des_SPtrans(%ebx),%ebx
1111 xorl %ebx, %edi
1112 movl 0x700+des_SPtrans(%ecx),%ebx
1113 xorl %ebx, %edi
1114 movl 0x400+des_SPtrans(%eax),%ebx
1115 xorl %ebx, %edi
1116 movl 0x500+des_SPtrans(%edx),%ebx
1117 xorl %ebx, %edi
1118
1119 /* Round 4 */
1120 movl 32(%ebp), %eax
1121 xorl %ebx, %ebx
1122 movl 36(%ebp), %edx
1123 xorl %edi, %eax
1124 xorl %edi, %edx
1125 andl $0xfcfcfcfc, %eax
1126 andl $0xcfcfcfcf, %edx
1127 movb %al, %bl
1128 movb %ah, %cl
1129 rorl $4, %edx
1130 movl des_SPtrans(%ebx),%ebp
1131 movb %dl, %bl
1132 xorl %ebp, %esi
1133 movl 0x200+des_SPtrans(%ecx),%ebp
1134 xorl %ebp, %esi
1135 movb %dh, %cl
1136 shrl $16, %eax
1137 movl 0x100+des_SPtrans(%ebx),%ebp
1138 xorl %ebp, %esi
1139 movb %ah, %bl
1140 shrl $16, %edx
1141 movl 0x300+des_SPtrans(%ecx),%ebp
1142 xorl %ebp, %esi
1143 movl 24(%esp), %ebp
1144 movb %dh, %cl
1145 andl $0xff, %eax
1146 andl $0xff, %edx
1147 movl 0x600+des_SPtrans(%ebx),%ebx
1148 xorl %ebx, %esi
1149 movl 0x700+des_SPtrans(%ecx),%ebx
1150 xorl %ebx, %esi
1151 movl 0x400+des_SPtrans(%eax),%ebx
1152 xorl %ebx, %esi
1153 movl 0x500+des_SPtrans(%edx),%ebx
1154 xorl %ebx, %esi
1155
1156 /* Round 3 */
1157 movl 24(%ebp), %eax
1158 xorl %ebx, %ebx
1159 movl 28(%ebp), %edx
1160 xorl %esi, %eax
1161 xorl %esi, %edx
1162 andl $0xfcfcfcfc, %eax
1163 andl $0xcfcfcfcf, %edx
1164 movb %al, %bl
1165 movb %ah, %cl
1166 rorl $4, %edx
1167 movl des_SPtrans(%ebx),%ebp
1168 movb %dl, %bl
1169 xorl %ebp, %edi
1170 movl 0x200+des_SPtrans(%ecx),%ebp
1171 xorl %ebp, %edi
1172 movb %dh, %cl
1173 shrl $16, %eax
1174 movl 0x100+des_SPtrans(%ebx),%ebp
1175 xorl %ebp, %edi
1176 movb %ah, %bl
1177 shrl $16, %edx
1178 movl 0x300+des_SPtrans(%ecx),%ebp
1179 xorl %ebp, %edi
1180 movl 24(%esp), %ebp
1181 movb %dh, %cl
1182 andl $0xff, %eax
1183 andl $0xff, %edx
1184 movl 0x600+des_SPtrans(%ebx),%ebx
1185 xorl %ebx, %edi
1186 movl 0x700+des_SPtrans(%ecx),%ebx
1187 xorl %ebx, %edi
1188 movl 0x400+des_SPtrans(%eax),%ebx
1189 xorl %ebx, %edi
1190 movl 0x500+des_SPtrans(%edx),%ebx
1191 xorl %ebx, %edi
1192
1193 /* Round 2 */
1194 movl 16(%ebp), %eax
1195 xorl %ebx, %ebx
1196 movl 20(%ebp), %edx
1197 xorl %edi, %eax
1198 xorl %edi, %edx
1199 andl $0xfcfcfcfc, %eax
1200 andl $0xcfcfcfcf, %edx
1201 movb %al, %bl
1202 movb %ah, %cl
1203 rorl $4, %edx
1204 movl des_SPtrans(%ebx),%ebp
1205 movb %dl, %bl
1206 xorl %ebp, %esi
1207 movl 0x200+des_SPtrans(%ecx),%ebp
1208 xorl %ebp, %esi
1209 movb %dh, %cl
1210 shrl $16, %eax
1211 movl 0x100+des_SPtrans(%ebx),%ebp
1212 xorl %ebp, %esi
1213 movb %ah, %bl
1214 shrl $16, %edx
1215 movl 0x300+des_SPtrans(%ecx),%ebp
1216 xorl %ebp, %esi
1217 movl 24(%esp), %ebp
1218 movb %dh, %cl
1219 andl $0xff, %eax
1220 andl $0xff, %edx
1221 movl 0x600+des_SPtrans(%ebx),%ebx
1222 xorl %ebx, %esi
1223 movl 0x700+des_SPtrans(%ecx),%ebx
1224 xorl %ebx, %esi
1225 movl 0x400+des_SPtrans(%eax),%ebx
1226 xorl %ebx, %esi
1227 movl 0x500+des_SPtrans(%edx),%ebx
1228 xorl %ebx, %esi
1229
1230 /* Round 1 */
1231 movl 8(%ebp), %eax
1232 xorl %ebx, %ebx
1233 movl 12(%ebp), %edx
1234 xorl %esi, %eax
1235 xorl %esi, %edx
1236 andl $0xfcfcfcfc, %eax
1237 andl $0xcfcfcfcf, %edx
1238 movb %al, %bl
1239 movb %ah, %cl
1240 rorl $4, %edx
1241 movl des_SPtrans(%ebx),%ebp
1242 movb %dl, %bl
1243 xorl %ebp, %edi
1244 movl 0x200+des_SPtrans(%ecx),%ebp
1245 xorl %ebp, %edi
1246 movb %dh, %cl
1247 shrl $16, %eax
1248 movl 0x100+des_SPtrans(%ebx),%ebp
1249 xorl %ebp, %edi
1250 movb %ah, %bl
1251 shrl $16, %edx
1252 movl 0x300+des_SPtrans(%ecx),%ebp
1253 xorl %ebp, %edi
1254 movl 24(%esp), %ebp
1255 movb %dh, %cl
1256 andl $0xff, %eax
1257 andl $0xff, %edx
1258 movl 0x600+des_SPtrans(%ebx),%ebx
1259 xorl %ebx, %edi
1260 movl 0x700+des_SPtrans(%ecx),%ebx
1261 xorl %ebx, %edi
1262 movl 0x400+des_SPtrans(%eax),%ebx
1263 xorl %ebx, %edi
1264 movl 0x500+des_SPtrans(%edx),%ebx
1265 xorl %ebx, %edi
1266
1267 /* Round 0 */
1268 movl (%ebp), %eax
1269 xorl %ebx, %ebx
1270 movl 4(%ebp), %edx
1271 xorl %edi, %eax
1272 xorl %edi, %edx
1273 andl $0xfcfcfcfc, %eax
1274 andl $0xcfcfcfcf, %edx
1275 movb %al, %bl
1276 movb %ah, %cl
1277 rorl $4, %edx
1278 movl des_SPtrans(%ebx),%ebp
1279 movb %dl, %bl
1280 xorl %ebp, %esi
1281 movl 0x200+des_SPtrans(%ecx),%ebp
1282 xorl %ebp, %esi
1283 movb %dh, %cl
1284 shrl $16, %eax
1285 movl 0x100+des_SPtrans(%ebx),%ebp
1286 xorl %ebp, %esi
1287 movb %ah, %bl
1288 shrl $16, %edx
1289 movl 0x300+des_SPtrans(%ecx),%ebp
1290 xorl %ebp, %esi
1291 movl 24(%esp), %ebp
1292 movb %dh, %cl
1293 andl $0xff, %eax
1294 andl $0xff, %edx
1295 movl 0x600+des_SPtrans(%ebx),%ebx
1296 xorl %ebx, %esi
1297 movl 0x700+des_SPtrans(%ecx),%ebx
1298 xorl %ebx, %esi
1299 movl 0x400+des_SPtrans(%eax),%ebx
1300 xorl %ebx, %esi
1301 movl 0x500+des_SPtrans(%edx),%ebx
1302 xorl %ebx, %esi
1303.L001end:
1304
1305 /* FP */
1306 movl 20(%esp), %edx
1307.byte 209
1308.byte 206 /* rorl $1 %esi */
1309 movl %edi, %eax
1310 xorl %esi, %edi
1311 andl $0xaaaaaaaa, %edi
1312 xorl %edi, %eax
1313 xorl %edi, %esi
1314
1315 roll $23, %eax
1316 movl %eax, %edi
1317 xorl %esi, %eax
1318 andl $0x03fc03fc, %eax
1319 xorl %eax, %edi
1320 xorl %eax, %esi
1321
1322 roll $10, %edi
1323 movl %edi, %eax
1324 xorl %esi, %edi
1325 andl $0x33333333, %edi
1326 xorl %edi, %eax
1327 xorl %edi, %esi
1328
1329 roll $18, %esi
1330 movl %esi, %edi
1331 xorl %eax, %esi
1332 andl $0xfff0000f, %esi
1333 xorl %esi, %edi
1334 xorl %esi, %eax
1335
1336 roll $12, %edi
1337 movl %edi, %esi
1338 xorl %eax, %edi
1339 andl $0xf0f0f0f0, %edi
1340 xorl %edi, %esi
1341 xorl %edi, %eax
1342
1343 rorl $4, %eax
1344 movl %eax, (%edx)
1345 movl %esi, 4(%edx)
1346 popl %ebp
1347 popl %ebx
1348 popl %edi
1349 popl %esi
1350 ret
1351.des_encrypt_end:
1352 SIZE(des_encrypt,.des_encrypt_end-des_encrypt)
1353.ident "desasm.pl"
1354.text
1355 .align ALIGN
1356.globl des_encrypt2
1357 TYPE(des_encrypt2,@function)
1358des_encrypt2:
1359 pushl %esi
1360 pushl %edi
1361
1362 /* Load the 2 words */
1363 movl 12(%esp), %eax
1364 xorl %ecx, %ecx
1365 pushl %ebx
1366 pushl %ebp
1367 movl (%eax), %esi
1368 movl 28(%esp), %ebx
1369 roll $3, %esi
1370 movl 4(%eax), %edi
1371 roll $3, %edi
1372 movl 24(%esp), %ebp
1373 cmpl $0, %ebx
1374 je .L002start_decrypt
1375
1376 /* Round 0 */
1377 movl (%ebp), %eax
1378 xorl %ebx, %ebx
1379 movl 4(%ebp), %edx
1380 xorl %esi, %eax
1381 xorl %esi, %edx
1382 andl $0xfcfcfcfc, %eax
1383 andl $0xcfcfcfcf, %edx
1384 movb %al, %bl
1385 movb %ah, %cl
1386 rorl $4, %edx
1387 movl des_SPtrans(%ebx),%ebp
1388 movb %dl, %bl
1389 xorl %ebp, %edi
1390 movl 0x200+des_SPtrans(%ecx),%ebp
1391 xorl %ebp, %edi
1392 movb %dh, %cl
1393 shrl $16, %eax
1394 movl 0x100+des_SPtrans(%ebx),%ebp
1395 xorl %ebp, %edi
1396 movb %ah, %bl
1397 shrl $16, %edx
1398 movl 0x300+des_SPtrans(%ecx),%ebp
1399 xorl %ebp, %edi
1400 movl 24(%esp), %ebp
1401 movb %dh, %cl
1402 andl $0xff, %eax
1403 andl $0xff, %edx
1404 movl 0x600+des_SPtrans(%ebx),%ebx
1405 xorl %ebx, %edi
1406 movl 0x700+des_SPtrans(%ecx),%ebx
1407 xorl %ebx, %edi
1408 movl 0x400+des_SPtrans(%eax),%ebx
1409 xorl %ebx, %edi
1410 movl 0x500+des_SPtrans(%edx),%ebx
1411 xorl %ebx, %edi
1412
1413 /* Round 1 */
1414 movl 8(%ebp), %eax
1415 xorl %ebx, %ebx
1416 movl 12(%ebp), %edx
1417 xorl %edi, %eax
1418 xorl %edi, %edx
1419 andl $0xfcfcfcfc, %eax
1420 andl $0xcfcfcfcf, %edx
1421 movb %al, %bl
1422 movb %ah, %cl
1423 rorl $4, %edx
1424 movl des_SPtrans(%ebx),%ebp
1425 movb %dl, %bl
1426 xorl %ebp, %esi
1427 movl 0x200+des_SPtrans(%ecx),%ebp
1428 xorl %ebp, %esi
1429 movb %dh, %cl
1430 shrl $16, %eax
1431 movl 0x100+des_SPtrans(%ebx),%ebp
1432 xorl %ebp, %esi
1433 movb %ah, %bl
1434 shrl $16, %edx
1435 movl 0x300+des_SPtrans(%ecx),%ebp
1436 xorl %ebp, %esi
1437 movl 24(%esp), %ebp
1438 movb %dh, %cl
1439 andl $0xff, %eax
1440 andl $0xff, %edx
1441 movl 0x600+des_SPtrans(%ebx),%ebx
1442 xorl %ebx, %esi
1443 movl 0x700+des_SPtrans(%ecx),%ebx
1444 xorl %ebx, %esi
1445 movl 0x400+des_SPtrans(%eax),%ebx
1446 xorl %ebx, %esi
1447 movl 0x500+des_SPtrans(%edx),%ebx
1448 xorl %ebx, %esi
1449
1450 /* Round 2 */
1451 movl 16(%ebp), %eax
1452 xorl %ebx, %ebx
1453 movl 20(%ebp), %edx
1454 xorl %esi, %eax
1455 xorl %esi, %edx
1456 andl $0xfcfcfcfc, %eax
1457 andl $0xcfcfcfcf, %edx
1458 movb %al, %bl
1459 movb %ah, %cl
1460 rorl $4, %edx
1461 movl des_SPtrans(%ebx),%ebp
1462 movb %dl, %bl
1463 xorl %ebp, %edi
1464 movl 0x200+des_SPtrans(%ecx),%ebp
1465 xorl %ebp, %edi
1466 movb %dh, %cl
1467 shrl $16, %eax
1468 movl 0x100+des_SPtrans(%ebx),%ebp
1469 xorl %ebp, %edi
1470 movb %ah, %bl
1471 shrl $16, %edx
1472 movl 0x300+des_SPtrans(%ecx),%ebp
1473 xorl %ebp, %edi
1474 movl 24(%esp), %ebp
1475 movb %dh, %cl
1476 andl $0xff, %eax
1477 andl $0xff, %edx
1478 movl 0x600+des_SPtrans(%ebx),%ebx
1479 xorl %ebx, %edi
1480 movl 0x700+des_SPtrans(%ecx),%ebx
1481 xorl %ebx, %edi
1482 movl 0x400+des_SPtrans(%eax),%ebx
1483 xorl %ebx, %edi
1484 movl 0x500+des_SPtrans(%edx),%ebx
1485 xorl %ebx, %edi
1486
1487 /* Round 3 */
1488 movl 24(%ebp), %eax
1489 xorl %ebx, %ebx
1490 movl 28(%ebp), %edx
1491 xorl %edi, %eax
1492 xorl %edi, %edx
1493 andl $0xfcfcfcfc, %eax
1494 andl $0xcfcfcfcf, %edx
1495 movb %al, %bl
1496 movb %ah, %cl
1497 rorl $4, %edx
1498 movl des_SPtrans(%ebx),%ebp
1499 movb %dl, %bl
1500 xorl %ebp, %esi
1501 movl 0x200+des_SPtrans(%ecx),%ebp
1502 xorl %ebp, %esi
1503 movb %dh, %cl
1504 shrl $16, %eax
1505 movl 0x100+des_SPtrans(%ebx),%ebp
1506 xorl %ebp, %esi
1507 movb %ah, %bl
1508 shrl $16, %edx
1509 movl 0x300+des_SPtrans(%ecx),%ebp
1510 xorl %ebp, %esi
1511 movl 24(%esp), %ebp
1512 movb %dh, %cl
1513 andl $0xff, %eax
1514 andl $0xff, %edx
1515 movl 0x600+des_SPtrans(%ebx),%ebx
1516 xorl %ebx, %esi
1517 movl 0x700+des_SPtrans(%ecx),%ebx
1518 xorl %ebx, %esi
1519 movl 0x400+des_SPtrans(%eax),%ebx
1520 xorl %ebx, %esi
1521 movl 0x500+des_SPtrans(%edx),%ebx
1522 xorl %ebx, %esi
1523
1524 /* Round 4 */
1525 movl 32(%ebp), %eax
1526 xorl %ebx, %ebx
1527 movl 36(%ebp), %edx
1528 xorl %esi, %eax
1529 xorl %esi, %edx
1530 andl $0xfcfcfcfc, %eax
1531 andl $0xcfcfcfcf, %edx
1532 movb %al, %bl
1533 movb %ah, %cl
1534 rorl $4, %edx
1535 movl des_SPtrans(%ebx),%ebp
1536 movb %dl, %bl
1537 xorl %ebp, %edi
1538 movl 0x200+des_SPtrans(%ecx),%ebp
1539 xorl %ebp, %edi
1540 movb %dh, %cl
1541 shrl $16, %eax
1542 movl 0x100+des_SPtrans(%ebx),%ebp
1543 xorl %ebp, %edi
1544 movb %ah, %bl
1545 shrl $16, %edx
1546 movl 0x300+des_SPtrans(%ecx),%ebp
1547 xorl %ebp, %edi
1548 movl 24(%esp), %ebp
1549 movb %dh, %cl
1550 andl $0xff, %eax
1551 andl $0xff, %edx
1552 movl 0x600+des_SPtrans(%ebx),%ebx
1553 xorl %ebx, %edi
1554 movl 0x700+des_SPtrans(%ecx),%ebx
1555 xorl %ebx, %edi
1556 movl 0x400+des_SPtrans(%eax),%ebx
1557 xorl %ebx, %edi
1558 movl 0x500+des_SPtrans(%edx),%ebx
1559 xorl %ebx, %edi
1560
1561 /* Round 5 */
1562 movl 40(%ebp), %eax
1563 xorl %ebx, %ebx
1564 movl 44(%ebp), %edx
1565 xorl %edi, %eax
1566 xorl %edi, %edx
1567 andl $0xfcfcfcfc, %eax
1568 andl $0xcfcfcfcf, %edx
1569 movb %al, %bl
1570 movb %ah, %cl
1571 rorl $4, %edx
1572 movl des_SPtrans(%ebx),%ebp
1573 movb %dl, %bl
1574 xorl %ebp, %esi
1575 movl 0x200+des_SPtrans(%ecx),%ebp
1576 xorl %ebp, %esi
1577 movb %dh, %cl
1578 shrl $16, %eax
1579 movl 0x100+des_SPtrans(%ebx),%ebp
1580 xorl %ebp, %esi
1581 movb %ah, %bl
1582 shrl $16, %edx
1583 movl 0x300+des_SPtrans(%ecx),%ebp
1584 xorl %ebp, %esi
1585 movl 24(%esp), %ebp
1586 movb %dh, %cl
1587 andl $0xff, %eax
1588 andl $0xff, %edx
1589 movl 0x600+des_SPtrans(%ebx),%ebx
1590 xorl %ebx, %esi
1591 movl 0x700+des_SPtrans(%ecx),%ebx
1592 xorl %ebx, %esi
1593 movl 0x400+des_SPtrans(%eax),%ebx
1594 xorl %ebx, %esi
1595 movl 0x500+des_SPtrans(%edx),%ebx
1596 xorl %ebx, %esi
1597
1598 /* Round 6 */
1599 movl 48(%ebp), %eax
1600 xorl %ebx, %ebx
1601 movl 52(%ebp), %edx
1602 xorl %esi, %eax
1603 xorl %esi, %edx
1604 andl $0xfcfcfcfc, %eax
1605 andl $0xcfcfcfcf, %edx
1606 movb %al, %bl
1607 movb %ah, %cl
1608 rorl $4, %edx
1609 movl des_SPtrans(%ebx),%ebp
1610 movb %dl, %bl
1611 xorl %ebp, %edi
1612 movl 0x200+des_SPtrans(%ecx),%ebp
1613 xorl %ebp, %edi
1614 movb %dh, %cl
1615 shrl $16, %eax
1616 movl 0x100+des_SPtrans(%ebx),%ebp
1617 xorl %ebp, %edi
1618 movb %ah, %bl
1619 shrl $16, %edx
1620 movl 0x300+des_SPtrans(%ecx),%ebp
1621 xorl %ebp, %edi
1622 movl 24(%esp), %ebp
1623 movb %dh, %cl
1624 andl $0xff, %eax
1625 andl $0xff, %edx
1626 movl 0x600+des_SPtrans(%ebx),%ebx
1627 xorl %ebx, %edi
1628 movl 0x700+des_SPtrans(%ecx),%ebx
1629 xorl %ebx, %edi
1630 movl 0x400+des_SPtrans(%eax),%ebx
1631 xorl %ebx, %edi
1632 movl 0x500+des_SPtrans(%edx),%ebx
1633 xorl %ebx, %edi
1634
1635 /* Round 7 */
1636 movl 56(%ebp), %eax
1637 xorl %ebx, %ebx
1638 movl 60(%ebp), %edx
1639 xorl %edi, %eax
1640 xorl %edi, %edx
1641 andl $0xfcfcfcfc, %eax
1642 andl $0xcfcfcfcf, %edx
1643 movb %al, %bl
1644 movb %ah, %cl
1645 rorl $4, %edx
1646 movl des_SPtrans(%ebx),%ebp
1647 movb %dl, %bl
1648 xorl %ebp, %esi
1649 movl 0x200+des_SPtrans(%ecx),%ebp
1650 xorl %ebp, %esi
1651 movb %dh, %cl
1652 shrl $16, %eax
1653 movl 0x100+des_SPtrans(%ebx),%ebp
1654 xorl %ebp, %esi
1655 movb %ah, %bl
1656 shrl $16, %edx
1657 movl 0x300+des_SPtrans(%ecx),%ebp
1658 xorl %ebp, %esi
1659 movl 24(%esp), %ebp
1660 movb %dh, %cl
1661 andl $0xff, %eax
1662 andl $0xff, %edx
1663 movl 0x600+des_SPtrans(%ebx),%ebx
1664 xorl %ebx, %esi
1665 movl 0x700+des_SPtrans(%ecx),%ebx
1666 xorl %ebx, %esi
1667 movl 0x400+des_SPtrans(%eax),%ebx
1668 xorl %ebx, %esi
1669 movl 0x500+des_SPtrans(%edx),%ebx
1670 xorl %ebx, %esi
1671
1672 /* Round 8 */
1673 movl 64(%ebp), %eax
1674 xorl %ebx, %ebx
1675 movl 68(%ebp), %edx
1676 xorl %esi, %eax
1677 xorl %esi, %edx
1678 andl $0xfcfcfcfc, %eax
1679 andl $0xcfcfcfcf, %edx
1680 movb %al, %bl
1681 movb %ah, %cl
1682 rorl $4, %edx
1683 movl des_SPtrans(%ebx),%ebp
1684 movb %dl, %bl
1685 xorl %ebp, %edi
1686 movl 0x200+des_SPtrans(%ecx),%ebp
1687 xorl %ebp, %edi
1688 movb %dh, %cl
1689 shrl $16, %eax
1690 movl 0x100+des_SPtrans(%ebx),%ebp
1691 xorl %ebp, %edi
1692 movb %ah, %bl
1693 shrl $16, %edx
1694 movl 0x300+des_SPtrans(%ecx),%ebp
1695 xorl %ebp, %edi
1696 movl 24(%esp), %ebp
1697 movb %dh, %cl
1698 andl $0xff, %eax
1699 andl $0xff, %edx
1700 movl 0x600+des_SPtrans(%ebx),%ebx
1701 xorl %ebx, %edi
1702 movl 0x700+des_SPtrans(%ecx),%ebx
1703 xorl %ebx, %edi
1704 movl 0x400+des_SPtrans(%eax),%ebx
1705 xorl %ebx, %edi
1706 movl 0x500+des_SPtrans(%edx),%ebx
1707 xorl %ebx, %edi
1708
1709 /* Round 9 */
1710 movl 72(%ebp), %eax
1711 xorl %ebx, %ebx
1712 movl 76(%ebp), %edx
1713 xorl %edi, %eax
1714 xorl %edi, %edx
1715 andl $0xfcfcfcfc, %eax
1716 andl $0xcfcfcfcf, %edx
1717 movb %al, %bl
1718 movb %ah, %cl
1719 rorl $4, %edx
1720 movl des_SPtrans(%ebx),%ebp
1721 movb %dl, %bl
1722 xorl %ebp, %esi
1723 movl 0x200+des_SPtrans(%ecx),%ebp
1724 xorl %ebp, %esi
1725 movb %dh, %cl
1726 shrl $16, %eax
1727 movl 0x100+des_SPtrans(%ebx),%ebp
1728 xorl %ebp, %esi
1729 movb %ah, %bl
1730 shrl $16, %edx
1731 movl 0x300+des_SPtrans(%ecx),%ebp
1732 xorl %ebp, %esi
1733 movl 24(%esp), %ebp
1734 movb %dh, %cl
1735 andl $0xff, %eax
1736 andl $0xff, %edx
1737 movl 0x600+des_SPtrans(%ebx),%ebx
1738 xorl %ebx, %esi
1739 movl 0x700+des_SPtrans(%ecx),%ebx
1740 xorl %ebx, %esi
1741 movl 0x400+des_SPtrans(%eax),%ebx
1742 xorl %ebx, %esi
1743 movl 0x500+des_SPtrans(%edx),%ebx
1744 xorl %ebx, %esi
1745
1746 /* Round 10 */
1747 movl 80(%ebp), %eax
1748 xorl %ebx, %ebx
1749 movl 84(%ebp), %edx
1750 xorl %esi, %eax
1751 xorl %esi, %edx
1752 andl $0xfcfcfcfc, %eax
1753 andl $0xcfcfcfcf, %edx
1754 movb %al, %bl
1755 movb %ah, %cl
1756 rorl $4, %edx
1757 movl des_SPtrans(%ebx),%ebp
1758 movb %dl, %bl
1759 xorl %ebp, %edi
1760 movl 0x200+des_SPtrans(%ecx),%ebp
1761 xorl %ebp, %edi
1762 movb %dh, %cl
1763 shrl $16, %eax
1764 movl 0x100+des_SPtrans(%ebx),%ebp
1765 xorl %ebp, %edi
1766 movb %ah, %bl
1767 shrl $16, %edx
1768 movl 0x300+des_SPtrans(%ecx),%ebp
1769 xorl %ebp, %edi
1770 movl 24(%esp), %ebp
1771 movb %dh, %cl
1772 andl $0xff, %eax
1773 andl $0xff, %edx
1774 movl 0x600+des_SPtrans(%ebx),%ebx
1775 xorl %ebx, %edi
1776 movl 0x700+des_SPtrans(%ecx),%ebx
1777 xorl %ebx, %edi
1778 movl 0x400+des_SPtrans(%eax),%ebx
1779 xorl %ebx, %edi
1780 movl 0x500+des_SPtrans(%edx),%ebx
1781 xorl %ebx, %edi
1782
1783 /* Round 11 */
1784 movl 88(%ebp), %eax
1785 xorl %ebx, %ebx
1786 movl 92(%ebp), %edx
1787 xorl %edi, %eax
1788 xorl %edi, %edx
1789 andl $0xfcfcfcfc, %eax
1790 andl $0xcfcfcfcf, %edx
1791 movb %al, %bl
1792 movb %ah, %cl
1793 rorl $4, %edx
1794 movl des_SPtrans(%ebx),%ebp
1795 movb %dl, %bl
1796 xorl %ebp, %esi
1797 movl 0x200+des_SPtrans(%ecx),%ebp
1798 xorl %ebp, %esi
1799 movb %dh, %cl
1800 shrl $16, %eax
1801 movl 0x100+des_SPtrans(%ebx),%ebp
1802 xorl %ebp, %esi
1803 movb %ah, %bl
1804 shrl $16, %edx
1805 movl 0x300+des_SPtrans(%ecx),%ebp
1806 xorl %ebp, %esi
1807 movl 24(%esp), %ebp
1808 movb %dh, %cl
1809 andl $0xff, %eax
1810 andl $0xff, %edx
1811 movl 0x600+des_SPtrans(%ebx),%ebx
1812 xorl %ebx, %esi
1813 movl 0x700+des_SPtrans(%ecx),%ebx
1814 xorl %ebx, %esi
1815 movl 0x400+des_SPtrans(%eax),%ebx
1816 xorl %ebx, %esi
1817 movl 0x500+des_SPtrans(%edx),%ebx
1818 xorl %ebx, %esi
1819
1820 /* Round 12 */
1821 movl 96(%ebp), %eax
1822 xorl %ebx, %ebx
1823 movl 100(%ebp), %edx
1824 xorl %esi, %eax
1825 xorl %esi, %edx
1826 andl $0xfcfcfcfc, %eax
1827 andl $0xcfcfcfcf, %edx
1828 movb %al, %bl
1829 movb %ah, %cl
1830 rorl $4, %edx
1831 movl des_SPtrans(%ebx),%ebp
1832 movb %dl, %bl
1833 xorl %ebp, %edi
1834 movl 0x200+des_SPtrans(%ecx),%ebp
1835 xorl %ebp, %edi
1836 movb %dh, %cl
1837 shrl $16, %eax
1838 movl 0x100+des_SPtrans(%ebx),%ebp
1839 xorl %ebp, %edi
1840 movb %ah, %bl
1841 shrl $16, %edx
1842 movl 0x300+des_SPtrans(%ecx),%ebp
1843 xorl %ebp, %edi
1844 movl 24(%esp), %ebp
1845 movb %dh, %cl
1846 andl $0xff, %eax
1847 andl $0xff, %edx
1848 movl 0x600+des_SPtrans(%ebx),%ebx
1849 xorl %ebx, %edi
1850 movl 0x700+des_SPtrans(%ecx),%ebx
1851 xorl %ebx, %edi
1852 movl 0x400+des_SPtrans(%eax),%ebx
1853 xorl %ebx, %edi
1854 movl 0x500+des_SPtrans(%edx),%ebx
1855 xorl %ebx, %edi
1856
1857 /* Round 13 */
1858 movl 104(%ebp), %eax
1859 xorl %ebx, %ebx
1860 movl 108(%ebp), %edx
1861 xorl %edi, %eax
1862 xorl %edi, %edx
1863 andl $0xfcfcfcfc, %eax
1864 andl $0xcfcfcfcf, %edx
1865 movb %al, %bl
1866 movb %ah, %cl
1867 rorl $4, %edx
1868 movl des_SPtrans(%ebx),%ebp
1869 movb %dl, %bl
1870 xorl %ebp, %esi
1871 movl 0x200+des_SPtrans(%ecx),%ebp
1872 xorl %ebp, %esi
1873 movb %dh, %cl
1874 shrl $16, %eax
1875 movl 0x100+des_SPtrans(%ebx),%ebp
1876 xorl %ebp, %esi
1877 movb %ah, %bl
1878 shrl $16, %edx
1879 movl 0x300+des_SPtrans(%ecx),%ebp
1880 xorl %ebp, %esi
1881 movl 24(%esp), %ebp
1882 movb %dh, %cl
1883 andl $0xff, %eax
1884 andl $0xff, %edx
1885 movl 0x600+des_SPtrans(%ebx),%ebx
1886 xorl %ebx, %esi
1887 movl 0x700+des_SPtrans(%ecx),%ebx
1888 xorl %ebx, %esi
1889 movl 0x400+des_SPtrans(%eax),%ebx
1890 xorl %ebx, %esi
1891 movl 0x500+des_SPtrans(%edx),%ebx
1892 xorl %ebx, %esi
1893
1894 /* Round 14 */
1895 movl 112(%ebp), %eax
1896 xorl %ebx, %ebx
1897 movl 116(%ebp), %edx
1898 xorl %esi, %eax
1899 xorl %esi, %edx
1900 andl $0xfcfcfcfc, %eax
1901 andl $0xcfcfcfcf, %edx
1902 movb %al, %bl
1903 movb %ah, %cl
1904 rorl $4, %edx
1905 movl des_SPtrans(%ebx),%ebp
1906 movb %dl, %bl
1907 xorl %ebp, %edi
1908 movl 0x200+des_SPtrans(%ecx),%ebp
1909 xorl %ebp, %edi
1910 movb %dh, %cl
1911 shrl $16, %eax
1912 movl 0x100+des_SPtrans(%ebx),%ebp
1913 xorl %ebp, %edi
1914 movb %ah, %bl
1915 shrl $16, %edx
1916 movl 0x300+des_SPtrans(%ecx),%ebp
1917 xorl %ebp, %edi
1918 movl 24(%esp), %ebp
1919 movb %dh, %cl
1920 andl $0xff, %eax
1921 andl $0xff, %edx
1922 movl 0x600+des_SPtrans(%ebx),%ebx
1923 xorl %ebx, %edi
1924 movl 0x700+des_SPtrans(%ecx),%ebx
1925 xorl %ebx, %edi
1926 movl 0x400+des_SPtrans(%eax),%ebx
1927 xorl %ebx, %edi
1928 movl 0x500+des_SPtrans(%edx),%ebx
1929 xorl %ebx, %edi
1930
1931 /* Round 15 */
1932 movl 120(%ebp), %eax
1933 xorl %ebx, %ebx
1934 movl 124(%ebp), %edx
1935 xorl %edi, %eax
1936 xorl %edi, %edx
1937 andl $0xfcfcfcfc, %eax
1938 andl $0xcfcfcfcf, %edx
1939 movb %al, %bl
1940 movb %ah, %cl
1941 rorl $4, %edx
1942 movl des_SPtrans(%ebx),%ebp
1943 movb %dl, %bl
1944 xorl %ebp, %esi
1945 movl 0x200+des_SPtrans(%ecx),%ebp
1946 xorl %ebp, %esi
1947 movb %dh, %cl
1948 shrl $16, %eax
1949 movl 0x100+des_SPtrans(%ebx),%ebp
1950 xorl %ebp, %esi
1951 movb %ah, %bl
1952 shrl $16, %edx
1953 movl 0x300+des_SPtrans(%ecx),%ebp
1954 xorl %ebp, %esi
1955 movl 24(%esp), %ebp
1956 movb %dh, %cl
1957 andl $0xff, %eax
1958 andl $0xff, %edx
1959 movl 0x600+des_SPtrans(%ebx),%ebx
1960 xorl %ebx, %esi
1961 movl 0x700+des_SPtrans(%ecx),%ebx
1962 xorl %ebx, %esi
1963 movl 0x400+des_SPtrans(%eax),%ebx
1964 xorl %ebx, %esi
1965 movl 0x500+des_SPtrans(%edx),%ebx
1966 xorl %ebx, %esi
1967 jmp .L003end
1968.L002start_decrypt:
1969
1970 /* Round 15 */
1971 movl 120(%ebp), %eax
1972 xorl %ebx, %ebx
1973 movl 124(%ebp), %edx
1974 xorl %esi, %eax
1975 xorl %esi, %edx
1976 andl $0xfcfcfcfc, %eax
1977 andl $0xcfcfcfcf, %edx
1978 movb %al, %bl
1979 movb %ah, %cl
1980 rorl $4, %edx
1981 movl des_SPtrans(%ebx),%ebp
1982 movb %dl, %bl
1983 xorl %ebp, %edi
1984 movl 0x200+des_SPtrans(%ecx),%ebp
1985 xorl %ebp, %edi
1986 movb %dh, %cl
1987 shrl $16, %eax
1988 movl 0x100+des_SPtrans(%ebx),%ebp
1989 xorl %ebp, %edi
1990 movb %ah, %bl
1991 shrl $16, %edx
1992 movl 0x300+des_SPtrans(%ecx),%ebp
1993 xorl %ebp, %edi
1994 movl 24(%esp), %ebp
1995 movb %dh, %cl
1996 andl $0xff, %eax
1997 andl $0xff, %edx
1998 movl 0x600+des_SPtrans(%ebx),%ebx
1999 xorl %ebx, %edi
2000 movl 0x700+des_SPtrans(%ecx),%ebx
2001 xorl %ebx, %edi
2002 movl 0x400+des_SPtrans(%eax),%ebx
2003 xorl %ebx, %edi
2004 movl 0x500+des_SPtrans(%edx),%ebx
2005 xorl %ebx, %edi
2006
2007 /* Round 14 */
2008 movl 112(%ebp), %eax
2009 xorl %ebx, %ebx
2010 movl 116(%ebp), %edx
2011 xorl %edi, %eax
2012 xorl %edi, %edx
2013 andl $0xfcfcfcfc, %eax
2014 andl $0xcfcfcfcf, %edx
2015 movb %al, %bl
2016 movb %ah, %cl
2017 rorl $4, %edx
2018 movl des_SPtrans(%ebx),%ebp
2019 movb %dl, %bl
2020 xorl %ebp, %esi
2021 movl 0x200+des_SPtrans(%ecx),%ebp
2022 xorl %ebp, %esi
2023 movb %dh, %cl
2024 shrl $16, %eax
2025 movl 0x100+des_SPtrans(%ebx),%ebp
2026 xorl %ebp, %esi
2027 movb %ah, %bl
2028 shrl $16, %edx
2029 movl 0x300+des_SPtrans(%ecx),%ebp
2030 xorl %ebp, %esi
2031 movl 24(%esp), %ebp
2032 movb %dh, %cl
2033 andl $0xff, %eax
2034 andl $0xff, %edx
2035 movl 0x600+des_SPtrans(%ebx),%ebx
2036 xorl %ebx, %esi
2037 movl 0x700+des_SPtrans(%ecx),%ebx
2038 xorl %ebx, %esi
2039 movl 0x400+des_SPtrans(%eax),%ebx
2040 xorl %ebx, %esi
2041 movl 0x500+des_SPtrans(%edx),%ebx
2042 xorl %ebx, %esi
2043
2044 /* Round 13 */
2045 movl 104(%ebp), %eax
2046 xorl %ebx, %ebx
2047 movl 108(%ebp), %edx
2048 xorl %esi, %eax
2049 xorl %esi, %edx
2050 andl $0xfcfcfcfc, %eax
2051 andl $0xcfcfcfcf, %edx
2052 movb %al, %bl
2053 movb %ah, %cl
2054 rorl $4, %edx
2055 movl des_SPtrans(%ebx),%ebp
2056 movb %dl, %bl
2057 xorl %ebp, %edi
2058 movl 0x200+des_SPtrans(%ecx),%ebp
2059 xorl %ebp, %edi
2060 movb %dh, %cl
2061 shrl $16, %eax
2062 movl 0x100+des_SPtrans(%ebx),%ebp
2063 xorl %ebp, %edi
2064 movb %ah, %bl
2065 shrl $16, %edx
2066 movl 0x300+des_SPtrans(%ecx),%ebp
2067 xorl %ebp, %edi
2068 movl 24(%esp), %ebp
2069 movb %dh, %cl
2070 andl $0xff, %eax
2071 andl $0xff, %edx
2072 movl 0x600+des_SPtrans(%ebx),%ebx
2073 xorl %ebx, %edi
2074 movl 0x700+des_SPtrans(%ecx),%ebx
2075 xorl %ebx, %edi
2076 movl 0x400+des_SPtrans(%eax),%ebx
2077 xorl %ebx, %edi
2078 movl 0x500+des_SPtrans(%edx),%ebx
2079 xorl %ebx, %edi
2080
2081 /* Round 12 */
2082 movl 96(%ebp), %eax
2083 xorl %ebx, %ebx
2084 movl 100(%ebp), %edx
2085 xorl %edi, %eax
2086 xorl %edi, %edx
2087 andl $0xfcfcfcfc, %eax
2088 andl $0xcfcfcfcf, %edx
2089 movb %al, %bl
2090 movb %ah, %cl
2091 rorl $4, %edx
2092 movl des_SPtrans(%ebx),%ebp
2093 movb %dl, %bl
2094 xorl %ebp, %esi
2095 movl 0x200+des_SPtrans(%ecx),%ebp
2096 xorl %ebp, %esi
2097 movb %dh, %cl
2098 shrl $16, %eax
2099 movl 0x100+des_SPtrans(%ebx),%ebp
2100 xorl %ebp, %esi
2101 movb %ah, %bl
2102 shrl $16, %edx
2103 movl 0x300+des_SPtrans(%ecx),%ebp
2104 xorl %ebp, %esi
2105 movl 24(%esp), %ebp
2106 movb %dh, %cl
2107 andl $0xff, %eax
2108 andl $0xff, %edx
2109 movl 0x600+des_SPtrans(%ebx),%ebx
2110 xorl %ebx, %esi
2111 movl 0x700+des_SPtrans(%ecx),%ebx
2112 xorl %ebx, %esi
2113 movl 0x400+des_SPtrans(%eax),%ebx
2114 xorl %ebx, %esi
2115 movl 0x500+des_SPtrans(%edx),%ebx
2116 xorl %ebx, %esi
2117
2118 /* Round 11 */
2119 movl 88(%ebp), %eax
2120 xorl %ebx, %ebx
2121 movl 92(%ebp), %edx
2122 xorl %esi, %eax
2123 xorl %esi, %edx
2124 andl $0xfcfcfcfc, %eax
2125 andl $0xcfcfcfcf, %edx
2126 movb %al, %bl
2127 movb %ah, %cl
2128 rorl $4, %edx
2129 movl des_SPtrans(%ebx),%ebp
2130 movb %dl, %bl
2131 xorl %ebp, %edi
2132 movl 0x200+des_SPtrans(%ecx),%ebp
2133 xorl %ebp, %edi
2134 movb %dh, %cl
2135 shrl $16, %eax
2136 movl 0x100+des_SPtrans(%ebx),%ebp
2137 xorl %ebp, %edi
2138 movb %ah, %bl
2139 shrl $16, %edx
2140 movl 0x300+des_SPtrans(%ecx),%ebp
2141 xorl %ebp, %edi
2142 movl 24(%esp), %ebp
2143 movb %dh, %cl
2144 andl $0xff, %eax
2145 andl $0xff, %edx
2146 movl 0x600+des_SPtrans(%ebx),%ebx
2147 xorl %ebx, %edi
2148 movl 0x700+des_SPtrans(%ecx),%ebx
2149 xorl %ebx, %edi
2150 movl 0x400+des_SPtrans(%eax),%ebx
2151 xorl %ebx, %edi
2152 movl 0x500+des_SPtrans(%edx),%ebx
2153 xorl %ebx, %edi
2154
2155 /* Round 10 */
2156 movl 80(%ebp), %eax
2157 xorl %ebx, %ebx
2158 movl 84(%ebp), %edx
2159 xorl %edi, %eax
2160 xorl %edi, %edx
2161 andl $0xfcfcfcfc, %eax
2162 andl $0xcfcfcfcf, %edx
2163 movb %al, %bl
2164 movb %ah, %cl
2165 rorl $4, %edx
2166 movl des_SPtrans(%ebx),%ebp
2167 movb %dl, %bl
2168 xorl %ebp, %esi
2169 movl 0x200+des_SPtrans(%ecx),%ebp
2170 xorl %ebp, %esi
2171 movb %dh, %cl
2172 shrl $16, %eax
2173 movl 0x100+des_SPtrans(%ebx),%ebp
2174 xorl %ebp, %esi
2175 movb %ah, %bl
2176 shrl $16, %edx
2177 movl 0x300+des_SPtrans(%ecx),%ebp
2178 xorl %ebp, %esi
2179 movl 24(%esp), %ebp
2180 movb %dh, %cl
2181 andl $0xff, %eax
2182 andl $0xff, %edx
2183 movl 0x600+des_SPtrans(%ebx),%ebx
2184 xorl %ebx, %esi
2185 movl 0x700+des_SPtrans(%ecx),%ebx
2186 xorl %ebx, %esi
2187 movl 0x400+des_SPtrans(%eax),%ebx
2188 xorl %ebx, %esi
2189 movl 0x500+des_SPtrans(%edx),%ebx
2190 xorl %ebx, %esi
2191
2192 /* Round 9 */
2193 movl 72(%ebp), %eax
2194 xorl %ebx, %ebx
2195 movl 76(%ebp), %edx
2196 xorl %esi, %eax
2197 xorl %esi, %edx
2198 andl $0xfcfcfcfc, %eax
2199 andl $0xcfcfcfcf, %edx
2200 movb %al, %bl
2201 movb %ah, %cl
2202 rorl $4, %edx
2203 movl des_SPtrans(%ebx),%ebp
2204 movb %dl, %bl
2205 xorl %ebp, %edi
2206 movl 0x200+des_SPtrans(%ecx),%ebp
2207 xorl %ebp, %edi
2208 movb %dh, %cl
2209 shrl $16, %eax
2210 movl 0x100+des_SPtrans(%ebx),%ebp
2211 xorl %ebp, %edi
2212 movb %ah, %bl
2213 shrl $16, %edx
2214 movl 0x300+des_SPtrans(%ecx),%ebp
2215 xorl %ebp, %edi
2216 movl 24(%esp), %ebp
2217 movb %dh, %cl
2218 andl $0xff, %eax
2219 andl $0xff, %edx
2220 movl 0x600+des_SPtrans(%ebx),%ebx
2221 xorl %ebx, %edi
2222 movl 0x700+des_SPtrans(%ecx),%ebx
2223 xorl %ebx, %edi
2224 movl 0x400+des_SPtrans(%eax),%ebx
2225 xorl %ebx, %edi
2226 movl 0x500+des_SPtrans(%edx),%ebx
2227 xorl %ebx, %edi
2228
2229 /* Round 8 */
2230 movl 64(%ebp), %eax
2231 xorl %ebx, %ebx
2232 movl 68(%ebp), %edx
2233 xorl %edi, %eax
2234 xorl %edi, %edx
2235 andl $0xfcfcfcfc, %eax
2236 andl $0xcfcfcfcf, %edx
2237 movb %al, %bl
2238 movb %ah, %cl
2239 rorl $4, %edx
2240 movl des_SPtrans(%ebx),%ebp
2241 movb %dl, %bl
2242 xorl %ebp, %esi
2243 movl 0x200+des_SPtrans(%ecx),%ebp
2244 xorl %ebp, %esi
2245 movb %dh, %cl
2246 shrl $16, %eax
2247 movl 0x100+des_SPtrans(%ebx),%ebp
2248 xorl %ebp, %esi
2249 movb %ah, %bl
2250 shrl $16, %edx
2251 movl 0x300+des_SPtrans(%ecx),%ebp
2252 xorl %ebp, %esi
2253 movl 24(%esp), %ebp
2254 movb %dh, %cl
2255 andl $0xff, %eax
2256 andl $0xff, %edx
2257 movl 0x600+des_SPtrans(%ebx),%ebx
2258 xorl %ebx, %esi
2259 movl 0x700+des_SPtrans(%ecx),%ebx
2260 xorl %ebx, %esi
2261 movl 0x400+des_SPtrans(%eax),%ebx
2262 xorl %ebx, %esi
2263 movl 0x500+des_SPtrans(%edx),%ebx
2264 xorl %ebx, %esi
2265
2266 /* Round 7 */
2267 movl 56(%ebp), %eax
2268 xorl %ebx, %ebx
2269 movl 60(%ebp), %edx
2270 xorl %esi, %eax
2271 xorl %esi, %edx
2272 andl $0xfcfcfcfc, %eax
2273 andl $0xcfcfcfcf, %edx
2274 movb %al, %bl
2275 movb %ah, %cl
2276 rorl $4, %edx
2277 movl des_SPtrans(%ebx),%ebp
2278 movb %dl, %bl
2279 xorl %ebp, %edi
2280 movl 0x200+des_SPtrans(%ecx),%ebp
2281 xorl %ebp, %edi
2282 movb %dh, %cl
2283 shrl $16, %eax
2284 movl 0x100+des_SPtrans(%ebx),%ebp
2285 xorl %ebp, %edi
2286 movb %ah, %bl
2287 shrl $16, %edx
2288 movl 0x300+des_SPtrans(%ecx),%ebp
2289 xorl %ebp, %edi
2290 movl 24(%esp), %ebp
2291 movb %dh, %cl
2292 andl $0xff, %eax
2293 andl $0xff, %edx
2294 movl 0x600+des_SPtrans(%ebx),%ebx
2295 xorl %ebx, %edi
2296 movl 0x700+des_SPtrans(%ecx),%ebx
2297 xorl %ebx, %edi
2298 movl 0x400+des_SPtrans(%eax),%ebx
2299 xorl %ebx, %edi
2300 movl 0x500+des_SPtrans(%edx),%ebx
2301 xorl %ebx, %edi
2302
2303 /* Round 6 */
2304 movl 48(%ebp), %eax
2305 xorl %ebx, %ebx
2306 movl 52(%ebp), %edx
2307 xorl %edi, %eax
2308 xorl %edi, %edx
2309 andl $0xfcfcfcfc, %eax
2310 andl $0xcfcfcfcf, %edx
2311 movb %al, %bl
2312 movb %ah, %cl
2313 rorl $4, %edx
2314 movl des_SPtrans(%ebx),%ebp
2315 movb %dl, %bl
2316 xorl %ebp, %esi
2317 movl 0x200+des_SPtrans(%ecx),%ebp
2318 xorl %ebp, %esi
2319 movb %dh, %cl
2320 shrl $16, %eax
2321 movl 0x100+des_SPtrans(%ebx),%ebp
2322 xorl %ebp, %esi
2323 movb %ah, %bl
2324 shrl $16, %edx
2325 movl 0x300+des_SPtrans(%ecx),%ebp
2326 xorl %ebp, %esi
2327 movl 24(%esp), %ebp
2328 movb %dh, %cl
2329 andl $0xff, %eax
2330 andl $0xff, %edx
2331 movl 0x600+des_SPtrans(%ebx),%ebx
2332 xorl %ebx, %esi
2333 movl 0x700+des_SPtrans(%ecx),%ebx
2334 xorl %ebx, %esi
2335 movl 0x400+des_SPtrans(%eax),%ebx
2336 xorl %ebx, %esi
2337 movl 0x500+des_SPtrans(%edx),%ebx
2338 xorl %ebx, %esi
2339
2340 /* Round 5 */
2341 movl 40(%ebp), %eax
2342 xorl %ebx, %ebx
2343 movl 44(%ebp), %edx
2344 xorl %esi, %eax
2345 xorl %esi, %edx
2346 andl $0xfcfcfcfc, %eax
2347 andl $0xcfcfcfcf, %edx
2348 movb %al, %bl
2349 movb %ah, %cl
2350 rorl $4, %edx
2351 movl des_SPtrans(%ebx),%ebp
2352 movb %dl, %bl
2353 xorl %ebp, %edi
2354 movl 0x200+des_SPtrans(%ecx),%ebp
2355 xorl %ebp, %edi
2356 movb %dh, %cl
2357 shrl $16, %eax
2358 movl 0x100+des_SPtrans(%ebx),%ebp
2359 xorl %ebp, %edi
2360 movb %ah, %bl
2361 shrl $16, %edx
2362 movl 0x300+des_SPtrans(%ecx),%ebp
2363 xorl %ebp, %edi
2364 movl 24(%esp), %ebp
2365 movb %dh, %cl
2366 andl $0xff, %eax
2367 andl $0xff, %edx
2368 movl 0x600+des_SPtrans(%ebx),%ebx
2369 xorl %ebx, %edi
2370 movl 0x700+des_SPtrans(%ecx),%ebx
2371 xorl %ebx, %edi
2372 movl 0x400+des_SPtrans(%eax),%ebx
2373 xorl %ebx, %edi
2374 movl 0x500+des_SPtrans(%edx),%ebx
2375 xorl %ebx, %edi
2376
2377 /* Round 4 */
2378 movl 32(%ebp), %eax
2379 xorl %ebx, %ebx
2380 movl 36(%ebp), %edx
2381 xorl %edi, %eax
2382 xorl %edi, %edx
2383 andl $0xfcfcfcfc, %eax
2384 andl $0xcfcfcfcf, %edx
2385 movb %al, %bl
2386 movb %ah, %cl
2387 rorl $4, %edx
2388 movl des_SPtrans(%ebx),%ebp
2389 movb %dl, %bl
2390 xorl %ebp, %esi
2391 movl 0x200+des_SPtrans(%ecx),%ebp
2392 xorl %ebp, %esi
2393 movb %dh, %cl
2394 shrl $16, %eax
2395 movl 0x100+des_SPtrans(%ebx),%ebp
2396 xorl %ebp, %esi
2397 movb %ah, %bl
2398 shrl $16, %edx
2399 movl 0x300+des_SPtrans(%ecx),%ebp
2400 xorl %ebp, %esi
2401 movl 24(%esp), %ebp
2402 movb %dh, %cl
2403 andl $0xff, %eax
2404 andl $0xff, %edx
2405 movl 0x600+des_SPtrans(%ebx),%ebx
2406 xorl %ebx, %esi
2407 movl 0x700+des_SPtrans(%ecx),%ebx
2408 xorl %ebx, %esi
2409 movl 0x400+des_SPtrans(%eax),%ebx
2410 xorl %ebx, %esi
2411 movl 0x500+des_SPtrans(%edx),%ebx
2412 xorl %ebx, %esi
2413
2414 /* Round 3 */
2415 movl 24(%ebp), %eax
2416 xorl %ebx, %ebx
2417 movl 28(%ebp), %edx
2418 xorl %esi, %eax
2419 xorl %esi, %edx
2420 andl $0xfcfcfcfc, %eax
2421 andl $0xcfcfcfcf, %edx
2422 movb %al, %bl
2423 movb %ah, %cl
2424 rorl $4, %edx
2425 movl des_SPtrans(%ebx),%ebp
2426 movb %dl, %bl
2427 xorl %ebp, %edi
2428 movl 0x200+des_SPtrans(%ecx),%ebp
2429 xorl %ebp, %edi
2430 movb %dh, %cl
2431 shrl $16, %eax
2432 movl 0x100+des_SPtrans(%ebx),%ebp
2433 xorl %ebp, %edi
2434 movb %ah, %bl
2435 shrl $16, %edx
2436 movl 0x300+des_SPtrans(%ecx),%ebp
2437 xorl %ebp, %edi
2438 movl 24(%esp), %ebp
2439 movb %dh, %cl
2440 andl $0xff, %eax
2441 andl $0xff, %edx
2442 movl 0x600+des_SPtrans(%ebx),%ebx
2443 xorl %ebx, %edi
2444 movl 0x700+des_SPtrans(%ecx),%ebx
2445 xorl %ebx, %edi
2446 movl 0x400+des_SPtrans(%eax),%ebx
2447 xorl %ebx, %edi
2448 movl 0x500+des_SPtrans(%edx),%ebx
2449 xorl %ebx, %edi
2450
2451 /* Round 2 */
2452 movl 16(%ebp), %eax
2453 xorl %ebx, %ebx
2454 movl 20(%ebp), %edx
2455 xorl %edi, %eax
2456 xorl %edi, %edx
2457 andl $0xfcfcfcfc, %eax
2458 andl $0xcfcfcfcf, %edx
2459 movb %al, %bl
2460 movb %ah, %cl
2461 rorl $4, %edx
2462 movl des_SPtrans(%ebx),%ebp
2463 movb %dl, %bl
2464 xorl %ebp, %esi
2465 movl 0x200+des_SPtrans(%ecx),%ebp
2466 xorl %ebp, %esi
2467 movb %dh, %cl
2468 shrl $16, %eax
2469 movl 0x100+des_SPtrans(%ebx),%ebp
2470 xorl %ebp, %esi
2471 movb %ah, %bl
2472 shrl $16, %edx
2473 movl 0x300+des_SPtrans(%ecx),%ebp
2474 xorl %ebp, %esi
2475 movl 24(%esp), %ebp
2476 movb %dh, %cl
2477 andl $0xff, %eax
2478 andl $0xff, %edx
2479 movl 0x600+des_SPtrans(%ebx),%ebx
2480 xorl %ebx, %esi
2481 movl 0x700+des_SPtrans(%ecx),%ebx
2482 xorl %ebx, %esi
2483 movl 0x400+des_SPtrans(%eax),%ebx
2484 xorl %ebx, %esi
2485 movl 0x500+des_SPtrans(%edx),%ebx
2486 xorl %ebx, %esi
2487
2488 /* Round 1 */
2489 movl 8(%ebp), %eax
2490 xorl %ebx, %ebx
2491 movl 12(%ebp), %edx
2492 xorl %esi, %eax
2493 xorl %esi, %edx
2494 andl $0xfcfcfcfc, %eax
2495 andl $0xcfcfcfcf, %edx
2496 movb %al, %bl
2497 movb %ah, %cl
2498 rorl $4, %edx
2499 movl des_SPtrans(%ebx),%ebp
2500 movb %dl, %bl
2501 xorl %ebp, %edi
2502 movl 0x200+des_SPtrans(%ecx),%ebp
2503 xorl %ebp, %edi
2504 movb %dh, %cl
2505 shrl $16, %eax
2506 movl 0x100+des_SPtrans(%ebx),%ebp
2507 xorl %ebp, %edi
2508 movb %ah, %bl
2509 shrl $16, %edx
2510 movl 0x300+des_SPtrans(%ecx),%ebp
2511 xorl %ebp, %edi
2512 movl 24(%esp), %ebp
2513 movb %dh, %cl
2514 andl $0xff, %eax
2515 andl $0xff, %edx
2516 movl 0x600+des_SPtrans(%ebx),%ebx
2517 xorl %ebx, %edi
2518 movl 0x700+des_SPtrans(%ecx),%ebx
2519 xorl %ebx, %edi
2520 movl 0x400+des_SPtrans(%eax),%ebx
2521 xorl %ebx, %edi
2522 movl 0x500+des_SPtrans(%edx),%ebx
2523 xorl %ebx, %edi
2524
2525 /* Round 0 */
2526 movl (%ebp), %eax
2527 xorl %ebx, %ebx
2528 movl 4(%ebp), %edx
2529 xorl %edi, %eax
2530 xorl %edi, %edx
2531 andl $0xfcfcfcfc, %eax
2532 andl $0xcfcfcfcf, %edx
2533 movb %al, %bl
2534 movb %ah, %cl
2535 rorl $4, %edx
2536 movl des_SPtrans(%ebx),%ebp
2537 movb %dl, %bl
2538 xorl %ebp, %esi
2539 movl 0x200+des_SPtrans(%ecx),%ebp
2540 xorl %ebp, %esi
2541 movb %dh, %cl
2542 shrl $16, %eax
2543 movl 0x100+des_SPtrans(%ebx),%ebp
2544 xorl %ebp, %esi
2545 movb %ah, %bl
2546 shrl $16, %edx
2547 movl 0x300+des_SPtrans(%ecx),%ebp
2548 xorl %ebp, %esi
2549 movl 24(%esp), %ebp
2550 movb %dh, %cl
2551 andl $0xff, %eax
2552 andl $0xff, %edx
2553 movl 0x600+des_SPtrans(%ebx),%ebx
2554 xorl %ebx, %esi
2555 movl 0x700+des_SPtrans(%ecx),%ebx
2556 xorl %ebx, %esi
2557 movl 0x400+des_SPtrans(%eax),%ebx
2558 xorl %ebx, %esi
2559 movl 0x500+des_SPtrans(%edx),%ebx
2560 xorl %ebx, %esi
2561.L003end:
2562
2563 /* Fixup */
2564 rorl $3, %edi
2565 movl 20(%esp), %eax
2566 rorl $3, %esi
2567 movl %edi, (%eax)
2568 movl %esi, 4(%eax)
2569 popl %ebp
2570 popl %ebx
2571 popl %edi
2572 popl %esi
2573 ret
2574.des_encrypt2_end:
2575 SIZE(des_encrypt2,.des_encrypt2_end-des_encrypt2)
2576.ident "desasm.pl"
2577.text
2578 .align ALIGN
2579.globl des_encrypt3
2580 TYPE(des_encrypt3,@function)
2581des_encrypt3:
2582 pushl %ebx
2583 movl 8(%esp), %ebx
2584 pushl %ebp
2585 pushl %esi
2586 pushl %edi
2587
2588 /* Load the data words */
2589 movl (%ebx), %edi
2590 movl 4(%ebx), %esi
2591 subl $12, %esp
2592
2593 /* IP */
2594 roll $4, %edi
2595 movl %edi, %edx
2596 xorl %esi, %edi
2597 andl $0xf0f0f0f0, %edi
2598 xorl %edi, %edx
2599 xorl %edi, %esi
2600
2601 roll $20, %esi
2602 movl %esi, %edi
2603 xorl %edx, %esi
2604 andl $0xfff0000f, %esi
2605 xorl %esi, %edi
2606 xorl %esi, %edx
2607
2608 roll $14, %edi
2609 movl %edi, %esi
2610 xorl %edx, %edi
2611 andl $0x33333333, %edi
2612 xorl %edi, %esi
2613 xorl %edi, %edx
2614
2615 roll $22, %edx
2616 movl %edx, %edi
2617 xorl %esi, %edx
2618 andl $0x03fc03fc, %edx
2619 xorl %edx, %edi
2620 xorl %edx, %esi
2621
2622 roll $9, %edi
2623 movl %edi, %edx
2624 xorl %esi, %edi
2625 andl $0xaaaaaaaa, %edi
2626 xorl %edi, %edx
2627 xorl %edi, %esi
2628
2629 rorl $3, %edx
2630 rorl $2, %esi
2631 movl %esi, 4(%ebx)
2632 movl 36(%esp), %eax
2633 movl %edx, (%ebx)
2634 movl 40(%esp), %edi
2635 movl 44(%esp), %esi
2636 movl $1, 8(%esp)
2637 movl %eax, 4(%esp)
2638 movl %ebx, (%esp)
2639 call des_encrypt2
2640 movl $0, 8(%esp)
2641 movl %edi, 4(%esp)
2642 movl %ebx, (%esp)
2643 call des_encrypt2
2644 movl $1, 8(%esp)
2645 movl %esi, 4(%esp)
2646 movl %ebx, (%esp)
2647 call des_encrypt2
2648 addl $12, %esp
2649 movl (%ebx), %edi
2650 movl 4(%ebx), %esi
2651
2652 /* FP */
2653 roll $2, %esi
2654 roll $3, %edi
2655 movl %edi, %eax
2656 xorl %esi, %edi
2657 andl $0xaaaaaaaa, %edi
2658 xorl %edi, %eax
2659 xorl %edi, %esi
2660
2661 roll $23, %eax
2662 movl %eax, %edi
2663 xorl %esi, %eax
2664 andl $0x03fc03fc, %eax
2665 xorl %eax, %edi
2666 xorl %eax, %esi
2667
2668 roll $10, %edi
2669 movl %edi, %eax
2670 xorl %esi, %edi
2671 andl $0x33333333, %edi
2672 xorl %edi, %eax
2673 xorl %edi, %esi
2674
2675 roll $18, %esi
2676 movl %esi, %edi
2677 xorl %eax, %esi
2678 andl $0xfff0000f, %esi
2679 xorl %esi, %edi
2680 xorl %esi, %eax
2681
2682 roll $12, %edi
2683 movl %edi, %esi
2684 xorl %eax, %edi
2685 andl $0xf0f0f0f0, %edi
2686 xorl %edi, %esi
2687 xorl %edi, %eax
2688
2689 rorl $4, %eax
2690 movl %eax, (%ebx)
2691 movl %esi, 4(%ebx)
2692 popl %edi
2693 popl %esi
2694 popl %ebp
2695 popl %ebx
2696 ret
2697.des_encrypt3_end:
2698 SIZE(des_encrypt3,.des_encrypt3_end-des_encrypt3)
2699.ident "desasm.pl"
2700.text
2701 .align ALIGN
2702.globl des_decrypt3
2703 TYPE(des_decrypt3,@function)
2704des_decrypt3:
2705 pushl %ebx
2706 movl 8(%esp), %ebx
2707 pushl %ebp
2708 pushl %esi
2709 pushl %edi
2710
2711 /* Load the data words */
2712 movl (%ebx), %edi
2713 movl 4(%ebx), %esi
2714 subl $12, %esp
2715
2716 /* IP */
2717 roll $4, %edi
2718 movl %edi, %edx
2719 xorl %esi, %edi
2720 andl $0xf0f0f0f0, %edi
2721 xorl %edi, %edx
2722 xorl %edi, %esi
2723
2724 roll $20, %esi
2725 movl %esi, %edi
2726 xorl %edx, %esi
2727 andl $0xfff0000f, %esi
2728 xorl %esi, %edi
2729 xorl %esi, %edx
2730
2731 roll $14, %edi
2732 movl %edi, %esi
2733 xorl %edx, %edi
2734 andl $0x33333333, %edi
2735 xorl %edi, %esi
2736 xorl %edi, %edx
2737
2738 roll $22, %edx
2739 movl %edx, %edi
2740 xorl %esi, %edx
2741 andl $0x03fc03fc, %edx
2742 xorl %edx, %edi
2743 xorl %edx, %esi
2744
2745 roll $9, %edi
2746 movl %edi, %edx
2747 xorl %esi, %edi
2748 andl $0xaaaaaaaa, %edi
2749 xorl %edi, %edx
2750 xorl %edi, %esi
2751
2752 rorl $3, %edx
2753 rorl $2, %esi
2754 movl %esi, 4(%ebx)
2755 movl 36(%esp), %esi
2756 movl %edx, (%ebx)
2757 movl 40(%esp), %edi
2758 movl 44(%esp), %eax
2759 movl $0, 8(%esp)
2760 movl %eax, 4(%esp)
2761 movl %ebx, (%esp)
2762 call des_encrypt2
2763 movl $1, 8(%esp)
2764 movl %edi, 4(%esp)
2765 movl %ebx, (%esp)
2766 call des_encrypt2
2767 movl $0, 8(%esp)
2768 movl %esi, 4(%esp)
2769 movl %ebx, (%esp)
2770 call des_encrypt2
2771 addl $12, %esp
2772 movl (%ebx), %edi
2773 movl 4(%ebx), %esi
2774
2775 /* FP */
2776 roll $2, %esi
2777 roll $3, %edi
2778 movl %edi, %eax
2779 xorl %esi, %edi
2780 andl $0xaaaaaaaa, %edi
2781 xorl %edi, %eax
2782 xorl %edi, %esi
2783
2784 roll $23, %eax
2785 movl %eax, %edi
2786 xorl %esi, %eax
2787 andl $0x03fc03fc, %eax
2788 xorl %eax, %edi
2789 xorl %eax, %esi
2790
2791 roll $10, %edi
2792 movl %edi, %eax
2793 xorl %esi, %edi
2794 andl $0x33333333, %edi
2795 xorl %edi, %eax
2796 xorl %edi, %esi
2797
2798 roll $18, %esi
2799 movl %esi, %edi
2800 xorl %eax, %esi
2801 andl $0xfff0000f, %esi
2802 xorl %esi, %edi
2803 xorl %esi, %eax
2804
2805 roll $12, %edi
2806 movl %edi, %esi
2807 xorl %eax, %edi
2808 andl $0xf0f0f0f0, %edi
2809 xorl %edi, %esi
2810 xorl %edi, %eax
2811
2812 rorl $4, %eax
2813 movl %eax, (%ebx)
2814 movl %esi, 4(%ebx)
2815 popl %edi
2816 popl %esi
2817 popl %ebp
2818 popl %ebx
2819 ret
2820.des_decrypt3_end:
2821 SIZE(des_decrypt3,.des_decrypt3_end-des_decrypt3)
2822.ident "desasm.pl"
2823.text
2824 .align ALIGN
2825.globl des_ncbc_encrypt
2826 TYPE(des_ncbc_encrypt,@function)
2827des_ncbc_encrypt:
2828
2829 pushl %ebp
2830 pushl %ebx
2831 pushl %esi
2832 pushl %edi
2833 movl 28(%esp), %ebp
2834 /* getting iv ptr from parameter 4 */
2835 movl 36(%esp), %ebx
2836 movl (%ebx), %esi
2837 movl 4(%ebx), %edi
2838 pushl %edi
2839 pushl %esi
2840 pushl %edi
2841 pushl %esi
2842 movl %esp, %ebx
2843 movl 36(%esp), %esi
2844 movl 40(%esp), %edi
2845 /* getting encrypt flag from parameter 5 */
2846 movl 56(%esp), %ecx
2847 /* get and push parameter 5 */
2848 pushl %ecx
2849 /* get and push parameter 3 */
2850 movl 52(%esp), %eax
2851 pushl %eax
2852 pushl %ebx
2853 cmpl $0, %ecx
2854 jz .L004decrypt
2855 andl $4294967288, %ebp
2856 movl 12(%esp), %eax
2857 movl 16(%esp), %ebx
2858 jz .L005encrypt_finish
2859.L006encrypt_loop:
2860 movl (%esi), %ecx
2861 movl 4(%esi), %edx
2862 xorl %ecx, %eax
2863 xorl %edx, %ebx
2864 movl %eax, 12(%esp)
2865 movl %ebx, 16(%esp)
2866 call des_encrypt
2867 movl 12(%esp), %eax
2868 movl 16(%esp), %ebx
2869 movl %eax, (%edi)
2870 movl %ebx, 4(%edi)
2871 addl $8, %esi
2872 addl $8, %edi
2873 subl $8, %ebp
2874 jnz .L006encrypt_loop
2875.L005encrypt_finish:
2876 movl 56(%esp), %ebp
2877 andl $7, %ebp
2878 jz .L007finish
2879 xorl %ecx, %ecx
2880 xorl %edx, %edx
2881 movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp
2882 jmp *%ebp
2883.L009ej7:
2884 movb 6(%esi), %dh
2885 sall $8, %edx
2886.L010ej6:
2887 movb 5(%esi), %dh
2888.L011ej5:
2889 movb 4(%esi), %dl
2890.L012ej4:
2891 movl (%esi), %ecx
2892 jmp .L013ejend
2893.L014ej3:
2894 movb 2(%esi), %ch
2895 sall $8, %ecx
2896.L015ej2:
2897 movb 1(%esi), %ch
2898.L016ej1:
2899 movb (%esi), %cl
2900.L013ejend:
2901 xorl %ecx, %eax
2902 xorl %edx, %ebx
2903 movl %eax, 12(%esp)
2904 movl %ebx, 16(%esp)
2905 call des_encrypt
2906 movl 12(%esp), %eax
2907 movl 16(%esp), %ebx
2908 movl %eax, (%edi)
2909 movl %ebx, 4(%edi)
2910 jmp .L007finish
2911.align ALIGN
2912.L004decrypt:
2913 andl $4294967288, %ebp
2914 movl 20(%esp), %eax
2915 movl 24(%esp), %ebx
2916 jz .L017decrypt_finish
2917.L018decrypt_loop:
2918 movl (%esi), %eax
2919 movl 4(%esi), %ebx
2920 movl %eax, 12(%esp)
2921 movl %ebx, 16(%esp)
2922 call des_encrypt
2923 movl 12(%esp), %eax
2924 movl 16(%esp), %ebx
2925 movl 20(%esp), %ecx
2926 movl 24(%esp), %edx
2927 xorl %eax, %ecx
2928 xorl %ebx, %edx
2929 movl (%esi), %eax
2930 movl 4(%esi), %ebx
2931 movl %ecx, (%edi)
2932 movl %edx, 4(%edi)
2933 movl %eax, 20(%esp)
2934 movl %ebx, 24(%esp)
2935 addl $8, %esi
2936 addl $8, %edi
2937 subl $8, %ebp
2938 jnz .L018decrypt_loop
2939.L017decrypt_finish:
2940 movl 56(%esp), %ebp
2941 andl $7, %ebp
2942 jz .L007finish
2943 movl (%esi), %eax
2944 movl 4(%esi), %ebx
2945 movl %eax, 12(%esp)
2946 movl %ebx, 16(%esp)
2947 call des_encrypt
2948 movl 12(%esp), %eax
2949 movl 16(%esp), %ebx
2950 movl 20(%esp), %ecx
2951 movl 24(%esp), %edx
2952 xorl %eax, %ecx
2953 xorl %ebx, %edx
2954 movl (%esi), %eax
2955 movl 4(%esi), %ebx
2956.L019dj7:
2957 rorl $16, %edx
2958 movb %dl, 6(%edi)
2959 shrl $16, %edx
2960.L020dj6:
2961 movb %dh, 5(%edi)
2962.L021dj5:
2963 movb %dl, 4(%edi)
2964.L022dj4:
2965 movl %ecx, (%edi)
2966 jmp .L023djend
2967.L024dj3:
2968 rorl $16, %ecx
2969 movb %cl, 2(%edi)
2970 sall $16, %ecx
2971.L025dj2:
2972 movb %ch, 1(%esi)
2973.L026dj1:
2974 movb %cl, (%esi)
2975.L023djend:
2976 jmp .L007finish
2977.align ALIGN
2978.L007finish:
2979 movl 64(%esp), %ecx
2980 addl $28, %esp
2981 movl %eax, (%ecx)
2982 movl %ebx, 4(%ecx)
2983 popl %edi
2984 popl %esi
2985 popl %ebx
2986 popl %ebp
2987 ret
2988.align ALIGN
2989.L008cbc_enc_jmp_table:
2990 .long 0
2991 .long .L016ej1
2992 .long .L015ej2
2993 .long .L014ej3
2994 .long .L012ej4
2995 .long .L011ej5
2996 .long .L010ej6
2997 .long .L009ej7
2998.align ALIGN
2999.L027cbc_dec_jmp_table:
3000 .long 0
3001 .long .L026dj1
3002 .long .L025dj2
3003 .long .L024dj3
3004 .long .L022dj4
3005 .long .L021dj5
3006 .long .L020dj6
3007 .long .L019dj7
3008.des_ncbc_encrypt_end:
3009 SIZE(des_ncbc_encrypt,.des_ncbc_encrypt_end-des_ncbc_encrypt)
3010.ident "desasm.pl"
3011.text
3012 .align ALIGN
3013.globl des_ede3_cbc_encrypt
3014 TYPE(des_ede3_cbc_encrypt,@function)
3015des_ede3_cbc_encrypt:
3016
3017 pushl %ebp
3018 pushl %ebx
3019 pushl %esi
3020 pushl %edi
3021 movl 28(%esp), %ebp
3022 /* getting iv ptr from parameter 6 */
3023 movl 44(%esp), %ebx
3024 movl (%ebx), %esi
3025 movl 4(%ebx), %edi
3026 pushl %edi
3027 pushl %esi
3028 pushl %edi
3029 pushl %esi
3030 movl %esp, %ebx
3031 movl 36(%esp), %esi
3032 movl 40(%esp), %edi
3033 /* getting encrypt flag from parameter 7 */
3034 movl 64(%esp), %ecx
3035 /* get and push parameter 5 */
3036 movl 56(%esp), %eax
3037 pushl %eax
3038 /* get and push parameter 4 */
3039 movl 56(%esp), %eax
3040 pushl %eax
3041 /* get and push parameter 3 */
3042 movl 56(%esp), %eax
3043 pushl %eax
3044 pushl %ebx
3045 cmpl $0, %ecx
3046 jz .L028decrypt
3047 andl $4294967288, %ebp
3048 movl 16(%esp), %eax
3049 movl 20(%esp), %ebx
3050 jz .L029encrypt_finish
3051.L030encrypt_loop:
3052 movl (%esi), %ecx
3053 movl 4(%esi), %edx
3054 xorl %ecx, %eax
3055 xorl %edx, %ebx
3056 movl %eax, 16(%esp)
3057 movl %ebx, 20(%esp)
3058 call des_encrypt3
3059 movl 16(%esp), %eax
3060 movl 20(%esp), %ebx
3061 movl %eax, (%edi)
3062 movl %ebx, 4(%edi)
3063 addl $8, %esi
3064 addl $8, %edi
3065 subl $8, %ebp
3066 jnz .L030encrypt_loop
3067.L029encrypt_finish:
3068 movl 60(%esp), %ebp
3069 andl $7, %ebp
3070 jz .L031finish
3071 xorl %ecx, %ecx
3072 xorl %edx, %edx
3073 movl .L032cbc_enc_jmp_table(,%ebp,4),%ebp
3074 jmp *%ebp
3075.L033ej7:
3076 movb 6(%esi), %dh
3077 sall $8, %edx
3078.L034ej6:
3079 movb 5(%esi), %dh
3080.L035ej5:
3081 movb 4(%esi), %dl
3082.L036ej4:
3083 movl (%esi), %ecx
3084 jmp .L037ejend
3085.L038ej3:
3086 movb 2(%esi), %ch
3087 sall $8, %ecx
3088.L039ej2:
3089 movb 1(%esi), %ch
3090.L040ej1:
3091 movb (%esi), %cl
3092.L037ejend:
3093 xorl %ecx, %eax
3094 xorl %edx, %ebx
3095 movl %eax, 16(%esp)
3096 movl %ebx, 20(%esp)
3097 call des_encrypt3
3098 movl 16(%esp), %eax
3099 movl 20(%esp), %ebx
3100 movl %eax, (%edi)
3101 movl %ebx, 4(%edi)
3102 jmp .L031finish
3103.align ALIGN
3104.L028decrypt:
3105 andl $4294967288, %ebp
3106 movl 24(%esp), %eax
3107 movl 28(%esp), %ebx
3108 jz .L041decrypt_finish
3109.L042decrypt_loop:
3110 movl (%esi), %eax
3111 movl 4(%esi), %ebx
3112 movl %eax, 16(%esp)
3113 movl %ebx, 20(%esp)
3114 call des_decrypt3
3115 movl 16(%esp), %eax
3116 movl 20(%esp), %ebx
3117 movl 24(%esp), %ecx
3118 movl 28(%esp), %edx
3119 xorl %eax, %ecx
3120 xorl %ebx, %edx
3121 movl (%esi), %eax
3122 movl 4(%esi), %ebx
3123 movl %ecx, (%edi)
3124 movl %edx, 4(%edi)
3125 movl %eax, 24(%esp)
3126 movl %ebx, 28(%esp)
3127 addl $8, %esi
3128 addl $8, %edi
3129 subl $8, %ebp
3130 jnz .L042decrypt_loop
3131.L041decrypt_finish:
3132 movl 60(%esp), %ebp
3133 andl $7, %ebp
3134 jz .L031finish
3135 movl (%esi), %eax
3136 movl 4(%esi), %ebx
3137 movl %eax, 16(%esp)
3138 movl %ebx, 20(%esp)
3139 call des_decrypt3
3140 movl 16(%esp), %eax
3141 movl 20(%esp), %ebx
3142 movl 24(%esp), %ecx
3143 movl 28(%esp), %edx
3144 xorl %eax, %ecx
3145 xorl %ebx, %edx
3146 movl (%esi), %eax
3147 movl 4(%esi), %ebx
3148.L043dj7:
3149 rorl $16, %edx
3150 movb %dl, 6(%edi)
3151 shrl $16, %edx
3152.L044dj6:
3153 movb %dh, 5(%edi)
3154.L045dj5:
3155 movb %dl, 4(%edi)
3156.L046dj4:
3157 movl %ecx, (%edi)
3158 jmp .L047djend
3159.L048dj3:
3160 rorl $16, %ecx
3161 movb %cl, 2(%edi)
3162 sall $16, %ecx
3163.L049dj2:
3164 movb %ch, 1(%esi)
3165.L050dj1:
3166 movb %cl, (%esi)
3167.L047djend:
3168 jmp .L031finish
3169.align ALIGN
3170.L031finish:
3171 movl 76(%esp), %ecx
3172 addl $32, %esp
3173 movl %eax, (%ecx)
3174 movl %ebx, 4(%ecx)
3175 popl %edi
3176 popl %esi
3177 popl %ebx
3178 popl %ebp
3179 ret
3180.align ALIGN
3181.L032cbc_enc_jmp_table:
3182 .long 0
3183 .long .L040ej1
3184 .long .L039ej2
3185 .long .L038ej3
3186 .long .L036ej4
3187 .long .L035ej5
3188 .long .L034ej6
3189 .long .L033ej7
3190.align ALIGN
3191.L051cbc_dec_jmp_table:
3192 .long 0
3193 .long .L050dj1
3194 .long .L049dj2
3195 .long .L048dj3
3196 .long .L046dj4
3197 .long .L045dj5
3198 .long .L044dj6
3199 .long .L043dj7
3200.des_ede3_cbc_encrypt_end:
3201 SIZE(des_ede3_cbc_encrypt,.des_ede3_cbc_encrypt_end-des_ede3_cbc_encrypt)
3202.ident "desasm.pl"
diff --git a/src/lib/libcrypto/des/asm/yx86unix.cpp b/src/lib/libcrypto/des/asm/yx86unix.cpp
deleted file mode 100644
index 8719e38607..0000000000
--- a/src/lib/libcrypto/des/asm/yx86unix.cpp
+++ /dev/null
@@ -1,976 +0,0 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define des_SPtrans _des_SPtrans
13#define fcrypt_body _fcrypt_body
14
15#endif
16
17#ifdef OUT
18#define OK 1
19#define ALIGN 4
20#endif
21
22#ifdef BSDI
23#define OK 1
24#define ALIGN 4
25#undef SIZE
26#undef TYPE
27#define SIZE(a,b)
28#define TYPE(a,b)
29#endif
30
31#if defined(ELF) || defined(SOL)
32#define OK 1
33#define ALIGN 16
34#endif
35
36#ifndef OK
37You need to define one of
38ELF - elf systems - linux-elf, NetBSD and DG-UX
39OUT - a.out systems - linux-a.out and FreeBSD
40SOL - solaris systems, which are elf with strange comment lines
41BSDI - a.out with a very primative version of as.
42#endif
43
44/* Let the Assembler begin :-) */
45 /* Don't even think of reading this code */
46 /* It was automatically generated by crypt586.pl */
47 /* Which is a perl program used to generate the x86 assember for */
48 /* any of elf, a.out, BSDI,Win32, or Solaris */
49 /* eric <eay@cryptsoft.com> */
50
51 .file "crypt586.s"
52 .version "01.01"
53gcc2_compiled.:
54.text
55 .align ALIGN
56.globl fcrypt_body
57 TYPE(fcrypt_body,@function)
58fcrypt_body:
59 pushl %ebp
60 pushl %ebx
61 pushl %esi
62 pushl %edi
63
64
65 /* Load the 2 words */
66 xorl %edi, %edi
67 xorl %esi, %esi
68 movl 24(%esp), %ebp
69 pushl $25
70.L000start:
71
72 /* Round 0 */
73 movl 32(%esp), %eax
74 movl %esi, %edx
75 shrl $16, %edx
76 movl 36(%esp), %ecx
77 xorl %esi, %edx
78 andl %edx, %eax
79 andl %ecx, %edx
80 movl %eax, %ebx
81 sall $16, %ebx
82 movl %edx, %ecx
83 sall $16, %ecx
84 xorl %ebx, %eax
85 xorl %ecx, %edx
86 movl (%ebp), %ebx
87 xorl %ebx, %eax
88 movl 4(%ebp), %ecx
89 xorl %esi, %eax
90 xorl %esi, %edx
91 xorl %ecx, %edx
92 andl $0xfcfcfcfc, %eax
93 xorl %ebx, %ebx
94 andl $0xcfcfcfcf, %edx
95 xorl %ecx, %ecx
96 movb %al, %bl
97 movb %ah, %cl
98 rorl $4, %edx
99 movl des_SPtrans(%ebx),%ebp
100 movb %dl, %bl
101 xorl %ebp, %edi
102 movl 0x200+des_SPtrans(%ecx),%ebp
103 xorl %ebp, %edi
104 movb %dh, %cl
105 shrl $16, %eax
106 movl 0x100+des_SPtrans(%ebx),%ebp
107 xorl %ebp, %edi
108 movb %ah, %bl
109 shrl $16, %edx
110 movl 0x300+des_SPtrans(%ecx),%ebp
111 xorl %ebp, %edi
112 movl 28(%esp), %ebp
113 movb %dh, %cl
114 andl $0xff, %eax
115 andl $0xff, %edx
116 movl 0x600+des_SPtrans(%ebx),%ebx
117 xorl %ebx, %edi
118 movl 0x700+des_SPtrans(%ecx),%ebx
119 xorl %ebx, %edi
120 movl 0x400+des_SPtrans(%eax),%ebx
121 xorl %ebx, %edi
122 movl 0x500+des_SPtrans(%edx),%ebx
123 xorl %ebx, %edi
124
125 /* Round 1 */
126 movl 32(%esp), %eax
127 movl %edi, %edx
128 shrl $16, %edx
129 movl 36(%esp), %ecx
130 xorl %edi, %edx
131 andl %edx, %eax
132 andl %ecx, %edx
133 movl %eax, %ebx
134 sall $16, %ebx
135 movl %edx, %ecx
136 sall $16, %ecx
137 xorl %ebx, %eax
138 xorl %ecx, %edx
139 movl 8(%ebp), %ebx
140 xorl %ebx, %eax
141 movl 12(%ebp), %ecx
142 xorl %edi, %eax
143 xorl %edi, %edx
144 xorl %ecx, %edx
145 andl $0xfcfcfcfc, %eax
146 xorl %ebx, %ebx
147 andl $0xcfcfcfcf, %edx
148 xorl %ecx, %ecx
149 movb %al, %bl
150 movb %ah, %cl
151 rorl $4, %edx
152 movl des_SPtrans(%ebx),%ebp
153 movb %dl, %bl
154 xorl %ebp, %esi
155 movl 0x200+des_SPtrans(%ecx),%ebp
156 xorl %ebp, %esi
157 movb %dh, %cl
158 shrl $16, %eax
159 movl 0x100+des_SPtrans(%ebx),%ebp
160 xorl %ebp, %esi
161 movb %ah, %bl
162 shrl $16, %edx
163 movl 0x300+des_SPtrans(%ecx),%ebp
164 xorl %ebp, %esi
165 movl 28(%esp), %ebp
166 movb %dh, %cl
167 andl $0xff, %eax
168 andl $0xff, %edx
169 movl 0x600+des_SPtrans(%ebx),%ebx
170 xorl %ebx, %esi
171 movl 0x700+des_SPtrans(%ecx),%ebx
172 xorl %ebx, %esi
173 movl 0x400+des_SPtrans(%eax),%ebx
174 xorl %ebx, %esi
175 movl 0x500+des_SPtrans(%edx),%ebx
176 xorl %ebx, %esi
177
178 /* Round 2 */
179 movl 32(%esp), %eax
180 movl %esi, %edx
181 shrl $16, %edx
182 movl 36(%esp), %ecx
183 xorl %esi, %edx
184 andl %edx, %eax
185 andl %ecx, %edx
186 movl %eax, %ebx
187 sall $16, %ebx
188 movl %edx, %ecx
189 sall $16, %ecx
190 xorl %ebx, %eax
191 xorl %ecx, %edx
192 movl 16(%ebp), %ebx
193 xorl %ebx, %eax
194 movl 20(%ebp), %ecx
195 xorl %esi, %eax
196 xorl %esi, %edx
197 xorl %ecx, %edx
198 andl $0xfcfcfcfc, %eax
199 xorl %ebx, %ebx
200 andl $0xcfcfcfcf, %edx
201 xorl %ecx, %ecx
202 movb %al, %bl
203 movb %ah, %cl
204 rorl $4, %edx
205 movl des_SPtrans(%ebx),%ebp
206 movb %dl, %bl
207 xorl %ebp, %edi
208 movl 0x200+des_SPtrans(%ecx),%ebp
209 xorl %ebp, %edi
210 movb %dh, %cl
211 shrl $16, %eax
212 movl 0x100+des_SPtrans(%ebx),%ebp
213 xorl %ebp, %edi
214 movb %ah, %bl
215 shrl $16, %edx
216 movl 0x300+des_SPtrans(%ecx),%ebp
217 xorl %ebp, %edi
218 movl 28(%esp), %ebp
219 movb %dh, %cl
220 andl $0xff, %eax
221 andl $0xff, %edx
222 movl 0x600+des_SPtrans(%ebx),%ebx
223 xorl %ebx, %edi
224 movl 0x700+des_SPtrans(%ecx),%ebx
225 xorl %ebx, %edi
226 movl 0x400+des_SPtrans(%eax),%ebx
227 xorl %ebx, %edi
228 movl 0x500+des_SPtrans(%edx),%ebx
229 xorl %ebx, %edi
230
231 /* Round 3 */
232 movl 32(%esp), %eax
233 movl %edi, %edx
234 shrl $16, %edx
235 movl 36(%esp), %ecx
236 xorl %edi, %edx
237 andl %edx, %eax
238 andl %ecx, %edx
239 movl %eax, %ebx
240 sall $16, %ebx
241 movl %edx, %ecx
242 sall $16, %ecx
243 xorl %ebx, %eax
244 xorl %ecx, %edx
245 movl 24(%ebp), %ebx
246 xorl %ebx, %eax
247 movl 28(%ebp), %ecx
248 xorl %edi, %eax
249 xorl %edi, %edx
250 xorl %ecx, %edx
251 andl $0xfcfcfcfc, %eax
252 xorl %ebx, %ebx
253 andl $0xcfcfcfcf, %edx
254 xorl %ecx, %ecx
255 movb %al, %bl
256 movb %ah, %cl
257 rorl $4, %edx
258 movl des_SPtrans(%ebx),%ebp
259 movb %dl, %bl
260 xorl %ebp, %esi
261 movl 0x200+des_SPtrans(%ecx),%ebp
262 xorl %ebp, %esi
263 movb %dh, %cl
264 shrl $16, %eax
265 movl 0x100+des_SPtrans(%ebx),%ebp
266 xorl %ebp, %esi
267 movb %ah, %bl
268 shrl $16, %edx
269 movl 0x300+des_SPtrans(%ecx),%ebp
270 xorl %ebp, %esi
271 movl 28(%esp), %ebp
272 movb %dh, %cl
273 andl $0xff, %eax
274 andl $0xff, %edx
275 movl 0x600+des_SPtrans(%ebx),%ebx
276 xorl %ebx, %esi
277 movl 0x700+des_SPtrans(%ecx),%ebx
278 xorl %ebx, %esi
279 movl 0x400+des_SPtrans(%eax),%ebx
280 xorl %ebx, %esi
281 movl 0x500+des_SPtrans(%edx),%ebx
282 xorl %ebx, %esi
283
284 /* Round 4 */
285 movl 32(%esp), %eax
286 movl %esi, %edx
287 shrl $16, %edx
288 movl 36(%esp), %ecx
289 xorl %esi, %edx
290 andl %edx, %eax
291 andl %ecx, %edx
292 movl %eax, %ebx
293 sall $16, %ebx
294 movl %edx, %ecx
295 sall $16, %ecx
296 xorl %ebx, %eax
297 xorl %ecx, %edx
298 movl 32(%ebp), %ebx
299 xorl %ebx, %eax
300 movl 36(%ebp), %ecx
301 xorl %esi, %eax
302 xorl %esi, %edx
303 xorl %ecx, %edx
304 andl $0xfcfcfcfc, %eax
305 xorl %ebx, %ebx
306 andl $0xcfcfcfcf, %edx
307 xorl %ecx, %ecx
308 movb %al, %bl
309 movb %ah, %cl
310 rorl $4, %edx
311 movl des_SPtrans(%ebx),%ebp
312 movb %dl, %bl
313 xorl %ebp, %edi
314 movl 0x200+des_SPtrans(%ecx),%ebp
315 xorl %ebp, %edi
316 movb %dh, %cl
317 shrl $16, %eax
318 movl 0x100+des_SPtrans(%ebx),%ebp
319 xorl %ebp, %edi
320 movb %ah, %bl
321 shrl $16, %edx
322 movl 0x300+des_SPtrans(%ecx),%ebp
323 xorl %ebp, %edi
324 movl 28(%esp), %ebp
325 movb %dh, %cl
326 andl $0xff, %eax
327 andl $0xff, %edx
328 movl 0x600+des_SPtrans(%ebx),%ebx
329 xorl %ebx, %edi
330 movl 0x700+des_SPtrans(%ecx),%ebx
331 xorl %ebx, %edi
332 movl 0x400+des_SPtrans(%eax),%ebx
333 xorl %ebx, %edi
334 movl 0x500+des_SPtrans(%edx),%ebx
335 xorl %ebx, %edi
336
337 /* Round 5 */
338 movl 32(%esp), %eax
339 movl %edi, %edx
340 shrl $16, %edx
341 movl 36(%esp), %ecx
342 xorl %edi, %edx
343 andl %edx, %eax
344 andl %ecx, %edx
345 movl %eax, %ebx
346 sall $16, %ebx
347 movl %edx, %ecx
348 sall $16, %ecx
349 xorl %ebx, %eax
350 xorl %ecx, %edx
351 movl 40(%ebp), %ebx
352 xorl %ebx, %eax
353 movl 44(%ebp), %ecx
354 xorl %edi, %eax
355 xorl %edi, %edx
356 xorl %ecx, %edx
357 andl $0xfcfcfcfc, %eax
358 xorl %ebx, %ebx
359 andl $0xcfcfcfcf, %edx
360 xorl %ecx, %ecx
361 movb %al, %bl
362 movb %ah, %cl
363 rorl $4, %edx
364 movl des_SPtrans(%ebx),%ebp
365 movb %dl, %bl
366 xorl %ebp, %esi
367 movl 0x200+des_SPtrans(%ecx),%ebp
368 xorl %ebp, %esi
369 movb %dh, %cl
370 shrl $16, %eax
371 movl 0x100+des_SPtrans(%ebx),%ebp
372 xorl %ebp, %esi
373 movb %ah, %bl
374 shrl $16, %edx
375 movl 0x300+des_SPtrans(%ecx),%ebp
376 xorl %ebp, %esi
377 movl 28(%esp), %ebp
378 movb %dh, %cl
379 andl $0xff, %eax
380 andl $0xff, %edx
381 movl 0x600+des_SPtrans(%ebx),%ebx
382 xorl %ebx, %esi
383 movl 0x700+des_SPtrans(%ecx),%ebx
384 xorl %ebx, %esi
385 movl 0x400+des_SPtrans(%eax),%ebx
386 xorl %ebx, %esi
387 movl 0x500+des_SPtrans(%edx),%ebx
388 xorl %ebx, %esi
389
390 /* Round 6 */
391 movl 32(%esp), %eax
392 movl %esi, %edx
393 shrl $16, %edx
394 movl 36(%esp), %ecx
395 xorl %esi, %edx
396 andl %edx, %eax
397 andl %ecx, %edx
398 movl %eax, %ebx
399 sall $16, %ebx
400 movl %edx, %ecx
401 sall $16, %ecx
402 xorl %ebx, %eax
403 xorl %ecx, %edx
404 movl 48(%ebp), %ebx
405 xorl %ebx, %eax
406 movl 52(%ebp), %ecx
407 xorl %esi, %eax
408 xorl %esi, %edx
409 xorl %ecx, %edx
410 andl $0xfcfcfcfc, %eax
411 xorl %ebx, %ebx
412 andl $0xcfcfcfcf, %edx
413 xorl %ecx, %ecx
414 movb %al, %bl
415 movb %ah, %cl
416 rorl $4, %edx
417 movl des_SPtrans(%ebx),%ebp
418 movb %dl, %bl
419 xorl %ebp, %edi
420 movl 0x200+des_SPtrans(%ecx),%ebp
421 xorl %ebp, %edi
422 movb %dh, %cl
423 shrl $16, %eax
424 movl 0x100+des_SPtrans(%ebx),%ebp
425 xorl %ebp, %edi
426 movb %ah, %bl
427 shrl $16, %edx
428 movl 0x300+des_SPtrans(%ecx),%ebp
429 xorl %ebp, %edi
430 movl 28(%esp), %ebp
431 movb %dh, %cl
432 andl $0xff, %eax
433 andl $0xff, %edx
434 movl 0x600+des_SPtrans(%ebx),%ebx
435 xorl %ebx, %edi
436 movl 0x700+des_SPtrans(%ecx),%ebx
437 xorl %ebx, %edi
438 movl 0x400+des_SPtrans(%eax),%ebx
439 xorl %ebx, %edi
440 movl 0x500+des_SPtrans(%edx),%ebx
441 xorl %ebx, %edi
442
443 /* Round 7 */
444 movl 32(%esp), %eax
445 movl %edi, %edx
446 shrl $16, %edx
447 movl 36(%esp), %ecx
448 xorl %edi, %edx
449 andl %edx, %eax
450 andl %ecx, %edx
451 movl %eax, %ebx
452 sall $16, %ebx
453 movl %edx, %ecx
454 sall $16, %ecx
455 xorl %ebx, %eax
456 xorl %ecx, %edx
457 movl 56(%ebp), %ebx
458 xorl %ebx, %eax
459 movl 60(%ebp), %ecx
460 xorl %edi, %eax
461 xorl %edi, %edx
462 xorl %ecx, %edx
463 andl $0xfcfcfcfc, %eax
464 xorl %ebx, %ebx
465 andl $0xcfcfcfcf, %edx
466 xorl %ecx, %ecx
467 movb %al, %bl
468 movb %ah, %cl
469 rorl $4, %edx
470 movl des_SPtrans(%ebx),%ebp
471 movb %dl, %bl
472 xorl %ebp, %esi
473 movl 0x200+des_SPtrans(%ecx),%ebp
474 xorl %ebp, %esi
475 movb %dh, %cl
476 shrl $16, %eax
477 movl 0x100+des_SPtrans(%ebx),%ebp
478 xorl %ebp, %esi
479 movb %ah, %bl
480 shrl $16, %edx
481 movl 0x300+des_SPtrans(%ecx),%ebp
482 xorl %ebp, %esi
483 movl 28(%esp), %ebp
484 movb %dh, %cl
485 andl $0xff, %eax
486 andl $0xff, %edx
487 movl 0x600+des_SPtrans(%ebx),%ebx
488 xorl %ebx, %esi
489 movl 0x700+des_SPtrans(%ecx),%ebx
490 xorl %ebx, %esi
491 movl 0x400+des_SPtrans(%eax),%ebx
492 xorl %ebx, %esi
493 movl 0x500+des_SPtrans(%edx),%ebx
494 xorl %ebx, %esi
495
496 /* Round 8 */
497 movl 32(%esp), %eax
498 movl %esi, %edx
499 shrl $16, %edx
500 movl 36(%esp), %ecx
501 xorl %esi, %edx
502 andl %edx, %eax
503 andl %ecx, %edx
504 movl %eax, %ebx
505 sall $16, %ebx
506 movl %edx, %ecx
507 sall $16, %ecx
508 xorl %ebx, %eax
509 xorl %ecx, %edx
510 movl 64(%ebp), %ebx
511 xorl %ebx, %eax
512 movl 68(%ebp), %ecx
513 xorl %esi, %eax
514 xorl %esi, %edx
515 xorl %ecx, %edx
516 andl $0xfcfcfcfc, %eax
517 xorl %ebx, %ebx
518 andl $0xcfcfcfcf, %edx
519 xorl %ecx, %ecx
520 movb %al, %bl
521 movb %ah, %cl
522 rorl $4, %edx
523 movl des_SPtrans(%ebx),%ebp
524 movb %dl, %bl
525 xorl %ebp, %edi
526 movl 0x200+des_SPtrans(%ecx),%ebp
527 xorl %ebp, %edi
528 movb %dh, %cl
529 shrl $16, %eax
530 movl 0x100+des_SPtrans(%ebx),%ebp
531 xorl %ebp, %edi
532 movb %ah, %bl
533 shrl $16, %edx
534 movl 0x300+des_SPtrans(%ecx),%ebp
535 xorl %ebp, %edi
536 movl 28(%esp), %ebp
537 movb %dh, %cl
538 andl $0xff, %eax
539 andl $0xff, %edx
540 movl 0x600+des_SPtrans(%ebx),%ebx
541 xorl %ebx, %edi
542 movl 0x700+des_SPtrans(%ecx),%ebx
543 xorl %ebx, %edi
544 movl 0x400+des_SPtrans(%eax),%ebx
545 xorl %ebx, %edi
546 movl 0x500+des_SPtrans(%edx),%ebx
547 xorl %ebx, %edi
548
549 /* Round 9 */
550 movl 32(%esp), %eax
551 movl %edi, %edx
552 shrl $16, %edx
553 movl 36(%esp), %ecx
554 xorl %edi, %edx
555 andl %edx, %eax
556 andl %ecx, %edx
557 movl %eax, %ebx
558 sall $16, %ebx
559 movl %edx, %ecx
560 sall $16, %ecx
561 xorl %ebx, %eax
562 xorl %ecx, %edx
563 movl 72(%ebp), %ebx
564 xorl %ebx, %eax
565 movl 76(%ebp), %ecx
566 xorl %edi, %eax
567 xorl %edi, %edx
568 xorl %ecx, %edx
569 andl $0xfcfcfcfc, %eax
570 xorl %ebx, %ebx
571 andl $0xcfcfcfcf, %edx
572 xorl %ecx, %ecx
573 movb %al, %bl
574 movb %ah, %cl
575 rorl $4, %edx
576 movl des_SPtrans(%ebx),%ebp
577 movb %dl, %bl
578 xorl %ebp, %esi
579 movl 0x200+des_SPtrans(%ecx),%ebp
580 xorl %ebp, %esi
581 movb %dh, %cl
582 shrl $16, %eax
583 movl 0x100+des_SPtrans(%ebx),%ebp
584 xorl %ebp, %esi
585 movb %ah, %bl
586 shrl $16, %edx
587 movl 0x300+des_SPtrans(%ecx),%ebp
588 xorl %ebp, %esi
589 movl 28(%esp), %ebp
590 movb %dh, %cl
591 andl $0xff, %eax
592 andl $0xff, %edx
593 movl 0x600+des_SPtrans(%ebx),%ebx
594 xorl %ebx, %esi
595 movl 0x700+des_SPtrans(%ecx),%ebx
596 xorl %ebx, %esi
597 movl 0x400+des_SPtrans(%eax),%ebx
598 xorl %ebx, %esi
599 movl 0x500+des_SPtrans(%edx),%ebx
600 xorl %ebx, %esi
601
602 /* Round 10 */
603 movl 32(%esp), %eax
604 movl %esi, %edx
605 shrl $16, %edx
606 movl 36(%esp), %ecx
607 xorl %esi, %edx
608 andl %edx, %eax
609 andl %ecx, %edx
610 movl %eax, %ebx
611 sall $16, %ebx
612 movl %edx, %ecx
613 sall $16, %ecx
614 xorl %ebx, %eax
615 xorl %ecx, %edx
616 movl 80(%ebp), %ebx
617 xorl %ebx, %eax
618 movl 84(%ebp), %ecx
619 xorl %esi, %eax
620 xorl %esi, %edx
621 xorl %ecx, %edx
622 andl $0xfcfcfcfc, %eax
623 xorl %ebx, %ebx
624 andl $0xcfcfcfcf, %edx
625 xorl %ecx, %ecx
626 movb %al, %bl
627 movb %ah, %cl
628 rorl $4, %edx
629 movl des_SPtrans(%ebx),%ebp
630 movb %dl, %bl
631 xorl %ebp, %edi
632 movl 0x200+des_SPtrans(%ecx),%ebp
633 xorl %ebp, %edi
634 movb %dh, %cl
635 shrl $16, %eax
636 movl 0x100+des_SPtrans(%ebx),%ebp
637 xorl %ebp, %edi
638 movb %ah, %bl
639 shrl $16, %edx
640 movl 0x300+des_SPtrans(%ecx),%ebp
641 xorl %ebp, %edi
642 movl 28(%esp), %ebp
643 movb %dh, %cl
644 andl $0xff, %eax
645 andl $0xff, %edx
646 movl 0x600+des_SPtrans(%ebx),%ebx
647 xorl %ebx, %edi
648 movl 0x700+des_SPtrans(%ecx),%ebx
649 xorl %ebx, %edi
650 movl 0x400+des_SPtrans(%eax),%ebx
651 xorl %ebx, %edi
652 movl 0x500+des_SPtrans(%edx),%ebx
653 xorl %ebx, %edi
654
655 /* Round 11 */
656 movl 32(%esp), %eax
657 movl %edi, %edx
658 shrl $16, %edx
659 movl 36(%esp), %ecx
660 xorl %edi, %edx
661 andl %edx, %eax
662 andl %ecx, %edx
663 movl %eax, %ebx
664 sall $16, %ebx
665 movl %edx, %ecx
666 sall $16, %ecx
667 xorl %ebx, %eax
668 xorl %ecx, %edx
669 movl 88(%ebp), %ebx
670 xorl %ebx, %eax
671 movl 92(%ebp), %ecx
672 xorl %edi, %eax
673 xorl %edi, %edx
674 xorl %ecx, %edx
675 andl $0xfcfcfcfc, %eax
676 xorl %ebx, %ebx
677 andl $0xcfcfcfcf, %edx
678 xorl %ecx, %ecx
679 movb %al, %bl
680 movb %ah, %cl
681 rorl $4, %edx
682 movl des_SPtrans(%ebx),%ebp
683 movb %dl, %bl
684 xorl %ebp, %esi
685 movl 0x200+des_SPtrans(%ecx),%ebp
686 xorl %ebp, %esi
687 movb %dh, %cl
688 shrl $16, %eax
689 movl 0x100+des_SPtrans(%ebx),%ebp
690 xorl %ebp, %esi
691 movb %ah, %bl
692 shrl $16, %edx
693 movl 0x300+des_SPtrans(%ecx),%ebp
694 xorl %ebp, %esi
695 movl 28(%esp), %ebp
696 movb %dh, %cl
697 andl $0xff, %eax
698 andl $0xff, %edx
699 movl 0x600+des_SPtrans(%ebx),%ebx
700 xorl %ebx, %esi
701 movl 0x700+des_SPtrans(%ecx),%ebx
702 xorl %ebx, %esi
703 movl 0x400+des_SPtrans(%eax),%ebx
704 xorl %ebx, %esi
705 movl 0x500+des_SPtrans(%edx),%ebx
706 xorl %ebx, %esi
707
708 /* Round 12 */
709 movl 32(%esp), %eax
710 movl %esi, %edx
711 shrl $16, %edx
712 movl 36(%esp), %ecx
713 xorl %esi, %edx
714 andl %edx, %eax
715 andl %ecx, %edx
716 movl %eax, %ebx
717 sall $16, %ebx
718 movl %edx, %ecx
719 sall $16, %ecx
720 xorl %ebx, %eax
721 xorl %ecx, %edx
722 movl 96(%ebp), %ebx
723 xorl %ebx, %eax
724 movl 100(%ebp), %ecx
725 xorl %esi, %eax
726 xorl %esi, %edx
727 xorl %ecx, %edx
728 andl $0xfcfcfcfc, %eax
729 xorl %ebx, %ebx
730 andl $0xcfcfcfcf, %edx
731 xorl %ecx, %ecx
732 movb %al, %bl
733 movb %ah, %cl
734 rorl $4, %edx
735 movl des_SPtrans(%ebx),%ebp
736 movb %dl, %bl
737 xorl %ebp, %edi
738 movl 0x200+des_SPtrans(%ecx),%ebp
739 xorl %ebp, %edi
740 movb %dh, %cl
741 shrl $16, %eax
742 movl 0x100+des_SPtrans(%ebx),%ebp
743 xorl %ebp, %edi
744 movb %ah, %bl
745 shrl $16, %edx
746 movl 0x300+des_SPtrans(%ecx),%ebp
747 xorl %ebp, %edi
748 movl 28(%esp), %ebp
749 movb %dh, %cl
750 andl $0xff, %eax
751 andl $0xff, %edx
752 movl 0x600+des_SPtrans(%ebx),%ebx
753 xorl %ebx, %edi
754 movl 0x700+des_SPtrans(%ecx),%ebx
755 xorl %ebx, %edi
756 movl 0x400+des_SPtrans(%eax),%ebx
757 xorl %ebx, %edi
758 movl 0x500+des_SPtrans(%edx),%ebx
759 xorl %ebx, %edi
760
761 /* Round 13 */
762 movl 32(%esp), %eax
763 movl %edi, %edx
764 shrl $16, %edx
765 movl 36(%esp), %ecx
766 xorl %edi, %edx
767 andl %edx, %eax
768 andl %ecx, %edx
769 movl %eax, %ebx
770 sall $16, %ebx
771 movl %edx, %ecx
772 sall $16, %ecx
773 xorl %ebx, %eax
774 xorl %ecx, %edx
775 movl 104(%ebp), %ebx
776 xorl %ebx, %eax
777 movl 108(%ebp), %ecx
778 xorl %edi, %eax
779 xorl %edi, %edx
780 xorl %ecx, %edx
781 andl $0xfcfcfcfc, %eax
782 xorl %ebx, %ebx
783 andl $0xcfcfcfcf, %edx
784 xorl %ecx, %ecx
785 movb %al, %bl
786 movb %ah, %cl
787 rorl $4, %edx
788 movl des_SPtrans(%ebx),%ebp
789 movb %dl, %bl
790 xorl %ebp, %esi
791 movl 0x200+des_SPtrans(%ecx),%ebp
792 xorl %ebp, %esi
793 movb %dh, %cl
794 shrl $16, %eax
795 movl 0x100+des_SPtrans(%ebx),%ebp
796 xorl %ebp, %esi
797 movb %ah, %bl
798 shrl $16, %edx
799 movl 0x300+des_SPtrans(%ecx),%ebp
800 xorl %ebp, %esi
801 movl 28(%esp), %ebp
802 movb %dh, %cl
803 andl $0xff, %eax
804 andl $0xff, %edx
805 movl 0x600+des_SPtrans(%ebx),%ebx
806 xorl %ebx, %esi
807 movl 0x700+des_SPtrans(%ecx),%ebx
808 xorl %ebx, %esi
809 movl 0x400+des_SPtrans(%eax),%ebx
810 xorl %ebx, %esi
811 movl 0x500+des_SPtrans(%edx),%ebx
812 xorl %ebx, %esi
813
814 /* Round 14 */
815 movl 32(%esp), %eax
816 movl %esi, %edx
817 shrl $16, %edx
818 movl 36(%esp), %ecx
819 xorl %esi, %edx
820 andl %edx, %eax
821 andl %ecx, %edx
822 movl %eax, %ebx
823 sall $16, %ebx
824 movl %edx, %ecx
825 sall $16, %ecx
826 xorl %ebx, %eax
827 xorl %ecx, %edx
828 movl 112(%ebp), %ebx
829 xorl %ebx, %eax
830 movl 116(%ebp), %ecx
831 xorl %esi, %eax
832 xorl %esi, %edx
833 xorl %ecx, %edx
834 andl $0xfcfcfcfc, %eax
835 xorl %ebx, %ebx
836 andl $0xcfcfcfcf, %edx
837 xorl %ecx, %ecx
838 movb %al, %bl
839 movb %ah, %cl
840 rorl $4, %edx
841 movl des_SPtrans(%ebx),%ebp
842 movb %dl, %bl
843 xorl %ebp, %edi
844 movl 0x200+des_SPtrans(%ecx),%ebp
845 xorl %ebp, %edi
846 movb %dh, %cl
847 shrl $16, %eax
848 movl 0x100+des_SPtrans(%ebx),%ebp
849 xorl %ebp, %edi
850 movb %ah, %bl
851 shrl $16, %edx
852 movl 0x300+des_SPtrans(%ecx),%ebp
853 xorl %ebp, %edi
854 movl 28(%esp), %ebp
855 movb %dh, %cl
856 andl $0xff, %eax
857 andl $0xff, %edx
858 movl 0x600+des_SPtrans(%ebx),%ebx
859 xorl %ebx, %edi
860 movl 0x700+des_SPtrans(%ecx),%ebx
861 xorl %ebx, %edi
862 movl 0x400+des_SPtrans(%eax),%ebx
863 xorl %ebx, %edi
864 movl 0x500+des_SPtrans(%edx),%ebx
865 xorl %ebx, %edi
866
867 /* Round 15 */
868 movl 32(%esp), %eax
869 movl %edi, %edx
870 shrl $16, %edx
871 movl 36(%esp), %ecx
872 xorl %edi, %edx
873 andl %edx, %eax
874 andl %ecx, %edx
875 movl %eax, %ebx
876 sall $16, %ebx
877 movl %edx, %ecx
878 sall $16, %ecx
879 xorl %ebx, %eax
880 xorl %ecx, %edx
881 movl 120(%ebp), %ebx
882 xorl %ebx, %eax
883 movl 124(%ebp), %ecx
884 xorl %edi, %eax
885 xorl %edi, %edx
886 xorl %ecx, %edx
887 andl $0xfcfcfcfc, %eax
888 xorl %ebx, %ebx
889 andl $0xcfcfcfcf, %edx
890 xorl %ecx, %ecx
891 movb %al, %bl
892 movb %ah, %cl
893 rorl $4, %edx
894 movl des_SPtrans(%ebx),%ebp
895 movb %dl, %bl
896 xorl %ebp, %esi
897 movl 0x200+des_SPtrans(%ecx),%ebp
898 xorl %ebp, %esi
899 movb %dh, %cl
900 shrl $16, %eax
901 movl 0x100+des_SPtrans(%ebx),%ebp
902 xorl %ebp, %esi
903 movb %ah, %bl
904 shrl $16, %edx
905 movl 0x300+des_SPtrans(%ecx),%ebp
906 xorl %ebp, %esi
907 movl 28(%esp), %ebp
908 movb %dh, %cl
909 andl $0xff, %eax
910 andl $0xff, %edx
911 movl 0x600+des_SPtrans(%ebx),%ebx
912 xorl %ebx, %esi
913 movl 0x700+des_SPtrans(%ecx),%ebx
914 xorl %ebx, %esi
915 movl 0x400+des_SPtrans(%eax),%ebx
916 xorl %ebx, %esi
917 movl 0x500+des_SPtrans(%edx),%ebx
918 xorl %ebx, %esi
919 movl (%esp), %ebx
920 movl %edi, %eax
921 decl %ebx
922 movl %esi, %edi
923 movl %eax, %esi
924 movl %ebx, (%esp)
925 jnz .L000start
926
927 /* FP */
928 movl 24(%esp), %edx
929.byte 209
930.byte 207 /* rorl $1 %edi */
931 movl %esi, %eax
932 xorl %edi, %esi
933 andl $0xaaaaaaaa, %esi
934 xorl %esi, %eax
935 xorl %esi, %edi
936
937 roll $23, %eax
938 movl %eax, %esi
939 xorl %edi, %eax
940 andl $0x03fc03fc, %eax
941 xorl %eax, %esi
942 xorl %eax, %edi
943
944 roll $10, %esi
945 movl %esi, %eax
946 xorl %edi, %esi
947 andl $0x33333333, %esi
948 xorl %esi, %eax
949 xorl %esi, %edi
950
951 roll $18, %edi
952 movl %edi, %esi
953 xorl %eax, %edi
954 andl $0xfff0000f, %edi
955 xorl %edi, %esi
956 xorl %edi, %eax
957
958 roll $12, %esi
959 movl %esi, %edi
960 xorl %eax, %esi
961 andl $0xf0f0f0f0, %esi
962 xorl %esi, %edi
963 xorl %esi, %eax
964
965 rorl $4, %eax
966 movl %eax, (%edx)
967 movl %edi, 4(%edx)
968 popl %ecx
969 popl %edi
970 popl %esi
971 popl %ebx
972 popl %ebp
973 ret
974.fcrypt_body_end:
975 SIZE(fcrypt_body,.fcrypt_body_end-fcrypt_body)
976.ident "fcrypt_body"
diff --git a/src/lib/libcrypto/des/cbc3_enc.c b/src/lib/libcrypto/des/cbc3_enc.c
index 92a78b05d6..3863a676d4 100644
--- a/src/lib/libcrypto/des/cbc3_enc.c
+++ b/src/lib/libcrypto/des/cbc3_enc.c
@@ -59,15 +59,9 @@
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61/* HAS BUGS? DON'T USE - this is only present for use in des.c */ 61/* HAS BUGS? DON'T USE - this is only present for use in des.c */
62void des_3cbc_encrypt(input, output, length, ks1, ks2, iv1, iv2, enc) 62void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
63des_cblock (*input); 63 des_key_schedule ks1, des_key_schedule ks2, des_cblock *iv1,
64des_cblock (*output); 64 des_cblock *iv2, int enc)
65long length;
66des_key_schedule ks1;
67des_key_schedule ks2;
68des_cblock (*iv1);
69des_cblock (*iv2);
70int enc;
71 { 65 {
72 int off=((int)length-1)/8; 66 int off=((int)length-1)/8;
73 long l8=((length+7)/8)*8; 67 long l8=((length+7)/8)*8;
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c
index edfdec8a0f..1e543cb2a1 100644
--- a/src/lib/libcrypto/des/cbc_cksm.c
+++ b/src/lib/libcrypto/des/cbc_cksm.c
@@ -58,21 +58,15 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61DES_LONG des_cbc_cksum(input, output, length, schedule, ivec) 61DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,
62des_cblock (*input); 62 long length,
63des_cblock (*output); 63 des_key_schedule schedule, const_des_cblock *ivec)
64long length;
65des_key_schedule schedule;
66des_cblock (*ivec);
67 { 64 {
68 register DES_LONG tout0,tout1,tin0,tin1; 65 register DES_LONG tout0,tout1,tin0,tin1;
69 register long l=length; 66 register long l=length;
70 DES_LONG tin[2]; 67 DES_LONG tin[2];
71 unsigned char *in,*out,*iv; 68 unsigned char *out = &(*output)[0];
72 69 const unsigned char *iv = &(*ivec)[0];
73 in=(unsigned char *)input;
74 out=(unsigned char *)output;
75 iv=(unsigned char *)ivec;
76 70
77 c2l(iv,tout0); 71 c2l(iv,tout0);
78 c2l(iv,tout1); 72 c2l(iv,tout1);
diff --git a/src/lib/libcrypto/des/cbc_enc.c b/src/lib/libcrypto/des/cbc_enc.c
index a84a53633c..677903ae4e 100644
--- a/src/lib/libcrypto/des/cbc_enc.c
+++ b/src/lib/libcrypto/des/cbc_enc.c
@@ -56,80 +56,6 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "des_locl.h" 59#define CBC_ENC_C__DONT_UPDATE_IV
60
61void des_cbc_encrypt(input, output, length, schedule, ivec, enc)
62des_cblock (*input);
63des_cblock (*output);
64long length;
65des_key_schedule schedule;
66des_cblock (*ivec);
67int enc;
68 {
69 register DES_LONG tin0,tin1;
70 register DES_LONG tout0,tout1,xor0,xor1;
71 register unsigned char *in,*out;
72 register long l=length;
73 DES_LONG tin[2];
74 unsigned char *iv;
75
76 in=(unsigned char *)input;
77 out=(unsigned char *)output;
78 iv=(unsigned char *)ivec;
79
80 if (enc)
81 {
82 c2l(iv,tout0);
83 c2l(iv,tout1);
84 for (l-=8; l>=0; l-=8)
85 {
86 c2l(in,tin0);
87 c2l(in,tin1);
88 tin0^=tout0; tin[0]=tin0;
89 tin1^=tout1; tin[1]=tin1;
90 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
91 tout0=tin[0]; l2c(tout0,out);
92 tout1=tin[1]; l2c(tout1,out);
93 }
94 if (l != -8)
95 {
96 c2ln(in,tin0,tin1,l+8);
97 tin0^=tout0; tin[0]=tin0;
98 tin1^=tout1; tin[1]=tin1;
99 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
100 tout0=tin[0]; l2c(tout0,out);
101 tout1=tin[1]; l2c(tout1,out);
102 }
103 }
104 else
105 {
106 c2l(iv,xor0);
107 c2l(iv,xor1);
108 for (l-=8; l>=0; l-=8)
109 {
110 c2l(in,tin0); tin[0]=tin0;
111 c2l(in,tin1); tin[1]=tin1;
112 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
113 tout0=tin[0]^xor0;
114 tout1=tin[1]^xor1;
115 l2c(tout0,out);
116 l2c(tout1,out);
117 xor0=tin0;
118 xor1=tin1;
119 }
120 if (l != -8)
121 {
122 c2l(in,tin0); tin[0]=tin0;
123 c2l(in,tin1); tin[1]=tin1;
124 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
125 tout0=tin[0]^xor0;
126 tout1=tin[1]^xor1;
127 l2cn(tout0,tout1,out,l+8);
128 /* xor0=tin0;
129 xor1=tin1; */
130 }
131 }
132 tin0=tin1=tout0=tout1=xor0=xor1=0;
133 tin[0]=tin[1]=0;
134 }
135 60
61#include "ncbc_enc.c" /* des_cbc_encrypt */
diff --git a/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c
index 80b8a9eaaa..5362a551bf 100644
--- a/src/lib/libcrypto/des/cfb64ede.c
+++ b/src/lib/libcrypto/des/cfb64ede.c
@@ -63,14 +63,9 @@
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65 65
66void des_ede3_cfb64_encrypt(in, out, length, ks1,ks2,ks3, ivec, num, enc) 66void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
67unsigned char *in; 67 long length, des_key_schedule ks1, des_key_schedule ks2,
68unsigned char *out; 68 des_key_schedule ks3, des_cblock *ivec, int *num, int enc)
69long length;
70des_key_schedule ks1,ks2,ks3;
71des_cblock (*ivec);
72int *num;
73int enc;
74 { 69 {
75 register DES_LONG v0,v1; 70 register DES_LONG v0,v1;
76 register long l=length; 71 register long l=length;
@@ -78,7 +73,7 @@ int enc;
78 DES_LONG ti[2]; 73 DES_LONG ti[2];
79 unsigned char *iv,c,cc; 74 unsigned char *iv,c,cc;
80 75
81 iv=(unsigned char *)ivec; 76 iv=&(*ivec)[0];
82 if (enc) 77 if (enc)
83 { 78 {
84 while (l--) 79 while (l--)
@@ -90,14 +85,14 @@ int enc;
90 85
91 ti[0]=v0; 86 ti[0]=v0;
92 ti[1]=v1; 87 ti[1]=v1;
93 des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3); 88 des_encrypt3(ti,ks1,ks2,ks3);
94 v0=ti[0]; 89 v0=ti[0];
95 v1=ti[1]; 90 v1=ti[1];
96 91
97 iv=(unsigned char *)ivec; 92 iv = &(*ivec)[0];
98 l2c(v0,iv); 93 l2c(v0,iv);
99 l2c(v1,iv); 94 l2c(v1,iv);
100 iv=(unsigned char *)ivec; 95 iv = &(*ivec)[0];
101 } 96 }
102 c= *(in++)^iv[n]; 97 c= *(in++)^iv[n];
103 *(out++)=c; 98 *(out++)=c;
@@ -116,14 +111,14 @@ int enc;
116 111
117 ti[0]=v0; 112 ti[0]=v0;
118 ti[1]=v1; 113 ti[1]=v1;
119 des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3); 114 des_encrypt3(ti,ks1,ks2,ks3);
120 v0=ti[0]; 115 v0=ti[0];
121 v1=ti[1]; 116 v1=ti[1];
122 117
123 iv=(unsigned char *)ivec; 118 iv = &(*ivec)[0];
124 l2c(v0,iv); 119 l2c(v0,iv);
125 l2c(v1,iv); 120 l2c(v1,iv);
126 iv=(unsigned char *)ivec; 121 iv = &(*ivec)[0];
127 } 122 }
128 cc= *(in++); 123 cc= *(in++);
129 c=iv[n]; 124 c=iv[n];
@@ -137,14 +132,9 @@ int enc;
137 } 132 }
138 133
139#ifdef undef /* MACRO */ 134#ifdef undef /* MACRO */
140void des_ede2_cfb64_encrypt(in, out, length, ks1,ks2, ivec, num, enc) 135void des_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
141unsigned char *in; 136 des_key_schedule ks1, des_key_schedule ks2, des_cblock (*ivec),
142unsigned char *out; 137 int *num, int enc)
143long length;
144des_key_schedule ks1,ks2;
145des_cblock (*ivec);
146int *num;
147int enc;
148 { 138 {
149 des_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); 139 des_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc);
150 } 140 }
diff --git a/src/lib/libcrypto/des/cfb64enc.c b/src/lib/libcrypto/des/cfb64enc.c
index 403da479df..389a232cb3 100644
--- a/src/lib/libcrypto/des/cfb64enc.c
+++ b/src/lib/libcrypto/des/cfb64enc.c
@@ -63,14 +63,9 @@
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65 65
66void des_cfb64_encrypt(in, out, length, schedule, ivec, num, enc) 66void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
67unsigned char *in; 67 long length, des_key_schedule schedule, des_cblock *ivec,
68unsigned char *out; 68 int *num, int enc)
69long length;
70des_key_schedule schedule;
71des_cblock (*ivec);
72int *num;
73int enc;
74 { 69 {
75 register DES_LONG v0,v1; 70 register DES_LONG v0,v1;
76 register long l=length; 71 register long l=length;
@@ -78,7 +73,7 @@ int enc;
78 DES_LONG ti[2]; 73 DES_LONG ti[2];
79 unsigned char *iv,c,cc; 74 unsigned char *iv,c,cc;
80 75
81 iv=(unsigned char *)ivec; 76 iv = &(*ivec)[0];
82 if (enc) 77 if (enc)
83 { 78 {
84 while (l--) 79 while (l--)
@@ -87,12 +82,11 @@ int enc;
87 { 82 {
88 c2l(iv,v0); ti[0]=v0; 83 c2l(iv,v0); ti[0]=v0;
89 c2l(iv,v1); ti[1]=v1; 84 c2l(iv,v1); ti[1]=v1;
90 des_encrypt((DES_LONG *)ti, 85 des_encrypt(ti,schedule,DES_ENCRYPT);
91 schedule,DES_ENCRYPT); 86 iv = &(*ivec)[0];
92 iv=(unsigned char *)ivec;
93 v0=ti[0]; l2c(v0,iv); 87 v0=ti[0]; l2c(v0,iv);
94 v0=ti[1]; l2c(v0,iv); 88 v0=ti[1]; l2c(v0,iv);
95 iv=(unsigned char *)ivec; 89 iv = &(*ivec)[0];
96 } 90 }
97 c= *(in++)^iv[n]; 91 c= *(in++)^iv[n];
98 *(out++)=c; 92 *(out++)=c;
@@ -108,12 +102,11 @@ int enc;
108 { 102 {
109 c2l(iv,v0); ti[0]=v0; 103 c2l(iv,v0); ti[0]=v0;
110 c2l(iv,v1); ti[1]=v1; 104 c2l(iv,v1); ti[1]=v1;
111 des_encrypt((DES_LONG *)ti, 105 des_encrypt(ti,schedule,DES_ENCRYPT);
112 schedule,DES_ENCRYPT); 106 iv = &(*ivec)[0];
113 iv=(unsigned char *)ivec;
114 v0=ti[0]; l2c(v0,iv); 107 v0=ti[0]; l2c(v0,iv);
115 v0=ti[1]; l2c(v0,iv); 108 v0=ti[1]; l2c(v0,iv);
116 iv=(unsigned char *)ivec; 109 iv = &(*ivec)[0];
117 } 110 }
118 cc= *(in++); 111 cc= *(in++);
119 c=iv[n]; 112 c=iv[n];
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c
index 342e785691..cca34dd7c5 100644
--- a/src/lib/libcrypto/des/cfb_enc.c
+++ b/src/lib/libcrypto/des/cfb_enc.c
@@ -64,14 +64,8 @@
64 * the second. The second 12 bits will come from the 3rd and half the 4th 64 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte. 65 * byte.
66 */ 66 */
67void des_cfb_encrypt(in, out, numbits, length, schedule, ivec, enc) 67void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
68unsigned char *in; 68 long length, des_key_schedule schedule, des_cblock *ivec, int enc)
69unsigned char *out;
70int numbits;
71long length;
72des_key_schedule schedule;
73des_cblock (*ivec);
74int enc;
75 { 69 {
76 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; 70 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
77 register DES_LONG mask0,mask1; 71 register DES_LONG mask0,mask1;
@@ -96,7 +90,7 @@ int enc;
96 mask1=0x00000000L; 90 mask1=0x00000000L;
97 } 91 }
98 92
99 iv=(unsigned char *)ivec; 93 iv = &(*ivec)[0];
100 c2l(iv,v0); 94 c2l(iv,v0);
101 c2l(iv,v1); 95 c2l(iv,v1);
102 if (enc) 96 if (enc)
@@ -163,7 +157,7 @@ int enc;
163 out+=n; 157 out+=n;
164 } 158 }
165 } 159 }
166 iv=(unsigned char *)ivec; 160 iv = &(*ivec)[0];
167 l2c(v0,iv); 161 l2c(v0,iv);
168 l2c(v1,iv); 162 l2c(v1,iv);
169 v0=v1=d0=d1=ti[0]=ti[1]=0; 163 v0=v1=d0=d1=ti[0]=ti[1]=0;
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com
new file mode 100644
index 0000000000..2aea7a0dea
--- /dev/null
+++ b/src/lib/libcrypto/des/des-lib.com
@@ -0,0 +1,1003 @@
1$!
2$! DES-LIB.COM
3$! Written By: Robert Byer
4$! Vice-President
5$! A-Com Computing, Inc.
6$! byer@mail.all-net.net
7$!
8$! Changes by Richard Levitte <richard@levitte.org>
9$!
10$! This command files compiles and creates the
11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine
12$! architecture of AXP or VAX.
13$!
14$! It was re-written to try to determine which "C" compiler to try to use
15$! or the user can specify a compiler in P3.
16$!
17$! Specify one of the following to build just that part, specify "ALL" to
18$! just build everything.
19$!
20$! ALL To Just Build "Everything".
21$! LIBRARY To Just Build The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library.
22$! DESTEST To Just Build The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program.
23$! SPEED To Just Build The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program.
24$! RPW To Just Build The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program.
25$! DES To Just Build The [.xxx.EXE.CRYPTO.DES]DES.EXE Program.
26$! DES_OPTS To Just Build The [.xxx.EXE.CRYPTO.DES]DES_OPTS.EXE Program.
27$!
28$! Specify either DEBUG or NODEBUG as P2 to compile with or without
29$! debugging information.
30$!
31$! Specify which compiler at P3 to try to compile under.
32$!
33$! VAXC For VAX C.
34$! DECC For DEC C.
35$! GNUC For GNU C.
36$!
37$! If you don't speficy a compiler, it will try to determine which
38$! "C" compiler to try to use.
39$!
40$! P4, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
41$!
42$!
43$! Make sure we know what architecture we run on.
44$!
45$!
46$! Check Which Architecture We Are Using.
47$!
48$ IF (F$GETSYI("CPU").GE.128)
49$ THEN
50$!
51$! The Architecture Is AXP.
52$!
53$ ARCH := AXP
54$!
55$! Else...
56$!
57$ ELSE
58$!
59$! The Architecture Is VAX.
60$!
61$ ARCH := VAX
62$!
63$! End The Architecture Check.
64$!
65$ ENDIF
66$!
67$! Check To Make Sure We Have Valid Command Line Parameters.
68$!
69$ GOSUB CHECK_OPTIONS
70$!
71$! Tell The User What Kind of Machine We Run On.
72$!
73$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
74$!
75$! Define The OBJ Directory Name.
76$!
77$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES]
78$!
79$! Check To See If The Architecture Specific OBJ Directory Exists.
80$!
81$ IF (F$PARSE(OBJ_DIR).EQS."")
82$ THEN
83$!
84$! It Dosen't Exist, So Create It.
85$!
86$ CREATE/DIR 'OBJ_DIR'
87$!
88$! End The Architecture Specific OBJ Directory Check.
89$!
90$ ENDIF
91$!
92$! Define The EXE Directory Name.
93$!
94$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES]
95$!
96$! Check To See If The Architecture Specific Directory Exists.
97$!
98$ IF (F$PARSE(EXE_DIR).EQS."")
99$ THEN
100$!
101$! It Dosen't Exist, So Create It.
102$!
103$ CREATE/DIR 'EXE_DIR'
104$!
105$! End The Architecture Specific Directory Check.
106$!
107$ ENDIF
108$!
109$! Define The Library Name.
110$!
111$ LIB_NAME := 'EXE_DIR'LIBDES.OLB
112$!
113$! Check To See What We Are To Do.
114$!
115$ IF (BUILDALL.EQS."TRUE")
116$ THEN
117$!
118$! Since Nothing Special Was Specified, Do Everything.
119$!
120$ GOSUB LIBRARY
121$ GOSUB DESTEST
122$ GOSUB SPEED
123$ GOSUB RPW
124$ GOSUB DES
125$ GOSUB DES_OPTS
126$!
127$! Else...
128$!
129$ ELSE
130$!
131$! Build Just What The User Wants Us To Build.
132$!
133$ GOSUB 'BUILDALL'
134$!
135$! End The BUILDALL Check.
136$!
137$ ENDIF
138$!
139$! Time To EXIT.
140$!
141$ EXIT
142$ LIBRARY:
143$!
144$! Tell The User That We Are Compiling.
145$!
146$ WRITE SYS$OUTPUT "Compiling The ",LIB_NAME," Files."
147$!
148$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" Library...
149$!
150$ IF (F$SEARCH(LIB_NAME).EQS."")
151$ THEN
152$!
153$! Guess Not, Create The Library.
154$!
155$ LIBRARY/CREATE/OBJECT 'LIB_NAME'
156$!
157$! End The Library Exist Check.
158$!
159$ ENDIF
160$!
161$! Define The DES Library Files.
162$!
163$ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
164 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
165 "enc_read,enc_writ,ofb64enc,"+ -
166 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
167 "des_enc,fcrypt_b,read2pwd,"+ -
168 "fcrypt,xcbc_enc,read_pwd,rpc_enc,cbc_cksm,supp"
169$!
170$! Define A File Counter And Set It To "0".
171$!
172$ FILE_COUNTER = 0
173$!
174$! Top Of The File Loop.
175$!
176$ NEXT_FILE:
177$!
178$! O.K, Extract The File Name From The File List.
179$!
180$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",LIB_DES)
181$!
182$! Check To See If We Are At The End Of The File List.
183$!
184$ IF (FILE_NAME.EQS.",") THEN GOTO FILE_DONE
185$!
186$! Increment The Counter.
187$!
188$ FILE_COUNTER = FILE_COUNTER + 1
189$!
190$! Create The Source File Name.
191$!
192$ SOURCE_FILE = "SYS$DISK:[]" + FILE_NAME + ".C"
193$!
194$! Tell The User We Are Compiling The Source File.
195$!
196$ WRITE SYS$OUTPUT " ",FILE_NAME,".C"
197$!
198$! Create The Object File Name.
199$!
200$ OBJECT_FILE = OBJ_DIR + FILE_NAME + "." + ARCH + "OBJ"
201$ ON WARNING THEN GOTO NEXT_FILE
202$!
203$! Check To See If The File We Want To Compile Actually Exists.
204$!
205$ IF (F$SEARCH(SOURCE_FILE).EQS."")
206$ THEN
207$!
208$! Tell The User That The File Dosen't Exist.
209$!
210$ WRITE SYS$OUTPUT ""
211$ WRITE SYS$OUTPUT "The File ",SOURCE_FILE," Dosen't Exist."
212$ WRITE SYS$OUTPUT ""
213$!
214$! Exit The Build.
215$!
216$ EXIT
217$!
218$! End The File Exists Check.
219$!
220$ ENDIF
221$!
222$! Compile The File.
223$!
224$ ON ERROR THEN GOTO NEXT_FILE
225$ CC/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
226$!
227$! Add It To The Library.
228$!
229$ LIBRARY/REPLACE/OBJECT 'LIB_NAME' 'OBJECT_FILE'
230$!
231$! Time To Clean Up The Object File.
232$!
233$ DELETE 'OBJECT_FILE';*
234$!
235$! Go Back And Do It Again.
236$!
237$ GOTO NEXT_FILE
238$!
239$! All Done With This Library Part.
240$!
241$ FILE_DONE:
242$!
243$! Tell The User That We Are All Done.
244$!
245$ WRITE SYS$OUTPUT "Library ",LIB_NAME," Built."
246$!
247$! All Done, Time To Return.
248$!
249$ RETURN
250$!
251$! Compile The DESTEST Program.
252$!
253$ DESTEST:
254$!
255$! Check To See If We Have The Proper Libraries.
256$!
257$ GOSUB LIB_CHECK
258$!
259$! Check To See If We Have A Linker Option File.
260$!
261$ GOSUB CHECK_OPT_FILE
262$!
263$! Check To See If The File We Want To Compile Actually Exists.
264$!
265$ IF (F$SEARCH("SYS$DISK:[]DESTEST.C").EQS."")
266$ THEN
267$!
268$! Tell The User That The File Dosen't Exist.
269$!
270$ WRITE SYS$OUTPUT ""
271$ WRITE SYS$OUTPUT "The File DESTEST.C Dosen't Exist."
272$ WRITE SYS$OUTPUT ""
273$!
274$! Exit The Build.
275$!
276$ EXIT
277$!
278$! End The DESTEST.C File Check.
279$!
280$ ENDIF
281$!
282$! Tell The User What We Are Building.
283$!
284$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DESTEST.EXE"
285$!
286$! Compile The DESTEST Program.
287$!
288$ CC/OBJECT='OBJ_DIR'DESTEST.OBJ SYS$DISK:[]DESTEST.C
289$!
290$! Link The DESTEST Program.
291$!
292$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DESTEST.EXE -
293 'OBJ_DIR'DESTEST.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
294$!
295$! All Done, Time To Return.
296$!
297$ RETURN
298$!
299$! Compile The SPEED Program.
300$!
301$ SPEED:
302$!
303$! Check To See If We Have The Proper Libraries.
304$!
305$ GOSUB LIB_CHECK
306$!
307$! Check To See If We Have A Linker Option File.
308$!
309$ GOSUB CHECK_OPT_FILE
310$!
311$! Check To See If The File We Want To Compile Actually Exists.
312$!
313$ IF (F$SEARCH("SYS$DISK:[]SPEED.C").EQS."")
314$ THEN
315$!
316$! Tell The User That The File Dosen't Exist.
317$!
318$ WRITE SYS$OUTPUT ""
319$ WRITE SYS$OUTPUT "The File SPEED.C Dosen't Exist."
320$ WRITE SYS$OUTPUT ""
321$!
322$! Exit The Build.
323$!
324$ EXIT
325$!
326$! End The SPEED.C File Check.
327$!
328$ ENDIF
329$!
330$! Tell The User What We Are Building.
331$!
332$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"SPEED.EXE"
333$!
334$! Compile The SPEED Program.
335$!
336$ CC/OBJECT='OBJ_DIR'SPEED.OBJ SYS$DISK:[]SPEED.C
337$!
338$! Link The SPEED Program.
339$!
340$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'SPEED.EXE -
341 'OBJ_DIR'SPEED.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
342$!
343$! All Done, Time To Return.
344$!
345$ RETURN
346$!
347$! Compile The RPW Program.
348$!
349$ RPW:
350$!
351$! Check To See If We Have The Proper Libraries.
352$!
353$ GOSUB LIB_CHECK
354$!
355$! Check To See If We Have A Linker Option File.
356$!
357$ GOSUB CHECK_OPT_FILE
358$!
359$! Check To See If The File We Want To Compile Actually Exists.
360$!
361$ IF (F$SEARCH("SYS$DISK:[]RPW.C").EQS."")
362$ THEN
363$!
364$! Tell The User That The File Dosen't Exist.
365$!
366$ WRITE SYS$OUTPUT ""
367$ WRITE SYS$OUTPUT "The File RPW.C Dosen't Exist."
368$ WRITE SYS$OUTPUT ""
369$!
370$! Exit The Build.
371$!
372$ EXIT
373$!
374$! End The RPW.C File Check.
375$!
376$ ENDIF
377$!
378$! Tell The User What We Are Building.
379$!
380$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"RPW.EXE"
381$!
382$! Compile The RPW Program.
383$!
384$ CC/OBJECT='OBJ_DIR'RPW.OBJ SYS$DISK:[]RPW.C
385$!
386$! Link The RPW Program.
387$!
388$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'RPW.EXE -
389 'OBJ_DIR'RPW.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
390$!
391$! All Done, Time To Return.
392$!
393$ RETURN
394$!
395$! Compile The DES Program.
396$!
397$ DES:
398$!
399$! Check To See If We Have The Proper Libraries.
400$!
401$ GOSUB LIB_CHECK
402$!
403$! Check To See If We Have A Linker Option File.
404$!
405$ GOSUB CHECK_OPT_FILE
406$!
407$! Check To See If The File We Want To Compile Actually Exists.
408$!
409$ IF (F$SEARCH("SYS$DISK:[]DES.C").EQS."")
410$ THEN
411$!
412$! Tell The User That The File Dosen't Exist.
413$!
414$ WRITE SYS$OUTPUT ""
415$ WRITE SYS$OUTPUT "The File DES.C Dosen't Exist."
416$ WRITE SYS$OUTPUT ""
417$!
418$! Exit The Build.
419$!
420$ EXIT
421$!
422$! End The DES.C File Check.
423$!
424$ ENDIF
425$!
426$! Tell The User What We Are Building.
427$!
428$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES.EXE"
429$!
430$! Compile The DES Program.
431$!
432$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]DES.C
433$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]CBC3_ENC.C
434$!
435$! Link The DES Program.
436$!
437$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES.EXE -
438 'OBJ_DIR'DES.OBJ,'OBJ_DIR'CBC3_ENC.OBJ,-
439 'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
440$!
441$! All Done, Time To Return.
442$!
443$ RETURN
444$!
445$! Compile The DES_OPTS Program.
446$!
447$ DES_OPTS:
448$!
449$! Check To See If We Have The Proper Libraries.
450$!
451$ GOSUB LIB_CHECK
452$!
453$! Check To See If We Have A Linker Option File.
454$!
455$ GOSUB CHECK_OPT_FILE
456$!
457$! Check To See If The File We Want To Compile Actually Exists.
458$!
459$ IF (F$SEARCH("SYS$DISK:[]DES_OPTS.C").EQS."")
460$ THEN
461$!
462$! Tell The User That The File Dosen't Exist.
463$!
464$ WRITE SYS$OUTPUT ""
465$ WRITE SYS$OUTPUT "The File DES_OPTS.C Dosen't Exist."
466$ WRITE SYS$OUTPUT ""
467$!
468$! Exit The Build.
469$!
470$ EXIT
471$!
472$! End The DES_OPTS.C File Check.
473$!
474$ ENDIF
475$!
476$! Tell The User What We Are Building.
477$!
478$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES_OPTS.EXE"
479$!
480$! Compile The DES_OPTS Program.
481$!
482$ CC/OBJECT='OBJ_DIR'DES_OPTS.OBJ SYS$DISK:[]DES_OPTS.C
483$!
484$! Link The DES_OPTS Program.
485$!
486$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES_OPTS.EXE -
487 'OBJ_DIR'DES_OPTS.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
488$!
489$! All Done, Time To Return.
490$!
491$ RETURN
492$ EXIT
493$!
494$! Check For The Link Option FIle.
495$!
496$ CHECK_OPT_FILE:
497$!
498$! Check To See If We Need To Make A VAX C Option File.
499$!
500$ IF (COMPILER.EQS."VAXC")
501$ THEN
502$!
503$! Check To See If We Already Have A VAX C Linker Option File.
504$!
505$ IF (F$SEARCH(OPT_FILE).EQS."")
506$ THEN
507$!
508$! We Need A VAX C Linker Option File.
509$!
510$ CREATE 'OPT_FILE'
511$DECK
512!
513! Default System Options File To Link Agianst
514! The Sharable VAX C Runtime Library.
515!
516SYS$SHARE:VAXCRTL.EXE/SHARE
517$EOD
518$!
519$! End The Option File Check.
520$!
521$ ENDIF
522$!
523$! End The VAXC Check.
524$!
525$ ENDIF
526$!
527$! Check To See If We Need A GNU C Option File.
528$!
529$ IF (COMPILER.EQS."GNUC")
530$ THEN
531$!
532$! Check To See If We Already Have A GNU C Linker Option File.
533$!
534$ IF (F$SEARCH(OPT_FILE).EQS."")
535$ THEN
536$!
537$! We Need A GNU C Linker Option File.
538$!
539$ CREATE 'OPT_FILE'
540$DECK
541!
542! Default System Options File To Link Agianst
543! The Sharable C Runtime Library.
544!
545GNU_CC:[000000]GCCLIB/LIBRARY
546SYS$SHARE:VAXCRTL/SHARE
547$EOD
548$!
549$! End The Option File Check.
550$!
551$ ENDIF
552$!
553$! End The GNU C Check.
554$!
555$ ENDIF
556$!
557$! Check To See If We Need A DEC C Option File.
558$!
559$ IF (COMPILER.EQS."DECC")
560$ THEN
561$!
562$! Check To See If We Already Have A DEC C Linker Option File.
563$!
564$ IF (F$SEARCH(OPT_FILE).EQS."")
565$ THEN
566$!
567$! Figure Out If We Need An AXP Or A VAX Linker Option File.
568$!
569$ IF (F$GETSYI("CPU").LT.128)
570$ THEN
571$!
572$! We Need A DEC C Linker Option File For VAX.
573$!
574$ CREATE 'OPT_FILE'
575$DECK
576!
577! Default System Options File To Link Agianst
578! The Sharable DEC C Runtime Library.
579!
580SYS$SHARE:DECC$SHR.EXE/SHARE
581$EOD
582$!
583$! Else...
584$!
585$ ELSE
586$!
587$! Create The AXP Linker Option File.
588$!
589$ CREATE 'OPT_FILE'
590$DECK
591!
592! Default System Options File For AXP To Link Agianst
593! The Sharable C Runtime Library.
594!
595SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
596SYS$SHARE:CMA$OPEN_RTL/SHARE
597$EOD
598$!
599$! End The VAX/AXP DEC C Option File Check.
600$!
601$ ENDIF
602$!
603$! End The Option File Search.
604$!
605$ ENDIF
606$!
607$! End The DEC C Check.
608$!
609$ ENDIF
610$!
611$! Tell The User What Linker Option File We Are Using.
612$!
613$ WRITE SYS$OUTPUT "Using Linker Option File ",OPT_FILE,"."
614$!
615$! Time To RETURN.
616$!
617$ RETURN
618$!
619$! Library Check.
620$!
621$ LIB_CHECK:
622$!
623$! Look For The Library LIBDES.OLB.
624$!
625$ IF (F$SEARCH(LIB_NAME).EQS."")
626$ THEN
627$!
628$! Tell The User We Can't Find The [.xxx.CRYPTO.DES]LIBDES.OLB Library.
629$!
630$ WRITE SYS$OUTPUT ""
631$ WRITE SYS$OUTPUT "Can't Find The Library ",LIB_NAME,"."
632$ WRITE SYS$OUTPUT "We Can't Link Without It."
633$ WRITE SYS$OUTPUT ""
634$!
635$! Since We Can't Link Without It, Exit.
636$!
637$ EXIT
638$ ENDIF
639$!
640$! Time To Return.
641$!
642$ RETURN
643$!
644$! Check The User's Options.
645$!
646$ CHECK_OPTIONS:
647$!
648$! Check To See If We Are To "Just Build Everything".
649$!
650$ IF (P1.EQS."ALL")
651$ THEN
652$!
653$! P1 Is "ALL", So Build Everything.
654$!
655$ BUILDALL = "TRUE"
656$!
657$! Else...
658$!
659$ ELSE
660$!
661$! Else, Check To See If P1 Has A Valid Arguement.
662$!
663$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."DESTEST").OR.(P1.EQS."SPEED") -
664 .OR.(P1.EQS."RPW").OR.(P1.EQS."DES").OR.(P1.EQS."DES_OPTS")
665$ THEN
666$!
667$! A Valid Arguement.
668$!
669$ BUILDALL = P1
670$!
671$! Else...
672$!
673$ ELSE
674$!
675$! Tell The User We Don't Know What They Want.
676$!
677$ WRITE SYS$OUTPUT ""
678$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
679$ WRITE SYS$OUTPUT ""
680$ WRITE SYS$OUTPUT " ALL : Just Build Everything.
681$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library."
682$ WRITE SYS$OUTPUT " DESTEST : To Compile Just The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program."
683$ WRITE SYS$OUTPUT " SPEED : To Compile Just The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program."
684$ WRITE SYS$OUTPUT " RPW : To Compile Just The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program."
685$ WRITE SYS$OUTPUT " DES : To Compile Just The [.xxx.EXE.CRYPTO.DES]DES.EXE Program."
686$ WRITE SYS$OUTPUT " DES_OPTS : To Compile Just The [.xxx.EXE.CRYTPO.DES]DES_OPTS.EXE Program."
687$ WRITE SYS$OUTPUT ""
688$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: "
689$ WRITE SYS$OUTPUT ""
690$ WRITE SYS$OUTPUT " AXP : Alpha Architecture."
691$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
692$ WRITE SYS$OUTPUT ""
693$!
694$! Time To EXIT.
695$!
696$ EXIT
697$!
698$! End The Valid Arguement Check.
699$!
700$ ENDIF
701$!
702$! End The P1 Check.
703$!
704$ ENDIF
705$!
706$! Check To See If We Are To Compile Without Debugger Information.
707$!
708$ IF (P2.EQS."NODEBUG")
709$ THEN
710$!
711$! P2 Is Blank, So Compile Without Debugger Information.
712$!
713$ DEBUGGER = "NODEBUG"
714$ TRACEBACK = "NOTRACEBACK"
715$ GCC_OPTIMIZE = "OPTIMIZE"
716$ CC_OPTIMIZE = "OPTIMIZE"
717$ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
718$ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
719$!
720$! Else...
721$!
722$ ELSE
723$!
724$! Check To See If We Are To Compile With Debugger Information.
725$!
726$ IF (P2.EQS."DEBUG")
727$ THEN
728$!
729$! Compile With Debugger Information.
730$!
731$ DEBUGGER = "DEBUG"
732$ TRACEBACK = "TRACEBACK"
733$ GCC_OPTIMIZE = "NOOPTIMIZE"
734$ CC_OPTIMIZE = "NOOPTIMIZE"
735$ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
736$ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
737$!
738$! Else...
739$!
740$ ELSE
741$!
742$! Tell The User Entered An Invalid Option..
743$!
744$ WRITE SYS$OUTPUT ""
745$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
746$ WRITE SYS$OUTPUT ""
747$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
748$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
749$ WRITE SYS$OUTPUT ""
750$!
751$! Time To EXIT.
752$!
753$ EXIT
754$!
755$! End The Valid Arguement Check.
756$!
757$ ENDIF
758$!
759$! End The P2 Check.
760$!
761$ ENDIF
762$!
763$! Special Threads For OpenVMS v7.1 Or Later.
764$!
765$! Written By: Richard Levitte
766$! richard@levitte.org
767$!
768$!
769$! Check To See If We Have A Option For P4.
770$!
771$ IF (P4.EQS."")
772$ THEN
773$!
774$! Get The Version Of VMS We Are Using.
775$!
776$ ISSEVEN := ""
777$ TMP = F$ELEMENT(0,"-",F$EXTRACT(1,4,F$GETSYI("VERSION")))
778$ TMP = F$INTEGER(F$ELEMENT(0,".",TMP)+F$ELEMENT(1,".",TMP))
779$!
780$! Check To See If The VMS Version Is v7.1 Or Later.
781$!
782$ IF (TMP.GE.71)
783$ THEN
784$!
785$! We Have OpenVMS v7.1 Or Later, So Use The Special Threads.
786$!
787$ ISSEVEN := ,PTHREAD_USE_D4
788$!
789$! End The VMS Version Check.
790$!
791$ ENDIF
792$!
793$! End The P4 Check.
794$!
795$ ENDIF
796$!
797$! Check To See If P3 Is Blank.
798$!
799$ IF (P3.EQS."")
800$ THEN
801$!
802$! O.K., The User Didn't Specify A Compiler, Let's Try To
803$! Find Out Which One To Use.
804$!
805$! Check To See If We Have GNU C.
806$!
807$ IF (F$TRNLNM("GNU_CC").NES."")
808$ THEN
809$!
810$! Looks Like GNUC, Set To Use GNUC.
811$!
812$ P3 = "GNUC"
813$!
814$! Else...
815$!
816$ ELSE
817$!
818$! Check To See If We Have VAXC Or DECC.
819$!
820$ IF (ARCH.EQS."AXP").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
821$ THEN
822$!
823$! Looks Like DECC, Set To Use DECC.
824$!
825$ P3 = "DECC"
826$!
827$! Else...
828$!
829$ ELSE
830$!
831$! Looks Like VAXC, Set To Use VAXC.
832$!
833$ P3 = "VAXC"
834$!
835$! End The VAXC Compiler Check.
836$!
837$ ENDIF
838$!
839$! End The DECC & VAXC Compiler Check.
840$!
841$ ENDIF
842$!
843$! End The Compiler Check.
844$!
845$ ENDIF
846$!
847$! Set Up Initial CC Definitions, Possibly With User Ones
848$!
849$ CCDEFS = "VMS=1"
850$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
851$ CCEXTRAFLAGS = ""
852$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
853$ CCDISABLEWARNINGS = ""
854$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
855 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS
856$!
857$! Check To See If The User Entered A Valid Paramter.
858$!
859$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC")
860$ THEN
861$!
862$! Check To See If The User Wanted DECC.
863$!
864$ IF (P3.EQS."DECC")
865$ THEN
866$!
867$! Looks Like DECC, Set To Use DECC.
868$!
869$ COMPILER = "DECC"
870$!
871$! Tell The User We Are Using DECC.
872$!
873$ WRITE SYS$OUTPUT "Using DECC 'C' Compiler."
874$!
875$! Use DECC...
876$!
877$ CC = "CC"
878$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
879 THEN CC = "CC/DECC"
880$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
881 "/NOLIST/PREFIX=ALL" + CCEXTRAFLAGS
882$!
883$! Define The Linker Options File Name.
884$!
885$ OPT_FILE = "SYS$DISK:[]VAX_DECC_OPTIONS.OPT"
886$!
887$! End DECC Check.
888$!
889$ ENDIF
890$!
891$! Check To See If We Are To Use VAXC.
892$!
893$ IF (P3.EQS."VAXC")
894$ THEN
895$!
896$! Looks Like VAXC, Set To Use VAXC.
897$!
898$ COMPILER = "VAXC"
899$!
900$! Tell The User We Are Using VAX C.
901$!
902$ WRITE SYS$OUTPUT "Using VAXC 'C' Compiler."
903$!
904$! Compile Using VAXC.
905$!
906$ CC = "CC"
907$ IF ARCH.EQS."AXP"
908$ THEN
909$ WRITE SYS$OUTPUT "There is no VAX C on Alpha!"
910$ EXIT
911$ ENDIF
912$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
913$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
914$ CCDEFS = """VAXC""," + CCDEFS
915$!
916$! Define <sys> As SYS$COMMON:[SYSLIB]
917$!
918$ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
919$!
920$! Define The Linker Options File Name.
921$!
922$ OPT_FILE = "SYS$DISK:[]VAX_VAXC_OPTIONS.OPT"
923$!
924$! End VAXC Check
925$!
926$ ENDIF
927$!
928$! Check To See If We Are To Use GNU C.
929$!
930$ IF (P3.EQS."GNUC")
931$ THEN
932$!
933$! Looks Like GNUC, Set To Use GNUC.
934$!
935$ COMPILER = "GNUC"
936$!
937$! Tell The User We Are Using GNUC.
938$!
939$ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
940$!
941$! Use GNU C...
942$!
943$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
944$!
945$! Define The Linker Options File Name.
946$!
947$ OPT_FILE = "SYS$DISK:[]VAX_GNUC_OPTIONS.OPT"
948$!
949$! End The GNU C Check.
950$!
951$ ENDIF
952$!
953$! Set up default defines
954$!
955$ CCDEFS = """FLAT_INC=1""," + CCDEFS
956$!
957$! Finish up the definition of CC.
958$!
959$ IF COMPILER .EQS. "DECC"
960$ THEN
961$ IF CCDISABLEWARNINGS .EQS. ""
962$ THEN
963$ CC4DISABLEWARNINGS = "DOLLARID"
964$ ELSE
965$ CC4DISABLEWARNINGS = CCDISABLEWARNINGS + ",DOLLARID"
966$ CCDISABLEWARNINGS = "/WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
967$ ENDIF
968$ CC4DISABLEWARNINGS = "/WARNING=(DISABLE=(" + CC4DISABLEWARNINGS + "))"
969$ ELSE
970$ CCDISABLEWARNINGS = ""
971$ CC4DISABLEWARNINGS = ""
972$ ENDIF
973$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
974$!
975$! Show user the result
976$!
977$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC
978$!
979$! Else The User Entered An Invalid Arguement.
980$!
981$ ELSE
982$!
983$! Tell The User We Don't Know What They Want.
984$!
985$ WRITE SYS$OUTPUT ""
986$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
987$ WRITE SYS$OUTPUT ""
988$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
989$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
990$ WRITE SYS$OUTPUT " GNUC : To Compile With GNU C."
991$ WRITE SYS$OUTPUT ""
992$!
993$! Time To EXIT.
994$!
995$ EXIT
996$!
997$! End The P3 Check.
998$!
999$ ENDIF
1000$!
1001$! Time To RETURN...
1002$!
1003$ RETURN
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
index c1e5005474..b2d7f0da78 100644
--- a/src/lib/libcrypto/des/des.c
+++ b/src/lib/libcrypto/des/des.c
@@ -59,10 +59,18 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#ifndef MSDOS 61#ifndef MSDOS
62#ifndef VMS
63#include <openssl/opensslconf.h>
64#include OPENSSL_UNISTD
65#else /* VMS */
66#ifdef __DECC
62#include <unistd.h> 67#include <unistd.h>
68#else /* not __DECC */
69#include <math.h>
70#endif /* __DECC */
71#endif /* VMS */
63#else 72#else
64#include <io.h> 73#include <io.h>
65#define RAND
66#endif 74#endif
67 75
68#include <time.h> 76#include <time.h>
@@ -77,21 +85,13 @@
77#endif 85#endif
78#include <sys/stat.h> 86#include <sys/stat.h>
79#endif 87#endif
80#if defined(NOCONST) 88#include <openssl/des.h>
81#define const 89#include <openssl/rand.h>
82#endif
83#include "des.h"
84 90
85#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) 91#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
86#include <string.h> 92#include <string.h>
87#endif 93#endif
88 94
89#ifdef RAND
90#define random rand
91#define srandom(s) srand(s)
92#endif
93
94#ifndef NOPROTO
95void usage(void); 95void usage(void);
96void doencryption(void); 96void doencryption(void);
97int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp); 97int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp);
@@ -102,17 +102,6 @@ int uudecode(unsigned char *in,int num,unsigned char *out);
102void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length, 102void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length,
103 des_key_schedule sk1,des_key_schedule sk2, 103 des_key_schedule sk1,des_key_schedule sk2,
104 des_cblock *ivec1,des_cblock *ivec2,int enc); 104 des_cblock *ivec1,des_cblock *ivec2,int enc);
105#else
106void usage();
107void doencryption();
108int uufwrite();
109void uufwriteEnd();
110int uufread();
111int uuencode();
112int uudecode();
113void des_3cbc_encrypt();
114#endif
115
116#ifdef VMS 105#ifdef VMS
117#define EXIT(a) exit(a&0x10000000L) 106#define EXIT(a) exit(a&0x10000000L)
118#else 107#else
@@ -138,9 +127,7 @@ char cksumname[200]="";
138 127
139int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error; 128int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error;
140 129
141int main(argc, argv) 130int main(int argc, char **argv)
142int argc;
143char **argv;
144 { 131 {
145 int i; 132 int i;
146 struct stat ins,outs; 133 struct stat ins,outs;
@@ -331,7 +318,7 @@ char **argv;
331 EXIT(0); 318 EXIT(0);
332 } 319 }
333 320
334void usage() 321void usage(void)
335 { 322 {
336 char **u; 323 char **u;
337 static const char *Usage[]={ 324 static const char *Usage[]={
@@ -357,7 +344,7 @@ void usage()
357"-3 : encrypt using tripple DES encryption. This uses 2 keys", 344"-3 : encrypt using tripple DES encryption. This uses 2 keys",
358" generated from the input key. If the input key is less", 345" generated from the input key. If the input key is less",
359" than 8 characters long, this is equivelent to normal", 346" than 8 characters long, this is equivelent to normal",
360" encryption. Default is tripple cbc, -b makes it tripple ecb.", 347" encryption. Default is triple cbc, -b makes it triple ecb.",
361NULL 348NULL
362}; 349};
363 for (u=(char **)Usage; *u; u++) 350 for (u=(char **)Usage; *u; u++)
@@ -369,17 +356,15 @@ NULL
369 EXIT(1); 356 EXIT(1);
370 } 357 }
371 358
372void doencryption() 359void doencryption(void)
373 { 360 {
374#ifdef _LIBC 361#ifdef _LIBC
375 extern int srandom();
376 extern int random();
377 extern unsigned long time(); 362 extern unsigned long time();
378#endif 363#endif
379 364
380 register int i; 365 register int i;
381 des_key_schedule ks,ks2; 366 des_key_schedule ks,ks2;
382 unsigned char iv[8],iv2[8]; 367 des_cblock iv,iv2;
383 char *p; 368 char *p;
384 int num=0,j,k,l,rem,ll,len,last,ex=0; 369 int num=0,j,k,l,rem,ll,len,last,ex=0;
385 des_cblock kk,k2; 370 des_cblock kk,k2;
@@ -392,8 +377,8 @@ void doencryption()
392 377
393 if (buf == NULL) 378 if (buf == NULL)
394 { 379 {
395 if ( (( buf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL) || 380 if ( (( buf=Malloc(BUFSIZE+8)) == NULL) ||
396 ((obuf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL)) 381 ((obuf=Malloc(BUFSIZE+8)) == NULL))
397 { 382 {
398 fputs("Not enough memory\n",stderr); 383 fputs("Not enough memory\n",stderr);
399 Exit=10; 384 Exit=10;
@@ -440,19 +425,19 @@ void doencryption()
440 else 425 else
441 k2[i-8]=k; 426 k2[i-8]=k;
442 } 427 }
443 des_set_key((C_Block *)k2,ks2); 428 des_set_key(&k2,ks2);
444 memset(k2,0,sizeof(k2)); 429 memset(k2,0,sizeof(k2));
445 } 430 }
446 else if (longk || flag3) 431 else if (longk || flag3)
447 { 432 {
448 if (flag3) 433 if (flag3)
449 { 434 {
450 des_string_to_2keys(key,(C_Block *)kk,(C_Block *)k2); 435 des_string_to_2keys(key,&kk,&k2);
451 des_set_key((C_Block *)k2,ks2); 436 des_set_key(&k2,ks2);
452 memset(k2,0,sizeof(k2)); 437 memset(k2,0,sizeof(k2));
453 } 438 }
454 else 439 else
455 des_string_to_key(key,(C_Block *)kk); 440 des_string_to_key(key,&kk);
456 } 441 }
457 else 442 else
458 for (i=0; i<KEYSIZ; i++) 443 for (i=0; i<KEYSIZ; i++)
@@ -470,7 +455,7 @@ void doencryption()
470 kk[i]=key[i]|0x80; 455 kk[i]=key[i]|0x80;
471 } 456 }
472 457
473 des_set_key((C_Block *)kk,ks); 458 des_set_key(&kk,ks);
474 memset(key,0,sizeof(key)); 459 memset(key,0,sizeof(key));
475 memset(kk,0,sizeof(kk)); 460 memset(kk,0,sizeof(kk));
476 /* woops - A bug that does not showup under unix :-( */ 461 /* woops - A bug that does not showup under unix :-( */
@@ -498,9 +483,8 @@ void doencryption()
498 len=l-rem; 483 len=l-rem;
499 if (feof(DES_IN)) 484 if (feof(DES_IN))
500 { 485 {
501 srandom((unsigned int)time(NULL));
502 for (i=7-rem; i>0; i--) 486 for (i=7-rem; i>0; i--)
503 buf[l++]=random()&0xff; 487 RAND_bytes(buf + l++, 1);
504 buf[l++]=rem; 488 buf[l++]=rem;
505 ex=1; 489 ex=1;
506 len+=rem; 490 len+=rem;
@@ -510,8 +494,8 @@ void doencryption()
510 494
511 if (cflag) 495 if (cflag)
512 { 496 {
513 des_cbc_cksum((C_Block *)buf,(C_Block *)cksum, 497 des_cbc_cksum(buf,&cksum,
514 (long)len,ks,(C_Block *)cksum); 498 (long)len,ks,&cksum);
515 if (!eflag) 499 if (!eflag)
516 { 500 {
517 if (feof(DES_IN)) break; 501 if (feof(DES_IN)) break;
@@ -539,16 +523,16 @@ void doencryption()
539 (unsigned int)rem); 523 (unsigned int)rem);
540 des_3cbc_encrypt( 524 des_3cbc_encrypt(
541 (des_cblock *)buf,(des_cblock *)obuf, 525 (des_cblock *)buf,(des_cblock *)obuf,
542 (long)l,ks,ks2,(des_cblock *)iv, 526 (long)l,ks,ks2,&iv,
543 (des_cblock *)iv2,do_encrypt); 527 &iv2,do_encrypt);
544 if (rem) memcpy(&(buf[l]),tmpbuf, 528 if (rem) memcpy(&(buf[l]),tmpbuf,
545 (unsigned int)rem); 529 (unsigned int)rem);
546 } 530 }
547 else 531 else
548 { 532 {
549 des_cbc_encrypt( 533 des_cbc_encrypt(
550 (des_cblock *)buf,(des_cblock *)obuf, 534 buf,obuf,
551 (long)l,ks,(des_cblock *)iv,do_encrypt); 535 (long)l,ks,&iv,do_encrypt);
552 if (l >= 8) memcpy(iv,&(obuf[l-8]),8); 536 if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
553 } 537 }
554 if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem); 538 if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem);
@@ -614,14 +598,14 @@ void doencryption()
614 { 598 {
615 des_3cbc_encrypt( 599 des_3cbc_encrypt(
616 (des_cblock *)buf,(des_cblock *)obuf, 600 (des_cblock *)buf,(des_cblock *)obuf,
617 (long)l,ks,ks2,(des_cblock *)iv, 601 (long)l,ks,ks2,&iv,
618 (des_cblock *)iv2,do_encrypt); 602 &iv2,do_encrypt);
619 } 603 }
620 else 604 else
621 { 605 {
622 des_cbc_encrypt( 606 des_cbc_encrypt(
623 (des_cblock *)buf,(des_cblock *)obuf, 607 buf,obuf,
624 (long)l,ks,(des_cblock *)iv,do_encrypt); 608 (long)l,ks,&iv,do_encrypt);
625 if (l >= 8) memcpy(iv,&(buf[l-8]),8); 609 if (l >= 8) memcpy(iv,&(buf[l-8]),8);
626 } 610 }
627 611
@@ -646,9 +630,9 @@ void doencryption()
646 l=l-8+last; 630 l=l-8+last;
647 } 631 }
648 i=0; 632 i=0;
649 if (cflag) des_cbc_cksum((C_Block *)obuf, 633 if (cflag) des_cbc_cksum(obuf,
650 (C_Block *)cksum,(long)l/8*8,ks, 634 (des_cblock *)cksum,(long)l/8*8,ks,
651 (C_Block *)cksum); 635 (des_cblock *)cksum);
652 while (i != l) 636 while (i != l)
653 { 637 {
654 j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT); 638 j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT);
@@ -696,15 +680,8 @@ problems:
696 if (Exit) EXIT(Exit); 680 if (Exit) EXIT(Exit);
697 } 681 }
698 682
699int uufwrite(data, size, num, fp) 683/* We ignore this parameter but it should be > ~50 I believe */
700unsigned char *data; 684int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp)
701int size;
702unsigned int num;
703FILE *fp;
704
705 /* We ignore this parameter but it should be > ~50 I believe */
706
707
708 { 685 {
709 int i,j,left,rem,ret=num; 686 int i,j,left,rem,ret=num;
710 static int start=1; 687 static int start=1;
@@ -757,8 +734,7 @@ FILE *fp;
757 return(ret); 734 return(ret);
758 } 735 }
759 736
760void uufwriteEnd(fp) 737void uufwriteEnd(FILE *fp)
761FILE *fp;
762 { 738 {
763 int j; 739 int j;
764 static const char *end=" \nend\n"; 740 static const char *end=" \nend\n";
@@ -774,11 +750,8 @@ FILE *fp;
774 fwrite(end,1,strlen(end),fp); 750 fwrite(end,1,strlen(end),fp);
775 } 751 }
776 752
777int uufread(out, size, num, fp) 753/* int size: should always be > ~ 60; I actually ignore this parameter :-) */
778unsigned char *out; 754int uufread(unsigned char *out, int size, unsigned int num, FILE *fp)
779int size; /* should always be > ~ 60; I actually ignore this parameter :-) */
780unsigned int num;
781FILE *fp;
782 { 755 {
783 int i,j,tot; 756 int i,j,tot;
784 static int done=0; 757 static int done=0;
@@ -850,10 +823,7 @@ FILE *fp;
850 *((c)++)=(unsigned char)(((l) )&0xff)) 823 *((c)++)=(unsigned char)(((l) )&0xff))
851 824
852 825
853int uuencode(in, num, out) 826int uuencode(unsigned char *in, int num, unsigned char *out)
854unsigned char *in;
855int num;
856unsigned char *out;
857 { 827 {
858 int j,i,n,tot=0; 828 int j,i,n,tot=0;
859 DES_LONG l; 829 DES_LONG l;
@@ -883,10 +853,7 @@ unsigned char *out;
883 return(tot); 853 return(tot);
884 } 854 }
885 855
886int uudecode(in, num, out) 856int uudecode(unsigned char *in, int num, unsigned char *out)
887unsigned char *in;
888int num;
889unsigned char *out;
890 { 857 {
891 int j,i,k; 858 int j,i,k;
892 unsigned int n=0,space=0; 859 unsigned int n=0,space=0;
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
new file mode 100644
index 0000000000..67f90aaf17
--- /dev/null
+++ b/src/lib/libcrypto/des/des.h
@@ -0,0 +1,249 @@
1/* crypto/des/des.h */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef HEADER_DES_H
60#define HEADER_DES_H
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66#ifdef NO_DES
67#error DES is disabled.
68#endif
69
70#ifdef _KERBEROS_DES_H
71#error <openssl/des.h> replaces <kerberos/des.h>.
72#endif
73
74#include <stdio.h>
75#include <openssl/opensslconf.h> /* DES_LONG */
76#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
77
78typedef unsigned char des_cblock[8];
79typedef /* const */ unsigned char const_des_cblock[8];
80/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock *
81 * and const_des_cblock * are incompatible pointer types.
82 * I haven't seen that warning on other systems ... I'll look
83 * what the standard says. */
84
85
86typedef struct des_ks_struct
87 {
88 union {
89 des_cblock cblock;
90 /* make sure things are correct size on machines with
91 * 8 byte longs */
92 DES_LONG deslong[2];
93 } ks;
94 int weak_key;
95 } des_key_schedule[16];
96
97#define DES_KEY_SZ (sizeof(des_cblock))
98#define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
99
100#define DES_ENCRYPT 1
101#define DES_DECRYPT 0
102
103#define DES_CBC_MODE 0
104#define DES_PCBC_MODE 1
105
106#define des_ecb2_encrypt(i,o,k1,k2,e) \
107 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
108
109#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
110 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
111
112#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
113 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
114
115#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
116 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
117
118OPENSSL_EXTERN int des_check_key; /* defaults to false */
119OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */
120OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */
121
122const char *des_options(void);
123void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
124 des_key_schedule ks1,des_key_schedule ks2,
125 des_key_schedule ks3, int enc);
126DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock *output,
127 long length,des_key_schedule schedule,
128 const_des_cblock *ivec);
129/* des_cbc_encrypt does not update the IV! Use des_ncbc_encrypt instead. */
130void des_cbc_encrypt(const unsigned char *input,unsigned char *output,
131 long length,des_key_schedule schedule,des_cblock *ivec,
132 int enc);
133void des_ncbc_encrypt(const unsigned char *input,unsigned char *output,
134 long length,des_key_schedule schedule,des_cblock *ivec,
135 int enc);
136void des_xcbc_encrypt(const unsigned char *input,unsigned char *output,
137 long length,des_key_schedule schedule,des_cblock *ivec,
138 const_des_cblock *inw,const_des_cblock *outw,int enc);
139void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
140 long length,des_key_schedule schedule,des_cblock *ivec,
141 int enc);
142void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
143 des_key_schedule ks,int enc);
144void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
145void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
146void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
147 des_key_schedule ks2, des_key_schedule ks3);
148void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
149 des_key_schedule ks2, des_key_schedule ks3);
150void des_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output,
151 long length,
152 des_key_schedule ks1,des_key_schedule ks2,
153 des_key_schedule ks3,des_cblock *ivec,int enc);
154void des_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
155 long length,
156 des_key_schedule ks1,des_key_schedule ks2,
157 des_key_schedule ks3,
158 des_cblock *ivec1,des_cblock *ivec2,
159 int enc);
160void des_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
161 long length,des_key_schedule ks1,
162 des_key_schedule ks2,des_key_schedule ks3,
163 des_cblock *ivec,int *num,int enc);
164void des_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
165 long length,des_key_schedule ks1,
166 des_key_schedule ks2,des_key_schedule ks3,
167 des_cblock *ivec,int *num);
168
169void des_xwhite_in2out(const_des_cblock *des_key,const_des_cblock *in_white,
170 des_cblock *out_white);
171
172int des_enc_read(int fd,void *buf,int len,des_key_schedule sched,
173 des_cblock *iv);
174int des_enc_write(int fd,const void *buf,int len,des_key_schedule sched,
175 des_cblock *iv);
176char *des_fcrypt(const char *buf,const char *salt, char *ret);
177char *des_crypt(const char *buf,const char *salt);
178#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT)
179char *crypt(const char *buf,const char *salt);
180#endif
181void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
182 long length,des_key_schedule schedule,des_cblock *ivec);
183void des_pcbc_encrypt(const unsigned char *input,unsigned char *output,
184 long length,des_key_schedule schedule,des_cblock *ivec,
185 int enc);
186DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[],
187 long length,int out_count,des_cblock *seed);
188void des_random_seed(des_cblock *key);
189void des_random_key(des_cblock *ret);
190int des_read_password(des_cblock *key,const char *prompt,int verify);
191int des_read_2passwords(des_cblock *key1,des_cblock *key2,
192 const char *prompt,int verify);
193int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
194void des_set_odd_parity(des_cblock *key);
195int des_is_weak_key(const_des_cblock *key);
196int des_set_key(const_des_cblock *key,des_key_schedule schedule);
197int des_key_sched(const_des_cblock *key,des_key_schedule schedule);
198void des_string_to_key(const char *str,des_cblock *key);
199void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2);
200void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
201 des_key_schedule schedule,des_cblock *ivec,int *num,
202 int enc);
203void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
204 des_key_schedule schedule,des_cblock *ivec,int *num);
205int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
206
207/* Extra functions from Mark Murray <mark@grondar.za> */
208void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
209
210/* The following definitions provide compatibility with the MIT Kerberos
211 * library. The des_key_schedule structure is not binary compatible. */
212
213#define _KERBEROS_DES_H
214
215#define KRBDES_ENCRYPT DES_ENCRYPT
216#define KRBDES_DECRYPT DES_DECRYPT
217
218#ifdef KERBEROS
219# define ENCRYPT DES_ENCRYPT
220# define DECRYPT DES_DECRYPT
221#endif
222
223#ifndef NCOMPAT
224# define C_Block des_cblock
225# define Key_schedule des_key_schedule
226# define KEY_SZ DES_KEY_SZ
227# define string_to_key des_string_to_key
228# define read_pw_string des_read_pw_string
229# define random_key des_random_key
230# define pcbc_encrypt des_pcbc_encrypt
231# define set_key des_set_key
232# define key_sched des_key_sched
233# define ecb_encrypt des_ecb_encrypt
234# define cbc_encrypt des_cbc_encrypt
235# define ncbc_encrypt des_ncbc_encrypt
236# define xcbc_encrypt des_xcbc_encrypt
237# define cbc_cksum des_cbc_cksum
238# define quad_cksum des_quad_cksum
239#endif
240
241typedef des_key_schedule bit_64;
242#define des_fixup_key_parity des_set_odd_parity
243#define des_check_key_parity check_parity
244
245#ifdef __cplusplus
246}
247#endif
248
249#endif
diff --git a/src/lib/libcrypto/des/des.org b/src/lib/libcrypto/des/des.org
deleted file mode 100644
index a4cf5c8770..0000000000
--- a/src/lib/libcrypto/des/des.org
+++ /dev/null
@@ -1,301 +0,0 @@
1/* crypto/des/des.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify des.org since des.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_DES_H
68#define HEADER_DES_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#include <stdio.h>
75
76/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
77 * %20 speed up (longs are 8 bytes, int's are 4). */
78#ifndef DES_LONG
79#define DES_LONG unsigned long
80#endif
81
82typedef unsigned char des_cblock[8];
83typedef struct des_ks_struct
84 {
85 union {
86 des_cblock _;
87 /* make sure things are correct size on machines with
88 * 8 byte longs */
89 DES_LONG pad[2];
90 } ks;
91#undef _
92#define _ ks._
93 } des_key_schedule[16];
94
95#define DES_KEY_SZ (sizeof(des_cblock))
96#define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
97
98#define DES_ENCRYPT 1
99#define DES_DECRYPT 0
100
101#define DES_CBC_MODE 0
102#define DES_PCBC_MODE 1
103
104#define des_ecb2_encrypt(i,o,k1,k2,e) \
105 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
106
107#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
108 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
109
110#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
111 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
112
113#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
114 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
115
116#define C_Block des_cblock
117#define Key_schedule des_key_schedule
118#ifdef KERBEROS
119#define ENCRYPT DES_ENCRYPT
120#define DECRYPT DES_DECRYPT
121#endif
122#define KEY_SZ DES_KEY_SZ
123#define string_to_key des_string_to_key
124#define read_pw_string des_read_pw_string
125#define random_key des_random_key
126#define pcbc_encrypt des_pcbc_encrypt
127#define set_key des_set_key
128#define key_sched des_key_sched
129#define ecb_encrypt des_ecb_encrypt
130#define cbc_encrypt des_cbc_encrypt
131#define ncbc_encrypt des_ncbc_encrypt
132#define xcbc_encrypt des_xcbc_encrypt
133#define cbc_cksum des_cbc_cksum
134#define quad_cksum des_quad_cksum
135
136/* For compatibility with the MIT lib - eay 20/05/92 */
137typedef des_key_schedule bit_64;
138#define des_fixup_key_parity des_set_odd_parity
139#define des_check_key_parity check_parity
140
141extern int des_check_key; /* defaults to false */
142extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
143
144/* The next line is used to disable full ANSI prototypes, if your
145 * compiler has problems with the prototypes, make sure this line always
146 * evaluates to true :-) */
147#if defined(MSDOS) || defined(__STDC__)
148#undef NOPROTO
149#endif
150#ifndef NOPROTO
151char *des_options(void);
152void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
153 des_key_schedule ks1,des_key_schedule ks2,
154 des_key_schedule ks3, int enc);
155DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
156 long length,des_key_schedule schedule,des_cblock *ivec);
157void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
158 des_key_schedule schedule,des_cblock *ivec,int enc);
159void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
160 des_key_schedule schedule,des_cblock *ivec,int enc);
161void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
162 des_key_schedule schedule,des_cblock *ivec,
163 des_cblock *inw,des_cblock *outw,int enc);
164void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
165 long length,des_key_schedule schedule,des_cblock *ivec,int enc);
166void des_ecb_encrypt(des_cblock *input,des_cblock *output,
167 des_key_schedule ks,int enc);
168void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
169void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
170void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
171 des_key_schedule ks2, des_key_schedule ks3);
172void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
173 des_key_schedule ks2, des_key_schedule ks3);
174void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
175 long length, des_key_schedule ks1, des_key_schedule ks2,
176 des_key_schedule ks3, des_cblock *ivec, int enc);
177void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
178 long length, des_key_schedule ks1, des_key_schedule ks2,
179 des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
180void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
181 long length, des_key_schedule ks1, des_key_schedule ks2,
182 des_key_schedule ks3, des_cblock *ivec, int *num);
183
184void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
185 des_cblock (*out_white));
186
187int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
188 des_cblock *iv);
189int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
190 des_cblock *iv);
191char *des_fcrypt(const char *buf,const char *salt, char *ret);
192#ifdef PERL5
193char *des_crypt(const char *buf,const char *salt);
194#else
195/* some stupid compilers complain because I have declared char instead
196 * of const char */
197#ifdef HEADER_DES_LOCL_H
198char *crypt(const char *buf,const char *salt);
199#else
200char *crypt();
201#endif
202#endif
203void des_ofb_encrypt(unsigned char *in,unsigned char *out,
204 int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
205void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
206 des_key_schedule schedule,des_cblock *ivec,int enc);
207DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
208 long length,int out_count,des_cblock *seed);
209void des_random_seed(des_cblock key);
210void des_random_key(des_cblock ret);
211int des_read_password(des_cblock *key,char *prompt,int verify);
212int des_read_2passwords(des_cblock *key1,des_cblock *key2,
213 char *prompt,int verify);
214int des_read_pw_string(char *buf,int length,char *prompt,int verify);
215void des_set_odd_parity(des_cblock *key);
216int des_is_weak_key(des_cblock *key);
217int des_set_key(des_cblock *key,des_key_schedule schedule);
218int des_key_sched(des_cblock *key,des_key_schedule schedule);
219void des_string_to_key(char *str,des_cblock *key);
220void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
221void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
222 des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
223void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
224 des_key_schedule schedule, des_cblock *ivec, int *num);
225int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify);
226
227/* Extra functions from Mark Murray <mark@grondar.za> */
228void des_cblock_print_file(des_cblock *cb, FILE *fp);
229/* The following functions are not in the normal unix build or the
230 * SSLeay build. When using the SSLeay build, use RAND_seed()
231 * and RAND_bytes() instead. */
232int des_new_random_key(des_cblock *key);
233void des_init_random_number_generator(des_cblock *key);
234void des_set_random_generator_seed(des_cblock *key);
235void des_set_sequence_number(des_cblock new_sequence_number);
236void des_generate_random_block(des_cblock *block);
237
238#else
239
240char *des_options();
241void des_ecb3_encrypt();
242DES_LONG des_cbc_cksum();
243void des_cbc_encrypt();
244void des_ncbc_encrypt();
245void des_xcbc_encrypt();
246void des_cfb_encrypt();
247void des_ede3_cfb64_encrypt();
248void des_ede3_ofb64_encrypt();
249void des_ecb_encrypt();
250void des_encrypt();
251void des_encrypt2();
252void des_encrypt3();
253void des_decrypt3();
254void des_ede3_cbc_encrypt();
255int des_enc_read();
256int des_enc_write();
257char *des_fcrypt();
258#ifdef PERL5
259char *des_crypt();
260#else
261char *crypt();
262#endif
263void des_ofb_encrypt();
264void des_pcbc_encrypt();
265DES_LONG des_quad_cksum();
266void des_random_seed();
267void des_random_key();
268int des_read_password();
269int des_read_2passwords();
270int des_read_pw_string();
271void des_set_odd_parity();
272int des_is_weak_key();
273int des_set_key();
274int des_key_sched();
275void des_string_to_key();
276void des_string_to_2keys();
277void des_cfb64_encrypt();
278void des_ofb64_encrypt();
279int des_read_pw();
280void des_xwhite_in2out();
281
282/* Extra functions from Mark Murray <mark@grondar.za> */
283void des_cblock_print_file();
284/* The following functions are not in the normal unix build or the
285 * SSLeay build. When using the SSLeay build, use RAND_seed()
286 * and RAND_bytes() instead. */
287#ifdef FreeBSD
288int des_new_random_key();
289void des_init_random_number_generator();
290void des_set_random_generator_seed();
291void des_set_sequence_number();
292void des_generate_random_block();
293#endif
294
295#endif
296
297#ifdef __cplusplus
298}
299#endif
300
301#endif
diff --git a/src/lib/libcrypto/des/des.pl b/src/lib/libcrypto/des/des.pl
index 935eacb504..8a3f7e3ed6 100644
--- a/src/lib/libcrypto/des/des.pl
+++ b/src/lib/libcrypto/des/des.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2# des.pl - eric young 22/11/1991 eay@cryptsoft.com 2# des.pl - eric young 22/11/1991 eay@cryptsoft.com
3# 3#
4# Copyright (C) 1993 Eric Young 4# Copyright (C) 1993 Eric Young
diff --git a/src/lib/libcrypto/des/des3s.cpp b/src/lib/libcrypto/des/des3s.cpp
index 9aff6494d9..02d527c057 100644
--- a/src/lib/libcrypto/des/des3s.cpp
+++ b/src/lib/libcrypto/des/des3s.cpp
@@ -32,7 +32,7 @@ void GetTSC(unsigned long& tsc)
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include "des.h" 35#include <openssl/des.h>
36 36
37void main(int argc,char *argv[]) 37void main(int argc,char *argv[])
38 { 38 {
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index e4db09299e..8311e10628 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -58,14 +58,11 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_encrypt(data, ks, enc) 61void des_encrypt(DES_LONG *data, des_key_schedule ks, int enc)
62DES_LONG *data;
63des_key_schedule ks;
64int enc;
65 { 62 {
66 register DES_LONG l,r,t,u; 63 register DES_LONG l,r,t,u;
67#ifdef DES_PTR 64#ifdef DES_PTR
68 register unsigned char *des_SP=(unsigned char *)des_SPtrans; 65 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans;
69#endif 66#endif
70#ifndef DES_UNROLL 67#ifndef DES_UNROLL
71 register int i; 68 register int i;
@@ -87,7 +84,7 @@ int enc;
87 r=ROTATE(r,29)&0xffffffffL; 84 r=ROTATE(r,29)&0xffffffffL;
88 l=ROTATE(l,29)&0xffffffffL; 85 l=ROTATE(l,29)&0xffffffffL;
89 86
90 s=(DES_LONG *)ks; 87 s=ks->ks.deslong;
91 /* I don't know if it is worth the effort of loop unrolling the 88 /* I don't know if it is worth the effort of loop unrolling the
92 * inner loop */ 89 * inner loop */
93 if (enc) 90 if (enc)
@@ -159,14 +156,11 @@ int enc;
159 l=r=t=u=0; 156 l=r=t=u=0;
160 } 157 }
161 158
162void des_encrypt2(data, ks, enc) 159void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
163DES_LONG *data;
164des_key_schedule ks;
165int enc;
166 { 160 {
167 register DES_LONG l,r,t,u; 161 register DES_LONG l,r,t,u;
168#ifdef DES_PTR 162#ifdef DES_PTR
169 register unsigned char *des_SP=(unsigned char *)des_SPtrans; 163 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans;
170#endif 164#endif
171#ifndef DES_UNROLL 165#ifndef DES_UNROLL
172 register int i; 166 register int i;
@@ -186,7 +180,7 @@ int enc;
186 r=ROTATE(r,29)&0xffffffffL; 180 r=ROTATE(r,29)&0xffffffffL;
187 l=ROTATE(l,29)&0xffffffffL; 181 l=ROTATE(l,29)&0xffffffffL;
188 182
189 s=(DES_LONG *)ks; 183 s=ks->ks.deslong;
190 /* I don't know if it is worth the effort of loop unrolling the 184 /* I don't know if it is worth the effort of loop unrolling the
191 * inner loop */ 185 * inner loop */
192 if (enc) 186 if (enc)
@@ -253,11 +247,8 @@ int enc;
253 l=r=t=u=0; 247 l=r=t=u=0;
254 } 248 }
255 249
256void des_encrypt3(data,ks1,ks2,ks3) 250void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
257DES_LONG *data; 251 des_key_schedule ks3)
258des_key_schedule ks1;
259des_key_schedule ks2;
260des_key_schedule ks3;
261 { 252 {
262 register DES_LONG l,r; 253 register DES_LONG l,r;
263 254
@@ -276,11 +267,8 @@ des_key_schedule ks3;
276 data[1]=r; 267 data[1]=r;
277 } 268 }
278 269
279void des_decrypt3(data,ks1,ks2,ks3) 270void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
280DES_LONG *data; 271 des_key_schedule ks3)
281des_key_schedule ks1;
282des_key_schedule ks2;
283des_key_schedule ks3;
284 { 272 {
285 register DES_LONG l,r; 273 register DES_LONG l,r;
286 274
@@ -301,108 +289,24 @@ des_key_schedule ks3;
301 289
302#ifndef DES_DEFAULT_OPTIONS 290#ifndef DES_DEFAULT_OPTIONS
303 291
304void des_ncbc_encrypt(input, output, length, schedule, ivec, enc) 292#undef CBC_ENC_C__DONT_UPDATE_IV
305des_cblock (*input); 293#include "ncbc_enc.c" /* des_ncbc_encrypt */
306des_cblock (*output);
307long length;
308des_key_schedule schedule;
309des_cblock (*ivec);
310int enc;
311 {
312 register DES_LONG tin0,tin1;
313 register DES_LONG tout0,tout1,xor0,xor1;
314 register unsigned char *in,*out;
315 register long l=length;
316 DES_LONG tin[2];
317 unsigned char *iv;
318
319 in=(unsigned char *)input;
320 out=(unsigned char *)output;
321 iv=(unsigned char *)ivec;
322
323 if (enc)
324 {
325 c2l(iv,tout0);
326 c2l(iv,tout1);
327 for (l-=8; l>=0; l-=8)
328 {
329 c2l(in,tin0);
330 c2l(in,tin1);
331 tin0^=tout0; tin[0]=tin0;
332 tin1^=tout1; tin[1]=tin1;
333 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
334 tout0=tin[0]; l2c(tout0,out);
335 tout1=tin[1]; l2c(tout1,out);
336 }
337 if (l != -8)
338 {
339 c2ln(in,tin0,tin1,l+8);
340 tin0^=tout0; tin[0]=tin0;
341 tin1^=tout1; tin[1]=tin1;
342 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
343 tout0=tin[0]; l2c(tout0,out);
344 tout1=tin[1]; l2c(tout1,out);
345 }
346 iv=(unsigned char *)ivec;
347 l2c(tout0,iv);
348 l2c(tout1,iv);
349 }
350 else
351 {
352 c2l(iv,xor0);
353 c2l(iv,xor1);
354 for (l-=8; l>=0; l-=8)
355 {
356 c2l(in,tin0); tin[0]=tin0;
357 c2l(in,tin1); tin[1]=tin1;
358 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
359 tout0=tin[0]^xor0;
360 tout1=tin[1]^xor1;
361 l2c(tout0,out);
362 l2c(tout1,out);
363 xor0=tin0;
364 xor1=tin1;
365 }
366 if (l != -8)
367 {
368 c2l(in,tin0); tin[0]=tin0;
369 c2l(in,tin1); tin[1]=tin1;
370 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
371 tout0=tin[0]^xor0;
372 tout1=tin[1]^xor1;
373 l2cn(tout0,tout1,out,l+8);
374 xor0=tin0;
375 xor1=tin1;
376 }
377
378 iv=(unsigned char *)ivec;
379 l2c(xor0,iv);
380 l2c(xor1,iv);
381 }
382 tin0=tin1=tout0=tout1=xor0=xor1=0;
383 tin[0]=tin[1]=0;
384 }
385 294
386void des_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc) 295void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
387des_cblock (*input); 296 long length, des_key_schedule ks1, des_key_schedule ks2,
388des_cblock (*output); 297 des_key_schedule ks3, des_cblock *ivec, int enc)
389long length;
390des_key_schedule ks1;
391des_key_schedule ks2;
392des_key_schedule ks3;
393des_cblock (*ivec);
394int enc;
395 { 298 {
396 register DES_LONG tin0,tin1; 299 register DES_LONG tin0,tin1;
397 register DES_LONG tout0,tout1,xor0,xor1; 300 register DES_LONG tout0,tout1,xor0,xor1;
398 register unsigned char *in,*out; 301 register const unsigned char *in;
302 unsigned char *out;
399 register long l=length; 303 register long l=length;
400 DES_LONG tin[2]; 304 DES_LONG tin[2];
401 unsigned char *iv; 305 unsigned char *iv;
402 306
403 in=(unsigned char *)input; 307 in=input;
404 out=(unsigned char *)output; 308 out=output;
405 iv=(unsigned char *)ivec; 309 iv = &(*ivec)[0];
406 310
407 if (enc) 311 if (enc)
408 { 312 {
@@ -439,7 +343,7 @@ int enc;
439 l2c(tout0,out); 343 l2c(tout0,out);
440 l2c(tout1,out); 344 l2c(tout1,out);
441 } 345 }
442 iv=(unsigned char *)ivec; 346 iv = &(*ivec)[0];
443 l2c(tout0,iv); 347 l2c(tout0,iv);
444 l2c(tout1,iv); 348 l2c(tout1,iv);
445 } 349 }
@@ -491,7 +395,7 @@ int enc;
491 xor1=t1; 395 xor1=t1;
492 } 396 }
493 397
494 iv=(unsigned char *)ivec; 398 iv = &(*ivec)[0];
495 l2c(xor0,iv); 399 l2c(xor0,iv);
496 l2c(xor1,iv); 400 l2c(xor1,iv);
497 } 401 }
diff --git a/src/lib/libcrypto/des/des_locl.org b/src/lib/libcrypto/des/des_locl.h
index e2e503cbed..d6ea17cb68 100644
--- a/src/lib/libcrypto/des/des_locl.org
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -1,4 +1,4 @@
1/* crypto/des/des_locl.org */ 1/* crypto/des/des_locl.h */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,14 +56,6 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify des_locl.org since des_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_DES_LOCL_H 59#ifndef HEADER_DES_LOCL_H
68#define HEADER_DES_LOCL_H 60#define HEADER_DES_LOCL_H
69 61
@@ -75,123 +67,28 @@
75 67
76#include <stdio.h> 68#include <stdio.h>
77#include <stdlib.h> 69#include <stdlib.h>
78#ifndef MSDOS
79#include <unistd.h>
80#endif
81#include "des.h"
82
83#ifndef DES_DEFAULT_OPTIONS
84/* the following is tweaked from a config script, that is why it is a
85 * protected undef/define */
86#ifndef DES_PTR
87#undef DES_PTR
88#endif
89 70
90/* This helps C compiler generate the correct code for multiple functional 71#include <openssl/opensslconf.h>
91 * units. It reduces register dependancies at the expense of 2 more
92 * registers */
93#ifndef DES_RISC1
94#undef DES_RISC1
95#endif
96
97#ifndef DES_RISC2
98#undef DES_RISC2
99#endif
100
101#if defined(DES_RISC1) && defined(DES_RISC2)
102YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
103#endif
104 72
105/* Unroll the inner loop, this sometimes helps, sometimes hinders. 73#ifndef MSDOS
106 * Very mucy CPU dependant */ 74#if !defined(VMS) || defined(__DECC)
107#ifndef DES_UNROLL 75#include OPENSSL_UNISTD
108#undef DES_UNROLL 76#include <math.h>
109#endif 77#endif
110
111/* These default values were supplied by
112 * Peter Gutman <pgut001@cs.auckland.ac.nz>
113 * They are only used if nothing else has been defined */
114#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
115/* Special defines which change the way the code is built depending on the
116 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
117 even newer MIPS CPU's, but at the moment one size fits all for
118 optimization options. Older Sparc's work better with only UNROLL, but
119 there's no way to tell at compile time what it is you're running on */
120
121#if defined( sun ) /* Newer Sparc's */
122 #define DES_PTR
123 #define DES_RISC1
124 #define DES_UNROLL
125#elif defined( __ultrix ) /* Older MIPS */
126 #define DES_PTR
127 #define DES_RISC2
128 #define DES_UNROLL
129#elif defined( __osf1__ ) /* Alpha */
130 #define DES_PTR
131 #define DES_RISC2
132#elif defined ( _AIX ) /* RS6000 */
133 /* Unknown */
134#elif defined( __hpux ) /* HP-PA */
135 /* Unknown */
136#elif defined( __aux ) /* 68K */
137 /* Unknown */
138#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
139 #define DES_UNROLL
140#elif defined( __sgi ) /* Newer MIPS */
141 #define DES_PTR
142 #define DES_RISC2
143 #define DES_UNROLL
144#elif defined( i386 ) /* x86 boxes, should be gcc */
145 #define DES_PTR
146 #define DES_RISC1
147 #define DES_UNROLL
148#endif /* Systems-specific speed defines */
149#endif 78#endif
150 79#include <openssl/des.h>
151#endif /* DES_DEFAULT_OPTIONS */
152 80
153#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */ 81#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
154#include <stdlib.h> 82#include <stdlib.h>
155#include <errno.h> 83#include <errno.h>
156#include <time.h> 84#include <time.h>
157#include <io.h> 85#include <io.h>
158#ifndef RAND
159#define RAND
160#endif
161#undef NOPROTO
162#endif 86#endif
163 87
164#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) 88#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
165#include <string.h> 89#include <string.h>
166#endif 90#endif
167 91
168#ifndef RAND
169#define RAND
170#endif
171
172#ifdef linux
173#undef RAND
174#endif
175
176#ifdef MSDOS
177#define getpid() 2
178#define RAND
179#undef NOPROTO
180#endif
181
182#if defined(NOCONST)
183#define const
184#endif
185
186#ifdef __STDC__
187#undef NOPROTO
188#endif
189
190#ifdef RAND
191#define srandom(s) srand(s)
192#define random rand
193#endif
194
195#define ITERATIONS 16 92#define ITERATIONS 16
196#define HALF_ITERATIONS 8 93#define HALF_ITERATIONS 8
197 94
@@ -302,24 +199,24 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
302 u2&=0xfc; \ 199 u2&=0xfc; \
303 t=ROTATE(t,4); \ 200 t=ROTATE(t,4); \
304 u>>=16L; \ 201 u>>=16L; \
305 LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \ 202 LL^= *(const DES_LONG *)(des_SP +u1); \
306 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \ 203 LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
307 u3=(int)(u>>8L); \ 204 u3=(int)(u>>8L); \
308 u1=(int)u&0xfc; \ 205 u1=(int)u&0xfc; \
309 u3&=0xfc; \ 206 u3&=0xfc; \
310 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+u1); \ 207 LL^= *(const DES_LONG *)(des_SP+0x400+u1); \
311 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+u3); \ 208 LL^= *(const DES_LONG *)(des_SP+0x600+u3); \
312 u2=(int)t>>8L; \ 209 u2=(int)t>>8L; \
313 u1=(int)t&0xfc; \ 210 u1=(int)t&0xfc; \
314 u2&=0xfc; \ 211 u2&=0xfc; \
315 t>>=16L; \ 212 t>>=16L; \
316 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \ 213 LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
317 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \ 214 LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
318 u3=(int)t>>8L; \ 215 u3=(int)t>>8L; \
319 u1=(int)t&0xfc; \ 216 u1=(int)t&0xfc; \
320 u3&=0xfc; \ 217 u3&=0xfc; \
321 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+u1); \ 218 LL^= *(const DES_LONG *)(des_SP+0x500+u1); \
322 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+u3); } 219 LL^= *(const DES_LONG *)(des_SP+0x700+u3); }
323#endif 220#endif
324#ifdef DES_RISC2 221#ifdef DES_RISC2
325#define D_ENCRYPT(LL,R,S) { \ 222#define D_ENCRYPT(LL,R,S) { \
@@ -329,39 +226,39 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
329 u1=(int)u&0xfc; \ 226 u1=(int)u&0xfc; \
330 u2&=0xfc; \ 227 u2&=0xfc; \
331 t=ROTATE(t,4); \ 228 t=ROTATE(t,4); \
332 LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \ 229 LL^= *(const DES_LONG *)(des_SP +u1); \
333 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \ 230 LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
334 s1=(int)(u>>16L); \ 231 s1=(int)(u>>16L); \
335 s2=(int)(u>>24L); \ 232 s2=(int)(u>>24L); \
336 s1&=0xfc; \ 233 s1&=0xfc; \
337 s2&=0xfc; \ 234 s2&=0xfc; \
338 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+s1); \ 235 LL^= *(const DES_LONG *)(des_SP+0x400+s1); \
339 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+s2); \ 236 LL^= *(const DES_LONG *)(des_SP+0x600+s2); \
340 u2=(int)t>>8L; \ 237 u2=(int)t>>8L; \
341 u1=(int)t&0xfc; \ 238 u1=(int)t&0xfc; \
342 u2&=0xfc; \ 239 u2&=0xfc; \
343 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \ 240 LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
344 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \ 241 LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
345 s1=(int)(t>>16L); \ 242 s1=(int)(t>>16L); \
346 s2=(int)(t>>24L); \ 243 s2=(int)(t>>24L); \
347 s1&=0xfc; \ 244 s1&=0xfc; \
348 s2&=0xfc; \ 245 s2&=0xfc; \
349 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+s1); \ 246 LL^= *(const DES_LONG *)(des_SP+0x500+s1); \
350 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+s2); } 247 LL^= *(const DES_LONG *)(des_SP+0x700+s2); }
351#endif 248#endif
352#else 249#else
353#define D_ENCRYPT(LL,R,S) { \ 250#define D_ENCRYPT(LL,R,S) { \
354 LOAD_DATA_tmp(R,S,u,t,E0,E1); \ 251 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
355 t=ROTATE(t,4); \ 252 t=ROTATE(t,4); \
356 LL^= \ 253 LL^= \
357 *(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))^ \ 254 *(const DES_LONG *)(des_SP +((u )&0xfc))^ \
358 *(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8L)&0xfc))^ \ 255 *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \
359 *(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16L)&0xfc))^ \ 256 *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \
360 *(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24L)&0xfc))^ \ 257 *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \
361 *(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))^ \ 258 *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \
362 *(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8L)&0xfc))^ \ 259 *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \
363 *(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16L)&0xfc))^ \ 260 *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \
364 *(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24L)&0xfc)); } 261 *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); }
365#endif 262#endif
366 263
367#else /* original version */ 264#else /* original version */
@@ -504,13 +401,8 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
504 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ 401 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
505 } 402 }
506 403
507extern const DES_LONG des_SPtrans[8][64]; 404OPENSSL_EXTERN const DES_LONG des_SPtrans[8][64];
508 405
509#ifndef NOPROTO
510void fcrypt_body(DES_LONG *out,des_key_schedule ks, 406void fcrypt_body(DES_LONG *out,des_key_schedule ks,
511 DES_LONG Eswap0, DES_LONG Eswap1); 407 DES_LONG Eswap0, DES_LONG Eswap1);
512#else
513void fcrypt_body();
514#endif
515
516#endif 408#endif
diff --git a/src/lib/libcrypto/des/des_opts.c b/src/lib/libcrypto/des/des_opts.c
index fdf0fbf461..746c456f8f 100644
--- a/src/lib/libcrypto/des/des_opts.c
+++ b/src/lib/libcrypto/des/des_opts.c
@@ -59,19 +59,19 @@
59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options. 59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
60 * This is for machines with 64k code segment size restrictions. */ 60 * This is for machines with 64k code segment size restrictions. */
61 61
62#ifndef MSDOS 62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
66#include <stdio.h> 66#include <stdio.h>
67#ifndef MSDOS 67#ifndef MSDOS
68#include <unistd.h> 68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD
69#else 70#else
70#include <io.h> 71#include <io.h>
71extern void exit(); 72extern void exit();
72#endif 73#endif
73#include <signal.h> 74#include <signal.h>
74#ifndef VMS
75#ifndef _IRIX 75#ifndef _IRIX
76#include <time.h> 76#include <time.h>
77#endif 77#endif
@@ -79,25 +79,27 @@ extern void exit();
79#include <sys/types.h> 79#include <sys/types.h>
80#include <sys/times.h> 80#include <sys/times.h>
81#endif 81#endif
82#else /* VMS */ 82
83#include <types.h> 83/* Depending on the VMS version, the tms structure is perhaps defined.
84struct tms { 84 The __TMS macro will show if it was. If it wasn't defined, we should
85 time_t tms_utime; 85 undefine TIMES, since that tells the rest of the program how things
86 time_t tms_stime; 86 should be handled. -- Richard Levitte */
87 time_t tms_uchild; /* I dunno... */ 87#if defined(VMS) && defined(__DECC) && !defined(__TMS)
88 time_t tms_uchildsys; /* so these names are a guess :-) */ 88#undef TIMES
89 }
90#endif 89#endif
90
91#ifndef TIMES 91#ifndef TIMES
92#include <sys/timeb.h> 92#include <sys/timeb.h>
93#endif 93#endif
94 94
95#ifdef sun 95
96#if defined(sun) || defined(__ultrix)
97#define _POSIX_SOURCE
96#include <limits.h> 98#include <limits.h>
97#include <sys/param.h> 99#include <sys/param.h>
98#endif 100#endif
99 101
100#include "des.h" 102#include <openssl/des.h>
101#include "spr.h" 103#include "spr.h"
102 104
103#define DES_DEFAULT_OPTIONS 105#define DES_DEFAULT_OPTIONS
@@ -317,11 +319,7 @@ struct tms {
317#ifndef HZ 319#ifndef HZ
318# ifndef CLK_TCK 320# ifndef CLK_TCK
319# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ 321# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
320# ifndef VMS 322# define HZ 100.0
321# define HZ 100.0
322# else /* VMS */
323# define HZ 100.0
324# endif
325# else /* _BSD_CLK_TCK_ */ 323# else /* _BSD_CLK_TCK_ */
326# define HZ ((double)_BSD_CLK_TCK_) 324# define HZ ((double)_BSD_CLK_TCK_)
327# endif 325# endif
@@ -333,12 +331,7 @@ struct tms {
333#define BUFSIZE ((long)1024) 331#define BUFSIZE ((long)1024)
334long run=0; 332long run=0;
335 333
336#ifndef NOPROTO
337double Time_F(int s); 334double Time_F(int s);
338#else
339double Time_F();
340#endif
341
342#ifdef SIGALRM 335#ifdef SIGALRM
343#if defined(__STDC__) || defined(sgi) 336#if defined(__STDC__) || defined(sgi)
344#define SIGRETTYPE void 337#define SIGRETTYPE void
@@ -346,14 +339,8 @@ double Time_F();
346#define SIGRETTYPE int 339#define SIGRETTYPE int
347#endif 340#endif
348 341
349#ifndef NOPROTO
350SIGRETTYPE sig_done(int sig); 342SIGRETTYPE sig_done(int sig);
351#else 343SIGRETTYPE sig_done(int sig)
352SIGRETTYPE sig_done();
353#endif
354
355SIGRETTYPE sig_done(sig)
356int sig;
357 { 344 {
358 signal(SIGALRM,sig_done); 345 signal(SIGALRM,sig_done);
359 run=0; 346 run=0;
@@ -366,8 +353,7 @@ int sig;
366#define START 0 353#define START 0
367#define STOP 1 354#define STOP 1
368 355
369double Time_F(s) 356double Time_F(int s)
370int s;
371 { 357 {
372 double ret; 358 double ret;
373#ifdef TIMES 359#ifdef TIMES
@@ -425,9 +411,7 @@ int s;
425 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ 411 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
426 tm[index]*8,1.0e6/tm[index]); 412 tm[index]*8,1.0e6/tm[index]);
427 413
428int main(argc,argv) 414int main(int argc, char **argv)
429int argc;
430char **argv;
431 { 415 {
432 long count; 416 long count;
433 static unsigned char buf[BUFSIZE]; 417 static unsigned char buf[BUFSIZE];
@@ -454,13 +438,13 @@ char **argv;
454 fprintf(stderr,"program when this computer is idle.\n"); 438 fprintf(stderr,"program when this computer is idle.\n");
455#endif 439#endif
456 440
457 des_set_key((C_Block *)key,sch); 441 des_set_key(&key,sch);
458 des_set_key((C_Block *)key2,sch2); 442 des_set_key(&key2,sch2);
459 des_set_key((C_Block *)key3,sch3); 443 des_set_key(&key3,sch3);
460 444
461#ifndef SIGALRM 445#ifndef SIGALRM
462 fprintf(stderr,"First we calculate the approximate speed ...\n"); 446 fprintf(stderr,"First we calculate the approximate speed ...\n");
463 des_set_key((C_Block *)key,sch); 447 des_set_key(&key,sch);
464 count=10; 448 count=10;
465 do { 449 do {
466 long i; 450 long i;
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h
index 7041a9271d..de3c02f110 100644
--- a/src/lib/libcrypto/des/des_ver.h
+++ b/src/lib/libcrypto/des/des_ver.h
@@ -56,5 +56,6 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59extern char *DES_version; /* SSLeay version string */ 59#include <openssl/e_os2.h>
60extern char *libdes_version; /* old libdes version string */ 60OPENSSL_EXTERN char *DES_version; /* SSLeay version string */
61OPENSSL_EXTERN char *libdes_version; /* old libdes version string */
diff --git a/src/lib/libcrypto/des/dess.cpp b/src/lib/libcrypto/des/dess.cpp
index 7fb5987314..753e67ad9b 100644
--- a/src/lib/libcrypto/des/dess.cpp
+++ b/src/lib/libcrypto/des/dess.cpp
@@ -32,7 +32,7 @@ void GetTSC(unsigned long& tsc)
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include "des.h" 35#include <openssl/des.h>
36 36
37void main(int argc,char *argv[]) 37void main(int argc,char *argv[])
38 { 38 {
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
index 620c13ba6f..5a04fc9298 100644
--- a/src/lib/libcrypto/des/destest.c
+++ b/src/lib/libcrypto/des/destest.c
@@ -65,12 +65,27 @@
65#include <stdio.h> 65#include <stdio.h>
66#include <stdlib.h> 66#include <stdlib.h>
67#ifndef MSDOS 67#ifndef MSDOS
68#include <unistd.h> 68#if !defined(VMS) || defined(__DECC)
69#include <openssl/opensslconf.h>
70#include OPENSSL_UNISTD
71#endif /* VMS */
69#else 72#else
70#include <io.h> 73#include <io.h>
71#endif 74#endif
72#include <string.h> 75#include <string.h>
73#include "des.h" 76
77#ifdef NO_DES
78int main(int argc, char *argv[])
79{
80 printf("No DES support\n");
81 return(0);
82}
83#else
84#include <openssl/des.h>
85
86#if defined(PERL5) || defined(__FreeBSD__)
87#define crypt(c,s) (des_crypt((c),(s)))
88#endif
74 89
75/* tisk tisk - the test keys don't all have odd parity :-( */ 90/* tisk tisk - the test keys don't all have odd parity :-( */
76/* test data */ 91/* test data */
@@ -225,7 +240,7 @@ static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
225/* Changed the following text constant to binary so it will work on ebcdic 240/* Changed the following text constant to binary so it will work on ebcdic
226 * machines :-) */ 241 * machines :-) */
227/* static char cbc_data[40]="7654321 Now is the time for \0001"; */ 242/* static char cbc_data[40]="7654321 Now is the time for \0001"; */
228static char cbc_data[40]={ 243static unsigned char cbc_data[40]={
229 0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20, 244 0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20,
230 0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74, 245 0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74,
231 0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20, 246 0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20,
@@ -297,24 +312,14 @@ static unsigned char ofb_cipher[24]=
297DES_LONG cbc_cksum_ret=0xB462FEF7L; 312DES_LONG cbc_cksum_ret=0xB462FEF7L;
298unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; 313unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
299 314
300#ifndef NOPROTO
301static char *pt(unsigned char *p); 315static char *pt(unsigned char *p);
302static int cfb_test(int bits, unsigned char *cfb_cipher); 316static int cfb_test(int bits, unsigned char *cfb_cipher);
303static int cfb64_test(unsigned char *cfb_cipher); 317static int cfb64_test(unsigned char *cfb_cipher);
304static int ede_cfb64_test(unsigned char *cfb_cipher); 318static int ede_cfb64_test(unsigned char *cfb_cipher);
305#else 319int main(int argc, char *argv[])
306static char *pt();
307static int cfb_test();
308static int cfb64_test();
309static int ede_cfb64_test();
310#endif
311
312int main(argc,argv)
313int argc;
314char *argv[];
315 { 320 {
316 int i,j,err=0; 321 int i,j,err=0;
317 des_cblock in,out,outin,iv3; 322 des_cblock in,out,outin,iv3,iv2;
318 des_key_schedule ks,ks2,ks3; 323 des_key_schedule ks,ks2,ks3;
319 unsigned char cbc_in[40]; 324 unsigned char cbc_in[40];
320 unsigned char cbc_out[40]; 325 unsigned char cbc_out[40];
@@ -324,10 +329,63 @@ char *argv[];
324 int num; 329 int num;
325 char *str; 330 char *str;
326 331
332#ifndef NO_DESCBCM
333 printf("Doing cbcm\n");
334 if ((j=des_key_sched(&cbc_key,ks)) != 0)
335 {
336 printf("Key error %d\n",j);
337 err=1;
338 }
339 if ((j=des_key_sched(&cbc2_key,ks2)) != 0)
340 {
341 printf("Key error %d\n",j);
342 err=1;
343 }
344 if ((j=des_key_sched(&cbc3_key,ks3)) != 0)
345 {
346 printf("Key error %d\n",j);
347 err=1;
348 }
349 memset(cbc_out,0,40);
350 memset(cbc_in,0,40);
351 i=strlen((char *)cbc_data)+1;
352 /* i=((i+7)/8)*8; */
353 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
354 memset(iv2,'\0',sizeof iv2);
355
356 des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,&iv2,
357 DES_ENCRYPT);
358 des_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,ks,ks2,ks3,
359 &iv3,&iv2,DES_ENCRYPT);
360 /* if (memcmp(cbc_out,cbc3_ok,
361 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
362 {
363 printf("des_ede3_cbc_encrypt encrypt error\n");
364 err=1;
365 }
366 */
367 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
368 memset(iv2,'\0',sizeof iv2);
369 des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,&iv2,DES_DECRYPT);
370 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
371 {
372 int n;
373
374 printf("des_ede3_cbcm_encrypt decrypt error\n");
375 for(n=0 ; n < i ; ++n)
376 printf(" %02x",cbc_data[n]);
377 printf("\n");
378 for(n=0 ; n < i ; ++n)
379 printf(" %02x",cbc_in[n]);
380 printf("\n");
381 err=1;
382 }
383#endif
384
327 printf("Doing ecb\n"); 385 printf("Doing ecb\n");
328 for (i=0; i<NUM_TESTS; i++) 386 for (i=0; i<NUM_TESTS; i++)
329 { 387 {
330 if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0) 388 if ((j=des_key_sched(&key_data[i],ks)) != 0)
331 { 389 {
332 printf("Key error %2d:%d\n",i+1,j); 390 printf("Key error %2d:%d\n",i+1,j);
333 err=1; 391 err=1;
@@ -335,8 +393,8 @@ char *argv[];
335 memcpy(in,plain_data[i],8); 393 memcpy(in,plain_data[i],8);
336 memset(out,0,8); 394 memset(out,0,8);
337 memset(outin,0,8); 395 memset(outin,0,8);
338 des_ecb_encrypt((C_Block *)in,(C_Block *)out,ks,DES_ENCRYPT); 396 des_ecb_encrypt(&in,&out,ks,DES_ENCRYPT);
339 des_ecb_encrypt((C_Block *)out,(C_Block *)outin,ks,DES_DECRYPT); 397 des_ecb_encrypt(&out,&outin,ks,DES_DECRYPT);
340 398
341 if (memcmp(out,cipher_data[i],8) != 0) 399 if (memcmp(out,cipher_data[i],8) != 0)
342 { 400 {
@@ -357,17 +415,17 @@ char *argv[];
357 printf("Doing ede ecb\n"); 415 printf("Doing ede ecb\n");
358 for (i=0; i<(NUM_TESTS-1); i++) 416 for (i=0; i<(NUM_TESTS-1); i++)
359 { 417 {
360 if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0) 418 if ((j=des_key_sched(&key_data[i],ks)) != 0)
361 { 419 {
362 err=1; 420 err=1;
363 printf("Key error %2d:%d\n",i+1,j); 421 printf("Key error %2d:%d\n",i+1,j);
364 } 422 }
365 if ((j=des_key_sched((C_Block *)(key_data[i+1]),ks2)) != 0) 423 if ((j=des_key_sched(&key_data[i+1],ks2)) != 0)
366 { 424 {
367 printf("Key error %2d:%d\n",i+2,j); 425 printf("Key error %2d:%d\n",i+2,j);
368 err=1; 426 err=1;
369 } 427 }
370 if ((j=des_key_sched((C_Block *)(key_data[i+2]),ks3)) != 0) 428 if ((j=des_key_sched(&key_data[i+2],ks3)) != 0)
371 { 429 {
372 printf("Key error %2d:%d\n",i+3,j); 430 printf("Key error %2d:%d\n",i+3,j);
373 err=1; 431 err=1;
@@ -375,10 +433,8 @@ char *argv[];
375 memcpy(in,plain_data[i],8); 433 memcpy(in,plain_data[i],8);
376 memset(out,0,8); 434 memset(out,0,8);
377 memset(outin,0,8); 435 memset(outin,0,8);
378 des_ecb2_encrypt((C_Block *)in,(C_Block *)out,ks,ks2, 436 des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT);
379 DES_ENCRYPT); 437 des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT);
380 des_ecb2_encrypt((C_Block *)out,(C_Block *)outin,ks,ks2,
381 DES_DECRYPT);
382 438
383 if (memcmp(out,cipher_ecb2[i],8) != 0) 439 if (memcmp(out,cipher_ecb2[i],8) != 0)
384 { 440 {
@@ -397,7 +453,7 @@ char *argv[];
397#endif 453#endif
398 454
399 printf("Doing cbc\n"); 455 printf("Doing cbc\n");
400 if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) 456 if ((j=des_key_sched(&cbc_key,ks)) != 0)
401 { 457 {
402 printf("Key error %d\n",j); 458 printf("Key error %d\n",j);
403 err=1; 459 err=1;
@@ -405,16 +461,14 @@ char *argv[];
405 memset(cbc_out,0,40); 461 memset(cbc_out,0,40);
406 memset(cbc_in,0,40); 462 memset(cbc_in,0,40);
407 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 463 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
408 des_ncbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, 464 des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
409 (long)strlen((char *)cbc_data)+1,ks, 465 &iv3,DES_ENCRYPT);
410 (C_Block *)iv3,DES_ENCRYPT);
411 if (memcmp(cbc_out,cbc_ok,32) != 0) 466 if (memcmp(cbc_out,cbc_ok,32) != 0)
412 printf("cbc_encrypt encrypt error\n"); 467 printf("cbc_encrypt encrypt error\n");
413 468
414 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 469 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
415 des_ncbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, 470 des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
416 (long)strlen((char *)cbc_data)+1,ks, 471 &iv3,DES_DECRYPT);
417 (C_Block *)iv3,DES_DECRYPT);
418 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0) 472 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0)
419 { 473 {
420 printf("cbc_encrypt decrypt error\n"); 474 printf("cbc_encrypt decrypt error\n");
@@ -423,7 +477,7 @@ char *argv[];
423 477
424#ifndef LIBDES_LIT 478#ifndef LIBDES_LIT
425 printf("Doing desx cbc\n"); 479 printf("Doing desx cbc\n");
426 if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) 480 if ((j=des_key_sched(&cbc_key,ks)) != 0)
427 { 481 {
428 printf("Key error %d\n",j); 482 printf("Key error %d\n",j);
429 err=1; 483 err=1;
@@ -431,19 +485,15 @@ char *argv[];
431 memset(cbc_out,0,40); 485 memset(cbc_out,0,40);
432 memset(cbc_in,0,40); 486 memset(cbc_in,0,40);
433 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 487 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
434 des_xcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, 488 des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
435 (long)strlen((char *)cbc_data)+1,ks, 489 &iv3,&cbc2_key,&cbc3_key, DES_ENCRYPT);
436 (C_Block *)iv3,
437 (C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_ENCRYPT);
438 if (memcmp(cbc_out,xcbc_ok,32) != 0) 490 if (memcmp(cbc_out,xcbc_ok,32) != 0)
439 { 491 {
440 printf("des_xcbc_encrypt encrypt error\n"); 492 printf("des_xcbc_encrypt encrypt error\n");
441 } 493 }
442 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 494 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
443 des_xcbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, 495 des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
444 (long)strlen((char *)cbc_data)+1,ks, 496 &iv3,&cbc2_key,&cbc3_key, DES_DECRYPT);
445 (C_Block *)iv3,
446 (C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_DECRYPT);
447 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) 497 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
448 { 498 {
449 printf("des_xcbc_encrypt decrypt error\n"); 499 printf("des_xcbc_encrypt decrypt error\n");
@@ -452,17 +502,17 @@ char *argv[];
452#endif 502#endif
453 503
454 printf("Doing ede cbc\n"); 504 printf("Doing ede cbc\n");
455 if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) 505 if ((j=des_key_sched(&cbc_key,ks)) != 0)
456 { 506 {
457 printf("Key error %d\n",j); 507 printf("Key error %d\n",j);
458 err=1; 508 err=1;
459 } 509 }
460 if ((j=des_key_sched((C_Block *)cbc2_key,ks2)) != 0) 510 if ((j=des_key_sched(&cbc2_key,ks2)) != 0)
461 { 511 {
462 printf("Key error %d\n",j); 512 printf("Key error %d\n",j);
463 err=1; 513 err=1;
464 } 514 }
465 if ((j=des_key_sched((C_Block *)cbc3_key,ks3)) != 0) 515 if ((j=des_key_sched(&cbc3_key,ks3)) != 0)
466 { 516 {
467 printf("Key error %d\n",j); 517 printf("Key error %d\n",j);
468 err=1; 518 err=1;
@@ -473,11 +523,9 @@ char *argv[];
473 /* i=((i+7)/8)*8; */ 523 /* i=((i+7)/8)*8; */
474 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 524 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
475 525
476 des_ede3_cbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, 526 des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,DES_ENCRYPT);
477 16L,ks,ks2,ks3,(C_Block *)iv3,DES_ENCRYPT); 527 des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3,
478 des_ede3_cbc_encrypt((C_Block *)&(cbc_data[16]), 528 &iv3,DES_ENCRYPT);
479 (C_Block *)&(cbc_out[16]),
480 (long)i-16,ks,ks2,ks3,(C_Block *)iv3,DES_ENCRYPT);
481 if (memcmp(cbc_out,cbc3_ok, 529 if (memcmp(cbc_out,cbc3_ok,
482 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) 530 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
483 { 531 {
@@ -486,9 +534,8 @@ char *argv[];
486 } 534 }
487 535
488 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 536 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
489 des_ede3_cbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, 537 des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT);
490 (long)i,ks,ks2,ks3,(C_Block *)iv3,DES_DECRYPT); 538 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
491 if (memcmp(cbc_in,cbc_data,strlen(cbc_data)+1) != 0)
492 { 539 {
493 printf("des_ede3_cbc_encrypt decrypt error\n"); 540 printf("des_ede3_cbc_encrypt decrypt error\n");
494 err=1; 541 err=1;
@@ -496,23 +543,23 @@ char *argv[];
496 543
497#ifndef LIBDES_LIT 544#ifndef LIBDES_LIT
498 printf("Doing pcbc\n"); 545 printf("Doing pcbc\n");
499 if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) 546 if ((j=des_key_sched(&cbc_key,ks)) != 0)
500 { 547 {
501 printf("Key error %d\n",j); 548 printf("Key error %d\n",j);
502 err=1; 549 err=1;
503 } 550 }
504 memset(cbc_out,0,40); 551 memset(cbc_out,0,40);
505 memset(cbc_in,0,40); 552 memset(cbc_in,0,40);
506 des_pcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, 553 des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
507 (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_ENCRYPT); 554 &cbc_iv,DES_ENCRYPT);
508 if (memcmp(cbc_out,pcbc_ok,32) != 0) 555 if (memcmp(cbc_out,pcbc_ok,32) != 0)
509 { 556 {
510 printf("pcbc_encrypt encrypt error\n"); 557 printf("pcbc_encrypt encrypt error\n");
511 err=1; 558 err=1;
512 } 559 }
513 des_pcbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, 560 des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,&cbc_iv,
514 (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_DECRYPT); 561 DES_DECRYPT);
515 if (memcmp(cbc_in,cbc_data,strlen(cbc_data)+1) != 0) 562 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
516 { 563 {
517 printf("pcbc_encrypt decrypt error\n"); 564 printf("pcbc_encrypt decrypt error\n");
518 err=1; 565 err=1;
@@ -536,7 +583,7 @@ char *argv[];
536 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 583 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
537 for (i=0; i<sizeof(plain); i++) 584 for (i=0; i<sizeof(plain); i++)
538 des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]), 585 des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]),
539 8,(long)1,ks,(C_Block *)cfb_tmp,DES_ENCRYPT); 586 8,1,ks,&cfb_tmp,DES_ENCRYPT);
540 if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0) 587 if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0)
541 { 588 {
542 printf("cfb_encrypt small encrypt error\n"); 589 printf("cfb_encrypt small encrypt error\n");
@@ -546,7 +593,7 @@ char *argv[];
546 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 593 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
547 for (i=0; i<sizeof(plain); i++) 594 for (i=0; i<sizeof(plain); i++)
548 des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]), 595 des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]),
549 8,(long)1,ks,(C_Block *)cfb_tmp,DES_DECRYPT); 596 8,1,ks,&cfb_tmp,DES_DECRYPT);
550 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) 597 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
551 { 598 {
552 printf("cfb_encrypt small decrypt error\n"); 599 printf("cfb_encrypt small decrypt error\n");
@@ -559,10 +606,9 @@ char *argv[];
559 printf("done\n"); 606 printf("done\n");
560 607
561 printf("Doing ofb\n"); 608 printf("Doing ofb\n");
562 des_key_sched((C_Block *)ofb_key,ks); 609 des_key_sched(&ofb_key,ks);
563 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 610 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
564 des_ofb_encrypt(plain,ofb_buf1,64,(long)sizeof(plain)/8,ks, 611 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
565 (C_Block *)ofb_tmp);
566 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 612 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
567 { 613 {
568 printf("ofb_encrypt encrypt error\n"); 614 printf("ofb_encrypt encrypt error\n");
@@ -575,8 +621,7 @@ ofb_buf1[8+4], ofb_cipher[8+5], ofb_cipher[8+6], ofb_cipher[8+7]);
575 err=1; 621 err=1;
576 } 622 }
577 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 623 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
578 des_ofb_encrypt(ofb_buf1,ofb_buf2,64,(long)sizeof(ofb_buf1)/8,ks, 624 des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,&ofb_tmp);
579 (C_Block *)ofb_tmp);
580 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) 625 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
581 { 626 {
582 printf("ofb_encrypt decrypt error\n"); 627 printf("ofb_encrypt decrypt error\n");
@@ -590,15 +635,15 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
590 } 635 }
591 636
592 printf("Doing ofb64\n"); 637 printf("Doing ofb64\n");
593 des_key_sched((C_Block *)ofb_key,ks); 638 des_key_sched(&ofb_key,ks);
594 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 639 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
595 memset(ofb_buf1,0,sizeof(ofb_buf1)); 640 memset(ofb_buf1,0,sizeof(ofb_buf1));
596 memset(ofb_buf2,0,sizeof(ofb_buf1)); 641 memset(ofb_buf2,0,sizeof(ofb_buf1));
597 num=0; 642 num=0;
598 for (i=0; i<sizeof(plain); i++) 643 for (i=0; i<sizeof(plain); i++)
599 { 644 {
600 des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks, 645 des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,&ofb_tmp,
601 (C_Block *)ofb_tmp,&num); 646 &num);
602 } 647 }
603 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 648 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
604 { 649 {
@@ -607,8 +652,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
607 } 652 }
608 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 653 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
609 num=0; 654 num=0;
610 des_ofb64_encrypt(ofb_buf1,ofb_buf2,(long)sizeof(ofb_buf1),ks, 655 des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,&num);
611 (C_Block *)ofb_tmp,&num);
612 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) 656 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
613 { 657 {
614 printf("ofb64_encrypt decrypt error\n"); 658 printf("ofb64_encrypt decrypt error\n");
@@ -616,7 +660,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
616 } 660 }
617 661
618 printf("Doing ede_ofb64\n"); 662 printf("Doing ede_ofb64\n");
619 des_key_sched((C_Block *)ofb_key,ks); 663 des_key_sched(&ofb_key,ks);
620 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 664 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
621 memset(ofb_buf1,0,sizeof(ofb_buf1)); 665 memset(ofb_buf1,0,sizeof(ofb_buf1));
622 memset(ofb_buf2,0,sizeof(ofb_buf1)); 666 memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -624,7 +668,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
624 for (i=0; i<sizeof(plain); i++) 668 for (i=0; i<sizeof(plain); i++)
625 { 669 {
626 des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,ks, 670 des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,ks,
627 (C_Block *)ofb_tmp,&num); 671 &ofb_tmp,&num);
628 } 672 }
629 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 673 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
630 { 674 {
@@ -633,8 +677,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
633 } 677 }
634 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 678 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
635 num=0; 679 num=0;
636 des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,(long)sizeof(ofb_buf1),ks, 680 des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,
637 ks,ks,(C_Block *)ofb_tmp,&num); 681 ks,ks,&ofb_tmp,&num);
638 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) 682 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
639 { 683 {
640 printf("ede_ofb64_encrypt decrypt error\n"); 684 printf("ede_ofb64_encrypt decrypt error\n");
@@ -642,9 +686,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
642 } 686 }
643 687
644 printf("Doing cbc_cksum\n"); 688 printf("Doing cbc_cksum\n");
645 des_key_sched((C_Block *)cbc_key,ks); 689 des_key_sched(&cbc_key,ks);
646 cs=des_cbc_cksum((C_Block *)cbc_data,(C_Block *)cret, 690 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
647 (long)strlen(cbc_data),ks,(C_Block *)cbc_iv);
648 if (cs != cbc_cksum_ret) 691 if (cs != cbc_cksum_ret)
649 { 692 {
650 printf("bad return value (%08lX), should be %08lX\n", 693 printf("bad return value (%08lX), should be %08lX\n",
@@ -658,19 +701,26 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
658 } 701 }
659 702
660 printf("Doing quad_cksum\n"); 703 printf("Doing quad_cksum\n");
661 cs=quad_cksum((C_Block *)cbc_data,(C_Block *)qret, 704 /* This is obviously done this way especially to puzzle me. Although
662 (long)strlen(cbc_data),2,(C_Block *)cbc_iv); 705 quad_cksum returns up to 4 groups of 8 bytes, this test gets it to
706 produce 2 groups then treats them as 4 groups of 4 bytes.
707 Ben 13 Feb 1999 */
708 cs=quad_cksum(cbc_data,(des_cblock *)qret,strlen((char *)cbc_data),2,
709 &cbc_iv);
710
711 { /* Big-endian fix */
712 static DES_LONG l=1;
713 static unsigned char *c=(unsigned char *)&l;
714 DES_LONG ll;
715
663 j=sizeof(lqret[0])-4; 716 j=sizeof(lqret[0])-4;
664 for (i=0; i<4; i++) 717 for (i=0; i<4; i++)
665 { 718 {
666 lqret[i]=0; 719 lqret[i]=0;
667 memcpy(&(lqret[i]),&(qret[i][0]),4); 720 memcpy(&(lqret[i]),&(qret[i][0]),4);
668 if (j > 0) lqret[i]=lqret[i]>>(j*8); /* For Cray */ 721 if (!c[0] && (j > 0))
722 lqret[i]=lqret[i]>>(j*8); /* For Cray */
669 } 723 }
670 { /* Big-endian fix */
671 static DES_LONG l=1;
672 static unsigned char *c=(unsigned char *)&l;
673 DES_LONG ll;
674 724
675 if (!c[0]) 725 if (!c[0])
676 { 726 {
@@ -691,25 +741,25 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
691 if (lqret[0] != 0x327eba8dL) 741 if (lqret[0] != 0x327eba8dL)
692 { 742 {
693 printf("quad_cksum error, out[0] %08lx is not %08lx\n", 743 printf("quad_cksum error, out[0] %08lx is not %08lx\n",
694 (unsigned long)lqret[0],0x327eba8dL); 744 (unsigned long)lqret[0],0x327eba8dUL);
695 err=1; 745 err=1;
696 } 746 }
697 if (lqret[1] != 0x201a49ccL) 747 if (lqret[1] != 0x201a49ccL)
698 { 748 {
699 printf("quad_cksum error, out[1] %08lx is not %08lx\n", 749 printf("quad_cksum error, out[1] %08lx is not %08lx\n",
700 (unsigned long)lqret[1],0x201a49ccL); 750 (unsigned long)lqret[1],0x201a49ccUL);
701 err=1; 751 err=1;
702 } 752 }
703 if (lqret[2] != 0x70d7a63aL) 753 if (lqret[2] != 0x70d7a63aL)
704 { 754 {
705 printf("quad_cksum error, out[2] %08lx is not %08lx\n", 755 printf("quad_cksum error, out[2] %08lx is not %08lx\n",
706 (unsigned long)lqret[2],0x70d7a63aL); 756 (unsigned long)lqret[2],0x70d7a63aUL);
707 err=1; 757 err=1;
708 } 758 }
709 if (lqret[3] != 0x501c2c26L) 759 if (lqret[3] != 0x501c2c26L)
710 { 760 {
711 printf("quad_cksum error, out[3] %08lx is not %08lx\n", 761 printf("quad_cksum error, out[3] %08lx is not %08lx\n",
712 (unsigned long)lqret[3],0x501c2c26L); 762 (unsigned long)lqret[3],0x501c2c26UL);
713 err=1; 763 err=1;
714 } 764 }
715#endif 765#endif
@@ -718,17 +768,17 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
718 for (i=0; i<4; i++) 768 for (i=0; i<4; i++)
719 { 769 {
720 printf(" %d",i); 770 printf(" %d",i);
721 des_ncbc_encrypt((C_Block *)&(cbc_out[i]),(C_Block *)cbc_in, 771 des_ncbc_encrypt(&(cbc_out[i]),cbc_in,
722 (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv, 772 strlen((char *)cbc_data)+1,ks,
723 DES_ENCRYPT); 773 &cbc_iv,DES_ENCRYPT);
724 } 774 }
725 printf("\noutput word alignment test"); 775 printf("\noutput word alignment test");
726 for (i=0; i<4; i++) 776 for (i=0; i<4; i++)
727 { 777 {
728 printf(" %d",i); 778 printf(" %d",i);
729 des_ncbc_encrypt((C_Block *)cbc_out,(C_Block *)&(cbc_in[i]), 779 des_ncbc_encrypt(cbc_out,&(cbc_in[i]),
730 (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv, 780 strlen((char *)cbc_data)+1,ks,
731 DES_ENCRYPT); 781 &cbc_iv,DES_ENCRYPT);
732 } 782 }
733 printf("\n"); 783 printf("\n");
734 printf("fast crypt test "); 784 printf("fast crypt test ");
@@ -749,8 +799,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
749 return(0); 799 return(0);
750 } 800 }
751 801
752static char *pt(p) 802static char *pt(unsigned char *p)
753unsigned char *p;
754 { 803 {
755 static char bufs[10][20]; 804 static char bufs[10][20];
756 static int bnum=0; 805 static int bnum=0;
@@ -771,17 +820,15 @@ unsigned char *p;
771 820
772#ifndef LIBDES_LIT 821#ifndef LIBDES_LIT
773 822
774static int cfb_test(bits, cfb_cipher) 823static int cfb_test(int bits, unsigned char *cfb_cipher)
775int bits;
776unsigned char *cfb_cipher;
777 { 824 {
778 des_key_schedule ks; 825 des_key_schedule ks;
779 int i,err=0; 826 int i,err=0;
780 827
781 des_key_sched((C_Block *)cfb_key,ks); 828 des_key_sched(&cfb_key,ks);
782 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 829 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
783 des_cfb_encrypt(plain,cfb_buf1,bits,(long)sizeof(plain),ks, 830 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
784 (C_Block *)cfb_tmp,DES_ENCRYPT); 831 DES_ENCRYPT);
785 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) 832 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
786 { 833 {
787 err=1; 834 err=1;
@@ -790,8 +837,8 @@ unsigned char *cfb_cipher;
790 printf("%s\n",pt(&(cfb_buf1[i]))); 837 printf("%s\n",pt(&(cfb_buf1[i])));
791 } 838 }
792 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 839 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
793 des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,(long)sizeof(plain),ks, 840 des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,&cfb_tmp,
794 (C_Block *)cfb_tmp,DES_DECRYPT); 841 DES_DECRYPT);
795 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) 842 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
796 { 843 {
797 err=1; 844 err=1;
@@ -802,20 +849,17 @@ unsigned char *cfb_cipher;
802 return(err); 849 return(err);
803 } 850 }
804 851
805static int cfb64_test(cfb_cipher) 852static int cfb64_test(unsigned char *cfb_cipher)
806unsigned char *cfb_cipher;
807 { 853 {
808 des_key_schedule ks; 854 des_key_schedule ks;
809 int err=0,i,n; 855 int err=0,i,n;
810 856
811 des_key_sched((C_Block *)cfb_key,ks); 857 des_key_sched(&cfb_key,ks);
812 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 858 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
813 n=0; 859 n=0;
814 des_cfb64_encrypt(plain,cfb_buf1,(long)12,ks, 860 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
815 (C_Block *)cfb_tmp,&n,DES_ENCRYPT); 861 des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks,
816 des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), 862 &cfb_tmp,&n,DES_ENCRYPT);
817 (long)sizeof(plain)-12,ks,
818 (C_Block *)cfb_tmp,&n,DES_ENCRYPT);
819 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) 863 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
820 { 864 {
821 err=1; 865 err=1;
@@ -825,11 +869,9 @@ unsigned char *cfb_cipher;
825 } 869 }
826 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 870 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
827 n=0; 871 n=0;
828 des_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks, 872 des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT);
829 (C_Block *)cfb_tmp,&n,DES_DECRYPT);
830 des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), 873 des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
831 (long)sizeof(plain)-17,ks, 874 sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT);
832 (C_Block *)cfb_tmp,&n,DES_DECRYPT);
833 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) 875 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
834 { 876 {
835 err=1; 877 err=1;
@@ -840,20 +882,19 @@ unsigned char *cfb_cipher;
840 return(err); 882 return(err);
841 } 883 }
842 884
843static int ede_cfb64_test(cfb_cipher) 885static int ede_cfb64_test(unsigned char *cfb_cipher)
844unsigned char *cfb_cipher;
845 { 886 {
846 des_key_schedule ks; 887 des_key_schedule ks;
847 int err=0,i,n; 888 int err=0,i,n;
848 889
849 des_key_sched((C_Block *)cfb_key,ks); 890 des_key_sched(&cfb_key,ks);
850 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 891 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
851 n=0; 892 n=0;
852 des_ede3_cfb64_encrypt(plain,cfb_buf1,(long)12,ks,ks,ks, 893 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
853 (C_Block *)cfb_tmp,&n,DES_ENCRYPT); 894 DES_ENCRYPT);
854 des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), 895 des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
855 (long)sizeof(plain)-12,ks,ks,ks, 896 sizeof(plain)-12,ks,ks,ks,
856 (C_Block *)cfb_tmp,&n,DES_ENCRYPT); 897 &cfb_tmp,&n,DES_ENCRYPT);
857 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) 898 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
858 { 899 {
859 err=1; 900 err=1;
@@ -864,10 +905,10 @@ unsigned char *cfb_cipher;
864 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 905 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
865 n=0; 906 n=0;
866 des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks, 907 des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks,
867 (C_Block *)cfb_tmp,&n,DES_DECRYPT); 908 &cfb_tmp,&n,DES_DECRYPT);
868 des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), 909 des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
869 (long)sizeof(plain)-17,ks,ks,ks, 910 sizeof(plain)-17,ks,ks,ks,
870 (C_Block *)cfb_tmp,&n,DES_DECRYPT); 911 &cfb_tmp,&n,DES_DECRYPT);
871 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) 912 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
872 { 913 {
873 err=1; 914 err=1;
@@ -879,4 +920,4 @@ unsigned char *cfb_cipher;
879 } 920 }
880 921
881#endif 922#endif
882 923#endif
diff --git a/src/lib/libcrypto/des/ecb3_enc.c b/src/lib/libcrypto/des/ecb3_enc.c
index 140f6b5285..fb28b97e1a 100644
--- a/src/lib/libcrypto/des/ecb3_enc.c
+++ b/src/lib/libcrypto/des/ecb3_enc.c
@@ -58,20 +58,15 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_ecb3_encrypt(input, output, ks1, ks2, ks3, enc) 61void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
62des_cblock (*input); 62 des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3,
63des_cblock (*output); 63 int enc)
64des_key_schedule ks1;
65des_key_schedule ks2;
66des_key_schedule ks3;
67int enc;
68 { 64 {
69 register DES_LONG l0,l1; 65 register DES_LONG l0,l1;
70 register unsigned char *in,*out;
71 DES_LONG ll[2]; 66 DES_LONG ll[2];
67 const unsigned char *in = &(*input)[0];
68 unsigned char *out = &(*output)[0];
72 69
73 in=(unsigned char *)input;
74 out=(unsigned char *)output;
75 c2l(in,l0); 70 c2l(in,l0);
76 c2l(in,l1); 71 c2l(in,l1);
77 ll[0]=l0; 72 ll[0]=l0;
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
index acf23fdd00..b261a8aad9 100644
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ b/src/lib/libcrypto/des/ecb_enc.c
@@ -58,20 +58,20 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60#include "spr.h" 60#include "spr.h"
61#include <openssl/opensslv.h>
61 62
62char *libdes_version="libdes v 3.24 - 20-Apr-1996 - eay"; 63OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT;
63char *DES_version="DES part of SSLeay 0.9.0b 29-Jun-1998"; 64OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT;
64 65
65char *des_options() 66const char *des_options(void)
66 { 67 {
67 static int init=1; 68 static int init=1;
68 static char buf[32]; 69 static char buf[32];
69 70
70 if (init) 71 if (init)
71 { 72 {
72 char *ptr,*unroll,*risc,*size; 73 const char *ptr,*unroll,*risc,*size;
73 74
74 init=0;
75#ifdef DES_PTR 75#ifdef DES_PTR
76 ptr="ptr"; 76 ptr="ptr";
77#else 77#else
@@ -97,23 +97,21 @@ char *des_options()
97 else 97 else
98 size="long"; 98 size="long";
99 sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size); 99 sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size);
100 init=0;
100 } 101 }
101 return(buf); 102 return(buf);
102 } 103 }
103 104
104 105
105void des_ecb_encrypt(input, output, ks, enc) 106void des_ecb_encrypt(const_des_cblock *input, des_cblock *output,
106des_cblock (*input); 107 des_key_schedule ks,
107des_cblock (*output); 108 int enc)
108des_key_schedule ks;
109int enc;
110 { 109 {
111 register DES_LONG l; 110 register DES_LONG l;
112 register unsigned char *in,*out;
113 DES_LONG ll[2]; 111 DES_LONG ll[2];
112 const unsigned char *in = &(*input)[0];
113 unsigned char *out = &(*output)[0];
114 114
115 in=(unsigned char *)input;
116 out=(unsigned char *)output;
117 c2l(in,l); ll[0]=l; 115 c2l(in,l); ll[0]=l;
118 c2l(in,l); ll[1]=l; 116 c2l(in,l); ll[1]=l;
119 des_encrypt(ll,ks,enc); 117 des_encrypt(ll,ks,enc);
diff --git a/src/lib/libcrypto/des/ede_cbcm_enc.c b/src/lib/libcrypto/des/ede_cbcm_enc.c
new file mode 100644
index 0000000000..c53062481d
--- /dev/null
+++ b/src/lib/libcrypto/des/ede_cbcm_enc.c
@@ -0,0 +1,197 @@
1/* ede_cbcm_enc.c */
2/* Written by Ben Laurie <ben@algroup.co.uk> for the OpenSSL
3 * project 13 Feb 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59/*
60
61This is an implementation of Triple DES Cipher Block Chaining with Output
62Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom).
63
64Note that there is a known attack on this by Biham and Knudsen but it takes
65a lot of work:
66
67http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz
68
69*/
70
71#ifndef NO_DESCBCM
72#include "des_locl.h"
73
74void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
75 long length, des_key_schedule ks1, des_key_schedule ks2,
76 des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2,
77 int enc)
78 {
79 register DES_LONG tin0,tin1;
80 register DES_LONG tout0,tout1,xor0,xor1,m0,m1;
81 register long l=length;
82 DES_LONG tin[2];
83 unsigned char *iv1,*iv2;
84
85 iv1 = &(*ivec1)[0];
86 iv2 = &(*ivec2)[0];
87
88 if (enc)
89 {
90 c2l(iv1,m0);
91 c2l(iv1,m1);
92 c2l(iv2,tout0);
93 c2l(iv2,tout1);
94 for (l-=8; l>=-7; l-=8)
95 {
96 tin[0]=m0;
97 tin[1]=m1;
98 des_encrypt(tin,ks3,1);
99 m0=tin[0];
100 m1=tin[1];
101
102 if(l < 0)
103 {
104 c2ln(in,tin0,tin1,l+8);
105 }
106 else
107 {
108 c2l(in,tin0);
109 c2l(in,tin1);
110 }
111 tin0^=tout0;
112 tin1^=tout1;
113
114 tin[0]=tin0;
115 tin[1]=tin1;
116 des_encrypt(tin,ks1,1);
117 tin[0]^=m0;
118 tin[1]^=m1;
119 des_encrypt(tin,ks2,0);
120 tin[0]^=m0;
121 tin[1]^=m1;
122 des_encrypt(tin,ks1,1);
123 tout0=tin[0];
124 tout1=tin[1];
125
126 l2c(tout0,out);
127 l2c(tout1,out);
128 }
129 iv1=&(*ivec1)[0];
130 l2c(m0,iv1);
131 l2c(m1,iv1);
132
133 iv2=&(*ivec2)[0];
134 l2c(tout0,iv2);
135 l2c(tout1,iv2);
136 }
137 else
138 {
139 register DES_LONG t0,t1;
140
141 c2l(iv1,m0);
142 c2l(iv1,m1);
143 c2l(iv2,xor0);
144 c2l(iv2,xor1);
145 for (l-=8; l>=-7; l-=8)
146 {
147 tin[0]=m0;
148 tin[1]=m1;
149 des_encrypt(tin,ks3,1);
150 m0=tin[0];
151 m1=tin[1];
152
153 c2l(in,tin0);
154 c2l(in,tin1);
155
156 t0=tin0;
157 t1=tin1;
158
159 tin[0]=tin0;
160 tin[1]=tin1;
161 des_encrypt(tin,ks1,0);
162 tin[0]^=m0;
163 tin[1]^=m1;
164 des_encrypt(tin,ks2,1);
165 tin[0]^=m0;
166 tin[1]^=m1;
167 des_encrypt(tin,ks1,0);
168 tout0=tin[0];
169 tout1=tin[1];
170
171 tout0^=xor0;
172 tout1^=xor1;
173 if(l < 0)
174 {
175 l2cn(tout0,tout1,out,l+8);
176 }
177 else
178 {
179 l2c(tout0,out);
180 l2c(tout1,out);
181 }
182 xor0=t0;
183 xor1=t1;
184 }
185
186 iv1=&(*ivec1)[0];
187 l2c(m0,iv1);
188 l2c(m1,iv1);
189
190 iv2=&(*ivec2)[0];
191 l2c(xor0,iv2);
192 l2c(xor1,iv2);
193 }
194 tin0=tin1=tout0=tout1=xor0=xor1=0;
195 tin[0]=tin[1]=0;
196 }
197#endif
diff --git a/src/lib/libcrypto/des/ede_enc.c b/src/lib/libcrypto/des/ede_enc.c
deleted file mode 100644
index 9f75dd1037..0000000000
--- a/src/lib/libcrypto/des/ede_enc.c
+++ /dev/null
@@ -1,190 +0,0 @@
1/* crypto/des/ede_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61void des_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc)
62des_cblock (*input);
63des_cblock (*output);
64long length;
65des_key_schedule ks1;
66des_key_schedule ks2;
67des_key_schedule ks3;
68des_cblock (*ivec);
69int enc;
70 {
71 register DES_LONG tin0,tin1;
72 register DES_LONG tout0,tout1,xor0,xor1;
73 register unsigned char *in,*out;
74 register long l=length;
75 DES_LONG tin[2];
76 unsigned char *iv;
77
78 in=(unsigned char *)input;
79 out=(unsigned char *)output;
80 iv=(unsigned char *)ivec;
81
82 if (enc)
83 {
84 c2l(iv,tout0);
85 c2l(iv,tout1);
86 for (l-=8; l>=0; l-=8)
87 {
88 c2l(in,tin0);
89 c2l(in,tin1);
90 tin0^=tout0;
91 tin1^=tout1;
92
93 tin[0]=tin0;
94 tin[1]=tin1;
95 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
96 tout0=tin[0];
97 tout1=tin[1];
98
99 l2c(tout0,out);
100 l2c(tout1,out);
101 }
102 if (l != -8)
103 {
104 c2ln(in,tin0,tin1,l+8);
105 tin0^=tout0;
106 tin1^=tout1;
107
108 tin[0]=tin0;
109 tin[1]=tin1;
110 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
111 tout0=tin[0];
112 tout1=tin[1];
113
114 l2c(tout0,out);
115 l2c(tout1,out);
116 }
117 iv=(unsigned char *)ivec;
118 l2c(tout0,iv);
119 l2c(tout1,iv);
120 }
121 else
122 {
123 register DES_LONG t0,t1;
124
125 c2l(iv,xor0);
126 c2l(iv,xor1);
127 for (l-=8; l>=0; l-=8)
128 {
129 c2l(in,tin0);
130 c2l(in,tin1);
131
132 t0=tin0;
133 t1=tin1;
134
135 tin[0]=tin0;
136 tin[1]=tin1;
137 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
138 tout0=tin[0];
139 tout1=tin[1];
140
141 tout0^=xor0;
142 tout1^=xor1;
143 l2c(tout0,out);
144 l2c(tout1,out);
145 xor0=t0;
146 xor1=t1;
147 }
148 if (l != -8)
149 {
150 c2l(in,tin0);
151 c2l(in,tin1);
152
153 t0=tin0;
154 t1=tin1;
155
156 tin[0]=tin0;
157 tin[1]=tin1;
158 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
159 tout0=tin[0];
160 tout1=tin[1];
161
162 tout0^=xor0;
163 tout1^=xor1;
164 l2cn(tout0,tout1,out,l+8);
165 xor0=t0;
166 xor1=t1;
167 }
168
169 iv=(unsigned char *)ivec;
170 l2c(xor0,iv);
171 l2c(xor1,iv);
172 }
173 tin0=tin1=tout0=tout1=xor0=xor1=0;
174 tin[0]=tin[1]=0;
175 }
176
177#ifdef undef /* MACRO */
178void des_ede2_cbc_encrypt(input, output, length, ks1, ks2, ivec, enc)
179des_cblock (*input);
180des_cblock (*output);
181long length;
182des_key_schedule ks1;
183des_key_schedule ks2;
184des_cblock (*ivec);
185int enc;
186 {
187 des_ede3_cbc_encrypt(input,output,length,ks1,ks2,ks1,ivec,enc);
188 }
189#endif
190
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c
index e08a904d75..694970ccd2 100644
--- a/src/lib/libcrypto/des/enc_read.c
+++ b/src/lib/libcrypto/des/enc_read.c
@@ -58,18 +58,34 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <errno.h> 60#include <errno.h>
61#include "cryptlib.h"
61#include "des_locl.h" 62#include "des_locl.h"
62 63
63/* This has some uglies in it but it works - even over sockets. */ 64/* This has some uglies in it but it works - even over sockets. */
64/*extern int errno;*/ 65/*extern int errno;*/
65int des_rw_mode=DES_PCBC_MODE; 66OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE;
66 67
67int des_enc_read(fd, buf, len, sched, iv) 68
68int fd; 69/*
69char *buf; 70 * WARNINGS:
70int len; 71 *
71des_key_schedule sched; 72 * - The data format used by des_enc_write() and des_enc_read()
72des_cblock (*iv); 73 * has a cryptographic weakness: When asked to write more
74 * than MAXWRITE bytes, des_enc_write will split the data
75 * into several chunks that are all encrypted
76 * using the same IV. So don't use these functions unless you
77 * are sure you know what you do (in which case you might
78 * not want to use them anyway).
79 *
80 * - This code cannot handle non-blocking sockets.
81 *
82 * - This function uses an internal state and thus cannot be
83 * used on multiple files.
84 */
85
86
87int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
88 des_cblock *iv)
73 { 89 {
74 /* data to be unencrypted */ 90 /* data to be unencrypted */
75 int net_num=0; 91 int net_num=0;
@@ -77,27 +93,27 @@ des_cblock (*iv);
77 /* extra unencrypted data 93 /* extra unencrypted data
78 * for when a block of 100 comes in but is des_read one byte at 94 * for when a block of 100 comes in but is des_read one byte at
79 * a time. */ 95 * a time. */
80 static char *unnet=NULL; 96 static unsigned char *unnet=NULL;
81 static int unnet_start=0; 97 static int unnet_start=0;
82 static int unnet_left=0; 98 static int unnet_left=0;
83 static char *tmpbuf=NULL; 99 static unsigned char *tmpbuf=NULL;
84 int i; 100 int i;
85 long num=0,rnum; 101 long num=0,rnum;
86 unsigned char *p; 102 unsigned char *p;
87 103
88 if (tmpbuf == NULL) 104 if (tmpbuf == NULL)
89 { 105 {
90 tmpbuf=(char *)malloc(BSIZE); 106 tmpbuf=Malloc(BSIZE);
91 if (tmpbuf == NULL) return(-1); 107 if (tmpbuf == NULL) return(-1);
92 } 108 }
93 if (net == NULL) 109 if (net == NULL)
94 { 110 {
95 net=(unsigned char *)malloc(BSIZE); 111 net=Malloc(BSIZE);
96 if (net == NULL) return(-1); 112 if (net == NULL) return(-1);
97 } 113 }
98 if (unnet == NULL) 114 if (unnet == NULL)
99 { 115 {
100 unnet=(char *)malloc(BSIZE); 116 unnet=Malloc(BSIZE);
101 if (unnet == NULL) return(-1); 117 if (unnet == NULL) return(-1);
102 } 118 }
103 /* left over data from last decrypt */ 119 /* left over data from last decrypt */
@@ -109,7 +125,7 @@ des_cblock (*iv);
109 * with the number of bytes we have - should always 125 * with the number of bytes we have - should always
110 * check the return value */ 126 * check the return value */
111 memcpy(buf,&(unnet[unnet_start]), 127 memcpy(buf,&(unnet[unnet_start]),
112 (unsigned int)unnet_left); 128 unnet_left);
113 /* eay 26/08/92 I had the next 2 lines 129 /* eay 26/08/92 I had the next 2 lines
114 * reversed :-( */ 130 * reversed :-( */
115 i=unnet_left; 131 i=unnet_left;
@@ -117,7 +133,7 @@ des_cblock (*iv);
117 } 133 }
118 else 134 else
119 { 135 {
120 memcpy(buf,&(unnet[unnet_start]),(unsigned int)len); 136 memcpy(buf,&(unnet[unnet_start]),len);
121 unnet_start+=len; 137 unnet_start+=len;
122 unnet_left-=len; 138 unnet_left-=len;
123 i=len; 139 i=len;
@@ -131,7 +147,7 @@ des_cblock (*iv);
131 /* first - get the length */ 147 /* first - get the length */
132 while (net_num < HDRSIZE) 148 while (net_num < HDRSIZE)
133 { 149 {
134 i=read(fd,&(net[net_num]),(unsigned int)HDRSIZE-net_num); 150 i=read(fd,&(net[net_num]),HDRSIZE-net_num);
135#ifdef EINTR 151#ifdef EINTR
136 if ((i == -1) && (errno == EINTR)) continue; 152 if ((i == -1) && (errno == EINTR)) continue;
137#endif 153#endif
@@ -153,7 +169,7 @@ des_cblock (*iv);
153 net_num=0; 169 net_num=0;
154 while (net_num < rnum) 170 while (net_num < rnum)
155 { 171 {
156 i=read(fd,&(net[net_num]),(unsigned int)rnum-net_num); 172 i=read(fd,&(net[net_num]),rnum-net_num);
157#ifdef EINTR 173#ifdef EINTR
158 if ((i == -1) && (errno == EINTR)) continue; 174 if ((i == -1) && (errno == EINTR)) continue;
159#endif 175#endif
@@ -165,14 +181,12 @@ des_cblock (*iv);
165 if (len < num) 181 if (len < num)
166 { 182 {
167 if (des_rw_mode & DES_PCBC_MODE) 183 if (des_rw_mode & DES_PCBC_MODE)
168 des_pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet, 184 des_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
169 num,sched,iv,DES_DECRYPT);
170 else 185 else
171 des_cbc_encrypt((des_cblock *)net,(des_cblock *)unnet, 186 des_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
172 num,sched,iv,DES_DECRYPT); 187 memcpy(buf,unnet,len);
173 memcpy(buf,unnet,(unsigned int)len);
174 unnet_start=len; 188 unnet_start=len;
175 unnet_left=(int)num-len; 189 unnet_left=num-len;
176 190
177 /* The following line is done because we return num 191 /* The following line is done because we return num
178 * as the number of bytes read. */ 192 * as the number of bytes read. */
@@ -189,30 +203,26 @@ des_cblock (*iv);
189 { 203 {
190 204
191 if (des_rw_mode & DES_PCBC_MODE) 205 if (des_rw_mode & DES_PCBC_MODE)
192 des_pcbc_encrypt((des_cblock *)net, 206 des_pcbc_encrypt(net,tmpbuf,num,sched,iv,
193 (des_cblock *)tmpbuf, 207 DES_DECRYPT);
194 num,sched,iv,DES_DECRYPT);
195 else 208 else
196 des_cbc_encrypt((des_cblock *)net, 209 des_cbc_encrypt(net,tmpbuf,num,sched,iv,
197 (des_cblock *)tmpbuf, 210 DES_DECRYPT);
198 num,sched,iv,DES_DECRYPT);
199 211
200 /* eay 26/08/92 fix a bug that returned more 212 /* eay 26/08/92 fix a bug that returned more
201 * bytes than you asked for (returned len bytes :-( */ 213 * bytes than you asked for (returned len bytes :-( */
202 memcpy(buf,tmpbuf,(unsigned int)num); 214 memcpy(buf,tmpbuf,num);
203 } 215 }
204 else 216 else
205 { 217 {
206 if (des_rw_mode & DES_PCBC_MODE) 218 if (des_rw_mode & DES_PCBC_MODE)
207 des_pcbc_encrypt((des_cblock *)net, 219 des_pcbc_encrypt(net,buf,num,sched,iv,
208 (des_cblock *)buf,num,sched,iv, 220 DES_DECRYPT);
209 DES_DECRYPT);
210 else 221 else
211 des_cbc_encrypt((des_cblock *)net, 222 des_cbc_encrypt(net,buf,num,sched,iv,
212 (des_cblock *)buf,num,sched,iv, 223 DES_DECRYPT);
213 DES_DECRYPT);
214 } 224 }
215 } 225 }
216 return((int)num); 226 return num;
217 } 227 }
218 228
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c
index 29a7330fb0..ba3f0822ef 100644
--- a/src/lib/libcrypto/des/enc_writ.c
+++ b/src/lib/libcrypto/des/enc_writ.c
@@ -58,32 +58,44 @@
58 58
59#include <errno.h> 59#include <errno.h>
60#include <time.h> 60#include <time.h>
61#include <stdio.h>
62#include "cryptlib.h"
61#include "des_locl.h" 63#include "des_locl.h"
64#include <openssl/rand.h>
62 65
63int des_enc_write(fd, buf, len, sched, iv) 66/*
64int fd; 67 * WARNINGS:
65char *buf; 68 *
66int len; 69 * - The data format used by des_enc_write() and des_enc_read()
67des_key_schedule sched; 70 * has a cryptographic weakness: When asked to write more
68des_cblock (*iv); 71 * than MAXWRITE bytes, des_enc_write will split the data
72 * into several chunks that are all encrypted
73 * using the same IV. So don't use these functions unless you
74 * are sure you know what you do (in which case you might
75 * not want to use them anyway).
76 *
77 * - This code cannot handle non-blocking sockets.
78 */
79
80int des_enc_write(int fd, const void *_buf, int len,
81 des_key_schedule sched, des_cblock *iv)
69 { 82 {
70#ifdef _LIBC 83#ifdef _LIBC
71 extern int srandom();
72 extern unsigned long time(); 84 extern unsigned long time();
73 extern int random();
74 extern int write(); 85 extern int write();
75#endif 86#endif
76 87 const unsigned char *buf=_buf;
77 long rnum; 88 long rnum;
78 int i,j,k,outnum; 89 int i,j,k,outnum;
79 static char *outbuf=NULL; 90 static unsigned char *outbuf=NULL;
80 char shortbuf[8]; 91 unsigned char shortbuf[8];
81 char *p; 92 unsigned char *p;
93 const unsigned char *cp;
82 static int start=1; 94 static int start=1;
83 95
84 if (outbuf == NULL) 96 if (outbuf == NULL)
85 { 97 {
86 outbuf=(char *)malloc(BSIZE+HDRSIZE); 98 outbuf=Malloc(BSIZE+HDRSIZE);
87 if (outbuf == NULL) return(-1); 99 if (outbuf == NULL) return(-1);
88 } 100 }
89 /* If we are sending less than 8 bytes, the same char will look 101 /* If we are sending less than 8 bytes, the same char will look
@@ -91,7 +103,6 @@ des_cblock (*iv);
91 if (start) 103 if (start)
92 { 104 {
93 start=0; 105 start=0;
94 srandom((unsigned int)time(NULL));
95 } 106 }
96 107
97 /* lets recurse if we want to send the data in small chunks */ 108 /* lets recurse if we want to send the data in small chunks */
@@ -117,35 +128,32 @@ des_cblock (*iv);
117 /* pad short strings */ 128 /* pad short strings */
118 if (len < 8) 129 if (len < 8)
119 { 130 {
120 p=shortbuf; 131 cp=shortbuf;
121 memcpy(shortbuf,buf,(unsigned int)len); 132 memcpy(shortbuf,buf,len);
122 for (i=len; i<8; i++) 133 RAND_bytes(shortbuf+len, 8-len);
123 shortbuf[i]=random();
124 rnum=8; 134 rnum=8;
125 } 135 }
126 else 136 else
127 { 137 {
128 p=buf; 138 cp=(unsigned char*)buf;
129 rnum=((len+7)/8*8); /* round up to nearest eight */ 139 rnum=((len+7)/8*8); /* round up to nearest eight */
130 } 140 }
131 141
132 if (des_rw_mode & DES_PCBC_MODE) 142 if (des_rw_mode & DES_PCBC_MODE)
133 des_pcbc_encrypt((des_cblock *)p, 143 des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
134 (des_cblock *)&(outbuf[HDRSIZE]), 144 DES_ENCRYPT);
135 (long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
136 else 145 else
137 des_cbc_encrypt((des_cblock *)p, 146 des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
138 (des_cblock *)&(outbuf[HDRSIZE]), 147 DES_ENCRYPT);
139 (long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
140 148
141 /* output */ 149 /* output */
142 outnum=(int)rnum+HDRSIZE; 150 outnum=rnum+HDRSIZE;
143 151
144 for (j=0; j<outnum; j+=i) 152 for (j=0; j<outnum; j+=i)
145 { 153 {
146 /* eay 26/08/92 I was not doing writing from where we 154 /* eay 26/08/92 I was not doing writing from where we
147 * got upto. */ 155 * got upto. */
148 i=write(fd,&(outbuf[j]),(unsigned int)(outnum-j)); 156 i=write(fd,&(outbuf[j]),outnum-j);
149 if (i == -1) 157 if (i == -1)
150 { 158 {
151 if (errno == EINTR) 159 if (errno == EINTR)
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
index 1544634bc1..9cbea97c1f 100644
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ b/src/lib/libcrypto/des/fcrypt_b.c
@@ -77,15 +77,12 @@
77#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ 77#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
78 (a)=(a)^(t)^(t>>(16-(n))))\ 78 (a)=(a)^(t)^(t>>(16-(n))))\
79 79
80void fcrypt_body(out, ks, Eswap0, Eswap1) 80void fcrypt_body(DES_LONG *out, des_key_schedule ks, DES_LONG Eswap0,
81DES_LONG *out; 81 DES_LONG Eswap1)
82des_key_schedule ks;
83DES_LONG Eswap0;
84DES_LONG Eswap1;
85 { 82 {
86 register DES_LONG l,r,t,u; 83 register DES_LONG l,r,t,u;
87#ifdef DES_PTR 84#ifdef DES_PTR
88 register unsigned char *des_SP=(unsigned char *)des_SPtrans; 85 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans;
89#endif 86#endif
90 register DES_LONG *s; 87 register DES_LONG *s;
91 register int j; 88 register int j;
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c
index 1d1a368c22..e0e67a417d 100644
--- a/src/lib/libcrypto/des/ncbc_enc.c
+++ b/src/lib/libcrypto/des/ncbc_enc.c
@@ -58,24 +58,21 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_ncbc_encrypt(input, output, length, schedule, ivec, enc) 61#ifdef CBC_ENC_C__DONT_UPDATE_IV
62des_cblock (*input); 62void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
63des_cblock (*output); 63 des_key_schedule schedule, des_cblock *ivec, int enc)
64long length; 64#else
65des_key_schedule schedule; 65void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
66des_cblock (*ivec); 66 des_key_schedule schedule, des_cblock *ivec, int enc)
67int enc; 67#endif
68 { 68 {
69 register DES_LONG tin0,tin1; 69 register DES_LONG tin0,tin1;
70 register DES_LONG tout0,tout1,xor0,xor1; 70 register DES_LONG tout0,tout1,xor0,xor1;
71 register unsigned char *in,*out;
72 register long l=length; 71 register long l=length;
73 DES_LONG tin[2]; 72 DES_LONG tin[2];
74 unsigned char *iv; 73 unsigned char *iv;
75 74
76 in=(unsigned char *)input; 75 iv = &(*ivec)[0];
77 out=(unsigned char *)output;
78 iv=(unsigned char *)ivec;
79 76
80 if (enc) 77 if (enc)
81 { 78 {
@@ -100,9 +97,11 @@ int enc;
100 tout0=tin[0]; l2c(tout0,out); 97 tout0=tin[0]; l2c(tout0,out);
101 tout1=tin[1]; l2c(tout1,out); 98 tout1=tin[1]; l2c(tout1,out);
102 } 99 }
103 iv=(unsigned char *)ivec; 100#ifndef CBC_ENC_C__DONT_UPDATE_IV
101 iv = &(*ivec)[0];
104 l2c(tout0,iv); 102 l2c(tout0,iv);
105 l2c(tout1,iv); 103 l2c(tout1,iv);
104#endif
106 } 105 }
107 else 106 else
108 { 107 {
@@ -120,11 +119,25 @@ int enc;
120 xor0=tin0; 119 xor0=tin0;
121 xor1=tin1; 120 xor1=tin1;
122 } 121 }
123 iv=(unsigned char *)ivec; 122 if (l != -8)
123 {
124 c2l(in,tin0); tin[0]=tin0;
125 c2l(in,tin1); tin[1]=tin1;
126 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
127 tout0=tin[0]^xor0;
128 tout1=tin[1]^xor1;
129 l2cn(tout0,tout1,out,l+8);
130#ifndef CBC_ENC_C__DONT_UPDATE_IV
131 xor0=tin0;
132 xor1=tin1;
133#endif
134 }
135#ifndef CBC_ENC_C__DONT_UPDATE_IV
136 iv = &(*ivec)[0];
124 l2c(xor0,iv); 137 l2c(xor0,iv);
125 l2c(xor1,iv); 138 l2c(xor1,iv);
139#endif
126 } 140 }
127 tin0=tin1=tout0=tout1=xor0=xor1=0; 141 tin0=tin1=tout0=tout1=xor0=xor1=0;
128 tin[0]=tin[1]=0; 142 tin[0]=tin[1]=0;
129 } 143 }
130
diff --git a/src/lib/libcrypto/des/ofb64ede.c b/src/lib/libcrypto/des/ofb64ede.c
index 4b1b0199f1..6eafe908da 100644
--- a/src/lib/libcrypto/des/ofb64ede.c
+++ b/src/lib/libcrypto/des/ofb64ede.c
@@ -62,13 +62,10 @@
62 * used. The extra state information to record how much of the 62 * used. The extra state information to record how much of the
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65void des_ede3_ofb64_encrypt(in, out, length, k1,k2,k3, ivec, num) 65void des_ede3_ofb64_encrypt(register const unsigned char *in,
66register unsigned char *in; 66 register unsigned char *out, long length, des_key_schedule k1,
67register unsigned char *out; 67 des_key_schedule k2, des_key_schedule k3, des_cblock *ivec,
68long length; 68 int *num)
69des_key_schedule k1,k2,k3;
70des_cblock (*ivec);
71int *num;
72 { 69 {
73 register DES_LONG v0,v1; 70 register DES_LONG v0,v1;
74 register int n= *num; 71 register int n= *num;
@@ -79,7 +76,7 @@ int *num;
79 unsigned char *iv; 76 unsigned char *iv;
80 int save=0; 77 int save=0;
81 78
82 iv=(unsigned char *)ivec; 79 iv = &(*ivec)[0];
83 c2l(iv,v0); 80 c2l(iv,v0);
84 c2l(iv,v1); 81 c2l(iv,v1);
85 ti[0]=v0; 82 ti[0]=v0;
@@ -93,7 +90,7 @@ int *num;
93 { 90 {
94 /* ti[0]=v0; */ 91 /* ti[0]=v0; */
95 /* ti[1]=v1; */ 92 /* ti[1]=v1; */
96 des_encrypt3((DES_LONG *)ti,k1,k2,k3); 93 des_encrypt3(ti,k1,k2,k3);
97 v0=ti[0]; 94 v0=ti[0];
98 v1=ti[1]; 95 v1=ti[1];
99 96
@@ -109,7 +106,7 @@ int *num;
109 { 106 {
110/* v0=ti[0]; 107/* v0=ti[0];
111 v1=ti[1];*/ 108 v1=ti[1];*/
112 iv=(unsigned char *)ivec; 109 iv = &(*ivec)[0];
113 l2c(v0,iv); 110 l2c(v0,iv);
114 l2c(v1,iv); 111 l2c(v1,iv);
115 } 112 }
@@ -118,13 +115,9 @@ int *num;
118 } 115 }
119 116
120#ifdef undef /* MACRO */ 117#ifdef undef /* MACRO */
121void des_ede2_ofb64_encrypt(in, out, length, k1,k2, ivec, num) 118void des_ede2_ofb64_encrypt(register unsigned char *in,
122register unsigned char *in; 119 register unsigned char *out, long length, des_key_schedule k1,
123register unsigned char *out; 120 des_key_schedule k2, des_cblock (*ivec), int *num)
124long length;
125des_key_schedule k1,k2;
126des_cblock (*ivec);
127int *num;
128 { 121 {
129 des_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num); 122 des_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num);
130 } 123 }
diff --git a/src/lib/libcrypto/des/ofb64enc.c b/src/lib/libcrypto/des/ofb64enc.c
index ea7e612697..64953959ca 100644
--- a/src/lib/libcrypto/des/ofb64enc.c
+++ b/src/lib/libcrypto/des/ofb64enc.c
@@ -62,37 +62,33 @@
62 * used. The extra state information to record how much of the 62 * used. The extra state information to record how much of the
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65void des_ofb64_encrypt(in, out, length, schedule, ivec, num) 65void des_ofb64_encrypt(register const unsigned char *in,
66register unsigned char *in; 66 register unsigned char *out, long length, des_key_schedule schedule,
67register unsigned char *out; 67 des_cblock *ivec, int *num)
68long length;
69des_key_schedule schedule;
70des_cblock (*ivec);
71int *num;
72 { 68 {
73 register DES_LONG v0,v1,t; 69 register DES_LONG v0,v1,t;
74 register int n= *num; 70 register int n= *num;
75 register long l=length; 71 register long l=length;
76 des_cblock d; 72 des_cblock d;
77 register char *dp; 73 register unsigned char *dp;
78 DES_LONG ti[2]; 74 DES_LONG ti[2];
79 unsigned char *iv; 75 unsigned char *iv;
80 int save=0; 76 int save=0;
81 77
82 iv=(unsigned char *)ivec; 78 iv = &(*ivec)[0];
83 c2l(iv,v0); 79 c2l(iv,v0);
84 c2l(iv,v1); 80 c2l(iv,v1);
85 ti[0]=v0; 81 ti[0]=v0;
86 ti[1]=v1; 82 ti[1]=v1;
87 dp=(char *)d; 83 dp=d;
88 l2c(v0,dp); 84 l2c(v0,dp);
89 l2c(v1,dp); 85 l2c(v1,dp);
90 while (l--) 86 while (l--)
91 { 87 {
92 if (n == 0) 88 if (n == 0)
93 { 89 {
94 des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT); 90 des_encrypt(ti,schedule,DES_ENCRYPT);
95 dp=(char *)d; 91 dp=d;
96 t=ti[0]; l2c(t,dp); 92 t=ti[0]; l2c(t,dp);
97 t=ti[1]; l2c(t,dp); 93 t=ti[1]; l2c(t,dp);
98 save++; 94 save++;
@@ -104,7 +100,7 @@ int *num;
104 { 100 {
105 v0=ti[0]; 101 v0=ti[0];
106 v1=ti[1]; 102 v1=ti[1];
107 iv=(unsigned char *)ivec; 103 iv = &(*ivec)[0];
108 l2c(v0,iv); 104 l2c(v0,iv);
109 l2c(v1,iv); 105 l2c(v1,iv);
110 } 106 }
diff --git a/src/lib/libcrypto/des/ofb_enc.c b/src/lib/libcrypto/des/ofb_enc.c
index 4db0cdbd60..a8f425a575 100644
--- a/src/lib/libcrypto/des/ofb_enc.c
+++ b/src/lib/libcrypto/des/ofb_enc.c
@@ -64,13 +64,8 @@
64 * the second. The second 12 bits will come from the 3rd and half the 4th 64 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte. 65 * byte.
66 */ 66 */
67void des_ofb_encrypt(in, out, numbits, length, schedule, ivec) 67void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
68unsigned char *in; 68 long length, des_key_schedule schedule, des_cblock *ivec)
69unsigned char *out;
70int numbits;
71long length;
72des_key_schedule schedule;
73des_cblock (*ivec);
74 { 69 {
75 register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8; 70 register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8;
76 register DES_LONG mask0,mask1; 71 register DES_LONG mask0,mask1;
@@ -97,7 +92,7 @@ des_cblock (*ivec);
97 mask1=0x00000000L; 92 mask1=0x00000000L;
98 } 93 }
99 94
100 iv=(unsigned char *)ivec; 95 iv = &(*ivec)[0];
101 c2l(iv,v0); 96 c2l(iv,v0);
102 c2l(iv,v1); 97 c2l(iv,v1);
103 ti[0]=v0; 98 ti[0]=v0;
@@ -131,7 +126,7 @@ des_cblock (*ivec);
131 v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL; 126 v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL;
132 } 127 }
133 } 128 }
134 iv=(unsigned char *)ivec; 129 iv = &(*ivec)[0];
135 l2c(v0,iv); 130 l2c(v0,iv);
136 l2c(v1,iv); 131 l2c(v1,iv);
137 v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0; 132 v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0;
diff --git a/src/lib/libcrypto/des/pcbc_enc.c b/src/lib/libcrypto/des/pcbc_enc.c
index 4513207d90..dd69a26d4a 100644
--- a/src/lib/libcrypto/des/pcbc_enc.c
+++ b/src/lib/libcrypto/des/pcbc_enc.c
@@ -58,21 +58,17 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_pcbc_encrypt(input, output, length, schedule, ivec, enc) 61void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
62des_cblock (*input); 62 long length, des_key_schedule schedule, des_cblock *ivec, int enc)
63des_cblock (*output);
64long length;
65des_key_schedule schedule;
66des_cblock (*ivec);
67int enc;
68 { 63 {
69 register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1; 64 register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;
70 DES_LONG tin[2]; 65 DES_LONG tin[2];
71 unsigned char *in,*out,*iv; 66 const unsigned char *in;
67 unsigned char *out,*iv;
72 68
73 in=(unsigned char *)input; 69 in=input;
74 out=(unsigned char *)output; 70 out=output;
75 iv=(unsigned char *)ivec; 71 iv = &(*ivec)[0];
76 72
77 if (enc) 73 if (enc)
78 { 74 {
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c
index 8526abf334..6ce8c61b42 100644
--- a/src/lib/libcrypto/des/qud_cksm.c
+++ b/src/lib/libcrypto/des/qud_cksm.c
@@ -73,28 +73,24 @@
73/* Got the value MIT uses via brute force :-) 2/10/90 eay */ 73/* Got the value MIT uses via brute force :-) 2/10/90 eay */
74#define NOISE ((DES_LONG)83653421L) 74#define NOISE ((DES_LONG)83653421L)
75 75
76DES_LONG des_quad_cksum(input, output, length, out_count, seed) 76DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[],
77des_cblock (*input); 77 long length, int out_count, des_cblock *seed)
78des_cblock (*output);
79long length;
80int out_count;
81des_cblock (*seed);
82 { 78 {
83 DES_LONG z0,z1,t0,t1; 79 DES_LONG z0,z1,t0,t1;
84 int i; 80 int i;
85 long l; 81 long l;
86 unsigned char *cp; 82 const unsigned char *cp;
87 unsigned char *lp; 83 unsigned char *lp;
88 84
89 if (out_count < 1) out_count=1; 85 if (out_count < 1) out_count=1;
90 lp=(unsigned char *)output; 86 lp = &(output[0])[0];
91 87
92 z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); 88 z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]);
93 z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); 89 z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]);
94 90
95 for (i=0; ((i<4)&&(i<out_count)); i++) 91 for (i=0; ((i<4)&&(i<out_count)); i++)
96 { 92 {
97 cp=(unsigned char *)input; 93 cp=input;
98 l=length; 94 l=length;
99 while (l > 0) 95 while (l > 0)
100 { 96 {
@@ -133,7 +129,7 @@ des_cblock (*seed);
133 } 129 }
134 else 130 else
135 { 131 {
136 lp=output[out_count-i-1]; 132 lp = &(output[out_count-i-1])[0];
137 l2n(z1,lp); 133 l2n(z1,lp);
138 l2n(z0,lp); 134 l2n(z0,lp);
139 } 135 }
diff --git a/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c
index 8c30bd029a..fc11792cda 100644
--- a/src/lib/libcrypto/des/rand_key.c
+++ b/src/lib/libcrypto/des/rand_key.c
@@ -62,15 +62,13 @@
62static int seed=0; 62static int seed=0;
63static des_cblock init; 63static des_cblock init;
64 64
65void des_random_seed(key) 65void des_random_seed(des_cblock *key)
66des_cblock key;
67 { 66 {
68 memcpy(init,key,sizeof(des_cblock)); 67 memcpy(&init,key,sizeof(des_cblock));
69 seed=1; 68 seed=1;
70 } 69 }
71 70
72void des_random_key(ret) 71void des_random_key(des_cblock *ret)
73unsigned char *ret;
74 { 72 {
75 des_key_schedule ks; 73 des_key_schedule ks;
76 static DES_LONG c=0; 74 static DES_LONG c=0;
@@ -101,15 +99,13 @@ unsigned char *ret;
101 t=(DES_LONG)((pid)|((c++)<<16)); 99 t=(DES_LONG)((pid)|((c++)<<16));
102 l2c(t,p); 100 l2c(t,p);
103 101
104 des_set_odd_parity((des_cblock *)data); 102 des_set_odd_parity(&data);
105 des_set_key((des_cblock *)data,ks); 103 des_set_key(&data,ks);
106 des_cbc_cksum((des_cblock *)key,(des_cblock *)key, 104 des_cbc_cksum(key,&key,sizeof(key),ks,&data);
107 (long)sizeof(key),ks,(des_cblock *)data);
108 105
109 des_set_odd_parity((des_cblock *)key); 106 des_set_odd_parity(&key);
110 des_set_key((des_cblock *)key,ks); 107 des_set_key(&key,ks);
111 des_cbc_cksum((des_cblock *)key,(des_cblock *)data, 108 des_cbc_cksum(key,&data,sizeof(key),ks,&key);
112 (long)sizeof(key),ks,(des_cblock *)key);
113 109
114 memcpy(ret,data,sizeof(key)); 110 memcpy(ret,data,sizeof(key));
115 memset(key,0,sizeof(key)); 111 memset(key,0,sizeof(key));
diff --git a/src/lib/libcrypto/des/ranlib.sh b/src/lib/libcrypto/des/ranlib.sh
deleted file mode 100644
index 543f712c6b..0000000000
--- a/src/lib/libcrypto/des/ranlib.sh
+++ /dev/null
@@ -1,23 +0,0 @@
1#!/bin/sh
2
3cwd=`pwd`
4cd /tmp
5
6if [ -s /bin/ranlib ] ; then
7 RL=/bin/ranlib
8else if [ -s /usr/bin/ranlib ] ; then
9 RL=/usr/bin/ranlib
10fi
11fi
12
13if [ "x$RL" != "x" ]
14then
15 case "$1" in
16 /*)
17 $RL "$1"
18 ;;
19 *)
20 $RL "$cwd/$1"
21 ;;
22 esac
23fi
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c
index a0d53793e4..a8ceaf088a 100644
--- a/src/lib/libcrypto/des/read2pwd.c
+++ b/src/lib/libcrypto/des/read2pwd.c
@@ -58,10 +58,7 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61int des_read_password(key, prompt, verify) 61int des_read_password(des_cblock *key, const char *prompt, int verify)
62des_cblock (*key);
63char *prompt;
64int verify;
65 { 62 {
66 int ok; 63 int ok;
67 char buf[BUFSIZ],buff[BUFSIZ]; 64 char buf[BUFSIZ],buff[BUFSIZ];
@@ -73,11 +70,8 @@ int verify;
73 return(ok); 70 return(ok);
74 } 71 }
75 72
76int des_read_2passwords(key1, key2, prompt, verify) 73int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt,
77des_cblock (*key1); 74 int verify)
78des_cblock (*key2);
79char *prompt;
80int verify;
81 { 75 {
82 int ok; 76 int ok;
83 char buf[BUFSIZ],buff[BUFSIZ]; 77 char buf[BUFSIZ],buff[BUFSIZ];
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
index 99920f2f86..fed49652c0 100644
--- a/src/lib/libcrypto/des/read_pwd.c
+++ b/src/lib/libcrypto/des/read_pwd.c
@@ -56,7 +56,23 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32)
60#include <openssl/opensslconf.h>
61#include OPENSSL_UNISTD
62/* If unistd.h defines _POSIX_VERSION, we conclude that we
63 * are on a POSIX system and have sigaction and termios. */
64#if defined(_POSIX_VERSION)
65
66# define SIGACTION
67# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
68# define TERMIOS
69# endif
70
71#endif
72#endif
73
59/* #define SIGACTION */ /* Define this if you have sigaction() */ 74/* #define SIGACTION */ /* Define this if you have sigaction() */
75
60#ifdef WIN16TTY 76#ifdef WIN16TTY
61#undef WIN16 77#undef WIN16
62#undef _WINDOWS 78#undef _WINDOWS
@@ -65,11 +81,26 @@
65 81
66/* 06-Apr-92 Luke Brennan Support for VMS */ 82/* 06-Apr-92 Luke Brennan Support for VMS */
67#include "des_locl.h" 83#include "des_locl.h"
84#include "cryptlib.h"
68#include <signal.h> 85#include <signal.h>
86#include <stdio.h>
69#include <string.h> 87#include <string.h>
70#include <setjmp.h> 88#include <setjmp.h>
71#include <errno.h> 89#include <errno.h>
72 90
91#ifdef VMS /* prototypes for sys$whatever */
92#include <starlet.h>
93#ifdef __DECC
94#pragma message disable DOLLARID
95#endif
96#endif
97
98#ifdef WIN_CONSOLE_BUG
99#include <windows.h>
100#include <wincon.h>
101#endif
102
103
73/* There are 5 types of terminal interface supported, 104/* There are 5 types of terminal interface supported,
74 * TERMIO, TERMIOS, VMS, MSDOS and SGTTY 105 * TERMIO, TERMIOS, VMS, MSDOS and SGTTY
75 */ 106 */
@@ -147,7 +178,6 @@ struct IOSB {
147#define NX509_SIG 32 178#define NX509_SIG 32
148#endif 179#endif
149 180
150#ifndef NOPROTO
151static void read_till_nl(FILE *); 181static void read_till_nl(FILE *);
152static void recsig(int); 182static void recsig(int);
153static void pushsig(void); 183static void pushsig(void);
@@ -155,32 +185,15 @@ static void popsig(void);
155#if defined(MSDOS) && !defined(WIN16) 185#if defined(MSDOS) && !defined(WIN16)
156static int noecho_fgets(char *buf, int size, FILE *tty); 186static int noecho_fgets(char *buf, int size, FILE *tty);
157#endif 187#endif
158#else
159static void read_till_nl();
160static void recsig();
161static void pushsig();
162static void popsig();
163#if defined(MSDOS) && !defined(WIN16)
164static int noecho_fgets();
165#endif
166#endif
167
168#ifdef SIGACTION 188#ifdef SIGACTION
169 static struct sigaction savsig[NX509_SIG]; 189 static struct sigaction savsig[NX509_SIG];
170#else 190#else
171# ifndef NOPROTO
172 static void (*savsig[NX509_SIG])(int ); 191 static void (*savsig[NX509_SIG])(int );
173# else
174 static void (*savsig[NX509_SIG])();
175# endif
176#endif 192#endif
177static jmp_buf save; 193static jmp_buf save;
178 194
179int des_read_pw_string(buf, length, prompt, verify) 195int des_read_pw_string(char *buf, int length, const char *prompt,
180char *buf; 196 int verify)
181int length;
182char *prompt;
183int verify;
184 { 197 {
185 char buff[BUFSIZ]; 198 char buff[BUFSIZ];
186 int ret; 199 int ret;
@@ -192,8 +205,7 @@ int verify;
192 205
193#ifndef WIN16 206#ifndef WIN16
194 207
195static void read_till_nl(in) 208static void read_till_nl(FILE *in)
196FILE *in;
197 { 209 {
198#define SIZE 4 210#define SIZE 4
199 char buf[SIZE+1]; 211 char buf[SIZE+1];
@@ -205,12 +217,8 @@ FILE *in;
205 217
206 218
207/* return 0 if ok, 1 (or -1) otherwise */ 219/* return 0 if ok, 1 (or -1) otherwise */
208int des_read_pw(buf, buff, size, prompt, verify) 220int des_read_pw(char *buf, char *buff, int size, const char *prompt,
209char *buf; 221 int verify)
210char *buff;
211int size;
212char *prompt;
213int verify;
214 { 222 {
215#ifdef VMS 223#ifdef VMS
216 struct IOSB iosb; 224 struct IOSB iosb;
@@ -223,14 +231,27 @@ int verify;
223 TTY_STRUCT tty_orig,tty_new; 231 TTY_STRUCT tty_orig,tty_new;
224#endif 232#endif
225#endif 233#endif
226 int number=5; 234 int number;
227 int ok=0; 235 int ok;
228 int ps=0; 236 /* statics are simply to avoid warnings about longjmp clobbering
229 int is_a_tty=1; 237 things */
230 238 static int ps;
231 FILE *tty=NULL; 239 int is_a_tty;
240 static FILE *tty;
232 char *p; 241 char *p;
233 242
243 if (setjmp(save))
244 {
245 ok=0;
246 goto error;
247 }
248
249 number=5;
250 ok=0;
251 ps=0;
252 is_a_tty=1;
253 tty=NULL;
254
234#ifndef MSDOS 255#ifndef MSDOS
235 if ((tty=fopen("/dev/tty","r")) == NULL) 256 if ((tty=fopen("/dev/tty","r")) == NULL)
236 tty=stdin; 257 tty=stdin;
@@ -259,19 +280,14 @@ int verify;
259 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); 280 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
260#endif 281#endif
261#ifdef VMS 282#ifdef VMS
262 status = SYS$ASSIGN(&terminal,&channel,0,0); 283 status = sys$assign(&terminal,&channel,0,0);
263 if (status != SS$_NORMAL) 284 if (status != SS$_NORMAL)
264 return(-1); 285 return(-1);
265 status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0); 286 status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
266 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) 287 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
267 return(-1); 288 return(-1);
268#endif 289#endif
269 290
270 if (setjmp(save))
271 {
272 ok=0;
273 goto error;
274 }
275 pushsig(); 291 pushsig();
276 ps=1; 292 ps=1;
277 293
@@ -287,7 +303,7 @@ int verify;
287 tty_new[0] = tty_orig[0]; 303 tty_new[0] = tty_orig[0];
288 tty_new[1] = tty_orig[1] | TT$M_NOECHO; 304 tty_new[1] = tty_orig[1] | TT$M_NOECHO;
289 tty_new[2] = tty_orig[2]; 305 tty_new[2] = tty_orig[2];
290 status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0); 306 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
291 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) 307 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
292 return(-1); 308 return(-1);
293#endif 309#endif
@@ -333,31 +349,26 @@ error:
333 perror("fgets(tty)"); 349 perror("fgets(tty)");
334#endif 350#endif
335 /* What can we do if there is an error? */ 351 /* What can we do if there is an error? */
336#if defined(TTY_set) && !defined(VMS) 352#if defined(TTY_set) && !defined(VMS)
337 if (ps >= 2) TTY_set(fileno(tty),&tty_orig); 353 if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
338#endif 354#endif
339#ifdef VMS 355#ifdef VMS
340 if (ps >= 2) 356 if (ps >= 2)
341 status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0 357 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
342 ,tty_orig,12,0,0,0,0); 358 ,tty_orig,12,0,0,0,0);
343#endif 359#endif
344 360
345 if (ps >= 1) popsig(); 361 if (ps >= 1) popsig();
346 if (stdin != tty) fclose(tty); 362 if (stdin != tty) fclose(tty);
347#ifdef VMS 363#ifdef VMS
348 status = SYS$DASSGN(channel); 364 status = sys$dassgn(channel);
349#endif 365#endif
350 return(!ok); 366 return(!ok);
351 } 367 }
352 368
353#else /* WIN16 */ 369#else /* WIN16 */
354 370
355int des_read_pw(buf, buff, size, prompt, verify) 371int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
356char *buf;
357char *buff;
358int size;
359char *prompt;
360int verify;
361 { 372 {
362 memset(buf,0,size); 373 memset(buf,0,size);
363 memset(buff,0,size); 374 memset(buff,0,size);
@@ -366,9 +377,15 @@ int verify;
366 377
367#endif 378#endif
368 379
369static void pushsig() 380static void pushsig(void)
370 { 381 {
371 int i; 382 int i;
383#ifdef SIGACTION
384 struct sigaction sa;
385
386 memset(&sa,0,sizeof sa);
387 sa.sa_handler=recsig;
388#endif
372 389
373 for (i=1; i<NX509_SIG; i++) 390 for (i=1; i<NX509_SIG; i++)
374 { 391 {
@@ -381,7 +398,7 @@ static void pushsig()
381 continue; 398 continue;
382#endif 399#endif
383#ifdef SIGACTION 400#ifdef SIGACTION
384 sigaction(i,NULL,&savsig[i]); 401 sigaction(i,&sa,&savsig[i]);
385#else 402#else
386 savsig[i]=signal(i,recsig); 403 savsig[i]=signal(i,recsig);
387#endif 404#endif
@@ -392,7 +409,7 @@ static void pushsig()
392#endif 409#endif
393 } 410 }
394 411
395static void popsig() 412static void popsig(void)
396 { 413 {
397 int i; 414 int i;
398 415
@@ -414,8 +431,7 @@ static void popsig()
414 } 431 }
415 } 432 }
416 433
417static void recsig(i) 434static void recsig(int i)
418int i;
419 { 435 {
420 longjmp(save,1); 436 longjmp(save,1);
421#ifdef LINT 437#ifdef LINT
@@ -424,10 +440,7 @@ int i;
424 } 440 }
425 441
426#if defined(MSDOS) && !defined(WIN16) 442#if defined(MSDOS) && !defined(WIN16)
427static int noecho_fgets(buf,size,tty) 443static int noecho_fgets(char *buf, int size, FILE *tty)
428char *buf;
429int size;
430FILE *tty;
431 { 444 {
432 int i; 445 int i;
433 char *p; 446 char *p;
@@ -454,6 +467,18 @@ FILE *tty;
454 break; 467 break;
455 } 468 }
456 } 469 }
470#ifdef WIN_CONSOLE_BUG
471/* Win95 has several evil console bugs: one of these is that the
472 * last character read using getch() is passed to the next read: this is
473 * usually a CR so this can be trouble. No STDIO fix seems to work but
474 * flushing the console appears to do the trick.
475 */
476 {
477 HANDLE inh;
478 inh = GetStdHandle(STD_INPUT_HANDLE);
479 FlushConsoleInputBuffer(inh);
480 }
481#endif
457 return(strlen(buf)); 482 return(strlen(buf));
458 } 483 }
459#endif 484#endif
diff --git a/src/lib/libcrypto/des/rpc_enc.c b/src/lib/libcrypto/des/rpc_enc.c
index 7c1da1f538..c96c204147 100644
--- a/src/lib/libcrypto/des/rpc_enc.c
+++ b/src/lib/libcrypto/des/rpc_enc.c
@@ -60,32 +60,23 @@
60#include "des_locl.h" 60#include "des_locl.h"
61#include "des_ver.h" 61#include "des_ver.h"
62 62
63#ifndef NOPROTO
64int _des_crypt(char *buf,int len,struct desparams *desp); 63int _des_crypt(char *buf,int len,struct desparams *desp);
65#else 64int _des_crypt(char *buf, int len, struct desparams *desp)
66int _des_crypt();
67#endif
68
69int _des_crypt(buf, len, desp)
70char *buf;
71int len;
72struct desparams *desp;
73 { 65 {
74 des_key_schedule ks; 66 des_key_schedule ks;
75 int enc; 67 int enc;
76 68
77 des_set_key((des_cblock *)desp->des_key,ks); 69 des_set_key(&desp->des_key,ks);
78 enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT; 70 enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT;
79 71
80 if (desp->des_mode == CBC) 72 if (desp->des_mode == CBC)
81 des_ecb_encrypt((des_cblock *)desp->UDES.UDES_buf, 73 des_ecb_encrypt((const_des_cblock *)desp->UDES.UDES_buf,
82 (des_cblock *)desp->UDES.UDES_buf,ks,enc); 74 (des_cblock *)desp->UDES.UDES_buf,ks,
75 enc);
83 else 76 else
84 { 77 {
85 des_ncbc_encrypt((des_cblock *)desp->UDES.UDES_buf, 78 des_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,
86 (des_cblock *)desp->UDES.UDES_buf, 79 len,ks,&desp->des_ivec,enc);
87 (long)len,ks,
88 (des_cblock *)desp->des_ivec,enc);
89#ifdef undef 80#ifdef undef
90 /* len will always be %8 if called from common_crypt 81 /* len will always be %8 if called from common_crypt
91 * in secure_rpc. 82 * in secure_rpc.
diff --git a/src/lib/libcrypto/des/rpw.c b/src/lib/libcrypto/des/rpw.c
index 6447ed9cf0..0b6b1519b0 100644
--- a/src/lib/libcrypto/des/rpw.c
+++ b/src/lib/libcrypto/des/rpw.c
@@ -57,17 +57,15 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "des.h" 60#include <openssl/des.h>
61 61
62int main(argc,argv) 62int main(int argc, char *argv[])
63int argc;
64char *argv[];
65 { 63 {
66 des_cblock k,k1; 64 des_cblock k,k1;
67 int i; 65 int i;
68 66
69 printf("read passwd\n"); 67 printf("read passwd\n");
70 if ((i=des_read_password((C_Block *)k,"Enter password:",0)) == 0) 68 if ((i=des_read_password(&k,"Enter password:",0)) == 0)
71 { 69 {
72 printf("password = "); 70 printf("password = ");
73 for (i=0; i<8; i++) 71 for (i=0; i<8; i++)
@@ -77,7 +75,7 @@ char *argv[];
77 printf("error %d\n",i); 75 printf("error %d\n",i);
78 printf("\n"); 76 printf("\n");
79 printf("read 2passwds and verify\n"); 77 printf("read 2passwds and verify\n");
80 if ((i=des_read_2passwords((C_Block *)k,(C_Block *)k1, 78 if ((i=des_read_2passwords(&k,&k1,
81 "Enter verified password:",1)) == 0) 79 "Enter verified password:",1)) == 0)
82 { 80 {
83 printf("password1 = "); 81 printf("password1 = ");
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index c3bcd7ee2b..52553a4c16 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -67,16 +67,10 @@
67#include "podd.h" 67#include "podd.h"
68#include "sk.h" 68#include "sk.h"
69 69
70#ifndef NOPROTO 70static int check_parity(const_des_cblock *key);
71static int check_parity(des_cblock (*key)); 71OPENSSL_GLOBAL int des_check_key=0;
72#else
73static int check_parity();
74#endif
75 72
76int des_check_key=0; 73void des_set_odd_parity(des_cblock *key)
77
78void des_set_odd_parity(key)
79des_cblock (*key);
80 { 74 {
81 int i; 75 int i;
82 76
@@ -84,8 +78,7 @@ des_cblock (*key);
84 (*key)[i]=odd_parity[(*key)[i]]; 78 (*key)[i]=odd_parity[(*key)[i]];
85 } 79 }
86 80
87static int check_parity(key) 81static int check_parity(const_des_cblock *key)
88des_cblock (*key);
89 { 82 {
90 int i; 83 int i;
91 84
@@ -111,8 +104,8 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
111 /* weak keys */ 104 /* weak keys */
112 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, 105 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
113 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, 106 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
114 {0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}, 107 {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E},
115 {0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0}, 108 {0xE0,0xE0,0xE0,0xE0,0xF1,0xF1,0xF1,0xF1},
116 /* semi-weak keys */ 109 /* semi-weak keys */
117 {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE}, 110 {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE},
118 {0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01}, 111 {0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01},
@@ -127,8 +120,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
127 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, 120 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
128 {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; 121 {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
129 122
130int des_is_weak_key(key) 123int des_is_weak_key(const_des_cblock *key)
131des_cblock (*key);
132 { 124 {
133 int i; 125 int i;
134 126
@@ -157,13 +149,11 @@ des_cblock (*key);
157 * return -1 if key parity error, 149 * return -1 if key parity error,
158 * return -2 if illegal weak key. 150 * return -2 if illegal weak key.
159 */ 151 */
160int des_set_key(key, schedule) 152int des_set_key(const_des_cblock *key, des_key_schedule schedule)
161des_cblock (*key);
162des_key_schedule schedule;
163 { 153 {
164 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 154 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
165 register DES_LONG c,d,t,s,t2; 155 register DES_LONG c,d,t,s,t2;
166 register unsigned char *in; 156 register const unsigned char *in;
167 register DES_LONG *k; 157 register DES_LONG *k;
168 register int i; 158 register int i;
169 159
@@ -176,8 +166,8 @@ des_key_schedule schedule;
176 return(-2); 166 return(-2);
177 } 167 }
178 168
179 k=(DES_LONG *)schedule; 169 k = &schedule->ks.deslong[0];
180 in=(unsigned char *)key; 170 in = &(*key)[0];
181 171
182 c2l(in,c); 172 c2l(in,c);
183 c2l(in,d); 173 c2l(in,d);
@@ -238,9 +228,7 @@ des_key_schedule schedule;
238 return(0); 228 return(0);
239 } 229 }
240 230
241int des_key_sched(key, schedule) 231int des_key_sched(const_des_cblock *key, des_key_schedule schedule)
242des_cblock (*key);
243des_key_schedule schedule;
244 { 232 {
245 return(des_set_key(key,schedule)); 233 return(des_set_key(key,schedule));
246 } 234 }
diff --git a/src/lib/libcrypto/des/shifts.pl b/src/lib/libcrypto/des/shifts.pl
index d8a240c1ba..ba686d8ef5 100644
--- a/src/lib/libcrypto/des/shifts.pl
+++ b/src/lib/libcrypto/des/shifts.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3sub lab_shift 3sub lab_shift
4 { 4 {
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c
index 5bbe8b01d6..da41abcb03 100644
--- a/src/lib/libcrypto/des/speed.c
+++ b/src/lib/libcrypto/des/speed.c
@@ -59,19 +59,17 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#ifndef MSDOS 62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
66#include <stdio.h> 66#include <stdio.h>
67#ifndef MSDOS 67
68#include <unistd.h> 68#include <openssl/e_os2.h>
69#else 69#include OPENSSL_UNISTD_IO
70#include <io.h> 70OPENSSL_DECLARE_EXIT
71extern int exit(); 71
72#endif
73#include <signal.h> 72#include <signal.h>
74#ifndef VMS
75#ifndef _IRIX 73#ifndef _IRIX
76#include <time.h> 74#include <time.h>
77#endif 75#endif
@@ -79,35 +77,32 @@ extern int exit();
79#include <sys/types.h> 77#include <sys/types.h>
80#include <sys/times.h> 78#include <sys/times.h>
81#endif 79#endif
82#else /* VMS */ 80
83#include <types.h> 81/* Depending on the VMS version, the tms structure is perhaps defined.
84struct tms { 82 The __TMS macro will show if it was. If it wasn't defined, we should
85 time_t tms_utime; 83 undefine TIMES, since that tells the rest of the program how things
86 time_t tms_stime; 84 should be handled. -- Richard Levitte */
87 time_t tms_uchild; /* I dunno... */ 85#if defined(VMS) && defined(__DECC) && !defined(__TMS)
88 time_t tms_uchildsys; /* so these names are a guess :-) */ 86#undef TIMES
89 }
90#endif 87#endif
88
91#ifndef TIMES 89#ifndef TIMES
92#include <sys/timeb.h> 90#include <sys/timeb.h>
93#endif 91#endif
94 92
95#ifdef sun 93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
96#include <limits.h> 95#include <limits.h>
97#include <sys/param.h> 96#include <sys/param.h>
98#endif 97#endif
99 98
100#include "des.h" 99#include <openssl/des.h>
101 100
102/* The following if from times(3) man page. It may need to be changed */ 101/* The following if from times(3) man page. It may need to be changed */
103#ifndef HZ 102#ifndef HZ
104# ifndef CLK_TCK 103# ifndef CLK_TCK
105# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ 104# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
106# ifndef VMS 105# define HZ 100.0
107# define HZ 100.0
108# else /* VMS */
109# define HZ 100.0
110# endif
111# else /* _BSD_CLK_TCK_ */ 106# else /* _BSD_CLK_TCK_ */
112# define HZ ((double)_BSD_CLK_TCK_) 107# define HZ ((double)_BSD_CLK_TCK_)
113# endif 108# endif
@@ -119,12 +114,7 @@ struct tms {
119#define BUFSIZE ((long)1024) 114#define BUFSIZE ((long)1024)
120long run=0; 115long run=0;
121 116
122#ifndef NOPROTO
123double Time_F(int s); 117double Time_F(int s);
124#else
125double Time_F();
126#endif
127
128#ifdef SIGALRM 118#ifdef SIGALRM
129#if defined(__STDC__) || defined(sgi) || defined(_AIX) 119#if defined(__STDC__) || defined(sgi) || defined(_AIX)
130#define SIGRETTYPE void 120#define SIGRETTYPE void
@@ -132,14 +122,8 @@ double Time_F();
132#define SIGRETTYPE int 122#define SIGRETTYPE int
133#endif 123#endif
134 124
135#ifndef NOPROTO
136SIGRETTYPE sig_done(int sig); 125SIGRETTYPE sig_done(int sig);
137#else 126SIGRETTYPE sig_done(int sig)
138SIGRETTYPE sig_done();
139#endif
140
141SIGRETTYPE sig_done(sig)
142int sig;
143 { 127 {
144 signal(SIGALRM,sig_done); 128 signal(SIGALRM,sig_done);
145 run=0; 129 run=0;
@@ -152,8 +136,7 @@ int sig;
152#define START 0 136#define START 0
153#define STOP 1 137#define STOP 1
154 138
155double Time_F(s) 139double Time_F(int s)
156int s;
157 { 140 {
158 double ret; 141 double ret;
159#ifdef TIMES 142#ifdef TIMES
@@ -189,9 +172,7 @@ int s;
189#endif 172#endif
190 } 173 }
191 174
192int main(argc,argv) 175int main(int argc, char **argv)
193int argc;
194char **argv;
195 { 176 {
196 long count; 177 long count;
197 static unsigned char buf[BUFSIZE]; 178 static unsigned char buf[BUFSIZE];
@@ -209,12 +190,12 @@ char **argv;
209 printf("program when this computer is idle.\n"); 190 printf("program when this computer is idle.\n");
210#endif 191#endif
211 192
212 des_set_key((C_Block *)key2,sch2); 193 des_set_key(&key2,sch2);
213 des_set_key((C_Block *)key3,sch3); 194 des_set_key(&key3,sch3);
214 195
215#ifndef SIGALRM 196#ifndef SIGALRM
216 printf("First we calculate the approximate speed ...\n"); 197 printf("First we calculate the approximate speed ...\n");
217 des_set_key((C_Block *)key,sch); 198 des_set_key(&key,sch);
218 count=10; 199 count=10;
219 do { 200 do {
220 long i; 201 long i;
@@ -244,7 +225,7 @@ char **argv;
244 225
245 Time_F(START); 226 Time_F(START);
246 for (count=0,run=1; COND(ca); count++) 227 for (count=0,run=1; COND(ca); count++)
247 des_set_key((C_Block *)key,sch); 228 des_set_key(&key,sch);
248 d=Time_F(STOP); 229 d=Time_F(STOP);
249 printf("%ld set_key's in %.2f seconds\n",count,d); 230 printf("%ld set_key's in %.2f seconds\n",count,d);
250 a=((double)COUNT(ca))/d; 231 a=((double)COUNT(ca))/d;
@@ -276,8 +257,8 @@ char **argv;
276#endif 257#endif
277 Time_F(START); 258 Time_F(START);
278 for (count=0,run=1; COND(cc); count++) 259 for (count=0,run=1; COND(cc); count++)
279 des_ncbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]), 260 des_ncbc_encrypt(buf,buf,BUFSIZE,&(sch[0]),
280 (C_Block *)&(key[0]),DES_ENCRYPT); 261 &key,DES_ENCRYPT);
281 d=Time_F(STOP); 262 d=Time_F(STOP);
282 printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n", 263 printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n",
283 count,BUFSIZE,d); 264 count,BUFSIZE,d);
@@ -293,11 +274,11 @@ char **argv;
293#endif 274#endif
294 Time_F(START); 275 Time_F(START);
295 for (count=0,run=1; COND(cd); count++) 276 for (count=0,run=1; COND(cd); count++)
296 des_ede3_cbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE, 277 des_ede3_cbc_encrypt(buf,buf,BUFSIZE,
297 &(sch[0]), 278 &(sch[0]),
298 &(sch2[0]), 279 &(sch2[0]),
299 &(sch3[0]), 280 &(sch3[0]),
300 (C_Block *)&(key[0]), 281 &key,
301 DES_ENCRYPT); 282 DES_ENCRYPT);
302 d=Time_F(STOP); 283 d=Time_F(STOP);
303 printf("%ld des_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", 284 printf("%ld des_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n",
diff --git a/src/lib/libcrypto/des/spr.h b/src/lib/libcrypto/des/spr.h
index 81813f9f7a..b8fbdcf8d3 100644
--- a/src/lib/libcrypto/des/spr.h
+++ b/src/lib/libcrypto/des/spr.h
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59const DES_LONG des_SPtrans[8][64]={ 59OPENSSL_GLOBAL const DES_LONG des_SPtrans[8][64]={
60{ 60{
61/* nibble 0 */ 61/* nibble 0 */
620x02080800L, 0x00080000L, 0x02000002L, 0x02080802L, 620x02080800L, 0x00080000L, 0x02000002L, 0x02080802L,
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c
index 3365c1bcf3..24841452f1 100644
--- a/src/lib/libcrypto/des/str2key.c
+++ b/src/lib/libcrypto/des/str2key.c
@@ -58,11 +58,9 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61extern int des_check_key; 61OPENSSL_EXTERN int des_check_key;
62 62
63void des_string_to_key(str, key) 63void des_string_to_key(const char *str, des_cblock *key)
64char *str;
65des_cblock (*key);
66 { 64 {
67 des_key_schedule ks; 65 des_key_schedule ks;
68 int i,length; 66 int i,length;
@@ -89,21 +87,17 @@ des_cblock (*key);
89 } 87 }
90 } 88 }
91#endif 89#endif
92 des_set_odd_parity((des_cblock *)key); 90 des_set_odd_parity(key);
93 i=des_check_key; 91 i=des_check_key;
94 des_check_key=0; 92 des_check_key=0;
95 des_set_key((des_cblock *)key,ks); 93 des_set_key(key,ks);
96 des_check_key=i; 94 des_check_key=i;
97 des_cbc_cksum((des_cblock *)str,(des_cblock *)key,(long)length,ks, 95 des_cbc_cksum((unsigned char*)str,key,length,ks,key);
98 (des_cblock *)key);
99 memset(ks,0,sizeof(ks)); 96 memset(ks,0,sizeof(ks));
100 des_set_odd_parity((des_cblock *)key); 97 des_set_odd_parity(key);
101 } 98 }
102 99
103void des_string_to_2keys(str, key1, key2) 100void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2)
104char *str;
105des_cblock (*key1);
106des_cblock (*key2);
107 { 101 {
108 des_key_schedule ks; 102 des_key_schedule ks;
109 int i,length; 103 int i,length;
@@ -154,16 +148,14 @@ des_cblock (*key2);
154 } 148 }
155 if (length <= 8) memcpy(key2,key1,8); 149 if (length <= 8) memcpy(key2,key1,8);
156#endif 150#endif
157 des_set_odd_parity((des_cblock *)key1); 151 des_set_odd_parity(key1);
158 des_set_odd_parity((des_cblock *)key2); 152 des_set_odd_parity(key2);
159 i=des_check_key; 153 i=des_check_key;
160 des_check_key=0; 154 des_check_key=0;
161 des_set_key((des_cblock *)key1,ks); 155 des_set_key(key1,ks);
162 des_cbc_cksum((des_cblock *)str,(des_cblock *)key1,(long)length,ks, 156 des_cbc_cksum((unsigned char*)str,key1,length,ks,key1);
163 (des_cblock *)key1); 157 des_set_key(key2,ks);
164 des_set_key((des_cblock *)key2,ks); 158 des_cbc_cksum((unsigned char*)str,key2,length,ks,key2);
165 des_cbc_cksum((des_cblock *)str,(des_cblock *)key2,(long)length,ks,
166 (des_cblock *)key2);
167 des_check_key=i; 159 des_check_key=i;
168 memset(ks,0,sizeof(ks)); 160 memset(ks,0,sizeof(ks));
169 des_set_odd_parity(key1); 161 des_set_odd_parity(key1);
diff --git a/src/lib/libcrypto/des/supp.c b/src/lib/libcrypto/des/supp.c
index f8e5833f69..8c570c2586 100644
--- a/src/lib/libcrypto/des/supp.c
+++ b/src/lib/libcrypto/des/supp.c
@@ -87,18 +87,16 @@
87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 * SUCH DAMAGE. 88 * SUCH DAMAGE.
89 * 89 *
90 * $Id: supp.c,v 1.1.1.1 1998/10/05 20:12:45 ryker Exp $ 90 * $Id: supp.c,v 1.2 1999/09/29 04:36:01 beck Exp $
91 */ 91 */
92 92
93#include <stdio.h> 93#include <stdio.h>
94#include "des_locl.h" 94#include "des_locl.h"
95 95
96void des_cblock_print_file(cb, fp) 96void des_cblock_print_file(const_des_cblock *cb, FILE *fp)
97 des_cblock *cb;
98 FILE *fp;
99{ 97{
100 int i; 98 int i;
101 unsigned int *p = (unsigned int *)cb; 99 const unsigned int *p = (const unsigned int *)cb;
102 100
103 fprintf(fp, " 0x { "); 101 fprintf(fp, " 0x { ");
104 for (i = 0; i < 8; i++) { 102 for (i = 0; i < 8; i++) {
diff --git a/src/lib/libcrypto/des/testdes.pl b/src/lib/libcrypto/des/testdes.pl
index 67fbd47f36..01a165a963 100644
--- a/src/lib/libcrypto/des/testdes.pl
+++ b/src/lib/libcrypto/des/testdes.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3# des.pl tesing code 3# des.pl tesing code
4 4
diff --git a/src/lib/libcrypto/des/vms.com b/src/lib/libcrypto/des/vms.com
deleted file mode 100644
index 62ca1fbda4..0000000000
--- a/src/lib/libcrypto/des/vms.com
+++ /dev/null
@@ -1,90 +0,0 @@
1$! --- VMS.com ---
2$!
3$ GoSub defines
4$ GoSub linker_options
5$ If (P1 .nes. "")
6$ Then
7$ GoSub 'P1'
8$ Else
9$ GoSub lib
10$ GoSub destest
11$ GoSub rpw
12$ GoSub speed
13$ GoSub des
14$ EndIF
15$!
16$ Exit
17$!
18$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19$!
20$DEFINES:
21$ OPT_FILE := "VAX_LINKER_OPTIONS.OPT"
22$!
23$ CC_OPTS := "/NODebug/OPTimize/NOWarn"
24$!
25$ LINK_OPTS := "/NODebug/NOTraceback/Contiguous"
26$!
27$ OBJS = "cbc_cksm.obj,cbc_enc.obj,ecb_enc.obj,pcbc_enc.obj," + -
28 "qud_cksm.obj,rand_key.obj,read_pwd.obj,set_key.obj," + -
29 "str2key.obj,enc_read.obj,enc_writ.obj,fcrypt.obj," + -
30 "cfb_enc.obj,ecb3_enc.obj,ofb_enc.obj"
31
32
33$!
34$ LIBDES = "cbc_cksm.c,cbc_enc.c,ecb_enc.c,enc_read.c," + -
35 "enc_writ.c,pcbc_enc.c,qud_cksm.c,rand_key.c," + -
36 "read_pwd.c,set_key.c,str2key.c,fcrypt.c," + -
37 "cfb_enc.c,ecb3_enc.c,ofb_enc.c"
38$ Return
39$!
40$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41$!
42$LINKER_OPTIONS:
43$ If (f$search(OPT_FILE) .eqs. "")
44$ Then
45$ Create 'OPT_FILE'
46$DECK
47! Default system options file to link against the sharable C runtime library
48!
49Sys$Share:VAXcRTL.exe/Share
50$EOD
51$ EndIF
52$ Return
53$!
54$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
55$!
56$LIB:
57$ CC 'CC_OPTS' 'LIBDES'
58$ If (f$search("LIBDES.OLB") .nes. "")
59$ Then Library /Object /Replace libdes 'OBJS'
60$ Else Library /Create /Object libdes 'OBJS'
61$ EndIF
62$ Return
63$!
64$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
65$!
66$DESTEST:
67$ CC 'CC_OPTS' destest
68$ Link 'link_opts' /Exec=destest destest.obj,libdes/LIBRARY,'opt_file'/Option
69$ Return
70$!
71$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
72$!
73$RPW:
74$ CC 'CC_OPTS' rpw
75$ Link 'link_opts' /Exec=rpw rpw.obj,libdes/LIBRARY,'opt_file'/Option
76$ Return
77$!
78$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
79$!
80$SPEED:
81$ CC 'CC_OPTS' speed
82$ Link 'link_opts' /Exec=speed speed.obj,libdes/LIBRARY,'opt_file'/Option
83$ Return
84$!
85$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86$!
87$DES:
88$ CC 'CC_OPTS' des
89$ Link 'link_opts' /Exec=des des.obj,libdes/LIBRARY,'opt_file'/Option
90$ Return
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c
index 031589bf50..51e17e6b8a 100644
--- a/src/lib/libcrypto/des/xcbc_enc.c
+++ b/src/lib/libcrypto/des/xcbc_enc.c
@@ -79,18 +79,14 @@ static unsigned char desx_white_in2out[256]={
790xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, 790xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB,
80 }; 80 };
81 81
82void des_xwhite_in2out(des_key,in_white,out_white) 82void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white,
83des_cblock (*des_key); 83 des_cblock *out_white)
84des_cblock (*in_white);
85des_cblock (*out_white);
86 { 84 {
87 unsigned char *key,*in,*out;
88 int out0,out1; 85 int out0,out1;
89 int i; 86 int i;
90 87 const unsigned char *key = &(*des_key)[0];
91 key=(unsigned char *)des_key; 88 const unsigned char *in = &(*in_white)[0];
92 in=(unsigned char *)in_white; 89 unsigned char *out = &(*out_white)[0];
93 out=(unsigned char *)out_white;
94 90
95 out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; 91 out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0;
96 out0=out1=0; 92 out0=out1=0;
@@ -111,34 +107,26 @@ des_cblock (*out_white);
111 } 107 }
112 } 108 }
113 109
114void des_xcbc_encrypt(input, output, length, schedule, ivec, inw,outw,enc) 110void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
115des_cblock (*input); 111 long length, des_key_schedule schedule, des_cblock *ivec,
116des_cblock (*output); 112 const_des_cblock *inw, const_des_cblock *outw, int enc)
117long length;
118des_key_schedule schedule;
119des_cblock (*ivec);
120des_cblock (*inw);
121des_cblock (*outw);
122int enc;
123 { 113 {
124 register DES_LONG tin0,tin1; 114 register DES_LONG tin0,tin1;
125 register DES_LONG tout0,tout1,xor0,xor1; 115 register DES_LONG tout0,tout1,xor0,xor1;
126 register DES_LONG inW0,inW1,outW0,outW1; 116 register DES_LONG inW0,inW1,outW0,outW1;
127 register unsigned char *in,*out; 117 register const unsigned char *in2;
128 register long l=length; 118 register long l=length;
129 DES_LONG tin[2]; 119 DES_LONG tin[2];
130 unsigned char *iv; 120 unsigned char *iv;
131 121
132 in=(unsigned char *)inw; 122 in2 = &(*inw)[0];
133 c2l(in,inW0); 123 c2l(in2,inW0);
134 c2l(in,inW1); 124 c2l(in2,inW1);
135 in=(unsigned char *)outw; 125 in2 = &(*outw)[0];
136 c2l(in,outW0); 126 c2l(in2,outW0);
137 c2l(in,outW1); 127 c2l(in2,outW1);
138 128
139 in=(unsigned char *)input; 129 iv = &(*ivec)[0];
140 out=(unsigned char *)output;
141 iv=(unsigned char *)ivec;
142 130
143 if (enc) 131 if (enc)
144 { 132 {
@@ -150,7 +138,7 @@ int enc;
150 c2l(in,tin1); 138 c2l(in,tin1);
151 tin0^=tout0^inW0; tin[0]=tin0; 139 tin0^=tout0^inW0; tin[0]=tin0;
152 tin1^=tout1^inW1; tin[1]=tin1; 140 tin1^=tout1^inW1; tin[1]=tin1;
153 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); 141 des_encrypt(tin,schedule,DES_ENCRYPT);
154 tout0=tin[0]^outW0; l2c(tout0,out); 142 tout0=tin[0]^outW0; l2c(tout0,out);
155 tout1=tin[1]^outW1; l2c(tout1,out); 143 tout1=tin[1]^outW1; l2c(tout1,out);
156 } 144 }
@@ -159,11 +147,11 @@ int enc;
159 c2ln(in,tin0,tin1,l+8); 147 c2ln(in,tin0,tin1,l+8);
160 tin0^=tout0^inW0; tin[0]=tin0; 148 tin0^=tout0^inW0; tin[0]=tin0;
161 tin1^=tout1^inW1; tin[1]=tin1; 149 tin1^=tout1^inW1; tin[1]=tin1;
162 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); 150 des_encrypt(tin,schedule,DES_ENCRYPT);
163 tout0=tin[0]^outW0; l2c(tout0,out); 151 tout0=tin[0]^outW0; l2c(tout0,out);
164 tout1=tin[1]^outW1; l2c(tout1,out); 152 tout1=tin[1]^outW1; l2c(tout1,out);
165 } 153 }
166 iv=(unsigned char *)ivec; 154 iv = &(*ivec)[0];
167 l2c(tout0,iv); 155 l2c(tout0,iv);
168 l2c(tout1,iv); 156 l2c(tout1,iv);
169 } 157 }
@@ -175,7 +163,7 @@ int enc;
175 { 163 {
176 c2l(in,tin0); tin[0]=tin0^outW0; 164 c2l(in,tin0); tin[0]=tin0^outW0;
177 c2l(in,tin1); tin[1]=tin1^outW1; 165 c2l(in,tin1); tin[1]=tin1^outW1;
178 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); 166 des_encrypt(tin,schedule,DES_DECRYPT);
179 tout0=tin[0]^xor0^inW0; 167 tout0=tin[0]^xor0^inW0;
180 tout1=tin[1]^xor1^inW1; 168 tout1=tin[1]^xor1^inW1;
181 l2c(tout0,out); 169 l2c(tout0,out);
@@ -187,7 +175,7 @@ int enc;
187 { 175 {
188 c2l(in,tin0); tin[0]=tin0^outW0; 176 c2l(in,tin0); tin[0]=tin0^outW0;
189 c2l(in,tin1); tin[1]=tin1^outW1; 177 c2l(in,tin1); tin[1]=tin1^outW1;
190 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); 178 des_encrypt(tin,schedule,DES_DECRYPT);
191 tout0=tin[0]^xor0^inW0; 179 tout0=tin[0]^xor0^inW0;
192 tout1=tin[1]^xor1^inW1; 180 tout1=tin[1]^xor1^inW1;
193 l2cn(tout0,tout1,out,l+8); 181 l2cn(tout0,tout1,out,l+8);
@@ -195,7 +183,7 @@ int enc;
195 xor1=tin1; 183 xor1=tin1;
196 } 184 }
197 185
198 iv=(unsigned char *)ivec; 186 iv = &(*ivec)[0];
199 l2c(xor0,iv); 187 l2c(xor0,iv);
200 l2c(xor1,iv); 188 l2c(xor1,iv);
201 } 189 }