提交 17f0e916 编写于 作者: A Andy Polyakov

Extend RC4 test.

上级 3dfa23cb
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册