From 4c6a70861bdeca87489f9de24c1c0090b6844d01 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 13 Apr 2017 09:37:48 -0700 Subject: [PATCH 1/4] Fix build errors with --enable-scrypt. --- wolfcrypt/benchmark/benchmark.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 9e7b41ecf..12110f15d 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -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 { From 3df47d57abf3a148abfebe0e55a6706939c18c09 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 13 Apr 2017 12:54:56 -0700 Subject: [PATCH 2/4] Fix error with armv8-aes wc_AesInit function using h instead of heap variable. (moved from PR #852). --- wolfcrypt/src/port/arm/armv8-aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/port/arm/armv8-aes.c b/wolfcrypt/src/port/arm/armv8-aes.c index 518c8fcda..0dc43e4e4 100644 --- a/wolfcrypt/src/port/arm/armv8-aes.c +++ b/wolfcrypt/src/port/arm/armv8-aes.c @@ -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; From 620d21c8507410646b844f8c58a9bb8adaed7b66 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 13 Apr 2017 15:06:26 -0600 Subject: [PATCH 3/4] fix scrypt test with no password --- wolfcrypt/src/hmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index f1020aa28..d724ed176 100755 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -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)) { From ebde18af59ec9f2a4d447fa14d03181a73ed10ef Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 13 Apr 2017 15:32:31 -0600 Subject: [PATCH 4/4] silence static analysis tool warning about null parameter after sanity check --- wolfcrypt/src/hmac.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index d724ed176..c595465da 100755 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -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);