'ranlib' doesn't always run on some systems. That's actually
[openssl.git] / crypto / md2 / md2_one.c
index 513bf62fdb36ed6ab9af90390af67bae8c795c55..b12c37ce4def4e1a538b7bca74ef7cac8ce7b8e3 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "md2.h"
+#include <openssl/md2.h>
 
 /* This is a separate file so that #defines in cryptlib.h can
  * map my MD functions to different names */
 
-unsigned char *MD2(d, n, md)
-unsigned char *d;
-unsigned long n;
-unsigned char *md;
+unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md)
        {
        MD2_CTX c;
        static unsigned char m[MD2_DIGEST_LENGTH];
 
        if (md == NULL) md=m;
        MD2_Init(&c);
+#ifndef CHARSET_EBCDIC
        MD2_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);
+                       MD2_Update(&c,temp,chunk);
+                       n -= chunk;
+                       d += chunk;
+               }
+       }
+#endif
        MD2_Final(md,&c);
        memset(&c,0,sizeof(c)); /* Security consideration */
        return(md);