Param check fix in hash files.

This commit is contained in:
jrblixt 2017-04-14 02:16:04 -06:00
parent ac6b840dc5
commit 00ea508751
4 changed files with 30 additions and 1 deletions

View File

@ -447,6 +447,9 @@ int wc_Md5Final(Md5* md5, byte* hash)
int wc_InitMd5(Md5* md5)
{
if (md5 == NULL) {
return BAD_FUNC_ARG;
}
return wc_InitMd5_ex(md5, NULL, INVALID_DEVID);
}

View File

@ -42,6 +42,9 @@
}
int wc_InitSha_ex(Sha* sha, void* heap, int devId)
{
if (sha == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return InitSha_fips(sha);
@ -543,6 +546,9 @@ int wc_ShaFinal(Sha* sha, byte* hash)
int wc_InitSha(Sha* sha)
{
if (sha == NULL) {
return BAD_FUNC_ARG;
}
return wc_InitSha_ex(sha, NULL, INVALID_DEVID);
}

View File

@ -45,6 +45,9 @@
}
int wc_InitSha256_ex(Sha256* sha, void* heap, int devId)
{
if (sha == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return InitSha256_fips(sha);
@ -562,9 +565,14 @@ static int InitSha256(Sha256* sha256)
static INLINE int Sha256Final(Sha256* sha256)
{
int ret;
byte* local = (byte*)sha256->buffer;
if (sha256 == NULL) {
return BAD_FUNC_ARG;
}
SAVE_XMM_YMM; /* for Intel AVX */
AddLength(sha256, sha256->buffLen); /* before adding pads */
@ -1918,6 +1926,9 @@ static int Transform_AVX2(Sha256* sha256)
int wc_InitSha256(Sha256* sha256)
{
if (sha256 == NULL) {
return BAD_FUNC_ARG;
}
return wc_InitSha256_ex(sha256, NULL, INVALID_DEVID);
}

View File

@ -44,6 +44,9 @@
}
int wc_InitSha512_ex(Sha512* sha, void* heap, int devId)
{
if (sha == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return InitSha512_fips(sha);
@ -537,7 +540,9 @@ static INLINE void AddLength(Sha512* sha512, word32 len)
static INLINE int Sha512Update(Sha512* sha512, const byte* data, word32 len)
{
int ret = 0;
if (sha512 == NULL || (data == NULL && len > 0)) {
return BAD_FUNC_ARG;
}
/* do block size increments */
byte* local = (byte*)sha512->buffer;
@ -598,6 +603,10 @@ static INLINE int Sha512Final(Sha512* sha512)
byte* local = (byte*)sha512->buffer;
int ret;
if (sha512 == NULL) {
return BAD_FUNC_ARG;
}
SAVE_XMM_YMM ; /* for Intel AVX */
AddLength(sha512, sha512->buffLen); /* before adding pads */