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.ssl316
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl5
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl282
-rw-r--r--src/lib/libcrypto/des/asm/des686.pl230
-rw-r--r--src/lib/libcrypto/des/des-lib.com66
-rw-r--r--src/lib/libcrypto/des/des_enc.c21
-rw-r--r--src/lib/libcrypto/des/des_lib.c106
-rw-r--r--src/lib/libcrypto/des/des_locl.h6
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c48
-rw-r--r--src/lib/libcrypto/des/enc_read.c12
-rw-r--r--src/lib/libcrypto/des/enc_writ.c4
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c4
-rw-r--r--src/lib/libcrypto/des/rpc_des.h4
-rw-r--r--src/lib/libcrypto/des/set_key.c13
-rw-r--r--src/lib/libcrypto/des/times/aix.cc4
-rw-r--r--src/lib/libcrypto/des/xcbc_enc.c2
16 files changed, 356 insertions, 767 deletions
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
deleted file mode 100644
index 0d9ba2b42f..0000000000
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ /dev/null
@@ -1,316 +0,0 @@
1#
2# SSLeay/crypto/des/Makefile
3#
4
5DIR= des
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=-I$(TOP) -I../../include
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19RANLIB= ranlib
20DES_ENC= des_enc.o fcrypt_b.o
21# or use
22#DES_ENC= dx86-elf.o yx86-elf.o
23
24CFLAGS= $(INCLUDES) $(CFLAG)
25ASFLAGS= $(INCLUDES) $(ASFLAG)
26
27GENERAL=Makefile
28TEST=destest.c
29APPS=
30
31LIB=$(TOP)/libcrypto.a
32LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
33 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
34 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
35 qud_cksm.c rand_key.c rpc_enc.c set_key.c \
36 des_enc.c fcrypt_b.c \
37 xcbc_enc.c \
38 str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c \
39 read2pwd.c
40
41LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
42 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
43 enc_read.o enc_writ.o ofb64enc.o \
44 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
45 ${DES_ENC} \
46 fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \
47 ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o
48
49SRC= $(LIBSRC)
50
51EXHEADER= des.h des_old.h
52HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER)
53
54ALL= $(GENERAL) $(SRC) $(HEADER)
55
56top:
57 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
58
59all: lib
60
61lib: $(LIBOBJ)
62 $(AR) $(LIB) $(LIBOBJ)
63 $(RANLIB) $(LIB) || echo Never mind.
64 @touch lib
65
66des: des.o cbc3_enc.o lib
67 $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
68
69# elf
70asm/dx86-elf.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
71 (cd asm; $(PERL) des-586.pl elf $(CFLAGS) > dx86-elf.s)
72
73asm/yx86-elf.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
74 (cd asm; $(PERL) crypt586.pl elf $(CFLAGS) > yx86-elf.s)
75
76# a.out
77asm/dx86-out.o: asm/dx86unix.cpp
78 $(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
79
80asm/yx86-out.o: asm/yx86unix.cpp
81 $(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o
82
83# bsdi
84asm/dx86bsdi.o: asm/dx86unix.cpp
85 $(CPP) -DBSDI asm/dx86unix.cpp | sed 's/ :/:/' | as -o asm/dx86bsdi.o
86
87asm/yx86bsdi.o: asm/yx86unix.cpp
88 $(CPP) -DBSDI asm/yx86unix.cpp | sed 's/ :/:/' | as -o asm/yx86bsdi.o
89
90asm/dx86unix.cpp: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
91 (cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp)
92
93asm/yx86unix.cpp: asm/crypt586.pl ../perlasm/x86asm.pl
94 (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp)
95
96files:
97 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
98
99links:
100 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
101 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
102 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
103 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
104
105install: installs
106
107installs:
108 @for i in $(EXHEADER) ; \
109 do \
110 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
111 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
112 done;
113
114tags:
115 ctags $(SRC)
116
117tests:
118
119lint:
120 lint -DLINT $(INCLUDES) $(SRC)>fluff
121
122depend:
123 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
124
125dclean:
126 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
127 mv -f Makefile.new $(MAKEFILE)
128
129clean:
130 rm -f asm/dx86unix.cpp asm/yx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
131
132# DO NOT DELETE THIS LINE -- make depend depends on it.
133
134cbc_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
135cbc_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
136cbc_cksm.o: ../../include/openssl/opensslconf.h
137cbc_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
138cbc_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
139cbc_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
140cbc_cksm.o: cbc_cksm.c des_locl.h
141cbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
142cbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
143cbc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
144cbc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
145cbc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
146cbc_enc.o: ../../include/openssl/ui_compat.h cbc_enc.c des_locl.h ncbc_enc.c
147cfb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
148cfb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
149cfb64ede.o: ../../include/openssl/opensslconf.h
150cfb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
151cfb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
152cfb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
153cfb64ede.o: cfb64ede.c des_locl.h
154cfb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
155cfb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
156cfb64enc.o: ../../include/openssl/opensslconf.h
157cfb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
158cfb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
159cfb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
160cfb64enc.o: cfb64enc.c des_locl.h
161cfb_enc.o: ../../e_os.h ../../include/openssl/crypto.h
162cfb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
163cfb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
164cfb_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
165cfb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
166cfb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
167cfb_enc.o: cfb_enc.c des_locl.h
168des_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
169des_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
170des_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
171des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
172des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
173des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h ncbc_enc.c
174des_old.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
175des_old.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
176des_old.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
177des_old.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
178des_old.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
179des_old.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
180des_old.o: ../../include/openssl/ui_compat.h des_old.c
181des_old2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
182des_old2.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
183des_old2.o: ../../include/openssl/opensslconf.h
184des_old2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
185des_old2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
186des_old2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
187des_old2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
188des_old2.o: des_old2.c
189ecb3_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
190ecb3_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
191ecb3_enc.o: ../../include/openssl/opensslconf.h
192ecb3_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
193ecb3_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
194ecb3_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
195ecb3_enc.o: des_locl.h ecb3_enc.c
196ecb_enc.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
197ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
198ecb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
199ecb_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
200ecb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
201ecb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
202ecb_enc.o: des_locl.h des_ver.h ecb_enc.c spr.h
203ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
204ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
205ede_cbcm_enc.o: ../../include/openssl/opensslconf.h
206ede_cbcm_enc.o: ../../include/openssl/opensslv.h
207ede_cbcm_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
208ede_cbcm_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
209ede_cbcm_enc.o: ../../include/openssl/ui_compat.h des_locl.h ede_cbcm_enc.c
210enc_read.o: ../../e_os.h ../../include/openssl/bio.h
211enc_read.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
212enc_read.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
213enc_read.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
214enc_read.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
215enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
216enc_read.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
217enc_read.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
218enc_read.o: ../cryptlib.h des_locl.h enc_read.c
219enc_writ.o: ../../e_os.h ../../include/openssl/bio.h
220enc_writ.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
221enc_writ.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
222enc_writ.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
223enc_writ.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
224enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
225enc_writ.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
226enc_writ.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
227enc_writ.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
228enc_writ.o: ../cryptlib.h des_locl.h enc_writ.c
229fcrypt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
230fcrypt.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
231fcrypt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
232fcrypt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
233fcrypt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
234fcrypt.o: ../../include/openssl/ui_compat.h des_locl.h fcrypt.c
235fcrypt_b.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
236fcrypt_b.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
237fcrypt_b.o: ../../include/openssl/opensslconf.h
238fcrypt_b.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
239fcrypt_b.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
240fcrypt_b.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
241fcrypt_b.o: des_locl.h fcrypt_b.c
242ofb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
243ofb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
244ofb64ede.o: ../../include/openssl/opensslconf.h
245ofb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
246ofb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
247ofb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
248ofb64ede.o: des_locl.h ofb64ede.c
249ofb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
250ofb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
251ofb64enc.o: ../../include/openssl/opensslconf.h
252ofb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
253ofb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
254ofb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
255ofb64enc.o: des_locl.h ofb64enc.c
256ofb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
257ofb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
258ofb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
259ofb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
260ofb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
261ofb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ofb_enc.c
262pcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
263pcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
264pcbc_enc.o: ../../include/openssl/opensslconf.h
265pcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
266pcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
267pcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
268pcbc_enc.o: des_locl.h pcbc_enc.c
269qud_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
270qud_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
271qud_cksm.o: ../../include/openssl/opensslconf.h
272qud_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
273qud_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
274qud_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
275qud_cksm.o: des_locl.h qud_cksm.c
276rand_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
277rand_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
278rand_key.o: ../../include/openssl/opensslconf.h
279rand_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
280rand_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
281rand_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
282rand_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
283rand_key.o: rand_key.c
284read2pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
285read2pwd.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
286read2pwd.o: ../../include/openssl/opensslconf.h
287read2pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
288read2pwd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
289read2pwd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
290read2pwd.o: read2pwd.c
291rpc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
292rpc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
293rpc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
294rpc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
295rpc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
296rpc_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h rpc_des.h
297rpc_enc.o: rpc_enc.c
298set_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
299set_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
300set_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
301set_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
302set_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
303set_key.o: ../../include/openssl/ui_compat.h des_locl.h set_key.c
304str2key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
305str2key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
306str2key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
307str2key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
308str2key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
309str2key.o: ../../include/openssl/ui_compat.h des_locl.h str2key.c
310xcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
311xcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
312xcbc_enc.o: ../../include/openssl/opensslconf.h
313xcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
314xcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
315xcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
316xcbc_enc.o: des_locl.h xcbc_enc.c
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl
index 1d04ed6def..e36f7d44bd 100644
--- a/src/lib/libcrypto/des/asm/crypt586.pl
+++ b/src/lib/libcrypto/des/asm/crypt586.pl
@@ -6,7 +6,8 @@
6# things perfect. 6# things perfect.
7# 7#
8 8
9push(@INC,"perlasm","../../perlasm"); 9$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
10push(@INC,"${dir}","${dir}../../perlasm");
10require "x86asm.pl"; 11require "x86asm.pl";
11 12
12&asm_init($ARGV[0],"crypt586.pl"); 13&asm_init($ARGV[0],"crypt586.pl");
@@ -22,7 +23,7 @@ sub fcrypt_body
22 { 23 {
23 local($name,$do_ip)=@_; 24 local($name,$do_ip)=@_;
24 25
25 &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); 26 &function_begin($name);
26 27
27 &comment(""); 28 &comment("");
28 &comment("Load the 2 words"); 29 &comment("Load the 2 words");
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
index 60d577cc8d..5b5f39cebd 100644
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ b/src/lib/libcrypto/des/asm/des-586.pl
@@ -4,7 +4,8 @@
4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> 4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
5# 5#
6 6
7push(@INC,"perlasm","../../perlasm"); 7$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
8push(@INC,"${dir}","${dir}../../perlasm");
8require "x86asm.pl"; 9require "x86asm.pl";
9require "cbc.pl"; 10require "cbc.pl";
10require "desboth.pl"; 11require "desboth.pl";
@@ -18,33 +19,110 @@ require "desboth.pl";
18 19
19$L="edi"; 20$L="edi";
20$R="esi"; 21$R="esi";
22$trans="ebp";
23$small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV));
24# one can discuss setting this variable to 1 unconditionally, as
25# the folded loop is only 3% slower than unrolled, but >7 times smaller
21 26
22&external_label("DES_SPtrans"); 27&public_label("DES_SPtrans");
28
29&DES_encrypt_internal();
30&DES_decrypt_internal();
23&DES_encrypt("DES_encrypt1",1); 31&DES_encrypt("DES_encrypt1",1);
24&DES_encrypt("DES_encrypt2",0); 32&DES_encrypt("DES_encrypt2",0);
33&DES_encrypt3("DES_encrypt3",1);
34&DES_encrypt3("DES_decrypt3",0);
35&cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1);
36&cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5);
37&DES_SPtrans();
38
39&asm_finish();
25 40
26if (!$main'openbsd) 41sub DES_encrypt_internal()
27 { 42 {
28 &DES_encrypt3("DES_encrypt3",1); 43 &function_begin_B("_x86_DES_encrypt");
29 &DES_encrypt3("DES_decrypt3",0); 44
30 &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); 45 if ($small_footprint)
31 &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); 46 {
47 &lea("edx",&DWP(128,"ecx"));
48 &push("edx");
49 &push("ecx");
50 &set_label("eloop");
51 &D_ENCRYPT(0,$L,$R,0,$trans,"eax","ebx","ecx","edx",&swtmp(0));
52 &comment("");
53 &D_ENCRYPT(1,$R,$L,2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
54 &comment("");
55 &add("ecx",16);
56 &cmp("ecx",&swtmp(1));
57 &mov(&swtmp(0),"ecx");
58 &jb(&label("eloop"));
59 &add("esp",8);
60 }
61 else
62 {
63 &push("ecx");
64 for ($i=0; $i<16; $i+=2)
65 {
66 &comment("Round $i");
67 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
68 &comment("Round ".sprintf("%d",$i+1));
69 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
70 }
71 &add("esp",4);
32 } 72 }
73 &ret();
33 74
34&asm_finish(); 75 &function_end_B("_x86_DES_encrypt");
76 }
77
78sub DES_decrypt_internal()
79 {
80 &function_begin_B("_x86_DES_decrypt");
81
82 if ($small_footprint)
83 {
84 &push("ecx");
85 &lea("ecx",&DWP(128,"ecx"));
86 &push("ecx");
87 &set_label("dloop");
88 &D_ENCRYPT(0,$L,$R,-2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
89 &comment("");
90 &D_ENCRYPT(1,$R,$L,-4,$trans,"eax","ebx","ecx","edx",&swtmp(0));
91 &comment("");
92 &sub("ecx",16);
93 &cmp("ecx",&swtmp(1));
94 &mov(&swtmp(0),"ecx");
95 &ja(&label("dloop"));
96 &add("esp",8);
97 }
98 else
99 {
100 &push("ecx");
101 for ($i=15; $i>0; $i-=2)
102 {
103 &comment("Round $i");
104 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
105 &comment("Round ".sprintf("%d",$i-1));
106 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
107 }
108 &add("esp",4);
109 }
110 &ret();
35 111
112 &function_end_B("_x86_DES_decrypt");
113 }
114
36sub DES_encrypt 115sub DES_encrypt
37 { 116 {
38 local($name,$do_ip)=@_; 117 local($name,$do_ip)=@_;
39 118
40 &function_begin_B($name,"EXTRN _DES_SPtrans:DWORD"); 119 &function_begin_B($name);
41 120
42 &push("esi"); 121 &push("esi");
43 &push("edi"); 122 &push("edi");
44 123
45 &comment(""); 124 &comment("");
46 &comment("Load the 2 words"); 125 &comment("Load the 2 words");
47 $trans="ebp";
48 126
49 if ($do_ip) 127 if ($do_ip)
50 { 128 {
@@ -77,39 +155,20 @@ sub DES_encrypt
77 } 155 }
78 156
79 # PIC-ification:-) 157 # PIC-ification:-)
80 &picmeup($trans,"DES_SPtrans"); 158 &call (&label("pic_point"));
81 #if ($cpp) { &picmeup($trans,"DES_SPtrans"); } 159 &set_label("pic_point");
82 #else { &lea($trans,&DWP("DES_SPtrans")); } 160 &blindpop($trans);
161 &lea ($trans,&DWP(&label("DES_SPtrans")."-".&label("pic_point"),$trans));
83 162
84 &mov( "ecx", &wparam(1) ); 163 &mov( "ecx", &wparam(1) );
85 &cmp("ebx","0");
86 &je(&label("start_decrypt"));
87
88 for ($i=0; $i<16; $i+=2)
89 {
90 &comment("");
91 &comment("Round $i");
92 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
93
94 &comment("");
95 &comment("Round ".sprintf("%d",$i+1));
96 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx");
97 }
98 &jmp(&label("end"));
99 164
100 &set_label("start_decrypt"); 165 &cmp("ebx","0");
101 166 &je(&label("decrypt"));
102 for ($i=15; $i>0; $i-=2) 167 &call("_x86_DES_encrypt");
103 { 168 &jmp(&label("done"));
104 &comment(""); 169 &set_label("decrypt");
105 &comment("Round $i"); 170 &call("_x86_DES_decrypt");
106 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); 171 &set_label("done");
107 &comment("");
108 &comment("Round ".sprintf("%d",$i-1));
109 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx");
110 }
111
112 &set_label("end");
113 172
114 if ($do_ip) 173 if ($do_ip)
115 { 174 {
@@ -143,7 +202,7 @@ sub DES_encrypt
143 202
144sub D_ENCRYPT 203sub D_ENCRYPT
145 { 204 {
146 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_; 205 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t,$wp1)=@_;
147 206
148 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0)); 207 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0));
149 &xor( $tmp1, $tmp1); 208 &xor( $tmp1, $tmp1);
@@ -170,7 +229,7 @@ sub D_ENCRYPT
170 &and( $t, "0xff" ); 229 &and( $t, "0xff" );
171 &xor( $L, &DWP("0x600",$trans,$tmp1,0)); 230 &xor( $L, &DWP("0x600",$trans,$tmp1,0));
172 &xor( $L, &DWP("0x700",$trans,$tmp2,0)); 231 &xor( $L, &DWP("0x700",$trans,$tmp2,0));
173 &mov( $tmp2, &wparam(1) ); 232 &mov( $tmp2, $wp1 );
174 &xor( $L, &DWP("0x400",$trans,$u,0)); 233 &xor( $L, &DWP("0x400",$trans,$u,0));
175 &xor( $L, &DWP("0x500",$trans,$t,0)); 234 &xor( $L, &DWP("0x500",$trans,$t,0));
176 } 235 }
@@ -253,3 +312,142 @@ sub FP_new
253 &rotr($tt , 4); 312 &rotr($tt , 4);
254 } 313 }
255 314
315sub DES_SPtrans
316 {
317 &set_label("DES_SPtrans",64);
318 &data_word(0x02080800, 0x00080000, 0x02000002, 0x02080802);
319 &data_word(0x02000000, 0x00080802, 0x00080002, 0x02000002);
320 &data_word(0x00080802, 0x02080800, 0x02080000, 0x00000802);
321 &data_word(0x02000802, 0x02000000, 0x00000000, 0x00080002);
322 &data_word(0x00080000, 0x00000002, 0x02000800, 0x00080800);
323 &data_word(0x02080802, 0x02080000, 0x00000802, 0x02000800);
324 &data_word(0x00000002, 0x00000800, 0x00080800, 0x02080002);
325 &data_word(0x00000800, 0x02000802, 0x02080002, 0x00000000);
326 &data_word(0x00000000, 0x02080802, 0x02000800, 0x00080002);
327 &data_word(0x02080800, 0x00080000, 0x00000802, 0x02000800);
328 &data_word(0x02080002, 0x00000800, 0x00080800, 0x02000002);
329 &data_word(0x00080802, 0x00000002, 0x02000002, 0x02080000);
330 &data_word(0x02080802, 0x00080800, 0x02080000, 0x02000802);
331 &data_word(0x02000000, 0x00000802, 0x00080002, 0x00000000);
332 &data_word(0x00080000, 0x02000000, 0x02000802, 0x02080800);
333 &data_word(0x00000002, 0x02080002, 0x00000800, 0x00080802);
334 # nibble 1
335 &data_word(0x40108010, 0x00000000, 0x00108000, 0x40100000);
336 &data_word(0x40000010, 0x00008010, 0x40008000, 0x00108000);
337 &data_word(0x00008000, 0x40100010, 0x00000010, 0x40008000);
338 &data_word(0x00100010, 0x40108000, 0x40100000, 0x00000010);
339 &data_word(0x00100000, 0x40008010, 0x40100010, 0x00008000);
340 &data_word(0x00108010, 0x40000000, 0x00000000, 0x00100010);
341 &data_word(0x40008010, 0x00108010, 0x40108000, 0x40000010);
342 &data_word(0x40000000, 0x00100000, 0x00008010, 0x40108010);
343 &data_word(0x00100010, 0x40108000, 0x40008000, 0x00108010);
344 &data_word(0x40108010, 0x00100010, 0x40000010, 0x00000000);
345 &data_word(0x40000000, 0x00008010, 0x00100000, 0x40100010);
346 &data_word(0x00008000, 0x40000000, 0x00108010, 0x40008010);
347 &data_word(0x40108000, 0x00008000, 0x00000000, 0x40000010);
348 &data_word(0x00000010, 0x40108010, 0x00108000, 0x40100000);
349 &data_word(0x40100010, 0x00100000, 0x00008010, 0x40008000);
350 &data_word(0x40008010, 0x00000010, 0x40100000, 0x00108000);
351 # nibble 2
352 &data_word(0x04000001, 0x04040100, 0x00000100, 0x04000101);
353 &data_word(0x00040001, 0x04000000, 0x04000101, 0x00040100);
354 &data_word(0x04000100, 0x00040000, 0x04040000, 0x00000001);
355 &data_word(0x04040101, 0x00000101, 0x00000001, 0x04040001);
356 &data_word(0x00000000, 0x00040001, 0x04040100, 0x00000100);
357 &data_word(0x00000101, 0x04040101, 0x00040000, 0x04000001);
358 &data_word(0x04040001, 0x04000100, 0x00040101, 0x04040000);
359 &data_word(0x00040100, 0x00000000, 0x04000000, 0x00040101);
360 &data_word(0x04040100, 0x00000100, 0x00000001, 0x00040000);
361 &data_word(0x00000101, 0x00040001, 0x04040000, 0x04000101);
362 &data_word(0x00000000, 0x04040100, 0x00040100, 0x04040001);
363 &data_word(0x00040001, 0x04000000, 0x04040101, 0x00000001);
364 &data_word(0x00040101, 0x04000001, 0x04000000, 0x04040101);
365 &data_word(0x00040000, 0x04000100, 0x04000101, 0x00040100);
366 &data_word(0x04000100, 0x00000000, 0x04040001, 0x00000101);
367 &data_word(0x04000001, 0x00040101, 0x00000100, 0x04040000);
368 # nibble 3
369 &data_word(0x00401008, 0x10001000, 0x00000008, 0x10401008);
370 &data_word(0x00000000, 0x10400000, 0x10001008, 0x00400008);
371 &data_word(0x10401000, 0x10000008, 0x10000000, 0x00001008);
372 &data_word(0x10000008, 0x00401008, 0x00400000, 0x10000000);
373 &data_word(0x10400008, 0x00401000, 0x00001000, 0x00000008);
374 &data_word(0x00401000, 0x10001008, 0x10400000, 0x00001000);
375 &data_word(0x00001008, 0x00000000, 0x00400008, 0x10401000);
376 &data_word(0x10001000, 0x10400008, 0x10401008, 0x00400000);
377 &data_word(0x10400008, 0x00001008, 0x00400000, 0x10000008);
378 &data_word(0x00401000, 0x10001000, 0x00000008, 0x10400000);
379 &data_word(0x10001008, 0x00000000, 0x00001000, 0x00400008);
380 &data_word(0x00000000, 0x10400008, 0x10401000, 0x00001000);
381 &data_word(0x10000000, 0x10401008, 0x00401008, 0x00400000);
382 &data_word(0x10401008, 0x00000008, 0x10001000, 0x00401008);
383 &data_word(0x00400008, 0x00401000, 0x10400000, 0x10001008);
384 &data_word(0x00001008, 0x10000000, 0x10000008, 0x10401000);
385 # nibble 4
386 &data_word(0x08000000, 0x00010000, 0x00000400, 0x08010420);
387 &data_word(0x08010020, 0x08000400, 0x00010420, 0x08010000);
388 &data_word(0x00010000, 0x00000020, 0x08000020, 0x00010400);
389 &data_word(0x08000420, 0x08010020, 0x08010400, 0x00000000);
390 &data_word(0x00010400, 0x08000000, 0x00010020, 0x00000420);
391 &data_word(0x08000400, 0x00010420, 0x00000000, 0x08000020);
392 &data_word(0x00000020, 0x08000420, 0x08010420, 0x00010020);
393 &data_word(0x08010000, 0x00000400, 0x00000420, 0x08010400);
394 &data_word(0x08010400, 0x08000420, 0x00010020, 0x08010000);
395 &data_word(0x00010000, 0x00000020, 0x08000020, 0x08000400);
396 &data_word(0x08000000, 0x00010400, 0x08010420, 0x00000000);
397 &data_word(0x00010420, 0x08000000, 0x00000400, 0x00010020);
398 &data_word(0x08000420, 0x00000400, 0x00000000, 0x08010420);
399 &data_word(0x08010020, 0x08010400, 0x00000420, 0x00010000);
400 &data_word(0x00010400, 0x08010020, 0x08000400, 0x00000420);
401 &data_word(0x00000020, 0x00010420, 0x08010000, 0x08000020);
402 # nibble 5
403 &data_word(0x80000040, 0x00200040, 0x00000000, 0x80202000);
404 &data_word(0x00200040, 0x00002000, 0x80002040, 0x00200000);
405 &data_word(0x00002040, 0x80202040, 0x00202000, 0x80000000);
406 &data_word(0x80002000, 0x80000040, 0x80200000, 0x00202040);
407 &data_word(0x00200000, 0x80002040, 0x80200040, 0x00000000);
408 &data_word(0x00002000, 0x00000040, 0x80202000, 0x80200040);
409 &data_word(0x80202040, 0x80200000, 0x80000000, 0x00002040);
410 &data_word(0x00000040, 0x00202000, 0x00202040, 0x80002000);
411 &data_word(0x00002040, 0x80000000, 0x80002000, 0x00202040);
412 &data_word(0x80202000, 0x00200040, 0x00000000, 0x80002000);
413 &data_word(0x80000000, 0x00002000, 0x80200040, 0x00200000);
414 &data_word(0x00200040, 0x80202040, 0x00202000, 0x00000040);
415 &data_word(0x80202040, 0x00202000, 0x00200000, 0x80002040);
416 &data_word(0x80000040, 0x80200000, 0x00202040, 0x00000000);
417 &data_word(0x00002000, 0x80000040, 0x80002040, 0x80202000);
418 &data_word(0x80200000, 0x00002040, 0x00000040, 0x80200040);
419 # nibble 6
420 &data_word(0x00004000, 0x00000200, 0x01000200, 0x01000004);
421 &data_word(0x01004204, 0x00004004, 0x00004200, 0x00000000);
422 &data_word(0x01000000, 0x01000204, 0x00000204, 0x01004000);
423 &data_word(0x00000004, 0x01004200, 0x01004000, 0x00000204);
424 &data_word(0x01000204, 0x00004000, 0x00004004, 0x01004204);
425 &data_word(0x00000000, 0x01000200, 0x01000004, 0x00004200);
426 &data_word(0x01004004, 0x00004204, 0x01004200, 0x00000004);
427 &data_word(0x00004204, 0x01004004, 0x00000200, 0x01000000);
428 &data_word(0x00004204, 0x01004000, 0x01004004, 0x00000204);
429 &data_word(0x00004000, 0x00000200, 0x01000000, 0x01004004);
430 &data_word(0x01000204, 0x00004204, 0x00004200, 0x00000000);
431 &data_word(0x00000200, 0x01000004, 0x00000004, 0x01000200);
432 &data_word(0x00000000, 0x01000204, 0x01000200, 0x00004200);
433 &data_word(0x00000204, 0x00004000, 0x01004204, 0x01000000);
434 &data_word(0x01004200, 0x00000004, 0x00004004, 0x01004204);
435 &data_word(0x01000004, 0x01004200, 0x01004000, 0x00004004);
436 # nibble 7
437 &data_word(0x20800080, 0x20820000, 0x00020080, 0x00000000);
438 &data_word(0x20020000, 0x00800080, 0x20800000, 0x20820080);
439 &data_word(0x00000080, 0x20000000, 0x00820000, 0x00020080);
440 &data_word(0x00820080, 0x20020080, 0x20000080, 0x20800000);
441 &data_word(0x00020000, 0x00820080, 0x00800080, 0x20020000);
442 &data_word(0x20820080, 0x20000080, 0x00000000, 0x00820000);
443 &data_word(0x20000000, 0x00800000, 0x20020080, 0x20800080);
444 &data_word(0x00800000, 0x00020000, 0x20820000, 0x00000080);
445 &data_word(0x00800000, 0x00020000, 0x20000080, 0x20820080);
446 &data_word(0x00020080, 0x20000000, 0x00000000, 0x00820000);
447 &data_word(0x20800080, 0x20020080, 0x20020000, 0x00800080);
448 &data_word(0x20820000, 0x00000080, 0x00800080, 0x20020000);
449 &data_word(0x20820080, 0x00800000, 0x20800000, 0x20000080);
450 &data_word(0x00820000, 0x00020080, 0x20020080, 0x20800000);
451 &data_word(0x00000080, 0x20820000, 0x00820080, 0x00000000);
452 &data_word(0x20000000, 0x20800080, 0x00020000, 0x00820080);
453 }
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl
deleted file mode 100644
index d3ad5d5edd..0000000000
--- a/src/lib/libcrypto/des/asm/des686.pl
+++ /dev/null
@@ -1,230 +0,0 @@
1#!/usr/local/bin/perl
2
3$prog="des686.pl";
4
5# base code is in microsft
6# op dest, source
7# format.
8#
9
10# WILL NOT WORK ANYMORE WITH desboth.pl
11require "desboth.pl";
12
13if ( ($ARGV[0] eq "elf"))
14 { require "x86unix.pl"; }
15elsif ( ($ARGV[0] eq "a.out"))
16 { $aout=1; require "x86unix.pl"; }
17elsif ( ($ARGV[0] eq "sol"))
18 { $sol=1; require "x86unix.pl"; }
19elsif ( ($ARGV[0] eq "cpp"))
20 { $cpp=1; require "x86unix.pl"; }
21elsif ( ($ARGV[0] eq "win32"))
22 { require "x86ms.pl"; }
23else
24 {
25 print STDERR <<"EOF";
26Pick one target type from
27 elf - linux, FreeBSD etc
28 a.out - old linux
29 sol - x86 solaris
30 cpp - format so x86unix.cpp can be used
31 win32 - Windows 95/Windows NT
32EOF
33 exit(1);
34 }
35
36&comment("Don't even think of reading this code");
37&comment("It was automatically generated by $prog");
38&comment("Which is a perl program used to generate the x86 assember for");
39&comment("any of elf, a.out, Win32, or Solaris");
40&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
41&comment("eric <eay\@cryptsoft.com>");
42&comment("");
43
44&file("dx86xxxx");
45
46$L="edi";
47$R="esi";
48
49&DES_encrypt("DES_encrypt1",1);
50&DES_encrypt("DES_encrypt2",0);
51
52&DES_encrypt3("DES_encrypt3",1);
53&DES_encrypt3("DES_decrypt3",0);
54
55&file_end();
56
57sub DES_encrypt
58 {
59 local($name,$do_ip)=@_;
60
61 &function_begin($name,"EXTRN _DES_SPtrans:DWORD");
62
63 &comment("");
64 &comment("Load the 2 words");
65 &mov("eax",&wparam(0));
66 &mov($L,&DWP(0,"eax","",0));
67 &mov($R,&DWP(4,"eax","",0));
68
69 $ksp=&wparam(1);
70
71 if ($do_ip)
72 {
73 &comment("");
74 &comment("IP");
75 &IP_new($L,$R,"eax");
76 }
77
78 &comment("");
79 &comment("fixup rotate");
80 &rotl($R,3);
81 &rotl($L,3);
82 &exch($L,$R);
83
84 &comment("");
85 &comment("load counter, key_schedule and enc flag");
86 &mov("eax",&wparam(2)); # get encrypt flag
87 &mov("ebp",&wparam(1)); # get ks
88 &cmp("eax","0");
89 &je(&label("start_decrypt"));
90
91 # encrypting part
92
93 for ($i=0; $i<16; $i+=2)
94 {
95 &comment("");
96 &comment("Round $i");
97 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
98
99 &comment("");
100 &comment("Round ".sprintf("%d",$i+1));
101 &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
102 }
103 &jmp(&label("end"));
104
105 &set_label("start_decrypt");
106
107 for ($i=15; $i>0; $i-=2)
108 {
109 &comment("");
110 &comment("Round $i");
111 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
112 &comment("");
113 &comment("Round ".sprintf("%d",$i-1));
114 &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
115 }
116
117 &set_label("end");
118
119 &comment("");
120 &comment("Fixup");
121 &rotr($L,3); # r
122 &rotr($R,3); # l
123
124 if ($do_ip)
125 {
126 &comment("");
127 &comment("FP");
128 &FP_new($R,$L,"eax");
129 }
130
131 &mov("eax",&wparam(0));
132 &mov(&DWP(0,"eax","",0),$L);
133 &mov(&DWP(4,"eax","",0),$R);
134
135 &function_end($name);
136 }
137
138
139# The logic is to load R into 2 registers and operate on both at the same time.
140# We also load the 2 R's into 2 more registers so we can do the 'move word down a byte'
141# while also masking the other copy and doing a lookup. We then also accumulate the
142# L value in 2 registers then combine them at the end.
143sub D_ENCRYPT
144 {
145 local($L,$R,$S,$ks,$desSP,$u,$t,$tmp1,$tmp2,$tmp3)=@_;
146
147 &mov( $u, &DWP(&n2a($S*4),$ks,"",0));
148 &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
149 &xor( $u, $R );
150 &xor( $t, $R );
151 &rotr( $t, 4 );
152
153 # the numbers at the end of the line are origional instruction order
154 &mov( $tmp2, $u ); # 1 2
155 &mov( $tmp1, $t ); # 1 1
156 &and( $tmp2, "0xfc" ); # 1 4
157 &and( $tmp1, "0xfc" ); # 1 3
158 &shr( $t, 8 ); # 1 5
159 &xor( $L, &DWP("0x100+$desSP",$tmp1,"",0)); # 1 7
160 &shr( $u, 8 ); # 1 6
161 &mov( $tmp1, &DWP(" $desSP",$tmp2,"",0)); # 1 8
162
163 &mov( $tmp2, $u ); # 2 2
164 &xor( $L, $tmp1 ); # 1 9
165 &and( $tmp2, "0xfc" ); # 2 4
166 &mov( $tmp1, $t ); # 2 1
167 &and( $tmp1, "0xfc" ); # 2 3
168 &shr( $t, 8 ); # 2 5
169 &xor( $L, &DWP("0x300+$desSP",$tmp1,"",0)); # 2 7
170 &shr( $u, 8 ); # 2 6
171 &mov( $tmp1, &DWP("0x200+$desSP",$tmp2,"",0)); # 2 8
172 &mov( $tmp2, $u ); # 3 2
173
174 &xor( $L, $tmp1 ); # 2 9
175 &and( $tmp2, "0xfc" ); # 3 4
176
177 &mov( $tmp1, $t ); # 3 1
178 &shr( $u, 8 ); # 3 6
179 &and( $tmp1, "0xfc" ); # 3 3
180 &shr( $t, 8 ); # 3 5
181 &xor( $L, &DWP("0x500+$desSP",$tmp1,"",0)); # 3 7
182 &mov( $tmp1, &DWP("0x400+$desSP",$tmp2,"",0)); # 3 8
183
184 &and( $t, "0xfc" ); # 4 1
185 &xor( $L, $tmp1 ); # 3 9
186
187 &and( $u, "0xfc" ); # 4 2
188 &xor( $L, &DWP("0x700+$desSP",$t,"",0)); # 4 3
189 &xor( $L, &DWP("0x600+$desSP",$u,"",0)); # 4 4
190 }
191
192sub PERM_OP
193 {
194 local($a,$b,$tt,$shift,$mask)=@_;
195
196 &mov( $tt, $a );
197 &shr( $tt, $shift );
198 &xor( $tt, $b );
199 &and( $tt, $mask );
200 &xor( $b, $tt );
201 &shl( $tt, $shift );
202 &xor( $a, $tt );
203 }
204
205sub IP_new
206 {
207 local($l,$r,$tt)=@_;
208
209 &PERM_OP($r,$l,$tt, 4,"0x0f0f0f0f");
210 &PERM_OP($l,$r,$tt,16,"0x0000ffff");
211 &PERM_OP($r,$l,$tt, 2,"0x33333333");
212 &PERM_OP($l,$r,$tt, 8,"0x00ff00ff");
213 &PERM_OP($r,$l,$tt, 1,"0x55555555");
214 }
215
216sub FP_new
217 {
218 local($l,$r,$tt)=@_;
219
220 &PERM_OP($l,$r,$tt, 1,"0x55555555");
221 &PERM_OP($r,$l,$tt, 8,"0x00ff00ff");
222 &PERM_OP($l,$r,$tt, 2,"0x33333333");
223 &PERM_OP($r,$l,$tt,16,"0x0000ffff");
224 &PERM_OP($l,$r,$tt, 4,"0x0f0f0f0f");
225 }
226
227sub n2a
228 {
229 sprintf("%d",$_[0]);
230 }
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com
index fc2c35a1ce..348f1c0470 100644
--- a/src/lib/libcrypto/des/des-lib.com
+++ b/src/lib/libcrypto/des/des-lib.com
@@ -9,7 +9,7 @@ $! Changes by Richard Levitte <richard@levitte.org>
9$! 9$!
10$! This command files compiles and creates the 10$! This command files compiles and creates the
11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine 11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine
12$! architecture of AXP or VAX. 12$! architecture of ALPHA, IA64 or VAX.
13$! 13$!
14$! It was re-written to try to determine which "C" compiler to try to use 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. 15$! or the user can specify a compiler in P3.
@@ -45,25 +45,34 @@ $!
45$! 45$!
46$! Check Which Architecture We Are Using. 46$! Check Which Architecture We Are Using.
47$! 47$!
48$ IF (F$GETSYI("CPU").GE.128) 48$ IF (F$GETSYI("CPU").LT.128)
49$ THEN 49$ THEN
50$! 50$!
51$! The Architecture Is AXP. 51$! The Architecture Is VAX
52$! 52$!
53$ ARCH := AXP 53$ ARCH := VAX
54$! 54$!
55$! Else... 55$! Else...
56$! 56$!
57$ ELSE 57$ ELSE
58$! 58$!
59$! The Architecture Is VAX. 59$! The Architecture Is Alpha, IA64 or whatever comes in the future.
60$! 60$!
61$ ARCH := VAX 61$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
62$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
62$! 63$!
63$! End The Architecture Check. 64$! End The Architecture Check.
64$! 65$!
65$ ENDIF 66$ ENDIF
66$! 67$!
68$! Define The OBJ Directory Name.
69$!
70$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES]
71$!
72$! Define The EXE Directory Name.
73$!
74$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES]
75$!
67$! Check To Make Sure We Have Valid Command Line Parameters. 76$! Check To Make Sure We Have Valid Command Line Parameters.
68$! 77$!
69$ GOSUB CHECK_OPTIONS 78$ GOSUB CHECK_OPTIONS
@@ -72,10 +81,6 @@ $! Tell The User What Kind of Machine We Run On.
72$! 81$!
73$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine." 82$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
74$! 83$!
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. 84$! Check To See If The Architecture Specific OBJ Directory Exists.
80$! 85$!
81$ IF (F$PARSE(OBJ_DIR).EQS."") 86$ IF (F$PARSE(OBJ_DIR).EQS."")
@@ -89,10 +94,6 @@ $! End The Architecture Specific OBJ Directory Check.
89$! 94$!
90$ ENDIF 95$ ENDIF
91$! 96$!
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$! Check To See If The Architecture Specific Directory Exists.
97$! 98$!
98$ IF (F$PARSE(EXE_DIR).EQS."") 99$ IF (F$PARSE(EXE_DIR).EQS."")
@@ -564,7 +565,7 @@ $!
564$ IF (F$SEARCH(OPT_FILE).EQS."") 565$ IF (F$SEARCH(OPT_FILE).EQS."")
565$ THEN 566$ THEN
566$! 567$!
567$! Figure Out If We Need An AXP Or A VAX Linker Option File. 568$! Figure Out If We Need An non-VAX Or A VAX Linker Option File.
568$! 569$!
569$ IF (F$GETSYI("CPU").LT.128) 570$ IF (F$GETSYI("CPU").LT.128)
570$ THEN 571$ THEN
@@ -584,19 +585,19 @@ $! Else...
584$! 585$!
585$ ELSE 586$ ELSE
586$! 587$!
587$! Create The AXP Linker Option File. 588$! Create The non-VAX Linker Option File.
588$! 589$!
589$ CREATE 'OPT_FILE' 590$ CREATE 'OPT_FILE'
590$DECK 591$DECK
591! 592!
592! Default System Options File For AXP To Link Agianst 593! Default System Options File For non-VAX To Link Agianst
593! The Sharable C Runtime Library. 594! The Sharable C Runtime Library.
594! 595!
595SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE 596SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
596SYS$SHARE:CMA$OPEN_RTL/SHARE 597SYS$SHARE:CMA$OPEN_RTL/SHARE
597$EOD 598$EOD
598$! 599$!
599$! End The VAX/AXP DEC C Option File Check. 600$! End The DEC C Option File Check.
600$! 601$!
601$ ENDIF 602$ ENDIF
602$! 603$!
@@ -658,13 +659,13 @@ $! Else...
658$! 659$!
659$ ELSE 660$ ELSE
660$! 661$!
661$! Else, Check To See If P1 Has A Valid Arguement. 662$! Else, Check To See If P1 Has A Valid Argument.
662$! 663$!
663$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."DESTEST").OR.(P1.EQS."SPEED") - 664$ 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 .OR.(P1.EQS."RPW").OR.(P1.EQS."DES").OR.(P1.EQS."DES_OPTS")
665$ THEN 666$ THEN
666$! 667$!
667$! A Valid Arguement. 668$! A Valid Argument.
668$! 669$!
669$ BUILDALL = P1 670$ BUILDALL = P1
670$! 671$!
@@ -677,7 +678,7 @@ $!
677$ WRITE SYS$OUTPUT "" 678$ WRITE SYS$OUTPUT ""
678$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:" 679$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
679$ WRITE SYS$OUTPUT "" 680$ WRITE SYS$OUTPUT ""
680$ WRITE SYS$OUTPUT " ALL : Just Build Everything. 681$ 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 " 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 " 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 " SPEED : To Compile Just The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program."
@@ -687,15 +688,16 @@ $ WRITE SYS$OUTPUT " DES_OPTS : To Compile Just The [.xxx.EXE.CRYTPO.DES
687$ WRITE SYS$OUTPUT "" 688$ WRITE SYS$OUTPUT ""
688$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: " 689$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: "
689$ WRITE SYS$OUTPUT "" 690$ WRITE SYS$OUTPUT ""
690$ WRITE SYS$OUTPUT " AXP : Alpha Architecture." 691$ WRITE SYS$OUTPUT " ALPHA : Alpha Architecture."
691$ WRITE SYS$OUTPUT " VAX : VAX Architecture." 692$ WRITE SYS$OUTPUT " IA64 : IA64 Architecture."
693$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
692$ WRITE SYS$OUTPUT "" 694$ WRITE SYS$OUTPUT ""
693$! 695$!
694$! Time To EXIT. 696$! Time To EXIT.
695$! 697$!
696$ EXIT 698$ EXIT
697$! 699$!
698$! End The Valid Arguement Check. 700$! End The Valid Argument Check.
699$! 701$!
700$ ENDIF 702$ ENDIF
701$! 703$!
@@ -752,7 +754,7 @@ $! Time To EXIT.
752$! 754$!
753$ EXIT 755$ EXIT
754$! 756$!
755$! End The Valid Arguement Check. 757$! End The Valid Argument Check.
756$! 758$!
757$ ENDIF 759$ ENDIF
758$! 760$!
@@ -817,7 +819,7 @@ $ ELSE
817$! 819$!
818$! Check To See If We Have VAXC Or DECC. 820$! Check To See If We Have VAXC Or DECC.
819$! 821$!
820$ IF (ARCH.EQS."AXP").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."") 822$ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
821$ THEN 823$ THEN
822$! 824$!
823$! Looks Like DECC, Set To Use DECC. 825$! Looks Like DECC, Set To Use DECC.
@@ -882,7 +884,7 @@ $ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
882$! 884$!
883$! Define The Linker Options File Name. 885$! Define The Linker Options File Name.
884$! 886$!
885$ OPT_FILE = "SYS$DISK:[]VAX_DECC_OPTIONS.OPT" 887$ OPT_FILE = "''EXE_DIR'VAX_DECC_OPTIONS.OPT"
886$! 888$!
887$! End DECC Check. 889$! End DECC Check.
888$! 890$!
@@ -904,9 +906,9 @@ $!
904$! Compile Using VAXC. 906$! Compile Using VAXC.
905$! 907$!
906$ CC = "CC" 908$ CC = "CC"
907$ IF ARCH.EQS."AXP" 909$ IF ARCH.NES."VAX"
908$ THEN 910$ THEN
909$ WRITE SYS$OUTPUT "There is no VAX C on Alpha!" 911$ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!"
910$ EXIT 912$ EXIT
911$ ENDIF 913$ ENDIF
912$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 914$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
@@ -919,7 +921,7 @@ $ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
919$! 921$!
920$! Define The Linker Options File Name. 922$! Define The Linker Options File Name.
921$! 923$!
922$ OPT_FILE = "SYS$DISK:[]VAX_VAXC_OPTIONS.OPT" 924$ OPT_FILE = "''EXE_DIR'VAX_VAXC_OPTIONS.OPT"
923$! 925$!
924$! End VAXC Check 926$! End VAXC Check
925$! 927$!
@@ -944,7 +946,7 @@ $ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
944$! 946$!
945$! Define The Linker Options File Name. 947$! Define The Linker Options File Name.
946$! 948$!
947$ OPT_FILE = "SYS$DISK:[]VAX_GNUC_OPTIONS.OPT" 949$ OPT_FILE = "''EXE_DIR'VAX_GNUC_OPTIONS.OPT"
948$! 950$!
949$! End The GNU C Check. 951$! End The GNU C Check.
950$! 952$!
@@ -976,7 +978,7 @@ $! Show user the result
976$! 978$!
977$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC 979$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC
978$! 980$!
979$! Else The User Entered An Invalid Arguement. 981$! Else The User Entered An Invalid Argument.
980$! 982$!
981$ ELSE 983$ ELSE
982$! 984$!
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index 22701e0669..5c47553a5a 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -57,6 +57,7 @@
57 */ 57 */
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60#include "spr.h"
60 61
61#ifndef OPENBSD_DES_ASM 62#ifndef OPENBSD_DES_ASM
62 63
@@ -109,12 +110,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
109 D_ENCRYPT(l,r,28); /* 15 */ 110 D_ENCRYPT(l,r,28); /* 15 */
110 D_ENCRYPT(r,l,30); /* 16 */ 111 D_ENCRYPT(r,l,30); /* 16 */
111#else 112#else
112 for (i=0; i<32; i+=8) 113 for (i=0; i<32; i+=4)
113 { 114 {
114 D_ENCRYPT(l,r,i+0); /* 1 */ 115 D_ENCRYPT(l,r,i+0); /* 1 */
115 D_ENCRYPT(r,l,i+2); /* 2 */ 116 D_ENCRYPT(r,l,i+2); /* 2 */
116 D_ENCRYPT(l,r,i+4); /* 3 */
117 D_ENCRYPT(r,l,i+6); /* 4 */
118 } 117 }
119#endif 118#endif
120 } 119 }
@@ -138,12 +137,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
138 D_ENCRYPT(l,r, 2); /* 2 */ 137 D_ENCRYPT(l,r, 2); /* 2 */
139 D_ENCRYPT(r,l, 0); /* 1 */ 138 D_ENCRYPT(r,l, 0); /* 1 */
140#else 139#else
141 for (i=30; i>0; i-=8) 140 for (i=30; i>0; i-=4)
142 { 141 {
143 D_ENCRYPT(l,r,i-0); /* 16 */ 142 D_ENCRYPT(l,r,i-0); /* 16 */
144 D_ENCRYPT(r,l,i-2); /* 15 */ 143 D_ENCRYPT(r,l,i-2); /* 15 */
145 D_ENCRYPT(l,r,i-4); /* 14 */
146 D_ENCRYPT(r,l,i-6); /* 13 */
147 } 144 }
148#endif 145#endif
149 } 146 }
@@ -205,12 +202,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
205 D_ENCRYPT(l,r,28); /* 15 */ 202 D_ENCRYPT(l,r,28); /* 15 */
206 D_ENCRYPT(r,l,30); /* 16 */ 203 D_ENCRYPT(r,l,30); /* 16 */
207#else 204#else
208 for (i=0; i<32; i+=8) 205 for (i=0; i<32; i+=4)
209 { 206 {
210 D_ENCRYPT(l,r,i+0); /* 1 */ 207 D_ENCRYPT(l,r,i+0); /* 1 */
211 D_ENCRYPT(r,l,i+2); /* 2 */ 208 D_ENCRYPT(r,l,i+2); /* 2 */
212 D_ENCRYPT(l,r,i+4); /* 3 */
213 D_ENCRYPT(r,l,i+6); /* 4 */
214 } 209 }
215#endif 210#endif
216 } 211 }
@@ -234,12 +229,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
234 D_ENCRYPT(l,r, 2); /* 2 */ 229 D_ENCRYPT(l,r, 2); /* 2 */
235 D_ENCRYPT(r,l, 0); /* 1 */ 230 D_ENCRYPT(r,l, 0); /* 1 */
236#else 231#else
237 for (i=30; i>0; i-=8) 232 for (i=30; i>0; i-=4)
238 { 233 {
239 D_ENCRYPT(l,r,i-0); /* 16 */ 234 D_ENCRYPT(l,r,i-0); /* 16 */
240 D_ENCRYPT(r,l,i-2); /* 15 */ 235 D_ENCRYPT(r,l,i-2); /* 15 */
241 D_ENCRYPT(l,r,i-4); /* 14 */
242 D_ENCRYPT(r,l,i-6); /* 13 */
243 } 236 }
244#endif 237#endif
245 } 238 }
@@ -293,8 +286,6 @@ void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
293 286
294#ifndef DES_DEFAULT_OPTIONS 287#ifndef DES_DEFAULT_OPTIONS
295 288
296#if !defined(OPENSSL_FIPS_DES_ASM)
297
298#undef CBC_ENC_C__DONT_UPDATE_IV 289#undef CBC_ENC_C__DONT_UPDATE_IV
299#include "ncbc_enc.c" /* DES_ncbc_encrypt */ 290#include "ncbc_enc.c" /* DES_ncbc_encrypt */
300 291
@@ -410,6 +401,4 @@ void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
410 tin[0]=tin[1]=0; 401 tin[0]=tin[1]=0;
411 } 402 }
412 403
413#endif
414
415#endif /* DES_DEFAULT_OPTIONS */ 404#endif /* DES_DEFAULT_OPTIONS */
diff --git a/src/lib/libcrypto/des/des_lib.c b/src/lib/libcrypto/des/des_lib.c
deleted file mode 100644
index d4b3047932..0000000000
--- a/src/lib/libcrypto/des/des_lib.c
+++ /dev/null
@@ -1,106 +0,0 @@
1/* crypto/des/ecb_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#include "des_ver.h"
61#include <openssl/opensslv.h>
62#include <openssl/bio.h>
63
64OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT;
65OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT;
66
67const char *DES_options(void)
68 {
69 static int init=1;
70 static char buf[32];
71
72 if (init)
73 {
74 const char *ptr,*unroll,*risc,*size;
75
76#ifdef DES_PTR
77 ptr="ptr";
78#else
79 ptr="idx";
80#endif
81#if defined(DES_RISC1) || defined(DES_RISC2)
82#ifdef DES_RISC1
83 risc="risc1";
84#endif
85#ifdef DES_RISC2
86 risc="risc2";
87#endif
88#else
89 risc="cisc";
90#endif
91#ifdef DES_UNROLL
92 unroll="16";
93#else
94 unroll="4";
95#endif
96 if (sizeof(DES_LONG) != sizeof(long))
97 size="int";
98 else
99 size="long";
100 BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
101 size);
102 init=0;
103 }
104 return(buf);
105 }
106
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
index 4b9ecff233..a3b512e9b0 100644
--- a/src/lib/libcrypto/des/des_locl.h
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -61,7 +61,7 @@
61 61
62#include <openssl/e_os2.h> 62#include <openssl/e_os2.h>
63 63
64#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) 64#if defined(OPENSSL_SYS_WIN32)
65#ifndef OPENSSL_SYS_MSDOS 65#ifndef OPENSSL_SYS_MSDOS
66#define OPENSSL_SYS_MSDOS 66#define OPENSSL_SYS_MSDOS
67#endif 67#endif
@@ -425,4 +425,8 @@ extern const DES_LONG DES_SPtrans[8][64];
425 425
426void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, 426void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
427 DES_LONG Eswap0, DES_LONG Eswap1); 427 DES_LONG Eswap0, DES_LONG Eswap1);
428
429#ifdef OPENSSL_SMALL_FOOTPRINT
430#undef DES_UNROLL
431#endif
428#endif 432#endif
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
index 75ae6cf8bb..0684e769b3 100644
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ b/src/lib/libcrypto/des/ecb_enc.c
@@ -57,7 +57,53 @@
57 */ 57 */
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60#include "spr.h" 60#include "des_ver.h"
61#include <openssl/opensslv.h>
62#include <openssl/bio.h>
63
64OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT;
65OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT;
66
67const char *DES_options(void)
68 {
69 static int init=1;
70 static char buf[32];
71
72 if (init)
73 {
74 const char *ptr,*unroll,*risc,*size;
75
76#ifdef DES_PTR
77 ptr="ptr";
78#else
79 ptr="idx";
80#endif
81#if defined(DES_RISC1) || defined(DES_RISC2)
82#ifdef DES_RISC1
83 risc="risc1";
84#endif
85#ifdef DES_RISC2
86 risc="risc2";
87#endif
88#else
89 risc="cisc";
90#endif
91#ifdef DES_UNROLL
92 unroll="16";
93#else
94 unroll="2";
95#endif
96 if (sizeof(DES_LONG) != sizeof(long))
97 size="int";
98 else
99 size="long";
100 BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
101 size);
102 init=0;
103 }
104 return(buf);
105 }
106
61 107
62void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, 108void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
63 DES_key_schedule *ks, int enc) 109 DES_key_schedule *ks, int enc)
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c
index e7da2ec66b..edb6620d08 100644
--- a/src/lib/libcrypto/des/enc_read.c
+++ b/src/lib/libcrypto/des/enc_read.c
@@ -63,7 +63,7 @@
63 63
64/* 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. */
65/*extern int errno;*/ 65/*extern int errno;*/
66OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE; 66OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode,DES_PCBC_MODE)
67 67
68 68
69/* 69/*
@@ -87,6 +87,9 @@ OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE;
87int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, 87int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
88 DES_cblock *iv) 88 DES_cblock *iv)
89 { 89 {
90#if defined(OPENSSL_NO_POSIX_IO)
91 return(0);
92#else
90 /* data to be unencrypted */ 93 /* data to be unencrypted */
91 int net_num=0; 94 int net_num=0;
92 static unsigned char *net=NULL; 95 static unsigned char *net=NULL;
@@ -147,7 +150,7 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
147 /* first - get the length */ 150 /* first - get the length */
148 while (net_num < HDRSIZE) 151 while (net_num < HDRSIZE)
149 { 152 {
150#ifndef _WIN32 153#ifndef OPENSSL_SYS_WIN32
151 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); 154 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
152#else 155#else
153 i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); 156 i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
@@ -173,7 +176,11 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
173 net_num=0; 176 net_num=0;
174 while (net_num < rnum) 177 while (net_num < rnum)
175 { 178 {
179#ifndef OPENSSL_SYS_WIN32
176 i=read(fd,(void *)&(net[net_num]),rnum-net_num); 180 i=read(fd,(void *)&(net[net_num]),rnum-net_num);
181#else
182 i=_read(fd,(void *)&(net[net_num]),rnum-net_num);
183#endif
177#ifdef EINTR 184#ifdef EINTR
178 if ((i == -1) && (errno == EINTR)) continue; 185 if ((i == -1) && (errno == EINTR)) continue;
179#endif 186#endif
@@ -228,5 +235,6 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
228 } 235 }
229 } 236 }
230 return num; 237 return num;
238#endif /* OPENSSL_NO_POSIX_IO */
231 } 239 }
232 240
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c
index c2f032c9a6..2353ac1e89 100644
--- a/src/lib/libcrypto/des/enc_writ.c
+++ b/src/lib/libcrypto/des/enc_writ.c
@@ -80,6 +80,9 @@
80int DES_enc_write(int fd, const void *_buf, int len, 80int DES_enc_write(int fd, const void *_buf, int len,
81 DES_key_schedule *sched, DES_cblock *iv) 81 DES_key_schedule *sched, DES_cblock *iv)
82 { 82 {
83#if defined(OPENSSL_NO_POSIX_IO)
84 return (-1);
85#else
83#ifdef _LIBC 86#ifdef _LIBC
84 extern unsigned long time(); 87 extern unsigned long time();
85 extern int write(); 88 extern int write();
@@ -172,4 +175,5 @@ int DES_enc_write(int fd, const void *_buf, int len,
172 } 175 }
173 176
174 return(len); 177 return(len);
178#endif /* OPENSSL_NO_POSIX_IO */
175 } 179 }
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
index c56b461e91..87fc71eb26 100644
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ b/src/lib/libcrypto/des/fcrypt_b.c
@@ -102,12 +102,10 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
102#ifndef DES_UNROLL 102#ifndef DES_UNROLL
103 register int i; 103 register int i;
104 104
105 for (i=0; i<32; i+=8) 105 for (i=0; i<32; i+=4)
106 { 106 {
107 D_ENCRYPT(l,r,i+0); /* 1 */ 107 D_ENCRYPT(l,r,i+0); /* 1 */
108 D_ENCRYPT(r,l,i+2); /* 2 */ 108 D_ENCRYPT(r,l,i+2); /* 2 */
109 D_ENCRYPT(l,r,i+4); /* 1 */
110 D_ENCRYPT(r,l,i+6); /* 2 */
111 } 109 }
112#else 110#else
113 D_ENCRYPT(l,r, 0); /* 1 */ 111 D_ENCRYPT(l,r, 0); /* 1 */
diff --git a/src/lib/libcrypto/des/rpc_des.h b/src/lib/libcrypto/des/rpc_des.h
index efc474f00e..8263c512ab 100644
--- a/src/lib/libcrypto/des/rpc_des.h
+++ b/src/lib/libcrypto/des/rpc_des.h
@@ -124,10 +124,10 @@ struct desparams {
124/* 124/*
125 * Encrypt an arbitrary sized buffer 125 * Encrypt an arbitrary sized buffer
126 */ 126 */
127#define DESIOCBLOCK _IOWR(d, 6, struct desparams) 127#define DESIOCBLOCK _IOWR('d', 6, struct desparams)
128 128
129/* 129/*
130 * Encrypt of small amount of data, quickly 130 * Encrypt of small amount of data, quickly
131 */ 131 */
132#define DESIOCQUICK _IOWR(d, 7, struct desparams) 132#define DESIOCQUICK _IOWR('d', 7, struct desparams)
133 133
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index c0806d593c..3004cc3ab3 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -64,12 +64,8 @@
64 * 1.0 First working version 64 * 1.0 First working version
65 */ 65 */
66#include "des_locl.h" 66#include "des_locl.h"
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70
71 67
72OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ 68OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key,0) /* defaults to false */
73 69
74static const unsigned char odd_parity[256]={ 70static const unsigned char odd_parity[256]={
75 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, 71 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
@@ -340,7 +336,7 @@ int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule)
340 336
341void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) 337void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
342 { 338 {
343 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 339 static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
344 register DES_LONG c,d,t,s,t2; 340 register DES_LONG c,d,t,s,t2;
345 register const unsigned char *in; 341 register const unsigned char *in;
346 register DES_LONG *k; 342 register DES_LONG *k;
@@ -353,10 +349,6 @@ void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
353 k = &schedule->ks->deslong[0]; 349 k = &schedule->ks->deslong[0];
354 in = &(*key)[0]; 350 in = &(*key)[0];
355 351
356#ifdef OPENSSL_FIPS
357 FIPS_selftest_check();
358#endif
359
360 c2l(in,c); 352 c2l(in,c);
361 c2l(in,d); 353 c2l(in,d);
362 354
@@ -413,4 +405,3 @@ void des_fixup_key_parity(des_cblock *key)
413 des_set_odd_parity(key); 405 des_set_odd_parity(key);
414 } 406 }
415*/ 407*/
416
diff --git a/src/lib/libcrypto/des/times/aix.cc b/src/lib/libcrypto/des/times/aix.cc
index e9b2e45751..d96b74e2ce 100644
--- a/src/lib/libcrypto/des/times/aix.cc
+++ b/src/lib/libcrypto/des/times/aix.cc
@@ -2,10 +2,10 @@ From: Paco Garcia <pgarcia@cam.es>
2 2
3This machine is a Bull Estrella Minitower Model MT604-100 3This machine is a Bull Estrella Minitower Model MT604-100
4Processor : PPC604 4Processor : PPC604
5P.Speed : 100MHz 5P.Speed : 100Mhz
6Data/Instr Cache : 16 K 6Data/Instr Cache : 16 K
7L2 Cache : 256 K 7L2 Cache : 256 K
8PCI BUS Speed : 33 MHz 8PCI BUS Speed : 33 Mhz
9TransfRate PCI : 132 MB/s 9TransfRate PCI : 132 MB/s
10Memory : 96 MB 10Memory : 96 MB
11 11
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c
index dc0c761b71..058cab6bce 100644
--- a/src/lib/libcrypto/des/xcbc_enc.c
+++ b/src/lib/libcrypto/des/xcbc_enc.c
@@ -61,7 +61,7 @@
61/* RSA's DESX */ 61/* RSA's DESX */
62 62
63#if 0 /* broken code, preserved just in case anyone specifically looks for this */ 63#if 0 /* broken code, preserved just in case anyone specifically looks for this */
64static unsigned char desx_white_in2out[256]={ 64static const unsigned char desx_white_in2out[256]={
650xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, 650xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0,
660x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, 660x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A,
670x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36, 670x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36,