66 int main(
int argc,
char *argv[])
68 printf(
"No RC4 support\n");
75 static unsigned char keys[7][30]={
76 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
77 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
78 {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
79 {4,0xef,0x01,0x23,0x45},
80 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
81 {4,0xef,0x01,0x23,0x45},
84 static unsigned char data_len[7]={8,8,8,20,28,10};
85 static unsigned char data[7][30]={
86 {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff},
87 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
88 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
89 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
90 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
91 0x00,0x00,0x00,0x00,0xff},
92 {0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
93 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
94 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
95 0x12,0x34,0x56,0x78,0xff},
96 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
100 static unsigned char output[7][30]={
101 {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00},
102 {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00},
103 {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00},
104 {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,
105 0xbd,0x61,0x5a,0x11,0x62,0xe1,0xc7,0xba,
106 0x36,0xb6,0x78,0x58,0x00},
107 {0x66,0xa0,0x94,0x9f,0x8a,0xf7,0xd6,0x89,
108 0x1f,0x7f,0x83,0x2b,0xa8,0x33,0xc0,0x0c,
109 0x89,0x2e,0xbe,0x30,0x14,0x3c,0xe2,0x87,
110 0x40,0x01,0x1e,0xcf,0x00},
111 {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,0xbd,0x61,0x00},
115 int main(
int argc,
char *argv[])
121 unsigned char obuf[512];
123 #if !defined(OPENSSL_PIC)
132 memset(obuf,0x00,
sizeof(obuf));
133 RC4(&key,data_len[i],&(data[i][0]),obuf);
134 if (memcmp(obuf,output[i],data_len[i]+1) != 0)
136 printf(
"error calculating RC4\n");
138 for (j=0; j<data_len[i]+1; j++)
139 printf(
" %02x",obuf[j]);
143 for (j=0; j<data_len[i]+1; j++)
144 printf(
" %02x",*(p++));
149 printf(
"test %d ok\n",i);
151 printf(
"test end processing ");
152 for (i=0; i<data_len[3]; i++)
155 memset(obuf,0x00,
sizeof(obuf));
156 RC4(&key,i,&(data[3][0]),obuf);
157 if ((memcmp(obuf,output[3],i) != 0) || (obuf[i] != 0))
159 printf(
"error in RC4 length processing\n");
161 for (j=0; j<i+1; j++)
162 printf(
" %02x",obuf[j]);
167 printf(
" %02x",*(p++));
178 printf(
"test multi-call ");
179 for (i=0; i<data_len[3]; i++)
182 memset(obuf,0x00,
sizeof(obuf));
183 RC4(&key,i,&(data[3][0]),obuf);
184 RC4(&key,data_len[3]-i,&(data[3][i]),&(obuf[i]));
185 if (memcmp(obuf,output[3],data_len[3]+1) != 0)
187 printf(
"error in RC4 multi-call processing\n");
189 for (j=0; j<data_len[3]+1; j++)
190 printf(
" %02x",obuf[j]);
194 for (j=0; j<data_len[3]+1; j++)
195 printf(
" %02x",*(p++));
205 printf(
"bulk test ");
206 {
unsigned char buf[513];
209 static unsigned char expected[]={
210 0xa4,0x7b,0xcc,0x00,0x3d,0xd0,0xbd,0xe1,0xac,0x5f,
211 0x12,0x1e,0x45,0xbc,0xfb,0x1a,0xa1,0xf2,0x7f,0xc5 };
214 memset(buf,
'\0',
sizeof(buf));
216 for (i=0;i<2571;i++) {
217 RC4(&key,
sizeof(buf),buf,buf);
222 if (memcmp(md,expected,
sizeof(md))) {
223 printf(
"error in RC4 bulk test\n");
225 for (j=0; j<(int)
sizeof(md); j++)
226 printf(
" %02x",md[j]);
229 for (j=0; j<(int)
sizeof(md); j++)
230 printf(
" %02x",expected[j]);
236 #ifdef OPENSSL_SYS_NETWARE
237 if (err) printf(
"ERROR: %d\n", err);