summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rc4
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:15:54 +0000
committerdjm <>2008-09-06 12:15:54 +0000
commitf1625f274acf5dcd5601f6cb5e29e233b2a441a3 (patch)
tree44899ddfbef8f24aacbea50086c041c1b150f6d6 /src/lib/libcrypto/rc4
parent4f828b924f54507141fb95ebe49dfcd261945e85 (diff)
downloadopenbsd-f1625f274acf5dcd5601f6cb5e29e233b2a441a3.tar.gz
openbsd-f1625f274acf5dcd5601f6cb5e29e233b2a441a3.tar.bz2
openbsd-f1625f274acf5dcd5601f6cb5e29e233b2a441a3.zip
import of OpenSSL 0.9.8h
Diffstat (limited to 'src/lib/libcrypto/rc4')
-rw-r--r--src/lib/libcrypto/rc4/Makefile63
-rw-r--r--src/lib/libcrypto/rc4/asm/rc4-ia64.S5
-rw-r--r--src/lib/libcrypto/rc4/rc4.c3
-rw-r--r--src/lib/libcrypto/rc4/rc4speed.c3
-rw-r--r--src/lib/libcrypto/rc4/rc4test.c51
5 files changed, 74 insertions, 51 deletions
diff --git a/src/lib/libcrypto/rc4/Makefile b/src/lib/libcrypto/rc4/Makefile
index 20d078ec87..187ed5c668 100644
--- a/src/lib/libcrypto/rc4/Makefile
+++ b/src/lib/libcrypto/rc4/Makefile
@@ -8,23 +8,13 @@ CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES= 9INCLUDES=
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile
17AR= ar r 11AR= ar r
18 12
19RC4_ENC=rc4_enc.o 13RC4_ENC=rc4_enc.o rc4_skey.o
20# or use
21#RC4_ENC=asm/rx86-elf.o
22#RC4_ENC=asm/rx86-out.o
23#RC4_ENC=asm/rx86-sol.o
24#RC4_ENC=asm/rx86bdsi.o
25 14
26CFLAGS= $(INCLUDES) $(CFLAG) 15CFLAGS= $(INCLUDES) $(CFLAG)
27ASFLAGS= $(INCLUDES) $(ASFLAG) 16ASFLAGS= $(INCLUDES) $(ASFLAG)
17AFLAGS= $(ASFLAGS)
28 18
29GENERAL=Makefile 19GENERAL=Makefile
30TEST=rc4test.c 20TEST=rc4test.c
@@ -32,7 +22,7 @@ APPS=
32 22
33LIB=$(TOP)/libcrypto.a 23LIB=$(TOP)/libcrypto.a
34LIBSRC=rc4_skey.c rc4_enc.c 24LIBSRC=rc4_skey.c rc4_enc.c
35LIBOBJ=rc4_skey.o $(RC4_ENC) 25LIBOBJ=$(RC4_ENC)
36 26
37SRC= $(LIBSRC) 27SRC= $(LIBSRC)
38 28
@@ -51,24 +41,19 @@ lib: $(LIBOBJ)
51 $(RANLIB) $(LIB) || echo Never mind. 41 $(RANLIB) $(LIB) || echo Never mind.
52 @touch lib 42 @touch lib
53 43
54# elf 44# ELF
55asm/rx86-elf.s: asm/rc4-586.pl ../perlasm/x86asm.pl 45rx86-elf.s: asm/rc4-586.pl ../perlasm/x86asm.pl
56 (cd asm; $(PERL) rc4-586.pl elf $(CFLAGS) > rx86-elf.s) 46 (cd asm; $(PERL) rc4-586.pl elf $(CFLAGS) > ../$@)
57 47# COFF
48rx86-cof.s: asm/rc4-586.pl ../perlasm/x86asm.pl
49 (cd asm; $(PERL) rc4-586.pl coff $(CFLAGS) > ../$@)
58# a.out 50# a.out
59asm/rx86-out.o: asm/rx86unix.cpp 51rx86-out.s: asm/rc4-586.pl ../perlasm/x86asm.pl
60 $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o 52 (cd asm; $(PERL) rc4-586.pl a.out $(CFLAGS) > ../$@)
61
62# bsdi
63asm/rx86bsdi.o: asm/rx86unix.cpp
64 $(CPP) -DBSDI asm/rx86unix.cpp | sed 's/ :/:/' | as -o asm/rx86bsdi.o
65
66asm/rx86unix.cpp: asm/rc4-586.pl ../perlasm/x86asm.pl
67 (cd asm; $(PERL) rc4-586.pl cpp >rx86unix.cpp)
68 53
69asm/rc4-x86_64.s: asm/rc4-x86_64.pl; $(PERL) asm/rc4-x86_64.pl $@ 54rc4-x86_64.s: asm/rc4-x86_64.pl; $(PERL) asm/rc4-x86_64.pl $@
70 55
71asm/rc4-ia64.s: asm/rc4-ia64.S 56rc4-ia64.s: asm/rc4-ia64.S
72 @case `awk '/^#define RC4_INT/{print$$NF}' $(TOP)/include/openssl/opensslconf.h` in \ 57 @case `awk '/^#define RC4_INT/{print$$NF}' $(TOP)/include/openssl/opensslconf.h` in \
73 int) set -x; $(CC) $(CFLAGS) -DSZ=4 -E asm/rc4-ia64.S > $@ ;; \ 58 int) set -x; $(CC) $(CFLAGS) -DSZ=4 -E asm/rc4-ia64.S > $@ ;; \
74 char) set -x; $(CC) $(CFLAGS) -DSZ=1 -E asm/rc4-ia64.S > $@ ;; \ 59 char) set -x; $(CC) $(CFLAGS) -DSZ=1 -E asm/rc4-ia64.S > $@ ;; \
@@ -84,6 +69,7 @@ links:
84 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) 69 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
85 70
86install: 71install:
72 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
87 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ 73 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
88 do \ 74 do \
89 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ 75 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
@@ -99,6 +85,7 @@ lint:
99 lint -DLINT $(INCLUDES) $(SRC)>fluff 85 lint -DLINT $(INCLUDES) $(SRC)>fluff
100 86
101depend: 87depend:
88 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
102 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) 89 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
103 90
104dclean: 91dclean:
@@ -106,7 +93,7 @@ dclean:
106 mv -f Makefile.new $(MAKEFILE) 93 mv -f Makefile.new $(MAKEFILE)
107 94
108clean: 95clean:
109 rm -f asm/rx86unix.cpp asm/*-elf.* *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o 96 rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
110 97
111# DO NOT DELETE THIS LINE -- make depend depends on it. 98# DO NOT DELETE THIS LINE -- make depend depends on it.
112 99
@@ -114,15 +101,15 @@ rc4_enc.o: ../../e_os.h ../../include/openssl/bio.h
114rc4_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 101rc4_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
115rc4_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 102rc4_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
116rc4_enc.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 103rc4_enc.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
117rc4_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/rc4.h 104rc4_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
118rc4_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 105rc4_enc.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h
119rc4_enc.o: ../../include/openssl/symhacks.h ../cryptlib.h rc4_enc.c rc4_locl.h 106rc4_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
107rc4_enc.o: ../cryptlib.h rc4_enc.c rc4_locl.h
120rc4_skey.o: ../../e_os.h ../../include/openssl/bio.h 108rc4_skey.o: ../../e_os.h ../../include/openssl/bio.h
121rc4_skey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 109rc4_skey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122rc4_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 110rc4_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
123rc4_skey.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 111rc4_skey.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
124rc4_skey.o: ../../include/openssl/opensslconf.h 112rc4_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125rc4_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/rc4.h 113rc4_skey.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h
126rc4_skey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 114rc4_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127rc4_skey.o: ../../include/openssl/symhacks.h ../cryptlib.h rc4_locl.h 115rc4_skey.o: ../cryptlib.h rc4_locl.h rc4_skey.c
128rc4_skey.o: rc4_skey.c
diff --git a/src/lib/libcrypto/rc4/asm/rc4-ia64.S b/src/lib/libcrypto/rc4/asm/rc4-ia64.S
index a322d0c718..8210c47d04 100644
--- a/src/lib/libcrypto/rc4/asm/rc4-ia64.S
+++ b/src/lib/libcrypto/rc4/asm/rc4-ia64.S
@@ -75,14 +75,13 @@ yy=r31;
75.skip 16 75.skip 16
76RC4: 76RC4:
77 .prologue 77 .prologue
78 .fframe 0
79 .save ar.pfs,r2 78 .save ar.pfs,r2
80 .save ar.lc,r3
81 .save pr,prsave
82{ .mii; alloc r2=ar.pfs,4,12,0,16 79{ .mii; alloc r2=ar.pfs,4,12,0,16
80 .save pr,prsave
83 mov prsave=pr 81 mov prsave=pr
84 ADDP key=0,in0 };; 82 ADDP key=0,in0 };;
85{ .mib; cmp.eq p6,p0=0,in1 // len==0? 83{ .mib; cmp.eq p6,p0=0,in1 // len==0?
84 .save ar.lc,r3
86 mov r3=ar.lc 85 mov r3=ar.lc
87(p6) br.ret.spnt.many b0 };; // emergency exit 86(p6) br.ret.spnt.many b0 };; // emergency exit
88 87
diff --git a/src/lib/libcrypto/rc4/rc4.c b/src/lib/libcrypto/rc4/rc4.c
index b39c070292..c900b26055 100644
--- a/src/lib/libcrypto/rc4/rc4.c
+++ b/src/lib/libcrypto/rc4/rc4.c
@@ -60,6 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <openssl/rc4.h> 62#include <openssl/rc4.h>
63#include <openssl/evp.h>
63 64
64char *usage[]={ 65char *usage[]={
65"usage: rc4 args\n", 66"usage: rc4 args\n",
@@ -162,7 +163,7 @@ bad:
162 keystr=buf; 163 keystr=buf;
163 } 164 }
164 165
165 EVP_Digest((unsigned char *)keystr,(unsigned long)strlen(keystr),md,NULL,EVP_md5()); 166 EVP_Digest((unsigned char *)keystr,strlen(keystr),md,NULL,EVP_md5(),NULL);
166 OPENSSL_cleanse(keystr,strlen(keystr)); 167 OPENSSL_cleanse(keystr,strlen(keystr));
167 RC4_set_key(&key,MD5_DIGEST_LENGTH,md); 168 RC4_set_key(&key,MD5_DIGEST_LENGTH,md);
168 169
diff --git a/src/lib/libcrypto/rc4/rc4speed.c b/src/lib/libcrypto/rc4/rc4speed.c
index ced98c52df..0ebd38123d 100644
--- a/src/lib/libcrypto/rc4/rc4speed.c
+++ b/src/lib/libcrypto/rc4/rc4speed.c
@@ -69,7 +69,10 @@
69#include OPENSSL_UNISTD_IO 69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT 70OPENSSL_DECLARE_EXIT
71 71
72#ifndef OPENSSL_SYS_NETWARE
72#include <signal.h> 73#include <signal.h>
74#endif
75
73#ifndef _IRIX 76#ifndef _IRIX
74#include <time.h> 77#include <time.h>
75#endif 78#endif
diff --git a/src/lib/libcrypto/rc4/rc4test.c b/src/lib/libcrypto/rc4/rc4test.c
index b9d8f20975..54b597fa26 100644
--- a/src/lib/libcrypto/rc4/rc4test.c
+++ b/src/lib/libcrypto/rc4/rc4test.c
@@ -70,6 +70,7 @@ int main(int argc, char *argv[])
70} 70}
71#else 71#else
72#include <openssl/rc4.h> 72#include <openssl/rc4.h>
73#include <openssl/sha.h>
73 74
74static unsigned char keys[7][30]={ 75static unsigned char keys[7][30]={
75 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, 76 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
@@ -113,13 +114,11 @@ static unsigned char output[7][30]={
113 114
114int main(int argc, char *argv[]) 115int main(int argc, char *argv[])
115 { 116 {
116 int i,err=0; 117 int err=0;
117 int j; 118 unsigned int i, j;
118 unsigned char *p; 119 unsigned char *p;
119 RC4_KEY key; 120 RC4_KEY key;
120 unsigned char buf[512],obuf[512]; 121 unsigned char obuf[512];
121
122 for (i=0; i<512; i++) buf[i]=0x01;
123 122
124 for (i=0; i<6; i++) 123 for (i=0; i<6; i++)
125 { 124 {
@@ -130,12 +129,12 @@ int main(int argc, char *argv[])
130 { 129 {
131 printf("error calculating RC4\n"); 130 printf("error calculating RC4\n");
132 printf("output:"); 131 printf("output:");
133 for (j=0; j<data_len[i]+1; j++) 132 for (j=0; j<data_len[i]+1U; j++)
134 printf(" %02x",obuf[j]); 133 printf(" %02x",obuf[j]);
135 printf("\n"); 134 printf("\n");
136 printf("expect:"); 135 printf("expect:");
137 p= &(output[i][0]); 136 p= &(output[i][0]);
138 for (j=0; j<data_len[i]+1; j++) 137 for (j=0; j<data_len[i]+1U; j++)
139 printf(" %02x",*(p++)); 138 printf(" %02x",*(p++));
140 printf("\n"); 139 printf("\n");
141 err++; 140 err++;
@@ -181,12 +180,12 @@ int main(int argc, char *argv[])
181 { 180 {
182 printf("error in RC4 multi-call processing\n"); 181 printf("error in RC4 multi-call processing\n");
183 printf("output:"); 182 printf("output:");
184 for (j=0; j<data_len[3]+1; j++) 183 for (j=0; j<data_len[3]+1U; j++)
185 printf(" %02x",obuf[j]); 184 printf(" %02x",obuf[j]);
186 printf("\n"); 185 printf("\n");
187 printf("expect:"); 186 printf("expect:");
188 p= &(output[3][0]); 187 p= &(output[3][0]);
189 for (j=0; j<data_len[3]+1; j++) 188 for (j=0; j<data_len[3]+1U; j++)
190 printf(" %02x",*(p++)); 189 printf(" %02x",*(p++));
191 err++; 190 err++;
192 } 191 }
@@ -197,6 +196,40 @@ int main(int argc, char *argv[])
197 } 196 }
198 } 197 }
199 printf("done\n"); 198 printf("done\n");
199 printf("bulk test ");
200 { unsigned char buf[513];
201 SHA_CTX c;
202 unsigned char md[SHA_DIGEST_LENGTH];
203 static unsigned char expected[]={
204 0xa4,0x7b,0xcc,0x00,0x3d,0xd0,0xbd,0xe1,0xac,0x5f,
205 0x12,0x1e,0x45,0xbc,0xfb,0x1a,0xa1,0xf2,0x7f,0xc5 };
206
207 RC4_set_key(&key,keys[0][0],&(keys[3][1]));
208 memset(buf,'\0',sizeof(buf));
209 SHA1_Init(&c);
210 for (i=0;i<2571;i++) {
211 RC4(&key,sizeof(buf),buf,buf);
212 SHA1_Update(&c,buf,sizeof(buf));
213 }
214 SHA1_Final(md,&c);
215
216 if (memcmp(md,expected,sizeof(md))) {
217 printf("error in RC4 bulk test\n");
218 printf("output:");
219 for (j=0; j<sizeof(md); j++)
220 printf(" %02x",md[j]);
221 printf("\n");
222 printf("expect:");
223 for (j=0; j<sizeof(md); j++)
224 printf(" %02x",expected[j]);
225 printf("\n");
226 err++;
227 }
228 else printf("ok\n");
229 }
230#ifdef OPENSSL_SYS_NETWARE
231 if (err) printf("ERROR: %d\n", err);
232#endif
200 EXIT(err); 233 EXIT(err);
201 return(0); 234 return(0);
202 } 235 }