Merge branch 'master' of https://github.com/wolfSSL/wolfssl into unitTest_api_dev

This commit is contained in:
jrblixt 2017-04-14 02:17:57 -06:00
commit b5d856eada
3 changed files with 28 additions and 12 deletions

View File

@ -2142,8 +2142,8 @@ void bench_cmac(void)
void bench_scrypt(void)
{
byte derived[64];
double start, total, each, milliEach;
int ret, i;
double start;
int ret, i, count;
bench_stats_start(&count, &start);
do {

View File

@ -237,7 +237,7 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
int ret = 0;
void* heap = NULL;
if (hmac == NULL || key == NULL ||
if (hmac == NULL || (key == NULL && length != 0) ||
!(type == MD5 || type == SHA || type == SHA256 || type == SHA384
|| type == SHA512 || type == BLAKE2B_ID
|| type == SHA224)) {
@ -254,7 +254,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
return WC_KEY_SIZE_E;
}
XMEMCPY(hmac->keyRaw, key, length);
if (key != NULL) {
XMEMCPY(hmac->keyRaw, key, length);
}
hmac->keyLen = (word16)length;
return 0; /* nothing to do here */
@ -279,7 +281,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case MD5:
hmac_block_size = MD5_BLOCK_SIZE;
if (length <= MD5_BLOCK_SIZE) {
XMEMCPY(ip, key, length);
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Md5Update(&hmac->hash.md5, key, length);
@ -297,7 +301,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA:
hmac_block_size = SHA_BLOCK_SIZE;
if (length <= SHA_BLOCK_SIZE) {
XMEMCPY(ip, key, length);
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_ShaUpdate(&hmac->hash.sha, key, length);
@ -317,7 +323,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
{
hmac_block_size = SHA224_BLOCK_SIZE;
if (length <= SHA224_BLOCK_SIZE) {
XMEMCPY(ip, key, length);
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha224Update(&hmac->hash.sha224, key, length);
@ -337,7 +345,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA256:
hmac_block_size = SHA256_BLOCK_SIZE;
if (length <= SHA256_BLOCK_SIZE) {
XMEMCPY(ip, key, length);
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha256Update(&hmac->hash.sha256, key, length);
@ -357,7 +367,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA384:
hmac_block_size = SHA384_BLOCK_SIZE;
if (length <= SHA384_BLOCK_SIZE) {
XMEMCPY(ip, key, length);
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha384Update(&hmac->hash.sha384, key, length);
@ -374,7 +386,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA512:
hmac_block_size = SHA512_BLOCK_SIZE;
if (length <= SHA512_BLOCK_SIZE) {
XMEMCPY(ip, key, length);
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha512Update(&hmac->hash.sha512, key, length);
@ -393,7 +407,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case BLAKE2B_ID:
hmac_block_size = BLAKE2B_BLOCKBYTES;
if (length <= BLAKE2B_BLOCKBYTES) {
XMEMCPY(ip, key, length);
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Blake2bUpdate(&hmac->hash.blake2b, key, length);

View File

@ -306,7 +306,7 @@ int wc_AesInit(Aes* aes, void* heap, int devId)
if (aes == NULL)
return BAD_FUNC_ARG;
aes->heap = h;
aes->heap = heap;
(void)devId;
return 0;