Remove unnecessary casts and avoid some warnings with gcc 4.2.
[openssl.git] / crypto / md5 / md5test.c
index 74b84bc67f8358d17971047183ed108aea324b47..2b37190e32b1c45738b017c892c579b03e081f2a 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include "md5.h"
 
-char *test[]={
+#include "../e_os.h"
+
+#ifdef OPENSSL_NO_MD5
+int main(int argc, char *argv[])
+{
+    printf("No MD5 support\n");
+    return(0);
+}
+#else
+#include <openssl/evp.h>
+#include <openssl/md5.h>
+
+static char *test[]={
        "",
        "a",
        "abc",
@@ -72,7 +83,7 @@ char *test[]={
        NULL,
        };
 
-char *ret[]={
+static char *ret[]={
        "d41d8cd98f00b204e9800998ecf8427e",
        "0cc175b9c0f1b6a831c399e269772661",
        "900150983cd24fb0d6963f7d28e17f72",
@@ -82,26 +93,21 @@ char *ret[]={
        "57edf4a22be3c955ac49da2e2107b67a",
        };
 
-#ifndef NOPROTO
 static char *pt(unsigned char *md);
-#else
-static char *pt();
-#endif
-
-int main(argc,argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
        {
        int i,err=0;
-       unsigned char **P,**R;
+       char **P,**R;
        char *p;
+       unsigned char md[MD5_DIGEST_LENGTH];
 
-       P=(unsigned char **)test;
-       R=(unsigned char **)ret;
+       P=test;
+       R=ret;
        i=1;
        while (*P != NULL)
                {
-               p=pt(MD5(&(P[0][0]),(unsigned long)strlen((char *)*P),NULL));
+               EVP_Digest(&(P[0][0]),strlen((char *)*P),md,NULL,EVP_md5(), NULL);
+               p=pt(md);
                if (strcmp(p,(char *)*R) != 0)
                        {
                        printf("error calculating MD5 on '%s'\n",*P);
@@ -114,12 +120,15 @@ char *argv[];
                R++;
                P++;
                }
-       exit(err);
+
+#ifdef OPENSSL_SYS_NETWARE
+    if (err) printf("ERROR: %d\n", err);
+#endif
+       EXIT(err);
        return(0);
        }
 
-static char *pt(md)
-unsigned char *md;
+static char *pt(unsigned char *md)
        {
        int i;
        static char buf[80];
@@ -128,3 +137,4 @@ unsigned char *md;
                sprintf(&(buf[i*2]),"%02x",md[i]);
        return(buf);
        }
+#endif