aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rc4
diff options
context:
space:
mode:
authorRalf S. Engelschall <rse@openssl.org>1998-12-21 10:56:39 +0000
committerRalf S. Engelschall <rse@openssl.org>1998-12-21 10:56:39 +0000
commit58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch)
treec7b16876a5789463bbbb468ef4829c8129b3d718 /crypto/rc4
parentd02b48c63a58ea4367a0e905979f140b7d090f86 (diff)
downloadopenssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.gz
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'crypto/rc4')
-rw-r--r--crypto/rc4/Makefile.ssl36
-rw-r--r--crypto/rc4/Makefile.uni102
-rw-r--r--crypto/rc4/asm/r4-win32.asm314
-rw-r--r--crypto/rc4/asm/rc4-586.pl173
-rw-r--r--crypto/rc4/asm/rx86unix.cpp358
-rw-r--r--crypto/rc4/rc4.c2
-rw-r--r--crypto/rc4/rc4_enc.c66
-rw-r--r--crypto/rc4/rc4_locl.h70
-rw-r--r--crypto/rc4/rc4_locl.org70
-rw-r--r--crypto/rc4/rc4_skey.c119
-rw-r--r--crypto/rc4/rc4s.cpp73
-rw-r--r--crypto/rc4/rc4speed.c269
-rw-r--r--crypto/rc4/rc4test.c107
13 files changed, 1673 insertions, 86 deletions
diff --git a/crypto/rc4/Makefile.ssl b/crypto/rc4/Makefile.ssl
index 2f40d4ed90..19c1e980f3 100644
--- a/crypto/rc4/Makefile.ssl
+++ b/crypto/rc4/Makefile.ssl
@@ -13,6 +13,13 @@ MAKEDEPEND= makedepend -f Makefile.ssl
MAKEFILE= Makefile.ssl
AR= ar r
+RC4_ENC=rc4_enc.o
+# or use
+#RC4_ENC=asm/rx86-elf.o
+#RC4_ENC=asm/rx86-out.o
+#RC4_ENC=asm/rx86-sol.o
+#RC4_ENC=asm/rx86bdsi.o
+
CFLAGS= $(INCLUDES) $(CFLAG)
GENERAL=Makefile
@@ -20,13 +27,13 @@ TEST=rc4test.c
APPS=
LIB=$(TOP)/libcrypto.a
-LIBSRC=rc4_enc.c
-LIBOBJ=rc4_enc.o
+LIBSRC=rc4_skey.c rc4_enc.c
+LIBOBJ=rc4_skey.o $(RC4_ENC)
SRC= $(LIBSRC)
EXHEADER= rc4.h
-HEADER= $(EXHEADER)
+HEADER= $(EXHEADER) rc4_locl.h
ALL= $(GENERAL) $(SRC) $(HEADER)
@@ -40,6 +47,27 @@ lib: $(LIBOBJ)
sh $(TOP)/util/ranlib.sh $(LIB)
@touch lib
+# elf
+asm/rx86-elf.o: asm/rx86unix.cpp
+ $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o
+
+# solaris
+asm/rx86-sol.o: asm/rx86unix.cpp
+ $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
+ as -o asm/rx86-sol.o asm/rx86-sol.s
+ rm -f asm/rx86-sol.s
+
+# a.out
+asm/rx86-out.o: asm/rx86unix.cpp
+ $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
+
+# bsdi
+asm/rx86bsdi.o: asm/rx86unix.cpp
+ $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o
+
+asm/rx86unix.cpp:
+ (cd asm; perl rc4-586.pl cpp >rx86unix.cpp)
+
files:
perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
@@ -73,7 +101,7 @@ dclean:
mv -f Makefile.new $(MAKEFILE)
clean:
- /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
+ /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
errors:
diff --git a/crypto/rc4/Makefile.uni b/crypto/rc4/Makefile.uni
new file mode 100644
index 0000000000..79dc17b8d1
--- /dev/null
+++ b/crypto/rc4/Makefile.uni
@@ -0,0 +1,102 @@
+# Targets
+# make - twidle the options yourself :-)
+# make cc - standard cc options
+# make gcc - standard gcc options
+# make x86-elf - linux-elf etc
+# make x86-out - linux-a.out, FreeBSD etc
+# make x86-solaris
+# make x86-bdsi
+
+DIR= rc4
+TOP= .
+CC= gcc
+CFLAG= -O3 -fomit-frame-pointer
+
+CPP= $(CC) -E
+INCLUDES=
+INSTALLTOP=/usr/local/lib
+MAKE= make
+MAKEDEPEND= makedepend
+MAKEFILE= Makefile.uni
+AR= ar r
+
+RC4_ENC=rc4_enc.o
+# or use
+#RC4_ENC=asm/rx86-elf.o
+#RC4_ENC=asm/rx86-out.o
+#RC4_ENC=asm/rx86-sol.o
+#RC4_ENC=asm/rx86bdsi.o
+
+CFLAGS= $(INCLUDES) $(CFLAG)
+
+GENERAL=Makefile
+TEST=rc4test
+APPS=rc4speed
+
+LIB=librc4.a
+LIBSRC=rc4_skey.c rc4_enc.c
+LIBOBJ=rc4_skey.o $(RC4_ENC)
+
+SRC= $(LIBSRC)
+
+EXHEADER= rc4.h
+HEADER= $(EXHEADER) rc4_locl.h
+
+ALL= $(GENERAL) $(SRC) $(HEADER)
+
+all: $(LIB) $(TEST) $(APPS)
+
+$(LIB): $(LIBOBJ)
+ $(AR) $(LIB) $(LIBOBJ)
+ sh $(TOP)/ranlib.sh $(LIB)
+
+# elf
+asm/rx86-elf.o: asm/rx86unix.cpp
+ $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o
+
+# solaris
+asm/rx86-sol.o: asm/rx86unix.cpp
+ $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
+ as -o asm/rx86-sol.o asm/rx86-sol.s
+ rm -f asm/rx86-sol.s
+
+# a.out
+asm/rx86-out.o: asm/rx86unix.cpp
+ $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
+
+# bsdi
+asm/rx86bsdi.o: asm/rx86unix.cpp
+ $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o
+
+asm/rx86unix.cpp:
+ (cd asm; perl rc4-586.pl cpp >rx86unix.cpp)
+
+test: $(TEST)
+ ./$(TEST)
+
+$(TEST): $(TEST).c $(LIB)
+ $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
+
+$(APPS): $(APPS).c $(LIB)
+ $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
+
+lint:
+ lint -DLINT $(INCLUDES) $(SRC)>fluff
+
+depend:
+ $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
+
+dclean:
+ perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
+ mv -f Makefile.new $(MAKEFILE)
+
+clean:
+ /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
+
+cc:
+ $(MAKE) CC="cc" CFLAG="-O" all
+
+gcc:
+ $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/crypto/rc4/asm/r4-win32.asm b/crypto/rc4/asm/r4-win32.asm
new file mode 100644
index 0000000000..70b0f7484c
--- /dev/null
+++ b/crypto/rc4/asm/r4-win32.asm
@@ -0,0 +1,314 @@
+ ; Don't even think of reading this code
+ ; It was automatically generated by rc4-586.pl
+ ; Which is a perl program used to generate the x86 assember for
+ ; any of elf, a.out, BSDI,Win32, or Solaris
+ ; eric <eay@cryptsoft.com>
+ ;
+ TITLE rc4-586.asm
+ .386
+.model FLAT
+_TEXT SEGMENT
+PUBLIC _RC4
+
+_RC4 PROC NEAR
+ ;
+ push ebp
+ push ebx
+ mov ebp, DWORD PTR 12[esp]
+ mov ebx, DWORD PTR 16[esp]
+ push esi
+ push edi
+ mov ecx, DWORD PTR [ebp]
+ mov edx, DWORD PTR 4[ebp]
+ mov esi, DWORD PTR 28[esp]
+ inc ecx
+ sub esp, 12
+ add ebp, 8
+ and ecx, 255
+ lea ebx, DWORD PTR [esi+ebx-8]
+ mov edi, DWORD PTR 44[esp]
+ mov DWORD PTR 8[esp],ebx
+ mov eax, DWORD PTR [ecx*4+ebp]
+ cmp ebx, esi
+ jl $L000end
+L001start:
+ add esi, 8
+ ; Round 0
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov BYTE PTR [esp], bl
+ ; Round 1
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov BYTE PTR 1[esp],bl
+ ; Round 2
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov BYTE PTR 2[esp],bl
+ ; Round 3
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov BYTE PTR 3[esp],bl
+ ; Round 4
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov BYTE PTR 4[esp],bl
+ ; Round 5
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov BYTE PTR 5[esp],bl
+ ; Round 6
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov BYTE PTR 6[esp],bl
+ ; Round 7
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ add edi, 8
+ mov BYTE PTR 7[esp],bl
+ ; apply the cipher text
+ mov eax, DWORD PTR [esp]
+ mov ebx, DWORD PTR [esi-8]
+ xor eax, ebx
+ mov ebx, DWORD PTR [esi-4]
+ mov DWORD PTR [edi-8],eax
+ mov eax, DWORD PTR 4[esp]
+ xor eax, ebx
+ mov ebx, DWORD PTR 8[esp]
+ mov DWORD PTR [edi-4],eax
+ mov eax, DWORD PTR [ecx*4+ebp]
+ cmp esi, ebx
+ jle L001start
+$L000end:
+ ; Round 0
+ add ebx, 8
+ inc esi
+ cmp ebx, esi
+ jl $L002finished
+ mov DWORD PTR 8[esp],ebx
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov bh, BYTE PTR [esi-1]
+ xor bl, bh
+ mov BYTE PTR [edi], bl
+ ; Round 1
+ mov ebx, DWORD PTR 8[esp]
+ cmp ebx, esi
+ jle $L002finished
+ inc esi
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov bh, BYTE PTR [esi-1]
+ xor bl, bh
+ mov BYTE PTR 1[edi],bl
+ ; Round 2
+ mov ebx, DWORD PTR 8[esp]
+ cmp ebx, esi
+ jle $L002finished
+ inc esi
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov bh, BYTE PTR [esi-1]
+ xor bl, bh
+ mov BYTE PTR 2[edi],bl
+ ; Round 3
+ mov ebx, DWORD PTR 8[esp]
+ cmp ebx, esi
+ jle $L002finished
+ inc esi
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov bh, BYTE PTR [esi-1]
+ xor bl, bh
+ mov BYTE PTR 3[edi],bl
+ ; Round 4
+ mov ebx, DWORD PTR 8[esp]
+ cmp ebx, esi
+ jle $L002finished
+ inc esi
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov bh, BYTE PTR [esi-1]
+ xor bl, bh
+ mov BYTE PTR 4[edi],bl
+ ; Round 5
+ mov ebx, DWORD PTR 8[esp]
+ cmp ebx, esi
+ jle $L002finished
+ inc esi
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov eax, DWORD PTR [ecx*4+ebp]
+ mov bh, BYTE PTR [esi-1]
+ xor bl, bh
+ mov BYTE PTR 5[edi],bl
+ ; Round 6
+ mov ebx, DWORD PTR 8[esp]
+ cmp ebx, esi
+ jle $L002finished
+ inc esi
+ add edx, eax
+ and edx, 255
+ inc ecx
+ mov ebx, DWORD PTR [edx*4+ebp]
+ mov DWORD PTR [ecx*4+ebp-4],ebx
+ add ebx, eax
+ and ecx, 255
+ and ebx, 255
+ mov DWORD PTR [edx*4+ebp],eax
+ nop
+ mov ebx, DWORD PTR [ebx*4+ebp]
+ mov bh, BYTE PTR [esi-1]
+ xor bl, bh
+ mov BYTE PTR 6[edi],bl
+$L002finished:
+ dec ecx
+ add esp, 12
+ mov DWORD PTR [ebp-4],edx
+ mov BYTE PTR [ebp-8],cl
+ pop edi
+ pop esi
+ pop ebx
+ pop ebp
+ ret
+_RC4 ENDP
+_TEXT ENDS
+END
diff --git a/crypto/rc4/asm/rc4-586.pl b/crypto/rc4/asm/rc4-586.pl
new file mode 100644
index 0000000000..7ef889e5a1
--- /dev/null
+++ b/crypto/rc4/asm/rc4-586.pl
@@ -0,0 +1,173 @@
+#!/usr/local/bin/perl
+
+# define for pentium pro friendly version
+
+push(@INC,"perlasm","../../perlasm");
+require "x86asm.pl";
+
+&asm_init($ARGV[0],"rc4-586.pl");
+
+$tx="eax";
+$ty="ebx";
+$x="ecx";
+$y="edx";
+$in="esi";
+$out="edi";
+$d="ebp";
+
+&RC4("RC4");
+
+&asm_finish();
+
+sub RC4_loop
+ {
+ local($n,$p,$char)=@_;
+
+ &comment("Round $n");
+
+ if ($char)
+ {
+ if ($p >= 0)
+ {
+ &mov($ty, &swtmp(2));
+ &cmp($ty, $in);
+ &jle(&label("finished"));
+ &inc($in);
+ }
+ else
+ {
+ &add($ty, 8);
+ &inc($in);
+ &cmp($ty, $in);
+ &jl(&label("finished"));
+ &mov(&swtmp(2), $ty);
+ }
+ }
+ # Moved out
+ # &mov( $tx, &DWP(0,$d,$x,4)) if $p < 0;
+
+ &add( $y, $tx);
+ &and( $y, 0xff);
+ &inc( $x); # NEXT ROUND
+ &mov( $ty, &DWP(0,$d,$y,4));
+ # XXX
+ &mov( &DWP(-4,$d,$x,4),$ty); # AGI
+ &add( $ty, $tx);
+ &and( $x, 0xff); # NEXT ROUND
+ &and( $ty, 0xff);
+ &mov( &DWP(0,$d,$y,4),$tx);
+ &nop();
+ &mov( $ty, &DWP(0,$d,$ty,4));
+ &mov( $tx, &DWP(0,$d,$x,4)) if $p < 1; # NEXT ROUND
+ # XXX
+
+ if (!$char)
+ {
+ #moved up into last round
+ if ($p >= 1)
+ {
+ &add( $out, 8)
+ }
+ &movb( &BP($n,"esp","",0), &LB($ty));
+ }
+ else
+ {
+ # Note in+=8 has occured
+ &movb( &HB($ty), &BP(-1,$in,"",0));
+ # XXX
+ &xorb(&LB($ty), &HB($ty));
+ # XXX
+ &movb(&BP($n,$out,"",0),&LB($ty));
+ }
+ }
+
+
+sub RC4
+ {
+ local($name)=@_;
+
+ &function_begin_B($name,"");
+
+ &comment("");
+
+ &push("ebp");
+ &push("ebx");
+ &mov( $d, &wparam(0)); # key
+ &mov( $ty, &wparam(1)); # num
+ &push("esi");
+ &push("edi");
+
+ &mov( $x, &DWP(0,$d,"",1));
+ &mov( $y, &DWP(4,$d,"",1));
+
+ &mov( $in, &wparam(2));
+ &inc( $x);
+
+ &stack_push(3); # 3 temp variables
+ &add( $d, 8);
+ &and( $x, 0xff);
+
+ &lea( $ty, &DWP(-8,$ty,$in));
+
+ # check for 0 length input
+
+ &mov( $out, &wparam(3));
+ &mov( &swtmp(2), $ty); # this is now address to exit at
+ &mov( $tx, &DWP(0,$d,$x,4));
+
+ &cmp( $ty, $in);
+ &jl( &label("end")); # less than 8 bytes
+
+ &set_label("start");
+
+ # filling DELAY SLOT
+ &add( $in, 8);
+
+ &RC4_loop(0,-1,0);
+ &RC4_loop(1,0,0);
+ &RC4_loop(2,0,0);
+ &RC4_loop(3,0,0);
+ &RC4_loop(4,0,0);
+ &RC4_loop(5,0,0);
+ &RC4_loop(6,0,0);
+ &RC4_loop(7,1,0);
+
+ &comment("apply the cipher text");
+ # xor the cipher data with input
+
+ #&add( $out, 8); #moved up into last round
+
+ &mov( $tx, &swtmp(0));
+ &mov( $ty, &DWP(-8,$in,"",0));
+ &xor( $tx, $ty);
+ &mov( $ty, &DWP(-4,$in,"",0));
+ &mov( &DWP(-8,$out,"",0), $tx);
+ &mov( $tx, &swtmp(1));
+ &xor( $tx, $ty);
+ &mov( $ty, &swtmp(2)); # load end ptr;
+ &mov( &DWP(-4,$out,"",0), $tx);
+ &mov( $tx, &DWP(0,$d,$x,4));
+ &cmp($in, $ty);
+ &jle(&label("start"));
+
+ &set_label("end");
+
+ # There is quite a bit of extra crap in RC4_loop() for this
+ # first round
+ &RC4_loop(0,-1,1);
+ &RC4_loop(1,0,1);
+ &RC4_loop(2,0,1);
+ &RC4_loop(3,0,1);
+ &RC4_loop(4,0,1);
+ &RC4_loop(5,0,1);
+ &RC4_loop(6,1,1);
+
+ &set_label("finished");
+ &dec( $x);
+ &stack_pop(3);
+ &mov( &DWP(-4,$d,"",0),$y);
+ &movb( &BP(-8,$d,"",0),&LB($x));
+
+ &function_end($name);
+ }
+
diff --git a/crypto/rc4/asm/rx86unix.cpp b/crypto/rc4/asm/rx86unix.cpp
new file mode 100644
index 0000000000..ec1d72a110
--- /dev/null
+++ b/crypto/rc4/asm/rx86unix.cpp
@@ -0,0 +1,358 @@
+/* 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 RC4 _RC4
+
+#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 rc4-586.pl */
+ /* Which is a perl program used to generate the x86 assember for */
+ /* any of elf, a.out, BSDI,Win32, or Solaris */
+ /* eric <eay@cryptsoft.com> */
+
+ .file "rc4-586.s"
+ .version "01.01"
+gcc2_compiled.:
+.text
+ .align ALIGN
+.globl RC4
+ TYPE(RC4,@function)
+RC4:
+
+ pushl %ebp
+ pushl %ebx
+ movl 12(%esp), %ebp
+ movl 16(%esp), %ebx
+ pushl %esi
+ pushl %edi
+ movl (%ebp), %ecx
+ movl 4(%ebp), %edx
+ movl 28(%esp), %esi
+ incl %ecx
+ subl $12, %esp
+ addl $8, %ebp
+ andl $255, %ecx
+ leal -8(%ebx,%esi,), %ebx
+ movl 44(%esp), %edi
+ movl %ebx, 8(%esp)
+ movl (%ebp,%ecx,4), %eax
+ cmpl %esi, %ebx
+ jl .L000end
+.L001start:
+ addl $8, %esi
+ /* Round 0 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb %bl, (%esp)
+ /* Round 1 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb %bl, 1(%esp)
+ /* Round 2 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb %bl, 2(%esp)
+ /* Round 3 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb %bl, 3(%esp)
+ /* Round 4 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb %bl, 4(%esp)
+ /* Round 5 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb %bl, 5(%esp)
+ /* Round 6 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb %bl, 6(%esp)
+ /* Round 7 */
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ addl $8, %edi
+ movb %bl, 7(%esp)
+ /* apply the cipher text */
+ movl (%esp), %eax
+ movl -8(%esi), %ebx
+ xorl %ebx, %eax
+ movl -4(%esi), %ebx
+ movl %eax, -8(%edi)
+ movl 4(%esp), %eax
+ xorl %ebx, %eax
+ movl 8(%esp), %ebx
+ movl %eax, -4(%edi)
+ movl (%ebp,%ecx,4), %eax
+ cmpl %ebx, %esi
+ jle .L001start
+.L000end:
+ /* Round 0 */
+ addl $8, %ebx
+ incl %esi
+ cmpl %esi, %ebx
+ jl .L002finished
+ movl %ebx, 8(%esp)
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb -1(%esi), %bh
+ xorb %bh, %bl
+ movb %bl, (%edi)
+ /* Round 1 */
+ movl 8(%esp), %ebx
+ cmpl %esi, %ebx
+ jle .L002finished
+ incl %esi
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb -1(%esi), %bh
+ xorb %bh, %bl
+ movb %bl, 1(%edi)
+ /* Round 2 */
+ movl 8(%esp), %ebx
+ cmpl %esi, %ebx
+ jle .L002finished
+ incl %esi
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb -1(%esi), %bh
+ xorb %bh, %bl
+ movb %bl, 2(%edi)
+ /* Round 3 */
+ movl 8(%esp), %ebx
+ cmpl %esi, %ebx
+ jle .L002finished
+ incl %esi
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb -1(%esi), %bh
+ xorb %bh, %bl
+ movb %bl, 3(%edi)
+ /* Round 4 */
+ movl 8(%esp), %ebx
+ cmpl %esi, %ebx
+ jle .L002finished
+ incl %esi
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb -1(%esi), %bh
+ xorb %bh, %bl
+ movb %bl, 4(%edi)
+ /* Round 5 */
+ movl 8(%esp), %ebx
+ cmpl %esi, %ebx
+ jle .L002finished
+ incl %esi
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movl (%ebp,%ecx,4), %eax
+ movb -1(%esi), %bh
+ xorb %bh, %bl
+ movb %bl, 5(%edi)
+ /* Round 6 */
+ movl 8(%esp), %ebx
+ cmpl %esi, %ebx
+ jle .L002finished
+ incl %esi
+ addl %eax, %edx
+ andl $255, %edx
+ incl %ecx
+ movl (%ebp,%edx,4), %ebx
+ movl %ebx, -4(%ebp,%ecx,4)
+ addl %eax, %ebx
+ andl $255, %ecx
+ andl $255, %ebx
+ movl %eax, (%ebp,%edx,4)
+ nop
+ movl (%ebp,%ebx,4), %ebx
+ movb -1(%esi), %bh
+ xorb %bh, %bl
+ movb %bl, 6(%edi)
+.L002finished:
+ decl %ecx
+ addl $12, %esp
+ movl %edx, -4(%ebp)
+ movb %cl, -8(%ebp)
+ popl %edi
+ popl %esi
+ popl %ebx
+ popl %ebp
+ ret
+.RC4_end:
+ SIZE(RC4,.RC4_end-RC4)
+.ident "RC4"
diff --git a/crypto/rc4/rc4.c b/crypto/rc4/rc4.c
index 37965d5262..127e8a5093 100644
--- a/crypto/rc4/rc4.c
+++ b/crypto/rc4/rc4.c
@@ -1,5 +1,5 @@
/* crypto/rc4/rc4.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
diff --git a/crypto/rc4/rc4_enc.c b/crypto/rc4/rc4_enc.c
index de57a970bf..ab8a111b52 100644
--- a/crypto/rc4/rc4_enc.c
+++ b/crypto/rc4/rc4_enc.c
@@ -1,5 +1,5 @@
-/* crypto/rc4/rc4_enc.org */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* crypto/rc4/rc4_enc.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -56,35 +56,8 @@
* [including the GNU Public Licence.]
*/
-/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
- *
- * Always modify rc4_enc.org since rc4_enc.c is automatically generated from
- * it during SSLeay configuration.
- * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
- */
-
#include "rc4.h"
-
-/* if this is defined data[i] is used instead of *data, this is a %20
- * speedup on x86 */
-#undef RC4_INDEX
-
-char *RC4_version="RC4 part of SSLeay 0.8.1a 24-Jun-1998";
-
-char *RC4_options()
- {
-#ifdef RC4_INDEX
- if (sizeof(RC4_INT) == 1)
- return("rc4(idx,char)");
- else
- return("rc4(idx,int)");
-#else
- if (sizeof(RC4_INT) == 1)
- return("rc4(ptr,char)");
- else
- return("rc4(ptr,int)");
-#endif
- }
+#include "rc4_locl.h"
/* RC4 as implemented from a posting from
* Newsgroups: sci.crypt
@@ -94,39 +67,6 @@ char *RC4_options()
* Date: Wed, 14 Sep 1994 06:35:31 GMT
*/
-void RC4_set_key(key, len, data)
-RC4_KEY *key;
-int len;
-register unsigned char *data;
- {
- register RC4_INT tmp;
- register int id1,id2;
- register RC4_INT *d;
- unsigned int i;
-
- d= &(key->data[0]);
- for (i=0; i<256; i++)
- d[i]=i;
- key->x = 0;
- key->y = 0;
- id1=id2=0;
-
-#define SK_LOOP(n) { \
- tmp=d[(n)]; \
- id2 = (data[id1] + tmp + id2) & 0xff; \
- if (++id1 == len) id1=0; \
- d[(n)]=d[id2]; \
- d[id2]=tmp; }
-
- for (i=0; i < 256; i+=4)
- {
- SK_LOOP(i+0);
- SK_LOOP(i+1);
- SK_LOOP(i+2);
- SK_LOOP(i+3);
- }
- }
-
void RC4(key, len, indata, outdata)
RC4_KEY *key;
unsigned long len;
diff --git a/crypto/rc4/rc4_locl.h b/crypto/rc4/rc4_locl.h
new file mode 100644
index 0000000000..1ef4455fb7
--- /dev/null
+++ b/crypto/rc4/rc4_locl.h
@@ -0,0 +1,70 @@
+/* crypto/rc4/rc4_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
+ */
+
+/* if this is defined data[i] is used instead of *data, this is a %20
+ * speedup on x86 */
+#undef RC4_INDEX
+
diff --git a/crypto/rc4/rc4_locl.org b/crypto/rc4/rc4_locl.org
new file mode 100644
index 0000000000..1ef4455fb7
--- /dev/null
+++ b/crypto/rc4/rc4_locl.org
@@ -0,0 +1,70 @@
+/* crypto/rc4/rc4_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
+ */
+
+/* if this is defined data[i] is used instead of *data, this is a %20
+ * speedup on x86 */
+#undef RC4_INDEX
+
diff --git a/crypto/rc4/rc4_skey.c b/crypto/rc4/rc4_skey.c
new file mode 100644
index 0000000000..0be5fde67b
--- /dev/null
+++ b/crypto/rc4/rc4_skey.c
@@ -0,0 +1,119 @@
+/* crypto/rc4/rc4_skey.c */
+/* Copyright (C) 1995-1998 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.]
+ */
+
+#include "rc4.h"
+#include "rc4_locl.h"
+
+char *RC4_version="RC4 part of SSLeay 0.9.0b 29-Jun-1998";
+
+char *RC4_options()
+ {
+#ifdef RC4_INDEX
+ if (sizeof(RC4_INT) == 1)
+ return("rc4(idx,char)");
+ else
+ return("rc4(idx,int)");
+#else
+ if (sizeof(RC4_INT) == 1)
+ return("rc4(ptr,char)");
+ else
+ return("rc4(ptr,int)");
+#endif
+ }
+
+/* RC4 as implemented from a posting from
+ * Newsgroups: sci.crypt
+ * From: sterndark@netcom.com (David Sterndark)
+ * Subject: RC4 Algorithm revealed.
+ * Message-ID: <sternCvKL4B.Hyy@netcom.com>
+ * Date: Wed, 14 Sep 1994 06:35:31 GMT
+ */
+
+void RC4_set_key(key, len, data)
+RC4_KEY *key;
+int len;
+register unsigned char *data;
+ {
+ register RC4_INT tmp;
+ register int id1,id2;
+ register RC4_INT *d;
+ unsigned int i;
+
+ d= &(key->data[0]);
+ for (i=0; i<256; i++)
+ d[i]=i;
+ key->x = 0;
+ key->y = 0;
+ id1=id2=0;
+
+#define SK_LOOP(n) { \
+ tmp=d[(n)]; \
+ id2 = (data[id1] + tmp + id2) & 0xff; \
+ if (++id1 == len) id1=0; \
+ d[(n)]=d[id2]; \
+ d[id2]=tmp; }
+
+ for (i=0; i < 256; i+=4)
+ {
+ SK_LOOP(i+0);
+ SK_LOOP(i+1);
+ SK_LOOP(i+2);
+ SK_LOOP(i+3);
+ }
+ }
+
diff --git a/crypto/rc4/rc4s.cpp b/crypto/rc4/rc4s.cpp
new file mode 100644
index 0000000000..39f1727dd3
--- /dev/null
+++ b/crypto/rc4/rc4s.cpp
@@ -0,0 +1,73 @@
+//
+// gettsc.inl
+//
+// gives access to the Pentium's (secret) cycle counter
+//
+// This software was written by Leonard Janke (janke@unixg.ubc.ca)
+// in 1996-7 and is entered, by him, into the public domain.
+
+#if defined(__WATCOMC__)
+void GetTSC(unsigned long&);
+#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
+#elif defined(__GNUC__)
+inline
+void GetTSC(unsigned long& tsc)
+{
+ asm volatile(".byte 15, 49\n\t"
+ : "=eax" (tsc)
+ :
+ : "%edx", "%eax");
+}
+#elif defined(_MSC_VER)
+inline
+void GetTSC(unsigned long& tsc)
+{
+ unsigned long a;
+ __asm _emit 0fh
+ __asm _emit 31h
+ __asm mov a, eax;
+ tsc=a;
+}
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "rc4.h"
+
+void main(int argc,char *argv[])
+ {
+ unsigned char buffer[1024];
+ RC4_KEY ctx;
+ unsigned long s1,s2,e1,e2;
+ unsigned char k[16];
+ unsigned long data[2];
+ unsigned char iv[8];
+ int i,num=64,numm;
+ int j=0;
+
+ if (argc >= 2)
+ num=atoi(argv[1]);
+
+ if (num == 0) num=256;
+ if (num > 1024-16) num=1024-16;
+ numm=num+8;
+
+ for (j=0; j<6; j++)
+ {
+ for (i=0; i<10; i++) /**/
+ {
+ RC4(&ctx,numm,buffer,buffer);
+ GetTSC(s1);
+ RC4(&ctx,numm,buffer,buffer);
+ GetTSC(e1);
+ GetTSC(s2);
+ RC4(&ctx,num,buffer,buffer);
+ GetTSC(e2);
+ RC4(&ctx,num,buffer,buffer);
+ }
+
+ printf("RC4 (%d bytes) %d %d (%d) - 8 bytes\n",num,
+ e1-s1,e2-s2,(e1-s1)-(e2-s2));
+ }
+ }
+
diff --git a/crypto/rc4/rc4speed.c b/crypto/rc4/rc4speed.c
new file mode 100644
index 0000000000..5298dad6d0
--- /dev/null
+++ b/crypto/rc4/rc4speed.c
@@ -0,0 +1,269 @@
+/* crypto/rc4/rc4speed.c */
+/* Copyright (C) 1995-1998 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.]
+ */
+
+/* 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
+#define TIMES
+#endif
+
+#include <stdio.h>
+#ifndef MSDOS
+#include <unistd.h>
+#else
+#include <io.h>
+extern int exit();
+#endif
+#include <signal.h>
+#ifndef VMS
+#ifndef _IRIX
+#include <time.h>
+#endif
+#ifdef TIMES
+#include <sys/types.h>
+#include <sys/times.h>
+#endif
+#else /* VMS */
+#include <types.h>
+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 :-) */
+ }
+#endif
+#ifndef TIMES
+#include <sys/timeb.h>
+#endif
+
+#ifdef sun
+#include <limits.h>
+#include <sys/param.h>
+#endif
+
+#include "rc4.h"
+
+/* 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
+#endif
+
+#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
+#else
+#define SIGRETTYPE int
+#endif
+
+#ifndef NOPROTO
+SIGRETTYPE sig_done(int sig);
+#else
+SIGRETTYPE sig_done();
+#endif
+
+SIGRETTYPE sig_done(sig)
+int sig;
+ {
+ signal(SIGALRM,sig_done);
+ run=0;
+#ifdef LINT
+ sig=sig;
+#endif
+ }
+#endif
+
+#define START 0
+#define STOP 1
+
+double Time_F(s)
+int s;
+ {
+ double ret;
+#ifdef TIMES
+ static struct tms tstart,tend;
+
+ if (s == START)
+ {
+ times(&tstart);
+ return(0);
+ }
+ else
+ {
+ times(&tend);
+ ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
+ return((ret == 0.0)?1e-6:ret);
+ }
+#else /* !times() */
+ static struct timeb tstart,tend;
+ long i;
+
+ if (s == START)
+ {
+ ftime(&tstart);
+ return(0);
+ }
+ else
+ {
+ ftime(&tend);
+ i=(long)tend.millitm-(long)tstart.millitm;
+ ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
+ return((ret == 0.0)?1e-6:ret);
+ }
+#endif
+ }
+
+int main(argc,argv)
+int argc;
+char **argv;
+ {
+ long count;
+ static unsigned char buf[BUFSIZE];
+ static unsigned char key[] ={
+ 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
+ 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
+ };
+ RC4_KEY sch;
+ double a,b,c,d;
+#ifndef SIGALRM
+ long ca,cb,cc;
+#endif
+
+#ifndef TIMES
+ printf("To get the most acurate results, try to run this\n");
+ printf("program when this computer is idle.\n");
+#endif
+
+#ifndef SIGALRM
+ printf("First we calculate the approximate speed ...\n");
+ RC4_set_key(&sch,16,key);
+ count=10;
+ do {
+ long i;
+ unsigned long data[2];
+
+ count*=2;
+ Time_F(START);
+ for (i=count; i; i--)
+ RC4(&sch,8,buf,buf);
+ d=Time_F(STOP);
+ } while (d < 3.0);
+ ca=count/512;
+ cc=count*8/BUFSIZE+1;
+ printf("Doing RC4_set_key %ld times\n",ca);
+#define COND(d) (count != (d))
+#define COUNT(d) (d)
+#else
+#define COND(c) (run)
+#define COUNT(d) (count)
+ signal(SIGALRM,sig_done);
+ printf("Doing RC4_set_key for 10 seconds\n");
+ alarm(10);
+#endif
+
+ Time_F(START);
+ for (count=0,run=1; COND(ca); count+=4)
+ {
+ RC4_set_key(&sch,16,key);
+ RC4_set_key(&sch,16,key);
+ RC4_set_key(&sch,16,key);
+ RC4_set_key(&sch,16,key);
+ }
+ d=Time_F(STOP);
+ printf("%ld RC4_set_key's in %.2f seconds\n",count,d);
+ a=((double)COUNT(ca))/d;
+
+#ifdef SIGALRM
+ printf("Doing RC4 on %ld byte blocks for 10 seconds\n",BUFSIZE);
+ alarm(10);
+#else
+ printf("Doing RC4 %ld times on %ld byte blocks\n",cc,BUFSIZE);
+#endif
+ Time_F(START);
+ for (count=0,run=1; COND(cc); count++)
+ RC4(&sch,BUFSIZE,buf,buf);
+ d=Time_F(STOP);
+ printf("%ld RC4's of %ld byte blocks in %.2f second\n",
+ count,BUFSIZE,d);
+ c=((double)COUNT(cc)*BUFSIZE)/d;
+
+ printf("RC4 set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
+ printf("RC4 bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
+ exit(0);
+#if defined(LINT) || defined(MSDOS)
+ return(0);
+#endif
+ }
+
diff --git a/crypto/rc4/rc4test.c b/crypto/rc4/rc4test.c
index aa4053e644..041e1aff95 100644
--- a/crypto/rc4/rc4test.c
+++ b/crypto/rc4/rc4test.c
@@ -1,5 +1,5 @@
/* crypto/rc4/rc4test.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -61,27 +61,43 @@
#include <string.h>
#include "rc4.h"
-unsigned char keys[6][11]={
+unsigned char keys[7][30]={
{8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
{8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
{8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{4,0xef,0x01,0x23,0x45},
{8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
+ {4,0xef,0x01,0x23,0x45},
};
-unsigned char data[6][11]={
- {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
- {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
- {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
- {10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+unsigned char data_len[7]={8,8,8,20,28,10};
+unsigned char data[7][30]={
+ {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff},
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff},
+ {0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
+ 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
+ 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
+ 0x12,0x34,0x56,0x78,0xff},
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
{0},
};
-unsigned char output[6][11]={
- {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96},
- {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79},
- {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a},
- {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,0xbd,0x61},
+unsigned char output[7][30]={
+ {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00},
+ {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00},
+ {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00},
+ {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,
+ 0xbd,0x61,0x5a,0x11,0x62,0xe1,0xc7,0xba,
+ 0x36,0xb6,0x78,0x58,0x00},
+ {0x66,0xa0,0x94,0x9f,0x8a,0xf7,0xd6,0x89,
+ 0x1f,0x7f,0x83,0x2b,0xa8,0x33,0xc0,0x0c,
+ 0x89,0x2e,0xbe,0x30,0x14,0x3c,0xe2,0x87,
+ 0x40,0x01,0x1e,0xcf,0x00},
+ {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,0xbd,0x61,0x00},
{0},
};
@@ -90,27 +106,28 @@ int argc;
char *argv[];
{
int i,err=0;
- unsigned int j;
+ int j;
unsigned char *p;
RC4_KEY key;
unsigned char buf[512],obuf[512];
for (i=0; i<512; i++) buf[i]=0x01;
- for (i=0; i<4; i++)
+ for (i=0; i<6; i++)
{
RC4_set_key(&key,keys[i][0],&(keys[i][1]));
- RC4(&key,data[i][0],&(data[i][1]),obuf);
- if (memcmp(obuf,output[i],data[i][0]) != 0)
+ memset(obuf,0x00,sizeof(obuf));
+ RC4(&key,data_len[i],&(data[i][0]),obuf);
+ if (memcmp(obuf,output[i],data_len[i]+1) != 0)
{
printf("error calculating RC4\n");
printf("output:");
- for (j=0; j<data[i][0]; j++)
+ for (j=0; j<data_len[i]+1; j++)
printf(" %02x",obuf[j]);
printf("\n");
printf("expect:");
p= &(output[i][0]);
- for (j=0; j<data[i][0]; j++)
+ for (j=0; j<data_len[i]+1; j++)
printf(" %02x",*(p++));
printf("\n");
err++;
@@ -118,6 +135,60 @@ char *argv[];
else
printf("test %d ok\n",i);
}
+ printf("test end processing ");
+ for (i=0; i<data_len[3]; i++)
+ {
+ RC4_set_key(&key,keys[3][0],&(keys[3][1]));
+ memset(obuf,0x00,sizeof(obuf));
+ RC4(&key,i,&(data[3][0]),obuf);
+ if ((memcmp(obuf,output[3],i) != 0) || (obuf[i] != 0))
+ {
+ printf("error in RC4 length processing\n");
+ printf("output:");
+ for (j=0; j<i+1; j++)
+ printf(" %02x",obuf[j]);
+ printf("\n");
+ printf("expect:");
+ p= &(output[3][0]);
+ for (j=0; j<i; j++)
+ printf(" %02x",*(p++));
+ printf(" 00\n");
+ err++;
+ }
+ else
+ {
+ printf(".");
+ fflush(stdout);
+ }
+ }
+ printf("done\n");
+ printf("test multi-call ");
+ for (i=0; i<data_len[3]; i++)
+ {
+ RC4_set_key(&key,keys[3][0],&(keys[3][1]));
+ memset(obuf,0x00,sizeof(obuf));
+ RC4(&key,i,&(data[3][0]),obuf);
+ RC4(&key,data_len[3]-i,&(data[3][i]),&(obuf[i]));
+ if (memcmp(obuf,output[3],data_len[3]+1) != 0)
+ {
+ printf("error in RC4 multi-call processing\n");
+ printf("output:");
+ for (j=0; j<data_len[3]+1; j++)
+ printf(" %02x",obuf[j]);
+ printf("\n");
+ printf("expect:");
+ p= &(output[3][0]);
+ for (j=0; j<data_len[3]+1; j++)
+ printf(" %02x",*(p++));
+ err++;
+ }
+ else
+ {
+ printf(".");
+ fflush(stdout);
+ }
+ }
+ printf("done\n");
exit(err);
return(0);
}