diff options
author | Andy Polyakov <appro@openssl.org> | 2004-07-22 10:21:13 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2004-07-22 10:21:13 +0000 |
commit | e39c2548f522a9293376a19fdbe466514a882d16 (patch) | |
tree | 2f4dfc01575d6745cf8d97bf85199f25b2af5d25 /crypto/sha/sha256t.c | |
parent | 8169dd73f90df9acaebb601bde2bbb0d36bf9893 (diff) |
Run SHA-256/-512 tests through EVP...
Diffstat (limited to 'crypto/sha/sha256t.c')
-rw-r--r-- | crypto/sha/sha256t.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/crypto/sha/sha256t.c b/crypto/sha/sha256t.c index e211c9c24f..20580faf5a 100644 --- a/crypto/sha/sha256t.c +++ b/crypto/sha/sha256t.c @@ -8,6 +8,7 @@ #include <stdlib.h> #include <openssl/sha.h> +#include <openssl/evp.h> unsigned char app_b1[SHA256_DIGEST_LENGTH] = { 0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea, @@ -48,11 +49,11 @@ unsigned char addenum_3[SHA224_DIGEST_LENGTH] = { int main () { unsigned char md[SHA256_DIGEST_LENGTH]; int i; - SHA256_CTX ctx; + EVP_MD_CTX evp; fprintf(stdout,"Testing SHA-256 "); - SHA256((unsigned char *)"abc",3,md); + EVP_Digest ("abc",3,md,NULL,EVP_sha256(),NULL); if (memcmp(md,app_b1,sizeof(app_b1))) { fflush(stdout); fprintf(stderr,"\nTEST 1 of 3 failed.\n"); @@ -61,8 +62,8 @@ int main () else fprintf(stdout,"."); fflush(stdout); - SHA256((unsigned char *)"abcdbcde""cdefdefg""efghfghi""ghijhijk" - "ijkljklm""klmnlmno""mnopnopq",56,md); + EVP_Digest ("abcdbcde""cdefdefg""efghfghi""ghijhijk" + "ijkljklm""klmnlmno""mnopnopq",56,md,NULL,EVP_sha256(),NULL); if (memcmp(md,app_b2,sizeof(app_b2))) { fflush(stdout); fprintf(stderr,"\nTEST 2 of 3 failed.\n"); @@ -71,12 +72,14 @@ int main () else fprintf(stdout,"."); fflush(stdout); - SHA256_Init(&ctx); + EVP_MD_CTX_init (&evp); + EVP_DigestInit_ex (&evp,EVP_sha256(),NULL); for (i=0;i<1000000;i+=64) - SHA256_Update(&ctx, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" - "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", - (1000000-i)<64?1000000-i:64); - SHA256_Final(md,&ctx); + EVP_DigestUpdate (&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" + "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", + (1000000-i)<64?1000000-i:64); + EVP_DigestFinal_ex (&evp,md,NULL); + EVP_MD_CTX_cleanup (&evp); if (memcmp(md,app_b3,sizeof(app_b3))) { fflush(stdout); @@ -90,7 +93,7 @@ int main () fprintf(stdout,"Testing SHA-224 "); - SHA224((unsigned char *)"abc",3,md); + EVP_Digest ("abc",3,md,NULL,EVP_sha224(),NULL); if (memcmp(md,addenum_1,sizeof(addenum_1))) { fflush(stdout); fprintf(stderr,"\nTEST 1 of 3 failed.\n"); @@ -99,8 +102,8 @@ int main () else fprintf(stdout,"."); fflush(stdout); - SHA224((unsigned char *)"abcdbcde""cdefdefg""efghfghi""ghijhijk" - "ijkljklm""klmnlmno""mnopnopq",56,md); + EVP_Digest ("abcdbcde""cdefdefg""efghfghi""ghijhijk" + "ijkljklm""klmnlmno""mnopnopq",56,md,NULL,EVP_sha224(),NULL); if (memcmp(md,addenum_2,sizeof(addenum_2))) { fflush(stdout); fprintf(stderr,"\nTEST 2 of 3 failed.\n"); @@ -109,12 +112,14 @@ int main () else fprintf(stdout,"."); fflush(stdout); - SHA224_Init(&ctx); + EVP_MD_CTX_init (&evp); + EVP_DigestInit_ex (&evp,EVP_sha224(),NULL); for (i=0;i<1000000;i+=64) - SHA256_Update(&ctx, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" - "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", - (1000000-i)<64?1000000-i:64); - SHA256_Final(md,&ctx); + EVP_DigestUpdate (&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" + "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", + (1000000-i)<64?1000000-i:64); + EVP_DigestFinal_ex (&evp,md,NULL); + EVP_MD_CTX_cleanup (&evp); if (memcmp(md,addenum_3,sizeof(addenum_3))) { fflush(stdout); |