From b7dac4911b88ba6776c592a26e454a78f26f0014 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 21 Jul 2017 11:43:01 -0700 Subject: [PATCH 1/2] Fix for using Async and HMAC when its not Intel QuickAssist. --- wolfcrypt/src/hmac.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index 886a838c1..d5a1e1ce6 100755 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -442,6 +442,7 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length) #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC) if (hmac->asyncDev.marker == WOLFSSL_ASYNC_MARKER_HMAC) { + #if defined(HAVE_INTEL_QA) if (length > hmac_block_size) length = hmac_block_size; /* update key length */ @@ -449,6 +450,7 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length) return ret; /* no need to pad below */ + #endif } #endif From 26ac5e1ab7a710b8194c78e7d658cf0cd87dfab8 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 21 Jul 2017 12:00:28 -0700 Subject: [PATCH 2/2] Fix for `error: array subscript is below array bounds` warning with GCC 7. Added check to prevent negative value from being used against array. --- wolfcrypt/src/tfm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index 5dfd49911..ff1d34a55 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -314,7 +314,7 @@ void fp_mul(fp_int *A, fp_int *B, fp_int *C) clean: /* zero any excess digits on the destination that we didn't write to */ - for (y = C->used; y < oldused; y++) { + for (y = C->used; y >= 0 && y < oldused; y++) { C->dp[y] = 0; } } @@ -1479,7 +1479,7 @@ void fp_sqr(fp_int *A, fp_int *B) clean: /* zero any excess digits on the destination that we didn't write to */ - for (y = B->used; y < oldused; y++) { + for (y = B->used; y >= 0 && y < oldused; y++) { B->dp[y] = 0; } } @@ -2467,7 +2467,7 @@ void fp_copy(fp_int *a, fp_int *b) XMEMCPY(b->dp, a->dp, a->used * sizeof(fp_digit)); /* zero any excess digits on the destination that we didn't write to */ - for (x = b->used; x < oldused; x++) { + for (x = b->used; x >= 0 && x < oldused; x++) { b->dp[x] = 0; } }