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.ssl45
-rw-r--r--src/lib/libcrypto/bf/Makefile.uni20
-rw-r--r--src/lib/libcrypto/bf/asm/bf-586.pl4
-rw-r--r--src/lib/libcrypto/bf/asm/bf-686.pl1
-rw-r--r--src/lib/libcrypto/bf/asm/bx86unix.cpp976
-rw-r--r--src/lib/libcrypto/bf/bf_cbc.c11
-rw-r--r--src/lib/libcrypto/bf/bf_cfb64.c12
-rw-r--r--src/lib/libcrypto/bf/bf_ecb.c14
-rw-r--r--src/lib/libcrypto/bf/bf_enc.c93
-rw-r--r--src/lib/libcrypto/bf/bf_locl.h (renamed from src/lib/libcrypto/bf/bf_locl.org)137
-rw-r--r--src/lib/libcrypto/bf/bf_ofb64.c11
-rw-r--r--src/lib/libcrypto/bf/bf_opts.c61
-rw-r--r--src/lib/libcrypto/bf/bf_skey.c7
-rw-r--r--src/lib/libcrypto/bf/bfs.cpp2
-rw-r--r--src/lib/libcrypto/bf/bfspeed.c59
-rw-r--r--src/lib/libcrypto/bf/bftest.c46
-rw-r--r--src/lib/libcrypto/bf/blowfish.h45
17 files changed, 282 insertions, 1262 deletions
diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl
index 236671f238..18bddda0db 100644
--- a/src/lib/libcrypto/bf/Makefile.ssl
+++ b/src/lib/libcrypto/bf/Makefile.ssl
@@ -8,9 +8,11 @@ CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES= 9INCLUDES=
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
11INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
14MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
15AR= ar r 17AR= ar r
16 18
@@ -42,7 +44,7 @@ all: lib
42 44
43lib: $(LIBOBJ) 45lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ) 46 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB) 47 $(RANLIB) $(LIB)
46 @touch lib 48 @touch lib
47 49
48# elf 50# elf
@@ -61,27 +63,25 @@ asm/bx86-out.o: asm/bx86unix.cpp
61 63
62# bsdi 64# bsdi
63asm/bx86bsdi.o: asm/bx86unix.cpp 65asm/bx86bsdi.o: asm/bx86unix.cpp
64 $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o 66 $(CPP) -DBSDI asm/bx86unix.cpp | sed 's/ :/:/' | as -o asm/bx86bsdi.o
65 67
66asm/bx86unix.cpp: 68asm/bx86unix.cpp:
67 (cd asm; perl bf-586.pl cpp >bx86unix.cpp) 69 (cd asm; $(PERL) bf-586.pl cpp $(PROCESSOR) >bx86unix.cpp)
68 70
69files: 71files:
70 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 72 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
71 73
72links: 74links:
73 /bin/rm -f Makefile 75 @$(TOP)/util/point.sh Makefile.ssl Makefile
74 $(TOP)/util/point.sh Makefile.ssl Makefile ; 76 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
75 $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ; 77 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
76 $(TOP)/util/mklink.sh ../../include $(EXHEADER) 78 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
77 $(TOP)/util/mklink.sh ../../test $(TEST)
78 $(TOP)/util/mklink.sh ../../apps $(APPS)
79 79
80install: 80install:
81 @for i in $(EXHEADER) ; \ 81 @for i in $(EXHEADER) ; \
82 do \ 82 do \
83 (cp $$i $(INSTALLTOP)/include/$$i; \ 83 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
84 chmod 644 $(INSTALLTOP)/include/$$i ); \ 84 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
85 done; 85 done;
86 86
87tags: 87tags:
@@ -93,15 +93,24 @@ lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff 93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94 94
95depend: 95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) 96 $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
97 97
98dclean: 98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 99 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE) 100 mv -f Makefile.new $(MAKEFILE)
101 101
102clean: 102clean:
103 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 103 rm -f asm/bx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105errors:
106 104
107# DO NOT DELETE THIS LINE -- make depend depends on it. 105# DO NOT DELETE THIS LINE -- make depend depends on it.
106
107bf_cfb64.o: ../../include/openssl/blowfish.h
108bf_cfb64.o: ../../include/openssl/opensslconf.h bf_locl.h
109bf_ecb.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h
110bf_ecb.o: ../../include/openssl/opensslv.h bf_locl.h
111bf_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h
112bf_enc.o: bf_locl.h
113bf_ofb64.o: ../../include/openssl/blowfish.h
114bf_ofb64.o: ../../include/openssl/opensslconf.h bf_locl.h
115bf_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h
116bf_skey.o: bf_locl.h bf_pi.h
diff --git a/src/lib/libcrypto/bf/Makefile.uni b/src/lib/libcrypto/bf/Makefile.uni
index 9ba5b0c854..f67e5ca23b 100644
--- a/src/lib/libcrypto/bf/Makefile.uni
+++ b/src/lib/libcrypto/bf/Makefile.uni
@@ -29,6 +29,7 @@ CFLAG= -O3 -fomit-frame-pointer
29CFLAGS=$(OPTS) $(CFLAG) 29CFLAGS=$(OPTS) $(CFLAG)
30CPP=$(CC) -E 30CPP=$(CC) -E
31AS=as 31AS=as
32RANLIB=ranlib
32 33
33# Assember version of bf_encrypt(). 34# Assember version of bf_encrypt().
34BF_ENC=bf_enc.o # normal C version 35BF_ENC=bf_enc.o # normal C version
@@ -105,9 +106,7 @@ test: all
105$(BLIB): $(LIBOBJ) 106$(BLIB): $(LIBOBJ)
106 /bin/rm -f $(BLIB) 107 /bin/rm -f $(BLIB)
107 ar cr $(BLIB) $(LIBOBJ) 108 ar cr $(BLIB) $(LIBOBJ)
108 -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \ 109 $(RANLIB) $(BLIB)
109 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \
110 else exit 0; fi; fi
111 110
112bftest: bftest.o $(BLIB) 111bftest: bftest.o $(BLIB)
113 $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB) 112 $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB)
@@ -142,25 +141,14 @@ install: $(BLIB)
142 if test $(INSTALLTOP); then \ 141 if test $(INSTALLTOP); then \
143 echo SSL style install; \ 142 echo SSL style install; \
144 cp $(BLIB) $(INSTALLTOP)/lib; \ 143 cp $(BLIB) $(INSTALLTOP)/lib; \
145 if test -s /bin/ranlib; then \ 144 $(RANLIB) $(BLIB); \
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); \ 145 chmod 644 $(INSTALLTOP)/lib/$(BLIB); \
152 cp blowfish.h $(INSTALLTOP)/include; \ 146 cp blowfish.h $(INSTALLTOP)/include; \
153 chmod 644 $(INSTALLTOP)/include/blowfish.h; \ 147 chmod 644 $(INSTALLTOP)/include/blowfish.h; \
154 else \ 148 else \
155 echo Standalone install; \ 149 echo Standalone install; \
156 cp $(BLIB) $(LIBDIR)/$(BLIB); \ 150 cp $(BLIB) $(LIBDIR)/$(BLIB); \
157 if test -s /bin/ranlib; then \ 151 $(RANLIB) $(BLIB); \
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); \ 152 chmod 644 $(LIBDIR)/$(BLIB); \
165 cp blowfish.h $(INCDIR)/blowfish.h; \ 153 cp blowfish.h $(INCDIR)/blowfish.h; \
166 chmod 644 $(INCDIR)/blowfish.h; \ 154 chmod 644 $(INCDIR)/blowfish.h; \
diff --git a/src/lib/libcrypto/bf/asm/bf-586.pl b/src/lib/libcrypto/bf/asm/bf-586.pl
index 5c7ab14ab0..b556642c94 100644
--- a/src/lib/libcrypto/bf/asm/bf-586.pl
+++ b/src/lib/libcrypto/bf/asm/bf-586.pl
@@ -1,10 +1,10 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3push(@INC,"perlasm","../../perlasm"); 3push(@INC,"perlasm","../../perlasm");
4require "x86asm.pl"; 4require "x86asm.pl";
5require "cbc.pl"; 5require "cbc.pl";
6 6
7&asm_init($ARGV[0],"bf-586.pl"); 7&asm_init($ARGV[0],"bf-586.pl",$ARGV[$#ARGV] eq "386");
8 8
9$BF_ROUNDS=16; 9$BF_ROUNDS=16;
10$BF_OFF=($BF_ROUNDS+2)*4; 10$BF_OFF=($BF_ROUNDS+2)*4;
diff --git a/src/lib/libcrypto/bf/asm/bf-686.pl b/src/lib/libcrypto/bf/asm/bf-686.pl
index bed303d786..8e4c25f598 100644
--- a/src/lib/libcrypto/bf/asm/bf-686.pl
+++ b/src/lib/libcrypto/bf/asm/bf-686.pl
@@ -1,4 +1,3 @@
1#!/usr/bin/perl
2#!/usr/local/bin/perl 1#!/usr/local/bin/perl
3 2
4push(@INC,"perlasm","../../perlasm"); 3push(@INC,"perlasm","../../perlasm");
diff --git a/src/lib/libcrypto/bf/asm/bx86unix.cpp b/src/lib/libcrypto/bf/asm/bx86unix.cpp
deleted file mode 100644
index cdaa269378..0000000000
--- a/src/lib/libcrypto/bf/asm/bx86unix.cpp
+++ /dev/null
@@ -1,976 +0,0 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define 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_cbc.c b/src/lib/libcrypto/bf/bf_cbc.c
index e0fa9ad763..95d1cdcdf9 100644
--- a/src/lib/libcrypto/bf/bf_cbc.c
+++ b/src/lib/libcrypto/bf/bf_cbc.c
@@ -56,16 +56,11 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "blowfish.h" 59#include <openssl/blowfish.h>
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62void BF_cbc_encrypt(in, out, length, ks, iv, encrypt) 62void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
63unsigned char *in; 63 BF_KEY *ks, unsigned char *iv, int encrypt)
64unsigned char *out;
65long length;
66BF_KEY *ks;
67unsigned char *iv;
68int encrypt;
69 { 64 {
70 register BF_LONG tin0,tin1; 65 register BF_LONG tin0,tin1;
71 register BF_LONG tout0,tout1,xor0,xor1; 66 register BF_LONG tout0,tout1,xor0,xor1;
diff --git a/src/lib/libcrypto/bf/bf_cfb64.c b/src/lib/libcrypto/bf/bf_cfb64.c
index f9c66e7ced..1fb8905f49 100644
--- a/src/lib/libcrypto/bf/bf_cfb64.c
+++ b/src/lib/libcrypto/bf/bf_cfb64.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "blowfish.h" 59#include <openssl/blowfish.h>
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62/* The input and output encrypted as though 64bit cfb mode is being 62/* The input and output encrypted as though 64bit cfb mode is being
@@ -64,14 +64,8 @@
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66 66
67void BF_cfb64_encrypt(in, out, length, schedule, ivec, num, encrypt) 67void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
68unsigned char *in; 68 BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt)
69unsigned char *out;
70long length;
71BF_KEY *schedule;
72unsigned char *ivec;
73int *num;
74int encrypt;
75 { 69 {
76 register BF_LONG v0,v1,t; 70 register BF_LONG v0,v1,t;
77 register int n= *num; 71 register int n= *num;
diff --git a/src/lib/libcrypto/bf/bf_ecb.c b/src/lib/libcrypto/bf/bf_ecb.c
index 6d16360bd9..9f8a24cdff 100644
--- a/src/lib/libcrypto/bf/bf_ecb.c
+++ b/src/lib/libcrypto/bf/bf_ecb.c
@@ -56,17 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "blowfish.h" 59#include <openssl/blowfish.h>
60#include "bf_locl.h" 60#include "bf_locl.h"
61#include <openssl/opensslv.h>
61 62
62/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' 63/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
63 * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, 64 * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
64 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) 65 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
65 */ 66 */
66 67
67char *BF_version="BlowFish part of SSLeay 0.9.0b 29-Jun-1998"; 68const char *BF_version="BlowFish" OPENSSL_VERSION_PTEXT;
68 69
69char *BF_options() 70const char *BF_options(void)
70 { 71 {
71#ifdef BF_PTR 72#ifdef BF_PTR
72 return("blowfish(ptr)"); 73 return("blowfish(ptr)");
@@ -77,11 +78,8 @@ char *BF_options()
77#endif 78#endif
78 } 79 }
79 80
80void BF_ecb_encrypt(in, out, ks, encrypt) 81void BF_ecb_encrypt(unsigned char *in, unsigned char *out, BF_KEY *ks,
81unsigned char *in; 82 int encrypt)
82unsigned char *out;
83BF_KEY *ks;
84int encrypt;
85 { 83 {
86 BF_LONG l,d[2]; 84 BF_LONG l,d[2];
87 85
diff --git a/src/lib/libcrypto/bf/bf_enc.c b/src/lib/libcrypto/bf/bf_enc.c
index 66a8604c59..ee01834561 100644
--- a/src/lib/libcrypto/bf/bf_enc.c
+++ b/src/lib/libcrypto/bf/bf_enc.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "blowfish.h" 59#include <openssl/blowfish.h>
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' 62/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
@@ -65,14 +65,13 @@
65 */ 65 */
66 66
67#if (BF_ROUNDS != 16) && (BF_ROUNDS != 20) 67#if (BF_ROUNDS != 16) && (BF_ROUNDS != 20)
68If you set BF_ROUNDS to some value other than 16 or 20, you will have 68#error If you set BF_ROUNDS to some value other than 16 or 20, you will have \
69to modify the code. 69to modify the code.
70#endif 70#endif
71 71
72void BF_encrypt(data,key) 72void BF_encrypt(BF_LONG *data, BF_KEY *key)
73BF_LONG *data;
74BF_KEY *key;
75 { 73 {
74#ifndef BF_PTR2
76 register BF_LONG l,r,*p,*s; 75 register BF_LONG l,r,*p,*s;
77 76
78 p=key->P; 77 p=key->P;
@@ -107,14 +106,48 @@ BF_KEY *key;
107 106
108 data[1]=l&0xffffffffL; 107 data[1]=l&0xffffffffL;
109 data[0]=r&0xffffffffL; 108 data[0]=r&0xffffffffL;
109#else
110 register BF_LONG l,r,t,*k;
111
112 l=data[0];
113 r=data[1];
114 k=(BF_LONG*)key;
115
116 l^=k[0];
117 BF_ENC(r,l,k, 1);
118 BF_ENC(l,r,k, 2);
119 BF_ENC(r,l,k, 3);
120 BF_ENC(l,r,k, 4);
121 BF_ENC(r,l,k, 5);
122 BF_ENC(l,r,k, 6);
123 BF_ENC(r,l,k, 7);
124 BF_ENC(l,r,k, 8);
125 BF_ENC(r,l,k, 9);
126 BF_ENC(l,r,k,10);
127 BF_ENC(r,l,k,11);
128 BF_ENC(l,r,k,12);
129 BF_ENC(r,l,k,13);
130 BF_ENC(l,r,k,14);
131 BF_ENC(r,l,k,15);
132 BF_ENC(l,r,k,16);
133#if BF_ROUNDS == 20
134 BF_ENC(r,l,k,17);
135 BF_ENC(l,r,k,18);
136 BF_ENC(r,l,k,19);
137 BF_ENC(l,r,k,20);
138#endif
139 r^=k[BF_ROUNDS+1];
140
141 data[1]=l&0xffffffffL;
142 data[0]=r&0xffffffffL;
143#endif
110 } 144 }
111 145
112#ifndef BF_DEFAULT_OPTIONS 146#ifndef BF_DEFAULT_OPTIONS
113 147
114void BF_decrypt(data,key) 148void BF_decrypt(BF_LONG *data, BF_KEY *key)
115BF_LONG *data;
116BF_KEY *key;
117 { 149 {
150#ifndef BF_PTR2
118 register BF_LONG l,r,*p,*s; 151 register BF_LONG l,r,*p,*s;
119 152
120 p=key->P; 153 p=key->P;
@@ -149,15 +182,45 @@ BF_KEY *key;
149 182
150 data[1]=l&0xffffffffL; 183 data[1]=l&0xffffffffL;
151 data[0]=r&0xffffffffL; 184 data[0]=r&0xffffffffL;
185#else
186 register BF_LONG l,r,t,*k;
187
188 l=data[0];
189 r=data[1];
190 k=(BF_LONG *)key;
191
192 l^=k[BF_ROUNDS+1];
193#if BF_ROUNDS == 20
194 BF_ENC(r,l,k,20);
195 BF_ENC(l,r,k,19);
196 BF_ENC(r,l,k,18);
197 BF_ENC(l,r,k,17);
198#endif
199 BF_ENC(r,l,k,16);
200 BF_ENC(l,r,k,15);
201 BF_ENC(r,l,k,14);
202 BF_ENC(l,r,k,13);
203 BF_ENC(r,l,k,12);
204 BF_ENC(l,r,k,11);
205 BF_ENC(r,l,k,10);
206 BF_ENC(l,r,k, 9);
207 BF_ENC(r,l,k, 8);
208 BF_ENC(l,r,k, 7);
209 BF_ENC(r,l,k, 6);
210 BF_ENC(l,r,k, 5);
211 BF_ENC(r,l,k, 4);
212 BF_ENC(l,r,k, 3);
213 BF_ENC(r,l,k, 2);
214 BF_ENC(l,r,k, 1);
215 r^=k[0];
216
217 data[1]=l&0xffffffffL;
218 data[0]=r&0xffffffffL;
219#endif
152 } 220 }
153 221
154void BF_cbc_encrypt(in, out, length, ks, iv, encrypt) 222void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
155unsigned char *in; 223 BF_KEY *ks, unsigned char *iv, int encrypt)
156unsigned char *out;
157long length;
158BF_KEY *ks;
159unsigned char *iv;
160int encrypt;
161 { 224 {
162 register BF_LONG tin0,tin1; 225 register BF_LONG tin0,tin1;
163 register BF_LONG tout0,tout1,xor0,xor1; 226 register BF_LONG tout0,tout1,xor0,xor1;
diff --git a/src/lib/libcrypto/bf/bf_locl.org b/src/lib/libcrypto/bf/bf_locl.h
index a5663de8ca..05756b5d3b 100644
--- a/src/lib/libcrypto/bf/bf_locl.org
+++ b/src/lib/libcrypto/bf/bf_locl.h
@@ -1,4 +1,4 @@
1/* crypto/bf/bf_locl.org */ 1/* crypto/bf/bf_locl.h */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,39 +56,9 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 59#ifndef HEADER_BF_LOCL_H
60 * 60#define HEADER_BF_LOCL_H
61 * Always modify bf_locl.org since bf_locl.h is automatically generated from 61#include <openssl/opensslconf.h> /* BF_PTR, BF_PTR2 */
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 62
93#undef c2l 63#undef c2l
94#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ 64#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
@@ -181,62 +151,69 @@
181/* This is actually a big endian algorithm, the most significate byte 151/* This is actually a big endian algorithm, the most significate byte
182 * is used to lookup array 0 */ 152 * is used to lookup array 0 */
183 153
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) 154#if defined(BF_PTR2)
199 155
200/* This is basically a special pentium verson */ 156/*
201#define BF_ENC(LL,R,S,P) \ 157 * This is basically a special Intel version. Point is that Intel
202 { \ 158 * doesn't have many registers, but offers a reach choice of addressing
203 BF_LONG t,u,v; \ 159 * modes. So we spare some registers by directly traversing BF_KEY
204 u=R>>BF_0; \ 160 * structure and hiring the most decorated addressing mode. The code
205 v=R>>BF_1; \ 161 * generated by EGCS is *perfectly* competitive with assembler
206 u&=BF_M; \ 162 * implementation!
207 v&=BF_M; \ 163 */
208 t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \ 164#define BF_ENC(LL,R,KEY,Pi) (\
209 u=R>>BF_2; \ 165 LL^=KEY[Pi], \
210 t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \ 166 t= KEY[BF_ROUNDS+2 + 0 + ((R>>24)&0xFF)], \
211 v=R<<BF_3; \ 167 t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \
212 u&=BF_M; \ 168 t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \
213 v&=BF_M; \ 169 t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \
214 t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \ 170 LL^=t \
215 LL^=P; \ 171 )
216 t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
217 LL^=t; \
218 }
219 172
220#elif defined(BF_PTR) 173#elif defined(BF_PTR)
221 174
222/* This is normally very good */ 175#ifndef BF_LONG_LOG2
176#define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */
177#endif
178#define BF_M (0xFF<<BF_LONG_LOG2)
179#define BF_0 (24-BF_LONG_LOG2)
180#define BF_1 (16-BF_LONG_LOG2)
181#define BF_2 ( 8-BF_LONG_LOG2)
182#define BF_3 BF_LONG_LOG2 /* left shift */
183
184/*
185 * This is normally very good on RISC platforms where normally you
186 * have to explicitely "multiplicate" array index by sizeof(BF_LONG)
187 * in order to caclulate the effective address. This implementation
188 * excuses CPU from this extra work. Power[PC] uses should have most
189 * fun as (R>>BF_i)&BF_M gets folded into a single instruction, namely
190 * rlwinm. So let'em double-check if their compiler does it.
191 */
223 192
224#define BF_ENC(LL,R,S,P) \ 193#define BF_ENC(LL,R,S,P) ( \
225 LL^=P; \ 194 LL^=P, \
226 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \ 195 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
227 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ 196 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
228 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ 197 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
229 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M))); 198 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M))) \
199 )
230#else 200#else
231 201
232/* This will always work, even on 64 bit machines and strangly enough, 202/*
233 * on the Alpha it is faster than the pointer versions (both 32 and 64 203 * This is a *generic* version. Seem to perform best on platforms that
234 * versions of BF_LONG) */ 204 * offer explicit support for extraction of 8-bit nibbles preferably
205 * complemented with "multiplying" of array index by sizeof(BF_LONG).
206 * For the moment of this writing the list comprises Alpha CPU featuring
207 * extbl and s[48]addq instructions.
208 */
209
210#define BF_ENC(LL,R,S,P) ( \
211 LL^=P, \
212 LL^=((( S[ ((int)(R>>24)&0xff)] + \
213 S[0x0100+((int)(R>>16)&0xff)])^ \
214 S[0x0200+((int)(R>> 8)&0xff)])+ \
215 S[0x0300+((int)(R )&0xff)])&0xffffffffL \
216 )
217#endif
235 218
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 219#endif
diff --git a/src/lib/libcrypto/bf/bf_ofb64.c b/src/lib/libcrypto/bf/bf_ofb64.c
index 5d844ac760..8ceb8d9bda 100644
--- a/src/lib/libcrypto/bf/bf_ofb64.c
+++ b/src/lib/libcrypto/bf/bf_ofb64.c
@@ -56,20 +56,15 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "blowfish.h" 59#include <openssl/blowfish.h>
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62/* The input and output encrypted as though 64bit ofb mode is being 62/* The input and output encrypted as though 64bit ofb mode is being
63 * used. The extra state information to record how much of the 63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66void BF_ofb64_encrypt(in, out, length, schedule, ivec, num) 66void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
67unsigned char *in; 67 BF_KEY *schedule, unsigned char *ivec, int *num)
68unsigned char *out;
69long length;
70BF_KEY *schedule;
71unsigned char *ivec;
72int *num;
73 { 68 {
74 register BF_LONG v0,v1,t; 69 register BF_LONG v0,v1,t;
75 register int n= *num; 70 register int n= *num;
diff --git a/src/lib/libcrypto/bf/bf_opts.c b/src/lib/libcrypto/bf/bf_opts.c
index 5cfa60c537..5f330cc53c 100644
--- a/src/lib/libcrypto/bf/bf_opts.c
+++ b/src/lib/libcrypto/bf/bf_opts.c
@@ -59,19 +59,17 @@
59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options. 59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
60 * This is for machines with 64k code segment size restrictions. */ 60 * This is for machines with 64k code segment size restrictions. */
61 61
62#ifndef MSDOS 62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
66#include <stdio.h> 66#include <stdio.h>
67#ifndef MSDOS 67
68#include <unistd.h> 68#include <openssl/e_os2.h>
69#else 69#include OPENSSL_UNISTD_IO
70#include <io.h> 70OPENSSL_DECLARE_EXIT
71extern void exit(); 71
72#endif
73#include <signal.h> 72#include <signal.h>
74#ifndef VMS
75#ifndef _IRIX 73#ifndef _IRIX
76#include <time.h> 74#include <time.h>
77#endif 75#endif
@@ -79,25 +77,26 @@ extern void exit();
79#include <sys/types.h> 77#include <sys/types.h>
80#include <sys/times.h> 78#include <sys/times.h>
81#endif 79#endif
82#else /* VMS */ 80
83#include <types.h> 81/* Depending on the VMS version, the tms structure is perhaps defined.
84struct tms { 82 The __TMS macro will show if it was. If it wasn't defined, we should
85 time_t tms_utime; 83 undefine TIMES, since that tells the rest of the program how things
86 time_t tms_stime; 84 should be handled. -- Richard Levitte */
87 time_t tms_uchild; /* I dunno... */ 85#if defined(VMS) && defined(__DECC) && !defined(__TMS)
88 time_t tms_uchildsys; /* so these names are a guess :-) */ 86#undef TIMES
89 }
90#endif 87#endif
88
91#ifndef TIMES 89#ifndef TIMES
92#include <sys/timeb.h> 90#include <sys/timeb.h>
93#endif 91#endif
94 92
95#ifdef sun 93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
96#include <limits.h> 95#include <limits.h>
97#include <sys/param.h> 96#include <sys/param.h>
98#endif 97#endif
99 98
100#include "blowfish.h" 99#include <openssl/blowfish.h>
101 100
102#define BF_DEFAULT_OPTIONS 101#define BF_DEFAULT_OPTIONS
103 102
@@ -126,11 +125,7 @@ struct tms {
126#ifndef HZ 125#ifndef HZ
127# ifndef CLK_TCK 126# ifndef CLK_TCK
128# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ 127# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
129# ifndef VMS 128# define HZ 100.0
130# define HZ 100.0
131# else /* VMS */
132# define HZ 100.0
133# endif
134# else /* _BSD_CLK_TCK_ */ 129# else /* _BSD_CLK_TCK_ */
135# define HZ ((double)_BSD_CLK_TCK_) 130# define HZ ((double)_BSD_CLK_TCK_)
136# endif 131# endif
@@ -142,12 +137,7 @@ struct tms {
142#define BUFSIZE ((long)1024) 137#define BUFSIZE ((long)1024)
143long run=0; 138long run=0;
144 139
145#ifndef NOPROTO
146double Time_F(int s); 140double Time_F(int s);
147#else
148double Time_F();
149#endif
150
151#ifdef SIGALRM 141#ifdef SIGALRM
152#if defined(__STDC__) || defined(sgi) 142#if defined(__STDC__) || defined(sgi)
153#define SIGRETTYPE void 143#define SIGRETTYPE void
@@ -155,14 +145,8 @@ double Time_F();
155#define SIGRETTYPE int 145#define SIGRETTYPE int
156#endif 146#endif
157 147
158#ifndef NOPROTO
159SIGRETTYPE sig_done(int sig); 148SIGRETTYPE sig_done(int sig);
160#else 149SIGRETTYPE sig_done(int sig)
161SIGRETTYPE sig_done();
162#endif
163
164SIGRETTYPE sig_done(sig)
165int sig;
166 { 150 {
167 signal(SIGALRM,sig_done); 151 signal(SIGALRM,sig_done);
168 run=0; 152 run=0;
@@ -175,8 +159,7 @@ int sig;
175#define START 0 159#define START 0
176#define STOP 1 160#define STOP 1
177 161
178double Time_F(s) 162double Time_F(int s)
179int s;
180 { 163 {
181 double ret; 164 double ret;
182#ifdef TIMES 165#ifdef TIMES
@@ -237,9 +220,7 @@ int s;
237 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ 220 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
238 tm[index]*8,1.0e6/tm[index]); 221 tm[index]*8,1.0e6/tm[index]);
239 222
240int main(argc,argv) 223int main(int argc, char **argv)
241int argc;
242char **argv;
243 { 224 {
244 long count; 225 long count;
245 static unsigned char buf[BUFSIZE]; 226 static unsigned char buf[BUFSIZE];
diff --git a/src/lib/libcrypto/bf/bf_skey.c b/src/lib/libcrypto/bf/bf_skey.c
index 86574c0acc..eefa8e6f51 100644
--- a/src/lib/libcrypto/bf/bf_skey.c
+++ b/src/lib/libcrypto/bf/bf_skey.c
@@ -58,14 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include "blowfish.h" 61#include <openssl/blowfish.h>
62#include "bf_locl.h" 62#include "bf_locl.h"
63#include "bf_pi.h" 63#include "bf_pi.h"
64 64
65void BF_set_key(key,len,data) 65void BF_set_key(BF_KEY *key, int len, unsigned char *data)
66BF_KEY *key;
67int len;
68unsigned char *data;
69 { 66 {
70 int i; 67 int i;
71 BF_LONG *p,ri,in[2]; 68 BF_LONG *p,ri,in[2];
diff --git a/src/lib/libcrypto/bf/bfs.cpp b/src/lib/libcrypto/bf/bfs.cpp
index 272ed2f978..d74c457760 100644
--- a/src/lib/libcrypto/bf/bfs.cpp
+++ b/src/lib/libcrypto/bf/bfs.cpp
@@ -32,7 +32,7 @@ void GetTSC(unsigned long& tsc)
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include "blowfish.h" 35#include <openssl/blowfish.h>
36 36
37void main(int argc,char *argv[]) 37void main(int argc,char *argv[])
38 { 38 {
diff --git a/src/lib/libcrypto/bf/bfspeed.c b/src/lib/libcrypto/bf/bfspeed.c
index 640d820dd3..9b893e92cc 100644
--- a/src/lib/libcrypto/bf/bfspeed.c
+++ b/src/lib/libcrypto/bf/bfspeed.c
@@ -59,19 +59,17 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#ifndef MSDOS 62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
66#include <stdio.h> 66#include <stdio.h>
67#ifndef MSDOS 67
68#include <unistd.h> 68#include <openssl/e_os2.h>
69#else 69#include OPENSSL_UNISTD_IO
70#include <io.h> 70OPENSSL_DECLARE_EXIT
71extern int exit(); 71
72#endif
73#include <signal.h> 72#include <signal.h>
74#ifndef VMS
75#ifndef _IRIX 73#ifndef _IRIX
76#include <time.h> 74#include <time.h>
77#endif 75#endif
@@ -79,34 +77,31 @@ extern int exit();
79#include <sys/types.h> 77#include <sys/types.h>
80#include <sys/times.h> 78#include <sys/times.h>
81#endif 79#endif
82#else /* VMS */ 80
83#include <types.h> 81/* Depending on the VMS version, the tms structure is perhaps defined.
84struct tms { 82 The __TMS macro will show if it was. If it wasn't defined, we should
85 time_t tms_utime; 83 undefine TIMES, since that tells the rest of the program how things
86 time_t tms_stime; 84 should be handled. -- Richard Levitte */
87 time_t tms_uchild; /* I dunno... */ 85#if defined(VMS) && defined(__DECC) && !defined(__TMS)
88 time_t tms_uchildsys; /* so these names are a guess :-) */ 86#undef TIMES
89 }
90#endif 87#endif
88
91#ifndef TIMES 89#ifndef TIMES
92#include <sys/timeb.h> 90#include <sys/timeb.h>
93#endif 91#endif
94 92
95#ifdef sun 93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
96#include <limits.h> 95#include <limits.h>
97#include <sys/param.h> 96#include <sys/param.h>
98#endif 97#endif
99 98
100#include "blowfish.h" 99#include <openssl/blowfish.h>
101 100
102/* The following if from times(3) man page. It may need to be changed */ 101/* The following if from times(3) man page. It may need to be changed */
103#ifndef HZ 102#ifndef HZ
104#ifndef CLK_TCK 103#ifndef CLK_TCK
105#ifndef VMS
106#define HZ 100.0
107#else /* VMS */
108#define HZ 100.0 104#define HZ 100.0
109#endif
110#else /* CLK_TCK */ 105#else /* CLK_TCK */
111#define HZ ((double)CLK_TCK) 106#define HZ ((double)CLK_TCK)
112#endif 107#endif
@@ -115,12 +110,7 @@ struct tms {
115#define BUFSIZE ((long)1024) 110#define BUFSIZE ((long)1024)
116long run=0; 111long run=0;
117 112
118#ifndef NOPROTO
119double Time_F(int s); 113double Time_F(int s);
120#else
121double Time_F();
122#endif
123
124#ifdef SIGALRM 114#ifdef SIGALRM
125#if defined(__STDC__) || defined(sgi) || defined(_AIX) 115#if defined(__STDC__) || defined(sgi) || defined(_AIX)
126#define SIGRETTYPE void 116#define SIGRETTYPE void
@@ -128,14 +118,8 @@ double Time_F();
128#define SIGRETTYPE int 118#define SIGRETTYPE int
129#endif 119#endif
130 120
131#ifndef NOPROTO
132SIGRETTYPE sig_done(int sig); 121SIGRETTYPE sig_done(int sig);
133#else 122SIGRETTYPE sig_done(int sig)
134SIGRETTYPE sig_done();
135#endif
136
137SIGRETTYPE sig_done(sig)
138int sig;
139 { 123 {
140 signal(SIGALRM,sig_done); 124 signal(SIGALRM,sig_done);
141 run=0; 125 run=0;
@@ -148,8 +132,7 @@ int sig;
148#define START 0 132#define START 0
149#define STOP 1 133#define STOP 1
150 134
151double Time_F(s) 135double Time_F(int s)
152int s;
153 { 136 {
154 double ret; 137 double ret;
155#ifdef TIMES 138#ifdef TIMES
@@ -185,9 +168,7 @@ int s;
185#endif 168#endif
186 } 169 }
187 170
188int main(argc,argv) 171int main(int argc, char **argv)
189int argc;
190char **argv;
191 { 172 {
192 long count; 173 long count;
193 static unsigned char buf[BUFSIZE]; 174 static unsigned char buf[BUFSIZE];
diff --git a/src/lib/libcrypto/bf/bftest.c b/src/lib/libcrypto/bf/bftest.c
index 9266cf813a..6ecd2609a9 100644
--- a/src/lib/libcrypto/bf/bftest.c
+++ b/src/lib/libcrypto/bf/bftest.c
@@ -62,7 +62,19 @@
62#include <stdio.h> 62#include <stdio.h>
63#include <string.h> 63#include <string.h>
64#include <stdlib.h> 64#include <stdlib.h>
65#include "blowfish.h" 65
66#ifdef NO_BF
67int main(int argc, char *argv[])
68{
69 printf("No BF support\n");
70 return(0);
71}
72#else
73#include <openssl/blowfish.h>
74
75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h>
77#endif
66 78
67char *bf_key[2]={ 79char *bf_key[2]={
68 "abcdefghijklmnopqrstuvwxyz", 80 "abcdefghijklmnopqrstuvwxyz",
@@ -252,17 +264,9 @@ unsigned char key_out[KEY_TEST_NUM][8]={
252 {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80}, 264 {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80},
253 }; 265 };
254 266
255#ifndef NOPROTO
256static int test(void ); 267static int test(void );
257static int print_test_data(void ); 268static int print_test_data(void );
258#else 269int main(int argc, char *argv[])
259static int test();
260static int print_test_data();
261#endif
262
263int main(argc,argv)
264int argc;
265char *argv[];
266 { 270 {
267 int ret; 271 int ret;
268 272
@@ -275,7 +279,7 @@ char *argv[];
275 return(0); 279 return(0);
276 } 280 }
277 281
278static int print_test_data() 282static int print_test_data(void)
279 { 283 {
280 unsigned int i,j; 284 unsigned int i,j;
281 285
@@ -304,7 +308,7 @@ static int print_test_data()
304 printf("c="); 308 printf("c=");
305 for (j=0; j<8; j++) 309 for (j=0; j<8; j++)
306 printf("%02X",key_out[i][j]); 310 printf("%02X",key_out[i][j]);
307 printf(" k[%2d]=",i+1); 311 printf(" k[%2u]=",i+1);
308 for (j=0; j<i+1; j++) 312 for (j=0; j<i+1; j++)
309 printf("%02X",key_test[j]); 313 printf("%02X",key_test[j]);
310 printf("\n"); 314 printf("\n");
@@ -342,7 +346,7 @@ static int print_test_data()
342 return(0); 346 return(0);
343 } 347 }
344 348
345static int test() 349static int test(void)
346 { 350 {
347 unsigned char cbc_in[40],cbc_out[40],iv[8]; 351 unsigned char cbc_in[40],cbc_out[40],iv[8];
348 int i,n,err=0; 352 int i,n,err=0;
@@ -351,9 +355,16 @@ static int test()
351 unsigned char out[8]; 355 unsigned char out[8];
352 BF_LONG len; 356 BF_LONG len;
353 357
358#ifdef CHARSET_EBCDIC
359 ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data));
360#endif
361
354 printf("testing blowfish in raw ecb mode\n"); 362 printf("testing blowfish in raw ecb mode\n");
355 for (n=0; n<2; n++) 363 for (n=0; n<2; n++)
356 { 364 {
365#ifdef CHARSET_EBCDIC
366 ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n]));
367#endif
357 BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]); 368 BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]);
358 369
359 data[0]=bf_plain[n][0]; 370 data[0]=bf_plain[n][0];
@@ -364,11 +375,11 @@ static int test()
364 printf("BF_encrypt error encrypting\n"); 375 printf("BF_encrypt error encrypting\n");
365 printf("got :"); 376 printf("got :");
366 for (i=0; i<2; i++) 377 for (i=0; i<2; i++)
367 printf("%08lX ",data[i]); 378 printf("%08lX ",(unsigned long)data[i]);
368 printf("\n"); 379 printf("\n");
369 printf("expected:"); 380 printf("expected:");
370 for (i=0; i<2; i++) 381 for (i=0; i<2; i++)
371 printf("%08lX ",bf_cipher[n][i]); 382 printf("%08lX ",(unsigned long)bf_cipher[n][i]);
372 err=1; 383 err=1;
373 printf("\n"); 384 printf("\n");
374 } 385 }
@@ -379,11 +390,11 @@ static int test()
379 printf("BF_encrypt error decrypting\n"); 390 printf("BF_encrypt error decrypting\n");
380 printf("got :"); 391 printf("got :");
381 for (i=0; i<2; i++) 392 for (i=0; i<2; i++)
382 printf("%08lX ",data[i]); 393 printf("%08lX ",(unsigned long)data[i]);
383 printf("\n"); 394 printf("\n");
384 printf("expected:"); 395 printf("expected:");
385 for (i=0; i<2; i++) 396 for (i=0; i<2; i++)
386 printf("%08lX ",bf_plain[n][i]); 397 printf("%08lX ",(unsigned long)bf_plain[n][i]);
387 printf("\n"); 398 printf("\n");
388 err=1; 399 err=1;
389 } 400 }
@@ -519,3 +530,4 @@ static int test()
519 530
520 return(err); 531 return(err);
521 } 532 }
533#endif
diff --git a/src/lib/libcrypto/bf/blowfish.h b/src/lib/libcrypto/bf/blowfish.h
index c4a8085a29..02f73b2f30 100644
--- a/src/lib/libcrypto/bf/blowfish.h
+++ b/src/lib/libcrypto/bf/blowfish.h
@@ -63,14 +63,35 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_BF
67#error BF is disabled.
68#endif
69
66#define BF_ENCRYPT 1 70#define BF_ENCRYPT 1
67#define BF_DECRYPT 0 71#define BF_DECRYPT 0
68 72
69/* If you make this 'unsigned int' the pointer variants will work on 73/*
70 * the Alpha, otherwise they will not. Strangly using the '8 byte' 74 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
71 * BF_LONG and the default 'non-pointer' inner loop is the best configuration 75 * ! BF_LONG has to be at least 32 bits wide. If it's wider, then !
72 * for the Alpha */ 76 * ! BF_LONG_LOG2 has to be defined along. !
77 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
78 */
79
80#if defined(WIN16) || defined(__LP32__)
73#define BF_LONG unsigned long 81#define BF_LONG unsigned long
82#elif defined(_CRAY) || defined(__ILP64__)
83#define BF_LONG unsigned long
84#define BF_LONG_LOG2 3
85/*
86 * _CRAY note. I could declare short, but I have no idea what impact
87 * does it have on performance on none-T3E machines. I could declare
88 * int, but at least on C90 sizeof(int) can be chosen at compile time.
89 * So I've chosen long...
90 * <appro@fy.chalmers.se>
91 */
92#else
93#define BF_LONG unsigned int
94#endif
74 95
75#define BF_ROUNDS 16 96#define BF_ROUNDS 16
76#define BF_BLOCK 8 97#define BF_BLOCK 8
@@ -81,7 +102,6 @@ typedef struct bf_key_st
81 BF_LONG S[4*256]; 102 BF_LONG S[4*256];
82 } BF_KEY; 103 } BF_KEY;
83 104
84#ifndef NOPROTO
85 105
86void BF_set_key(BF_KEY *key, int len, unsigned char *data); 106void BF_set_key(BF_KEY *key, int len, unsigned char *data);
87void BF_ecb_encrypt(unsigned char *in,unsigned char *out,BF_KEY *key, 107void BF_ecb_encrypt(unsigned char *in,unsigned char *out,BF_KEY *key,
@@ -94,20 +114,7 @@ void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
94 BF_KEY *schedule, unsigned char *ivec, int *num, int enc); 114 BF_KEY *schedule, unsigned char *ivec, int *num, int enc);
95void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, 115void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
96 BF_KEY *schedule, unsigned char *ivec, int *num); 116 BF_KEY *schedule, unsigned char *ivec, int *num);
97char *BF_options(void); 117const char *BF_options(void);
98
99#else
100
101void BF_set_key();
102void BF_ecb_encrypt();
103void BF_encrypt();
104void BF_decrypt();
105void BF_cbc_encrypt();
106void BF_cfb64_encrypt();
107void BF_ofb64_encrypt();
108char *BF_options();
109
110#endif
111 118
112#ifdef __cplusplus 119#ifdef __cplusplus
113} 120}