I have no idea how I cut away that piece of text...
[openssl.git] / crypto / md5 / md5_one.c
index ab6bb435f90e1e8054b62a4017974a918b7d9943..c5dd2d81db49373db908cb14814b2eeb2363ce9d 100644 (file)
  */
 
 #include <stdio.h>
-#include "md5_locl.h"
+#include <string.h>
+#include <openssl/md5.h>
+#include <openssl/crypto.h>
 
-unsigned char *MD5(d, n, md)
-unsigned char *d;
-unsigned long n;
-unsigned char *md;
+#ifdef CHARSET_EBCDIC
+#include <openssl/ebcdic.h>
+#endif
+
+unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md)
        {
        MD5_CTX c;
        static unsigned char m[MD5_DIGEST_LENGTH];
 
        if (md == NULL) md=m;
        MD5_Init(&c);
+#ifndef CHARSET_EBCDIC
        MD5_Update(&c,d,n);
+#else
+       {
+               char temp[1024];
+               unsigned long chunk;
+
+               while (n > 0)
+               {
+                       chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
+                       ebcdic2ascii(temp, d, chunk);
+                       MD5_Update(&c,temp,chunk);
+                       n -= chunk;
+                       d += chunk;
+               }
+       }
+#endif
        MD5_Final(md,&c);
-       memset(&c,0,sizeof(c)); /* security consideration */
+       OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
        return(md);
        }