From de8f24ea083384bb66b32ec105dc4743c5663cdf Mon Sep 17 00:00:00 2001 From: beck <> Date: Wed, 29 Sep 1999 04:37:45 +0000 Subject: OpenSSL 0.9.4 merge --- src/lib/libcrypto/bf/Makefile.ssl | 45 +- src/lib/libcrypto/bf/Makefile.uni | 20 +- src/lib/libcrypto/bf/asm/bf-586.pl | 4 +- src/lib/libcrypto/bf/asm/bf-686.pl | 1 - src/lib/libcrypto/bf/asm/bx86unix.cpp | 976 ---------------------------------- src/lib/libcrypto/bf/bf_cbc.c | 11 +- src/lib/libcrypto/bf/bf_cfb64.c | 12 +- src/lib/libcrypto/bf/bf_ecb.c | 14 +- src/lib/libcrypto/bf/bf_enc.c | 93 +++- src/lib/libcrypto/bf/bf_locl.h | 219 ++++++++ src/lib/libcrypto/bf/bf_locl.org | 242 --------- src/lib/libcrypto/bf/bf_ofb64.c | 11 +- src/lib/libcrypto/bf/bf_opts.c | 61 +-- src/lib/libcrypto/bf/bf_skey.c | 7 +- src/lib/libcrypto/bf/bfs.cpp | 2 +- src/lib/libcrypto/bf/bfspeed.c | 59 +- src/lib/libcrypto/bf/bftest.c | 46 +- src/lib/libcrypto/bf/blowfish.h | 45 +- 18 files changed, 444 insertions(+), 1424 deletions(-) delete mode 100644 src/lib/libcrypto/bf/asm/bx86unix.cpp create mode 100644 src/lib/libcrypto/bf/bf_locl.h delete mode 100644 src/lib/libcrypto/bf/bf_locl.org (limited to 'src/lib/libcrypto/bf') 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 CPP= $(CC) -E INCLUDES= CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl MAKE= make -f Makefile.ssl -MAKEDEPEND= makedepend -f Makefile.ssl +MAKEDEPEND= $(TOP)/util/domd $(TOP) MAKEFILE= Makefile.ssl AR= ar r @@ -42,7 +44,7 @@ all: lib lib: $(LIBOBJ) $(AR) $(LIB) $(LIBOBJ) - sh $(TOP)/util/ranlib.sh $(LIB) + $(RANLIB) $(LIB) @touch lib # elf @@ -61,27 +63,25 @@ asm/bx86-out.o: asm/bx86unix.cpp # bsdi asm/bx86bsdi.o: asm/bx86unix.cpp - $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o + $(CPP) -DBSDI asm/bx86unix.cpp | sed 's/ :/:/' | as -o asm/bx86bsdi.o asm/bx86unix.cpp: - (cd asm; perl bf-586.pl cpp >bx86unix.cpp) + (cd asm; $(PERL) bf-586.pl cpp $(PROCESSOR) >bx86unix.cpp) files: - perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO links: - /bin/rm -f Makefile - $(TOP)/util/point.sh Makefile.ssl Makefile ; - $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ; - $(TOP)/util/mklink.sh ../../include $(EXHEADER) - $(TOP)/util/mklink.sh ../../test $(TEST) - $(TOP)/util/mklink.sh ../../apps $(APPS) + @$(TOP)/util/point.sh Makefile.ssl Makefile + @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) install: @for i in $(EXHEADER) ; \ do \ - (cp $$i $(INSTALLTOP)/include/$$i; \ - chmod 644 $(INSTALLTOP)/include/$$i ); \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ done; tags: @@ -93,15 +93,24 @@ lint: lint -DLINT $(INCLUDES) $(SRC)>fluff depend: - $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) dclean: - perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new mv -f Makefile.new $(MAKEFILE) clean: - /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff - -errors: + rm -f asm/bx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff # DO NOT DELETE THIS LINE -- make depend depends on it. + +bf_cfb64.o: ../../include/openssl/blowfish.h +bf_cfb64.o: ../../include/openssl/opensslconf.h bf_locl.h +bf_ecb.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h +bf_ecb.o: ../../include/openssl/opensslv.h bf_locl.h +bf_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h +bf_enc.o: bf_locl.h +bf_ofb64.o: ../../include/openssl/blowfish.h +bf_ofb64.o: ../../include/openssl/opensslconf.h bf_locl.h +bf_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h +bf_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 CFLAGS=$(OPTS) $(CFLAG) CPP=$(CC) -E AS=as +RANLIB=ranlib # Assember version of bf_encrypt(). BF_ENC=bf_enc.o # normal C version @@ -105,9 +106,7 @@ test: all $(BLIB): $(LIBOBJ) /bin/rm -f $(BLIB) ar cr $(BLIB) $(LIBOBJ) - -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \ - else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \ - else exit 0; fi; fi + $(RANLIB) $(BLIB) bftest: bftest.o $(BLIB) $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB) @@ -142,25 +141,14 @@ install: $(BLIB) if test $(INSTALLTOP); then \ echo SSL style install; \ cp $(BLIB) $(INSTALLTOP)/lib; \ - if test -s /bin/ranlib; then \ - /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ - else \ - if test -s /usr/bin/ranlib; then \ - /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ - fi; fi; \ + $(RANLIB) $(BLIB); \ chmod 644 $(INSTALLTOP)/lib/$(BLIB); \ cp blowfish.h $(INSTALLTOP)/include; \ chmod 644 $(INSTALLTOP)/include/blowfish.h; \ else \ echo Standalone install; \ cp $(BLIB) $(LIBDIR)/$(BLIB); \ - if test -s /bin/ranlib; then \ - /bin/ranlib $(LIBDIR)/$(BLIB); \ - else \ - if test -s /usr/bin/ranlib; then \ - /usr/bin/ranlib $(LIBDIR)/$(BLIB); \ - fi; \ - fi; \ + $(RANLIB) $(BLIB); \ chmod 644 $(LIBDIR)/$(BLIB); \ cp blowfish.h $(INCDIR)/blowfish.h; \ 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 @@ -#!/usr/bin/perl +#!/usr/local/bin/perl push(@INC,"perlasm","../../perlasm"); require "x86asm.pl"; require "cbc.pl"; -&asm_init($ARGV[0],"bf-586.pl"); +&asm_init($ARGV[0],"bf-586.pl",$ARGV[$#ARGV] eq "386"); $BF_ROUNDS=16; $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 @@ -#!/usr/bin/perl #!/usr/local/bin/perl push(@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 @@ -/* Run the C pre-processor over this file with one of the following defined - * ELF - elf object files, - * OUT - a.out object files, - * BSDI - BSDI style a.out object files - * SOL - Solaris style elf - */ - -#define TYPE(a,b) .type a,b -#define SIZE(a,b) .size a,b - -#if defined(OUT) || defined(BSDI) -#define BF_encrypt _BF_encrypt -#define BF_decrypt _BF_decrypt -#define BF_cbc_encrypt _BF_cbc_encrypt - -#endif - -#ifdef OUT -#define OK 1 -#define ALIGN 4 -#endif - -#ifdef BSDI -#define OK 1 -#define ALIGN 4 -#undef SIZE -#undef TYPE -#define SIZE(a,b) -#define TYPE(a,b) -#endif - -#if defined(ELF) || defined(SOL) -#define OK 1 -#define ALIGN 16 -#endif - -#ifndef OK -You need to define one of -ELF - elf systems - linux-elf, NetBSD and DG-UX -OUT - a.out systems - linux-a.out and FreeBSD -SOL - solaris systems, which are elf with strange comment lines -BSDI - a.out with a very primative version of as. -#endif - -/* Let the Assembler begin :-) */ - /* Don't even think of reading this code */ - /* It was automatically generated by bf-586.pl */ - /* Which is a perl program used to generate the x86 assember for */ - /* any of elf, a.out, BSDI,Win32, or Solaris */ - /* eric */ - - .file "bf-586.s" - .version "01.01" -gcc2_compiled.: -.text - .align ALIGN -.globl BF_encrypt - TYPE(BF_encrypt,@function) -BF_encrypt: - - pushl %ebp - pushl %ebx - movl 12(%esp), %ebx - movl 16(%esp), %ebp - pushl %esi - pushl %edi - /* Load the 2 words */ - movl (%ebx), %edi - movl 4(%ebx), %esi - xorl %eax, %eax - movl (%ebp), %ebx - xorl %ecx, %ecx - xorl %ebx, %edi - - /* Round 0 */ - movl 4(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 1 */ - movl 8(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 2 */ - movl 12(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 3 */ - movl 16(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 4 */ - movl 20(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 5 */ - movl 24(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 6 */ - movl 28(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 7 */ - movl 32(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 8 */ - movl 36(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 9 */ - movl 40(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 10 */ - movl 44(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 11 */ - movl 48(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 12 */ - movl 52(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 13 */ - movl 56(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 14 */ - movl 60(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 15 */ - movl 64(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - /* Load parameter 0 (16) enc=1 */ - movl 20(%esp), %eax - xorl %ebx, %edi - movl 68(%ebp), %edx - xorl %edx, %esi - movl %edi, 4(%eax) - movl %esi, (%eax) - popl %edi - popl %esi - popl %ebx - popl %ebp - ret -.BF_encrypt_end: - SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt) -.ident "BF_encrypt" -.text - .align ALIGN -.globl BF_decrypt - TYPE(BF_decrypt,@function) -BF_decrypt: - - pushl %ebp - pushl %ebx - movl 12(%esp), %ebx - movl 16(%esp), %ebp - pushl %esi - pushl %edi - /* Load the 2 words */ - movl (%ebx), %edi - movl 4(%ebx), %esi - xorl %eax, %eax - movl 68(%ebp), %ebx - xorl %ecx, %ecx - xorl %ebx, %edi - - /* Round 16 */ - movl 64(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 15 */ - movl 60(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 14 */ - movl 56(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 13 */ - movl 52(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 12 */ - movl 48(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 11 */ - movl 44(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 10 */ - movl 40(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 9 */ - movl 36(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 8 */ - movl 32(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 7 */ - movl 28(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 6 */ - movl 24(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 5 */ - movl 20(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 4 */ - movl 16(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 3 */ - movl 12(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %edi - - /* Round 2 */ - movl 8(%ebp), %edx - movl %edi, %ebx - xorl %edx, %esi - shrl $16, %ebx - movl %edi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - xorl %eax, %eax - xorl %ebx, %esi - - /* Round 1 */ - movl 4(%ebp), %edx - movl %esi, %ebx - xorl %edx, %edi - shrl $16, %ebx - movl %esi, %edx - movb %bh, %al - andl $255, %ebx - movb %dh, %cl - andl $255, %edx - movl 72(%ebp,%eax,4),%eax - movl 1096(%ebp,%ebx,4),%ebx - addl %eax, %ebx - movl 2120(%ebp,%ecx,4),%eax - xorl %eax, %ebx - movl 3144(%ebp,%edx,4),%edx - addl %edx, %ebx - /* Load parameter 0 (1) enc=0 */ - movl 20(%esp), %eax - xorl %ebx, %edi - movl (%ebp), %edx - xorl %edx, %esi - movl %edi, 4(%eax) - movl %esi, (%eax) - popl %edi - popl %esi - popl %ebx - popl %ebp - ret -.BF_decrypt_end: - SIZE(BF_decrypt,.BF_decrypt_end-BF_decrypt) -.ident "BF_decrypt" -.text - .align ALIGN -.globl BF_cbc_encrypt - TYPE(BF_cbc_encrypt,@function) -BF_cbc_encrypt: - - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - movl 28(%esp), %ebp - /* getting iv ptr from parameter 4 */ - movl 36(%esp), %ebx - movl (%ebx), %esi - movl 4(%ebx), %edi - pushl %edi - pushl %esi - pushl %edi - pushl %esi - movl %esp, %ebx - movl 36(%esp), %esi - movl 40(%esp), %edi - /* getting encrypt flag from parameter 5 */ - movl 56(%esp), %ecx - /* get and push parameter 3 */ - movl 48(%esp), %eax - pushl %eax - pushl %ebx - cmpl $0, %ecx - jz .L000decrypt - andl $4294967288, %ebp - movl 8(%esp), %eax - movl 12(%esp), %ebx - jz .L001encrypt_finish -.L002encrypt_loop: - movl (%esi), %ecx - movl 4(%esi), %edx - xorl %ecx, %eax - xorl %edx, %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl %eax, 8(%esp) - movl %ebx, 12(%esp) - call BF_encrypt - movl 8(%esp), %eax - movl 12(%esp), %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl %eax, (%edi) - movl %ebx, 4(%edi) - addl $8, %esi - addl $8, %edi - subl $8, %ebp - jnz .L002encrypt_loop -.L001encrypt_finish: - movl 52(%esp), %ebp - andl $7, %ebp - jz .L003finish - xorl %ecx, %ecx - xorl %edx, %edx - movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp - jmp *%ebp -.L005ej7: - movb 6(%esi), %dh - sall $8, %edx -.L006ej6: - movb 5(%esi), %dh -.L007ej5: - movb 4(%esi), %dl -.L008ej4: - movl (%esi), %ecx - jmp .L009ejend -.L010ej3: - movb 2(%esi), %ch - sall $8, %ecx -.L011ej2: - movb 1(%esi), %ch -.L012ej1: - movb (%esi), %cl -.L009ejend: - xorl %ecx, %eax - xorl %edx, %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl %eax, 8(%esp) - movl %ebx, 12(%esp) - call BF_encrypt - movl 8(%esp), %eax - movl 12(%esp), %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl %eax, (%edi) - movl %ebx, 4(%edi) - jmp .L003finish -.align ALIGN -.L000decrypt: - andl $4294967288, %ebp - movl 16(%esp), %eax - movl 20(%esp), %ebx - jz .L013decrypt_finish -.L014decrypt_loop: - movl (%esi), %eax - movl 4(%esi), %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl %eax, 8(%esp) - movl %ebx, 12(%esp) - call BF_decrypt - movl 8(%esp), %eax - movl 12(%esp), %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl 16(%esp), %ecx - movl 20(%esp), %edx - xorl %eax, %ecx - xorl %ebx, %edx - movl (%esi), %eax - movl 4(%esi), %ebx - movl %ecx, (%edi) - movl %edx, 4(%edi) - movl %eax, 16(%esp) - movl %ebx, 20(%esp) - addl $8, %esi - addl $8, %edi - subl $8, %ebp - jnz .L014decrypt_loop -.L013decrypt_finish: - movl 52(%esp), %ebp - andl $7, %ebp - jz .L003finish - movl (%esi), %eax - movl 4(%esi), %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl %eax, 8(%esp) - movl %ebx, 12(%esp) - call BF_decrypt - movl 8(%esp), %eax - movl 12(%esp), %ebx -.byte 15 -.byte 200 /* bswapl %eax */ -.byte 15 -.byte 203 /* bswapl %ebx */ - movl 16(%esp), %ecx - movl 20(%esp), %edx - xorl %eax, %ecx - xorl %ebx, %edx - movl (%esi), %eax - movl 4(%esi), %ebx -.L015dj7: - rorl $16, %edx - movb %dl, 6(%edi) - shrl $16, %edx -.L016dj6: - movb %dh, 5(%edi) -.L017dj5: - movb %dl, 4(%edi) -.L018dj4: - movl %ecx, (%edi) - jmp .L019djend -.L020dj3: - rorl $16, %ecx - movb %cl, 2(%edi) - sall $16, %ecx -.L021dj2: - movb %ch, 1(%esi) -.L022dj1: - movb %cl, (%esi) -.L019djend: - jmp .L003finish -.align ALIGN -.L003finish: - movl 60(%esp), %ecx - addl $24, %esp - movl %eax, (%ecx) - movl %ebx, 4(%ecx) - popl %edi - popl %esi - popl %ebx - popl %ebp - ret -.align ALIGN -.L004cbc_enc_jmp_table: - .long 0 - .long .L012ej1 - .long .L011ej2 - .long .L010ej3 - .long .L008ej4 - .long .L007ej5 - .long .L006ej6 - .long .L005ej7 -.align ALIGN -.L023cbc_dec_jmp_table: - .long 0 - .long .L022dj1 - .long .L021dj2 - .long .L020dj3 - .long .L018dj4 - .long .L017dj5 - .long .L016dj6 - .long .L015dj7 -.BF_cbc_encrypt_end: - SIZE(BF_cbc_encrypt,.BF_cbc_encrypt_end-BF_cbc_encrypt) -.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 @@ * [including the GNU Public Licence.] */ -#include "blowfish.h" +#include #include "bf_locl.h" -void BF_cbc_encrypt(in, out, length, ks, iv, encrypt) -unsigned char *in; -unsigned char *out; -long length; -BF_KEY *ks; -unsigned char *iv; -int encrypt; +void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, + BF_KEY *ks, unsigned char *iv, int encrypt) { register BF_LONG tin0,tin1; 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 @@ * [including the GNU Public Licence.] */ -#include "blowfish.h" +#include #include "bf_locl.h" /* The input and output encrypted as though 64bit cfb mode is being @@ -64,14 +64,8 @@ * 64bit block we have used is contained in *num; */ -void BF_cfb64_encrypt(in, out, length, schedule, ivec, num, encrypt) -unsigned char *in; -unsigned char *out; -long length; -BF_KEY *schedule; -unsigned char *ivec; -int *num; -int encrypt; +void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) { register BF_LONG v0,v1,t; 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 @@ * [including the GNU Public Licence.] */ -#include "blowfish.h" +#include #include "bf_locl.h" +#include /* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) */ -char *BF_version="BlowFish part of SSLeay 0.9.0b 29-Jun-1998"; +const char *BF_version="BlowFish" OPENSSL_VERSION_PTEXT; -char *BF_options() +const char *BF_options(void) { #ifdef BF_PTR return("blowfish(ptr)"); @@ -77,11 +78,8 @@ char *BF_options() #endif } -void BF_ecb_encrypt(in, out, ks, encrypt) -unsigned char *in; -unsigned char *out; -BF_KEY *ks; -int encrypt; +void BF_ecb_encrypt(unsigned char *in, unsigned char *out, BF_KEY *ks, + int encrypt) { BF_LONG l,d[2]; 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 @@ * [including the GNU Public Licence.] */ -#include "blowfish.h" +#include #include "bf_locl.h" /* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' @@ -65,14 +65,13 @@ */ #if (BF_ROUNDS != 16) && (BF_ROUNDS != 20) -If you set BF_ROUNDS to some value other than 16 or 20, you will have +#error If you set BF_ROUNDS to some value other than 16 or 20, you will have \ to modify the code. #endif -void BF_encrypt(data,key) -BF_LONG *data; -BF_KEY *key; +void BF_encrypt(BF_LONG *data, BF_KEY *key) { +#ifndef BF_PTR2 register BF_LONG l,r,*p,*s; p=key->P; @@ -107,14 +106,48 @@ BF_KEY *key; data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; +#else + register BF_LONG l,r,t,*k; + + l=data[0]; + r=data[1]; + k=(BF_LONG*)key; + + l^=k[0]; + BF_ENC(r,l,k, 1); + BF_ENC(l,r,k, 2); + BF_ENC(r,l,k, 3); + BF_ENC(l,r,k, 4); + BF_ENC(r,l,k, 5); + BF_ENC(l,r,k, 6); + BF_ENC(r,l,k, 7); + BF_ENC(l,r,k, 8); + BF_ENC(r,l,k, 9); + BF_ENC(l,r,k,10); + BF_ENC(r,l,k,11); + BF_ENC(l,r,k,12); + BF_ENC(r,l,k,13); + BF_ENC(l,r,k,14); + BF_ENC(r,l,k,15); + BF_ENC(l,r,k,16); +#if BF_ROUNDS == 20 + BF_ENC(r,l,k,17); + BF_ENC(l,r,k,18); + BF_ENC(r,l,k,19); + BF_ENC(l,r,k,20); +#endif + r^=k[BF_ROUNDS+1]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#endif } #ifndef BF_DEFAULT_OPTIONS -void BF_decrypt(data,key) -BF_LONG *data; -BF_KEY *key; +void BF_decrypt(BF_LONG *data, BF_KEY *key) { +#ifndef BF_PTR2 register BF_LONG l,r,*p,*s; p=key->P; @@ -149,15 +182,45 @@ BF_KEY *key; data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; +#else + register BF_LONG l,r,t,*k; + + l=data[0]; + r=data[1]; + k=(BF_LONG *)key; + + l^=k[BF_ROUNDS+1]; +#if BF_ROUNDS == 20 + BF_ENC(r,l,k,20); + BF_ENC(l,r,k,19); + BF_ENC(r,l,k,18); + BF_ENC(l,r,k,17); +#endif + BF_ENC(r,l,k,16); + BF_ENC(l,r,k,15); + BF_ENC(r,l,k,14); + BF_ENC(l,r,k,13); + BF_ENC(r,l,k,12); + BF_ENC(l,r,k,11); + BF_ENC(r,l,k,10); + BF_ENC(l,r,k, 9); + BF_ENC(r,l,k, 8); + BF_ENC(l,r,k, 7); + BF_ENC(r,l,k, 6); + BF_ENC(l,r,k, 5); + BF_ENC(r,l,k, 4); + BF_ENC(l,r,k, 3); + BF_ENC(r,l,k, 2); + BF_ENC(l,r,k, 1); + r^=k[0]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#endif } -void BF_cbc_encrypt(in, out, length, ks, iv, encrypt) -unsigned char *in; -unsigned char *out; -long length; -BF_KEY *ks; -unsigned char *iv; -int encrypt; +void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, + BF_KEY *ks, unsigned char *iv, int encrypt) { register BF_LONG tin0,tin1; register BF_LONG tout0,tout1,xor0,xor1; diff --git a/src/lib/libcrypto/bf/bf_locl.h b/src/lib/libcrypto/bf/bf_locl.h new file mode 100644 index 0000000000..05756b5d3b --- /dev/null +++ b/src/lib/libcrypto/bf/bf_locl.h @@ -0,0 +1,219 @@ +/* crypto/bf/bf_locl.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BF_LOCL_H +#define HEADER_BF_LOCL_H +#include /* BF_PTR, BF_PTR2 */ + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +#undef l2n +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* This is actually a big endian algorithm, the most significate byte + * is used to lookup array 0 */ + +#if defined(BF_PTR2) + +/* + * This is basically a special Intel version. Point is that Intel + * doesn't have many registers, but offers a reach choice of addressing + * modes. So we spare some registers by directly traversing BF_KEY + * structure and hiring the most decorated addressing mode. The code + * generated by EGCS is *perfectly* competitive with assembler + * implementation! + */ +#define BF_ENC(LL,R,KEY,Pi) (\ + LL^=KEY[Pi], \ + t= KEY[BF_ROUNDS+2 + 0 + ((R>>24)&0xFF)], \ + t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \ + t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \ + t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \ + LL^=t \ + ) + +#elif defined(BF_PTR) + +#ifndef BF_LONG_LOG2 +#define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */ +#endif +#define BF_M (0xFF<>BF_i)&BF_M gets folded into a single instruction, namely + * rlwinm. So let'em double-check if their compiler does it. + */ + +#define BF_ENC(LL,R,S,P) ( \ + LL^=P, \ + LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \ + *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ + *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ + *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24)&0xff)] + \ + S[0x0100+((int)(R>>16)&0xff)])^ \ + S[0x0200+((int)(R>> 8)&0xff)])+ \ + S[0x0300+((int)(R )&0xff)])&0xffffffffL \ + ) +#endif + +#endif diff --git a/src/lib/libcrypto/bf/bf_locl.org b/src/lib/libcrypto/bf/bf_locl.org deleted file mode 100644 index a5663de8ca..0000000000 --- a/src/lib/libcrypto/bf/bf_locl.org +++ /dev/null @@ -1,242 +0,0 @@ -/* crypto/bf/bf_locl.org */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * - * Always modify bf_locl.org since bf_locl.h is automatically generated from - * it during SSLeay configuration. - * - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - */ - -/* Special defines which change the way the code is built depending on the - CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find - even newer MIPS CPU's, but at the moment one size fits all for - optimization options. Older Sparc's work better with only UNROLL, but - there's no way to tell at compile time what it is you're running on */ - -#if defined( sun ) /* Newer Sparc's */ -# define BF_PTR -#elif defined( __ultrix ) /* Older MIPS */ -# define BF_PTR -#elif defined( __osf1__ ) /* Alpha */ - /* None */ -#elif defined ( _AIX ) /* RS6000 */ - /* Unknown */ -#elif defined( __hpux ) /* HP-PA */ - /* None */ -#elif defined( __aux ) /* 68K */ - /* Unknown */ -#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ - /* Unknown */ -#elif defined( __sgi ) /* Newer MIPS */ -# define BF_PTR -#elif defined( i386 ) /* x86 boxes, should be gcc */ -#elif defined( _MSC_VER ) /* x86 boxes, Visual C */ -#endif /* Systems-specific speed defines */ - -#undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -#undef c2ln -#define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ - case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ - case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -#undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* NOTE - c is not incremented as per l2c */ -#undef l2cn -#define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -/* This is actually a big endian algorithm, the most significate byte - * is used to lookup array 0 */ - -/* use BF_PTR2 for intel boxes, - * BF_PTR for sparc and MIPS/SGI - * use nothing for Alpha and HP. - */ -#if !defined(BF_PTR) && !defined(BF_PTR2) -#undef BF_PTR -#endif - -#define BF_M 0x3fc -#define BF_0 22L -#define BF_1 14L -#define BF_2 6L -#define BF_3 2L /* left shift */ - -#if defined(BF_PTR2) - -/* This is basically a special pentium verson */ -#define BF_ENC(LL,R,S,P) \ - { \ - BF_LONG t,u,v; \ - u=R>>BF_0; \ - v=R>>BF_1; \ - u&=BF_M; \ - v&=BF_M; \ - t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \ - u=R>>BF_2; \ - t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \ - v=R<>BF_0)&BF_M))+ \ - *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ - *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ - *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24L) ] + \ - S[0x0100+((int)(R>>16L)&0xff)])^ \ - S[0x0200+((int)(R>> 8L)&0xff)])+ \ - S[0x0300+((int)(R )&0xff)])&0xffffffffL; -#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 @@ * [including the GNU Public Licence.] */ -#include "blowfish.h" +#include #include "bf_locl.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ -void BF_ofb64_encrypt(in, out, length, schedule, ivec, num) -unsigned char *in; -unsigned char *out; -long length; -BF_KEY *schedule; -unsigned char *ivec; -int *num; +void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + BF_KEY *schedule, unsigned char *ivec, int *num) { register BF_LONG v0,v1,t; 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 @@ /* define PART1, PART2, PART3 or PART4 to build only with a few of the options. * This is for machines with 64k code segment size restrictions. */ -#ifndef MSDOS +#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) #define TIMES #endif #include -#ifndef MSDOS -#include -#else -#include -extern void exit(); -#endif + +#include +#include OPENSSL_UNISTD_IO +OPENSSL_DECLARE_EXIT + #include -#ifndef VMS #ifndef _IRIX #include #endif @@ -79,25 +77,26 @@ extern void exit(); #include #include #endif -#else /* VMS */ -#include -struct tms { - time_t tms_utime; - time_t tms_stime; - time_t tms_uchild; /* I dunno... */ - time_t tms_uchildsys; /* so these names are a guess :-) */ - } + +/* Depending on the VMS version, the tms structure is perhaps defined. + The __TMS macro will show if it was. If it wasn't defined, we should + undefine TIMES, since that tells the rest of the program how things + should be handled. -- Richard Levitte */ +#if defined(VMS) && defined(__DECC) && !defined(__TMS) +#undef TIMES #endif + #ifndef TIMES #include #endif -#ifdef sun +#if defined(sun) || defined(__ultrix) +#define _POSIX_SOURCE #include #include #endif -#include "blowfish.h" +#include #define BF_DEFAULT_OPTIONS @@ -126,11 +125,7 @@ struct tms { #ifndef HZ # ifndef CLK_TCK # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ -# ifndef VMS -# define HZ 100.0 -# else /* VMS */ -# define HZ 100.0 -# endif +# define HZ 100.0 # else /* _BSD_CLK_TCK_ */ # define HZ ((double)_BSD_CLK_TCK_) # endif @@ -142,12 +137,7 @@ struct tms { #define BUFSIZE ((long)1024) long run=0; -#ifndef NOPROTO double Time_F(int s); -#else -double Time_F(); -#endif - #ifdef SIGALRM #if defined(__STDC__) || defined(sgi) #define SIGRETTYPE void @@ -155,14 +145,8 @@ double Time_F(); #define SIGRETTYPE int #endif -#ifndef NOPROTO SIGRETTYPE sig_done(int sig); -#else -SIGRETTYPE sig_done(); -#endif - -SIGRETTYPE sig_done(sig) -int sig; +SIGRETTYPE sig_done(int sig) { signal(SIGALRM,sig_done); run=0; @@ -175,8 +159,7 @@ int sig; #define START 0 #define STOP 1 -double Time_F(s) -int s; +double Time_F(int s) { double ret; #ifdef TIMES @@ -237,9 +220,7 @@ int s; fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ tm[index]*8,1.0e6/tm[index]); -int main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { long count; 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 @@ #include #include -#include "blowfish.h" +#include #include "bf_locl.h" #include "bf_pi.h" -void BF_set_key(key,len,data) -BF_KEY *key; -int len; -unsigned char *data; +void BF_set_key(BF_KEY *key, int len, unsigned char *data) { int i; 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) #include #include -#include "blowfish.h" +#include void main(int argc,char *argv[]) { 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 @@ /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ -#ifndef MSDOS +#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) #define TIMES #endif #include -#ifndef MSDOS -#include -#else -#include -extern int exit(); -#endif + +#include +#include OPENSSL_UNISTD_IO +OPENSSL_DECLARE_EXIT + #include -#ifndef VMS #ifndef _IRIX #include #endif @@ -79,34 +77,31 @@ extern int exit(); #include #include #endif -#else /* VMS */ -#include -struct tms { - time_t tms_utime; - time_t tms_stime; - time_t tms_uchild; /* I dunno... */ - time_t tms_uchildsys; /* so these names are a guess :-) */ - } + +/* Depending on the VMS version, the tms structure is perhaps defined. + The __TMS macro will show if it was. If it wasn't defined, we should + undefine TIMES, since that tells the rest of the program how things + should be handled. -- Richard Levitte */ +#if defined(VMS) && defined(__DECC) && !defined(__TMS) +#undef TIMES #endif + #ifndef TIMES #include #endif -#ifdef sun +#if defined(sun) || defined(__ultrix) +#define _POSIX_SOURCE #include #include #endif -#include "blowfish.h" +#include /* The following if from times(3) man page. It may need to be changed */ #ifndef HZ #ifndef CLK_TCK -#ifndef VMS -#define HZ 100.0 -#else /* VMS */ #define HZ 100.0 -#endif #else /* CLK_TCK */ #define HZ ((double)CLK_TCK) #endif @@ -115,12 +110,7 @@ struct tms { #define BUFSIZE ((long)1024) long run=0; -#ifndef NOPROTO double Time_F(int s); -#else -double Time_F(); -#endif - #ifdef SIGALRM #if defined(__STDC__) || defined(sgi) || defined(_AIX) #define SIGRETTYPE void @@ -128,14 +118,8 @@ double Time_F(); #define SIGRETTYPE int #endif -#ifndef NOPROTO SIGRETTYPE sig_done(int sig); -#else -SIGRETTYPE sig_done(); -#endif - -SIGRETTYPE sig_done(sig) -int sig; +SIGRETTYPE sig_done(int sig) { signal(SIGALRM,sig_done); run=0; @@ -148,8 +132,7 @@ int sig; #define START 0 #define STOP 1 -double Time_F(s) -int s; +double Time_F(int s) { double ret; #ifdef TIMES @@ -185,9 +168,7 @@ int s; #endif } -int main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { long count; 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 @@ #include #include #include -#include "blowfish.h" + +#ifdef NO_BF +int main(int argc, char *argv[]) +{ + printf("No BF support\n"); + return(0); +} +#else +#include + +#ifdef CHARSET_EBCDIC +#include +#endif char *bf_key[2]={ "abcdefghijklmnopqrstuvwxyz", @@ -252,17 +264,9 @@ unsigned char key_out[KEY_TEST_NUM][8]={ {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80}, }; -#ifndef NOPROTO static int test(void ); static int print_test_data(void ); -#else -static int test(); -static int print_test_data(); -#endif - -int main(argc,argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { int ret; @@ -275,7 +279,7 @@ char *argv[]; return(0); } -static int print_test_data() +static int print_test_data(void) { unsigned int i,j; @@ -304,7 +308,7 @@ static int print_test_data() printf("c="); for (j=0; j<8; j++) printf("%02X",key_out[i][j]); - printf(" k[%2d]=",i+1); + printf(" k[%2u]=",i+1); for (j=0; j + */ +#else +#define BF_LONG unsigned int +#endif #define BF_ROUNDS 16 #define BF_BLOCK 8 @@ -81,7 +102,6 @@ typedef struct bf_key_st BF_LONG S[4*256]; } BF_KEY; -#ifndef NOPROTO void BF_set_key(BF_KEY *key, int len, unsigned char *data); void 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, BF_KEY *schedule, unsigned char *ivec, int *num, int enc); void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, BF_KEY *schedule, unsigned char *ivec, int *num); -char *BF_options(void); - -#else - -void BF_set_key(); -void BF_ecb_encrypt(); -void BF_encrypt(); -void BF_decrypt(); -void BF_cbc_encrypt(); -void BF_cfb64_encrypt(); -void BF_ofb64_encrypt(); -char *BF_options(); - -#endif +const char *BF_options(void); #ifdef __cplusplus } -- cgit v1.2.3-55-g6feb