summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rc4/rc4test.c
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:17:54 +0000
committerdjm <>2008-09-06 12:17:54 +0000
commit38ce604e3cc97706b876b0525ddff0121115456d (patch)
tree7ccc28afe1789ea3dbedf72365f955d5b8e105b5 /src/lib/libcrypto/rc4/rc4test.c
parent12867252827c8efaa8ddd1fa3b3d6e321e2bcdef (diff)
downloadopenbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.gz
openbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.bz2
openbsd-38ce604e3cc97706b876b0525ddff0121115456d.zip
resolve conflicts
Diffstat (limited to 'src/lib/libcrypto/rc4/rc4test.c')
-rw-r--r--src/lib/libcrypto/rc4/rc4test.c51
1 files changed, 42 insertions, 9 deletions
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 }