Support the EBCDIC character set and BS2000/OSD-POSIX (work in progress).
[openssl.git] / crypto / md2 / md2_one.c
index 17b288bad82357221383c0d238ef4a1e1e4aa867..7157299d9536eeb47bc23c2661bac9894d2c6958 100644 (file)
@@ -70,7 +70,23 @@ unsigned char *MD2(unsigned char *d, unsigned long n, unsigned char *md)
 
        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);