Check return values of <Digest>_Init functions in low level digest calls.

This commit is contained in:
Dr. Stephen Henson 2005-04-14 22:58:44 +00:00
parent 2b85e23d2e
commit fbe6ba81e9
7 changed files with 14 additions and 7 deletions

View File

@ -69,7 +69,8 @@ unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md)
static unsigned char m[MD2_DIGEST_LENGTH];
if (md == NULL) md=m;
MD2_Init(&c);
if (!MD2_Init(&c))
return NULL;
#ifndef CHARSET_EBCDIC
MD2_Update(&c,d,n);
#else

View File

@ -71,7 +71,8 @@ unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md)
static unsigned char m[MD4_DIGEST_LENGTH];
if (md == NULL) md=m;
MD4_Init(&c);
if (!MD4_Init(&c))
return NULL;
#ifndef CHARSET_EBCDIC
MD4_Update(&c,d,n);
#else

View File

@ -71,7 +71,8 @@ unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
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

View File

@ -66,7 +66,8 @@ unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md)
static unsigned char m[MDC2_DIGEST_LENGTH];
if (md == NULL) md=m;
MDC2_Init(&c);
if (!MDC2_Init(&c))
return NULL;
MDC2_Update(&c,d,n);
MDC2_Final(md,&c);
OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */

View File

@ -68,7 +68,8 @@ unsigned char *RIPEMD160(const unsigned char *d, size_t n,
static unsigned char m[RIPEMD160_DIGEST_LENGTH];
if (md == NULL) md=m;
RIPEMD160_Init(&c);
if (!RIPEMD160_Init(&c))
return NULL;
RIPEMD160_Update(&c,d,n);
RIPEMD160_Final(md,&c);
OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */

View File

@ -68,7 +68,8 @@ unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
static unsigned char m[SHA_DIGEST_LENGTH];
if (md == NULL) md=m;
SHA1_Init(&c);
if (!SHA1_Init(&c))
return NULL;
SHA1_Update(&c,d,n);
SHA1_Final(md,&c);
OPENSSL_cleanse(&c,sizeof(c));

View File

@ -68,7 +68,8 @@ unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md)
static unsigned char m[SHA_DIGEST_LENGTH];
if (md == NULL) md=m;
SHA_Init(&c);
if (!SHA_Init(&c))
return NULL;
SHA_Update(&c,d,n);
SHA_Final(md,&c);
OPENSSL_cleanse(&c,sizeof(c));