X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fmd5%2Fmd5_one.c;h=43fee89379634a4658887f2cc4e4abecebd22ac9;hb=2766515fcad8dfe9223a041b7ca42f00c7c55156;hp=ab6bb435f90e1e8054b62a4017974a918b7d9943;hpb=78414a6a897db42c9bcf06aa21c705811ab33921;p=oweals%2Fopenssl.git diff --git a/crypto/md5/md5_one.c b/crypto/md5/md5_one.c index ab6bb435f9..43fee89379 100644 --- a/crypto/md5/md5_one.c +++ b/crypto/md5/md5_one.c @@ -57,21 +57,41 @@ */ #include -#include "md5_locl.h" +#include +#include +#include -unsigned char *MD5(d, n, md) -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); }