summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bf
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bf')
-rw-r--r--src/lib/libcrypto/bf/Makefile.ssl107
-rw-r--r--src/lib/libcrypto/bf/Makefile.uni169
-rw-r--r--src/lib/libcrypto/bf/asm/b-win32.asm906
-rw-r--r--src/lib/libcrypto/bf/asm/bx86unix.cpp976
-rw-r--r--src/lib/libcrypto/bf/bf_locl.org242
5 files changed, 2400 insertions, 0 deletions
diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl
new file mode 100644
index 0000000000..236671f238
--- /dev/null
+++ b/src/lib/libcrypto/bf/Makefile.ssl
@@ -0,0 +1,107 @@
1#
2# SSLeay/crypto/blowfish/Makefile
3#
4
5DIR= bf
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17BF_ENC= bf_enc.o
18# or use
19#DES_ENC= bx86-elf.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=bftest.c
25APPS=
26
27LIB=$(TOP)/libcrypto.a
28LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
29LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= blowfish.h
34HEADER= bf_pi.h bf_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB)
46 @touch lib
47
48# elf
49asm/bx86-elf.o: asm/bx86unix.cpp
50 $(CPP) -DELF asm/bx86unix.cpp | as -o asm/bx86-elf.o
51
52# solaris
53asm/bx86-sol.o: asm/bx86unix.cpp
54 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
55 as -o asm/bx86-sol.o asm/bx86-sol.s
56 rm -f asm/bx86-sol.s
57
58# a.out
59asm/bx86-out.o: asm/bx86unix.cpp
60 $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o
61
62# bsdi
63asm/bx86bsdi.o: asm/bx86unix.cpp
64 $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o
65
66asm/bx86unix.cpp:
67 (cd asm; perl bf-586.pl cpp >bx86unix.cpp)
68
69files:
70 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
71
72links:
73 /bin/rm -f Makefile
74 $(TOP)/util/point.sh Makefile.ssl Makefile ;
75 $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ;
76 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
77 $(TOP)/util/mklink.sh ../../test $(TEST)
78 $(TOP)/util/mklink.sh ../../apps $(APPS)
79
80install:
81 @for i in $(EXHEADER) ; \
82 do \
83 (cp $$i $(INSTALLTOP)/include/$$i; \
84 chmod 644 $(INSTALLTOP)/include/$$i ); \
85 done;
86
87tags:
88 ctags $(SRC)
89
90tests:
91
92lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94
95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
97
98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE)
101
102clean:
103 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105errors:
106
107# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/bf/Makefile.uni b/src/lib/libcrypto/bf/Makefile.uni
new file mode 100644
index 0000000000..9ba5b0c854
--- /dev/null
+++ b/src/lib/libcrypto/bf/Makefile.uni
@@ -0,0 +1,169 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= bf
11TOP= .
12# use BF_PTR2 for intel boxes,
13# BF_PTR for sparc and MIPS/SGI
14# use nothing for Alpha and HP.
15
16# There are 3 possible performance options, experiment :-)
17#OPTS= -DBF_PTR # usr for sparc and MIPS/SGI
18#OPTS= -DBF_PTR2 # use for pentium
19OPTS= # use for pentium pro, Alpha and HP
20
21MAKE=make -f Makefile
22#CC=cc
23#CFLAG= -O
24
25CC=gcc
26#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
27CFLAG= -O3 -fomit-frame-pointer
28
29CFLAGS=$(OPTS) $(CFLAG)
30CPP=$(CC) -E
31AS=as
32
33# Assember version of bf_encrypt().
34BF_ENC=bf_enc.o # normal C version
35#BF_ENC=asm/bx86-elf.o # elf format x86
36#BF_ENC=asm/bx86-out.o # a.out format x86
37#BF_ENC=asm/bx86-sol.o # solaris format x86
38#BF_ENC=asm/bx86bsdi.o # bsdi format x86
39
40LIBDIR=/usr/local/lib
41BINDIR=/usr/local/bin
42INCDIR=/usr/local/include
43MANDIR=/usr/local/man
44MAN1=1
45MAN3=3
46SHELL=/bin/sh
47LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
48LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
49
50GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \
51 COPYRIGHT blowfish.doc INSTALL
52
53TESTING= bftest bfspeed bf_opts
54TESTING_SRC=bftest.c bfspeed.c bf_opts.c
55HEADERS=bf_locl.h blowfish.h bf_pi.h
56
57ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS)
58
59BLIB= libblowfish.a
60
61all: $(BLIB) $(TESTING)
62
63cc:
64 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
65
66gcc:
67 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
68
69x86-elf:
70 $(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
71
72x86-out:
73 $(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
74
75x86-solaris:
76 $(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
77
78x86-bsdi:
79 $(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
80
81# elf
82asm/bx86-elf.o: asm/bx86unix.cpp
83 $(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o
84
85# solaris
86asm/bx86-sol.o: asm/bx86unix.cpp
87 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
88 as -o asm/bx86-sol.o asm/bx86-sol.s
89 rm -f asm/bx86-sol.s
90
91# a.out
92asm/bx86-out.o: asm/bx86unix.cpp
93 $(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o
94
95# bsdi
96asm/bx86bsdi.o: asm/bx86unix.cpp
97 $(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o
98
99asm/bx86unix.cpp:
100 (cd asm; perl bf-586.pl cpp >bx86unix.cpp)
101
102test: all
103 ./bftest
104
105$(BLIB): $(LIBOBJ)
106 /bin/rm -f $(BLIB)
107 ar cr $(BLIB) $(LIBOBJ)
108 -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \
109 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \
110 else exit 0; fi; fi
111
112bftest: bftest.o $(BLIB)
113 $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB)
114
115bfspeed: bfspeed.o $(BLIB)
116 $(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB)
117
118bf_opts: bf_opts.o $(BLIB)
119 $(CC) $(CFLAGS) -o bf_opts bf_opts.o $(BLIB)
120
121tags:
122 ctags $(TESTING_SRC) $(LIBBF)
123
124tar:
125 tar chf libbf.tar $(ALL)
126
127shar:
128 shar $(ALL) >libbf.shar
129
130depend:
131 makedepend $(LIBBF) $(TESTING_SRC)
132
133clean:
134 /bin/rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o
135
136dclean:
137 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
138 mv -f Makefile.new Makefile
139
140# Eric is probably going to choke when he next looks at this --tjh
141install: $(BLIB)
142 if test $(INSTALLTOP); then \
143 echo SSL style install; \
144 cp $(BLIB) $(INSTALLTOP)/lib; \
145 if test -s /bin/ranlib; then \
146 /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
147 else \
148 if test -s /usr/bin/ranlib; then \
149 /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
150 fi; fi; \
151 chmod 644 $(INSTALLTOP)/lib/$(BLIB); \
152 cp blowfish.h $(INSTALLTOP)/include; \
153 chmod 644 $(INSTALLTOP)/include/blowfish.h; \
154 else \
155 echo Standalone install; \
156 cp $(BLIB) $(LIBDIR)/$(BLIB); \
157 if test -s /bin/ranlib; then \
158 /bin/ranlib $(LIBDIR)/$(BLIB); \
159 else \
160 if test -s /usr/bin/ranlib; then \
161 /usr/bin/ranlib $(LIBDIR)/$(BLIB); \
162 fi; \
163 fi; \
164 chmod 644 $(LIBDIR)/$(BLIB); \
165 cp blowfish.h $(INCDIR)/blowfish.h; \
166 chmod 644 $(INCDIR)/blowfish.h; \
167 fi
168
169# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/bf/asm/b-win32.asm b/src/lib/libcrypto/bf/asm/b-win32.asm
new file mode 100644
index 0000000000..138c99d0aa
--- /dev/null
+++ b/src/lib/libcrypto/bf/asm/b-win32.asm
@@ -0,0 +1,906 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by bf-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 bf-586.asm
8 .486
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _BF_encrypt
12
13_BF_encrypt PROC NEAR
14 ;
15 push ebp
16 push ebx
17 mov ebx, DWORD PTR 12[esp]
18 mov ebp, DWORD PTR 16[esp]
19 push esi
20 push edi
21 ; Load the 2 words
22 mov edi, DWORD PTR [ebx]
23 mov esi, DWORD PTR 4[ebx]
24 xor eax, eax
25 mov ebx, DWORD PTR [ebp]
26 xor ecx, ecx
27 xor edi, ebx
28 ;
29 ; Round 0
30 mov edx, DWORD PTR 4[ebp]
31 mov ebx, edi
32 xor esi, edx
33 shr ebx, 16
34 mov edx, edi
35 mov al, bh
36 and ebx, 255
37 mov cl, dh
38 and edx, 255
39 mov eax, DWORD PTR 72[eax*4+ebp]
40 mov ebx, DWORD PTR 1096[ebx*4+ebp]
41 add ebx, eax
42 mov eax, DWORD PTR 2120[ecx*4+ebp]
43 xor ebx, eax
44 mov edx, DWORD PTR 3144[edx*4+ebp]
45 add ebx, edx
46 xor eax, eax
47 xor esi, ebx
48 ;
49 ; Round 1
50 mov edx, DWORD PTR 8[ebp]
51 mov ebx, esi
52 xor edi, edx
53 shr ebx, 16
54 mov edx, esi
55 mov al, bh
56 and ebx, 255
57 mov cl, dh
58 and edx, 255
59 mov eax, DWORD PTR 72[eax*4+ebp]
60 mov ebx, DWORD PTR 1096[ebx*4+ebp]
61 add ebx, eax
62 mov eax, DWORD PTR 2120[ecx*4+ebp]
63 xor ebx, eax
64 mov edx, DWORD PTR 3144[edx*4+ebp]
65 add ebx, edx
66 xor eax, eax
67 xor edi, ebx
68 ;
69 ; Round 2
70 mov edx, DWORD PTR 12[ebp]
71 mov ebx, edi
72 xor esi, edx
73 shr ebx, 16
74 mov edx, edi
75 mov al, bh
76 and ebx, 255
77 mov cl, dh
78 and edx, 255
79 mov eax, DWORD PTR 72[eax*4+ebp]
80 mov ebx, DWORD PTR 1096[ebx*4+ebp]
81 add ebx, eax
82 mov eax, DWORD PTR 2120[ecx*4+ebp]
83 xor ebx, eax
84 mov edx, DWORD PTR 3144[edx*4+ebp]
85 add ebx, edx
86 xor eax, eax
87 xor esi, ebx
88 ;
89 ; Round 3
90 mov edx, DWORD PTR 16[ebp]
91 mov ebx, esi
92 xor edi, edx
93 shr ebx, 16
94 mov edx, esi
95 mov al, bh
96 and ebx, 255
97 mov cl, dh
98 and edx, 255
99 mov eax, DWORD PTR 72[eax*4+ebp]
100 mov ebx, DWORD PTR 1096[ebx*4+ebp]
101 add ebx, eax
102 mov eax, DWORD PTR 2120[ecx*4+ebp]
103 xor ebx, eax
104 mov edx, DWORD PTR 3144[edx*4+ebp]
105 add ebx, edx
106 xor eax, eax
107 xor edi, ebx
108 ;
109 ; Round 4
110 mov edx, DWORD PTR 20[ebp]
111 mov ebx, edi
112 xor esi, edx
113 shr ebx, 16
114 mov edx, edi
115 mov al, bh
116 and ebx, 255
117 mov cl, dh
118 and edx, 255
119 mov eax, DWORD PTR 72[eax*4+ebp]
120 mov ebx, DWORD PTR 1096[ebx*4+ebp]
121 add ebx, eax
122 mov eax, DWORD PTR 2120[ecx*4+ebp]
123 xor ebx, eax
124 mov edx, DWORD PTR 3144[edx*4+ebp]
125 add ebx, edx
126 xor eax, eax
127 xor esi, ebx
128 ;
129 ; Round 5
130 mov edx, DWORD PTR 24[ebp]
131 mov ebx, esi
132 xor edi, edx
133 shr ebx, 16
134 mov edx, esi
135 mov al, bh
136 and ebx, 255
137 mov cl, dh
138 and edx, 255
139 mov eax, DWORD PTR 72[eax*4+ebp]
140 mov ebx, DWORD PTR 1096[ebx*4+ebp]
141 add ebx, eax
142 mov eax, DWORD PTR 2120[ecx*4+ebp]
143 xor ebx, eax
144 mov edx, DWORD PTR 3144[edx*4+ebp]
145 add ebx, edx
146 xor eax, eax
147 xor edi, ebx
148 ;
149 ; Round 6
150 mov edx, DWORD PTR 28[ebp]
151 mov ebx, edi
152 xor esi, edx
153 shr ebx, 16
154 mov edx, edi
155 mov al, bh
156 and ebx, 255
157 mov cl, dh
158 and edx, 255
159 mov eax, DWORD PTR 72[eax*4+ebp]
160 mov ebx, DWORD PTR 1096[ebx*4+ebp]
161 add ebx, eax
162 mov eax, DWORD PTR 2120[ecx*4+ebp]
163 xor ebx, eax
164 mov edx, DWORD PTR 3144[edx*4+ebp]
165 add ebx, edx
166 xor eax, eax
167 xor esi, ebx
168 ;
169 ; Round 7
170 mov edx, DWORD PTR 32[ebp]
171 mov ebx, esi
172 xor edi, edx
173 shr ebx, 16
174 mov edx, esi
175 mov al, bh
176 and ebx, 255
177 mov cl, dh
178 and edx, 255
179 mov eax, DWORD PTR 72[eax*4+ebp]
180 mov ebx, DWORD PTR 1096[ebx*4+ebp]
181 add ebx, eax
182 mov eax, DWORD PTR 2120[ecx*4+ebp]
183 xor ebx, eax
184 mov edx, DWORD PTR 3144[edx*4+ebp]
185 add ebx, edx
186 xor eax, eax
187 xor edi, ebx
188 ;
189 ; Round 8
190 mov edx, DWORD PTR 36[ebp]
191 mov ebx, edi
192 xor esi, edx
193 shr ebx, 16
194 mov edx, edi
195 mov al, bh
196 and ebx, 255
197 mov cl, dh
198 and edx, 255
199 mov eax, DWORD PTR 72[eax*4+ebp]
200 mov ebx, DWORD PTR 1096[ebx*4+ebp]
201 add ebx, eax
202 mov eax, DWORD PTR 2120[ecx*4+ebp]
203 xor ebx, eax
204 mov edx, DWORD PTR 3144[edx*4+ebp]
205 add ebx, edx
206 xor eax, eax
207 xor esi, ebx
208 ;
209 ; Round 9
210 mov edx, DWORD PTR 40[ebp]
211 mov ebx, esi
212 xor edi, edx
213 shr ebx, 16
214 mov edx, esi
215 mov al, bh
216 and ebx, 255
217 mov cl, dh
218 and edx, 255
219 mov eax, DWORD PTR 72[eax*4+ebp]
220 mov ebx, DWORD PTR 1096[ebx*4+ebp]
221 add ebx, eax
222 mov eax, DWORD PTR 2120[ecx*4+ebp]
223 xor ebx, eax
224 mov edx, DWORD PTR 3144[edx*4+ebp]
225 add ebx, edx
226 xor eax, eax
227 xor edi, ebx
228 ;
229 ; Round 10
230 mov edx, DWORD PTR 44[ebp]
231 mov ebx, edi
232 xor esi, edx
233 shr ebx, 16
234 mov edx, edi
235 mov al, bh
236 and ebx, 255
237 mov cl, dh
238 and edx, 255
239 mov eax, DWORD PTR 72[eax*4+ebp]
240 mov ebx, DWORD PTR 1096[ebx*4+ebp]
241 add ebx, eax
242 mov eax, DWORD PTR 2120[ecx*4+ebp]
243 xor ebx, eax
244 mov edx, DWORD PTR 3144[edx*4+ebp]
245 add ebx, edx
246 xor eax, eax
247 xor esi, ebx
248 ;
249 ; Round 11
250 mov edx, DWORD PTR 48[ebp]
251 mov ebx, esi
252 xor edi, edx
253 shr ebx, 16
254 mov edx, esi
255 mov al, bh
256 and ebx, 255
257 mov cl, dh
258 and edx, 255
259 mov eax, DWORD PTR 72[eax*4+ebp]
260 mov ebx, DWORD PTR 1096[ebx*4+ebp]
261 add ebx, eax
262 mov eax, DWORD PTR 2120[ecx*4+ebp]
263 xor ebx, eax
264 mov edx, DWORD PTR 3144[edx*4+ebp]
265 add ebx, edx
266 xor eax, eax
267 xor edi, ebx
268 ;
269 ; Round 12
270 mov edx, DWORD PTR 52[ebp]
271 mov ebx, edi
272 xor esi, edx
273 shr ebx, 16
274 mov edx, edi
275 mov al, bh
276 and ebx, 255
277 mov cl, dh
278 and edx, 255
279 mov eax, DWORD PTR 72[eax*4+ebp]
280 mov ebx, DWORD PTR 1096[ebx*4+ebp]
281 add ebx, eax
282 mov eax, DWORD PTR 2120[ecx*4+ebp]
283 xor ebx, eax
284 mov edx, DWORD PTR 3144[edx*4+ebp]
285 add ebx, edx
286 xor eax, eax
287 xor esi, ebx
288 ;
289 ; Round 13
290 mov edx, DWORD PTR 56[ebp]
291 mov ebx, esi
292 xor edi, edx
293 shr ebx, 16
294 mov edx, esi
295 mov al, bh
296 and ebx, 255
297 mov cl, dh
298 and edx, 255
299 mov eax, DWORD PTR 72[eax*4+ebp]
300 mov ebx, DWORD PTR 1096[ebx*4+ebp]
301 add ebx, eax
302 mov eax, DWORD PTR 2120[ecx*4+ebp]
303 xor ebx, eax
304 mov edx, DWORD PTR 3144[edx*4+ebp]
305 add ebx, edx
306 xor eax, eax
307 xor edi, ebx
308 ;
309 ; Round 14
310 mov edx, DWORD PTR 60[ebp]
311 mov ebx, edi
312 xor esi, edx
313 shr ebx, 16
314 mov edx, edi
315 mov al, bh
316 and ebx, 255
317 mov cl, dh
318 and edx, 255
319 mov eax, DWORD PTR 72[eax*4+ebp]
320 mov ebx, DWORD PTR 1096[ebx*4+ebp]
321 add ebx, eax
322 mov eax, DWORD PTR 2120[ecx*4+ebp]
323 xor ebx, eax
324 mov edx, DWORD PTR 3144[edx*4+ebp]
325 add ebx, edx
326 xor eax, eax
327 xor esi, ebx
328 ;
329 ; Round 15
330 mov edx, DWORD PTR 64[ebp]
331 mov ebx, esi
332 xor edi, edx
333 shr ebx, 16
334 mov edx, esi
335 mov al, bh
336 and ebx, 255
337 mov cl, dh
338 and edx, 255
339 mov eax, DWORD PTR 72[eax*4+ebp]
340 mov ebx, DWORD PTR 1096[ebx*4+ebp]
341 add ebx, eax
342 mov eax, DWORD PTR 2120[ecx*4+ebp]
343 xor ebx, eax
344 mov edx, DWORD PTR 3144[edx*4+ebp]
345 add ebx, edx
346 ; Load parameter 0 (16) enc=1
347 mov eax, DWORD PTR 20[esp]
348 xor edi, ebx
349 mov edx, DWORD PTR 68[ebp]
350 xor esi, edx
351 mov DWORD PTR 4[eax],edi
352 mov DWORD PTR [eax],esi
353 pop edi
354 pop esi
355 pop ebx
356 pop ebp
357 ret
358_BF_encrypt ENDP
359_TEXT ENDS
360_TEXT SEGMENT
361PUBLIC _BF_decrypt
362
363_BF_decrypt PROC NEAR
364 ;
365 push ebp
366 push ebx
367 mov ebx, DWORD PTR 12[esp]
368 mov ebp, DWORD PTR 16[esp]
369 push esi
370 push edi
371 ; Load the 2 words
372 mov edi, DWORD PTR [ebx]
373 mov esi, DWORD PTR 4[ebx]
374 xor eax, eax
375 mov ebx, DWORD PTR 68[ebp]
376 xor ecx, ecx
377 xor edi, ebx
378 ;
379 ; Round 16
380 mov edx, DWORD PTR 64[ebp]
381 mov ebx, edi
382 xor esi, edx
383 shr ebx, 16
384 mov edx, edi
385 mov al, bh
386 and ebx, 255
387 mov cl, dh
388 and edx, 255
389 mov eax, DWORD PTR 72[eax*4+ebp]
390 mov ebx, DWORD PTR 1096[ebx*4+ebp]
391 add ebx, eax
392 mov eax, DWORD PTR 2120[ecx*4+ebp]
393 xor ebx, eax
394 mov edx, DWORD PTR 3144[edx*4+ebp]
395 add ebx, edx
396 xor eax, eax
397 xor esi, ebx
398 ;
399 ; Round 15
400 mov edx, DWORD PTR 60[ebp]
401 mov ebx, esi
402 xor edi, edx
403 shr ebx, 16
404 mov edx, esi
405 mov al, bh
406 and ebx, 255
407 mov cl, dh
408 and edx, 255
409 mov eax, DWORD PTR 72[eax*4+ebp]
410 mov ebx, DWORD PTR 1096[ebx*4+ebp]
411 add ebx, eax
412 mov eax, DWORD PTR 2120[ecx*4+ebp]
413 xor ebx, eax
414 mov edx, DWORD PTR 3144[edx*4+ebp]
415 add ebx, edx
416 xor eax, eax
417 xor edi, ebx
418 ;
419 ; Round 14
420 mov edx, DWORD PTR 56[ebp]
421 mov ebx, edi
422 xor esi, edx
423 shr ebx, 16
424 mov edx, edi
425 mov al, bh
426 and ebx, 255
427 mov cl, dh
428 and edx, 255
429 mov eax, DWORD PTR 72[eax*4+ebp]
430 mov ebx, DWORD PTR 1096[ebx*4+ebp]
431 add ebx, eax
432 mov eax, DWORD PTR 2120[ecx*4+ebp]
433 xor ebx, eax
434 mov edx, DWORD PTR 3144[edx*4+ebp]
435 add ebx, edx
436 xor eax, eax
437 xor esi, ebx
438 ;
439 ; Round 13
440 mov edx, DWORD PTR 52[ebp]
441 mov ebx, esi
442 xor edi, edx
443 shr ebx, 16
444 mov edx, esi
445 mov al, bh
446 and ebx, 255
447 mov cl, dh
448 and edx, 255
449 mov eax, DWORD PTR 72[eax*4+ebp]
450 mov ebx, DWORD PTR 1096[ebx*4+ebp]
451 add ebx, eax
452 mov eax, DWORD PTR 2120[ecx*4+ebp]
453 xor ebx, eax
454 mov edx, DWORD PTR 3144[edx*4+ebp]
455 add ebx, edx
456 xor eax, eax
457 xor edi, ebx
458 ;
459 ; Round 12
460 mov edx, DWORD PTR 48[ebp]
461 mov ebx, edi
462 xor esi, edx
463 shr ebx, 16
464 mov edx, edi
465 mov al, bh
466 and ebx, 255
467 mov cl, dh
468 and edx, 255
469 mov eax, DWORD PTR 72[eax*4+ebp]
470 mov ebx, DWORD PTR 1096[ebx*4+ebp]
471 add ebx, eax
472 mov eax, DWORD PTR 2120[ecx*4+ebp]
473 xor ebx, eax
474 mov edx, DWORD PTR 3144[edx*4+ebp]
475 add ebx, edx
476 xor eax, eax
477 xor esi, ebx
478 ;
479 ; Round 11
480 mov edx, DWORD PTR 44[ebp]
481 mov ebx, esi
482 xor edi, edx
483 shr ebx, 16
484 mov edx, esi
485 mov al, bh
486 and ebx, 255
487 mov cl, dh
488 and edx, 255
489 mov eax, DWORD PTR 72[eax*4+ebp]
490 mov ebx, DWORD PTR 1096[ebx*4+ebp]
491 add ebx, eax
492 mov eax, DWORD PTR 2120[ecx*4+ebp]
493 xor ebx, eax
494 mov edx, DWORD PTR 3144[edx*4+ebp]
495 add ebx, edx
496 xor eax, eax
497 xor edi, ebx
498 ;
499 ; Round 10
500 mov edx, DWORD PTR 40[ebp]
501 mov ebx, edi
502 xor esi, edx
503 shr ebx, 16
504 mov edx, edi
505 mov al, bh
506 and ebx, 255
507 mov cl, dh
508 and edx, 255
509 mov eax, DWORD PTR 72[eax*4+ebp]
510 mov ebx, DWORD PTR 1096[ebx*4+ebp]
511 add ebx, eax
512 mov eax, DWORD PTR 2120[ecx*4+ebp]
513 xor ebx, eax
514 mov edx, DWORD PTR 3144[edx*4+ebp]
515 add ebx, edx
516 xor eax, eax
517 xor esi, ebx
518 ;
519 ; Round 9
520 mov edx, DWORD PTR 36[ebp]
521 mov ebx, esi
522 xor edi, edx
523 shr ebx, 16
524 mov edx, esi
525 mov al, bh
526 and ebx, 255
527 mov cl, dh
528 and edx, 255
529 mov eax, DWORD PTR 72[eax*4+ebp]
530 mov ebx, DWORD PTR 1096[ebx*4+ebp]
531 add ebx, eax
532 mov eax, DWORD PTR 2120[ecx*4+ebp]
533 xor ebx, eax
534 mov edx, DWORD PTR 3144[edx*4+ebp]
535 add ebx, edx
536 xor eax, eax
537 xor edi, ebx
538 ;
539 ; Round 8
540 mov edx, DWORD PTR 32[ebp]
541 mov ebx, edi
542 xor esi, edx
543 shr ebx, 16
544 mov edx, edi
545 mov al, bh
546 and ebx, 255
547 mov cl, dh
548 and edx, 255
549 mov eax, DWORD PTR 72[eax*4+ebp]
550 mov ebx, DWORD PTR 1096[ebx*4+ebp]
551 add ebx, eax
552 mov eax, DWORD PTR 2120[ecx*4+ebp]
553 xor ebx, eax
554 mov edx, DWORD PTR 3144[edx*4+ebp]
555 add ebx, edx
556 xor eax, eax
557 xor esi, ebx
558 ;
559 ; Round 7
560 mov edx, DWORD PTR 28[ebp]
561 mov ebx, esi
562 xor edi, edx
563 shr ebx, 16
564 mov edx, esi
565 mov al, bh
566 and ebx, 255
567 mov cl, dh
568 and edx, 255
569 mov eax, DWORD PTR 72[eax*4+ebp]
570 mov ebx, DWORD PTR 1096[ebx*4+ebp]
571 add ebx, eax
572 mov eax, DWORD PTR 2120[ecx*4+ebp]
573 xor ebx, eax
574 mov edx, DWORD PTR 3144[edx*4+ebp]
575 add ebx, edx
576 xor eax, eax
577 xor edi, ebx
578 ;
579 ; Round 6
580 mov edx, DWORD PTR 24[ebp]
581 mov ebx, edi
582 xor esi, edx
583 shr ebx, 16
584 mov edx, edi
585 mov al, bh
586 and ebx, 255
587 mov cl, dh
588 and edx, 255
589 mov eax, DWORD PTR 72[eax*4+ebp]
590 mov ebx, DWORD PTR 1096[ebx*4+ebp]
591 add ebx, eax
592 mov eax, DWORD PTR 2120[ecx*4+ebp]
593 xor ebx, eax
594 mov edx, DWORD PTR 3144[edx*4+ebp]
595 add ebx, edx
596 xor eax, eax
597 xor esi, ebx
598 ;
599 ; Round 5
600 mov edx, DWORD PTR 20[ebp]
601 mov ebx, esi
602 xor edi, edx
603 shr ebx, 16
604 mov edx, esi
605 mov al, bh
606 and ebx, 255
607 mov cl, dh
608 and edx, 255
609 mov eax, DWORD PTR 72[eax*4+ebp]
610 mov ebx, DWORD PTR 1096[ebx*4+ebp]
611 add ebx, eax
612 mov eax, DWORD PTR 2120[ecx*4+ebp]
613 xor ebx, eax
614 mov edx, DWORD PTR 3144[edx*4+ebp]
615 add ebx, edx
616 xor eax, eax
617 xor edi, ebx
618 ;
619 ; Round 4
620 mov edx, DWORD PTR 16[ebp]
621 mov ebx, edi
622 xor esi, edx
623 shr ebx, 16
624 mov edx, edi
625 mov al, bh
626 and ebx, 255
627 mov cl, dh
628 and edx, 255
629 mov eax, DWORD PTR 72[eax*4+ebp]
630 mov ebx, DWORD PTR 1096[ebx*4+ebp]
631 add ebx, eax
632 mov eax, DWORD PTR 2120[ecx*4+ebp]
633 xor ebx, eax
634 mov edx, DWORD PTR 3144[edx*4+ebp]
635 add ebx, edx
636 xor eax, eax
637 xor esi, ebx
638 ;
639 ; Round 3
640 mov edx, DWORD PTR 12[ebp]
641 mov ebx, esi
642 xor edi, edx
643 shr ebx, 16
644 mov edx, esi
645 mov al, bh
646 and ebx, 255
647 mov cl, dh
648 and edx, 255
649 mov eax, DWORD PTR 72[eax*4+ebp]
650 mov ebx, DWORD PTR 1096[ebx*4+ebp]
651 add ebx, eax
652 mov eax, DWORD PTR 2120[ecx*4+ebp]
653 xor ebx, eax
654 mov edx, DWORD PTR 3144[edx*4+ebp]
655 add ebx, edx
656 xor eax, eax
657 xor edi, ebx
658 ;
659 ; Round 2
660 mov edx, DWORD PTR 8[ebp]
661 mov ebx, edi
662 xor esi, edx
663 shr ebx, 16
664 mov edx, edi
665 mov al, bh
666 and ebx, 255
667 mov cl, dh
668 and edx, 255
669 mov eax, DWORD PTR 72[eax*4+ebp]
670 mov ebx, DWORD PTR 1096[ebx*4+ebp]
671 add ebx, eax
672 mov eax, DWORD PTR 2120[ecx*4+ebp]
673 xor ebx, eax
674 mov edx, DWORD PTR 3144[edx*4+ebp]
675 add ebx, edx
676 xor eax, eax
677 xor esi, ebx
678 ;
679 ; Round 1
680 mov edx, DWORD PTR 4[ebp]
681 mov ebx, esi
682 xor edi, edx
683 shr ebx, 16
684 mov edx, esi
685 mov al, bh
686 and ebx, 255
687 mov cl, dh
688 and edx, 255
689 mov eax, DWORD PTR 72[eax*4+ebp]
690 mov ebx, DWORD PTR 1096[ebx*4+ebp]
691 add ebx, eax
692 mov eax, DWORD PTR 2120[ecx*4+ebp]
693 xor ebx, eax
694 mov edx, DWORD PTR 3144[edx*4+ebp]
695 add ebx, edx
696 ; Load parameter 0 (1) enc=0
697 mov eax, DWORD PTR 20[esp]
698 xor edi, ebx
699 mov edx, DWORD PTR [ebp]
700 xor esi, edx
701 mov DWORD PTR 4[eax],edi
702 mov DWORD PTR [eax],esi
703 pop edi
704 pop esi
705 pop ebx
706 pop ebp
707 ret
708_BF_decrypt ENDP
709_TEXT ENDS
710_TEXT SEGMENT
711PUBLIC _BF_cbc_encrypt
712
713_BF_cbc_encrypt PROC NEAR
714 ;
715 push ebp
716 push ebx
717 push esi
718 push edi
719 mov ebp, DWORD PTR 28[esp]
720 ; getting iv ptr from parameter 4
721 mov ebx, DWORD PTR 36[esp]
722 mov esi, DWORD PTR [ebx]
723 mov edi, DWORD PTR 4[ebx]
724 push edi
725 push esi
726 push edi
727 push esi
728 mov ebx, esp
729 mov esi, DWORD PTR 36[esp]
730 mov edi, DWORD PTR 40[esp]
731 ; getting encrypt flag from parameter 5
732 mov ecx, DWORD PTR 56[esp]
733 ; get and push parameter 3
734 mov eax, DWORD PTR 48[esp]
735 push eax
736 push ebx
737 cmp ecx, 0
738 jz $L000decrypt
739 and ebp, 4294967288
740 mov eax, DWORD PTR 8[esp]
741 mov ebx, DWORD PTR 12[esp]
742 jz $L001encrypt_finish
743L002encrypt_loop:
744 mov ecx, DWORD PTR [esi]
745 mov edx, DWORD PTR 4[esi]
746 xor eax, ecx
747 xor ebx, edx
748 bswap eax
749 bswap ebx
750 mov DWORD PTR 8[esp],eax
751 mov DWORD PTR 12[esp],ebx
752 call _BF_encrypt
753 mov eax, DWORD PTR 8[esp]
754 mov ebx, DWORD PTR 12[esp]
755 bswap eax
756 bswap ebx
757 mov DWORD PTR [edi],eax
758 mov DWORD PTR 4[edi],ebx
759 add esi, 8
760 add edi, 8
761 sub ebp, 8
762 jnz L002encrypt_loop
763$L001encrypt_finish:
764 mov ebp, DWORD PTR 52[esp]
765 and ebp, 7
766 jz $L003finish
767 xor ecx, ecx
768 xor edx, edx
769 mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4]
770 jmp ebp
771L005ej7:
772 mov dh, BYTE PTR 6[esi]
773 shl edx, 8
774L006ej6:
775 mov dh, BYTE PTR 5[esi]
776L007ej5:
777 mov dl, BYTE PTR 4[esi]
778L008ej4:
779 mov ecx, DWORD PTR [esi]
780 jmp $L009ejend
781L010ej3:
782 mov ch, BYTE PTR 2[esi]
783 shl ecx, 8
784L011ej2:
785 mov ch, BYTE PTR 1[esi]
786L012ej1:
787 mov cl, BYTE PTR [esi]
788$L009ejend:
789 xor eax, ecx
790 xor ebx, edx
791 bswap eax
792 bswap ebx
793 mov DWORD PTR 8[esp],eax
794 mov DWORD PTR 12[esp],ebx
795 call _BF_encrypt
796 mov eax, DWORD PTR 8[esp]
797 mov ebx, DWORD PTR 12[esp]
798 bswap eax
799 bswap ebx
800 mov DWORD PTR [edi],eax
801 mov DWORD PTR 4[edi],ebx
802 jmp $L003finish
803$L000decrypt:
804 and ebp, 4294967288
805 mov eax, DWORD PTR 16[esp]
806 mov ebx, DWORD PTR 20[esp]
807 jz $L013decrypt_finish
808L014decrypt_loop:
809 mov eax, DWORD PTR [esi]
810 mov ebx, DWORD PTR 4[esi]
811 bswap eax
812 bswap ebx
813 mov DWORD PTR 8[esp],eax
814 mov DWORD PTR 12[esp],ebx
815 call _BF_decrypt
816 mov eax, DWORD PTR 8[esp]
817 mov ebx, DWORD PTR 12[esp]
818 bswap eax
819 bswap ebx
820 mov ecx, DWORD PTR 16[esp]
821 mov edx, DWORD PTR 20[esp]
822 xor ecx, eax
823 xor edx, ebx
824 mov eax, DWORD PTR [esi]
825 mov ebx, DWORD PTR 4[esi]
826 mov DWORD PTR [edi],ecx
827 mov DWORD PTR 4[edi],edx
828 mov DWORD PTR 16[esp],eax
829 mov DWORD PTR 20[esp],ebx
830 add esi, 8
831 add edi, 8
832 sub ebp, 8
833 jnz L014decrypt_loop
834$L013decrypt_finish:
835 mov ebp, DWORD PTR 52[esp]
836 and ebp, 7
837 jz $L003finish
838 mov eax, DWORD PTR [esi]
839 mov ebx, DWORD PTR 4[esi]
840 bswap eax
841 bswap ebx
842 mov DWORD PTR 8[esp],eax
843 mov DWORD PTR 12[esp],ebx
844 call _BF_decrypt
845 mov eax, DWORD PTR 8[esp]
846 mov ebx, DWORD PTR 12[esp]
847 bswap eax
848 bswap ebx
849 mov ecx, DWORD PTR 16[esp]
850 mov edx, DWORD PTR 20[esp]
851 xor ecx, eax
852 xor edx, ebx
853 mov eax, DWORD PTR [esi]
854 mov ebx, DWORD PTR 4[esi]
855L015dj7:
856 ror edx, 16
857 mov BYTE PTR 6[edi],dl
858 shr edx, 16
859L016dj6:
860 mov BYTE PTR 5[edi],dh
861L017dj5:
862 mov BYTE PTR 4[edi],dl
863L018dj4:
864 mov DWORD PTR [edi],ecx
865 jmp $L019djend
866L020dj3:
867 ror ecx, 16
868 mov BYTE PTR 2[edi],cl
869 shl ecx, 16
870L021dj2:
871 mov BYTE PTR 1[esi],ch
872L022dj1:
873 mov BYTE PTR [esi], cl
874$L019djend:
875 jmp $L003finish
876$L003finish:
877 mov ecx, DWORD PTR 60[esp]
878 add esp, 24
879 mov DWORD PTR [ecx],eax
880 mov DWORD PTR 4[ecx],ebx
881 pop edi
882 pop esi
883 pop ebx
884 pop ebp
885 ret
886$L004cbc_enc_jmp_table:
887 DD 0
888 DD L012ej1
889 DD L011ej2
890 DD L010ej3
891 DD L008ej4
892 DD L007ej5
893 DD L006ej6
894 DD L005ej7
895L023cbc_dec_jmp_table:
896 DD 0
897 DD L022dj1
898 DD L021dj2
899 DD L020dj3
900 DD L018dj4
901 DD L017dj5
902 DD L016dj6
903 DD L015dj7
904_BF_cbc_encrypt ENDP
905_TEXT ENDS
906END
diff --git a/src/lib/libcrypto/bf/asm/bx86unix.cpp b/src/lib/libcrypto/bf/asm/bx86unix.cpp
new file mode 100644
index 0000000000..cdaa269378
--- /dev/null
+++ b/src/lib/libcrypto/bf/asm/bx86unix.cpp
@@ -0,0 +1,976 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define BF_encrypt _BF_encrypt
13#define BF_decrypt _BF_decrypt
14#define BF_cbc_encrypt _BF_cbc_encrypt
15
16#endif
17
18#ifdef OUT
19#define OK 1
20#define ALIGN 4
21#endif
22
23#ifdef BSDI
24#define OK 1
25#define ALIGN 4
26#undef SIZE
27#undef TYPE
28#define SIZE(a,b)
29#define TYPE(a,b)
30#endif
31
32#if defined(ELF) || defined(SOL)
33#define OK 1
34#define ALIGN 16
35#endif
36
37#ifndef OK
38You need to define one of
39ELF - elf systems - linux-elf, NetBSD and DG-UX
40OUT - a.out systems - linux-a.out and FreeBSD
41SOL - solaris systems, which are elf with strange comment lines
42BSDI - a.out with a very primative version of as.
43#endif
44
45/* Let the Assembler begin :-) */
46 /* Don't even think of reading this code */
47 /* It was automatically generated by bf-586.pl */
48 /* Which is a perl program used to generate the x86 assember for */
49 /* any of elf, a.out, BSDI,Win32, or Solaris */
50 /* eric <eay@cryptsoft.com> */
51
52 .file "bf-586.s"
53 .version "01.01"
54gcc2_compiled.:
55.text
56 .align ALIGN
57.globl BF_encrypt
58 TYPE(BF_encrypt,@function)
59BF_encrypt:
60
61 pushl %ebp
62 pushl %ebx
63 movl 12(%esp), %ebx
64 movl 16(%esp), %ebp
65 pushl %esi
66 pushl %edi
67 /* Load the 2 words */
68 movl (%ebx), %edi
69 movl 4(%ebx), %esi
70 xorl %eax, %eax
71 movl (%ebp), %ebx
72 xorl %ecx, %ecx
73 xorl %ebx, %edi
74
75 /* Round 0 */
76 movl 4(%ebp), %edx
77 movl %edi, %ebx
78 xorl %edx, %esi
79 shrl $16, %ebx
80 movl %edi, %edx
81 movb %bh, %al
82 andl $255, %ebx
83 movb %dh, %cl
84 andl $255, %edx
85 movl 72(%ebp,%eax,4),%eax
86 movl 1096(%ebp,%ebx,4),%ebx
87 addl %eax, %ebx
88 movl 2120(%ebp,%ecx,4),%eax
89 xorl %eax, %ebx
90 movl 3144(%ebp,%edx,4),%edx
91 addl %edx, %ebx
92 xorl %eax, %eax
93 xorl %ebx, %esi
94
95 /* Round 1 */
96 movl 8(%ebp), %edx
97 movl %esi, %ebx
98 xorl %edx, %edi
99 shrl $16, %ebx
100 movl %esi, %edx
101 movb %bh, %al
102 andl $255, %ebx
103 movb %dh, %cl
104 andl $255, %edx
105 movl 72(%ebp,%eax,4),%eax
106 movl 1096(%ebp,%ebx,4),%ebx
107 addl %eax, %ebx
108 movl 2120(%ebp,%ecx,4),%eax
109 xorl %eax, %ebx
110 movl 3144(%ebp,%edx,4),%edx
111 addl %edx, %ebx
112 xorl %eax, %eax
113 xorl %ebx, %edi
114
115 /* Round 2 */
116 movl 12(%ebp), %edx
117 movl %edi, %ebx
118 xorl %edx, %esi
119 shrl $16, %ebx
120 movl %edi, %edx
121 movb %bh, %al
122 andl $255, %ebx
123 movb %dh, %cl
124 andl $255, %edx
125 movl 72(%ebp,%eax,4),%eax
126 movl 1096(%ebp,%ebx,4),%ebx
127 addl %eax, %ebx
128 movl 2120(%ebp,%ecx,4),%eax
129 xorl %eax, %ebx
130 movl 3144(%ebp,%edx,4),%edx
131 addl %edx, %ebx
132 xorl %eax, %eax
133 xorl %ebx, %esi
134
135 /* Round 3 */
136 movl 16(%ebp), %edx
137 movl %esi, %ebx
138 xorl %edx, %edi
139 shrl $16, %ebx
140 movl %esi, %edx
141 movb %bh, %al
142 andl $255, %ebx
143 movb %dh, %cl
144 andl $255, %edx
145 movl 72(%ebp,%eax,4),%eax
146 movl 1096(%ebp,%ebx,4),%ebx
147 addl %eax, %ebx
148 movl 2120(%ebp,%ecx,4),%eax
149 xorl %eax, %ebx
150 movl 3144(%ebp,%edx,4),%edx
151 addl %edx, %ebx
152 xorl %eax, %eax
153 xorl %ebx, %edi
154
155 /* Round 4 */
156 movl 20(%ebp), %edx
157 movl %edi, %ebx
158 xorl %edx, %esi
159 shrl $16, %ebx
160 movl %edi, %edx
161 movb %bh, %al
162 andl $255, %ebx
163 movb %dh, %cl
164 andl $255, %edx
165 movl 72(%ebp,%eax,4),%eax
166 movl 1096(%ebp,%ebx,4),%ebx
167 addl %eax, %ebx
168 movl 2120(%ebp,%ecx,4),%eax
169 xorl %eax, %ebx
170 movl 3144(%ebp,%edx,4),%edx
171 addl %edx, %ebx
172 xorl %eax, %eax
173 xorl %ebx, %esi
174
175 /* Round 5 */
176 movl 24(%ebp), %edx
177 movl %esi, %ebx
178 xorl %edx, %edi
179 shrl $16, %ebx
180 movl %esi, %edx
181 movb %bh, %al
182 andl $255, %ebx
183 movb %dh, %cl
184 andl $255, %edx
185 movl 72(%ebp,%eax,4),%eax
186 movl 1096(%ebp,%ebx,4),%ebx
187 addl %eax, %ebx
188 movl 2120(%ebp,%ecx,4),%eax
189 xorl %eax, %ebx
190 movl 3144(%ebp,%edx,4),%edx
191 addl %edx, %ebx
192 xorl %eax, %eax
193 xorl %ebx, %edi
194
195 /* Round 6 */
196 movl 28(%ebp), %edx
197 movl %edi, %ebx
198 xorl %edx, %esi
199 shrl $16, %ebx
200 movl %edi, %edx
201 movb %bh, %al
202 andl $255, %ebx
203 movb %dh, %cl
204 andl $255, %edx
205 movl 72(%ebp,%eax,4),%eax
206 movl 1096(%ebp,%ebx,4),%ebx
207 addl %eax, %ebx
208 movl 2120(%ebp,%ecx,4),%eax
209 xorl %eax, %ebx
210 movl 3144(%ebp,%edx,4),%edx
211 addl %edx, %ebx
212 xorl %eax, %eax
213 xorl %ebx, %esi
214
215 /* Round 7 */
216 movl 32(%ebp), %edx
217 movl %esi, %ebx
218 xorl %edx, %edi
219 shrl $16, %ebx
220 movl %esi, %edx
221 movb %bh, %al
222 andl $255, %ebx
223 movb %dh, %cl
224 andl $255, %edx
225 movl 72(%ebp,%eax,4),%eax
226 movl 1096(%ebp,%ebx,4),%ebx
227 addl %eax, %ebx
228 movl 2120(%ebp,%ecx,4),%eax
229 xorl %eax, %ebx
230 movl 3144(%ebp,%edx,4),%edx
231 addl %edx, %ebx
232 xorl %eax, %eax
233 xorl %ebx, %edi
234
235 /* Round 8 */
236 movl 36(%ebp), %edx
237 movl %edi, %ebx
238 xorl %edx, %esi
239 shrl $16, %ebx
240 movl %edi, %edx
241 movb %bh, %al
242 andl $255, %ebx
243 movb %dh, %cl
244 andl $255, %edx
245 movl 72(%ebp,%eax,4),%eax
246 movl 1096(%ebp,%ebx,4),%ebx
247 addl %eax, %ebx
248 movl 2120(%ebp,%ecx,4),%eax
249 xorl %eax, %ebx
250 movl 3144(%ebp,%edx,4),%edx
251 addl %edx, %ebx
252 xorl %eax, %eax
253 xorl %ebx, %esi
254
255 /* Round 9 */
256 movl 40(%ebp), %edx
257 movl %esi, %ebx
258 xorl %edx, %edi
259 shrl $16, %ebx
260 movl %esi, %edx
261 movb %bh, %al
262 andl $255, %ebx
263 movb %dh, %cl
264 andl $255, %edx
265 movl 72(%ebp,%eax,4),%eax
266 movl 1096(%ebp,%ebx,4),%ebx
267 addl %eax, %ebx
268 movl 2120(%ebp,%ecx,4),%eax
269 xorl %eax, %ebx
270 movl 3144(%ebp,%edx,4),%edx
271 addl %edx, %ebx
272 xorl %eax, %eax
273 xorl %ebx, %edi
274
275 /* Round 10 */
276 movl 44(%ebp), %edx
277 movl %edi, %ebx
278 xorl %edx, %esi
279 shrl $16, %ebx
280 movl %edi, %edx
281 movb %bh, %al
282 andl $255, %ebx
283 movb %dh, %cl
284 andl $255, %edx
285 movl 72(%ebp,%eax,4),%eax
286 movl 1096(%ebp,%ebx,4),%ebx
287 addl %eax, %ebx
288 movl 2120(%ebp,%ecx,4),%eax
289 xorl %eax, %ebx
290 movl 3144(%ebp,%edx,4),%edx
291 addl %edx, %ebx
292 xorl %eax, %eax
293 xorl %ebx, %esi
294
295 /* Round 11 */
296 movl 48(%ebp), %edx
297 movl %esi, %ebx
298 xorl %edx, %edi
299 shrl $16, %ebx
300 movl %esi, %edx
301 movb %bh, %al
302 andl $255, %ebx
303 movb %dh, %cl
304 andl $255, %edx
305 movl 72(%ebp,%eax,4),%eax
306 movl 1096(%ebp,%ebx,4),%ebx
307 addl %eax, %ebx
308 movl 2120(%ebp,%ecx,4),%eax
309 xorl %eax, %ebx
310 movl 3144(%ebp,%edx,4),%edx
311 addl %edx, %ebx
312 xorl %eax, %eax
313 xorl %ebx, %edi
314
315 /* Round 12 */
316 movl 52(%ebp), %edx
317 movl %edi, %ebx
318 xorl %edx, %esi
319 shrl $16, %ebx
320 movl %edi, %edx
321 movb %bh, %al
322 andl $255, %ebx
323 movb %dh, %cl
324 andl $255, %edx
325 movl 72(%ebp,%eax,4),%eax
326 movl 1096(%ebp,%ebx,4),%ebx
327 addl %eax, %ebx
328 movl 2120(%ebp,%ecx,4),%eax
329 xorl %eax, %ebx
330 movl 3144(%ebp,%edx,4),%edx
331 addl %edx, %ebx
332 xorl %eax, %eax
333 xorl %ebx, %esi
334
335 /* Round 13 */
336 movl 56(%ebp), %edx
337 movl %esi, %ebx
338 xorl %edx, %edi
339 shrl $16, %ebx
340 movl %esi, %edx
341 movb %bh, %al
342 andl $255, %ebx
343 movb %dh, %cl
344 andl $255, %edx
345 movl 72(%ebp,%eax,4),%eax
346 movl 1096(%ebp,%ebx,4),%ebx
347 addl %eax, %ebx
348 movl 2120(%ebp,%ecx,4),%eax
349 xorl %eax, %ebx
350 movl 3144(%ebp,%edx,4),%edx
351 addl %edx, %ebx
352 xorl %eax, %eax
353 xorl %ebx, %edi
354
355 /* Round 14 */
356 movl 60(%ebp), %edx
357 movl %edi, %ebx
358 xorl %edx, %esi
359 shrl $16, %ebx
360 movl %edi, %edx
361 movb %bh, %al
362 andl $255, %ebx
363 movb %dh, %cl
364 andl $255, %edx
365 movl 72(%ebp,%eax,4),%eax
366 movl 1096(%ebp,%ebx,4),%ebx
367 addl %eax, %ebx
368 movl 2120(%ebp,%ecx,4),%eax
369 xorl %eax, %ebx
370 movl 3144(%ebp,%edx,4),%edx
371 addl %edx, %ebx
372 xorl %eax, %eax
373 xorl %ebx, %esi
374
375 /* Round 15 */
376 movl 64(%ebp), %edx
377 movl %esi, %ebx
378 xorl %edx, %edi
379 shrl $16, %ebx
380 movl %esi, %edx
381 movb %bh, %al
382 andl $255, %ebx
383 movb %dh, %cl
384 andl $255, %edx
385 movl 72(%ebp,%eax,4),%eax
386 movl 1096(%ebp,%ebx,4),%ebx
387 addl %eax, %ebx
388 movl 2120(%ebp,%ecx,4),%eax
389 xorl %eax, %ebx
390 movl 3144(%ebp,%edx,4),%edx
391 addl %edx, %ebx
392 /* Load parameter 0 (16) enc=1 */
393 movl 20(%esp), %eax
394 xorl %ebx, %edi
395 movl 68(%ebp), %edx
396 xorl %edx, %esi
397 movl %edi, 4(%eax)
398 movl %esi, (%eax)
399 popl %edi
400 popl %esi
401 popl %ebx
402 popl %ebp
403 ret
404.BF_encrypt_end:
405 SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt)
406.ident "BF_encrypt"
407.text
408 .align ALIGN
409.globl BF_decrypt
410 TYPE(BF_decrypt,@function)
411BF_decrypt:
412
413 pushl %ebp
414 pushl %ebx
415 movl 12(%esp), %ebx
416 movl 16(%esp), %ebp
417 pushl %esi
418 pushl %edi
419 /* Load the 2 words */
420 movl (%ebx), %edi
421 movl 4(%ebx), %esi
422 xorl %eax, %eax
423 movl 68(%ebp), %ebx
424 xorl %ecx, %ecx
425 xorl %ebx, %edi
426
427 /* Round 16 */
428 movl 64(%ebp), %edx
429 movl %edi, %ebx
430 xorl %edx, %esi
431 shrl $16, %ebx
432 movl %edi, %edx
433 movb %bh, %al
434 andl $255, %ebx
435 movb %dh, %cl
436 andl $255, %edx
437 movl 72(%ebp,%eax,4),%eax
438 movl 1096(%ebp,%ebx,4),%ebx
439 addl %eax, %ebx
440 movl 2120(%ebp,%ecx,4),%eax
441 xorl %eax, %ebx
442 movl 3144(%ebp,%edx,4),%edx
443 addl %edx, %ebx
444 xorl %eax, %eax
445 xorl %ebx, %esi
446
447 /* Round 15 */
448 movl 60(%ebp), %edx
449 movl %esi, %ebx
450 xorl %edx, %edi
451 shrl $16, %ebx
452 movl %esi, %edx
453 movb %bh, %al
454 andl $255, %ebx
455 movb %dh, %cl
456 andl $255, %edx
457 movl 72(%ebp,%eax,4),%eax
458 movl 1096(%ebp,%ebx,4),%ebx
459 addl %eax, %ebx
460 movl 2120(%ebp,%ecx,4),%eax
461 xorl %eax, %ebx
462 movl 3144(%ebp,%edx,4),%edx
463 addl %edx, %ebx
464 xorl %eax, %eax
465 xorl %ebx, %edi
466
467 /* Round 14 */
468 movl 56(%ebp), %edx
469 movl %edi, %ebx
470 xorl %edx, %esi
471 shrl $16, %ebx
472 movl %edi, %edx
473 movb %bh, %al
474 andl $255, %ebx
475 movb %dh, %cl
476 andl $255, %edx
477 movl 72(%ebp,%eax,4),%eax
478 movl 1096(%ebp,%ebx,4),%ebx
479 addl %eax, %ebx
480 movl 2120(%ebp,%ecx,4),%eax
481 xorl %eax, %ebx
482 movl 3144(%ebp,%edx,4),%edx
483 addl %edx, %ebx
484 xorl %eax, %eax
485 xorl %ebx, %esi
486
487 /* Round 13 */
488 movl 52(%ebp), %edx
489 movl %esi, %ebx
490 xorl %edx, %edi
491 shrl $16, %ebx
492 movl %esi, %edx
493 movb %bh, %al
494 andl $255, %ebx
495 movb %dh, %cl
496 andl $255, %edx
497 movl 72(%ebp,%eax,4),%eax
498 movl 1096(%ebp,%ebx,4),%ebx
499 addl %eax, %ebx
500 movl 2120(%ebp,%ecx,4),%eax
501 xorl %eax, %ebx
502 movl 3144(%ebp,%edx,4),%edx
503 addl %edx, %ebx
504 xorl %eax, %eax
505 xorl %ebx, %edi
506
507 /* Round 12 */
508 movl 48(%ebp), %edx
509 movl %edi, %ebx
510 xorl %edx, %esi
511 shrl $16, %ebx
512 movl %edi, %edx
513 movb %bh, %al
514 andl $255, %ebx
515 movb %dh, %cl
516 andl $255, %edx
517 movl 72(%ebp,%eax,4),%eax
518 movl 1096(%ebp,%ebx,4),%ebx
519 addl %eax, %ebx
520 movl 2120(%ebp,%ecx,4),%eax
521 xorl %eax, %ebx
522 movl 3144(%ebp,%edx,4),%edx
523 addl %edx, %ebx
524 xorl %eax, %eax
525 xorl %ebx, %esi
526
527 /* Round 11 */
528 movl 44(%ebp), %edx
529 movl %esi, %ebx
530 xorl %edx, %edi
531 shrl $16, %ebx
532 movl %esi, %edx
533 movb %bh, %al
534 andl $255, %ebx
535 movb %dh, %cl
536 andl $255, %edx
537 movl 72(%ebp,%eax,4),%eax
538 movl 1096(%ebp,%ebx,4),%ebx
539 addl %eax, %ebx
540 movl 2120(%ebp,%ecx,4),%eax
541 xorl %eax, %ebx
542 movl 3144(%ebp,%edx,4),%edx
543 addl %edx, %ebx
544 xorl %eax, %eax
545 xorl %ebx, %edi
546
547 /* Round 10 */
548 movl 40(%ebp), %edx
549 movl %edi, %ebx
550 xorl %edx, %esi
551 shrl $16, %ebx
552 movl %edi, %edx
553 movb %bh, %al
554 andl $255, %ebx
555 movb %dh, %cl
556 andl $255, %edx
557 movl 72(%ebp,%eax,4),%eax
558 movl 1096(%ebp,%ebx,4),%ebx
559 addl %eax, %ebx
560 movl 2120(%ebp,%ecx,4),%eax
561 xorl %eax, %ebx
562 movl 3144(%ebp,%edx,4),%edx
563 addl %edx, %ebx
564 xorl %eax, %eax
565 xorl %ebx, %esi
566
567 /* Round 9 */
568 movl 36(%ebp), %edx
569 movl %esi, %ebx
570 xorl %edx, %edi
571 shrl $16, %ebx
572 movl %esi, %edx
573 movb %bh, %al
574 andl $255, %ebx
575 movb %dh, %cl
576 andl $255, %edx
577 movl 72(%ebp,%eax,4),%eax
578 movl 1096(%ebp,%ebx,4),%ebx
579 addl %eax, %ebx
580 movl 2120(%ebp,%ecx,4),%eax
581 xorl %eax, %ebx
582 movl 3144(%ebp,%edx,4),%edx
583 addl %edx, %ebx
584 xorl %eax, %eax
585 xorl %ebx, %edi
586
587 /* Round 8 */
588 movl 32(%ebp), %edx
589 movl %edi, %ebx
590 xorl %edx, %esi
591 shrl $16, %ebx
592 movl %edi, %edx
593 movb %bh, %al
594 andl $255, %ebx
595 movb %dh, %cl
596 andl $255, %edx
597 movl 72(%ebp,%eax,4),%eax
598 movl 1096(%ebp,%ebx,4),%ebx
599 addl %eax, %ebx
600 movl 2120(%ebp,%ecx,4),%eax
601 xorl %eax, %ebx
602 movl 3144(%ebp,%edx,4),%edx
603 addl %edx, %ebx
604 xorl %eax, %eax
605 xorl %ebx, %esi
606
607 /* Round 7 */
608 movl 28(%ebp), %edx
609 movl %esi, %ebx
610 xorl %edx, %edi
611 shrl $16, %ebx
612 movl %esi, %edx
613 movb %bh, %al
614 andl $255, %ebx
615 movb %dh, %cl
616 andl $255, %edx
617 movl 72(%ebp,%eax,4),%eax
618 movl 1096(%ebp,%ebx,4),%ebx
619 addl %eax, %ebx
620 movl 2120(%ebp,%ecx,4),%eax
621 xorl %eax, %ebx
622 movl 3144(%ebp,%edx,4),%edx
623 addl %edx, %ebx
624 xorl %eax, %eax
625 xorl %ebx, %edi
626
627 /* Round 6 */
628 movl 24(%ebp), %edx
629 movl %edi, %ebx
630 xorl %edx, %esi
631 shrl $16, %ebx
632 movl %edi, %edx
633 movb %bh, %al
634 andl $255, %ebx
635 movb %dh, %cl
636 andl $255, %edx
637 movl 72(%ebp,%eax,4),%eax
638 movl 1096(%ebp,%ebx,4),%ebx
639 addl %eax, %ebx
640 movl 2120(%ebp,%ecx,4),%eax
641 xorl %eax, %ebx
642 movl 3144(%ebp,%edx,4),%edx
643 addl %edx, %ebx
644 xorl %eax, %eax
645 xorl %ebx, %esi
646
647 /* Round 5 */
648 movl 20(%ebp), %edx
649 movl %esi, %ebx
650 xorl %edx, %edi
651 shrl $16, %ebx
652 movl %esi, %edx
653 movb %bh, %al
654 andl $255, %ebx
655 movb %dh, %cl
656 andl $255, %edx
657 movl 72(%ebp,%eax,4),%eax
658 movl 1096(%ebp,%ebx,4),%ebx
659 addl %eax, %ebx
660 movl 2120(%ebp,%ecx,4),%eax
661 xorl %eax, %ebx
662 movl 3144(%ebp,%edx,4),%edx
663 addl %edx, %ebx
664 xorl %eax, %eax
665 xorl %ebx, %edi
666
667 /* Round 4 */
668 movl 16(%ebp), %edx
669 movl %edi, %ebx
670 xorl %edx, %esi
671 shrl $16, %ebx
672 movl %edi, %edx
673 movb %bh, %al
674 andl $255, %ebx
675 movb %dh, %cl
676 andl $255, %edx
677 movl 72(%ebp,%eax,4),%eax
678 movl 1096(%ebp,%ebx,4),%ebx
679 addl %eax, %ebx
680 movl 2120(%ebp,%ecx,4),%eax
681 xorl %eax, %ebx
682 movl 3144(%ebp,%edx,4),%edx
683 addl %edx, %ebx
684 xorl %eax, %eax
685 xorl %ebx, %esi
686
687 /* Round 3 */
688 movl 12(%ebp), %edx
689 movl %esi, %ebx
690 xorl %edx, %edi
691 shrl $16, %ebx
692 movl %esi, %edx
693 movb %bh, %al
694 andl $255, %ebx
695 movb %dh, %cl
696 andl $255, %edx
697 movl 72(%ebp,%eax,4),%eax
698 movl 1096(%ebp,%ebx,4),%ebx
699 addl %eax, %ebx
700 movl 2120(%ebp,%ecx,4),%eax
701 xorl %eax, %ebx
702 movl 3144(%ebp,%edx,4),%edx
703 addl %edx, %ebx
704 xorl %eax, %eax
705 xorl %ebx, %edi
706
707 /* Round 2 */
708 movl 8(%ebp), %edx
709 movl %edi, %ebx
710 xorl %edx, %esi
711 shrl $16, %ebx
712 movl %edi, %edx
713 movb %bh, %al
714 andl $255, %ebx
715 movb %dh, %cl
716 andl $255, %edx
717 movl 72(%ebp,%eax,4),%eax
718 movl 1096(%ebp,%ebx,4),%ebx
719 addl %eax, %ebx
720 movl 2120(%ebp,%ecx,4),%eax
721 xorl %eax, %ebx
722 movl 3144(%ebp,%edx,4),%edx
723 addl %edx, %ebx
724 xorl %eax, %eax
725 xorl %ebx, %esi
726
727 /* Round 1 */
728 movl 4(%ebp), %edx
729 movl %esi, %ebx
730 xorl %edx, %edi
731 shrl $16, %ebx
732 movl %esi, %edx
733 movb %bh, %al
734 andl $255, %ebx
735 movb %dh, %cl
736 andl $255, %edx
737 movl 72(%ebp,%eax,4),%eax
738 movl 1096(%ebp,%ebx,4),%ebx
739 addl %eax, %ebx
740 movl 2120(%ebp,%ecx,4),%eax
741 xorl %eax, %ebx
742 movl 3144(%ebp,%edx,4),%edx
743 addl %edx, %ebx
744 /* Load parameter 0 (1) enc=0 */
745 movl 20(%esp), %eax
746 xorl %ebx, %edi
747 movl (%ebp), %edx
748 xorl %edx, %esi
749 movl %edi, 4(%eax)
750 movl %esi, (%eax)
751 popl %edi
752 popl %esi
753 popl %ebx
754 popl %ebp
755 ret
756.BF_decrypt_end:
757 SIZE(BF_decrypt,.BF_decrypt_end-BF_decrypt)
758.ident "BF_decrypt"
759.text
760 .align ALIGN
761.globl BF_cbc_encrypt
762 TYPE(BF_cbc_encrypt,@function)
763BF_cbc_encrypt:
764
765 pushl %ebp
766 pushl %ebx
767 pushl %esi
768 pushl %edi
769 movl 28(%esp), %ebp
770 /* getting iv ptr from parameter 4 */
771 movl 36(%esp), %ebx
772 movl (%ebx), %esi
773 movl 4(%ebx), %edi
774 pushl %edi
775 pushl %esi
776 pushl %edi
777 pushl %esi
778 movl %esp, %ebx
779 movl 36(%esp), %esi
780 movl 40(%esp), %edi
781 /* getting encrypt flag from parameter 5 */
782 movl 56(%esp), %ecx
783 /* get and push parameter 3 */
784 movl 48(%esp), %eax
785 pushl %eax
786 pushl %ebx
787 cmpl $0, %ecx
788 jz .L000decrypt
789 andl $4294967288, %ebp
790 movl 8(%esp), %eax
791 movl 12(%esp), %ebx
792 jz .L001encrypt_finish
793.L002encrypt_loop:
794 movl (%esi), %ecx
795 movl 4(%esi), %edx
796 xorl %ecx, %eax
797 xorl %edx, %ebx
798.byte 15
799.byte 200 /* bswapl %eax */
800.byte 15
801.byte 203 /* bswapl %ebx */
802 movl %eax, 8(%esp)
803 movl %ebx, 12(%esp)
804 call BF_encrypt
805 movl 8(%esp), %eax
806 movl 12(%esp), %ebx
807.byte 15
808.byte 200 /* bswapl %eax */
809.byte 15
810.byte 203 /* bswapl %ebx */
811 movl %eax, (%edi)
812 movl %ebx, 4(%edi)
813 addl $8, %esi
814 addl $8, %edi
815 subl $8, %ebp
816 jnz .L002encrypt_loop
817.L001encrypt_finish:
818 movl 52(%esp), %ebp
819 andl $7, %ebp
820 jz .L003finish
821 xorl %ecx, %ecx
822 xorl %edx, %edx
823 movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp
824 jmp *%ebp
825.L005ej7:
826 movb 6(%esi), %dh
827 sall $8, %edx
828.L006ej6:
829 movb 5(%esi), %dh
830.L007ej5:
831 movb 4(%esi), %dl
832.L008ej4:
833 movl (%esi), %ecx
834 jmp .L009ejend
835.L010ej3:
836 movb 2(%esi), %ch
837 sall $8, %ecx
838.L011ej2:
839 movb 1(%esi), %ch
840.L012ej1:
841 movb (%esi), %cl
842.L009ejend:
843 xorl %ecx, %eax
844 xorl %edx, %ebx
845.byte 15
846.byte 200 /* bswapl %eax */
847.byte 15
848.byte 203 /* bswapl %ebx */
849 movl %eax, 8(%esp)
850 movl %ebx, 12(%esp)
851 call BF_encrypt
852 movl 8(%esp), %eax
853 movl 12(%esp), %ebx
854.byte 15
855.byte 200 /* bswapl %eax */
856.byte 15
857.byte 203 /* bswapl %ebx */
858 movl %eax, (%edi)
859 movl %ebx, 4(%edi)
860 jmp .L003finish
861.align ALIGN
862.L000decrypt:
863 andl $4294967288, %ebp
864 movl 16(%esp), %eax
865 movl 20(%esp), %ebx
866 jz .L013decrypt_finish
867.L014decrypt_loop:
868 movl (%esi), %eax
869 movl 4(%esi), %ebx
870.byte 15
871.byte 200 /* bswapl %eax */
872.byte 15
873.byte 203 /* bswapl %ebx */
874 movl %eax, 8(%esp)
875 movl %ebx, 12(%esp)
876 call BF_decrypt
877 movl 8(%esp), %eax
878 movl 12(%esp), %ebx
879.byte 15
880.byte 200 /* bswapl %eax */
881.byte 15
882.byte 203 /* bswapl %ebx */
883 movl 16(%esp), %ecx
884 movl 20(%esp), %edx
885 xorl %eax, %ecx
886 xorl %ebx, %edx
887 movl (%esi), %eax
888 movl 4(%esi), %ebx
889 movl %ecx, (%edi)
890 movl %edx, 4(%edi)
891 movl %eax, 16(%esp)
892 movl %ebx, 20(%esp)
893 addl $8, %esi
894 addl $8, %edi
895 subl $8, %ebp
896 jnz .L014decrypt_loop
897.L013decrypt_finish:
898 movl 52(%esp), %ebp
899 andl $7, %ebp
900 jz .L003finish
901 movl (%esi), %eax
902 movl 4(%esi), %ebx
903.byte 15
904.byte 200 /* bswapl %eax */
905.byte 15
906.byte 203 /* bswapl %ebx */
907 movl %eax, 8(%esp)
908 movl %ebx, 12(%esp)
909 call BF_decrypt
910 movl 8(%esp), %eax
911 movl 12(%esp), %ebx
912.byte 15
913.byte 200 /* bswapl %eax */
914.byte 15
915.byte 203 /* bswapl %ebx */
916 movl 16(%esp), %ecx
917 movl 20(%esp), %edx
918 xorl %eax, %ecx
919 xorl %ebx, %edx
920 movl (%esi), %eax
921 movl 4(%esi), %ebx
922.L015dj7:
923 rorl $16, %edx
924 movb %dl, 6(%edi)
925 shrl $16, %edx
926.L016dj6:
927 movb %dh, 5(%edi)
928.L017dj5:
929 movb %dl, 4(%edi)
930.L018dj4:
931 movl %ecx, (%edi)
932 jmp .L019djend
933.L020dj3:
934 rorl $16, %ecx
935 movb %cl, 2(%edi)
936 sall $16, %ecx
937.L021dj2:
938 movb %ch, 1(%esi)
939.L022dj1:
940 movb %cl, (%esi)
941.L019djend:
942 jmp .L003finish
943.align ALIGN
944.L003finish:
945 movl 60(%esp), %ecx
946 addl $24, %esp
947 movl %eax, (%ecx)
948 movl %ebx, 4(%ecx)
949 popl %edi
950 popl %esi
951 popl %ebx
952 popl %ebp
953 ret
954.align ALIGN
955.L004cbc_enc_jmp_table:
956 .long 0
957 .long .L012ej1
958 .long .L011ej2
959 .long .L010ej3
960 .long .L008ej4
961 .long .L007ej5
962 .long .L006ej6
963 .long .L005ej7
964.align ALIGN
965.L023cbc_dec_jmp_table:
966 .long 0
967 .long .L022dj1
968 .long .L021dj2
969 .long .L020dj3
970 .long .L018dj4
971 .long .L017dj5
972 .long .L016dj6
973 .long .L015dj7
974.BF_cbc_encrypt_end:
975 SIZE(BF_cbc_encrypt,.BF_cbc_encrypt_end-BF_cbc_encrypt)
976.ident "desasm.pl"
diff --git a/src/lib/libcrypto/bf/bf_locl.org b/src/lib/libcrypto/bf/bf_locl.org
new file mode 100644
index 0000000000..a5663de8ca
--- /dev/null
+++ b/src/lib/libcrypto/bf/bf_locl.org
@@ -0,0 +1,242 @@
1/* crypto/bf/bf_locl.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify bf_locl.org since bf_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67/* Special defines which change the way the code is built depending on the
68 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
69 even newer MIPS CPU's, but at the moment one size fits all for
70 optimization options. Older Sparc's work better with only UNROLL, but
71 there's no way to tell at compile time what it is you're running on */
72
73#if defined( sun ) /* Newer Sparc's */
74# define BF_PTR
75#elif defined( __ultrix ) /* Older MIPS */
76# define BF_PTR
77#elif defined( __osf1__ ) /* Alpha */
78 /* None */
79#elif defined ( _AIX ) /* RS6000 */
80 /* Unknown */
81#elif defined( __hpux ) /* HP-PA */
82 /* None */
83#elif defined( __aux ) /* 68K */
84 /* Unknown */
85#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
86 /* Unknown */
87#elif defined( __sgi ) /* Newer MIPS */
88# define BF_PTR
89#elif defined( i386 ) /* x86 boxes, should be gcc */
90#elif defined( _MSC_VER ) /* x86 boxes, Visual C */
91#endif /* Systems-specific speed defines */
92
93#undef c2l
94#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
95 l|=((unsigned long)(*((c)++)))<< 8L, \
96 l|=((unsigned long)(*((c)++)))<<16L, \
97 l|=((unsigned long)(*((c)++)))<<24L)
98
99/* NOTE - c is not incremented as per c2l */
100#undef c2ln
101#define c2ln(c,l1,l2,n) { \
102 c+=n; \
103 l1=l2=0; \
104 switch (n) { \
105 case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
106 case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
107 case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
108 case 5: l2|=((unsigned long)(*(--(c)))); \
109 case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
110 case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
111 case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
112 case 1: l1|=((unsigned long)(*(--(c)))); \
113 } \
114 }
115
116#undef l2c
117#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
118 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
119 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
120 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
121
122/* NOTE - c is not incremented as per l2c */
123#undef l2cn
124#define l2cn(l1,l2,c,n) { \
125 c+=n; \
126 switch (n) { \
127 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
128 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
129 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
130 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
131 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
132 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
133 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
134 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
135 } \
136 }
137
138/* NOTE - c is not incremented as per n2l */
139#define n2ln(c,l1,l2,n) { \
140 c+=n; \
141 l1=l2=0; \
142 switch (n) { \
143 case 8: l2 =((unsigned long)(*(--(c)))) ; \
144 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
145 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
146 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
147 case 4: l1 =((unsigned long)(*(--(c)))) ; \
148 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
149 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
150 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
151 } \
152 }
153
154/* NOTE - c is not incremented as per l2n */
155#define l2nn(l1,l2,c,n) { \
156 c+=n; \
157 switch (n) { \
158 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
159 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
160 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
161 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
162 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
163 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
164 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
165 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
166 } \
167 }
168
169#undef n2l
170#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
171 l|=((unsigned long)(*((c)++)))<<16L, \
172 l|=((unsigned long)(*((c)++)))<< 8L, \
173 l|=((unsigned long)(*((c)++))))
174
175#undef l2n
176#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
177 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
178 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
179 *((c)++)=(unsigned char)(((l) )&0xff))
180
181/* This is actually a big endian algorithm, the most significate byte
182 * is used to lookup array 0 */
183
184/* use BF_PTR2 for intel boxes,
185 * BF_PTR for sparc and MIPS/SGI
186 * use nothing for Alpha and HP.
187 */
188#if !defined(BF_PTR) && !defined(BF_PTR2)
189#undef BF_PTR
190#endif
191
192#define BF_M 0x3fc
193#define BF_0 22L
194#define BF_1 14L
195#define BF_2 6L
196#define BF_3 2L /* left shift */
197
198#if defined(BF_PTR2)
199
200/* This is basically a special pentium verson */
201#define BF_ENC(LL,R,S,P) \
202 { \
203 BF_LONG t,u,v; \
204 u=R>>BF_0; \
205 v=R>>BF_1; \
206 u&=BF_M; \
207 v&=BF_M; \
208 t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \
209 u=R>>BF_2; \
210 t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \
211 v=R<<BF_3; \
212 u&=BF_M; \
213 v&=BF_M; \
214 t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
215 LL^=P; \
216 t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
217 LL^=t; \
218 }
219
220#elif defined(BF_PTR)
221
222/* This is normally very good */
223
224#define BF_ENC(LL,R,S,P) \
225 LL^=P; \
226 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
227 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
228 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
229 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M)));
230#else
231
232/* This will always work, even on 64 bit machines and strangly enough,
233 * on the Alpha it is faster than the pointer versions (both 32 and 64
234 * versions of BF_LONG) */
235
236#define BF_ENC(LL,R,S,P) \
237 LL^=P; \
238 LL^=((( S[ (int)(R>>24L) ] + \
239 S[0x0100+((int)(R>>16L)&0xff)])^ \
240 S[0x0200+((int)(R>> 8L)&0xff)])+ \
241 S[0x0300+((int)(R )&0xff)])&0xffffffffL;
242#endif