aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rc4
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/rc4')
-rw-r--r--crypto/rc4/Makefile.ssl5
-rw-r--r--crypto/rc4/Makefile.uni103
-rw-r--r--crypto/rc4/asm/r4-win32.asm314
-rw-r--r--crypto/rc4/rc4.h8
4 files changed, 423 insertions, 7 deletions
diff --git a/crypto/rc4/Makefile.ssl b/crypto/rc4/Makefile.ssl
index 53eac2064a4..64092fd4f1c 100644
--- a/crypto/rc4/Makefile.ssl
+++ b/crypto/rc4/Makefile.ssl
@@ -5,7 +5,6 @@
DIR= rc4
TOP= ../..
CC= cc
-CPP= $(CC) -E
INCLUDES=
CFLAG=-g
INSTALL_PREFIX=
@@ -52,7 +51,7 @@ lib: $(LIBOBJ)
# elf
asm/rx86-elf.o: asm/rx86unix.cpp
- $(CPP) -DELF -x c asm/rx86unix.cpp | as -o asm/rx86-elf.o
+ $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o
# solaris
asm/rx86-sol.o: asm/rx86unix.cpp
@@ -68,7 +67,7 @@ asm/rx86-out.o: asm/rx86unix.cpp
asm/rx86bsdi.o: asm/rx86unix.cpp
$(CPP) -DBSDI asm/rx86unix.cpp | sed 's/ :/:/' | as -o asm/rx86bsdi.o
-asm/rx86unix.cpp: asm/rc4-586.pl ../perlasm/x86asm.pl
+asm/rx86unix.cpp: asm/rc4-586.pl
(cd asm; $(PERL) rc4-586.pl cpp >rx86unix.cpp)
files:
diff --git a/crypto/rc4/Makefile.uni b/crypto/rc4/Makefile.uni
new file mode 100644
index 00000000000..855d9e50f37
--- /dev/null
+++ b/crypto/rc4/Makefile.uni
@@ -0,0 +1,103 @@
+# 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
+RANLIB= ranlib
+
+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)
+ $(RANLIB) $(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 00000000000..70b0f7484cd
--- /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
+ ;
+ 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/rc4.h b/crypto/rc4/rc4.h
index 40251024a42..8556dddab0e 100644
--- a/crypto/rc4/rc4.h
+++ b/crypto/rc4/rc4.h
@@ -59,16 +59,16 @@
#ifndef HEADER_RC4_H
#define HEADER_RC4_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifdef NO_RC4
#error RC4 is disabled.
#endif
#include <openssl/opensslconf.h> /* RC4_INT */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct rc4_key_st
{
RC4_INT x,y;