MIPS assembly pack: add support for SmartMIPS ASE.
[openssl.git] / crypto / sha / sha256t.c
index f57cfc5..e1d3428 100644 (file)
@@ -8,6 +8,15 @@
 #include <stdlib.h>
 
 #include <openssl/sha.h>
+#include <openssl/evp.h>
+
+#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA256)
+int main(int argc, char *argv[])
+{
+    printf("No SHA256 support\n");
+    return(0);
+}
+#else
 
 unsigned char app_b1[SHA256_DIGEST_LENGTH] = {
        0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea,
@@ -45,14 +54,14 @@ unsigned char addenum_3[SHA224_DIGEST_LENGTH] = {
        0xf0,0x3f,0x42,0x58,0x19,0x48,0xb2,0xee,
        0x4e,0xe7,0xad,0x67 };
 
-int main ()
+int main (int argc,char **argv)
 { unsigned char md[SHA256_DIGEST_LENGTH];
   int          i;
-  SHA256_CTX   ctx;
+  EVP_MD_CTX   evp;
 
     fprintf(stdout,"Testing SHA-256 ");
 
-    SHA256("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 +70,8 @@ int main ()
     else
        fprintf(stdout,"."); fflush(stdout);
 
-    SHA256("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 +80,21 @@ int main ()
     else
        fprintf(stdout,"."); fflush(stdout);
 
-    SHA256_Init(&ctx);
-    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_MD_CTX_init (&evp);
+    EVP_DigestInit_ex (&evp,EVP_sha256(),NULL);
+    for (i=0;i<1000000;i+=288)
+       EVP_DigestUpdate (&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
+                               "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
+                               (1000000-i)<288?1000000-i:288);
+    EVP_DigestFinal_ex (&evp,md,NULL);
+    EVP_MD_CTX_cleanup (&evp);
 
     if (memcmp(md,app_b3,sizeof(app_b3)))
     {  fflush(stdout);
@@ -90,7 +108,7 @@ int main ()
 
     fprintf(stdout,"Testing SHA-224 ");
 
-    SHA224("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 +117,8 @@ int main ()
     else
        fprintf(stdout,"."); fflush(stdout);
 
-    SHA224("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 +127,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);
@@ -128,3 +148,4 @@ int main ()
 
   return 0;
 }
+#endif