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/DES.pod16
-rw-r--r--src/lib/libcrypto/des/MODES.DES84
-rw-r--r--src/lib/libcrypto/des/Makefile.PL14
-rw-r--r--src/lib/libcrypto/des/Makefile.lit250
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl26
-rw-r--r--src/lib/libcrypto/des/Makefile.uni251
-rw-r--r--src/lib/libcrypto/des/PC128
-rw-r--r--src/lib/libcrypto/des/PC257
-rw-r--r--src/lib/libcrypto/des/asm/d-win32.asm3132
-rw-r--r--src/lib/libcrypto/des/asm/y-win32.asm929
-rw-r--r--src/lib/libcrypto/des/des.c7
-rw-r--r--src/lib/libcrypto/des/des.h29
-rw-r--r--src/lib/libcrypto/des/des.man186
-rw-r--r--src/lib/libcrypto/des/des.pl552
-rw-r--r--src/lib/libcrypto/des/des.pod217
-rw-r--r--src/lib/libcrypto/des/des_crypt.man508
-rw-r--r--src/lib/libcrypto/des/des_locl.h2
-rw-r--r--src/lib/libcrypto/des/destest.c69
-rw-r--r--src/lib/libcrypto/des/doIP46
-rw-r--r--src/lib/libcrypto/des/doPC1110
-rw-r--r--src/lib/libcrypto/des/doPC294
-rw-r--r--src/lib/libcrypto/des/fcrypt.c1
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c2
-rw-r--r--src/lib/libcrypto/des/ncbc_enc.c5
-rw-r--r--src/lib/libcrypto/des/podd.h75
-rw-r--r--src/lib/libcrypto/des/qud_cksm.c31
-rw-r--r--src/lib/libcrypto/des/rand_key.c8
-rw-r--r--src/lib/libcrypto/des/set_key.c199
-rw-r--r--src/lib/libcrypto/des/shifts.pl198
-rw-r--r--src/lib/libcrypto/des/sk.h204
-rw-r--r--src/lib/libcrypto/des/testdes.pl167
31 files changed, 488 insertions, 7009 deletions
diff --git a/src/lib/libcrypto/des/DES.pod b/src/lib/libcrypto/des/DES.pod
index 8a739e7ca0..e69de29bb2 100644
--- a/src/lib/libcrypto/des/DES.pod
+++ b/src/lib/libcrypto/des/DES.pod
@@ -1,16 +0,0 @@
1crypt <= crypt(buf,salt)
2key <= set_odd_parity(key)
3int <= is_weak_key(key)
4keysched<= set_key(key)
5key <= ecb_encrypt(string8,ks,enc)
6key <= ecb3_encrypt(input,ks1,ks2,enc)
7string <= cbc_encrypt(input,ks,ivec,enc) => ivec
8string <= cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,enc) => ivec1&ivec2
9ck1,ck2 <= cbc_cksum(input,ks,ivec) => ivec
10string <= pcbc_encrypt(input,ks,ivec,enc) => ivec
11string <= ofb_encrypt(input,numbits,ks,ivec) => ivec
12string <= cfb_encrypt(input,numbits,ks,ivec,enc) => ivec
13key <= random_key()
14key <= string_to_key(string)
15key1,key2<= string_to_2keys(string)
16
diff --git a/src/lib/libcrypto/des/MODES.DES b/src/lib/libcrypto/des/MODES.DES
index 0cbc44f51d..e69de29bb2 100644
--- a/src/lib/libcrypto/des/MODES.DES
+++ b/src/lib/libcrypto/des/MODES.DES
@@ -1,84 +0,0 @@
1Modes of DES
2Quite a bit of the following information has been taken from
3 AS 2805.5.2
4 Australian Standard
5 Electronic funds transfer - Requirements for interfaces,
6 Part 5.2: Modes of operation for an n-bit block cipher algorithm
7 Appendix A
8
9There are several different modes in which DES can be used, they are
10as follows.
11
12Electronic Codebook Mode (ECB) (des_ecb_encrypt())
13- 64 bits are enciphered at a time.
14- The order of the blocks can be rearranged without detection.
15- The same plaintext block always produces the same ciphertext block
16 (for the same key) making it vulnerable to a 'dictionary attack'.
17- An error will only affect one ciphertext block.
18
19Cipher Block Chaining Mode (CBC) (des_cbc_encrypt())
20- a multiple of 64 bits are enciphered at a time.
21- The CBC mode produces the same ciphertext whenever the same
22 plaintext is encrypted using the same key and starting variable.
23- The chaining operation makes the ciphertext blocks dependent on the
24 current and all preceding plaintext blocks and therefore blocks can not
25 be rearranged.
26- The use of different starting variables prevents the same plaintext
27 enciphering to the same ciphertext.
28- An error will affect the current and the following ciphertext blocks.
29
30Cipher Feedback Mode (CFB) (des_cfb_encrypt())
31- a number of bits (j) <= 64 are enciphered at a time.
32- The CFB mode produces the same ciphertext whenever the same
33 plaintext is encrypted using the same key and starting variable.
34- The chaining operation makes the ciphertext variables dependent on the
35 current and all preceding variables and therefore j-bit variables are
36 chained together and con not be rearranged.
37- The use of different starting variables prevents the same plaintext
38 enciphering to the same ciphertext.
39- The strength of the CFB mode depends on the size of k (maximal if
40 j == k). In my implementation this is always the case.
41- Selection of a small value for j will require more cycles through
42 the encipherment algorithm per unit of plaintext and thus cause
43 greater processing overheads.
44- Only multiples of j bits can be enciphered.
45- An error will affect the current and the following ciphertext variables.
46
47Output Feedback Mode (OFB) (des_ofb_encrypt())
48- a number of bits (j) <= 64 are enciphered at a time.
49- The OFB mode produces the same ciphertext whenever the same
50 plaintext enciphered using the same key and starting variable. More
51 over, in the OFB mode the same key stream is produced when the same
52 key and start variable are used. Consequently, for security reasons
53 a specific start variable should be used only once for a given key.
54- The absence of chaining makes the OFB more vulnerable to specific attacks.
55- The use of different start variables values prevents the same
56 plaintext enciphering to the same ciphertext, by producing different
57 key streams.
58- Selection of a small value for j will require more cycles through
59 the encipherment algorithm per unit of plaintext and thus cause
60 greater processing overheads.
61- Only multiples of j bits can be enciphered.
62- OFB mode of operation does not extend ciphertext errors in the
63 resultant plaintext output. Every bit error in the ciphertext causes
64 only one bit to be in error in the deciphered plaintext.
65- OFB mode is not self-synchronising. If the two operation of
66 encipherment and decipherment get out of synchronism, the system needs
67 to be re-initialised.
68- Each re-initialisation should use a value of the start variable
69different from the start variable values used before with the same
70key. The reason for this is that an identical bit stream would be
71produced each time from the same parameters. This would be
72susceptible to a 'known plaintext' attack.
73
74Triple ECB Mode (des_ecb3_encrypt())
75- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
76- As for ECB encryption but increases the effective key length to 112 bits.
77- If both keys are the same it is equivalent to encrypting once with
78 just one key.
79
80Triple CBC Mode (des_3cbc_encrypt())
81- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
82- As for CBC encryption but increases the effective key length to 112 bits.
83- If both keys are the same it is equivalent to encrypting once with
84 just one key.
diff --git a/src/lib/libcrypto/des/Makefile.PL b/src/lib/libcrypto/des/Makefile.PL
index b54a24387c..e69de29bb2 100644
--- a/src/lib/libcrypto/des/Makefile.PL
+++ b/src/lib/libcrypto/des/Makefile.PL
@@ -1,14 +0,0 @@
1use ExtUtils::MakeMaker;
2# See lib/ExtUtils/MakeMaker.pm for details of how to influence
3# the contents of the Makefile being created.
4&writeMakefile(
5 'potential_libs' => '', # e.g., '-lm'
6 'INC' => '', # e.g., '-I/usr/include/other'
7 'DISTNAME' => 'DES',
8 'VERSION' => '0.1',
9 'DEFINE' => '-DPERL5',
10 'OBJECT' => 'DES.o cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
11 rand_key.o set_key.o str2key.o \
12 enc_read.o enc_writ.o fcrypt.o cfb_enc.o \
13 ecb3_enc.o ofb_enc.o cbc3_enc.o des_enc.o',
14 );
diff --git a/src/lib/libcrypto/des/Makefile.lit b/src/lib/libcrypto/des/Makefile.lit
index c09f6969da..e69de29bb2 100644
--- a/src/lib/libcrypto/des/Makefile.lit
+++ b/src/lib/libcrypto/des/Makefile.lit
@@ -1,250 +0,0 @@
1# You must select the correct terminal control system to be used to
2# turn character echo off when reading passwords. There a 5 systems
3# SGTTY - the old BSD system
4# TERMIO - most system V boxes
5# TERMIOS - SGI (ala IRIX).
6# VMS - the DEC operating system
7# MSDOS - we all know what it is :-)
8# read_pwd.c makes a reasonable guess at what is correct.
9
10# Targets
11# make - twidle the options yourself :-)
12# make cc - standard cc options
13# make gcc - standard gcc options
14# make x86-elf - linux-elf etc
15# make x86-out - linux-a.out, FreeBSD etc
16# make x86-solaris
17# make x86-bdsi
18
19# If you are on a DEC Alpha, edit des.h and change the DES_LONG
20# define to 'unsigned int'. I have seen this give a %20 speedup.
21
22OPTS0= -DLIBDES_LIT -DRAND -DTERMIO #-DNOCONST
23
24# Version 1.94 has changed the strings_to_key function so that it is
25# now compatible with MITs when the string is longer than 8 characters.
26# If you wish to keep the old version, uncomment the following line.
27# This will affect the -E/-D options on des(1).
28#OPTS1= -DOLD_STR_TO_KEY
29
30# There are 4 possible performance options
31# -DDES_PTR
32# -DDES_RISC1
33# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
34# -DDES_UNROLL
35# after the initial build, run 'des_opts' to see which options are best
36# for your platform. There are some listed in options.txt
37#OPTS2= -DDES_PTR
38#OPTS3= -DDES_RISC1 # or DES_RISC2
39#OPTS4= -DDES_UNROLL
40
41OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
42
43MAKE=make -f Makefile
44#CC=cc
45#CFLAG= -O
46
47CC=gcc
48#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
49CFLAG= -O3 -fomit-frame-pointer
50
51CFLAGS=$(OPTS) $(CFLAG)
52CPP=$(CC) -E
53AS=as
54
55# Assember version of des_encrypt*().
56DES_ENC=des_enc.o fcrypt_b.o # normal C version
57#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
58#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
59#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
60#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
61
62LIBDIR=/usr/local/lib
63BINDIR=/usr/local/bin
64INCDIR=/usr/local/include
65MANDIR=/usr/local/man
66MAN1=1
67MAN3=3
68SHELL=/bin/sh
69OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
70OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
71 xcbc_enc.o qud_cksm.o \
72 cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
73 enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
74 rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
75
76GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
77 des.doc options.txt asm
78GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
79 des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
80 Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
81 des.org des_locl.org
82TESTING_LIT= destest speed des_opts
83TESTING_FULL= rpw $(TESTING_LIT)
84TESTING_SRC_LIT=destest.c speed.c des_opts.c
85TESTING_SRC_FULL=rpw.c $(TESTING_SRC_LIT)
86HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
87HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
88LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
89LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c \
90 cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
91 enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
92 rand_key.c rpc_enc.c str2key.c supp.c \
93 xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
94
95PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
96
97OBJ= $(OBJ_LIT)
98GENERAL=$(GENERAL_LIT)
99TESTING=$(TESTING_LIT)
100TESTING_SRC=$(TESTING_SRC_LIT)
101HEADERS=$(HEADERS_LIT)
102LIBDES= $(LIBDES_LIT)
103
104ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
105
106DLIB= libdes.a
107
108all: $(DLIB) $(TESTING)
109
110cc:
111 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
112
113gcc:
114 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
115
116x86-elf:
117 $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
118
119x86-out:
120 $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
121
122x86-solaris:
123 $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
124
125x86-bsdi:
126 $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
127
128# elf
129asm/dx86-elf.o: asm/dx86unix.cpp
130 $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
131
132asm/yx86-elf.o: asm/yx86unix.cpp
133 $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
134
135# solaris
136asm/dx86-sol.o: asm/dx86unix.cpp
137 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
138 as -o asm/dx86-sol.o asm/dx86-sol.s
139 rm -f asm/dx86-sol.s
140
141asm/yx86-sol.o: asm/yx86unix.cpp
142 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
143 as -o asm/yx86-sol.o asm/yx86-sol.s
144 rm -f asm/yx86-sol.s
145
146# a.out
147asm/dx86-out.o: asm/dx86unix.cpp
148 $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
149
150asm/yx86-out.o: asm/yx86unix.cpp
151 $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
152
153# bsdi
154asm/dx86bsdi.o: asm/dx86unix.cpp
155 $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
156
157asm/yx86bsdi.o: asm/yx86unix.cpp
158 $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
159
160asm/dx86unix.cpp:
161 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
162
163asm/yx86unix.cpp:
164 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
165
166test: all
167 ./destest
168
169$(DLIB): $(OBJ)
170 /bin/rm -f $(DLIB)
171 ar cr $(DLIB) $(OBJ)
172 -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
173 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
174 else exit 0; fi; fi
175
176des_opts: des_opts.o $(DLIB)
177 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
178
179destest: destest.o $(DLIB)
180 $(CC) $(CFLAGS) -o destest destest.o $(DLIB)
181
182rpw: rpw.o $(DLIB)
183 $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
184
185speed: speed.o $(DLIB)
186 $(CC) $(CFLAGS) -o speed speed.o $(DLIB)
187
188des: des.o $(DLIB)
189 $(CC) $(CFLAGS) -o des des.o $(DLIB)
190
191tags:
192 ctags $(TESTING_SRC) $(LIBDES)
193
194tar_lit:
195 /bin/mv Makefile Makefile.tmp
196 /bin/cp Makefile.lit Makefile
197 tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \
198 $(GENERAL_LIT) $(TESTING_SRC_LIT)
199 /bin/rm -f Makefile
200 /bin/mv Makefile.tmp Makefile
201
202tar:
203 tar chf libdes.tar $(ALL)
204
205shar:
206 shar $(ALL) >libdes.shar
207
208depend:
209 makedepend $(LIBDES) $(TESTING_SRC)
210
211clean:
212 /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
213
214dclean:
215 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
216 mv -f Makefile.new Makefile
217
218# Eric is probably going to choke when he next looks at this --tjh
219install:
220 if test $(INSTALLTOP); then \
221 echo SSL style install; \
222 cp $(DLIB) $(INSTALLTOP)/lib; \
223 if test -s /bin/ranlib; then \
224 /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
225 else \
226 if test -s /usr/bin/ranlib; then \
227 /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
228 fi; fi; \
229 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
230 cp des.h $(INSTALLTOP)/include; \
231 chmod 644 $(INSTALLTOP)/include/des.h; \
232 else \
233 echo Standalone install; \
234 cp $(DLIB) $(LIBDIR)/$(DLIB); \
235 if test -s /bin/ranlib; then \
236 /bin/ranlib $(LIBDIR)/$(DLIB); \
237 else \
238 if test -s /usr/bin/ranlib; then \
239 /usr/bin/ranlib $(LIBDIR)/$(DLIB); \
240 fi; \
241 fi; \
242 chmod 644 $(LIBDIR)/$(DLIB); \
243 cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
244 chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
245 cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \
246 chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \
247 cp des.h $(INCDIR)/des.h; \
248 chmod 644 $(INCDIR)/des.h; \
249 fi
250# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
index 41976655e9..3eb0738b7b 100644
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -32,21 +32,21 @@ LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
32 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ 32 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
33 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ 33 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
34 des_enc.c fcrypt_b.c read2pwd.c \ 34 des_enc.c fcrypt_b.c read2pwd.c \
35 fcrypt.c xcbc_enc.c \ 35 xcbc_enc.c \
36 str2key.c cfb64ede.c ofb64ede.c supp.c ede_cbcm_enc.c 36 str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c
37 37
38LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ 38LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
39 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ 39 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
40 enc_read.o enc_writ.o ofb64enc.o \ 40 enc_read.o enc_writ.o ofb64enc.o \
41 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ 41 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
42 ${DES_ENC} read2pwd.o \ 42 ${DES_ENC} read2pwd.o \
43 fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o \ 43 fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o \
44 ede_cbcm_enc.o 44 ede_cbcm_enc.o
45 45
46SRC= $(LIBSRC) 46SRC= $(LIBSRC)
47 47
48EXHEADER= des.h 48EXHEADER= des.h
49HEADER= des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h $(EXHEADER) 49HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER)
50 50
51ALL= $(GENERAL) $(SRC) $(HEADER) 51ALL= $(GENERAL) $(SRC) $(HEADER)
52 52
@@ -65,10 +65,10 @@ des: des.o cbc3_enc.o lib
65 65
66# elf 66# elf
67asm/dx86-elf.o: asm/dx86unix.cpp 67asm/dx86-elf.o: asm/dx86unix.cpp
68 $(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o 68 $(CPP) -DELF -x c asm/dx86unix.cpp | as -o asm/dx86-elf.o
69 69
70asm/yx86-elf.o: asm/yx86unix.cpp 70asm/yx86-elf.o: asm/yx86unix.cpp
71 $(CPP) -DELF asm/yx86unix.cpp | as -o asm/yx86-elf.o 71 $(CPP) -DELF -x c asm/yx86unix.cpp | as -o asm/yx86-elf.o
72 72
73# solaris 73# solaris
74asm/dx86-sol.o: asm/dx86unix.cpp 74asm/dx86-sol.o: asm/dx86unix.cpp
@@ -95,10 +95,10 @@ asm/dx86bsdi.o: asm/dx86unix.cpp
95asm/yx86bsdi.o: asm/yx86unix.cpp 95asm/yx86bsdi.o: asm/yx86unix.cpp
96 $(CPP) -DBSDI asm/yx86unix.cpp | sed 's/ :/:/' | as -o asm/yx86bsdi.o 96 $(CPP) -DBSDI asm/yx86unix.cpp | sed 's/ :/:/' | as -o asm/yx86bsdi.o
97 97
98asm/dx86unix.cpp: asm/des-586.pl 98asm/dx86unix.cpp: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
99 (cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp) 99 (cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp)
100 100
101asm/yx86unix.cpp: asm/crypt586.pl 101asm/yx86unix.cpp: asm/crypt586.pl ../perlasm/x86asm.pl
102 (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp) 102 (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp)
103 103
104files: 104files:
@@ -172,10 +172,8 @@ enc_writ.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
172enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 172enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
173enc_writ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 173enc_writ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
174enc_writ.o: ../cryptlib.h des_locl.h 174enc_writ.o: ../cryptlib.h des_locl.h
175fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des.h 175fcrypt.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
176fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/e_os2.h 176fcrypt.o: ../../include/openssl/opensslconf.h des_locl.h
177fcrypt.o: ../../include/openssl/opensslconf.h
178fcrypt.o: ../../include/openssl/opensslconf.h des_locl.h des_locl.h
179fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 177fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
180fcrypt_b.o: ../../include/openssl/opensslconf.h des_locl.h 178fcrypt_b.o: ../../include/openssl/opensslconf.h des_locl.h
181ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 179ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
@@ -201,10 +199,8 @@ read_pwd.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h
201rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 199rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
202rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h 200rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h
203set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 201set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
204set_key.o: ../../include/openssl/opensslconf.h des_locl.h podd.h sk.h 202set_key.o: ../../include/openssl/opensslconf.h des_locl.h
205str2key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 203str2key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
206str2key.o: ../../include/openssl/opensslconf.h des_locl.h 204str2key.o: ../../include/openssl/opensslconf.h des_locl.h
207supp.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
208supp.o: ../../include/openssl/opensslconf.h des_locl.h
209xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 205xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
210xcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h 206xcbc_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 ec19d75b81..e69de29bb2 100644
--- a/src/lib/libcrypto/des/Makefile.uni
+++ b/src/lib/libcrypto/des/Makefile.uni
@@ -1,251 +0,0 @@
1# You must select the correct terminal control system to be used to
2# turn character echo off when reading passwords. There a 5 systems
3# SGTTY - the old BSD system
4# TERMIO - most system V boxes
5# TERMIOS - SGI (ala IRIX).
6# VMS - the DEC operating system
7# MSDOS - we all know what it is :-)
8# read_pwd.c makes a reasonable guess at what is correct.
9
10# Targets
11# make - twidle the options yourself :-)
12# make cc - standard cc options
13# make gcc - standard gcc options
14# make x86-elf - linux-elf etc
15# make x86-out - linux-a.out, FreeBSD etc
16# make x86-solaris
17# make x86-bdsi
18
19# If you are on a DEC Alpha, edit des.h and change the DES_LONG
20# define to 'unsigned int'. I have seen this give a %20 speedup.
21
22OPTS0= -DRAND -DTERMIO #-DNOCONST
23
24# Version 1.94 has changed the strings_to_key function so that it is
25# now compatible with MITs when the string is longer than 8 characters.
26# If you wish to keep the old version, uncomment the following line.
27# This will affect the -E/-D options on des(1).
28#OPTS1= -DOLD_STR_TO_KEY
29
30# There are 4 possible performance options
31# -DDES_PTR
32# -DDES_RISC1
33# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
34# -DDES_UNROLL
35# after the initial build, run 'des_opts' to see which options are best
36# for your platform. There are some listed in options.txt
37#OPTS2= -DDES_PTR
38#OPTS3= -DDES_RISC1 # or DES_RISC2
39#OPTS4= -DDES_UNROLL
40
41OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
42
43MAKE=make -f Makefile
44#CC=cc
45#CFLAG= -O
46
47CC=gcc
48#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
49CFLAG= -O3 -fomit-frame-pointer
50
51CFLAGS=$(OPTS) $(CFLAG)
52CPP=$(CC) -E
53AS=as
54RANLIB=ranlib
55
56# Assember version of des_encrypt*().
57DES_ENC=des_enc.o fcrypt_b.o # normal C version
58#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
59#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
60#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
61#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
62
63LIBDIR=/usr/local/lib
64BINDIR=/usr/local/bin
65INCDIR=/usr/local/include
66MANDIR=/usr/local/man
67MAN1=1
68MAN3=3
69SHELL=/bin/sh
70OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
71OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
72 xcbc_enc.o qud_cksm.o cbc3_enc.o \
73 cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
74 enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
75 rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
76
77GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
78 des.doc options.txt asm
79GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
80 des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
81 Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
82 des.org des_locl.org
83TESTING_LIT= destest speed des_opts
84TESTING_FULL= rpw des $(TESTING_LIT)
85TESTING_SRC_LIT=destest.c speed.c des_opts.c
86TESTING_SRC_FULL=rpw.c des.c $(TESTING_SRC_LIT)
87HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
88HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
89LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
90LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c cbc3_enc.c \
91 cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
92 enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
93 rand_key.c rpc_enc.c str2key.c supp.c \
94 xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
95
96PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
97
98OBJ= $(OBJ_FULL)
99GENERAL=$(GENERAL_FULL)
100TESTING=$(TESTING_FULL)
101TESTING_SRC=$(TESTING_SRC_FULL)
102HEADERS=$(HEADERS_FULL)
103LIBDES= $(LIBDES_FULL)
104
105ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
106
107DLIB= libdes.a
108
109all: $(DLIB) $(TESTING)
110
111cc:
112 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
113
114gcc:
115 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
116
117x86-elf:
118 $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
119
120x86-out:
121 $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
122
123x86-solaris:
124 $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
125
126x86-bsdi:
127 $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
128
129# elf
130asm/dx86-elf.o: asm/dx86unix.cpp
131 $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
132
133asm/yx86-elf.o: asm/yx86unix.cpp
134 $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
135
136# solaris
137asm/dx86-sol.o: asm/dx86unix.cpp
138 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
139 as -o asm/dx86-sol.o asm/dx86-sol.s
140 rm -f asm/dx86-sol.s
141
142asm/yx86-sol.o: asm/yx86unix.cpp
143 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
144 as -o asm/yx86-sol.o asm/yx86-sol.s
145 rm -f asm/yx86-sol.s
146
147# a.out
148asm/dx86-out.o: asm/dx86unix.cpp
149 $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
150
151asm/yx86-out.o: asm/yx86unix.cpp
152 $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
153
154# bsdi
155asm/dx86bsdi.o: asm/dx86unix.cpp
156 $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
157
158asm/yx86bsdi.o: asm/yx86unix.cpp
159 $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
160
161asm/dx86unix.cpp:
162 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
163
164asm/yx86unix.cpp:
165 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
166
167test: all
168 ./destest
169
170$(DLIB): $(OBJ)
171 /bin/rm -f $(DLIB)
172 ar cr $(DLIB) $(OBJ)
173 $(RANLIB) $(DLIB)
174
175des_opts: des_opts.o $(DLIB)
176 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
177
178destest: destest.o $(DLIB)
179 $(CC) $(CFLAGS) -o destest destest.o $(DLIB)
180
181rpw: rpw.o $(DLIB)
182 $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
183
184speed: speed.o $(DLIB)
185 $(CC) $(CFLAGS) -o speed speed.o $(DLIB)
186
187des: des.o $(DLIB)
188 $(CC) $(CFLAGS) -o des des.o $(DLIB)
189
190tags:
191 ctags $(TESTING_SRC) $(LIBDES)
192
193tar_lit:
194 /bin/mv Makefile Makefile.tmp
195 /bin/cp Makefile.lit Makefile
196 for i in $(HEADERS_LIT) $(LIBDES_LIT) $(GENERAL_LIT) $(TESTING_SRC_LIT) ;\
197 do \
198 n="$$n des/$$i"; \
199 done; \
200 ( cd .. ; tar chf - $$n )| gzip > libdes-l.tgz
201 /bin/rm -f Makefile
202 /bin/mv Makefile.tmp Makefile
203
204tar:
205 mv Makefile Makefile.tmp
206 /bin/cp Makefile.uni Makefile
207 for i in $(ALL) ;\
208 do \
209 n="$$n des/$$i"; \
210 done; \
211 ( cd .. ; tar chf - $$n )| gzip > libdes.tgz
212 /bin/rm -f Makefile
213 /bin/mv Makefile.tmp Makefile
214
215shar:
216 shar $(ALL) >libdes.shar
217
218depend:
219 makedepend $(LIBDES) $(TESTING_SRC)
220
221clean:
222 /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
223
224dclean:
225 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
226 mv -f Makefile.new Makefile
227
228# Eric is probably going to choke when he next looks at this --tjh
229install: des
230 if test $(INSTALLTOP); then \
231 echo SSL style install; \
232 cp $(DLIB) $(INSTALLTOP)/lib; \
233 $(RANLIB) $(DLIB); \
234 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
235 cp des.h $(INSTALLTOP)/include; \
236 chmod 644 $(INSTALLTOP)/include/des.h; \
237 else \
238 echo Standalone install; \
239 cp $(DLIB) $(LIBDIR)/$(DLIB); \
240 $(RANLIB) $(DLIB); \
241 chmod 644 $(LIBDIR)/$(DLIB); \
242 cp des $(BINDIR)/des; \
243 chmod 711 $(BINDIR)/des; \
244 cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
245 chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
246 cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \
247 chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \
248 cp des.h $(INCDIR)/des.h; \
249 chmod 644 $(INCDIR)/des.h; \
250 fi
251# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/des/PC1 b/src/lib/libcrypto/des/PC1
index efb8348b72..e69de29bb2 100644
--- a/src/lib/libcrypto/des/PC1
+++ b/src/lib/libcrypto/des/PC1
@@ -1,28 +0,0 @@
1#!/usr/local/bin/perl
2
3@PC1=( 57,49,41,33,25,17, 9,
4 1,58,50,42,34,26,18,
5 10, 2,59,51,43,35,27,
6 19,11, 3,60,52,44,36,
7 "-","-","-","-",
8 63,55,47,39,31,23,15,
9 7,62,54,46,38,30,22,
10 14, 6,61,53,45,37,29,
11 21,13, 5,28,20,12, 4,
12 "-","-","-","-",
13 );
14
15foreach (@PC1)
16 {
17 if ($_ ne "-")
18 {
19 $_--;
20 $_=int($_/8)*8+7-($_%8);
21 printf "%2d ",$_;
22 }
23 else
24 { print "-- "; }
25 print "\n" if (((++$i) % 8) == 0);
26 print "\n" if ((($i) % 32) == 0);
27 }
28
diff --git a/src/lib/libcrypto/des/PC2 b/src/lib/libcrypto/des/PC2
index 2d560270ec..e69de29bb2 100644
--- a/src/lib/libcrypto/des/PC2
+++ b/src/lib/libcrypto/des/PC2
@@ -1,57 +0,0 @@
1#!/usr/local/bin/perl
2
3@PC2_C=(14,17,11,24, 1, 5,
4 3,28,15, 6,21,10,
5 23,19,12, 4,26, 8,
6 16, 7,27,20,13, 2,
7 );
8
9@PC2_D=(41,52,31,37,47,55,
10 30,40,51,45,33,48,
11 44,49,39,56,34,53,
12 46,42,50,36,29,32,
13 );
14
15foreach (@PC2_C) {
16 if ($_ ne "-")
17 {
18 $_--;
19 printf "%2d ",$_; }
20 else { print "-- "; }
21 $C{$_}=1;
22 print "\n" if (((++$i) % 8) == 0);
23 }
24$i=0;
25print "\n";
26foreach (@PC2_D) {
27 if ($_ ne "-")
28 {
29 $_-=29;
30 printf "%2d ",$_; }
31 else { print "-- "; }
32 $D{$_}=1;
33 print "\n" if (((++$i) % 8) == 0); }
34
35print "\n";
36foreach $i (0 .. 27)
37 {
38 $_=$C{$i};
39 if ($_ ne "-") {printf "%2d ",$_;}
40 else { print "-- "; }
41 print "\n" if (((++$i) % 8) == 0);
42 }
43print "\n";
44
45print "\n";
46foreach $i (0 .. 27)
47 {
48 $_=$D{$i};
49 if ($_ ne "-") {printf "%2d ",$_;}
50 else { print "-- "; }
51 print "\n" if (((++$i) % 8) == 0);
52 }
53print "\n";
54sub numsort
55 {
56 $a-$b;
57 }
diff --git a/src/lib/libcrypto/des/asm/d-win32.asm b/src/lib/libcrypto/des/asm/d-win32.asm
index 9e3dc9cd87..e69de29bb2 100644
--- a/src/lib/libcrypto/des/asm/d-win32.asm
+++ b/src/lib/libcrypto/des/asm/d-win32.asm
@@ -1,3132 +0,0 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by des-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE des-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _des_encrypt
12EXTRN _des_SPtrans:DWORD
13_des_encrypt PROC NEAR
14 push esi
15 push edi
16 ;
17 ; Load the 2 words
18 mov esi, DWORD PTR 12[esp]
19 xor ecx, ecx
20 push ebx
21 push ebp
22 mov eax, DWORD PTR [esi]
23 mov ebx, DWORD PTR 28[esp]
24 mov edi, DWORD PTR 4[esi]
25 ;
26 ; IP
27 rol eax, 4
28 mov esi, eax
29 xor eax, edi
30 and eax, 0f0f0f0f0h
31 xor esi, eax
32 xor edi, eax
33 ;
34 rol edi, 20
35 mov eax, edi
36 xor edi, esi
37 and edi, 0fff0000fh
38 xor eax, edi
39 xor esi, edi
40 ;
41 rol eax, 14
42 mov edi, eax
43 xor eax, esi
44 and eax, 033333333h
45 xor edi, eax
46 xor esi, eax
47 ;
48 rol esi, 22
49 mov eax, esi
50 xor esi, edi
51 and esi, 003fc03fch
52 xor eax, esi
53 xor edi, esi
54 ;
55 rol eax, 9
56 mov esi, eax
57 xor eax, edi
58 and eax, 0aaaaaaaah
59 xor esi, eax
60 xor edi, eax
61 ;
62 rol edi, 1
63 mov ebp, DWORD PTR 24[esp]
64 cmp ebx, 0
65 je $L000start_decrypt
66 ;
67 ; Round 0
68 mov eax, DWORD PTR [ebp]
69 xor ebx, ebx
70 mov edx, DWORD PTR 4[ebp]
71 xor eax, esi
72 xor edx, esi
73 and eax, 0fcfcfcfch
74 and edx, 0cfcfcfcfh
75 mov bl, al
76 mov cl, ah
77 ror edx, 4
78 mov ebp, DWORD PTR _des_SPtrans[ebx]
79 mov bl, dl
80 xor edi, ebp
81 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
82 xor edi, ebp
83 mov cl, dh
84 shr eax, 16
85 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
86 xor edi, ebp
87 mov bl, ah
88 shr edx, 16
89 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
90 xor edi, ebp
91 mov ebp, DWORD PTR 24[esp]
92 mov cl, dh
93 and eax, 0ffh
94 and edx, 0ffh
95 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
96 xor edi, ebx
97 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
98 xor edi, ebx
99 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
100 xor edi, ebx
101 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
102 xor edi, ebx
103 ;
104 ; Round 1
105 mov eax, DWORD PTR 8[ebp]
106 xor ebx, ebx
107 mov edx, DWORD PTR 12[ebp]
108 xor eax, edi
109 xor edx, edi
110 and eax, 0fcfcfcfch
111 and edx, 0cfcfcfcfh
112 mov bl, al
113 mov cl, ah
114 ror edx, 4
115 mov ebp, DWORD PTR _des_SPtrans[ebx]
116 mov bl, dl
117 xor esi, ebp
118 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
119 xor esi, ebp
120 mov cl, dh
121 shr eax, 16
122 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
123 xor esi, ebp
124 mov bl, ah
125 shr edx, 16
126 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
127 xor esi, ebp
128 mov ebp, DWORD PTR 24[esp]
129 mov cl, dh
130 and eax, 0ffh
131 and edx, 0ffh
132 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
133 xor esi, ebx
134 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
135 xor esi, ebx
136 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
137 xor esi, ebx
138 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
139 xor esi, ebx
140 ;
141 ; Round 2
142 mov eax, DWORD PTR 16[ebp]
143 xor ebx, ebx
144 mov edx, DWORD PTR 20[ebp]
145 xor eax, esi
146 xor edx, esi
147 and eax, 0fcfcfcfch
148 and edx, 0cfcfcfcfh
149 mov bl, al
150 mov cl, ah
151 ror edx, 4
152 mov ebp, DWORD PTR _des_SPtrans[ebx]
153 mov bl, dl
154 xor edi, ebp
155 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
156 xor edi, ebp
157 mov cl, dh
158 shr eax, 16
159 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
160 xor edi, ebp
161 mov bl, ah
162 shr edx, 16
163 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
164 xor edi, ebp
165 mov ebp, DWORD PTR 24[esp]
166 mov cl, dh
167 and eax, 0ffh
168 and edx, 0ffh
169 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
170 xor edi, ebx
171 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
172 xor edi, ebx
173 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
174 xor edi, ebx
175 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
176 xor edi, ebx
177 ;
178 ; Round 3
179 mov eax, DWORD PTR 24[ebp]
180 xor ebx, ebx
181 mov edx, DWORD PTR 28[ebp]
182 xor eax, edi
183 xor edx, edi
184 and eax, 0fcfcfcfch
185 and edx, 0cfcfcfcfh
186 mov bl, al
187 mov cl, ah
188 ror edx, 4
189 mov ebp, DWORD PTR _des_SPtrans[ebx]
190 mov bl, dl
191 xor esi, ebp
192 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
193 xor esi, ebp
194 mov cl, dh
195 shr eax, 16
196 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
197 xor esi, ebp
198 mov bl, ah
199 shr edx, 16
200 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
201 xor esi, ebp
202 mov ebp, DWORD PTR 24[esp]
203 mov cl, dh
204 and eax, 0ffh
205 and edx, 0ffh
206 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
207 xor esi, ebx
208 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
209 xor esi, ebx
210 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
211 xor esi, ebx
212 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
213 xor esi, ebx
214 ;
215 ; Round 4
216 mov eax, DWORD PTR 32[ebp]
217 xor ebx, ebx
218 mov edx, DWORD PTR 36[ebp]
219 xor eax, esi
220 xor edx, esi
221 and eax, 0fcfcfcfch
222 and edx, 0cfcfcfcfh
223 mov bl, al
224 mov cl, ah
225 ror edx, 4
226 mov ebp, DWORD PTR _des_SPtrans[ebx]
227 mov bl, dl
228 xor edi, ebp
229 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
230 xor edi, ebp
231 mov cl, dh
232 shr eax, 16
233 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
234 xor edi, ebp
235 mov bl, ah
236 shr edx, 16
237 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
238 xor edi, ebp
239 mov ebp, DWORD PTR 24[esp]
240 mov cl, dh
241 and eax, 0ffh
242 and edx, 0ffh
243 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
244 xor edi, ebx
245 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
246 xor edi, ebx
247 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
248 xor edi, ebx
249 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
250 xor edi, ebx
251 ;
252 ; Round 5
253 mov eax, DWORD PTR 40[ebp]
254 xor ebx, ebx
255 mov edx, DWORD PTR 44[ebp]
256 xor eax, edi
257 xor edx, edi
258 and eax, 0fcfcfcfch
259 and edx, 0cfcfcfcfh
260 mov bl, al
261 mov cl, ah
262 ror edx, 4
263 mov ebp, DWORD PTR _des_SPtrans[ebx]
264 mov bl, dl
265 xor esi, ebp
266 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
267 xor esi, ebp
268 mov cl, dh
269 shr eax, 16
270 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
271 xor esi, ebp
272 mov bl, ah
273 shr edx, 16
274 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
275 xor esi, ebp
276 mov ebp, DWORD PTR 24[esp]
277 mov cl, dh
278 and eax, 0ffh
279 and edx, 0ffh
280 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
281 xor esi, ebx
282 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
283 xor esi, ebx
284 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
285 xor esi, ebx
286 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
287 xor esi, ebx
288 ;
289 ; Round 6
290 mov eax, DWORD PTR 48[ebp]
291 xor ebx, ebx
292 mov edx, DWORD PTR 52[ebp]
293 xor eax, esi
294 xor edx, esi
295 and eax, 0fcfcfcfch
296 and edx, 0cfcfcfcfh
297 mov bl, al
298 mov cl, ah
299 ror edx, 4
300 mov ebp, DWORD PTR _des_SPtrans[ebx]
301 mov bl, dl
302 xor edi, ebp
303 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
304 xor edi, ebp
305 mov cl, dh
306 shr eax, 16
307 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
308 xor edi, ebp
309 mov bl, ah
310 shr edx, 16
311 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
312 xor edi, ebp
313 mov ebp, DWORD PTR 24[esp]
314 mov cl, dh
315 and eax, 0ffh
316 and edx, 0ffh
317 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
318 xor edi, ebx
319 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
320 xor edi, ebx
321 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
322 xor edi, ebx
323 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
324 xor edi, ebx
325 ;
326 ; Round 7
327 mov eax, DWORD PTR 56[ebp]
328 xor ebx, ebx
329 mov edx, DWORD PTR 60[ebp]
330 xor eax, edi
331 xor edx, edi
332 and eax, 0fcfcfcfch
333 and edx, 0cfcfcfcfh
334 mov bl, al
335 mov cl, ah
336 ror edx, 4
337 mov ebp, DWORD PTR _des_SPtrans[ebx]
338 mov bl, dl
339 xor esi, ebp
340 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
341 xor esi, ebp
342 mov cl, dh
343 shr eax, 16
344 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
345 xor esi, ebp
346 mov bl, ah
347 shr edx, 16
348 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
349 xor esi, ebp
350 mov ebp, DWORD PTR 24[esp]
351 mov cl, dh
352 and eax, 0ffh
353 and edx, 0ffh
354 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
355 xor esi, ebx
356 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
357 xor esi, ebx
358 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
359 xor esi, ebx
360 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
361 xor esi, ebx
362 ;
363 ; Round 8
364 mov eax, DWORD PTR 64[ebp]
365 xor ebx, ebx
366 mov edx, DWORD PTR 68[ebp]
367 xor eax, esi
368 xor edx, esi
369 and eax, 0fcfcfcfch
370 and edx, 0cfcfcfcfh
371 mov bl, al
372 mov cl, ah
373 ror edx, 4
374 mov ebp, DWORD PTR _des_SPtrans[ebx]
375 mov bl, dl
376 xor edi, ebp
377 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
378 xor edi, ebp
379 mov cl, dh
380 shr eax, 16
381 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
382 xor edi, ebp
383 mov bl, ah
384 shr edx, 16
385 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
386 xor edi, ebp
387 mov ebp, DWORD PTR 24[esp]
388 mov cl, dh
389 and eax, 0ffh
390 and edx, 0ffh
391 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
392 xor edi, ebx
393 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
394 xor edi, ebx
395 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
396 xor edi, ebx
397 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
398 xor edi, ebx
399 ;
400 ; Round 9
401 mov eax, DWORD PTR 72[ebp]
402 xor ebx, ebx
403 mov edx, DWORD PTR 76[ebp]
404 xor eax, edi
405 xor edx, edi
406 and eax, 0fcfcfcfch
407 and edx, 0cfcfcfcfh
408 mov bl, al
409 mov cl, ah
410 ror edx, 4
411 mov ebp, DWORD PTR _des_SPtrans[ebx]
412 mov bl, dl
413 xor esi, ebp
414 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
415 xor esi, ebp
416 mov cl, dh
417 shr eax, 16
418 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
419 xor esi, ebp
420 mov bl, ah
421 shr edx, 16
422 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
423 xor esi, ebp
424 mov ebp, DWORD PTR 24[esp]
425 mov cl, dh
426 and eax, 0ffh
427 and edx, 0ffh
428 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
429 xor esi, ebx
430 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
431 xor esi, ebx
432 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
433 xor esi, ebx
434 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
435 xor esi, ebx
436 ;
437 ; Round 10
438 mov eax, DWORD PTR 80[ebp]
439 xor ebx, ebx
440 mov edx, DWORD PTR 84[ebp]
441 xor eax, esi
442 xor edx, esi
443 and eax, 0fcfcfcfch
444 and edx, 0cfcfcfcfh
445 mov bl, al
446 mov cl, ah
447 ror edx, 4
448 mov ebp, DWORD PTR _des_SPtrans[ebx]
449 mov bl, dl
450 xor edi, ebp
451 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
452 xor edi, ebp
453 mov cl, dh
454 shr eax, 16
455 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
456 xor edi, ebp
457 mov bl, ah
458 shr edx, 16
459 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
460 xor edi, ebp
461 mov ebp, DWORD PTR 24[esp]
462 mov cl, dh
463 and eax, 0ffh
464 and edx, 0ffh
465 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
466 xor edi, ebx
467 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
468 xor edi, ebx
469 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
470 xor edi, ebx
471 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
472 xor edi, ebx
473 ;
474 ; Round 11
475 mov eax, DWORD PTR 88[ebp]
476 xor ebx, ebx
477 mov edx, DWORD PTR 92[ebp]
478 xor eax, edi
479 xor edx, edi
480 and eax, 0fcfcfcfch
481 and edx, 0cfcfcfcfh
482 mov bl, al
483 mov cl, ah
484 ror edx, 4
485 mov ebp, DWORD PTR _des_SPtrans[ebx]
486 mov bl, dl
487 xor esi, ebp
488 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
489 xor esi, ebp
490 mov cl, dh
491 shr eax, 16
492 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
493 xor esi, ebp
494 mov bl, ah
495 shr edx, 16
496 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
497 xor esi, ebp
498 mov ebp, DWORD PTR 24[esp]
499 mov cl, dh
500 and eax, 0ffh
501 and edx, 0ffh
502 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
503 xor esi, ebx
504 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
505 xor esi, ebx
506 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
507 xor esi, ebx
508 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
509 xor esi, ebx
510 ;
511 ; Round 12
512 mov eax, DWORD PTR 96[ebp]
513 xor ebx, ebx
514 mov edx, DWORD PTR 100[ebp]
515 xor eax, esi
516 xor edx, esi
517 and eax, 0fcfcfcfch
518 and edx, 0cfcfcfcfh
519 mov bl, al
520 mov cl, ah
521 ror edx, 4
522 mov ebp, DWORD PTR _des_SPtrans[ebx]
523 mov bl, dl
524 xor edi, ebp
525 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
526 xor edi, ebp
527 mov cl, dh
528 shr eax, 16
529 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
530 xor edi, ebp
531 mov bl, ah
532 shr edx, 16
533 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
534 xor edi, ebp
535 mov ebp, DWORD PTR 24[esp]
536 mov cl, dh
537 and eax, 0ffh
538 and edx, 0ffh
539 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
540 xor edi, ebx
541 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
542 xor edi, ebx
543 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
544 xor edi, ebx
545 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
546 xor edi, ebx
547 ;
548 ; Round 13
549 mov eax, DWORD PTR 104[ebp]
550 xor ebx, ebx
551 mov edx, DWORD PTR 108[ebp]
552 xor eax, edi
553 xor edx, edi
554 and eax, 0fcfcfcfch
555 and edx, 0cfcfcfcfh
556 mov bl, al
557 mov cl, ah
558 ror edx, 4
559 mov ebp, DWORD PTR _des_SPtrans[ebx]
560 mov bl, dl
561 xor esi, ebp
562 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
563 xor esi, ebp
564 mov cl, dh
565 shr eax, 16
566 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
567 xor esi, ebp
568 mov bl, ah
569 shr edx, 16
570 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
571 xor esi, ebp
572 mov ebp, DWORD PTR 24[esp]
573 mov cl, dh
574 and eax, 0ffh
575 and edx, 0ffh
576 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
577 xor esi, ebx
578 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
579 xor esi, ebx
580 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
581 xor esi, ebx
582 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
583 xor esi, ebx
584 ;
585 ; Round 14
586 mov eax, DWORD PTR 112[ebp]
587 xor ebx, ebx
588 mov edx, DWORD PTR 116[ebp]
589 xor eax, esi
590 xor edx, esi
591 and eax, 0fcfcfcfch
592 and edx, 0cfcfcfcfh
593 mov bl, al
594 mov cl, ah
595 ror edx, 4
596 mov ebp, DWORD PTR _des_SPtrans[ebx]
597 mov bl, dl
598 xor edi, ebp
599 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
600 xor edi, ebp
601 mov cl, dh
602 shr eax, 16
603 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
604 xor edi, ebp
605 mov bl, ah
606 shr edx, 16
607 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
608 xor edi, ebp
609 mov ebp, DWORD PTR 24[esp]
610 mov cl, dh
611 and eax, 0ffh
612 and edx, 0ffh
613 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
614 xor edi, ebx
615 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
616 xor edi, ebx
617 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
618 xor edi, ebx
619 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
620 xor edi, ebx
621 ;
622 ; Round 15
623 mov eax, DWORD PTR 120[ebp]
624 xor ebx, ebx
625 mov edx, DWORD PTR 124[ebp]
626 xor eax, edi
627 xor edx, edi
628 and eax, 0fcfcfcfch
629 and edx, 0cfcfcfcfh
630 mov bl, al
631 mov cl, ah
632 ror edx, 4
633 mov ebp, DWORD PTR _des_SPtrans[ebx]
634 mov bl, dl
635 xor esi, ebp
636 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
637 xor esi, ebp
638 mov cl, dh
639 shr eax, 16
640 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
641 xor esi, ebp
642 mov bl, ah
643 shr edx, 16
644 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
645 xor esi, ebp
646 mov ebp, DWORD PTR 24[esp]
647 mov cl, dh
648 and eax, 0ffh
649 and edx, 0ffh
650 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
651 xor esi, ebx
652 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
653 xor esi, ebx
654 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
655 xor esi, ebx
656 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
657 xor esi, ebx
658 jmp $L001end
659$L000start_decrypt:
660 ;
661 ; Round 15
662 mov eax, DWORD PTR 120[ebp]
663 xor ebx, ebx
664 mov edx, DWORD PTR 124[ebp]
665 xor eax, esi
666 xor edx, esi
667 and eax, 0fcfcfcfch
668 and edx, 0cfcfcfcfh
669 mov bl, al
670 mov cl, ah
671 ror edx, 4
672 mov ebp, DWORD PTR _des_SPtrans[ebx]
673 mov bl, dl
674 xor edi, ebp
675 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
676 xor edi, ebp
677 mov cl, dh
678 shr eax, 16
679 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
680 xor edi, ebp
681 mov bl, ah
682 shr edx, 16
683 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
684 xor edi, ebp
685 mov ebp, DWORD PTR 24[esp]
686 mov cl, dh
687 and eax, 0ffh
688 and edx, 0ffh
689 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
690 xor edi, ebx
691 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
692 xor edi, ebx
693 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
694 xor edi, ebx
695 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
696 xor edi, ebx
697 ;
698 ; Round 14
699 mov eax, DWORD PTR 112[ebp]
700 xor ebx, ebx
701 mov edx, DWORD PTR 116[ebp]
702 xor eax, edi
703 xor edx, edi
704 and eax, 0fcfcfcfch
705 and edx, 0cfcfcfcfh
706 mov bl, al
707 mov cl, ah
708 ror edx, 4
709 mov ebp, DWORD PTR _des_SPtrans[ebx]
710 mov bl, dl
711 xor esi, ebp
712 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
713 xor esi, ebp
714 mov cl, dh
715 shr eax, 16
716 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
717 xor esi, ebp
718 mov bl, ah
719 shr edx, 16
720 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
721 xor esi, ebp
722 mov ebp, DWORD PTR 24[esp]
723 mov cl, dh
724 and eax, 0ffh
725 and edx, 0ffh
726 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
727 xor esi, ebx
728 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
729 xor esi, ebx
730 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
731 xor esi, ebx
732 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
733 xor esi, ebx
734 ;
735 ; Round 13
736 mov eax, DWORD PTR 104[ebp]
737 xor ebx, ebx
738 mov edx, DWORD PTR 108[ebp]
739 xor eax, esi
740 xor edx, esi
741 and eax, 0fcfcfcfch
742 and edx, 0cfcfcfcfh
743 mov bl, al
744 mov cl, ah
745 ror edx, 4
746 mov ebp, DWORD PTR _des_SPtrans[ebx]
747 mov bl, dl
748 xor edi, ebp
749 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
750 xor edi, ebp
751 mov cl, dh
752 shr eax, 16
753 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
754 xor edi, ebp
755 mov bl, ah
756 shr edx, 16
757 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
758 xor edi, ebp
759 mov ebp, DWORD PTR 24[esp]
760 mov cl, dh
761 and eax, 0ffh
762 and edx, 0ffh
763 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
764 xor edi, ebx
765 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
766 xor edi, ebx
767 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
768 xor edi, ebx
769 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
770 xor edi, ebx
771 ;
772 ; Round 12
773 mov eax, DWORD PTR 96[ebp]
774 xor ebx, ebx
775 mov edx, DWORD PTR 100[ebp]
776 xor eax, edi
777 xor edx, edi
778 and eax, 0fcfcfcfch
779 and edx, 0cfcfcfcfh
780 mov bl, al
781 mov cl, ah
782 ror edx, 4
783 mov ebp, DWORD PTR _des_SPtrans[ebx]
784 mov bl, dl
785 xor esi, ebp
786 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
787 xor esi, ebp
788 mov cl, dh
789 shr eax, 16
790 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
791 xor esi, ebp
792 mov bl, ah
793 shr edx, 16
794 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
795 xor esi, ebp
796 mov ebp, DWORD PTR 24[esp]
797 mov cl, dh
798 and eax, 0ffh
799 and edx, 0ffh
800 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
801 xor esi, ebx
802 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
803 xor esi, ebx
804 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
805 xor esi, ebx
806 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
807 xor esi, ebx
808 ;
809 ; Round 11
810 mov eax, DWORD PTR 88[ebp]
811 xor ebx, ebx
812 mov edx, DWORD PTR 92[ebp]
813 xor eax, esi
814 xor edx, esi
815 and eax, 0fcfcfcfch
816 and edx, 0cfcfcfcfh
817 mov bl, al
818 mov cl, ah
819 ror edx, 4
820 mov ebp, DWORD PTR _des_SPtrans[ebx]
821 mov bl, dl
822 xor edi, ebp
823 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
824 xor edi, ebp
825 mov cl, dh
826 shr eax, 16
827 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
828 xor edi, ebp
829 mov bl, ah
830 shr edx, 16
831 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
832 xor edi, ebp
833 mov ebp, DWORD PTR 24[esp]
834 mov cl, dh
835 and eax, 0ffh
836 and edx, 0ffh
837 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
838 xor edi, ebx
839 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
840 xor edi, ebx
841 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
842 xor edi, ebx
843 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
844 xor edi, ebx
845 ;
846 ; Round 10
847 mov eax, DWORD PTR 80[ebp]
848 xor ebx, ebx
849 mov edx, DWORD PTR 84[ebp]
850 xor eax, edi
851 xor edx, edi
852 and eax, 0fcfcfcfch
853 and edx, 0cfcfcfcfh
854 mov bl, al
855 mov cl, ah
856 ror edx, 4
857 mov ebp, DWORD PTR _des_SPtrans[ebx]
858 mov bl, dl
859 xor esi, ebp
860 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
861 xor esi, ebp
862 mov cl, dh
863 shr eax, 16
864 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
865 xor esi, ebp
866 mov bl, ah
867 shr edx, 16
868 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
869 xor esi, ebp
870 mov ebp, DWORD PTR 24[esp]
871 mov cl, dh
872 and eax, 0ffh
873 and edx, 0ffh
874 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
875 xor esi, ebx
876 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
877 xor esi, ebx
878 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
879 xor esi, ebx
880 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
881 xor esi, ebx
882 ;
883 ; Round 9
884 mov eax, DWORD PTR 72[ebp]
885 xor ebx, ebx
886 mov edx, DWORD PTR 76[ebp]
887 xor eax, esi
888 xor edx, esi
889 and eax, 0fcfcfcfch
890 and edx, 0cfcfcfcfh
891 mov bl, al
892 mov cl, ah
893 ror edx, 4
894 mov ebp, DWORD PTR _des_SPtrans[ebx]
895 mov bl, dl
896 xor edi, ebp
897 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
898 xor edi, ebp
899 mov cl, dh
900 shr eax, 16
901 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
902 xor edi, ebp
903 mov bl, ah
904 shr edx, 16
905 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
906 xor edi, ebp
907 mov ebp, DWORD PTR 24[esp]
908 mov cl, dh
909 and eax, 0ffh
910 and edx, 0ffh
911 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
912 xor edi, ebx
913 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
914 xor edi, ebx
915 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
916 xor edi, ebx
917 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
918 xor edi, ebx
919 ;
920 ; Round 8
921 mov eax, DWORD PTR 64[ebp]
922 xor ebx, ebx
923 mov edx, DWORD PTR 68[ebp]
924 xor eax, edi
925 xor edx, edi
926 and eax, 0fcfcfcfch
927 and edx, 0cfcfcfcfh
928 mov bl, al
929 mov cl, ah
930 ror edx, 4
931 mov ebp, DWORD PTR _des_SPtrans[ebx]
932 mov bl, dl
933 xor esi, ebp
934 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
935 xor esi, ebp
936 mov cl, dh
937 shr eax, 16
938 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
939 xor esi, ebp
940 mov bl, ah
941 shr edx, 16
942 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
943 xor esi, ebp
944 mov ebp, DWORD PTR 24[esp]
945 mov cl, dh
946 and eax, 0ffh
947 and edx, 0ffh
948 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
949 xor esi, ebx
950 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
951 xor esi, ebx
952 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
953 xor esi, ebx
954 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
955 xor esi, ebx
956 ;
957 ; Round 7
958 mov eax, DWORD PTR 56[ebp]
959 xor ebx, ebx
960 mov edx, DWORD PTR 60[ebp]
961 xor eax, esi
962 xor edx, esi
963 and eax, 0fcfcfcfch
964 and edx, 0cfcfcfcfh
965 mov bl, al
966 mov cl, ah
967 ror edx, 4
968 mov ebp, DWORD PTR _des_SPtrans[ebx]
969 mov bl, dl
970 xor edi, ebp
971 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
972 xor edi, ebp
973 mov cl, dh
974 shr eax, 16
975 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
976 xor edi, ebp
977 mov bl, ah
978 shr edx, 16
979 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
980 xor edi, ebp
981 mov ebp, DWORD PTR 24[esp]
982 mov cl, dh
983 and eax, 0ffh
984 and edx, 0ffh
985 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
986 xor edi, ebx
987 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
988 xor edi, ebx
989 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
990 xor edi, ebx
991 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
992 xor edi, ebx
993 ;
994 ; Round 6
995 mov eax, DWORD PTR 48[ebp]
996 xor ebx, ebx
997 mov edx, DWORD PTR 52[ebp]
998 xor eax, edi
999 xor edx, edi
1000 and eax, 0fcfcfcfch
1001 and edx, 0cfcfcfcfh
1002 mov bl, al
1003 mov cl, ah
1004 ror edx, 4
1005 mov ebp, DWORD PTR _des_SPtrans[ebx]
1006 mov bl, dl
1007 xor esi, ebp
1008 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1009 xor esi, ebp
1010 mov cl, dh
1011 shr eax, 16
1012 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1013 xor esi, ebp
1014 mov bl, ah
1015 shr edx, 16
1016 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1017 xor esi, ebp
1018 mov ebp, DWORD PTR 24[esp]
1019 mov cl, dh
1020 and eax, 0ffh
1021 and edx, 0ffh
1022 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1023 xor esi, ebx
1024 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1025 xor esi, ebx
1026 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1027 xor esi, ebx
1028 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1029 xor esi, ebx
1030 ;
1031 ; Round 5
1032 mov eax, DWORD PTR 40[ebp]
1033 xor ebx, ebx
1034 mov edx, DWORD PTR 44[ebp]
1035 xor eax, esi
1036 xor edx, esi
1037 and eax, 0fcfcfcfch
1038 and edx, 0cfcfcfcfh
1039 mov bl, al
1040 mov cl, ah
1041 ror edx, 4
1042 mov ebp, DWORD PTR _des_SPtrans[ebx]
1043 mov bl, dl
1044 xor edi, ebp
1045 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1046 xor edi, ebp
1047 mov cl, dh
1048 shr eax, 16
1049 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1050 xor edi, ebp
1051 mov bl, ah
1052 shr edx, 16
1053 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1054 xor edi, ebp
1055 mov ebp, DWORD PTR 24[esp]
1056 mov cl, dh
1057 and eax, 0ffh
1058 and edx, 0ffh
1059 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1060 xor edi, ebx
1061 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1062 xor edi, ebx
1063 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1064 xor edi, ebx
1065 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1066 xor edi, ebx
1067 ;
1068 ; Round 4
1069 mov eax, DWORD PTR 32[ebp]
1070 xor ebx, ebx
1071 mov edx, DWORD PTR 36[ebp]
1072 xor eax, edi
1073 xor edx, edi
1074 and eax, 0fcfcfcfch
1075 and edx, 0cfcfcfcfh
1076 mov bl, al
1077 mov cl, ah
1078 ror edx, 4
1079 mov ebp, DWORD PTR _des_SPtrans[ebx]
1080 mov bl, dl
1081 xor esi, ebp
1082 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1083 xor esi, ebp
1084 mov cl, dh
1085 shr eax, 16
1086 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1087 xor esi, ebp
1088 mov bl, ah
1089 shr edx, 16
1090 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1091 xor esi, ebp
1092 mov ebp, DWORD PTR 24[esp]
1093 mov cl, dh
1094 and eax, 0ffh
1095 and edx, 0ffh
1096 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1097 xor esi, ebx
1098 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1099 xor esi, ebx
1100 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1101 xor esi, ebx
1102 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1103 xor esi, ebx
1104 ;
1105 ; Round 3
1106 mov eax, DWORD PTR 24[ebp]
1107 xor ebx, ebx
1108 mov edx, DWORD PTR 28[ebp]
1109 xor eax, esi
1110 xor edx, esi
1111 and eax, 0fcfcfcfch
1112 and edx, 0cfcfcfcfh
1113 mov bl, al
1114 mov cl, ah
1115 ror edx, 4
1116 mov ebp, DWORD PTR _des_SPtrans[ebx]
1117 mov bl, dl
1118 xor edi, ebp
1119 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1120 xor edi, ebp
1121 mov cl, dh
1122 shr eax, 16
1123 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1124 xor edi, ebp
1125 mov bl, ah
1126 shr edx, 16
1127 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1128 xor edi, ebp
1129 mov ebp, DWORD PTR 24[esp]
1130 mov cl, dh
1131 and eax, 0ffh
1132 and edx, 0ffh
1133 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1134 xor edi, ebx
1135 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1136 xor edi, ebx
1137 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1138 xor edi, ebx
1139 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1140 xor edi, ebx
1141 ;
1142 ; Round 2
1143 mov eax, DWORD PTR 16[ebp]
1144 xor ebx, ebx
1145 mov edx, DWORD PTR 20[ebp]
1146 xor eax, edi
1147 xor edx, edi
1148 and eax, 0fcfcfcfch
1149 and edx, 0cfcfcfcfh
1150 mov bl, al
1151 mov cl, ah
1152 ror edx, 4
1153 mov ebp, DWORD PTR _des_SPtrans[ebx]
1154 mov bl, dl
1155 xor esi, ebp
1156 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1157 xor esi, ebp
1158 mov cl, dh
1159 shr eax, 16
1160 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1161 xor esi, ebp
1162 mov bl, ah
1163 shr edx, 16
1164 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1165 xor esi, ebp
1166 mov ebp, DWORD PTR 24[esp]
1167 mov cl, dh
1168 and eax, 0ffh
1169 and edx, 0ffh
1170 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1171 xor esi, ebx
1172 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1173 xor esi, ebx
1174 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1175 xor esi, ebx
1176 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1177 xor esi, ebx
1178 ;
1179 ; Round 1
1180 mov eax, DWORD PTR 8[ebp]
1181 xor ebx, ebx
1182 mov edx, DWORD PTR 12[ebp]
1183 xor eax, esi
1184 xor edx, esi
1185 and eax, 0fcfcfcfch
1186 and edx, 0cfcfcfcfh
1187 mov bl, al
1188 mov cl, ah
1189 ror edx, 4
1190 mov ebp, DWORD PTR _des_SPtrans[ebx]
1191 mov bl, dl
1192 xor edi, ebp
1193 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1194 xor edi, ebp
1195 mov cl, dh
1196 shr eax, 16
1197 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1198 xor edi, ebp
1199 mov bl, ah
1200 shr edx, 16
1201 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1202 xor edi, ebp
1203 mov ebp, DWORD PTR 24[esp]
1204 mov cl, dh
1205 and eax, 0ffh
1206 and edx, 0ffh
1207 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1208 xor edi, ebx
1209 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1210 xor edi, ebx
1211 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1212 xor edi, ebx
1213 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1214 xor edi, ebx
1215 ;
1216 ; Round 0
1217 mov eax, DWORD PTR [ebp]
1218 xor ebx, ebx
1219 mov edx, DWORD PTR 4[ebp]
1220 xor eax, edi
1221 xor edx, edi
1222 and eax, 0fcfcfcfch
1223 and edx, 0cfcfcfcfh
1224 mov bl, al
1225 mov cl, ah
1226 ror edx, 4
1227 mov ebp, DWORD PTR _des_SPtrans[ebx]
1228 mov bl, dl
1229 xor esi, ebp
1230 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1231 xor esi, ebp
1232 mov cl, dh
1233 shr eax, 16
1234 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1235 xor esi, ebp
1236 mov bl, ah
1237 shr edx, 16
1238 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1239 xor esi, ebp
1240 mov ebp, DWORD PTR 24[esp]
1241 mov cl, dh
1242 and eax, 0ffh
1243 and edx, 0ffh
1244 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1245 xor esi, ebx
1246 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1247 xor esi, ebx
1248 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1249 xor esi, ebx
1250 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1251 xor esi, ebx
1252$L001end:
1253 ;
1254 ; FP
1255 mov edx, DWORD PTR 20[esp]
1256 ror esi, 1
1257 mov eax, edi
1258 xor edi, esi
1259 and edi, 0aaaaaaaah
1260 xor eax, edi
1261 xor esi, edi
1262 ;
1263 rol eax, 23
1264 mov edi, eax
1265 xor eax, esi
1266 and eax, 003fc03fch
1267 xor edi, eax
1268 xor esi, eax
1269 ;
1270 rol edi, 10
1271 mov eax, edi
1272 xor edi, esi
1273 and edi, 033333333h
1274 xor eax, edi
1275 xor esi, edi
1276 ;
1277 rol esi, 18
1278 mov edi, esi
1279 xor esi, eax
1280 and esi, 0fff0000fh
1281 xor edi, esi
1282 xor eax, esi
1283 ;
1284 rol edi, 12
1285 mov esi, edi
1286 xor edi, eax
1287 and edi, 0f0f0f0f0h
1288 xor esi, edi
1289 xor eax, edi
1290 ;
1291 ror eax, 4
1292 mov DWORD PTR [edx],eax
1293 mov DWORD PTR 4[edx],esi
1294 pop ebp
1295 pop ebx
1296 pop edi
1297 pop esi
1298 ret
1299_des_encrypt ENDP
1300_TEXT ENDS
1301_TEXT SEGMENT
1302PUBLIC _des_encrypt2
1303EXTRN _des_SPtrans:DWORD
1304_des_encrypt2 PROC NEAR
1305 push esi
1306 push edi
1307 ;
1308 ; Load the 2 words
1309 mov eax, DWORD PTR 12[esp]
1310 xor ecx, ecx
1311 push ebx
1312 push ebp
1313 mov esi, DWORD PTR [eax]
1314 mov ebx, DWORD PTR 28[esp]
1315 rol esi, 3
1316 mov edi, DWORD PTR 4[eax]
1317 rol edi, 3
1318 mov ebp, DWORD PTR 24[esp]
1319 cmp ebx, 0
1320 je $L002start_decrypt
1321 ;
1322 ; Round 0
1323 mov eax, DWORD PTR [ebp]
1324 xor ebx, ebx
1325 mov edx, DWORD PTR 4[ebp]
1326 xor eax, esi
1327 xor edx, esi
1328 and eax, 0fcfcfcfch
1329 and edx, 0cfcfcfcfh
1330 mov bl, al
1331 mov cl, ah
1332 ror edx, 4
1333 mov ebp, DWORD PTR _des_SPtrans[ebx]
1334 mov bl, dl
1335 xor edi, ebp
1336 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1337 xor edi, ebp
1338 mov cl, dh
1339 shr eax, 16
1340 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1341 xor edi, ebp
1342 mov bl, ah
1343 shr edx, 16
1344 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1345 xor edi, ebp
1346 mov ebp, DWORD PTR 24[esp]
1347 mov cl, dh
1348 and eax, 0ffh
1349 and edx, 0ffh
1350 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1351 xor edi, ebx
1352 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1353 xor edi, ebx
1354 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1355 xor edi, ebx
1356 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1357 xor edi, ebx
1358 ;
1359 ; Round 1
1360 mov eax, DWORD PTR 8[ebp]
1361 xor ebx, ebx
1362 mov edx, DWORD PTR 12[ebp]
1363 xor eax, edi
1364 xor edx, edi
1365 and eax, 0fcfcfcfch
1366 and edx, 0cfcfcfcfh
1367 mov bl, al
1368 mov cl, ah
1369 ror edx, 4
1370 mov ebp, DWORD PTR _des_SPtrans[ebx]
1371 mov bl, dl
1372 xor esi, ebp
1373 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1374 xor esi, ebp
1375 mov cl, dh
1376 shr eax, 16
1377 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1378 xor esi, ebp
1379 mov bl, ah
1380 shr edx, 16
1381 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1382 xor esi, ebp
1383 mov ebp, DWORD PTR 24[esp]
1384 mov cl, dh
1385 and eax, 0ffh
1386 and edx, 0ffh
1387 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1388 xor esi, ebx
1389 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1390 xor esi, ebx
1391 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1392 xor esi, ebx
1393 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1394 xor esi, ebx
1395 ;
1396 ; Round 2
1397 mov eax, DWORD PTR 16[ebp]
1398 xor ebx, ebx
1399 mov edx, DWORD PTR 20[ebp]
1400 xor eax, esi
1401 xor edx, esi
1402 and eax, 0fcfcfcfch
1403 and edx, 0cfcfcfcfh
1404 mov bl, al
1405 mov cl, ah
1406 ror edx, 4
1407 mov ebp, DWORD PTR _des_SPtrans[ebx]
1408 mov bl, dl
1409 xor edi, ebp
1410 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1411 xor edi, ebp
1412 mov cl, dh
1413 shr eax, 16
1414 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1415 xor edi, ebp
1416 mov bl, ah
1417 shr edx, 16
1418 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1419 xor edi, ebp
1420 mov ebp, DWORD PTR 24[esp]
1421 mov cl, dh
1422 and eax, 0ffh
1423 and edx, 0ffh
1424 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1425 xor edi, ebx
1426 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1427 xor edi, ebx
1428 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1429 xor edi, ebx
1430 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1431 xor edi, ebx
1432 ;
1433 ; Round 3
1434 mov eax, DWORD PTR 24[ebp]
1435 xor ebx, ebx
1436 mov edx, DWORD PTR 28[ebp]
1437 xor eax, edi
1438 xor edx, edi
1439 and eax, 0fcfcfcfch
1440 and edx, 0cfcfcfcfh
1441 mov bl, al
1442 mov cl, ah
1443 ror edx, 4
1444 mov ebp, DWORD PTR _des_SPtrans[ebx]
1445 mov bl, dl
1446 xor esi, ebp
1447 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1448 xor esi, ebp
1449 mov cl, dh
1450 shr eax, 16
1451 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1452 xor esi, ebp
1453 mov bl, ah
1454 shr edx, 16
1455 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1456 xor esi, ebp
1457 mov ebp, DWORD PTR 24[esp]
1458 mov cl, dh
1459 and eax, 0ffh
1460 and edx, 0ffh
1461 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1462 xor esi, ebx
1463 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1464 xor esi, ebx
1465 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1466 xor esi, ebx
1467 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1468 xor esi, ebx
1469 ;
1470 ; Round 4
1471 mov eax, DWORD PTR 32[ebp]
1472 xor ebx, ebx
1473 mov edx, DWORD PTR 36[ebp]
1474 xor eax, esi
1475 xor edx, esi
1476 and eax, 0fcfcfcfch
1477 and edx, 0cfcfcfcfh
1478 mov bl, al
1479 mov cl, ah
1480 ror edx, 4
1481 mov ebp, DWORD PTR _des_SPtrans[ebx]
1482 mov bl, dl
1483 xor edi, ebp
1484 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1485 xor edi, ebp
1486 mov cl, dh
1487 shr eax, 16
1488 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1489 xor edi, ebp
1490 mov bl, ah
1491 shr edx, 16
1492 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1493 xor edi, ebp
1494 mov ebp, DWORD PTR 24[esp]
1495 mov cl, dh
1496 and eax, 0ffh
1497 and edx, 0ffh
1498 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1499 xor edi, ebx
1500 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1501 xor edi, ebx
1502 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1503 xor edi, ebx
1504 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1505 xor edi, ebx
1506 ;
1507 ; Round 5
1508 mov eax, DWORD PTR 40[ebp]
1509 xor ebx, ebx
1510 mov edx, DWORD PTR 44[ebp]
1511 xor eax, edi
1512 xor edx, edi
1513 and eax, 0fcfcfcfch
1514 and edx, 0cfcfcfcfh
1515 mov bl, al
1516 mov cl, ah
1517 ror edx, 4
1518 mov ebp, DWORD PTR _des_SPtrans[ebx]
1519 mov bl, dl
1520 xor esi, ebp
1521 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1522 xor esi, ebp
1523 mov cl, dh
1524 shr eax, 16
1525 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1526 xor esi, ebp
1527 mov bl, ah
1528 shr edx, 16
1529 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1530 xor esi, ebp
1531 mov ebp, DWORD PTR 24[esp]
1532 mov cl, dh
1533 and eax, 0ffh
1534 and edx, 0ffh
1535 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1536 xor esi, ebx
1537 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1538 xor esi, ebx
1539 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1540 xor esi, ebx
1541 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1542 xor esi, ebx
1543 ;
1544 ; Round 6
1545 mov eax, DWORD PTR 48[ebp]
1546 xor ebx, ebx
1547 mov edx, DWORD PTR 52[ebp]
1548 xor eax, esi
1549 xor edx, esi
1550 and eax, 0fcfcfcfch
1551 and edx, 0cfcfcfcfh
1552 mov bl, al
1553 mov cl, ah
1554 ror edx, 4
1555 mov ebp, DWORD PTR _des_SPtrans[ebx]
1556 mov bl, dl
1557 xor edi, ebp
1558 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1559 xor edi, ebp
1560 mov cl, dh
1561 shr eax, 16
1562 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1563 xor edi, ebp
1564 mov bl, ah
1565 shr edx, 16
1566 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1567 xor edi, ebp
1568 mov ebp, DWORD PTR 24[esp]
1569 mov cl, dh
1570 and eax, 0ffh
1571 and edx, 0ffh
1572 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1573 xor edi, ebx
1574 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1575 xor edi, ebx
1576 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1577 xor edi, ebx
1578 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1579 xor edi, ebx
1580 ;
1581 ; Round 7
1582 mov eax, DWORD PTR 56[ebp]
1583 xor ebx, ebx
1584 mov edx, DWORD PTR 60[ebp]
1585 xor eax, edi
1586 xor edx, edi
1587 and eax, 0fcfcfcfch
1588 and edx, 0cfcfcfcfh
1589 mov bl, al
1590 mov cl, ah
1591 ror edx, 4
1592 mov ebp, DWORD PTR _des_SPtrans[ebx]
1593 mov bl, dl
1594 xor esi, ebp
1595 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1596 xor esi, ebp
1597 mov cl, dh
1598 shr eax, 16
1599 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1600 xor esi, ebp
1601 mov bl, ah
1602 shr edx, 16
1603 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1604 xor esi, ebp
1605 mov ebp, DWORD PTR 24[esp]
1606 mov cl, dh
1607 and eax, 0ffh
1608 and edx, 0ffh
1609 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1610 xor esi, ebx
1611 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1612 xor esi, ebx
1613 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1614 xor esi, ebx
1615 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1616 xor esi, ebx
1617 ;
1618 ; Round 8
1619 mov eax, DWORD PTR 64[ebp]
1620 xor ebx, ebx
1621 mov edx, DWORD PTR 68[ebp]
1622 xor eax, esi
1623 xor edx, esi
1624 and eax, 0fcfcfcfch
1625 and edx, 0cfcfcfcfh
1626 mov bl, al
1627 mov cl, ah
1628 ror edx, 4
1629 mov ebp, DWORD PTR _des_SPtrans[ebx]
1630 mov bl, dl
1631 xor edi, ebp
1632 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1633 xor edi, ebp
1634 mov cl, dh
1635 shr eax, 16
1636 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1637 xor edi, ebp
1638 mov bl, ah
1639 shr edx, 16
1640 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1641 xor edi, ebp
1642 mov ebp, DWORD PTR 24[esp]
1643 mov cl, dh
1644 and eax, 0ffh
1645 and edx, 0ffh
1646 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1647 xor edi, ebx
1648 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1649 xor edi, ebx
1650 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1651 xor edi, ebx
1652 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1653 xor edi, ebx
1654 ;
1655 ; Round 9
1656 mov eax, DWORD PTR 72[ebp]
1657 xor ebx, ebx
1658 mov edx, DWORD PTR 76[ebp]
1659 xor eax, edi
1660 xor edx, edi
1661 and eax, 0fcfcfcfch
1662 and edx, 0cfcfcfcfh
1663 mov bl, al
1664 mov cl, ah
1665 ror edx, 4
1666 mov ebp, DWORD PTR _des_SPtrans[ebx]
1667 mov bl, dl
1668 xor esi, ebp
1669 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1670 xor esi, ebp
1671 mov cl, dh
1672 shr eax, 16
1673 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1674 xor esi, ebp
1675 mov bl, ah
1676 shr edx, 16
1677 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1678 xor esi, ebp
1679 mov ebp, DWORD PTR 24[esp]
1680 mov cl, dh
1681 and eax, 0ffh
1682 and edx, 0ffh
1683 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1684 xor esi, ebx
1685 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1686 xor esi, ebx
1687 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1688 xor esi, ebx
1689 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1690 xor esi, ebx
1691 ;
1692 ; Round 10
1693 mov eax, DWORD PTR 80[ebp]
1694 xor ebx, ebx
1695 mov edx, DWORD PTR 84[ebp]
1696 xor eax, esi
1697 xor edx, esi
1698 and eax, 0fcfcfcfch
1699 and edx, 0cfcfcfcfh
1700 mov bl, al
1701 mov cl, ah
1702 ror edx, 4
1703 mov ebp, DWORD PTR _des_SPtrans[ebx]
1704 mov bl, dl
1705 xor edi, ebp
1706 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1707 xor edi, ebp
1708 mov cl, dh
1709 shr eax, 16
1710 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1711 xor edi, ebp
1712 mov bl, ah
1713 shr edx, 16
1714 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1715 xor edi, ebp
1716 mov ebp, DWORD PTR 24[esp]
1717 mov cl, dh
1718 and eax, 0ffh
1719 and edx, 0ffh
1720 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1721 xor edi, ebx
1722 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1723 xor edi, ebx
1724 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1725 xor edi, ebx
1726 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1727 xor edi, ebx
1728 ;
1729 ; Round 11
1730 mov eax, DWORD PTR 88[ebp]
1731 xor ebx, ebx
1732 mov edx, DWORD PTR 92[ebp]
1733 xor eax, edi
1734 xor edx, edi
1735 and eax, 0fcfcfcfch
1736 and edx, 0cfcfcfcfh
1737 mov bl, al
1738 mov cl, ah
1739 ror edx, 4
1740 mov ebp, DWORD PTR _des_SPtrans[ebx]
1741 mov bl, dl
1742 xor esi, ebp
1743 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1744 xor esi, ebp
1745 mov cl, dh
1746 shr eax, 16
1747 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1748 xor esi, ebp
1749 mov bl, ah
1750 shr edx, 16
1751 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1752 xor esi, ebp
1753 mov ebp, DWORD PTR 24[esp]
1754 mov cl, dh
1755 and eax, 0ffh
1756 and edx, 0ffh
1757 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1758 xor esi, ebx
1759 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1760 xor esi, ebx
1761 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1762 xor esi, ebx
1763 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1764 xor esi, ebx
1765 ;
1766 ; Round 12
1767 mov eax, DWORD PTR 96[ebp]
1768 xor ebx, ebx
1769 mov edx, DWORD PTR 100[ebp]
1770 xor eax, esi
1771 xor edx, esi
1772 and eax, 0fcfcfcfch
1773 and edx, 0cfcfcfcfh
1774 mov bl, al
1775 mov cl, ah
1776 ror edx, 4
1777 mov ebp, DWORD PTR _des_SPtrans[ebx]
1778 mov bl, dl
1779 xor edi, ebp
1780 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1781 xor edi, ebp
1782 mov cl, dh
1783 shr eax, 16
1784 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1785 xor edi, ebp
1786 mov bl, ah
1787 shr edx, 16
1788 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1789 xor edi, ebp
1790 mov ebp, DWORD PTR 24[esp]
1791 mov cl, dh
1792 and eax, 0ffh
1793 and edx, 0ffh
1794 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1795 xor edi, ebx
1796 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1797 xor edi, ebx
1798 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1799 xor edi, ebx
1800 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1801 xor edi, ebx
1802 ;
1803 ; Round 13
1804 mov eax, DWORD PTR 104[ebp]
1805 xor ebx, ebx
1806 mov edx, DWORD PTR 108[ebp]
1807 xor eax, edi
1808 xor edx, edi
1809 and eax, 0fcfcfcfch
1810 and edx, 0cfcfcfcfh
1811 mov bl, al
1812 mov cl, ah
1813 ror edx, 4
1814 mov ebp, DWORD PTR _des_SPtrans[ebx]
1815 mov bl, dl
1816 xor esi, ebp
1817 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1818 xor esi, ebp
1819 mov cl, dh
1820 shr eax, 16
1821 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1822 xor esi, ebp
1823 mov bl, ah
1824 shr edx, 16
1825 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1826 xor esi, ebp
1827 mov ebp, DWORD PTR 24[esp]
1828 mov cl, dh
1829 and eax, 0ffh
1830 and edx, 0ffh
1831 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1832 xor esi, ebx
1833 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1834 xor esi, ebx
1835 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1836 xor esi, ebx
1837 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1838 xor esi, ebx
1839 ;
1840 ; Round 14
1841 mov eax, DWORD PTR 112[ebp]
1842 xor ebx, ebx
1843 mov edx, DWORD PTR 116[ebp]
1844 xor eax, esi
1845 xor edx, esi
1846 and eax, 0fcfcfcfch
1847 and edx, 0cfcfcfcfh
1848 mov bl, al
1849 mov cl, ah
1850 ror edx, 4
1851 mov ebp, DWORD PTR _des_SPtrans[ebx]
1852 mov bl, dl
1853 xor edi, ebp
1854 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1855 xor edi, ebp
1856 mov cl, dh
1857 shr eax, 16
1858 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1859 xor edi, ebp
1860 mov bl, ah
1861 shr edx, 16
1862 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1863 xor edi, ebp
1864 mov ebp, DWORD PTR 24[esp]
1865 mov cl, dh
1866 and eax, 0ffh
1867 and edx, 0ffh
1868 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1869 xor edi, ebx
1870 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1871 xor edi, ebx
1872 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1873 xor edi, ebx
1874 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1875 xor edi, ebx
1876 ;
1877 ; Round 15
1878 mov eax, DWORD PTR 120[ebp]
1879 xor ebx, ebx
1880 mov edx, DWORD PTR 124[ebp]
1881 xor eax, edi
1882 xor edx, edi
1883 and eax, 0fcfcfcfch
1884 and edx, 0cfcfcfcfh
1885 mov bl, al
1886 mov cl, ah
1887 ror edx, 4
1888 mov ebp, DWORD PTR _des_SPtrans[ebx]
1889 mov bl, dl
1890 xor esi, ebp
1891 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1892 xor esi, ebp
1893 mov cl, dh
1894 shr eax, 16
1895 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1896 xor esi, ebp
1897 mov bl, ah
1898 shr edx, 16
1899 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1900 xor esi, ebp
1901 mov ebp, DWORD PTR 24[esp]
1902 mov cl, dh
1903 and eax, 0ffh
1904 and edx, 0ffh
1905 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1906 xor esi, ebx
1907 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1908 xor esi, ebx
1909 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1910 xor esi, ebx
1911 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1912 xor esi, ebx
1913 jmp $L003end
1914$L002start_decrypt:
1915 ;
1916 ; Round 15
1917 mov eax, DWORD PTR 120[ebp]
1918 xor ebx, ebx
1919 mov edx, DWORD PTR 124[ebp]
1920 xor eax, esi
1921 xor edx, esi
1922 and eax, 0fcfcfcfch
1923 and edx, 0cfcfcfcfh
1924 mov bl, al
1925 mov cl, ah
1926 ror edx, 4
1927 mov ebp, DWORD PTR _des_SPtrans[ebx]
1928 mov bl, dl
1929 xor edi, ebp
1930 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1931 xor edi, ebp
1932 mov cl, dh
1933 shr eax, 16
1934 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1935 xor edi, ebp
1936 mov bl, ah
1937 shr edx, 16
1938 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1939 xor edi, ebp
1940 mov ebp, DWORD PTR 24[esp]
1941 mov cl, dh
1942 and eax, 0ffh
1943 and edx, 0ffh
1944 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1945 xor edi, ebx
1946 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1947 xor edi, ebx
1948 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1949 xor edi, ebx
1950 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1951 xor edi, ebx
1952 ;
1953 ; Round 14
1954 mov eax, DWORD PTR 112[ebp]
1955 xor ebx, ebx
1956 mov edx, DWORD PTR 116[ebp]
1957 xor eax, edi
1958 xor edx, edi
1959 and eax, 0fcfcfcfch
1960 and edx, 0cfcfcfcfh
1961 mov bl, al
1962 mov cl, ah
1963 ror edx, 4
1964 mov ebp, DWORD PTR _des_SPtrans[ebx]
1965 mov bl, dl
1966 xor esi, ebp
1967 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1968 xor esi, ebp
1969 mov cl, dh
1970 shr eax, 16
1971 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1972 xor esi, ebp
1973 mov bl, ah
1974 shr edx, 16
1975 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1976 xor esi, ebp
1977 mov ebp, DWORD PTR 24[esp]
1978 mov cl, dh
1979 and eax, 0ffh
1980 and edx, 0ffh
1981 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1982 xor esi, ebx
1983 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1984 xor esi, ebx
1985 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1986 xor esi, ebx
1987 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1988 xor esi, ebx
1989 ;
1990 ; Round 13
1991 mov eax, DWORD PTR 104[ebp]
1992 xor ebx, ebx
1993 mov edx, DWORD PTR 108[ebp]
1994 xor eax, esi
1995 xor edx, esi
1996 and eax, 0fcfcfcfch
1997 and edx, 0cfcfcfcfh
1998 mov bl, al
1999 mov cl, ah
2000 ror edx, 4
2001 mov ebp, DWORD PTR _des_SPtrans[ebx]
2002 mov bl, dl
2003 xor edi, ebp
2004 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2005 xor edi, ebp
2006 mov cl, dh
2007 shr eax, 16
2008 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2009 xor edi, ebp
2010 mov bl, ah
2011 shr edx, 16
2012 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2013 xor edi, ebp
2014 mov ebp, DWORD PTR 24[esp]
2015 mov cl, dh
2016 and eax, 0ffh
2017 and edx, 0ffh
2018 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2019 xor edi, ebx
2020 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2021 xor edi, ebx
2022 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2023 xor edi, ebx
2024 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2025 xor edi, ebx
2026 ;
2027 ; Round 12
2028 mov eax, DWORD PTR 96[ebp]
2029 xor ebx, ebx
2030 mov edx, DWORD PTR 100[ebp]
2031 xor eax, edi
2032 xor edx, edi
2033 and eax, 0fcfcfcfch
2034 and edx, 0cfcfcfcfh
2035 mov bl, al
2036 mov cl, ah
2037 ror edx, 4
2038 mov ebp, DWORD PTR _des_SPtrans[ebx]
2039 mov bl, dl
2040 xor esi, ebp
2041 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2042 xor esi, ebp
2043 mov cl, dh
2044 shr eax, 16
2045 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2046 xor esi, ebp
2047 mov bl, ah
2048 shr edx, 16
2049 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2050 xor esi, ebp
2051 mov ebp, DWORD PTR 24[esp]
2052 mov cl, dh
2053 and eax, 0ffh
2054 and edx, 0ffh
2055 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2056 xor esi, ebx
2057 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2058 xor esi, ebx
2059 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2060 xor esi, ebx
2061 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2062 xor esi, ebx
2063 ;
2064 ; Round 11
2065 mov eax, DWORD PTR 88[ebp]
2066 xor ebx, ebx
2067 mov edx, DWORD PTR 92[ebp]
2068 xor eax, esi
2069 xor edx, esi
2070 and eax, 0fcfcfcfch
2071 and edx, 0cfcfcfcfh
2072 mov bl, al
2073 mov cl, ah
2074 ror edx, 4
2075 mov ebp, DWORD PTR _des_SPtrans[ebx]
2076 mov bl, dl
2077 xor edi, ebp
2078 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2079 xor edi, ebp
2080 mov cl, dh
2081 shr eax, 16
2082 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2083 xor edi, ebp
2084 mov bl, ah
2085 shr edx, 16
2086 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2087 xor edi, ebp
2088 mov ebp, DWORD PTR 24[esp]
2089 mov cl, dh
2090 and eax, 0ffh
2091 and edx, 0ffh
2092 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2093 xor edi, ebx
2094 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2095 xor edi, ebx
2096 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2097 xor edi, ebx
2098 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2099 xor edi, ebx
2100 ;
2101 ; Round 10
2102 mov eax, DWORD PTR 80[ebp]
2103 xor ebx, ebx
2104 mov edx, DWORD PTR 84[ebp]
2105 xor eax, edi
2106 xor edx, edi
2107 and eax, 0fcfcfcfch
2108 and edx, 0cfcfcfcfh
2109 mov bl, al
2110 mov cl, ah
2111 ror edx, 4
2112 mov ebp, DWORD PTR _des_SPtrans[ebx]
2113 mov bl, dl
2114 xor esi, ebp
2115 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2116 xor esi, ebp
2117 mov cl, dh
2118 shr eax, 16
2119 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2120 xor esi, ebp
2121 mov bl, ah
2122 shr edx, 16
2123 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2124 xor esi, ebp
2125 mov ebp, DWORD PTR 24[esp]
2126 mov cl, dh
2127 and eax, 0ffh
2128 and edx, 0ffh
2129 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2130 xor esi, ebx
2131 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2132 xor esi, ebx
2133 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2134 xor esi, ebx
2135 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2136 xor esi, ebx
2137 ;
2138 ; Round 9
2139 mov eax, DWORD PTR 72[ebp]
2140 xor ebx, ebx
2141 mov edx, DWORD PTR 76[ebp]
2142 xor eax, esi
2143 xor edx, esi
2144 and eax, 0fcfcfcfch
2145 and edx, 0cfcfcfcfh
2146 mov bl, al
2147 mov cl, ah
2148 ror edx, 4
2149 mov ebp, DWORD PTR _des_SPtrans[ebx]
2150 mov bl, dl
2151 xor edi, ebp
2152 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2153 xor edi, ebp
2154 mov cl, dh
2155 shr eax, 16
2156 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2157 xor edi, ebp
2158 mov bl, ah
2159 shr edx, 16
2160 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2161 xor edi, ebp
2162 mov ebp, DWORD PTR 24[esp]
2163 mov cl, dh
2164 and eax, 0ffh
2165 and edx, 0ffh
2166 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2167 xor edi, ebx
2168 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2169 xor edi, ebx
2170 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2171 xor edi, ebx
2172 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2173 xor edi, ebx
2174 ;
2175 ; Round 8
2176 mov eax, DWORD PTR 64[ebp]
2177 xor ebx, ebx
2178 mov edx, DWORD PTR 68[ebp]
2179 xor eax, edi
2180 xor edx, edi
2181 and eax, 0fcfcfcfch
2182 and edx, 0cfcfcfcfh
2183 mov bl, al
2184 mov cl, ah
2185 ror edx, 4
2186 mov ebp, DWORD PTR _des_SPtrans[ebx]
2187 mov bl, dl
2188 xor esi, ebp
2189 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2190 xor esi, ebp
2191 mov cl, dh
2192 shr eax, 16
2193 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2194 xor esi, ebp
2195 mov bl, ah
2196 shr edx, 16
2197 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2198 xor esi, ebp
2199 mov ebp, DWORD PTR 24[esp]
2200 mov cl, dh
2201 and eax, 0ffh
2202 and edx, 0ffh
2203 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2204 xor esi, ebx
2205 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2206 xor esi, ebx
2207 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2208 xor esi, ebx
2209 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2210 xor esi, ebx
2211 ;
2212 ; Round 7
2213 mov eax, DWORD PTR 56[ebp]
2214 xor ebx, ebx
2215 mov edx, DWORD PTR 60[ebp]
2216 xor eax, esi
2217 xor edx, esi
2218 and eax, 0fcfcfcfch
2219 and edx, 0cfcfcfcfh
2220 mov bl, al
2221 mov cl, ah
2222 ror edx, 4
2223 mov ebp, DWORD PTR _des_SPtrans[ebx]
2224 mov bl, dl
2225 xor edi, ebp
2226 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2227 xor edi, ebp
2228 mov cl, dh
2229 shr eax, 16
2230 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2231 xor edi, ebp
2232 mov bl, ah
2233 shr edx, 16
2234 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2235 xor edi, ebp
2236 mov ebp, DWORD PTR 24[esp]
2237 mov cl, dh
2238 and eax, 0ffh
2239 and edx, 0ffh
2240 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2241 xor edi, ebx
2242 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2243 xor edi, ebx
2244 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2245 xor edi, ebx
2246 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2247 xor edi, ebx
2248 ;
2249 ; Round 6
2250 mov eax, DWORD PTR 48[ebp]
2251 xor ebx, ebx
2252 mov edx, DWORD PTR 52[ebp]
2253 xor eax, edi
2254 xor edx, edi
2255 and eax, 0fcfcfcfch
2256 and edx, 0cfcfcfcfh
2257 mov bl, al
2258 mov cl, ah
2259 ror edx, 4
2260 mov ebp, DWORD PTR _des_SPtrans[ebx]
2261 mov bl, dl
2262 xor esi, ebp
2263 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2264 xor esi, ebp
2265 mov cl, dh
2266 shr eax, 16
2267 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2268 xor esi, ebp
2269 mov bl, ah
2270 shr edx, 16
2271 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2272 xor esi, ebp
2273 mov ebp, DWORD PTR 24[esp]
2274 mov cl, dh
2275 and eax, 0ffh
2276 and edx, 0ffh
2277 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2278 xor esi, ebx
2279 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2280 xor esi, ebx
2281 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2282 xor esi, ebx
2283 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2284 xor esi, ebx
2285 ;
2286 ; Round 5
2287 mov eax, DWORD PTR 40[ebp]
2288 xor ebx, ebx
2289 mov edx, DWORD PTR 44[ebp]
2290 xor eax, esi
2291 xor edx, esi
2292 and eax, 0fcfcfcfch
2293 and edx, 0cfcfcfcfh
2294 mov bl, al
2295 mov cl, ah
2296 ror edx, 4
2297 mov ebp, DWORD PTR _des_SPtrans[ebx]
2298 mov bl, dl
2299 xor edi, ebp
2300 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2301 xor edi, ebp
2302 mov cl, dh
2303 shr eax, 16
2304 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2305 xor edi, ebp
2306 mov bl, ah
2307 shr edx, 16
2308 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2309 xor edi, ebp
2310 mov ebp, DWORD PTR 24[esp]
2311 mov cl, dh
2312 and eax, 0ffh
2313 and edx, 0ffh
2314 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2315 xor edi, ebx
2316 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2317 xor edi, ebx
2318 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2319 xor edi, ebx
2320 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2321 xor edi, ebx
2322 ;
2323 ; Round 4
2324 mov eax, DWORD PTR 32[ebp]
2325 xor ebx, ebx
2326 mov edx, DWORD PTR 36[ebp]
2327 xor eax, edi
2328 xor edx, edi
2329 and eax, 0fcfcfcfch
2330 and edx, 0cfcfcfcfh
2331 mov bl, al
2332 mov cl, ah
2333 ror edx, 4
2334 mov ebp, DWORD PTR _des_SPtrans[ebx]
2335 mov bl, dl
2336 xor esi, ebp
2337 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2338 xor esi, ebp
2339 mov cl, dh
2340 shr eax, 16
2341 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2342 xor esi, ebp
2343 mov bl, ah
2344 shr edx, 16
2345 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2346 xor esi, ebp
2347 mov ebp, DWORD PTR 24[esp]
2348 mov cl, dh
2349 and eax, 0ffh
2350 and edx, 0ffh
2351 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2352 xor esi, ebx
2353 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2354 xor esi, ebx
2355 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2356 xor esi, ebx
2357 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2358 xor esi, ebx
2359 ;
2360 ; Round 3
2361 mov eax, DWORD PTR 24[ebp]
2362 xor ebx, ebx
2363 mov edx, DWORD PTR 28[ebp]
2364 xor eax, esi
2365 xor edx, esi
2366 and eax, 0fcfcfcfch
2367 and edx, 0cfcfcfcfh
2368 mov bl, al
2369 mov cl, ah
2370 ror edx, 4
2371 mov ebp, DWORD PTR _des_SPtrans[ebx]
2372 mov bl, dl
2373 xor edi, ebp
2374 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2375 xor edi, ebp
2376 mov cl, dh
2377 shr eax, 16
2378 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2379 xor edi, ebp
2380 mov bl, ah
2381 shr edx, 16
2382 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2383 xor edi, ebp
2384 mov ebp, DWORD PTR 24[esp]
2385 mov cl, dh
2386 and eax, 0ffh
2387 and edx, 0ffh
2388 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2389 xor edi, ebx
2390 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2391 xor edi, ebx
2392 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2393 xor edi, ebx
2394 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2395 xor edi, ebx
2396 ;
2397 ; Round 2
2398 mov eax, DWORD PTR 16[ebp]
2399 xor ebx, ebx
2400 mov edx, DWORD PTR 20[ebp]
2401 xor eax, edi
2402 xor edx, edi
2403 and eax, 0fcfcfcfch
2404 and edx, 0cfcfcfcfh
2405 mov bl, al
2406 mov cl, ah
2407 ror edx, 4
2408 mov ebp, DWORD PTR _des_SPtrans[ebx]
2409 mov bl, dl
2410 xor esi, ebp
2411 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2412 xor esi, ebp
2413 mov cl, dh
2414 shr eax, 16
2415 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2416 xor esi, ebp
2417 mov bl, ah
2418 shr edx, 16
2419 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2420 xor esi, ebp
2421 mov ebp, DWORD PTR 24[esp]
2422 mov cl, dh
2423 and eax, 0ffh
2424 and edx, 0ffh
2425 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2426 xor esi, ebx
2427 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2428 xor esi, ebx
2429 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2430 xor esi, ebx
2431 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2432 xor esi, ebx
2433 ;
2434 ; Round 1
2435 mov eax, DWORD PTR 8[ebp]
2436 xor ebx, ebx
2437 mov edx, DWORD PTR 12[ebp]
2438 xor eax, esi
2439 xor edx, esi
2440 and eax, 0fcfcfcfch
2441 and edx, 0cfcfcfcfh
2442 mov bl, al
2443 mov cl, ah
2444 ror edx, 4
2445 mov ebp, DWORD PTR _des_SPtrans[ebx]
2446 mov bl, dl
2447 xor edi, ebp
2448 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2449 xor edi, ebp
2450 mov cl, dh
2451 shr eax, 16
2452 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2453 xor edi, ebp
2454 mov bl, ah
2455 shr edx, 16
2456 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2457 xor edi, ebp
2458 mov ebp, DWORD PTR 24[esp]
2459 mov cl, dh
2460 and eax, 0ffh
2461 and edx, 0ffh
2462 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2463 xor edi, ebx
2464 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2465 xor edi, ebx
2466 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2467 xor edi, ebx
2468 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2469 xor edi, ebx
2470 ;
2471 ; Round 0
2472 mov eax, DWORD PTR [ebp]
2473 xor ebx, ebx
2474 mov edx, DWORD PTR 4[ebp]
2475 xor eax, edi
2476 xor edx, edi
2477 and eax, 0fcfcfcfch
2478 and edx, 0cfcfcfcfh
2479 mov bl, al
2480 mov cl, ah
2481 ror edx, 4
2482 mov ebp, DWORD PTR _des_SPtrans[ebx]
2483 mov bl, dl
2484 xor esi, ebp
2485 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2486 xor esi, ebp
2487 mov cl, dh
2488 shr eax, 16
2489 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2490 xor esi, ebp
2491 mov bl, ah
2492 shr edx, 16
2493 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2494 xor esi, ebp
2495 mov ebp, DWORD PTR 24[esp]
2496 mov cl, dh
2497 and eax, 0ffh
2498 and edx, 0ffh
2499 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2500 xor esi, ebx
2501 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2502 xor esi, ebx
2503 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2504 xor esi, ebx
2505 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2506 xor esi, ebx
2507$L003end:
2508 ;
2509 ; Fixup
2510 ror edi, 3
2511 mov eax, DWORD PTR 20[esp]
2512 ror esi, 3
2513 mov DWORD PTR [eax],edi
2514 mov DWORD PTR 4[eax],esi
2515 pop ebp
2516 pop ebx
2517 pop edi
2518 pop esi
2519 ret
2520_des_encrypt2 ENDP
2521_TEXT ENDS
2522_TEXT SEGMENT
2523PUBLIC _des_encrypt3
2524
2525_des_encrypt3 PROC NEAR
2526 push ebx
2527 mov ebx, DWORD PTR 8[esp]
2528 push ebp
2529 push esi
2530 push edi
2531 ;
2532 ; Load the data words
2533 mov edi, DWORD PTR [ebx]
2534 mov esi, DWORD PTR 4[ebx]
2535 sub esp, 12
2536 ;
2537 ; IP
2538 rol edi, 4
2539 mov edx, edi
2540 xor edi, esi
2541 and edi, 0f0f0f0f0h
2542 xor edx, edi
2543 xor esi, edi
2544 ;
2545 rol esi, 20
2546 mov edi, esi
2547 xor esi, edx
2548 and esi, 0fff0000fh
2549 xor edi, esi
2550 xor edx, esi
2551 ;
2552 rol edi, 14
2553 mov esi, edi
2554 xor edi, edx
2555 and edi, 033333333h
2556 xor esi, edi
2557 xor edx, edi
2558 ;
2559 rol edx, 22
2560 mov edi, edx
2561 xor edx, esi
2562 and edx, 003fc03fch
2563 xor edi, edx
2564 xor esi, edx
2565 ;
2566 rol edi, 9
2567 mov edx, edi
2568 xor edi, esi
2569 and edi, 0aaaaaaaah
2570 xor edx, edi
2571 xor esi, edi
2572 ;
2573 ror edx, 3
2574 ror esi, 2
2575 mov DWORD PTR 4[ebx],esi
2576 mov eax, DWORD PTR 36[esp]
2577 mov DWORD PTR [ebx],edx
2578 mov edi, DWORD PTR 40[esp]
2579 mov esi, DWORD PTR 44[esp]
2580 mov DWORD PTR 8[esp],1
2581 mov DWORD PTR 4[esp],eax
2582 mov DWORD PTR [esp],ebx
2583 call _des_encrypt2
2584 mov DWORD PTR 8[esp],0
2585 mov DWORD PTR 4[esp],edi
2586 mov DWORD PTR [esp],ebx
2587 call _des_encrypt2
2588 mov DWORD PTR 8[esp],1
2589 mov DWORD PTR 4[esp],esi
2590 mov DWORD PTR [esp],ebx
2591 call _des_encrypt2
2592 add esp, 12
2593 mov edi, DWORD PTR [ebx]
2594 mov esi, DWORD PTR 4[ebx]
2595 ;
2596 ; FP
2597 rol esi, 2
2598 rol edi, 3
2599 mov eax, edi
2600 xor edi, esi
2601 and edi, 0aaaaaaaah
2602 xor eax, edi
2603 xor esi, edi
2604 ;
2605 rol eax, 23
2606 mov edi, eax
2607 xor eax, esi
2608 and eax, 003fc03fch
2609 xor edi, eax
2610 xor esi, eax
2611 ;
2612 rol edi, 10
2613 mov eax, edi
2614 xor edi, esi
2615 and edi, 033333333h
2616 xor eax, edi
2617 xor esi, edi
2618 ;
2619 rol esi, 18
2620 mov edi, esi
2621 xor esi, eax
2622 and esi, 0fff0000fh
2623 xor edi, esi
2624 xor eax, esi
2625 ;
2626 rol edi, 12
2627 mov esi, edi
2628 xor edi, eax
2629 and edi, 0f0f0f0f0h
2630 xor esi, edi
2631 xor eax, edi
2632 ;
2633 ror eax, 4
2634 mov DWORD PTR [ebx],eax
2635 mov DWORD PTR 4[ebx],esi
2636 pop edi
2637 pop esi
2638 pop ebp
2639 pop ebx
2640 ret
2641_des_encrypt3 ENDP
2642_TEXT ENDS
2643_TEXT SEGMENT
2644PUBLIC _des_decrypt3
2645
2646_des_decrypt3 PROC NEAR
2647 push ebx
2648 mov ebx, DWORD PTR 8[esp]
2649 push ebp
2650 push esi
2651 push edi
2652 ;
2653 ; Load the data words
2654 mov edi, DWORD PTR [ebx]
2655 mov esi, DWORD PTR 4[ebx]
2656 sub esp, 12
2657 ;
2658 ; IP
2659 rol edi, 4
2660 mov edx, edi
2661 xor edi, esi
2662 and edi, 0f0f0f0f0h
2663 xor edx, edi
2664 xor esi, edi
2665 ;
2666 rol esi, 20
2667 mov edi, esi
2668 xor esi, edx
2669 and esi, 0fff0000fh
2670 xor edi, esi
2671 xor edx, esi
2672 ;
2673 rol edi, 14
2674 mov esi, edi
2675 xor edi, edx
2676 and edi, 033333333h
2677 xor esi, edi
2678 xor edx, edi
2679 ;
2680 rol edx, 22
2681 mov edi, edx
2682 xor edx, esi
2683 and edx, 003fc03fch
2684 xor edi, edx
2685 xor esi, edx
2686 ;
2687 rol edi, 9
2688 mov edx, edi
2689 xor edi, esi
2690 and edi, 0aaaaaaaah
2691 xor edx, edi
2692 xor esi, edi
2693 ;
2694 ror edx, 3
2695 ror esi, 2
2696 mov DWORD PTR 4[ebx],esi
2697 mov esi, DWORD PTR 36[esp]
2698 mov DWORD PTR [ebx],edx
2699 mov edi, DWORD PTR 40[esp]
2700 mov eax, DWORD PTR 44[esp]
2701 mov DWORD PTR 8[esp],0
2702 mov DWORD PTR 4[esp],eax
2703 mov DWORD PTR [esp],ebx
2704 call _des_encrypt2
2705 mov DWORD PTR 8[esp],1
2706 mov DWORD PTR 4[esp],edi
2707 mov DWORD PTR [esp],ebx
2708 call _des_encrypt2
2709 mov DWORD PTR 8[esp],0
2710 mov DWORD PTR 4[esp],esi
2711 mov DWORD PTR [esp],ebx
2712 call _des_encrypt2
2713 add esp, 12
2714 mov edi, DWORD PTR [ebx]
2715 mov esi, DWORD PTR 4[ebx]
2716 ;
2717 ; FP
2718 rol esi, 2
2719 rol edi, 3
2720 mov eax, edi
2721 xor edi, esi
2722 and edi, 0aaaaaaaah
2723 xor eax, edi
2724 xor esi, edi
2725 ;
2726 rol eax, 23
2727 mov edi, eax
2728 xor eax, esi
2729 and eax, 003fc03fch
2730 xor edi, eax
2731 xor esi, eax
2732 ;
2733 rol edi, 10
2734 mov eax, edi
2735 xor edi, esi
2736 and edi, 033333333h
2737 xor eax, edi
2738 xor esi, edi
2739 ;
2740 rol esi, 18
2741 mov edi, esi
2742 xor esi, eax
2743 and esi, 0fff0000fh
2744 xor edi, esi
2745 xor eax, esi
2746 ;
2747 rol edi, 12
2748 mov esi, edi
2749 xor edi, eax
2750 and edi, 0f0f0f0f0h
2751 xor esi, edi
2752 xor eax, edi
2753 ;
2754 ror eax, 4
2755 mov DWORD PTR [ebx],eax
2756 mov DWORD PTR 4[ebx],esi
2757 pop edi
2758 pop esi
2759 pop ebp
2760 pop ebx
2761 ret
2762_des_decrypt3 ENDP
2763_TEXT ENDS
2764_TEXT SEGMENT
2765PUBLIC _des_ncbc_encrypt
2766
2767_des_ncbc_encrypt PROC NEAR
2768 ;
2769 push ebp
2770 push ebx
2771 push esi
2772 push edi
2773 mov ebp, DWORD PTR 28[esp]
2774 ; getting iv ptr from parameter 4
2775 mov ebx, DWORD PTR 36[esp]
2776 mov esi, DWORD PTR [ebx]
2777 mov edi, DWORD PTR 4[ebx]
2778 push edi
2779 push esi
2780 push edi
2781 push esi
2782 mov ebx, esp
2783 mov esi, DWORD PTR 36[esp]
2784 mov edi, DWORD PTR 40[esp]
2785 ; getting encrypt flag from parameter 5
2786 mov ecx, DWORD PTR 56[esp]
2787 ; get and push parameter 5
2788 push ecx
2789 ; get and push parameter 3
2790 mov eax, DWORD PTR 52[esp]
2791 push eax
2792 push ebx
2793 cmp ecx, 0
2794 jz $L004decrypt
2795 and ebp, 4294967288
2796 mov eax, DWORD PTR 12[esp]
2797 mov ebx, DWORD PTR 16[esp]
2798 jz $L005encrypt_finish
2799L006encrypt_loop:
2800 mov ecx, DWORD PTR [esi]
2801 mov edx, DWORD PTR 4[esi]
2802 xor eax, ecx
2803 xor ebx, edx
2804 mov DWORD PTR 12[esp],eax
2805 mov DWORD PTR 16[esp],ebx
2806 call _des_encrypt
2807 mov eax, DWORD PTR 12[esp]
2808 mov ebx, DWORD PTR 16[esp]
2809 mov DWORD PTR [edi],eax
2810 mov DWORD PTR 4[edi],ebx
2811 add esi, 8
2812 add edi, 8
2813 sub ebp, 8
2814 jnz L006encrypt_loop
2815$L005encrypt_finish:
2816 mov ebp, DWORD PTR 56[esp]
2817 and ebp, 7
2818 jz $L007finish
2819 xor ecx, ecx
2820 xor edx, edx
2821 mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4]
2822 jmp ebp
2823L009ej7:
2824 mov dh, BYTE PTR 6[esi]
2825 shl edx, 8
2826L010ej6:
2827 mov dh, BYTE PTR 5[esi]
2828L011ej5:
2829 mov dl, BYTE PTR 4[esi]
2830L012ej4:
2831 mov ecx, DWORD PTR [esi]
2832 jmp $L013ejend
2833L014ej3:
2834 mov ch, BYTE PTR 2[esi]
2835 shl ecx, 8
2836L015ej2:
2837 mov ch, BYTE PTR 1[esi]
2838L016ej1:
2839 mov cl, BYTE PTR [esi]
2840$L013ejend:
2841 xor eax, ecx
2842 xor ebx, edx
2843 mov DWORD PTR 12[esp],eax
2844 mov DWORD PTR 16[esp],ebx
2845 call _des_encrypt
2846 mov eax, DWORD PTR 12[esp]
2847 mov ebx, DWORD PTR 16[esp]
2848 mov DWORD PTR [edi],eax
2849 mov DWORD PTR 4[edi],ebx
2850 jmp $L007finish
2851$L004decrypt:
2852 and ebp, 4294967288
2853 mov eax, DWORD PTR 20[esp]
2854 mov ebx, DWORD PTR 24[esp]
2855 jz $L017decrypt_finish
2856L018decrypt_loop:
2857 mov eax, DWORD PTR [esi]
2858 mov ebx, DWORD PTR 4[esi]
2859 mov DWORD PTR 12[esp],eax
2860 mov DWORD PTR 16[esp],ebx
2861 call _des_encrypt
2862 mov eax, DWORD PTR 12[esp]
2863 mov ebx, DWORD PTR 16[esp]
2864 mov ecx, DWORD PTR 20[esp]
2865 mov edx, DWORD PTR 24[esp]
2866 xor ecx, eax
2867 xor edx, ebx
2868 mov eax, DWORD PTR [esi]
2869 mov ebx, DWORD PTR 4[esi]
2870 mov DWORD PTR [edi],ecx
2871 mov DWORD PTR 4[edi],edx
2872 mov DWORD PTR 20[esp],eax
2873 mov DWORD PTR 24[esp],ebx
2874 add esi, 8
2875 add edi, 8
2876 sub ebp, 8
2877 jnz L018decrypt_loop
2878$L017decrypt_finish:
2879 mov ebp, DWORD PTR 56[esp]
2880 and ebp, 7
2881 jz $L007finish
2882 mov eax, DWORD PTR [esi]
2883 mov ebx, DWORD PTR 4[esi]
2884 mov DWORD PTR 12[esp],eax
2885 mov DWORD PTR 16[esp],ebx
2886 call _des_encrypt
2887 mov eax, DWORD PTR 12[esp]
2888 mov ebx, DWORD PTR 16[esp]
2889 mov ecx, DWORD PTR 20[esp]
2890 mov edx, DWORD PTR 24[esp]
2891 xor ecx, eax
2892 xor edx, ebx
2893 mov eax, DWORD PTR [esi]
2894 mov ebx, DWORD PTR 4[esi]
2895L019dj7:
2896 ror edx, 16
2897 mov BYTE PTR 6[edi],dl
2898 shr edx, 16
2899L020dj6:
2900 mov BYTE PTR 5[edi],dh
2901L021dj5:
2902 mov BYTE PTR 4[edi],dl
2903L022dj4:
2904 mov DWORD PTR [edi],ecx
2905 jmp $L023djend
2906L024dj3:
2907 ror ecx, 16
2908 mov BYTE PTR 2[edi],cl
2909 shl ecx, 16
2910L025dj2:
2911 mov BYTE PTR 1[esi],ch
2912L026dj1:
2913 mov BYTE PTR [esi], cl
2914$L023djend:
2915 jmp $L007finish
2916$L007finish:
2917 mov ecx, DWORD PTR 64[esp]
2918 add esp, 28
2919 mov DWORD PTR [ecx],eax
2920 mov DWORD PTR 4[ecx],ebx
2921 pop edi
2922 pop esi
2923 pop ebx
2924 pop ebp
2925 ret
2926$L008cbc_enc_jmp_table:
2927 DD 0
2928 DD L016ej1
2929 DD L015ej2
2930 DD L014ej3
2931 DD L012ej4
2932 DD L011ej5
2933 DD L010ej6
2934 DD L009ej7
2935L027cbc_dec_jmp_table:
2936 DD 0
2937 DD L026dj1
2938 DD L025dj2
2939 DD L024dj3
2940 DD L022dj4
2941 DD L021dj5
2942 DD L020dj6
2943 DD L019dj7
2944_des_ncbc_encrypt ENDP
2945_TEXT ENDS
2946_TEXT SEGMENT
2947PUBLIC _des_ede3_cbc_encrypt
2948
2949_des_ede3_cbc_encrypt PROC NEAR
2950 ;
2951 push ebp
2952 push ebx
2953 push esi
2954 push edi
2955 mov ebp, DWORD PTR 28[esp]
2956 ; getting iv ptr from parameter 6
2957 mov ebx, DWORD PTR 44[esp]
2958 mov esi, DWORD PTR [ebx]
2959 mov edi, DWORD PTR 4[ebx]
2960 push edi
2961 push esi
2962 push edi
2963 push esi
2964 mov ebx, esp
2965 mov esi, DWORD PTR 36[esp]
2966 mov edi, DWORD PTR 40[esp]
2967 ; getting encrypt flag from parameter 7
2968 mov ecx, DWORD PTR 64[esp]
2969 ; get and push parameter 5
2970 mov eax, DWORD PTR 56[esp]
2971 push eax
2972 ; get and push parameter 4
2973 mov eax, DWORD PTR 56[esp]
2974 push eax
2975 ; get and push parameter 3
2976 mov eax, DWORD PTR 56[esp]
2977 push eax
2978 push ebx
2979 cmp ecx, 0
2980 jz $L028decrypt
2981 and ebp, 4294967288
2982 mov eax, DWORD PTR 16[esp]
2983 mov ebx, DWORD PTR 20[esp]
2984 jz $L029encrypt_finish
2985L030encrypt_loop:
2986 mov ecx, DWORD PTR [esi]
2987 mov edx, DWORD PTR 4[esi]
2988 xor eax, ecx
2989 xor ebx, edx
2990 mov DWORD PTR 16[esp],eax
2991 mov DWORD PTR 20[esp],ebx
2992 call _des_encrypt3
2993 mov eax, DWORD PTR 16[esp]
2994 mov ebx, DWORD PTR 20[esp]
2995 mov DWORD PTR [edi],eax
2996 mov DWORD PTR 4[edi],ebx
2997 add esi, 8
2998 add edi, 8
2999 sub ebp, 8
3000 jnz L030encrypt_loop
3001$L029encrypt_finish:
3002 mov ebp, DWORD PTR 60[esp]
3003 and ebp, 7
3004 jz $L031finish
3005 xor ecx, ecx
3006 xor edx, edx
3007 mov ebp, DWORD PTR $L032cbc_enc_jmp_table[ebp*4]
3008 jmp ebp
3009L033ej7:
3010 mov dh, BYTE PTR 6[esi]
3011 shl edx, 8
3012L034ej6:
3013 mov dh, BYTE PTR 5[esi]
3014L035ej5:
3015 mov dl, BYTE PTR 4[esi]
3016L036ej4:
3017 mov ecx, DWORD PTR [esi]
3018 jmp $L037ejend
3019L038ej3:
3020 mov ch, BYTE PTR 2[esi]
3021 shl ecx, 8
3022L039ej2:
3023 mov ch, BYTE PTR 1[esi]
3024L040ej1:
3025 mov cl, BYTE PTR [esi]
3026$L037ejend:
3027 xor eax, ecx
3028 xor ebx, edx
3029 mov DWORD PTR 16[esp],eax
3030 mov DWORD PTR 20[esp],ebx
3031 call _des_encrypt3
3032 mov eax, DWORD PTR 16[esp]
3033 mov ebx, DWORD PTR 20[esp]
3034 mov DWORD PTR [edi],eax
3035 mov DWORD PTR 4[edi],ebx
3036 jmp $L031finish
3037$L028decrypt:
3038 and ebp, 4294967288
3039 mov eax, DWORD PTR 24[esp]
3040 mov ebx, DWORD PTR 28[esp]
3041 jz $L041decrypt_finish
3042L042decrypt_loop:
3043 mov eax, DWORD PTR [esi]
3044 mov ebx, DWORD PTR 4[esi]
3045 mov DWORD PTR 16[esp],eax
3046 mov DWORD PTR 20[esp],ebx
3047 call _des_decrypt3
3048 mov eax, DWORD PTR 16[esp]
3049 mov ebx, DWORD PTR 20[esp]
3050 mov ecx, DWORD PTR 24[esp]
3051 mov edx, DWORD PTR 28[esp]
3052 xor ecx, eax
3053 xor edx, ebx
3054 mov eax, DWORD PTR [esi]
3055 mov ebx, DWORD PTR 4[esi]
3056 mov DWORD PTR [edi],ecx
3057 mov DWORD PTR 4[edi],edx
3058 mov DWORD PTR 24[esp],eax
3059 mov DWORD PTR 28[esp],ebx
3060 add esi, 8
3061 add edi, 8
3062 sub ebp, 8
3063 jnz L042decrypt_loop
3064$L041decrypt_finish:
3065 mov ebp, DWORD PTR 60[esp]
3066 and ebp, 7
3067 jz $L031finish
3068 mov eax, DWORD PTR [esi]
3069 mov ebx, DWORD PTR 4[esi]
3070 mov DWORD PTR 16[esp],eax
3071 mov DWORD PTR 20[esp],ebx
3072 call _des_decrypt3
3073 mov eax, DWORD PTR 16[esp]
3074 mov ebx, DWORD PTR 20[esp]
3075 mov ecx, DWORD PTR 24[esp]
3076 mov edx, DWORD PTR 28[esp]
3077 xor ecx, eax
3078 xor edx, ebx
3079 mov eax, DWORD PTR [esi]
3080 mov ebx, DWORD PTR 4[esi]
3081L043dj7:
3082 ror edx, 16
3083 mov BYTE PTR 6[edi],dl
3084 shr edx, 16
3085L044dj6:
3086 mov BYTE PTR 5[edi],dh
3087L045dj5:
3088 mov BYTE PTR 4[edi],dl
3089L046dj4:
3090 mov DWORD PTR [edi],ecx
3091 jmp $L047djend
3092L048dj3:
3093 ror ecx, 16
3094 mov BYTE PTR 2[edi],cl
3095 shl ecx, 16
3096L049dj2:
3097 mov BYTE PTR 1[esi],ch
3098L050dj1:
3099 mov BYTE PTR [esi], cl
3100$L047djend:
3101 jmp $L031finish
3102$L031finish:
3103 mov ecx, DWORD PTR 76[esp]
3104 add esp, 32
3105 mov DWORD PTR [ecx],eax
3106 mov DWORD PTR 4[ecx],ebx
3107 pop edi
3108 pop esi
3109 pop ebx
3110 pop ebp
3111 ret
3112$L032cbc_enc_jmp_table:
3113 DD 0
3114 DD L040ej1
3115 DD L039ej2
3116 DD L038ej3
3117 DD L036ej4
3118 DD L035ej5
3119 DD L034ej6
3120 DD L033ej7
3121L051cbc_dec_jmp_table:
3122 DD 0
3123 DD L050dj1
3124 DD L049dj2
3125 DD L048dj3
3126 DD L046dj4
3127 DD L045dj5
3128 DD L044dj6
3129 DD L043dj7
3130_des_ede3_cbc_encrypt ENDP
3131_TEXT ENDS
3132END
diff --git a/src/lib/libcrypto/des/asm/y-win32.asm b/src/lib/libcrypto/des/asm/y-win32.asm
index af5c102422..e69de29bb2 100644
--- a/src/lib/libcrypto/des/asm/y-win32.asm
+++ b/src/lib/libcrypto/des/asm/y-win32.asm
@@ -1,929 +0,0 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by crypt586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE crypt586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _fcrypt_body
12EXTRN _des_SPtrans:DWORD
13_fcrypt_body PROC NEAR
14 push ebp
15 push ebx
16 push esi
17 push edi
18 ;
19 ; Load the 2 words
20 xor edi, edi
21 xor esi, esi
22 mov ebp, DWORD PTR 24[esp]
23 push 25
24L000start:
25 ;
26 ; Round 0
27 mov eax, DWORD PTR 32[esp]
28 mov edx, esi
29 shr edx, 16
30 mov ecx, DWORD PTR 36[esp]
31 xor edx, esi
32 and eax, edx
33 and edx, ecx
34 mov ebx, eax
35 shl ebx, 16
36 mov ecx, edx
37 shl ecx, 16
38 xor eax, ebx
39 xor edx, ecx
40 mov ebx, DWORD PTR [ebp]
41 xor eax, ebx
42 mov ecx, DWORD PTR 4[ebp]
43 xor eax, esi
44 xor edx, esi
45 xor edx, ecx
46 and eax, 0fcfcfcfch
47 xor ebx, ebx
48 and edx, 0cfcfcfcfh
49 xor ecx, ecx
50 mov bl, al
51 mov cl, ah
52 ror edx, 4
53 mov ebp, DWORD PTR _des_SPtrans[ebx]
54 mov bl, dl
55 xor edi, ebp
56 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
57 xor edi, ebp
58 mov cl, dh
59 shr eax, 16
60 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
61 xor edi, ebp
62 mov bl, ah
63 shr edx, 16
64 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
65 xor edi, ebp
66 mov ebp, DWORD PTR 28[esp]
67 mov cl, dh
68 and eax, 0ffh
69 and edx, 0ffh
70 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
71 xor edi, ebx
72 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
73 xor edi, ebx
74 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
75 xor edi, ebx
76 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
77 xor edi, ebx
78 ;
79 ; Round 1
80 mov eax, DWORD PTR 32[esp]
81 mov edx, edi
82 shr edx, 16
83 mov ecx, DWORD PTR 36[esp]
84 xor edx, edi
85 and eax, edx
86 and edx, ecx
87 mov ebx, eax
88 shl ebx, 16
89 mov ecx, edx
90 shl ecx, 16
91 xor eax, ebx
92 xor edx, ecx
93 mov ebx, DWORD PTR 8[ebp]
94 xor eax, ebx
95 mov ecx, DWORD PTR 12[ebp]
96 xor eax, edi
97 xor edx, edi
98 xor edx, ecx
99 and eax, 0fcfcfcfch
100 xor ebx, ebx
101 and edx, 0cfcfcfcfh
102 xor ecx, ecx
103 mov bl, al
104 mov cl, ah
105 ror edx, 4
106 mov ebp, DWORD PTR _des_SPtrans[ebx]
107 mov bl, dl
108 xor esi, ebp
109 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
110 xor esi, ebp
111 mov cl, dh
112 shr eax, 16
113 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
114 xor esi, ebp
115 mov bl, ah
116 shr edx, 16
117 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
118 xor esi, ebp
119 mov ebp, DWORD PTR 28[esp]
120 mov cl, dh
121 and eax, 0ffh
122 and edx, 0ffh
123 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
124 xor esi, ebx
125 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
126 xor esi, ebx
127 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
128 xor esi, ebx
129 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
130 xor esi, ebx
131 ;
132 ; Round 2
133 mov eax, DWORD PTR 32[esp]
134 mov edx, esi
135 shr edx, 16
136 mov ecx, DWORD PTR 36[esp]
137 xor edx, esi
138 and eax, edx
139 and edx, ecx
140 mov ebx, eax
141 shl ebx, 16
142 mov ecx, edx
143 shl ecx, 16
144 xor eax, ebx
145 xor edx, ecx
146 mov ebx, DWORD PTR 16[ebp]
147 xor eax, ebx
148 mov ecx, DWORD PTR 20[ebp]
149 xor eax, esi
150 xor edx, esi
151 xor edx, ecx
152 and eax, 0fcfcfcfch
153 xor ebx, ebx
154 and edx, 0cfcfcfcfh
155 xor ecx, ecx
156 mov bl, al
157 mov cl, ah
158 ror edx, 4
159 mov ebp, DWORD PTR _des_SPtrans[ebx]
160 mov bl, dl
161 xor edi, ebp
162 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
163 xor edi, ebp
164 mov cl, dh
165 shr eax, 16
166 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
167 xor edi, ebp
168 mov bl, ah
169 shr edx, 16
170 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
171 xor edi, ebp
172 mov ebp, DWORD PTR 28[esp]
173 mov cl, dh
174 and eax, 0ffh
175 and edx, 0ffh
176 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
177 xor edi, ebx
178 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
179 xor edi, ebx
180 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
181 xor edi, ebx
182 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
183 xor edi, ebx
184 ;
185 ; Round 3
186 mov eax, DWORD PTR 32[esp]
187 mov edx, edi
188 shr edx, 16
189 mov ecx, DWORD PTR 36[esp]
190 xor edx, edi
191 and eax, edx
192 and edx, ecx
193 mov ebx, eax
194 shl ebx, 16
195 mov ecx, edx
196 shl ecx, 16
197 xor eax, ebx
198 xor edx, ecx
199 mov ebx, DWORD PTR 24[ebp]
200 xor eax, ebx
201 mov ecx, DWORD PTR 28[ebp]
202 xor eax, edi
203 xor edx, edi
204 xor edx, ecx
205 and eax, 0fcfcfcfch
206 xor ebx, ebx
207 and edx, 0cfcfcfcfh
208 xor ecx, ecx
209 mov bl, al
210 mov cl, ah
211 ror edx, 4
212 mov ebp, DWORD PTR _des_SPtrans[ebx]
213 mov bl, dl
214 xor esi, ebp
215 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
216 xor esi, ebp
217 mov cl, dh
218 shr eax, 16
219 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
220 xor esi, ebp
221 mov bl, ah
222 shr edx, 16
223 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
224 xor esi, ebp
225 mov ebp, DWORD PTR 28[esp]
226 mov cl, dh
227 and eax, 0ffh
228 and edx, 0ffh
229 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
230 xor esi, ebx
231 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
232 xor esi, ebx
233 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
234 xor esi, ebx
235 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
236 xor esi, ebx
237 ;
238 ; Round 4
239 mov eax, DWORD PTR 32[esp]
240 mov edx, esi
241 shr edx, 16
242 mov ecx, DWORD PTR 36[esp]
243 xor edx, esi
244 and eax, edx
245 and edx, ecx
246 mov ebx, eax
247 shl ebx, 16
248 mov ecx, edx
249 shl ecx, 16
250 xor eax, ebx
251 xor edx, ecx
252 mov ebx, DWORD PTR 32[ebp]
253 xor eax, ebx
254 mov ecx, DWORD PTR 36[ebp]
255 xor eax, esi
256 xor edx, esi
257 xor edx, ecx
258 and eax, 0fcfcfcfch
259 xor ebx, ebx
260 and edx, 0cfcfcfcfh
261 xor ecx, ecx
262 mov bl, al
263 mov cl, ah
264 ror edx, 4
265 mov ebp, DWORD PTR _des_SPtrans[ebx]
266 mov bl, dl
267 xor edi, ebp
268 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
269 xor edi, ebp
270 mov cl, dh
271 shr eax, 16
272 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
273 xor edi, ebp
274 mov bl, ah
275 shr edx, 16
276 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
277 xor edi, ebp
278 mov ebp, DWORD PTR 28[esp]
279 mov cl, dh
280 and eax, 0ffh
281 and edx, 0ffh
282 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
283 xor edi, ebx
284 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
285 xor edi, ebx
286 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
287 xor edi, ebx
288 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
289 xor edi, ebx
290 ;
291 ; Round 5
292 mov eax, DWORD PTR 32[esp]
293 mov edx, edi
294 shr edx, 16
295 mov ecx, DWORD PTR 36[esp]
296 xor edx, edi
297 and eax, edx
298 and edx, ecx
299 mov ebx, eax
300 shl ebx, 16
301 mov ecx, edx
302 shl ecx, 16
303 xor eax, ebx
304 xor edx, ecx
305 mov ebx, DWORD PTR 40[ebp]
306 xor eax, ebx
307 mov ecx, DWORD PTR 44[ebp]
308 xor eax, edi
309 xor edx, edi
310 xor edx, ecx
311 and eax, 0fcfcfcfch
312 xor ebx, ebx
313 and edx, 0cfcfcfcfh
314 xor ecx, ecx
315 mov bl, al
316 mov cl, ah
317 ror edx, 4
318 mov ebp, DWORD PTR _des_SPtrans[ebx]
319 mov bl, dl
320 xor esi, ebp
321 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
322 xor esi, ebp
323 mov cl, dh
324 shr eax, 16
325 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
326 xor esi, ebp
327 mov bl, ah
328 shr edx, 16
329 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
330 xor esi, ebp
331 mov ebp, DWORD PTR 28[esp]
332 mov cl, dh
333 and eax, 0ffh
334 and edx, 0ffh
335 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
336 xor esi, ebx
337 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
338 xor esi, ebx
339 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
340 xor esi, ebx
341 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
342 xor esi, ebx
343 ;
344 ; Round 6
345 mov eax, DWORD PTR 32[esp]
346 mov edx, esi
347 shr edx, 16
348 mov ecx, DWORD PTR 36[esp]
349 xor edx, esi
350 and eax, edx
351 and edx, ecx
352 mov ebx, eax
353 shl ebx, 16
354 mov ecx, edx
355 shl ecx, 16
356 xor eax, ebx
357 xor edx, ecx
358 mov ebx, DWORD PTR 48[ebp]
359 xor eax, ebx
360 mov ecx, DWORD PTR 52[ebp]
361 xor eax, esi
362 xor edx, esi
363 xor edx, ecx
364 and eax, 0fcfcfcfch
365 xor ebx, ebx
366 and edx, 0cfcfcfcfh
367 xor ecx, ecx
368 mov bl, al
369 mov cl, ah
370 ror edx, 4
371 mov ebp, DWORD PTR _des_SPtrans[ebx]
372 mov bl, dl
373 xor edi, ebp
374 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
375 xor edi, ebp
376 mov cl, dh
377 shr eax, 16
378 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
379 xor edi, ebp
380 mov bl, ah
381 shr edx, 16
382 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
383 xor edi, ebp
384 mov ebp, DWORD PTR 28[esp]
385 mov cl, dh
386 and eax, 0ffh
387 and edx, 0ffh
388 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
389 xor edi, ebx
390 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
391 xor edi, ebx
392 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
393 xor edi, ebx
394 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
395 xor edi, ebx
396 ;
397 ; Round 7
398 mov eax, DWORD PTR 32[esp]
399 mov edx, edi
400 shr edx, 16
401 mov ecx, DWORD PTR 36[esp]
402 xor edx, edi
403 and eax, edx
404 and edx, ecx
405 mov ebx, eax
406 shl ebx, 16
407 mov ecx, edx
408 shl ecx, 16
409 xor eax, ebx
410 xor edx, ecx
411 mov ebx, DWORD PTR 56[ebp]
412 xor eax, ebx
413 mov ecx, DWORD PTR 60[ebp]
414 xor eax, edi
415 xor edx, edi
416 xor edx, ecx
417 and eax, 0fcfcfcfch
418 xor ebx, ebx
419 and edx, 0cfcfcfcfh
420 xor ecx, ecx
421 mov bl, al
422 mov cl, ah
423 ror edx, 4
424 mov ebp, DWORD PTR _des_SPtrans[ebx]
425 mov bl, dl
426 xor esi, ebp
427 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
428 xor esi, ebp
429 mov cl, dh
430 shr eax, 16
431 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
432 xor esi, ebp
433 mov bl, ah
434 shr edx, 16
435 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
436 xor esi, ebp
437 mov ebp, DWORD PTR 28[esp]
438 mov cl, dh
439 and eax, 0ffh
440 and edx, 0ffh
441 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
442 xor esi, ebx
443 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
444 xor esi, ebx
445 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
446 xor esi, ebx
447 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
448 xor esi, ebx
449 ;
450 ; Round 8
451 mov eax, DWORD PTR 32[esp]
452 mov edx, esi
453 shr edx, 16
454 mov ecx, DWORD PTR 36[esp]
455 xor edx, esi
456 and eax, edx
457 and edx, ecx
458 mov ebx, eax
459 shl ebx, 16
460 mov ecx, edx
461 shl ecx, 16
462 xor eax, ebx
463 xor edx, ecx
464 mov ebx, DWORD PTR 64[ebp]
465 xor eax, ebx
466 mov ecx, DWORD PTR 68[ebp]
467 xor eax, esi
468 xor edx, esi
469 xor edx, ecx
470 and eax, 0fcfcfcfch
471 xor ebx, ebx
472 and edx, 0cfcfcfcfh
473 xor ecx, ecx
474 mov bl, al
475 mov cl, ah
476 ror edx, 4
477 mov ebp, DWORD PTR _des_SPtrans[ebx]
478 mov bl, dl
479 xor edi, ebp
480 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
481 xor edi, ebp
482 mov cl, dh
483 shr eax, 16
484 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
485 xor edi, ebp
486 mov bl, ah
487 shr edx, 16
488 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
489 xor edi, ebp
490 mov ebp, DWORD PTR 28[esp]
491 mov cl, dh
492 and eax, 0ffh
493 and edx, 0ffh
494 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
495 xor edi, ebx
496 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
497 xor edi, ebx
498 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
499 xor edi, ebx
500 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
501 xor edi, ebx
502 ;
503 ; Round 9
504 mov eax, DWORD PTR 32[esp]
505 mov edx, edi
506 shr edx, 16
507 mov ecx, DWORD PTR 36[esp]
508 xor edx, edi
509 and eax, edx
510 and edx, ecx
511 mov ebx, eax
512 shl ebx, 16
513 mov ecx, edx
514 shl ecx, 16
515 xor eax, ebx
516 xor edx, ecx
517 mov ebx, DWORD PTR 72[ebp]
518 xor eax, ebx
519 mov ecx, DWORD PTR 76[ebp]
520 xor eax, edi
521 xor edx, edi
522 xor edx, ecx
523 and eax, 0fcfcfcfch
524 xor ebx, ebx
525 and edx, 0cfcfcfcfh
526 xor ecx, ecx
527 mov bl, al
528 mov cl, ah
529 ror edx, 4
530 mov ebp, DWORD PTR _des_SPtrans[ebx]
531 mov bl, dl
532 xor esi, ebp
533 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
534 xor esi, ebp
535 mov cl, dh
536 shr eax, 16
537 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
538 xor esi, ebp
539 mov bl, ah
540 shr edx, 16
541 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
542 xor esi, ebp
543 mov ebp, DWORD PTR 28[esp]
544 mov cl, dh
545 and eax, 0ffh
546 and edx, 0ffh
547 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
548 xor esi, ebx
549 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
550 xor esi, ebx
551 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
552 xor esi, ebx
553 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
554 xor esi, ebx
555 ;
556 ; Round 10
557 mov eax, DWORD PTR 32[esp]
558 mov edx, esi
559 shr edx, 16
560 mov ecx, DWORD PTR 36[esp]
561 xor edx, esi
562 and eax, edx
563 and edx, ecx
564 mov ebx, eax
565 shl ebx, 16
566 mov ecx, edx
567 shl ecx, 16
568 xor eax, ebx
569 xor edx, ecx
570 mov ebx, DWORD PTR 80[ebp]
571 xor eax, ebx
572 mov ecx, DWORD PTR 84[ebp]
573 xor eax, esi
574 xor edx, esi
575 xor edx, ecx
576 and eax, 0fcfcfcfch
577 xor ebx, ebx
578 and edx, 0cfcfcfcfh
579 xor ecx, ecx
580 mov bl, al
581 mov cl, ah
582 ror edx, 4
583 mov ebp, DWORD PTR _des_SPtrans[ebx]
584 mov bl, dl
585 xor edi, ebp
586 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
587 xor edi, ebp
588 mov cl, dh
589 shr eax, 16
590 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
591 xor edi, ebp
592 mov bl, ah
593 shr edx, 16
594 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
595 xor edi, ebp
596 mov ebp, DWORD PTR 28[esp]
597 mov cl, dh
598 and eax, 0ffh
599 and edx, 0ffh
600 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
601 xor edi, ebx
602 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
603 xor edi, ebx
604 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
605 xor edi, ebx
606 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
607 xor edi, ebx
608 ;
609 ; Round 11
610 mov eax, DWORD PTR 32[esp]
611 mov edx, edi
612 shr edx, 16
613 mov ecx, DWORD PTR 36[esp]
614 xor edx, edi
615 and eax, edx
616 and edx, ecx
617 mov ebx, eax
618 shl ebx, 16
619 mov ecx, edx
620 shl ecx, 16
621 xor eax, ebx
622 xor edx, ecx
623 mov ebx, DWORD PTR 88[ebp]
624 xor eax, ebx
625 mov ecx, DWORD PTR 92[ebp]
626 xor eax, edi
627 xor edx, edi
628 xor edx, ecx
629 and eax, 0fcfcfcfch
630 xor ebx, ebx
631 and edx, 0cfcfcfcfh
632 xor ecx, ecx
633 mov bl, al
634 mov cl, ah
635 ror edx, 4
636 mov ebp, DWORD PTR _des_SPtrans[ebx]
637 mov bl, dl
638 xor esi, ebp
639 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
640 xor esi, ebp
641 mov cl, dh
642 shr eax, 16
643 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
644 xor esi, ebp
645 mov bl, ah
646 shr edx, 16
647 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
648 xor esi, ebp
649 mov ebp, DWORD PTR 28[esp]
650 mov cl, dh
651 and eax, 0ffh
652 and edx, 0ffh
653 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
654 xor esi, ebx
655 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
656 xor esi, ebx
657 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
658 xor esi, ebx
659 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
660 xor esi, ebx
661 ;
662 ; Round 12
663 mov eax, DWORD PTR 32[esp]
664 mov edx, esi
665 shr edx, 16
666 mov ecx, DWORD PTR 36[esp]
667 xor edx, esi
668 and eax, edx
669 and edx, ecx
670 mov ebx, eax
671 shl ebx, 16
672 mov ecx, edx
673 shl ecx, 16
674 xor eax, ebx
675 xor edx, ecx
676 mov ebx, DWORD PTR 96[ebp]
677 xor eax, ebx
678 mov ecx, DWORD PTR 100[ebp]
679 xor eax, esi
680 xor edx, esi
681 xor edx, ecx
682 and eax, 0fcfcfcfch
683 xor ebx, ebx
684 and edx, 0cfcfcfcfh
685 xor ecx, ecx
686 mov bl, al
687 mov cl, ah
688 ror edx, 4
689 mov ebp, DWORD PTR _des_SPtrans[ebx]
690 mov bl, dl
691 xor edi, ebp
692 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
693 xor edi, ebp
694 mov cl, dh
695 shr eax, 16
696 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
697 xor edi, ebp
698 mov bl, ah
699 shr edx, 16
700 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
701 xor edi, ebp
702 mov ebp, DWORD PTR 28[esp]
703 mov cl, dh
704 and eax, 0ffh
705 and edx, 0ffh
706 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
707 xor edi, ebx
708 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
709 xor edi, ebx
710 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
711 xor edi, ebx
712 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
713 xor edi, ebx
714 ;
715 ; Round 13
716 mov eax, DWORD PTR 32[esp]
717 mov edx, edi
718 shr edx, 16
719 mov ecx, DWORD PTR 36[esp]
720 xor edx, edi
721 and eax, edx
722 and edx, ecx
723 mov ebx, eax
724 shl ebx, 16
725 mov ecx, edx
726 shl ecx, 16
727 xor eax, ebx
728 xor edx, ecx
729 mov ebx, DWORD PTR 104[ebp]
730 xor eax, ebx
731 mov ecx, DWORD PTR 108[ebp]
732 xor eax, edi
733 xor edx, edi
734 xor edx, ecx
735 and eax, 0fcfcfcfch
736 xor ebx, ebx
737 and edx, 0cfcfcfcfh
738 xor ecx, ecx
739 mov bl, al
740 mov cl, ah
741 ror edx, 4
742 mov ebp, DWORD PTR _des_SPtrans[ebx]
743 mov bl, dl
744 xor esi, ebp
745 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
746 xor esi, ebp
747 mov cl, dh
748 shr eax, 16
749 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
750 xor esi, ebp
751 mov bl, ah
752 shr edx, 16
753 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
754 xor esi, ebp
755 mov ebp, DWORD PTR 28[esp]
756 mov cl, dh
757 and eax, 0ffh
758 and edx, 0ffh
759 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
760 xor esi, ebx
761 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
762 xor esi, ebx
763 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
764 xor esi, ebx
765 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
766 xor esi, ebx
767 ;
768 ; Round 14
769 mov eax, DWORD PTR 32[esp]
770 mov edx, esi
771 shr edx, 16
772 mov ecx, DWORD PTR 36[esp]
773 xor edx, esi
774 and eax, edx
775 and edx, ecx
776 mov ebx, eax
777 shl ebx, 16
778 mov ecx, edx
779 shl ecx, 16
780 xor eax, ebx
781 xor edx, ecx
782 mov ebx, DWORD PTR 112[ebp]
783 xor eax, ebx
784 mov ecx, DWORD PTR 116[ebp]
785 xor eax, esi
786 xor edx, esi
787 xor edx, ecx
788 and eax, 0fcfcfcfch
789 xor ebx, ebx
790 and edx, 0cfcfcfcfh
791 xor ecx, ecx
792 mov bl, al
793 mov cl, ah
794 ror edx, 4
795 mov ebp, DWORD PTR _des_SPtrans[ebx]
796 mov bl, dl
797 xor edi, ebp
798 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
799 xor edi, ebp
800 mov cl, dh
801 shr eax, 16
802 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
803 xor edi, ebp
804 mov bl, ah
805 shr edx, 16
806 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
807 xor edi, ebp
808 mov ebp, DWORD PTR 28[esp]
809 mov cl, dh
810 and eax, 0ffh
811 and edx, 0ffh
812 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
813 xor edi, ebx
814 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
815 xor edi, ebx
816 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
817 xor edi, ebx
818 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
819 xor edi, ebx
820 ;
821 ; Round 15
822 mov eax, DWORD PTR 32[esp]
823 mov edx, edi
824 shr edx, 16
825 mov ecx, DWORD PTR 36[esp]
826 xor edx, edi
827 and eax, edx
828 and edx, ecx
829 mov ebx, eax
830 shl ebx, 16
831 mov ecx, edx
832 shl ecx, 16
833 xor eax, ebx
834 xor edx, ecx
835 mov ebx, DWORD PTR 120[ebp]
836 xor eax, ebx
837 mov ecx, DWORD PTR 124[ebp]
838 xor eax, edi
839 xor edx, edi
840 xor edx, ecx
841 and eax, 0fcfcfcfch
842 xor ebx, ebx
843 and edx, 0cfcfcfcfh
844 xor ecx, ecx
845 mov bl, al
846 mov cl, ah
847 ror edx, 4
848 mov ebp, DWORD PTR _des_SPtrans[ebx]
849 mov bl, dl
850 xor esi, ebp
851 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
852 xor esi, ebp
853 mov cl, dh
854 shr eax, 16
855 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
856 xor esi, ebp
857 mov bl, ah
858 shr edx, 16
859 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
860 xor esi, ebp
861 mov ebp, DWORD PTR 28[esp]
862 mov cl, dh
863 and eax, 0ffh
864 and edx, 0ffh
865 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
866 xor esi, ebx
867 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
868 xor esi, ebx
869 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
870 xor esi, ebx
871 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
872 xor esi, ebx
873 mov ebx, DWORD PTR [esp]
874 mov eax, edi
875 dec ebx
876 mov edi, esi
877 mov esi, eax
878 mov DWORD PTR [esp],ebx
879 jnz L000start
880 ;
881 ; FP
882 mov edx, DWORD PTR 24[esp]
883 ror edi, 1
884 mov eax, esi
885 xor esi, edi
886 and esi, 0aaaaaaaah
887 xor eax, esi
888 xor edi, esi
889 ;
890 rol eax, 23
891 mov esi, eax
892 xor eax, edi
893 and eax, 003fc03fch
894 xor esi, eax
895 xor edi, eax
896 ;
897 rol esi, 10
898 mov eax, esi
899 xor esi, edi
900 and esi, 033333333h
901 xor eax, esi
902 xor edi, esi
903 ;
904 rol edi, 18
905 mov esi, edi
906 xor edi, eax
907 and edi, 0fff0000fh
908 xor esi, edi
909 xor eax, edi
910 ;
911 rol esi, 12
912 mov edi, esi
913 xor esi, eax
914 and esi, 0f0f0f0f0h
915 xor edi, esi
916 xor eax, esi
917 ;
918 ror eax, 4
919 mov DWORD PTR [edx],eax
920 mov DWORD PTR 4[edx],edi
921 pop ecx
922 pop edi
923 pop esi
924 pop ebx
925 pop ebp
926 ret
927_fcrypt_body ENDP
928_TEXT ENDS
929END
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
index 91d7153b34..0197489c9e 100644
--- a/src/lib/libcrypto/des/des.c
+++ b/src/lib/libcrypto/des/des.c
@@ -58,6 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h>
61#ifndef MSDOS 62#ifndef MSDOS
62#ifndef VMS 63#ifndef VMS
63#include <openssl/opensslconf.h> 64#include <openssl/opensslconf.h>
@@ -69,7 +70,7 @@
69#include <math.h> 70#include <math.h>
70#endif /* __DECC */ 71#endif /* __DECC */
71#endif /* VMS */ 72#endif /* VMS */
72#else 73#else /* MSDOS */
73#include <io.h> 74#include <io.h>
74#endif 75#endif
75 76
@@ -88,10 +89,6 @@
88#include <openssl/des.h> 89#include <openssl/des.h>
89#include <openssl/rand.h> 90#include <openssl/rand.h>
90 91
91#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
92#include <string.h>
93#endif
94
95void usage(void); 92void usage(void);
96void doencryption(void); 93void doencryption(void);
97int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp); 94int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp);
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
index 98a9c4127c..ead67986d9 100644
--- a/src/lib/libcrypto/des/des.h
+++ b/src/lib/libcrypto/des/des.h
@@ -78,10 +78,7 @@ extern "C" {
78typedef unsigned char des_cblock[8]; 78typedef unsigned char des_cblock[8];
79typedef /* const */ unsigned char const_des_cblock[8]; 79typedef /* const */ unsigned char const_des_cblock[8];
80/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock * 80/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock *
81 * and const_des_cblock * are incompatible pointer types. 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 82
86typedef struct des_ks_struct 83typedef struct des_ks_struct
87 { 84 {
@@ -141,8 +138,26 @@ void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
141 int enc); 138 int enc);
142void des_ecb_encrypt(const_des_cblock *input,des_cblock *output, 139void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
143 des_key_schedule ks,int enc); 140 des_key_schedule ks,int enc);
141
142/* This is the DES encryption function that gets called by just about
143 every other DES routine in the library. You should not use this
144 function except to implement 'modes' of DES. I say this because the
145 functions that call this routine do the conversion from 'char *' to
146 long, and this needs to be done to make sure 'non-aligned' memory
147 access do not occur. The characters are loaded 'little endian'.
148 Data is a pointer to 2 unsigned long's and ks is the
149 des_key_schedule to use. enc, is non zero specifies encryption,
150 zero if decryption. */
144void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc); 151void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
152
153/* This functions is the same as des_encrypt() except that the DES
154 initial permutation (IP) and final permutation (FP) have been left
155 out. As for des_encrypt(), you should not use this function.
156 It is used by the routines in the library that implement triple DES.
157 IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same
158 as des_encrypt() des_encrypt() des_encrypt() except faster :-). */
145void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc); 159void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
160
146void des_encrypt3(DES_LONG *data, des_key_schedule ks1, 161void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
147 des_key_schedule ks2, des_key_schedule ks3); 162 des_key_schedule ks2, des_key_schedule ks3);
148void des_decrypt3(DES_LONG *data, des_key_schedule ks1, 163void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
@@ -192,6 +207,7 @@ int des_read_2passwords(des_cblock *key1,des_cblock *key2,
192 const char *prompt,int verify); 207 const char *prompt,int verify);
193int des_read_pw_string(char *buf,int length,const char *prompt,int verify); 208int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
194void des_set_odd_parity(des_cblock *key); 209void des_set_odd_parity(des_cblock *key);
210int des_check_key_parity(const_des_cblock *key);
195int des_is_weak_key(const_des_cblock *key); 211int des_is_weak_key(const_des_cblock *key);
196/* des_set_key (= set_key = des_key_sched = key_sched) calls 212/* des_set_key (= set_key = des_key_sched = key_sched) calls
197 * des_set_key_checked if global variable des_check_key is set, 213 * des_set_key_checked if global variable des_check_key is set,
@@ -209,9 +225,6 @@ void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
209 des_key_schedule schedule,des_cblock *ivec,int *num); 225 des_key_schedule schedule,des_cblock *ivec,int *num);
210int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); 226int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
211 227
212/* Extra functions from Mark Murray <mark@grondar.za> */
213void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
214
215/* The following definitions provide compatibility with the MIT Kerberos 228/* The following definitions provide compatibility with the MIT Kerberos
216 * library. The des_key_schedule structure is not binary compatible. */ 229 * library. The des_key_schedule structure is not binary compatible. */
217 230
@@ -241,11 +254,11 @@ void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
241# define xcbc_encrypt des_xcbc_encrypt 254# define xcbc_encrypt des_xcbc_encrypt
242# define cbc_cksum des_cbc_cksum 255# define cbc_cksum des_cbc_cksum
243# define quad_cksum des_quad_cksum 256# define quad_cksum des_quad_cksum
257# define check_parity des_check_key_parity
244#endif 258#endif
245 259
246typedef des_key_schedule bit_64; 260typedef des_key_schedule bit_64;
247#define des_fixup_key_parity des_set_odd_parity 261#define des_fixup_key_parity des_set_odd_parity
248#define des_check_key_parity check_parity
249 262
250#ifdef __cplusplus 263#ifdef __cplusplus
251} 264}
diff --git a/src/lib/libcrypto/des/des.man b/src/lib/libcrypto/des/des.man
index 7e06a1851a..e69de29bb2 100644
--- a/src/lib/libcrypto/des/des.man
+++ b/src/lib/libcrypto/des/des.man
@@ -1,186 +0,0 @@
1.TH DES 1
2.SH NAME
3des - encrypt or decrypt data using Data Encryption Standard
4.SH SYNOPSIS
5.B des
6(
7.B \-e
8|
9.B \-E
10) | (
11.B \-d
12|
13.B \-D
14) | (
15.B \-\fR[\fPcC\fR][\fPckname\fR]\fP
16) |
17[
18.B \-b3hfs
19] [
20.B \-k
21.I key
22]
23] [
24.B \-u\fR[\fIuuname\fR]
25[
26.I input-file
27[
28.I output-file
29] ]
30.SH DESCRIPTION
31.B des
32encrypts and decrypts data using the
33Data Encryption Standard algorithm.
34One of
35.B \-e, \-E
36(for encrypt) or
37.B \-d, \-D
38(for decrypt) must be specified.
39It is also possible to use
40.B \-c
41or
42.B \-C
43in conjunction or instead of the a encrypt/decrypt option to generate
44a 16 character hexadecimal checksum, generated via the
45.I des_cbc_cksum.
46.LP
47Two standard encryption modes are supported by the
48.B des
49program, Cipher Block Chaining (the default) and Electronic Code Book
50(specified with
51.B \-b
52).
53.LP
54The key used for the DES
55algorithm is obtained by prompting the user unless the
56.B `\-k
57.I key'
58option is given.
59If the key is an argument to the
60.B des
61command, it is potentially visible to users executing
62.BR ps (1)
63or a derivative. To minimise this possibility,
64.B des
65takes care to destroy the key argument immediately upon entry.
66If your shell keeps a history file be careful to make sure it is not
67world readable.
68.LP
69Since this program attempts to maintain compatability with sunOS's
70des(1) command, there are 2 different methods used to convert the user
71supplied key to a des key.
72Whenever and one or more of
73.B \-E, \-D, \-C
74or
75.B \-3
76options are used, the key conversion procedure will not be compatible
77with the sunOS des(1) version but will use all the user supplied
78character to generate the des key.
79.B des
80command reads from standard input unless
81.I input-file
82is specified and writes to standard output unless
83.I output-file
84is given.
85.SH OPTIONS
86.TP
87.B \-b
88Select ECB
89(eight bytes at a time) encryption mode.
90.TP
91.B \-3
92Encrypt using triple encryption.
93By default triple cbc encryption is used but if the
94.B \-b
95option is used then triple ecb encryption is performed.
96If the key is less than 8 characters long, the flag has no effect.
97.TP
98.B \-e
99Encrypt data using an 8 byte key in a manner compatible with sunOS
100des(1).
101.TP
102.B \-E
103Encrypt data using a key of nearly unlimited length (1024 bytes).
104This will product a more secure encryption.
105.TP
106.B \-d
107Decrypt data that was encrypted with the \-e option.
108.TP
109.B \-D
110Decrypt data that was encrypted with the \-E option.
111.TP
112.B \-c
113Generate a 16 character hexadecimal cbc checksum and output this to
114stderr.
115If a filename was specified after the
116.B \-c
117option, the checksum is output to that file.
118The checksum is generated using a key generated in a sunOS compatible
119manner.
120.TP
121.B \-C
122A cbc checksum is generated in the same manner as described for the
123.B \-c
124option but the DES key is generated in the same manner as used for the
125.B \-E
126and
127.B \-D
128options
129.TP
130.B \-f
131Does nothing - allowed for compatibility with sunOS des(1) command.
132.TP
133.B \-s
134Does nothing - allowed for compatibility with sunOS des(1) command.
135.TP
136.B "\-k \fIkey\fP"
137Use the encryption
138.I key
139specified.
140.TP
141.B "\-h"
142The
143.I key
144is assumed to be a 16 character hexadecimal number.
145If the
146.B "\-3"
147option is used the key is assumed to be a 32 character hexadecimal
148number.
149.TP
150.B \-u
151This flag is used to read and write uuencoded files. If decrypting,
152the input file is assumed to contain uuencoded, DES encrypted data.
153If encrypting, the characters following the -u are used as the name of
154the uuencoded file to embed in the begin line of the uuencoded
155output. If there is no name specified after the -u, the name text.des
156will be embedded in the header.
157.SH SEE ALSO
158.B ps (1)
159.B des_crypt(3)
160.SH BUGS
161.LP
162The problem with using the
163.B -e
164option is the short key length.
165It would be better to use a real 56-bit key rather than an
166ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
167radically reduces the time necessary for a brute-force cryptographic attack.
168My attempt to remove this problem is to add an alternative text-key to
169DES-key function. This alternative function (accessed via
170.B -E, -D, -S
171and
172.B -3
173)
174uses DES to help generate the key.
175.LP
176Be carefully when using the -u option. Doing des -ud <filename> will
177not decrypt filename (the -u option will gobble the d option).
178.LP
179The VMS operating system operates in a world where files are always a
180multiple of 512 bytes. This causes problems when encrypted data is
181send from unix to VMS since a 88 byte file will suddenly be padded
182with 424 null bytes. To get around this problem, use the -u option
183to uuencode the data before it is send to the VMS system.
184.SH AUTHOR
185.LP
186Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libcrypto/des/des.pl b/src/lib/libcrypto/des/des.pl
index 8a3f7e3ed6..e69de29bb2 100644
--- a/src/lib/libcrypto/des/des.pl
+++ b/src/lib/libcrypto/des/des.pl
@@ -1,552 +0,0 @@
1#!/usr/local/bin/perl
2# des.pl - eric young 22/11/1991 eay@cryptsoft.com
3#
4# Copyright (C) 1993 Eric Young
5#
6# 11 April 1996 - patched to circumvent Perl 5 (through 5.002) problem
7# with sign-extension on right shift operations.
8# Ed Kubaitis - ejk@uiuc.edu
9#
10# eay - 92/08/31 - I think I have fixed all problems for 64bit
11# versions of perl but I could be wrong since I have not tested it yet :-).
12#
13# This is an implementation of DES in perl.
14# The two routines (des_set_key and des_ecb_encrypt)
15# take 8 byte objects as arguments.
16#
17# des_set_key takes an 8 byte string as a key and returns a key schedule
18# for use in calls to des_ecb_encrypt.
19# des_ecb_encrypt takes three arguments, the first is a key schedule
20# (make sure to pass it by reference with the *), the second is 1
21# to encrypt, 0 to decrypt. The third argument is an 8 byte object
22# to encrypt. The function returns an 8 byte object that has been
23# DES encrypted.
24#
25# example:
26# require 'des.pl'
27#
28# $key =pack("C8",0x12,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
29# @ks= &des_set_key($key);
30#
31# $outbytes= &des_ecb_encrypt(*ks,1,$data);
32# @enc =unpack("C8",$outbytes);
33#
34
35package des;
36
37eval("use integer;") if (int($]) > 4);
38
39# The following 8 arrays are used in des_set_key
40@skb0=(
41# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6
420x00000000,0x00000010,0x20000000,0x20000010,
430x00010000,0x00010010,0x20010000,0x20010010,
440x00000800,0x00000810,0x20000800,0x20000810,
450x00010800,0x00010810,0x20010800,0x20010810,
460x00000020,0x00000030,0x20000020,0x20000030,
470x00010020,0x00010030,0x20010020,0x20010030,
480x00000820,0x00000830,0x20000820,0x20000830,
490x00010820,0x00010830,0x20010820,0x20010830,
500x00080000,0x00080010,0x20080000,0x20080010,
510x00090000,0x00090010,0x20090000,0x20090010,
520x00080800,0x00080810,0x20080800,0x20080810,
530x00090800,0x00090810,0x20090800,0x20090810,
540x00080020,0x00080030,0x20080020,0x20080030,
550x00090020,0x00090030,0x20090020,0x20090030,
560x00080820,0x00080830,0x20080820,0x20080830,
570x00090820,0x00090830,0x20090820,0x20090830,
58);
59@skb1=(
60# for C bits (numbered as per FIPS 46) 7 8 10 11 12 13
610x00000000,0x02000000,0x00002000,0x02002000,
620x00200000,0x02200000,0x00202000,0x02202000,
630x00000004,0x02000004,0x00002004,0x02002004,
640x00200004,0x02200004,0x00202004,0x02202004,
650x00000400,0x02000400,0x00002400,0x02002400,
660x00200400,0x02200400,0x00202400,0x02202400,
670x00000404,0x02000404,0x00002404,0x02002404,
680x00200404,0x02200404,0x00202404,0x02202404,
690x10000000,0x12000000,0x10002000,0x12002000,
700x10200000,0x12200000,0x10202000,0x12202000,
710x10000004,0x12000004,0x10002004,0x12002004,
720x10200004,0x12200004,0x10202004,0x12202004,
730x10000400,0x12000400,0x10002400,0x12002400,
740x10200400,0x12200400,0x10202400,0x12202400,
750x10000404,0x12000404,0x10002404,0x12002404,
760x10200404,0x12200404,0x10202404,0x12202404,
77);
78@skb2=(
79# for C bits (numbered as per FIPS 46) 14 15 16 17 19 20
800x00000000,0x00000001,0x00040000,0x00040001,
810x01000000,0x01000001,0x01040000,0x01040001,
820x00000002,0x00000003,0x00040002,0x00040003,
830x01000002,0x01000003,0x01040002,0x01040003,
840x00000200,0x00000201,0x00040200,0x00040201,
850x01000200,0x01000201,0x01040200,0x01040201,
860x00000202,0x00000203,0x00040202,0x00040203,
870x01000202,0x01000203,0x01040202,0x01040203,
880x08000000,0x08000001,0x08040000,0x08040001,
890x09000000,0x09000001,0x09040000,0x09040001,
900x08000002,0x08000003,0x08040002,0x08040003,
910x09000002,0x09000003,0x09040002,0x09040003,
920x08000200,0x08000201,0x08040200,0x08040201,
930x09000200,0x09000201,0x09040200,0x09040201,
940x08000202,0x08000203,0x08040202,0x08040203,
950x09000202,0x09000203,0x09040202,0x09040203,
96);
97@skb3=(
98# for C bits (numbered as per FIPS 46) 21 23 24 26 27 28
990x00000000,0x00100000,0x00000100,0x00100100,
1000x00000008,0x00100008,0x00000108,0x00100108,
1010x00001000,0x00101000,0x00001100,0x00101100,
1020x00001008,0x00101008,0x00001108,0x00101108,
1030x04000000,0x04100000,0x04000100,0x04100100,
1040x04000008,0x04100008,0x04000108,0x04100108,
1050x04001000,0x04101000,0x04001100,0x04101100,
1060x04001008,0x04101008,0x04001108,0x04101108,
1070x00020000,0x00120000,0x00020100,0x00120100,
1080x00020008,0x00120008,0x00020108,0x00120108,
1090x00021000,0x00121000,0x00021100,0x00121100,
1100x00021008,0x00121008,0x00021108,0x00121108,
1110x04020000,0x04120000,0x04020100,0x04120100,
1120x04020008,0x04120008,0x04020108,0x04120108,
1130x04021000,0x04121000,0x04021100,0x04121100,
1140x04021008,0x04121008,0x04021108,0x04121108,
115);
116@skb4=(
117# for D bits (numbered as per FIPS 46) 1 2 3 4 5 6
1180x00000000,0x10000000,0x00010000,0x10010000,
1190x00000004,0x10000004,0x00010004,0x10010004,
1200x20000000,0x30000000,0x20010000,0x30010000,
1210x20000004,0x30000004,0x20010004,0x30010004,
1220x00100000,0x10100000,0x00110000,0x10110000,
1230x00100004,0x10100004,0x00110004,0x10110004,
1240x20100000,0x30100000,0x20110000,0x30110000,
1250x20100004,0x30100004,0x20110004,0x30110004,
1260x00001000,0x10001000,0x00011000,0x10011000,
1270x00001004,0x10001004,0x00011004,0x10011004,
1280x20001000,0x30001000,0x20011000,0x30011000,
1290x20001004,0x30001004,0x20011004,0x30011004,
1300x00101000,0x10101000,0x00111000,0x10111000,
1310x00101004,0x10101004,0x00111004,0x10111004,
1320x20101000,0x30101000,0x20111000,0x30111000,
1330x20101004,0x30101004,0x20111004,0x30111004,
134);
135@skb5=(
136# for D bits (numbered as per FIPS 46) 8 9 11 12 13 14
1370x00000000,0x08000000,0x00000008,0x08000008,
1380x00000400,0x08000400,0x00000408,0x08000408,
1390x00020000,0x08020000,0x00020008,0x08020008,
1400x00020400,0x08020400,0x00020408,0x08020408,
1410x00000001,0x08000001,0x00000009,0x08000009,
1420x00000401,0x08000401,0x00000409,0x08000409,
1430x00020001,0x08020001,0x00020009,0x08020009,
1440x00020401,0x08020401,0x00020409,0x08020409,
1450x02000000,0x0A000000,0x02000008,0x0A000008,
1460x02000400,0x0A000400,0x02000408,0x0A000408,
1470x02020000,0x0A020000,0x02020008,0x0A020008,
1480x02020400,0x0A020400,0x02020408,0x0A020408,
1490x02000001,0x0A000001,0x02000009,0x0A000009,
1500x02000401,0x0A000401,0x02000409,0x0A000409,
1510x02020001,0x0A020001,0x02020009,0x0A020009,
1520x02020401,0x0A020401,0x02020409,0x0A020409,
153);
154@skb6=(
155# for D bits (numbered as per FIPS 46) 16 17 18 19 20 21
1560x00000000,0x00000100,0x00080000,0x00080100,
1570x01000000,0x01000100,0x01080000,0x01080100,
1580x00000010,0x00000110,0x00080010,0x00080110,
1590x01000010,0x01000110,0x01080010,0x01080110,
1600x00200000,0x00200100,0x00280000,0x00280100,
1610x01200000,0x01200100,0x01280000,0x01280100,
1620x00200010,0x00200110,0x00280010,0x00280110,
1630x01200010,0x01200110,0x01280010,0x01280110,
1640x00000200,0x00000300,0x00080200,0x00080300,
1650x01000200,0x01000300,0x01080200,0x01080300,
1660x00000210,0x00000310,0x00080210,0x00080310,
1670x01000210,0x01000310,0x01080210,0x01080310,
1680x00200200,0x00200300,0x00280200,0x00280300,
1690x01200200,0x01200300,0x01280200,0x01280300,
1700x00200210,0x00200310,0x00280210,0x00280310,
1710x01200210,0x01200310,0x01280210,0x01280310,
172);
173@skb7=(
174# for D bits (numbered as per FIPS 46) 22 23 24 25 27 28
1750x00000000,0x04000000,0x00040000,0x04040000,
1760x00000002,0x04000002,0x00040002,0x04040002,
1770x00002000,0x04002000,0x00042000,0x04042000,
1780x00002002,0x04002002,0x00042002,0x04042002,
1790x00000020,0x04000020,0x00040020,0x04040020,
1800x00000022,0x04000022,0x00040022,0x04040022,
1810x00002020,0x04002020,0x00042020,0x04042020,
1820x00002022,0x04002022,0x00042022,0x04042022,
1830x00000800,0x04000800,0x00040800,0x04040800,
1840x00000802,0x04000802,0x00040802,0x04040802,
1850x00002800,0x04002800,0x00042800,0x04042800,
1860x00002802,0x04002802,0x00042802,0x04042802,
1870x00000820,0x04000820,0x00040820,0x04040820,
1880x00000822,0x04000822,0x00040822,0x04040822,
1890x00002820,0x04002820,0x00042820,0x04042820,
1900x00002822,0x04002822,0x00042822,0x04042822,
191);
192
193@shifts2=(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0);
194
195# used in ecb_encrypt
196@SP0=(
1970x00410100, 0x00010000, 0x40400000, 0x40410100,
1980x00400000, 0x40010100, 0x40010000, 0x40400000,
1990x40010100, 0x00410100, 0x00410000, 0x40000100,
2000x40400100, 0x00400000, 0x00000000, 0x40010000,
2010x00010000, 0x40000000, 0x00400100, 0x00010100,
2020x40410100, 0x00410000, 0x40000100, 0x00400100,
2030x40000000, 0x00000100, 0x00010100, 0x40410000,
2040x00000100, 0x40400100, 0x40410000, 0x00000000,
2050x00000000, 0x40410100, 0x00400100, 0x40010000,
2060x00410100, 0x00010000, 0x40000100, 0x00400100,
2070x40410000, 0x00000100, 0x00010100, 0x40400000,
2080x40010100, 0x40000000, 0x40400000, 0x00410000,
2090x40410100, 0x00010100, 0x00410000, 0x40400100,
2100x00400000, 0x40000100, 0x40010000, 0x00000000,
2110x00010000, 0x00400000, 0x40400100, 0x00410100,
2120x40000000, 0x40410000, 0x00000100, 0x40010100,
213);
214@SP1=(
2150x08021002, 0x00000000, 0x00021000, 0x08020000,
2160x08000002, 0x00001002, 0x08001000, 0x00021000,
2170x00001000, 0x08020002, 0x00000002, 0x08001000,
2180x00020002, 0x08021000, 0x08020000, 0x00000002,
2190x00020000, 0x08001002, 0x08020002, 0x00001000,
2200x00021002, 0x08000000, 0x00000000, 0x00020002,
2210x08001002, 0x00021002, 0x08021000, 0x08000002,
2220x08000000, 0x00020000, 0x00001002, 0x08021002,
2230x00020002, 0x08021000, 0x08001000, 0x00021002,
2240x08021002, 0x00020002, 0x08000002, 0x00000000,
2250x08000000, 0x00001002, 0x00020000, 0x08020002,
2260x00001000, 0x08000000, 0x00021002, 0x08001002,
2270x08021000, 0x00001000, 0x00000000, 0x08000002,
2280x00000002, 0x08021002, 0x00021000, 0x08020000,
2290x08020002, 0x00020000, 0x00001002, 0x08001000,
2300x08001002, 0x00000002, 0x08020000, 0x00021000,
231);
232@SP2=(
2330x20800000, 0x00808020, 0x00000020, 0x20800020,
2340x20008000, 0x00800000, 0x20800020, 0x00008020,
2350x00800020, 0x00008000, 0x00808000, 0x20000000,
2360x20808020, 0x20000020, 0x20000000, 0x20808000,
2370x00000000, 0x20008000, 0x00808020, 0x00000020,
2380x20000020, 0x20808020, 0x00008000, 0x20800000,
2390x20808000, 0x00800020, 0x20008020, 0x00808000,
2400x00008020, 0x00000000, 0x00800000, 0x20008020,
2410x00808020, 0x00000020, 0x20000000, 0x00008000,
2420x20000020, 0x20008000, 0x00808000, 0x20800020,
2430x00000000, 0x00808020, 0x00008020, 0x20808000,
2440x20008000, 0x00800000, 0x20808020, 0x20000000,
2450x20008020, 0x20800000, 0x00800000, 0x20808020,
2460x00008000, 0x00800020, 0x20800020, 0x00008020,
2470x00800020, 0x00000000, 0x20808000, 0x20000020,
2480x20800000, 0x20008020, 0x00000020, 0x00808000,
249);
250@SP3=(
2510x00080201, 0x02000200, 0x00000001, 0x02080201,
2520x00000000, 0x02080000, 0x02000201, 0x00080001,
2530x02080200, 0x02000001, 0x02000000, 0x00000201,
2540x02000001, 0x00080201, 0x00080000, 0x02000000,
2550x02080001, 0x00080200, 0x00000200, 0x00000001,
2560x00080200, 0x02000201, 0x02080000, 0x00000200,
2570x00000201, 0x00000000, 0x00080001, 0x02080200,
2580x02000200, 0x02080001, 0x02080201, 0x00080000,
2590x02080001, 0x00000201, 0x00080000, 0x02000001,
2600x00080200, 0x02000200, 0x00000001, 0x02080000,
2610x02000201, 0x00000000, 0x00000200, 0x00080001,
2620x00000000, 0x02080001, 0x02080200, 0x00000200,
2630x02000000, 0x02080201, 0x00080201, 0x00080000,
2640x02080201, 0x00000001, 0x02000200, 0x00080201,
2650x00080001, 0x00080200, 0x02080000, 0x02000201,
2660x00000201, 0x02000000, 0x02000001, 0x02080200,
267);
268@SP4=(
2690x01000000, 0x00002000, 0x00000080, 0x01002084,
2700x01002004, 0x01000080, 0x00002084, 0x01002000,
2710x00002000, 0x00000004, 0x01000004, 0x00002080,
2720x01000084, 0x01002004, 0x01002080, 0x00000000,
2730x00002080, 0x01000000, 0x00002004, 0x00000084,
2740x01000080, 0x00002084, 0x00000000, 0x01000004,
2750x00000004, 0x01000084, 0x01002084, 0x00002004,
2760x01002000, 0x00000080, 0x00000084, 0x01002080,
2770x01002080, 0x01000084, 0x00002004, 0x01002000,
2780x00002000, 0x00000004, 0x01000004, 0x01000080,
2790x01000000, 0x00002080, 0x01002084, 0x00000000,
2800x00002084, 0x01000000, 0x00000080, 0x00002004,
2810x01000084, 0x00000080, 0x00000000, 0x01002084,
2820x01002004, 0x01002080, 0x00000084, 0x00002000,
2830x00002080, 0x01002004, 0x01000080, 0x00000084,
2840x00000004, 0x00002084, 0x01002000, 0x01000004,
285);
286@SP5=(
2870x10000008, 0x00040008, 0x00000000, 0x10040400,
2880x00040008, 0x00000400, 0x10000408, 0x00040000,
2890x00000408, 0x10040408, 0x00040400, 0x10000000,
2900x10000400, 0x10000008, 0x10040000, 0x00040408,
2910x00040000, 0x10000408, 0x10040008, 0x00000000,
2920x00000400, 0x00000008, 0x10040400, 0x10040008,
2930x10040408, 0x10040000, 0x10000000, 0x00000408,
2940x00000008, 0x00040400, 0x00040408, 0x10000400,
2950x00000408, 0x10000000, 0x10000400, 0x00040408,
2960x10040400, 0x00040008, 0x00000000, 0x10000400,
2970x10000000, 0x00000400, 0x10040008, 0x00040000,
2980x00040008, 0x10040408, 0x00040400, 0x00000008,
2990x10040408, 0x00040400, 0x00040000, 0x10000408,
3000x10000008, 0x10040000, 0x00040408, 0x00000000,
3010x00000400, 0x10000008, 0x10000408, 0x10040400,
3020x10040000, 0x00000408, 0x00000008, 0x10040008,
303);
304@SP6=(
3050x00000800, 0x00000040, 0x00200040, 0x80200000,
3060x80200840, 0x80000800, 0x00000840, 0x00000000,
3070x00200000, 0x80200040, 0x80000040, 0x00200800,
3080x80000000, 0x00200840, 0x00200800, 0x80000040,
3090x80200040, 0x00000800, 0x80000800, 0x80200840,
3100x00000000, 0x00200040, 0x80200000, 0x00000840,
3110x80200800, 0x80000840, 0x00200840, 0x80000000,
3120x80000840, 0x80200800, 0x00000040, 0x00200000,
3130x80000840, 0x00200800, 0x80200800, 0x80000040,
3140x00000800, 0x00000040, 0x00200000, 0x80200800,
3150x80200040, 0x80000840, 0x00000840, 0x00000000,
3160x00000040, 0x80200000, 0x80000000, 0x00200040,
3170x00000000, 0x80200040, 0x00200040, 0x00000840,
3180x80000040, 0x00000800, 0x80200840, 0x00200000,
3190x00200840, 0x80000000, 0x80000800, 0x80200840,
3200x80200000, 0x00200840, 0x00200800, 0x80000800,
321);
322@SP7=(
3230x04100010, 0x04104000, 0x00004010, 0x00000000,
3240x04004000, 0x00100010, 0x04100000, 0x04104010,
3250x00000010, 0x04000000, 0x00104000, 0x00004010,
3260x00104010, 0x04004010, 0x04000010, 0x04100000,
3270x00004000, 0x00104010, 0x00100010, 0x04004000,
3280x04104010, 0x04000010, 0x00000000, 0x00104000,
3290x04000000, 0x00100000, 0x04004010, 0x04100010,
3300x00100000, 0x00004000, 0x04104000, 0x00000010,
3310x00100000, 0x00004000, 0x04000010, 0x04104010,
3320x00004010, 0x04000000, 0x00000000, 0x00104000,
3330x04100010, 0x04004010, 0x04004000, 0x00100010,
3340x04104000, 0x00000010, 0x00100010, 0x04004000,
3350x04104010, 0x00100000, 0x04100000, 0x04000010,
3360x00104000, 0x00004010, 0x04004010, 0x04100000,
3370x00000010, 0x04104000, 0x00104010, 0x00000000,
3380x04000000, 0x04100010, 0x00004000, 0x00104010,
339);
340
341sub main'des_set_key
342 {
343 local($param)=@_;
344 local(@key);
345 local($c,$d,$i,$s,$t);
346 local(@ks)=();
347
348 # Get the bytes in the order we want.
349 @key=unpack("C8",$param);
350
351 $c= ($key[0] )|
352 ($key[1]<< 8)|
353 ($key[2]<<16)|
354 ($key[3]<<24);
355 $d= ($key[4] )|
356 ($key[5]<< 8)|
357 ($key[6]<<16)|
358 ($key[7]<<24);
359
360 &doPC1(*c,*d);
361
362 for $i (@shifts2)
363 {
364 if ($i)
365 {
366 $c=($c>>2)|($c<<26);
367 $d=($d>>2)|($d<<26);
368 }
369 else
370 {
371 $c=($c>>1)|($c<<27);
372 $d=($d>>1)|($d<<27);
373 }
374 $c&=0x0fffffff;
375 $d&=0x0fffffff;
376 $s= $skb0[ ($c )&0x3f ]|
377 $skb1[(($c>> 6)&0x03)|(($c>> 7)&0x3c)]|
378 $skb2[(($c>>13)&0x0f)|(($c>>14)&0x30)]|
379 $skb3[(($c>>20)&0x01)|(($c>>21)&0x06) |
380 (($c>>22)&0x38)];
381 $t= $skb4[ ($d )&0x3f ]|
382 $skb5[(($d>> 7)&0x03)|(($d>> 8)&0x3c)]|
383 $skb6[ ($d>>15)&0x3f ]|
384 $skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)];
385 push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff);
386 $s= (($s>>16)&0x0000ffff)|($t&0xffff0000) ;
387 push(@ks,(($s<<4)|(($s>>28)&0xf))&0xffffffff);
388 }
389 @ks;
390 }
391
392sub doPC1
393 {
394 local(*a,*b)=@_;
395 local($t);
396
397 $t=(($b>>4)^$a)&0x0f0f0f0f;
398 $b^=($t<<4); $a^=$t;
399 # do $a first
400 $t=(($a<<18)^$a)&0xcccc0000;
401 $a=$a^$t^(($t>>18)&0x00003fff);
402 $t=(($a<<17)^$a)&0xaaaa0000;
403 $a=$a^$t^(($t>>17)&0x00007fff);
404 $t=(($a<< 8)^$a)&0x00ff0000;
405 $a=$a^$t^(($t>> 8)&0x00ffffff);
406 $t=(($a<<17)^$a)&0xaaaa0000;
407 $a=$a^$t^(($t>>17)&0x00007fff);
408
409 # now do $b
410 $t=(($b<<24)^$b)&0xff000000;
411 $b=$b^$t^(($t>>24)&0x000000ff);
412 $t=(($b<< 8)^$b)&0x00ff0000;
413 $b=$b^$t^(($t>> 8)&0x00ffffff);
414 $t=(($b<<14)^$b)&0x33330000;
415 $b=$b^$t^(($t>>14)&0x0003ffff);
416 $b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55);
417 $b=(($b>>8)&0x00ffffff)|((($a&0xf0000000)>>4)&0x0fffffff);
418 $a&=0x0fffffff;
419 }
420
421sub doIP
422 {
423 local(*a,*b)=@_;
424 local($t);
425
426 $t=(($b>> 4)^$a)&0x0f0f0f0f;
427 $b^=($t<< 4); $a^=$t;
428 $t=(($a>>16)^$b)&0x0000ffff;
429 $a^=($t<<16); $b^=$t;
430 $t=(($b>> 2)^$a)&0x33333333;
431 $b^=($t<< 2); $a^=$t;
432 $t=(($a>> 8)^$b)&0x00ff00ff;
433 $a^=($t<< 8); $b^=$t;
434 $t=(($b>> 1)^$a)&0x55555555;
435 $b^=($t<< 1); $a^=$t;
436 $t=$a;
437 $a=$b&0xffffffff;
438 $b=$t&0xffffffff;
439 }
440
441sub doFP
442 {
443 local(*a,*b)=@_;
444 local($t);
445
446 $t=(($b>> 1)^$a)&0x55555555;
447 $b^=($t<< 1); $a^=$t;
448 $t=(($a>> 8)^$b)&0x00ff00ff;
449 $a^=($t<< 8); $b^=$t;
450 $t=(($b>> 2)^$a)&0x33333333;
451 $b^=($t<< 2); $a^=$t;
452 $t=(($a>>16)^$b)&0x0000ffff;
453 $a^=($t<<16); $b^=$t;
454 $t=(($b>> 4)^$a)&0x0f0f0f0f;
455 $b^=($t<< 4); $a^=$t;
456 $a&=0xffffffff;
457 $b&=0xffffffff;
458 }
459
460sub main'des_ecb_encrypt
461 {
462 local(*ks,$encrypt,$in)=@_;
463 local($l,$r,$i,$t,$u,@input);
464
465 @input=unpack("C8",$in);
466 # Get the bytes in the order we want.
467 $l= ($input[0] )|
468 ($input[1]<< 8)|
469 ($input[2]<<16)|
470 ($input[3]<<24);
471 $r= ($input[4] )|
472 ($input[5]<< 8)|
473 ($input[6]<<16)|
474 ($input[7]<<24);
475
476 $l&=0xffffffff;
477 $r&=0xffffffff;
478 &doIP(*l,*r);
479 if ($encrypt)
480 {
481 for ($i=0; $i<32; $i+=4)
482 {
483 $t=((($r&0x7fffffff)<<1)|(($r>>31)&0x00000001));
484 $u=$t^$ks[$i ];
485 $t=$t^$ks[$i+1];
486 $t2=(($t&0x0000000f)<<28);
487
488 $t=((($t>>4)&0x0fffffff)|(($t&0x0000000f)<<28));
489 $l^= $SP1[ $t &0x3f]|
490 $SP3[($t>> 8)&0x3f]|
491 $SP5[($t>>16)&0x3f]|
492 $SP7[($t>>24)&0x3f]|
493 $SP0[ $u &0x3f]|
494 $SP2[($u>> 8)&0x3f]|
495 $SP4[($u>>16)&0x3f]|
496 $SP6[($u>>24)&0x3f];
497
498 $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
499 $u=$t^$ks[$i+2];
500 $t=$t^$ks[$i+3];
501 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
502 $r^= $SP1[ $t &0x3f]|
503 $SP3[($t>> 8)&0x3f]|
504 $SP5[($t>>16)&0x3f]|
505 $SP7[($t>>24)&0x3f]|
506 $SP0[ $u &0x3f]|
507 $SP2[($u>> 8)&0x3f]|
508 $SP4[($u>>16)&0x3f]|
509 $SP6[($u>>24)&0x3f];
510 }
511 }
512 else
513 {
514 for ($i=30; $i>0; $i-=4)
515 {
516 $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff;
517 $u=$t^$ks[$i ];
518 $t=$t^$ks[$i+1];
519 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
520 $l^= $SP1[ $t &0x3f]|
521 $SP3[($t>> 8)&0x3f]|
522 $SP5[($t>>16)&0x3f]|
523 $SP7[($t>>24)&0x3f]|
524 $SP0[ $u &0x3f]|
525 $SP2[($u>> 8)&0x3f]|
526 $SP4[($u>>16)&0x3f]|
527 $SP6[($u>>24)&0x3f];
528
529 $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
530 $u=$t^$ks[$i-2];
531 $t=$t^$ks[$i-1];
532 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
533 $r^= $SP1[ $t &0x3f]|
534 $SP3[($t>> 8)&0x3f]|
535 $SP5[($t>>16)&0x3f]|
536 $SP7[($t>>24)&0x3f]|
537 $SP0[ $u &0x3f]|
538 $SP2[($u>> 8)&0x3f]|
539 $SP4[($u>>16)&0x3f]|
540 $SP6[($u>>24)&0x3f];
541 }
542 }
543 &doFP(*l,*r);
544 pack("C8",$l&0xff,
545 ($l>> 8)&0x00ffffff,
546 ($l>>16)&0x0000ffff,
547 ($l>>24)&0x000000ff,
548 $r&0xff,
549 ($r>> 8)&0x00ffffff,
550 ($r>>16)&0x0000ffff,
551 ($r>>24)&0x000000ff);
552 }
diff --git a/src/lib/libcrypto/des/des.pod b/src/lib/libcrypto/des/des.pod
new file mode 100644
index 0000000000..bf479e83d2
--- /dev/null
+++ b/src/lib/libcrypto/des/des.pod
@@ -0,0 +1,217 @@
1=pod
2
3=head1 NAME
4
5des - encrypt or decrypt data using Data Encryption Standard
6
7=head1 SYNOPSIS
8
9B<des>
10(
11B<-e>
12|
13B<-E>
14) | (
15B<-d>
16|
17B<-D>
18) | (
19B<->[B<cC>][B<ckname>]
20) |
21[
22B<-b3hfs>
23] [
24B<-k>
25I<key>
26]
27] [
28B<-u>[I<uuname>]
29[
30I<input-file>
31[
32I<output-file>
33] ]
34
35=head1 NOTE
36
37This page describes the B<des> stand-alone program, not the B<openssl des>
38command.
39
40=head1 DESCRIPTION
41
42B<des>
43encrypts and decrypts data using the
44Data Encryption Standard algorithm.
45One of
46B<-e>, B<-E>
47(for encrypt) or
48B<-d>, B<-D>
49(for decrypt) must be specified.
50It is also possible to use
51B<-c>
52or
53B<-C>
54in conjunction or instead of the a encrypt/decrypt option to generate
55a 16 character hexadecimal checksum, generated via the
56I<des_cbc_cksum>.
57
58Two standard encryption modes are supported by the
59B<des>
60program, Cipher Block Chaining (the default) and Electronic Code Book
61(specified with
62B<-b>).
63
64The key used for the DES
65algorithm is obtained by prompting the user unless the
66B<-k>
67I<key>
68option is given.
69If the key is an argument to the
70B<des>
71command, it is potentially visible to users executing
72ps(1)
73or a derivative. To minimise this possibility,
74B<des>
75takes care to destroy the key argument immediately upon entry.
76If your shell keeps a history file be careful to make sure it is not
77world readable.
78
79Since this program attempts to maintain compatibility with sunOS's
80des(1) command, there are 2 different methods used to convert the user
81supplied key to a des key.
82Whenever and one or more of
83B<-E>, B<-D>, B<-C>
84or
85B<-3>
86options are used, the key conversion procedure will not be compatible
87with the sunOS des(1) version but will use all the user supplied
88character to generate the des key.
89B<des>
90command reads from standard input unless
91I<input-file>
92is specified and writes to standard output unless
93I<output-file>
94is given.
95
96=head1 OPTIONS
97
98=over 4
99
100=item B<-b>
101
102Select ECB
103(eight bytes at a time) encryption mode.
104
105=item B<-3>
106
107Encrypt using triple encryption.
108By default triple cbc encryption is used but if the
109B<-b>
110option is used then triple ECB encryption is performed.
111If the key is less than 8 characters long, the flag has no effect.
112
113=item B<-e>
114
115Encrypt data using an 8 byte key in a manner compatible with sunOS
116des(1).
117
118=item B<-E>
119
120Encrypt data using a key of nearly unlimited length (1024 bytes).
121This will product a more secure encryption.
122
123=item B<-d>
124
125Decrypt data that was encrypted with the B<-e> option.
126
127=item B<-D>
128
129Decrypt data that was encrypted with the B<-E> option.
130
131=item B<-c>
132
133Generate a 16 character hexadecimal cbc checksum and output this to
134stderr.
135If a filename was specified after the
136B<-c>
137option, the checksum is output to that file.
138The checksum is generated using a key generated in a sunOS compatible
139manner.
140
141=item B<-C>
142
143A cbc checksum is generated in the same manner as described for the
144B<-c>
145option but the DES key is generated in the same manner as used for the
146B<-E>
147and
148B<-D>
149options
150
151=item B<-f>
152
153Does nothing - allowed for compatibility with sunOS des(1) command.
154
155=item B<-s>
156
157Does nothing - allowed for compatibility with sunOS des(1) command.
158
159=item B<-k> I<key>
160
161Use the encryption
162I<key>
163specified.
164
165=item B<-h>
166
167The
168I<key>
169is assumed to be a 16 character hexadecimal number.
170If the
171B<-3>
172option is used the key is assumed to be a 32 character hexadecimal
173number.
174
175=item B<-u>
176
177This flag is used to read and write uuencoded files. If decrypting,
178the input file is assumed to contain uuencoded, DES encrypted data.
179If encrypting, the characters following the B<-u> are used as the name of
180the uuencoded file to embed in the begin line of the uuencoded
181output. If there is no name specified after the B<-u>, the name text.des
182will be embedded in the header.
183
184=head1 SEE ALSO
185
186ps(1),
187L<des_crypt(3)|des_crypt(3)>
188
189=head1 BUGS
190
191The problem with using the
192B<-e>
193option is the short key length.
194It would be better to use a real 56-bit key rather than an
195ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
196radically reduces the time necessary for a brute-force cryptographic attack.
197My attempt to remove this problem is to add an alternative text-key to
198DES-key function. This alternative function (accessed via
199B<-E>, B<-D>, B<-S>
200and
201B<-3>)
202uses DES to help generate the key.
203
204Be carefully when using the B<-u> option. Doing B<des -ud> I<filename> will
205not decrypt filename (the B<-u> option will gobble the B<-d> option).
206
207The VMS operating system operates in a world where files are always a
208multiple of 512 bytes. This causes problems when encrypted data is
209send from Unix to VMS since a 88 byte file will suddenly be padded
210with 424 null bytes. To get around this problem, use the B<-u> option
211to uuencode the data before it is send to the VMS system.
212
213=head1 AUTHOR
214
215Eric Young (eay@cryptsoft.com)
216
217=cut
diff --git a/src/lib/libcrypto/des/des_crypt.man b/src/lib/libcrypto/des/des_crypt.man
index 0ecc416877..e69de29bb2 100644
--- a/src/lib/libcrypto/des/des_crypt.man
+++ b/src/lib/libcrypto/des/des_crypt.man
@@ -1,508 +0,0 @@
1.TH DES_CRYPT 3
2.SH NAME
3des_read_password, des_read_2password,
4des_string_to_key, des_string_to_2key, des_read_pw_string,
5des_random_key, des_set_key,
6des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt,
7des_3cbc_encrypt,
8des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt,
9des_cbc_cksum, des_quad_cksum,
10des_enc_read, des_enc_write, des_set_odd_parity,
11des_is_weak_key, crypt \- (non USA) DES encryption
12.SH SYNOPSIS
13.nf
14.nj
15.ft B
16#include <des.h>
17.PP
18.B int des_read_password(key,prompt,verify)
19des_cblock *key;
20char *prompt;
21int verify;
22.PP
23.B int des_read_2password(key1,key2,prompt,verify)
24des_cblock *key1,*key2;
25char *prompt;
26int verify;
27.PP
28.B int des_string_to_key(str,key)
29char *str;
30des_cblock *key;
31.PP
32.B int des_string_to_2keys(str,key1,key2)
33char *str;
34des_cblock *key1,*key2;
35.PP
36.B int des_read_pw_string(buf,length,prompt,verify)
37char *buf;
38int length;
39char *prompt;
40int verify;
41.PP
42.B int des_random_key(key)
43des_cblock *key;
44.PP
45.B int des_set_key(key,schedule)
46des_cblock *key;
47des_key_schedule schedule;
48.PP
49.B int des_key_sched(key,schedule)
50des_cblock *key;
51des_key_schedule schedule;
52.PP
53.B int des_ecb_encrypt(input,output,schedule,encrypt)
54des_cblock *input;
55des_cblock *output;
56des_key_schedule schedule;
57int encrypt;
58.PP
59.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt)
60des_cblock *input;
61des_cblock *output;
62des_key_schedule ks1,ks2;
63int encrypt;
64.PP
65.B int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
66des_cblock *input;
67des_cblock *output;
68long length;
69des_key_schedule schedule;
70des_cblock *ivec;
71int encrypt;
72.PP
73.B int des_3cbc_encrypt(input,output,length,sk1,sk2,ivec1,ivec2,encrypt)
74des_cblock *input;
75des_cblock *output;
76long length;
77des_key_schedule sk1;
78des_key_schedule sk2;
79des_cblock *ivec1;
80des_cblock *ivec2;
81int encrypt;
82.PP
83.B int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)
84des_cblock *input;
85des_cblock *output;
86long length;
87des_key_schedule schedule;
88des_cblock *ivec;
89int encrypt;
90.PP
91.B int des_cfb_encrypt(input,output,numbits,length,schedule,ivec,encrypt)
92unsigned char *input;
93unsigned char *output;
94int numbits;
95long length;
96des_key_schedule schedule;
97des_cblock *ivec;
98int encrypt;
99.PP
100.B int des_ofb_encrypt(input,output,numbits,length,schedule,ivec)
101unsigned char *input,*output;
102int numbits;
103long length;
104des_key_schedule schedule;
105des_cblock *ivec;
106.PP
107.B unsigned long des_cbc_cksum(input,output,length,schedule,ivec)
108des_cblock *input;
109des_cblock *output;
110long length;
111des_key_schedule schedule;
112des_cblock *ivec;
113.PP
114.B unsigned long des_quad_cksum(input,output,length,out_count,seed)
115des_cblock *input;
116des_cblock *output;
117long length;
118int out_count;
119des_cblock *seed;
120.PP
121.B int des_check_key;
122.PP
123.B int des_enc_read(fd,buf,len,sched,iv)
124int fd;
125char *buf;
126int len;
127des_key_schedule sched;
128des_cblock *iv;
129.PP
130.B int des_enc_write(fd,buf,len,sched,iv)
131int fd;
132char *buf;
133int len;
134des_key_schedule sched;
135des_cblock *iv;
136.PP
137.B extern int des_rw_mode;
138.PP
139.B void des_set_odd_parity(key)
140des_cblock *key;
141.PP
142.B int des_is_weak_key(key)
143des_cblock *key;
144.PP
145.B char *crypt(passwd,salt)
146char *passwd;
147char *salt;
148.PP
149.fi
150.SH DESCRIPTION
151This library contains a fast implementation of the DES encryption
152algorithm.
153.PP
154There are two phases to the use of DES encryption.
155The first is the generation of a
156.I des_key_schedule
157from a key,
158the second is the actual encryption.
159A des key is of type
160.I des_cblock.
161This type is made from 8 characters with odd parity.
162The least significant bit in the character is the parity bit.
163The key schedule is an expanded form of the key; it is used to speed the
164encryption process.
165.PP
166.I des_read_password
167writes the string specified by prompt to the standard output,
168turns off echo and reads an input string from standard input
169until terminated with a newline.
170If verify is non-zero, it prompts and reads the input again and verifies
171that both entered passwords are the same.
172The entered string is converted into a des key by using the
173.I des_string_to_key
174routine.
175The new key is placed in the
176.I des_cblock
177that was passed (by reference) to the routine.
178If there were no errors,
179.I des_read_password
180returns 0,
181-1 is returned if there was a terminal error and 1 is returned for
182any other error.
183.PP
184.I des_read_2password
185operates in the same way as
186.I des_read_password
187except that it generates 2 keys by using the
188.I des_string_to_2key
189function.
190.PP
191.I des_read_pw_string
192is called by
193.I des_read_password
194to read and verify a string from a terminal device.
195The string is returned in
196.I buf.
197The size of
198.I buf
199is passed to the routine via the
200.I length
201parameter.
202.PP
203.I des_string_to_key
204converts a string into a valid des key.
205.PP
206.I des_string_to_2key
207converts a string into 2 valid des keys.
208This routine is best suited for used to generate keys for use with
209.I des_ecb3_encrypt.
210.PP
211.I des_random_key
212returns a random key that is made of a combination of process id,
213time and an increasing counter.
214.PP
215Before a des key can be used it is converted into a
216.I des_key_schedule
217via the
218.I des_set_key
219routine.
220If the
221.I des_check_key
222flag is non-zero,
223.I des_set_key
224will check that the key passed is of odd parity and is not a week or
225semi-weak key.
226If the parity is wrong,
227then -1 is returned.
228If the key is a weak key,
229then -2 is returned.
230If an error is returned,
231the key schedule is not generated.
232.PP
233.I des_key_sched
234is another name for the
235.I des_set_key
236function.
237.PP
238The following routines mostly operate on an input and output stream of
239.I des_cblock's.
240.PP
241.I des_ecb_encrypt
242is the basic DES encryption routine that encrypts or decrypts a single 8-byte
243.I des_cblock
244in
245.I electronic code book
246mode.
247It always transforms the input data, pointed to by
248.I input,
249into the output data,
250pointed to by the
251.I output
252argument.
253If the
254.I encrypt
255argument is non-zero (DES_ENCRYPT),
256the
257.I input
258(cleartext) is encrypted in to the
259.I output
260(ciphertext) using the key_schedule specified by the
261.I schedule
262argument,
263previously set via
264.I des_set_key.
265If
266.I encrypt
267is zero (DES_DECRYPT),
268the
269.I input
270(now ciphertext)
271is decrypted into the
272.I output
273(now cleartext).
274Input and output may overlap.
275No meaningful value is returned.
276.PP
277.I des_ecb3_encrypt
278encrypts/decrypts the
279.I input
280block by using triple ecb DES encryption.
281This involves encrypting the input with
282.I ks1,
283decryption with the key schedule
284.I ks2,
285and then encryption with the first again.
286This routine greatly reduces the chances of brute force breaking of
287DES and has the advantage of if
288.I ks1
289and
290.I ks2
291are the same, it is equivalent to just encryption using ecb mode and
292.I ks1
293as the key.
294.PP
295.I des_cbc_encrypt
296encrypts/decrypts using the
297.I cipher-block-chaining
298mode of DES.
299If the
300.I encrypt
301argument is non-zero,
302the routine cipher-block-chain encrypts the cleartext data pointed to by the
303.I input
304argument into the ciphertext pointed to by the
305.I output
306argument,
307using the key schedule provided by the
308.I schedule
309argument,
310and initialisation vector provided by the
311.I ivec
312argument.
313If the
314.I length
315argument is not an integral multiple of eight bytes,
316the last block is copied to a temporary area and zero filled.
317The output is always
318an integral multiple of eight bytes.
319To make multiple cbc encrypt calls on a large amount of data appear to
320be one
321.I des_cbc_encrypt
322call, the
323.I ivec
324of subsequent calls should be the last 8 bytes of the output.
325.PP
326.I des_3cbc_encrypt
327encrypts/decrypts the
328.I input
329block by using triple cbc DES encryption.
330This involves encrypting the input with key schedule
331.I ks1,
332decryption with the key schedule
333.I ks2,
334and then encryption with the first again.
3352 initialisation vectors are required,
336.I ivec1
337and
338.I ivec2.
339Unlike
340.I des_cbc_encrypt,
341these initialisation vectors are modified by the subroutine.
342This routine greatly reduces the chances of brute force breaking of
343DES and has the advantage of if
344.I ks1
345and
346.I ks2
347are the same, it is equivalent to just encryption using cbc mode and
348.I ks1
349as the key.
350.PP
351.I des_pcbc_encrypt
352encrypt/decrypts using a modified block chaining mode.
353It provides better error propagation characteristics than cbc
354encryption.
355.PP
356.I des_cfb_encrypt
357encrypt/decrypts using cipher feedback mode. This method takes an
358array of characters as input and outputs and array of characters. It
359does not require any padding to 8 character groups. Note: the ivec
360variable is changed and the new changed value needs to be passed to
361the next call to this function. Since this function runs a complete
362DES ecb encryption per numbits, this function is only suggested for
363use when sending small numbers of characters.
364.PP
365.I des_ofb_encrypt
366encrypt using output feedback mode. This method takes an
367array of characters as input and outputs and array of characters. It
368does not require any padding to 8 character groups. Note: the ivec
369variable is changed and the new changed value needs to be passed to
370the next call to this function. Since this function runs a complete
371DES ecb encryption per numbits, this function is only suggested for
372use when sending small numbers of characters.
373.PP
374.I des_cbc_cksum
375produces an 8 byte checksum based on the input stream (via cbc encryption).
376The last 4 bytes of the checksum is returned and the complete 8 bytes is
377placed in
378.I output.
379.PP
380.I des_quad_cksum
381returns a 4 byte checksum from the input bytes.
382The algorithm can be iterated over the input,
383depending on
384.I out_count,
3851, 2, 3 or 4 times.
386If
387.I output
388is non-NULL,
389the 8 bytes generated by each pass are written into
390.I output.
391.PP
392.I des_enc_write
393is used to write
394.I len
395bytes
396to file descriptor
397.I fd
398from buffer
399.I buf.
400The data is encrypted via
401.I pcbc_encrypt
402(default) using
403.I sched
404for the key and
405.I iv
406as a starting vector.
407The actual data send down
408.I fd
409consists of 4 bytes (in network byte order) containing the length of the
410following encrypted data. The encrypted data then follows, padded with random
411data out to a multiple of 8 bytes.
412.PP
413.I des_enc_read
414is used to read
415.I len
416bytes
417from file descriptor
418.I fd
419into buffer
420.I buf.
421The data being read from
422.I fd
423is assumed to have come from
424.I des_enc_write
425and is decrypted using
426.I sched
427for the key schedule and
428.I iv
429for the initial vector.
430The
431.I des_enc_read/des_enc_write
432pair can be used to read/write to files, pipes and sockets.
433I have used them in implementing a version of rlogin in which all
434data is encrypted.
435.PP
436.I des_rw_mode
437is used to specify the encryption mode to use with
438.I des_enc_read
439and
440.I des_end_write.
441If set to
442.I DES_PCBC_MODE
443(the default), des_pcbc_encrypt is used.
444If set to
445.I DES_CBC_MODE
446des_cbc_encrypt is used.
447These two routines and the variable are not part of the normal MIT library.
448.PP
449.I des_set_odd_parity
450sets the parity of the passed
451.I key
452to odd. This routine is not part of the standard MIT library.
453.PP
454.I des_is_weak_key
455returns 1 is the passed key is a weak key (pick again :-),
4560 if it is ok.
457This routine is not part of the standard MIT library.
458.PP
459.I crypt
460is a replacement for the normal system crypt.
461It is much faster than the system crypt.
462.PP
463.SH FILES
464/usr/include/des.h
465.br
466/usr/lib/libdes.a
467.PP
468The encryption routines have been tested on 16bit, 32bit and 64bit
469machines of various endian and even works under VMS.
470.PP
471.SH BUGS
472.PP
473If you think this manual is sparse,
474read the des_crypt(3) manual from the MIT kerberos (or bones outside
475of the USA) distribution.
476.PP
477.I des_cfb_encrypt
478and
479.I des_ofb_encrypt
480operates on input of 8 bits. What this means is that if you set
481numbits to 12, and length to 2, the first 12 bits will come from the 1st
482input byte and the low half of the second input byte. The second 12
483bits will have the low 8 bits taken from the 3rd input byte and the
484top 4 bits taken from the 4th input byte. The same holds for output.
485This function has been implemented this way because most people will
486be using a multiple of 8 and because once you get into pulling bytes input
487bytes apart things get ugly!
488.PP
489.I des_read_pw_string
490is the most machine/OS dependent function and normally generates the
491most problems when porting this code.
492.PP
493.I des_string_to_key
494is probably different from the MIT version since there are lots
495of fun ways to implement one-way encryption of a text string.
496.PP
497The routines are optimised for 32 bit machines and so are not efficient
498on IBM PCs.
499.PP
500NOTE: extensive work has been done on this library since this document
501was origionally written. Please try to read des.doc from the libdes
502distribution since it is far more upto date and documents more of the
503functions. Libdes is now also being shipped as part of SSLeay, a
504general cryptographic library that amonst other things implements
505netscapes SSL protocoll. The most recent version can be found in
506SSLeay distributions.
507.SH AUTHOR
508Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
index 4dfed199a7..1ace8f5930 100644
--- a/src/lib/libcrypto/des/des_locl.h
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -155,7 +155,7 @@
155 } \ 155 } \
156 } 156 }
157 157
158#if defined(WIN32) 158#if defined(WIN32) && defined(_MSC_VER)
159#define ROTATE(a,n) (_lrotr(a,n)) 159#define ROTATE(a,n) (_lrotr(a,n))
160#else 160#else
161#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) 161#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
index 9ad4ecb072..df0d615d6b 100644
--- a/src/lib/libcrypto/des/destest.c
+++ b/src/lib/libcrypto/des/destest.c
@@ -336,8 +336,15 @@ int main(int argc, char *argv[])
336 unsigned char cbc_in[40]; 336 unsigned char cbc_in[40];
337 unsigned char cbc_out[40]; 337 unsigned char cbc_out[40];
338 DES_LONG cs; 338 DES_LONG cs;
339 unsigned char qret[4][4],cret[8]; 339 unsigned char cret[8];
340 DES_LONG lqret[4]; 340#ifdef _CRAY
341 struct {
342 int a:32;
343 int b:32;
344 } lqret[2];
345#else
346 DES_LONG lqret[4];
347#endif
341 int num; 348 int num;
342 char *str; 349 char *str;
343 350
@@ -701,43 +708,40 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
701 } 708 }
702 709
703 printf("Doing quad_cksum\n"); 710 printf("Doing quad_cksum\n");
704 /* This is obviously done this way especially to puzzle me. Although 711 cs=quad_cksum(cbc_data,(des_cblock *)lqret,
705 quad_cksum returns up to 4 groups of 8 bytes, this test gets it to 712 (long)strlen((char *)cbc_data),2,(des_cblock *)cbc_iv);
706 produce 2 groups then treats them as 4 groups of 4 bytes. 713 if (cs != 0x70d7a63aL)
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
716 j=sizeof(lqret[0])-4;
717 for (i=0; i<4; i++)
718 { 714 {
719 lqret[i]=0; 715 printf("quad_cksum error, ret %08lx should be 70d7a63a\n",
720 memcpy(&(lqret[i]),&(qret[i][0]),4); 716 (unsigned long)cs);
721 if (!c[0] && (j > 0)) 717 err=1;
722 lqret[i]=lqret[i]>>(j*8); /* For Cray */
723 } 718 }
724 719#ifdef _CRAY
725 if (!c[0]) 720 if (lqret[0].a != 0x327eba8dL)
726 { 721 {
727 ll=lqret[0]^lqret[3]; 722 printf("quad_cksum error, out[0] %08lx is not %08lx\n",
728 lqret[0]^=ll; 723 (unsigned long)lqret[0].a,0x327eba8dUL);
729 lqret[3]^=ll; 724 err=1;
730 ll=lqret[1]^lqret[2];
731 lqret[1]^=ll;
732 lqret[2]^=ll;
733 } 725 }
734 } 726 if (lqret[0].b != 0x201a49ccL)
735 if (cs != 0x70d7a63aL)
736 { 727 {
737 printf("quad_cksum error, ret %08lx should be 70d7a63a\n", 728 printf("quad_cksum error, out[1] %08lx is not %08lx\n",
738 (unsigned long)cs); 729 (unsigned long)lqret[0].b,0x201a49ccUL);
730 err=1;
731 }
732 if (lqret[1].a != 0x70d7a63aL)
733 {
734 printf("quad_cksum error, out[2] %08lx is not %08lx\n",
735 (unsigned long)lqret[1].a,0x70d7a63aUL);
739 err=1; 736 err=1;
740 } 737 }
738 if (lqret[1].b != 0x501c2c26L)
739 {
740 printf("quad_cksum error, out[3] %08lx is not %08lx\n",
741 (unsigned long)lqret[1].b,0x501c2c26UL);
742 err=1;
743 }
744#else
741 if (lqret[0] != 0x327eba8dL) 745 if (lqret[0] != 0x327eba8dL)
742 { 746 {
743 printf("quad_cksum error, out[0] %08lx is not %08lx\n", 747 printf("quad_cksum error, out[0] %08lx is not %08lx\n",
@@ -763,6 +767,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
763 err=1; 767 err=1;
764 } 768 }
765#endif 769#endif
770#endif
766 771
767 printf("input word alignment test"); 772 printf("input word alignment test");
768 for (i=0; i<4; i++) 773 for (i=0; i<4; i++)
diff --git a/src/lib/libcrypto/des/doIP b/src/lib/libcrypto/des/doIP
index 18cf231303..e69de29bb2 100644
--- a/src/lib/libcrypto/des/doIP
+++ b/src/lib/libcrypto/des/doIP
@@ -1,46 +0,0 @@
1#!/usr/local/bin/perl
2
3@l=(
4 0, 1, 2, 3, 4, 5, 6, 7,
5 8, 9,10,11,12,13,14,15,
6 16,17,18,19,20,21,22,23,
7 24,25,26,27,28,29,30,31
8 );
9@r=(
10 32,33,34,35,36,37,38,39,
11 40,41,42,43,44,45,46,47,
12 48,49,50,51,52,53,54,55,
13 56,57,58,59,60,61,62,63
14 );
15
16require 'shifts.pl';
17
18sub PERM_OP
19 {
20 local(*a,*b,*t,$n,$m)=@_;
21
22 @z=&shift(*a,-$n);
23 @z=&xor(*b,*z);
24 @z=&and(*z,$m);
25 @b=&xor(*b,*z);
26 @z=&shift(*z,$n);
27 @a=&xor(*a,*z);
28 }
29
30
31@L=@l;
32@R=@r;
33&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
34&PERM_OP(*L,*R,*T,16,0x0000ffff);
35&PERM_OP(*R,*L,*T,2,0x33333333);
36&PERM_OP(*L,*R,*T,8,0x00ff00ff);
37&PERM_OP(*R,*L,*T,1,0x55555555);
38 &printit(@L);
39 &printit(@R);
40&PERM_OP(*R,*L,*T,1,0x55555555);
41&PERM_OP(*L,*R,*T,8,0x00ff00ff);
42&PERM_OP(*R,*L,*T,2,0x33333333);
43&PERM_OP(*L,*R,*T,16,0x0000ffff);
44&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
45 &printit(@L);
46 &printit(@R);
diff --git a/src/lib/libcrypto/des/doPC1 b/src/lib/libcrypto/des/doPC1
index 096afd8c46..e69de29bb2 100644
--- a/src/lib/libcrypto/des/doPC1
+++ b/src/lib/libcrypto/des/doPC1
@@ -1,110 +0,0 @@
1#!/usr/local/bin/perl
2
3@l=(
4 0, 1, 2, 3, 4, 5, 6, 7,
5 8, 9,10,11,12,13,14,15,
6 16,17,18,19,20,21,22,23,
7 24,25,26,27,28,29,30,31
8 );
9@r=(
10 32,33,34,35,36,37,38,39,
11 40,41,42,43,44,45,46,47,
12 48,49,50,51,52,53,54,55,
13 56,57,58,59,60,61,62,63
14 );
15
16require 'shifts.pl';
17
18sub PERM_OP
19 {
20 local(*a,*b,*t,$n,$m)=@_;
21
22 @z=&shift(*a,-$n);
23 @z=&xor(*b,*z);
24 @z=&and(*z,$m);
25 @b=&xor(*b,*z);
26 @z=&shift(*z,$n);
27 @a=&xor(*a,*z);
28 }
29
30sub HPERM_OP2
31 {
32 local(*a,*t,$n,$m)=@_;
33 local(@x,@y,$i);
34
35 @z=&shift(*a,16-$n);
36 @z=&xor(*a,*z);
37 @z=&and(*z,$m);
38 @a=&xor(*a,*z);
39 @z=&shift(*z,$n-16);
40 @a=&xor(*a,*z);
41 }
42
43sub HPERM_OP
44 {
45 local(*a,*t,$n,$m)=@_;
46 local(@x,@y,$i);
47
48 for ($i=0; $i<16; $i++)
49 {
50 $x[$i]=$a[$i];
51 $y[$i]=$a[16+$i];
52 }
53 @z=&shift(*x,-$n);
54 @z=&xor(*y,*z);
55 @z=&and(*z,$m);
56 @y=&xor(*y,*z);
57 @z=&shift(*z,$n);
58 @x=&xor(*x,*z);
59 for ($i=0; $i<16; $i++)
60 {
61 $a[$i]=$x[$i];
62 $a[16+$i]=$y[$i];
63 }
64 }
65
66@L=@l;
67@R=@r;
68
69 print "---\n"; &printit(@R);
70&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
71 print "---\n"; &printit(@R);
72&HPERM_OP2(*L,*T,-2,0xcccc0000);
73&HPERM_OP2(*R,*T,-2,0xcccc0000);
74 print "---\n"; &printit(@R);
75&PERM_OP(*R,*L,*T,1,0x55555555);
76 print "---\n"; &printit(@R);
77&PERM_OP(*L,*R,*T,8,0x00ff00ff);
78 print "---\n"; &printit(@R);
79&PERM_OP(*R,*L,*T,1,0x55555555);
80 print "---\n"; &printit(@R);
81# &printit(@L);
82 &printit(@R);
83print <<"EOF";
84==============================
8563 55 47 39 31 23 15 7
8662 54 46 38 30 22 14 6
8761 53 45 37 29 21 13 5
8860 52 44 36 -- -- -- --
89
9057 49 41 33 25 17 9 1
9158 50 42 34 26 18 10 2
9259 51 43 35 27 19 11 3
9328 20 12 4 -- -- -- --
94EOF
95exit(1);
96@A=&and(*R,0x000000ff);
97@A=&shift(*A,16);
98@B=&and(*R,0x0000ff00);
99@C=&and(*R,0x00ff0000);
100@C=&shift(*C,-16);
101@D=&and(*L,0xf0000000);
102@D=&shift(*D,-4);
103@A=&or(*A,*B);
104@B=&or(*D,*C);
105@R=&or(*A,*B);
106@L=&and(*L,0x0fffffff);
107
108 &printit(@L);
109 &printit(@R);
110
diff --git a/src/lib/libcrypto/des/doPC2 b/src/lib/libcrypto/des/doPC2
index fa5cf74cf7..e69de29bb2 100644
--- a/src/lib/libcrypto/des/doPC2
+++ b/src/lib/libcrypto/des/doPC2
@@ -1,94 +0,0 @@
1#!/usr/local/bin/perl
2
3@PC2_C=(14,17,11,24, 1, 5,
4 3,28,15, 6,21,10,
5 23,19,12, 4,26, 8,
6 16, 7,27,20,13, 2,
7 );
8
9@PC2_D=(41,52,31,37,47,55,
10 30,40,51,45,33,48,
11 44,49,39,56,34,53,
12 46,42,50,36,29,32,
13 );
14
15$i=0;
16foreach (@PC2_C) {
17 $_--;
18# printf "%2d,",$_;
19 $C{$_}=$i;
20 ++$i;
21# print "\n" if ((($i) % 8) == 0);
22 }
23$i=0;
24#print "\n";
25foreach (@PC2_D) {
26 $_-=28;
27 $_--;
28# printf "%2d,",$_;
29 $D{$_}=$i;
30 $i++;
31# print "\n" if ((($i) % 8) == 0);
32 }
33
34#print "\n";
35foreach $i (0 .. 27)
36 {
37 $_=$C{$i};
38# printf "%2d,",$_;
39 $i++;
40# print "\n" if ((($i) % 8) == 0);
41 }
42#print "\n";
43
44#print "\n";
45foreach $i (0 .. 27)
46 {
47 $_=$D{$i};
48# printf "%2d,",$_;
49 $i++;
50# print "\n" if ((($i) % 8) == 0);
51 }
52#print "\n";
53
54print "static ulong skb[8][64]={\n";
55&doit("C",*C, 0, 1, 2, 3, 4, 5);
56&doit("C",*C, 6, 7, 9,10,11,12);
57&doit("C",*C,13,14,15,16,18,19);
58&doit("C",*C,20,22,23,25,26,27);
59
60&doit("D",*D, 0, 1, 2, 3, 4, 5);
61&doit("D",*D, 7, 8,10,11,12,13);
62&doit("D",*D,15,16,17,18,19,20);
63&doit("D",*D,21,22,23,24,26,27);
64print "};\n";
65
66sub doit
67 {
68 local($l,*A,@b)=@_;
69 local(@out);
70
71 printf("/* for $l bits (numbered as per FIPS 46) %d %d %d %d %d %d */\n",
72 $b[0]+1, $b[1]+1, $b[2]+1, $b[3]+1, $b[4]+1, $b[5]+1);
73 for ($i=0; $i<64; $i++)
74 {
75 $out[$i]=0;
76 $j=1;
77#print "\n";
78 for ($k=0; $k<6; $k++)
79 {
80 $l=$A{$b[$k]};
81#print"$l - ";
82 if ((1<<$k) & $i)
83 {
84 $ll=int($l/6)*8+($l%6);
85 $out[$i]|=1<<($ll);
86 }
87 }
88 $pp=$out[$i];
89 $pp=($pp&0xff0000ff)| (($pp&0x00ff0000)>>8)|
90 (($pp&0x0000ff00)<<8);
91 printf("0x%08X,",$pp);
92 print "\n" if (($i+1) % 4 == 0);
93 }
94 }
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c
index fa1b8aa34a..9b21f81cc2 100644
--- a/src/lib/libcrypto/des/fcrypt.c
+++ b/src/lib/libcrypto/des/fcrypt.c
@@ -3,7 +3,6 @@
3 3
4/* This version of crypt has been developed from my MIT compatible 4/* This version of crypt has been developed from my MIT compatible
5 * DES library. 5 * DES library.
6 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
7 * Eric Young (eay@cryptsoft.com) 6 * Eric Young (eay@cryptsoft.com)
8 */ 7 */
9 8
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
index 83c94054e3..22c87f5983 100644
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ b/src/lib/libcrypto/des/fcrypt_b.c
@@ -97,7 +97,7 @@ void fcrypt_body(DES_LONG *out, des_key_schedule ks, DES_LONG Eswap0,
97 97
98 for (j=0; j<25; j++) 98 for (j=0; j<25; j++)
99 { 99 {
100#ifdef DES_UNROLL 100#ifndef DES_UNROLL
101 register int i; 101 register int i;
102 102
103 for (i=0; i<32; i+=8) 103 for (i=0; i<32; i+=8)
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c
index e0e67a417d..3b681691a9 100644
--- a/src/lib/libcrypto/des/ncbc_enc.c
+++ b/src/lib/libcrypto/des/ncbc_enc.c
@@ -1,4 +1,9 @@
1/* crypto/des/ncbc_enc.c */ 1/* crypto/des/ncbc_enc.c */
2/*
3 * #included by:
4 * cbc_enc.c (des_cbc_encrypt)
5 * des_enc.c (des_ncbc_encrypt)
6 */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 7/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 8 * All rights reserved.
4 * 9 *
diff --git a/src/lib/libcrypto/des/podd.h b/src/lib/libcrypto/des/podd.h
index 1b2bfe0843..e69de29bb2 100644
--- a/src/lib/libcrypto/des/podd.h
+++ b/src/lib/libcrypto/des/podd.h
@@ -1,75 +0,0 @@
1/* crypto/des/podd.h */
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
59static const unsigned char odd_parity[256]={
60 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
61 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
62 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
63 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
64 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
65 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
66 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
67112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
68128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
69145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
70161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
71176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
72193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
73208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
74224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
75241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c
index 6ce8c61b42..5f0ec5387f 100644
--- a/src/lib/libcrypto/des/qud_cksm.c
+++ b/src/lib/libcrypto/des/qud_cksm.c
@@ -80,10 +80,14 @@ DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[],
80 int i; 80 int i;
81 long l; 81 long l;
82 const unsigned char *cp; 82 const unsigned char *cp;
83 unsigned char *lp; 83#ifdef _CRAY
84 short *lp;
85#else
86 DES_LONG *lp;
87#endif
84 88
85 if (out_count < 1) out_count=1; 89 if (out_count < 1) out_count=1;
86 lp = &(output[0])[0]; 90 lp = (DES_LONG *) &(output[0])[0];
87 91
88 z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); 92 z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]);
89 z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); 93 z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]);
@@ -114,25 +118,10 @@ DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[],
114 } 118 }
115 if (lp != NULL) 119 if (lp != NULL)
116 { 120 {
117 /* I believe I finally have things worked out. 121 /* The MIT library assumes that the checksum is
118 * The MIT library assumes that the checksum 122 * composed of 2*out_count 32 bit ints */
119 * is one huge number and it is returned in a 123 *lp++ = z0;
120 * host dependant byte order. 124 *lp++ = z1;
121 */
122 static DES_LONG ltmp=1;
123 static unsigned char *c=(unsigned char *)&ltmp;
124
125 if (c[0])
126 {
127 l2c(z0,lp);
128 l2c(z1,lp);
129 }
130 else
131 {
132 lp = &(output[out_count-i-1])[0];
133 l2n(z1,lp);
134 l2n(z0,lp);
135 }
136 } 125 }
137 } 126 }
138 return(z0); 127 return(z0);
diff --git a/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c
index 7816a8f25c..ee1a6c274e 100644
--- a/src/lib/libcrypto/des/rand_key.c
+++ b/src/lib/libcrypto/des/rand_key.c
@@ -63,7 +63,11 @@ void des_random_seed(des_cblock *key)
63 63
64int des_random_key(des_cblock *ret) 64int des_random_key(des_cblock *ret)
65 { 65 {
66 int r = RAND_bytes((unsigned char *)ret, sizeof(des_cblock)); 66 do
67 {
68 if (RAND_bytes((unsigned char *)ret, sizeof(des_cblock)) != 1)
69 return (0);
70 } while (des_is_weak_key(ret));
67 des_set_odd_parity(ret); 71 des_set_odd_parity(ret);
68 return r; 72 return (1);
69 } 73 }
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index bbdc71ba6b..09afd4fc03 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -64,12 +64,27 @@
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#include "podd.h"
68#include "sk.h"
69 67
70static int check_parity(const_des_cblock *key);
71OPENSSL_GLOBAL int des_check_key=0; 68OPENSSL_GLOBAL int des_check_key=0;
72 69
70static const unsigned char odd_parity[256]={
71 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
72 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
73 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
74 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
75 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
76 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
77 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
78112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
79128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
80145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
81161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
82176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
83193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
84208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
85224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
86241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
87
73void des_set_odd_parity(des_cblock *key) 88void des_set_odd_parity(des_cblock *key)
74 { 89 {
75 int i; 90 int i;
@@ -78,7 +93,7 @@ void des_set_odd_parity(des_cblock *key)
78 (*key)[i]=odd_parity[(*key)[i]]; 93 (*key)[i]=odd_parity[(*key)[i]];
79 } 94 }
80 95
81static int check_parity(const_des_cblock *key) 96int des_check_key_parity(const_des_cblock *key)
82 { 97 {
83 int i; 98 int i;
84 99
@@ -145,6 +160,153 @@ int des_is_weak_key(const_des_cblock *key)
145#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ 160#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
146 (a)=(a)^(t)^(t>>(16-(n)))) 161 (a)=(a)^(t)^(t>>(16-(n))))
147 162
163static const DES_LONG des_skb[8][64]={
164 {
165 /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
166 0x00000000L,0x00000010L,0x20000000L,0x20000010L,
167 0x00010000L,0x00010010L,0x20010000L,0x20010010L,
168 0x00000800L,0x00000810L,0x20000800L,0x20000810L,
169 0x00010800L,0x00010810L,0x20010800L,0x20010810L,
170 0x00000020L,0x00000030L,0x20000020L,0x20000030L,
171 0x00010020L,0x00010030L,0x20010020L,0x20010030L,
172 0x00000820L,0x00000830L,0x20000820L,0x20000830L,
173 0x00010820L,0x00010830L,0x20010820L,0x20010830L,
174 0x00080000L,0x00080010L,0x20080000L,0x20080010L,
175 0x00090000L,0x00090010L,0x20090000L,0x20090010L,
176 0x00080800L,0x00080810L,0x20080800L,0x20080810L,
177 0x00090800L,0x00090810L,0x20090800L,0x20090810L,
178 0x00080020L,0x00080030L,0x20080020L,0x20080030L,
179 0x00090020L,0x00090030L,0x20090020L,0x20090030L,
180 0x00080820L,0x00080830L,0x20080820L,0x20080830L,
181 0x00090820L,0x00090830L,0x20090820L,0x20090830L,
182 },{
183 /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
184 0x00000000L,0x02000000L,0x00002000L,0x02002000L,
185 0x00200000L,0x02200000L,0x00202000L,0x02202000L,
186 0x00000004L,0x02000004L,0x00002004L,0x02002004L,
187 0x00200004L,0x02200004L,0x00202004L,0x02202004L,
188 0x00000400L,0x02000400L,0x00002400L,0x02002400L,
189 0x00200400L,0x02200400L,0x00202400L,0x02202400L,
190 0x00000404L,0x02000404L,0x00002404L,0x02002404L,
191 0x00200404L,0x02200404L,0x00202404L,0x02202404L,
192 0x10000000L,0x12000000L,0x10002000L,0x12002000L,
193 0x10200000L,0x12200000L,0x10202000L,0x12202000L,
194 0x10000004L,0x12000004L,0x10002004L,0x12002004L,
195 0x10200004L,0x12200004L,0x10202004L,0x12202004L,
196 0x10000400L,0x12000400L,0x10002400L,0x12002400L,
197 0x10200400L,0x12200400L,0x10202400L,0x12202400L,
198 0x10000404L,0x12000404L,0x10002404L,0x12002404L,
199 0x10200404L,0x12200404L,0x10202404L,0x12202404L,
200 },{
201 /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
202 0x00000000L,0x00000001L,0x00040000L,0x00040001L,
203 0x01000000L,0x01000001L,0x01040000L,0x01040001L,
204 0x00000002L,0x00000003L,0x00040002L,0x00040003L,
205 0x01000002L,0x01000003L,0x01040002L,0x01040003L,
206 0x00000200L,0x00000201L,0x00040200L,0x00040201L,
207 0x01000200L,0x01000201L,0x01040200L,0x01040201L,
208 0x00000202L,0x00000203L,0x00040202L,0x00040203L,
209 0x01000202L,0x01000203L,0x01040202L,0x01040203L,
210 0x08000000L,0x08000001L,0x08040000L,0x08040001L,
211 0x09000000L,0x09000001L,0x09040000L,0x09040001L,
212 0x08000002L,0x08000003L,0x08040002L,0x08040003L,
213 0x09000002L,0x09000003L,0x09040002L,0x09040003L,
214 0x08000200L,0x08000201L,0x08040200L,0x08040201L,
215 0x09000200L,0x09000201L,0x09040200L,0x09040201L,
216 0x08000202L,0x08000203L,0x08040202L,0x08040203L,
217 0x09000202L,0x09000203L,0x09040202L,0x09040203L,
218 },{
219 /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
220 0x00000000L,0x00100000L,0x00000100L,0x00100100L,
221 0x00000008L,0x00100008L,0x00000108L,0x00100108L,
222 0x00001000L,0x00101000L,0x00001100L,0x00101100L,
223 0x00001008L,0x00101008L,0x00001108L,0x00101108L,
224 0x04000000L,0x04100000L,0x04000100L,0x04100100L,
225 0x04000008L,0x04100008L,0x04000108L,0x04100108L,
226 0x04001000L,0x04101000L,0x04001100L,0x04101100L,
227 0x04001008L,0x04101008L,0x04001108L,0x04101108L,
228 0x00020000L,0x00120000L,0x00020100L,0x00120100L,
229 0x00020008L,0x00120008L,0x00020108L,0x00120108L,
230 0x00021000L,0x00121000L,0x00021100L,0x00121100L,
231 0x00021008L,0x00121008L,0x00021108L,0x00121108L,
232 0x04020000L,0x04120000L,0x04020100L,0x04120100L,
233 0x04020008L,0x04120008L,0x04020108L,0x04120108L,
234 0x04021000L,0x04121000L,0x04021100L,0x04121100L,
235 0x04021008L,0x04121008L,0x04021108L,0x04121108L,
236 },{
237 /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
238 0x00000000L,0x10000000L,0x00010000L,0x10010000L,
239 0x00000004L,0x10000004L,0x00010004L,0x10010004L,
240 0x20000000L,0x30000000L,0x20010000L,0x30010000L,
241 0x20000004L,0x30000004L,0x20010004L,0x30010004L,
242 0x00100000L,0x10100000L,0x00110000L,0x10110000L,
243 0x00100004L,0x10100004L,0x00110004L,0x10110004L,
244 0x20100000L,0x30100000L,0x20110000L,0x30110000L,
245 0x20100004L,0x30100004L,0x20110004L,0x30110004L,
246 0x00001000L,0x10001000L,0x00011000L,0x10011000L,
247 0x00001004L,0x10001004L,0x00011004L,0x10011004L,
248 0x20001000L,0x30001000L,0x20011000L,0x30011000L,
249 0x20001004L,0x30001004L,0x20011004L,0x30011004L,
250 0x00101000L,0x10101000L,0x00111000L,0x10111000L,
251 0x00101004L,0x10101004L,0x00111004L,0x10111004L,
252 0x20101000L,0x30101000L,0x20111000L,0x30111000L,
253 0x20101004L,0x30101004L,0x20111004L,0x30111004L,
254 },{
255 /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
256 0x00000000L,0x08000000L,0x00000008L,0x08000008L,
257 0x00000400L,0x08000400L,0x00000408L,0x08000408L,
258 0x00020000L,0x08020000L,0x00020008L,0x08020008L,
259 0x00020400L,0x08020400L,0x00020408L,0x08020408L,
260 0x00000001L,0x08000001L,0x00000009L,0x08000009L,
261 0x00000401L,0x08000401L,0x00000409L,0x08000409L,
262 0x00020001L,0x08020001L,0x00020009L,0x08020009L,
263 0x00020401L,0x08020401L,0x00020409L,0x08020409L,
264 0x02000000L,0x0A000000L,0x02000008L,0x0A000008L,
265 0x02000400L,0x0A000400L,0x02000408L,0x0A000408L,
266 0x02020000L,0x0A020000L,0x02020008L,0x0A020008L,
267 0x02020400L,0x0A020400L,0x02020408L,0x0A020408L,
268 0x02000001L,0x0A000001L,0x02000009L,0x0A000009L,
269 0x02000401L,0x0A000401L,0x02000409L,0x0A000409L,
270 0x02020001L,0x0A020001L,0x02020009L,0x0A020009L,
271 0x02020401L,0x0A020401L,0x02020409L,0x0A020409L,
272 },{
273 /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
274 0x00000000L,0x00000100L,0x00080000L,0x00080100L,
275 0x01000000L,0x01000100L,0x01080000L,0x01080100L,
276 0x00000010L,0x00000110L,0x00080010L,0x00080110L,
277 0x01000010L,0x01000110L,0x01080010L,0x01080110L,
278 0x00200000L,0x00200100L,0x00280000L,0x00280100L,
279 0x01200000L,0x01200100L,0x01280000L,0x01280100L,
280 0x00200010L,0x00200110L,0x00280010L,0x00280110L,
281 0x01200010L,0x01200110L,0x01280010L,0x01280110L,
282 0x00000200L,0x00000300L,0x00080200L,0x00080300L,
283 0x01000200L,0x01000300L,0x01080200L,0x01080300L,
284 0x00000210L,0x00000310L,0x00080210L,0x00080310L,
285 0x01000210L,0x01000310L,0x01080210L,0x01080310L,
286 0x00200200L,0x00200300L,0x00280200L,0x00280300L,
287 0x01200200L,0x01200300L,0x01280200L,0x01280300L,
288 0x00200210L,0x00200310L,0x00280210L,0x00280310L,
289 0x01200210L,0x01200310L,0x01280210L,0x01280310L,
290 },{
291 /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
292 0x00000000L,0x04000000L,0x00040000L,0x04040000L,
293 0x00000002L,0x04000002L,0x00040002L,0x04040002L,
294 0x00002000L,0x04002000L,0x00042000L,0x04042000L,
295 0x00002002L,0x04002002L,0x00042002L,0x04042002L,
296 0x00000020L,0x04000020L,0x00040020L,0x04040020L,
297 0x00000022L,0x04000022L,0x00040022L,0x04040022L,
298 0x00002020L,0x04002020L,0x00042020L,0x04042020L,
299 0x00002022L,0x04002022L,0x00042022L,0x04042022L,
300 0x00000800L,0x04000800L,0x00040800L,0x04040800L,
301 0x00000802L,0x04000802L,0x00040802L,0x04040802L,
302 0x00002800L,0x04002800L,0x00042800L,0x04042800L,
303 0x00002802L,0x04002802L,0x00042802L,0x04042802L,
304 0x00000820L,0x04000820L,0x00040820L,0x04040820L,
305 0x00000822L,0x04000822L,0x00040822L,0x04040822L,
306 0x00002820L,0x04002820L,0x00042820L,0x04042820L,
307 0x00002822L,0x04002822L,0x00042822L,0x04042822L,
308 }};
309
148int des_set_key(const_des_cblock *key, des_key_schedule schedule) 310int des_set_key(const_des_cblock *key, des_key_schedule schedule)
149 { 311 {
150 if (des_check_key) 312 if (des_check_key)
@@ -164,7 +326,7 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule)
164 */ 326 */
165int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule) 327int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule)
166 { 328 {
167 if (!check_parity(key)) 329 if (!des_check_key_parity(key))
168 return(-1); 330 return(-1);
169 if (des_is_weak_key(key)) 331 if (des_is_weak_key(key))
170 return(-2); 332 return(-2);
@@ -186,20 +348,7 @@ void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule)
186 c2l(in,c); 348 c2l(in,c);
187 c2l(in,d); 349 c2l(in,d);
188 350
189 /* do PC1 in 60 simple operations */ 351 /* do PC1 in 47 simple operations :-)
190/* PERM_OP(d,c,t,4,0x0f0f0f0fL);
191 HPERM_OP(c,t,-2, 0xcccc0000L);
192 HPERM_OP(c,t,-1, 0xaaaa0000L);
193 HPERM_OP(c,t, 8, 0x00ff0000L);
194 HPERM_OP(c,t,-1, 0xaaaa0000L);
195 HPERM_OP(d,t,-8, 0xff000000L);
196 HPERM_OP(d,t, 8, 0x00ff0000L);
197 HPERM_OP(d,t, 2, 0x33330000L);
198 d=((d&0x00aa00aaL)<<7L)|((d&0x55005500L)>>7L)|(d&0xaa55aa55L);
199 d=(d>>8)|((c&0xf0000000L)>>4);
200 c&=0x0fffffffL; */
201
202 /* I now do it in 47 simple operations :-)
203 * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) 352 * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov)
204 * for the inspiration. :-) */ 353 * for the inspiration. :-) */
205 PERM_OP (d,c,t,4,0x0f0f0f0fL); 354 PERM_OP (d,c,t,4,0x0f0f0f0fL);
@@ -223,9 +372,9 @@ void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule)
223 /* could be a few less shifts but I am to lazy at this 372 /* could be a few less shifts but I am to lazy at this
224 * point in time to investigate */ 373 * point in time to investigate */
225 s= des_skb[0][ (c )&0x3f ]| 374 s= des_skb[0][ (c )&0x3f ]|
226 des_skb[1][((c>> 6)&0x03)|((c>> 7L)&0x3c)]| 375 des_skb[1][((c>> 6L)&0x03)|((c>> 7L)&0x3c)]|
227 des_skb[2][((c>>13)&0x0f)|((c>>14L)&0x30)]| 376 des_skb[2][((c>>13L)&0x0f)|((c>>14L)&0x30)]|
228 des_skb[3][((c>>20)&0x01)|((c>>21L)&0x06) | 377 des_skb[3][((c>>20L)&0x01)|((c>>21L)&0x06) |
229 ((c>>22L)&0x38)]; 378 ((c>>22L)&0x38)];
230 t= des_skb[4][ (d )&0x3f ]| 379 t= des_skb[4][ (d )&0x3f ]|
231 des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]| 380 des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]|
@@ -245,3 +394,9 @@ int des_key_sched(const_des_cblock *key, des_key_schedule schedule)
245 { 394 {
246 return(des_set_key(key,schedule)); 395 return(des_set_key(key,schedule));
247 } 396 }
397
398#undef des_fixup_key_parity
399void des_fixup_key_parity(des_cblock *key)
400 {
401 des_set_odd_parity(key);
402 }
diff --git a/src/lib/libcrypto/des/shifts.pl b/src/lib/libcrypto/des/shifts.pl
index ba686d8ef5..e69de29bb2 100644
--- a/src/lib/libcrypto/des/shifts.pl
+++ b/src/lib/libcrypto/des/shifts.pl
@@ -1,198 +0,0 @@
1#!/usr/local/bin/perl
2
3sub lab_shift
4 {
5 local(*a,$n)=@_;
6 local(@r,$i,$j,$k,$d,@z);
7
8 @r=&shift(*a,$n);
9 foreach $i (0 .. 31)
10 {
11 @z=split(/\^/,$r[$i]);
12 for ($j=0; $j <= $#z; $j++)
13 {
14 ($d)=($z[$j] =~ /^(..)/);
15 ($k)=($z[$j] =~ /\[(.*)\]$/);
16 $k.=",$n" if ($k ne "");
17 $k="$n" if ($k eq "");
18 $d="$d[$k]";
19 $z[$j]=$d;
20 }
21 $r[$i]=join('^',@z);
22 }
23 return(@r);
24 }
25
26sub shift
27 {
28 local(*a,$n)=@_;
29 local(@f);
30
31 if ($n > 0)
32 {
33 @f=&shiftl(*a,$n);
34 }
35 else
36 {
37 @f=&shiftr(*a,-$n);
38 }
39 return(@f);
40 }
41
42sub rotate
43 {
44 local(*a,$n)=@_;
45 local(@f);
46
47 if ($n > 0)
48 { @f=&rotatel(*a,$n); }
49 else
50 { @f=&rotater(*a,-$n); }
51 return(@f);
52 }
53
54sub rotater
55 {
56 local(*a,$n)=@_;
57 local(@f,@g);
58
59 @f=&shiftr(*a,$n);
60 @g=&shiftl(*a,32-$n);
61 $#f=31;
62 $#g=31;
63 return(&or(*f,*g));
64 }
65
66sub rotatel
67 {
68 local(*a,$n)=@_;
69 local(@f,@g);
70
71 @f=&shiftl(*a,$n);
72 @g=&shiftr(*a,32-$n);
73 $#f=31;
74 $#g=31;
75 return(&or(*f,*g));
76 }
77
78sub shiftr
79 {
80 local(*a,$n)=@_;
81 local(@r,$i);
82
83 $#r=31;
84 foreach $i (0 .. 31)
85 {
86 if (($i+$n) > 31)
87 {
88 $r[$i]="--";
89 }
90 else
91 {
92 $r[$i]=$a[$i+$n];
93 }
94 }
95 return(@r);
96 }
97
98sub shiftl
99 {
100 local(*a,$n)=@_;
101 local(@r,$i);
102
103 $#r=31;
104 foreach $i (0 .. 31)
105 {
106 if ($i < $n)
107 {
108 $r[$i]="--";
109 }
110 else
111 {
112 $r[$i]=$a[$i-$n];
113 }
114 }
115 return(@r);
116 }
117
118sub printit
119 {
120 local(@a)=@_;
121 local($i);
122
123 foreach $i (0 .. 31)
124 {
125 printf "%2s ",$a[$i];
126 print "\n" if (($i%8) == 7);
127 }
128 print "\n";
129 }
130
131sub xor
132 {
133 local(*a,*b)=@_;
134 local(@r,$i);
135
136 $#r=31;
137 foreach $i (0 .. 31)
138 {
139 $r[$i]=&compress($a[$i].'^'.$b[$i]);
140# $r[$i]=$a[$i]."^".$b[$i];
141 }
142 return(@r);
143 }
144
145sub and
146 {
147 local(*a,$m)=@_;
148 local(@r,$i);
149
150 $#r=31;
151 foreach $i (0 .. 31)
152 {
153 $r[$i]=(($m & (1<<$i))?($a[$i]):('--'));
154 }
155 return(@r);
156 }
157
158sub or
159 {
160 local(*a,*b)=@_;
161 local(@r,$i);
162
163 $#r=31;
164 foreach $i (0 .. 31)
165 {
166 $r[$i]='--' if (($a[$i] eq '--') && ($b[$i] eq '--'));
167 $r[$i]=$a[$i] if (($a[$i] ne '--') && ($b[$i] eq '--'));
168 $r[$i]=$b[$i] if (($a[$i] eq '--') && ($b[$i] ne '--'));
169 $r[$i]='++' if (($a[$i] ne '--') && ($b[$i] ne '--'));
170 }
171 return(@r);
172 }
173
174sub compress
175 {
176 local($s)=@_;
177 local($_,$i,@a,%a,$r);
178
179 $s =~ s/\^\^/\^/g;
180 $s =~ s/^\^//;
181 $s =~ s/\^$//;
182 @a=split(/\^/,$s);
183
184 while ($#a >= 0)
185 {
186 $_=shift(@a);
187 next unless /\d/;
188 $a{$_}++;
189 }
190 foreach $i (sort keys %a)
191 {
192 next if ($a{$i}%2 == 0);
193 $r.="$i^";
194 }
195 chop($r);
196 return($r);
197 }
1981;
diff --git a/src/lib/libcrypto/des/sk.h b/src/lib/libcrypto/des/sk.h
index f2ade88c7c..e69de29bb2 100644
--- a/src/lib/libcrypto/des/sk.h
+++ b/src/lib/libcrypto/des/sk.h
@@ -1,204 +0,0 @@
1/* crypto/des/sk.h */
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
59static const DES_LONG des_skb[8][64]={
60{
61/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
620x00000000L,0x00000010L,0x20000000L,0x20000010L,
630x00010000L,0x00010010L,0x20010000L,0x20010010L,
640x00000800L,0x00000810L,0x20000800L,0x20000810L,
650x00010800L,0x00010810L,0x20010800L,0x20010810L,
660x00000020L,0x00000030L,0x20000020L,0x20000030L,
670x00010020L,0x00010030L,0x20010020L,0x20010030L,
680x00000820L,0x00000830L,0x20000820L,0x20000830L,
690x00010820L,0x00010830L,0x20010820L,0x20010830L,
700x00080000L,0x00080010L,0x20080000L,0x20080010L,
710x00090000L,0x00090010L,0x20090000L,0x20090010L,
720x00080800L,0x00080810L,0x20080800L,0x20080810L,
730x00090800L,0x00090810L,0x20090800L,0x20090810L,
740x00080020L,0x00080030L,0x20080020L,0x20080030L,
750x00090020L,0x00090030L,0x20090020L,0x20090030L,
760x00080820L,0x00080830L,0x20080820L,0x20080830L,
770x00090820L,0x00090830L,0x20090820L,0x20090830L,
78},{
79/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
800x00000000L,0x02000000L,0x00002000L,0x02002000L,
810x00200000L,0x02200000L,0x00202000L,0x02202000L,
820x00000004L,0x02000004L,0x00002004L,0x02002004L,
830x00200004L,0x02200004L,0x00202004L,0x02202004L,
840x00000400L,0x02000400L,0x00002400L,0x02002400L,
850x00200400L,0x02200400L,0x00202400L,0x02202400L,
860x00000404L,0x02000404L,0x00002404L,0x02002404L,
870x00200404L,0x02200404L,0x00202404L,0x02202404L,
880x10000000L,0x12000000L,0x10002000L,0x12002000L,
890x10200000L,0x12200000L,0x10202000L,0x12202000L,
900x10000004L,0x12000004L,0x10002004L,0x12002004L,
910x10200004L,0x12200004L,0x10202004L,0x12202004L,
920x10000400L,0x12000400L,0x10002400L,0x12002400L,
930x10200400L,0x12200400L,0x10202400L,0x12202400L,
940x10000404L,0x12000404L,0x10002404L,0x12002404L,
950x10200404L,0x12200404L,0x10202404L,0x12202404L,
96},{
97/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
980x00000000L,0x00000001L,0x00040000L,0x00040001L,
990x01000000L,0x01000001L,0x01040000L,0x01040001L,
1000x00000002L,0x00000003L,0x00040002L,0x00040003L,
1010x01000002L,0x01000003L,0x01040002L,0x01040003L,
1020x00000200L,0x00000201L,0x00040200L,0x00040201L,
1030x01000200L,0x01000201L,0x01040200L,0x01040201L,
1040x00000202L,0x00000203L,0x00040202L,0x00040203L,
1050x01000202L,0x01000203L,0x01040202L,0x01040203L,
1060x08000000L,0x08000001L,0x08040000L,0x08040001L,
1070x09000000L,0x09000001L,0x09040000L,0x09040001L,
1080x08000002L,0x08000003L,0x08040002L,0x08040003L,
1090x09000002L,0x09000003L,0x09040002L,0x09040003L,
1100x08000200L,0x08000201L,0x08040200L,0x08040201L,
1110x09000200L,0x09000201L,0x09040200L,0x09040201L,
1120x08000202L,0x08000203L,0x08040202L,0x08040203L,
1130x09000202L,0x09000203L,0x09040202L,0x09040203L,
114},{
115/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
1160x00000000L,0x00100000L,0x00000100L,0x00100100L,
1170x00000008L,0x00100008L,0x00000108L,0x00100108L,
1180x00001000L,0x00101000L,0x00001100L,0x00101100L,
1190x00001008L,0x00101008L,0x00001108L,0x00101108L,
1200x04000000L,0x04100000L,0x04000100L,0x04100100L,
1210x04000008L,0x04100008L,0x04000108L,0x04100108L,
1220x04001000L,0x04101000L,0x04001100L,0x04101100L,
1230x04001008L,0x04101008L,0x04001108L,0x04101108L,
1240x00020000L,0x00120000L,0x00020100L,0x00120100L,
1250x00020008L,0x00120008L,0x00020108L,0x00120108L,
1260x00021000L,0x00121000L,0x00021100L,0x00121100L,
1270x00021008L,0x00121008L,0x00021108L,0x00121108L,
1280x04020000L,0x04120000L,0x04020100L,0x04120100L,
1290x04020008L,0x04120008L,0x04020108L,0x04120108L,
1300x04021000L,0x04121000L,0x04021100L,0x04121100L,
1310x04021008L,0x04121008L,0x04021108L,0x04121108L,
132},{
133/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
1340x00000000L,0x10000000L,0x00010000L,0x10010000L,
1350x00000004L,0x10000004L,0x00010004L,0x10010004L,
1360x20000000L,0x30000000L,0x20010000L,0x30010000L,
1370x20000004L,0x30000004L,0x20010004L,0x30010004L,
1380x00100000L,0x10100000L,0x00110000L,0x10110000L,
1390x00100004L,0x10100004L,0x00110004L,0x10110004L,
1400x20100000L,0x30100000L,0x20110000L,0x30110000L,
1410x20100004L,0x30100004L,0x20110004L,0x30110004L,
1420x00001000L,0x10001000L,0x00011000L,0x10011000L,
1430x00001004L,0x10001004L,0x00011004L,0x10011004L,
1440x20001000L,0x30001000L,0x20011000L,0x30011000L,
1450x20001004L,0x30001004L,0x20011004L,0x30011004L,
1460x00101000L,0x10101000L,0x00111000L,0x10111000L,
1470x00101004L,0x10101004L,0x00111004L,0x10111004L,
1480x20101000L,0x30101000L,0x20111000L,0x30111000L,
1490x20101004L,0x30101004L,0x20111004L,0x30111004L,
150},{
151/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
1520x00000000L,0x08000000L,0x00000008L,0x08000008L,
1530x00000400L,0x08000400L,0x00000408L,0x08000408L,
1540x00020000L,0x08020000L,0x00020008L,0x08020008L,
1550x00020400L,0x08020400L,0x00020408L,0x08020408L,
1560x00000001L,0x08000001L,0x00000009L,0x08000009L,
1570x00000401L,0x08000401L,0x00000409L,0x08000409L,
1580x00020001L,0x08020001L,0x00020009L,0x08020009L,
1590x00020401L,0x08020401L,0x00020409L,0x08020409L,
1600x02000000L,0x0A000000L,0x02000008L,0x0A000008L,
1610x02000400L,0x0A000400L,0x02000408L,0x0A000408L,
1620x02020000L,0x0A020000L,0x02020008L,0x0A020008L,
1630x02020400L,0x0A020400L,0x02020408L,0x0A020408L,
1640x02000001L,0x0A000001L,0x02000009L,0x0A000009L,
1650x02000401L,0x0A000401L,0x02000409L,0x0A000409L,
1660x02020001L,0x0A020001L,0x02020009L,0x0A020009L,
1670x02020401L,0x0A020401L,0x02020409L,0x0A020409L,
168},{
169/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
1700x00000000L,0x00000100L,0x00080000L,0x00080100L,
1710x01000000L,0x01000100L,0x01080000L,0x01080100L,
1720x00000010L,0x00000110L,0x00080010L,0x00080110L,
1730x01000010L,0x01000110L,0x01080010L,0x01080110L,
1740x00200000L,0x00200100L,0x00280000L,0x00280100L,
1750x01200000L,0x01200100L,0x01280000L,0x01280100L,
1760x00200010L,0x00200110L,0x00280010L,0x00280110L,
1770x01200010L,0x01200110L,0x01280010L,0x01280110L,
1780x00000200L,0x00000300L,0x00080200L,0x00080300L,
1790x01000200L,0x01000300L,0x01080200L,0x01080300L,
1800x00000210L,0x00000310L,0x00080210L,0x00080310L,
1810x01000210L,0x01000310L,0x01080210L,0x01080310L,
1820x00200200L,0x00200300L,0x00280200L,0x00280300L,
1830x01200200L,0x01200300L,0x01280200L,0x01280300L,
1840x00200210L,0x00200310L,0x00280210L,0x00280310L,
1850x01200210L,0x01200310L,0x01280210L,0x01280310L,
186},{
187/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
1880x00000000L,0x04000000L,0x00040000L,0x04040000L,
1890x00000002L,0x04000002L,0x00040002L,0x04040002L,
1900x00002000L,0x04002000L,0x00042000L,0x04042000L,
1910x00002002L,0x04002002L,0x00042002L,0x04042002L,
1920x00000020L,0x04000020L,0x00040020L,0x04040020L,
1930x00000022L,0x04000022L,0x00040022L,0x04040022L,
1940x00002020L,0x04002020L,0x00042020L,0x04042020L,
1950x00002022L,0x04002022L,0x00042022L,0x04042022L,
1960x00000800L,0x04000800L,0x00040800L,0x04040800L,
1970x00000802L,0x04000802L,0x00040802L,0x04040802L,
1980x00002800L,0x04002800L,0x00042800L,0x04042800L,
1990x00002802L,0x04002802L,0x00042802L,0x04042802L,
2000x00000820L,0x04000820L,0x00040820L,0x04040820L,
2010x00000822L,0x04000822L,0x00040822L,0x04040822L,
2020x00002820L,0x04002820L,0x00042820L,0x04042820L,
2030x00002822L,0x04002822L,0x00042822L,0x04042822L,
204}};
diff --git a/src/lib/libcrypto/des/testdes.pl b/src/lib/libcrypto/des/testdes.pl
index 01a165a963..e69de29bb2 100644
--- a/src/lib/libcrypto/des/testdes.pl
+++ b/src/lib/libcrypto/des/testdes.pl
@@ -1,167 +0,0 @@
1#!/usr/local/bin/perl
2
3# des.pl tesing code
4
5require 'des.pl';
6
7$num_tests=34;
8@key_data=(
9 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
10 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
11 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
12 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
13 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
14 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
15 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
16 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
17 0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57,
18 0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E,
19 0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86,
20 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E,
21 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6,
22 0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE,
23 0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6,
24 0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE,
25 0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16,
26 0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F,
27 0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46,
28 0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E,
29 0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76,
30 0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07,
31 0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F,
32 0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7,
33 0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF,
34 0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6,
35 0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF,
36 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
37 0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E,
38 0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE,
39 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
40 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
41 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
42 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
43 );
44
45@plain_data=(
46 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
47 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
48 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
49 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
50 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
51 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
52 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
53 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
54 0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42,
55 0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA,
56 0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72,
57 0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A,
58 0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2,
59 0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A,
60 0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2,
61 0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A,
62 0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02,
63 0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A,
64 0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32,
65 0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA,
66 0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62,
67 0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2,
68 0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA,
69 0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92,
70 0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A,
71 0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2,
72 0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A,
73 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
74 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
75 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
76 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
80
81@cipher_data=(
82 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
83 0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58,
84 0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B,
85 0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33,
86 0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D,
87 0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD,
88 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
89 0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4,
90 0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B,
91 0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71,
92 0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A,
93 0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A,
94 0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95,
95 0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B,
96 0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09,
97 0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A,
98 0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F,
99 0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88,
100 0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77,
101 0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A,
102 0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56,
103 0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56,
104 0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56,
105 0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC,
106 0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A,
107 0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41,
108 0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93,
109 0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00,
110 0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06,
111 0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7,
112 0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51,
113 0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE,
114 0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D,
115 0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2);
116
117print "Doing ecb tests\n";
118for ($i=0; $i<$num_tests; $i++)
119 {
120 printf "Doing test $i\n";
121 $key =pack("C8",splice(@key_data ,0,8));
122 $data=pack("C8",splice(@plain_data ,0,8));
123 $res =pack("C8",splice(@cipher_data,0,8));
124
125 @ks= &des_set_key($key);
126 $out1= &des_ecb_encrypt(*ks,1,$data);
127 $out2= &des_ecb_encrypt(*ks,0,$out1);
128 $out3= &des_ecb_encrypt(*ks,0,$res);
129 &eprint("encryption failure",$res,$out1)
130 if ($out1 ne $res);
131 &eprint("encryption/decryption failure",$data,$out2)
132 if ($out2 ne $data);
133 &eprint("decryption failure",$data,$out3)
134 if ($data ne $out3);
135 }
136print "Done\n";
137
138print "doing speed test over 30 seconds\n";
139$SIG{'ALRM'}='done';
140sub done {$done=1;}
141$done=0;
142
143$count=0;
144$d=pack("C8",0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
145@ks= &des_set_key($d);
146alarm(30);
147$start=(times)[0];
148while (!$done)
149 {
150 $count++;
151 $d=&des_ecb_encrypt(*ks,1,$d);
152 }
153$end=(times)[0];
154$t=$end-$start;
155printf "$count DESs in %.2f seconds is %.2f DESs/sec or %.2f bytes/sec\n",
156 1.0*$t,1.0*$count/$t,$count*8.0/$t;
157
158sub eprint
159 {
160 local($s,$c,$e)=@_;
161 local(@k);
162
163 @k=unpack("C8",$c);
164 printf "%02x%02x%02x%02x %02x%02x%02x%02x - ",unpack("C8",$c);
165 printf "%02x%02x%02x%02x %02x%02x%02x%02x :",unpack("C8",$e);
166 print " $s\n";
167 }