Fix the tests to work with EBCDIC
[openssl.git] / test / mdc2test.c
index a0d77a30ecf20a36da04844e11a3b32189a95f63..06456a87a18ca7c064372f72713e1f5d3982a0c5 100644 (file)
@@ -1,4 +1,3 @@
-/* crypto/mdc2/mdc2test.c */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -95,17 +94,17 @@ int main(int argc, char *argv[])
     int ret = 0;
     unsigned char md[MDC2_DIGEST_LENGTH];
     int i;
-    EVP_MD_CTX c;
-    static char *text = "Now is the time for all ";
+    EVP_MD_CTX *c;
+    static char text[30] = "Now is the time for all ";
 
 # ifdef CHARSET_EBCDIC
     ebcdic2ascii(text, text, strlen(text));
 # endif
 
-    EVP_MD_CTX_init(&c);
-    EVP_DigestInit_ex(&c, EVP_mdc2(), NULL);
-    EVP_DigestUpdate(&c, (unsigned char *)text, strlen(text));
-    EVP_DigestFinal_ex(&c, &(md[0]), NULL);
+    c = EVP_MD_CTX_new();
+    EVP_DigestInit_ex(c, EVP_mdc2(), NULL);
+    EVP_DigestUpdate(c, (unsigned char *)text, strlen(text));
+    EVP_DigestFinal_ex(c, &(md[0]), NULL);
 
     if (memcmp(md, pad1, MDC2_DIGEST_LENGTH) != 0) {
         for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
@@ -118,11 +117,11 @@ int main(int argc, char *argv[])
     } else
         printf("pad1 - ok\n");
 
-    EVP_DigestInit_ex(&c, EVP_mdc2(), NULL);
+    EVP_DigestInit_ex(c, EVP_mdc2(), NULL);
     /* FIXME: use a ctl function? */
-    ((MDC2_CTX *)c.md_data)->pad_type = 2;
-    EVP_DigestUpdate(&c, (unsigned char *)text, strlen(text));
-    EVP_DigestFinal_ex(&c, &(md[0]), NULL);
+    ((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;
+    EVP_DigestUpdate(c, (unsigned char *)text, strlen(text));
+    EVP_DigestFinal_ex(c, &(md[0]), NULL);
 
     if (memcmp(md, pad2, MDC2_DIGEST_LENGTH) != 0) {
         for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
@@ -135,11 +134,7 @@ int main(int argc, char *argv[])
     } else
         printf("pad2 - ok\n");
 
-    EVP_MD_CTX_cleanup(&c);
-# ifdef OPENSSL_SYS_NETWARE
-    if (ret)
-        printf("ERROR: %d\n", ret);
-# endif
+    EVP_MD_CTX_free(c);
     EXIT(ret);
 }
 #endif