diff options
author | Andy Polyakov <appro@openssl.org> | 2004-12-07 11:55:56 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2004-12-07 11:55:56 +0000 |
commit | 17f0e916db41a9201267a7f4178bd325a027b735 (patch) | |
tree | 3c7490d93012a9295d168523aad4322fa1ac541d /crypto | |
parent | 3dfa23cbc4b9d39627b7de2fec4b2d61d347f077 (diff) |
Extend RC4 test.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/rc4/rc4test.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crypto/rc4/rc4test.c b/crypto/rc4/rc4test.c index 18154025eb..d74484b4c4 100644 --- a/crypto/rc4/rc4test.c +++ b/crypto/rc4/rc4test.c @@ -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 |