Extend RC4 test.
authorAndy Polyakov <appro@openssl.org>
Tue, 7 Dec 2004 11:55:56 +0000 (11:55 +0000)
committerAndy Polyakov <appro@openssl.org>
Tue, 7 Dec 2004 11:55:56 +0000 (11:55 +0000)
crypto/rc4/rc4test.c

index 18154025ebade105a362858f330215fc9a916830..d74484b4c469bc93c47160a440d6e89cd3ce41af 100644 (file)
@@ -70,6 +70,7 @@ int main(int argc, char *argv[])
 }
 #else
 #include <openssl/rc4.h>
+#include <openssl/sha.h>
 
 static unsigned char keys[7][30]={
        {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
@@ -197,6 +198,37 @@ int main(int argc, char *argv[])
                        }
                }
        printf("done\n");
+       printf("bulk test ");
+       {   unsigned char buf[513];
+           SHA_CTX c;
+           unsigned char md[SHA_DIGEST_LENGTH];
+           static unsigned char expected[]={
+               0xa4,0x7b,0xcc,0x00,0x3d,0xd0,0xbd,0xe1,0xac,0x5f,
+               0x12,0x1e,0x45,0xbc,0xfb,0x1a,0xa1,0xf2,0x7f,0xc5 };
+
+               RC4_set_key(&key,keys[0][0],&(keys[3][1]));
+               memset(buf,'\0',sizeof(buf));
+               SHA1_Init(&c);
+               for (i=0;i<2571;i++) {
+                       RC4(&key,sizeof(buf),buf,buf);
+                       SHA1_Update(&c,buf,sizeof(buf));
+               }
+               SHA1_Final(md,&c);
+
+               if (memcmp(md,expected,sizeof(md))) {
+                       printf("error in RC4 bulk test\n");
+                       printf("output:");
+                       for (j=0; j<sizeof(md); j++)
+                               printf(" %02x",md[j]);
+                       printf("\n");
+                       printf("expect:");
+                       for (j=0; j<sizeof(md); j++)
+                               printf(" %02x",expected[j]);
+                       printf("\n");
+                       err++;
+               }
+               else    printf("ok\n");
+       }
 #ifdef OPENSSL_SYS_NETWARE
     if (err) printf("ERROR: %d\n", err);
 #endif