X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fmd5%2Fmd5_one.c;h=43fee89379634a4658887f2cc4e4abecebd22ac9;hb=80106dc5fb7c906c6af136cc66300f6e8af06583;hp=c98721f4d8d4222edfaacd1443e5148a2f3e9e2e;hpb=bd3576d2ddedb0492f5bd3c1e47c15778e4fbe3c;p=oweals%2Fopenssl.git diff --git a/crypto/md5/md5_one.c b/crypto/md5/md5_one.c index c98721f4d8..43fee89379 100644 --- a/crypto/md5/md5_one.c +++ b/crypto/md5/md5_one.c @@ -59,17 +59,39 @@ #include #include #include +#include -unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md) +#ifdef CHARSET_EBCDIC +#include +#endif + +unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) { MD5_CTX c; static unsigned char m[MD5_DIGEST_LENGTH]; if (md == NULL) md=m; - MD5_Init(&c); + if (!MD5_Init(&c)) + return NULL; +#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); }