From 4642077146f572b62094659da90afc0ce3325039 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Tue, 28 Nov 2023 23:25:31 -0600 Subject: [PATCH] src/ssl.c: remove frivolous (void)heap to clear -Wdeclaration-after-statement. wolfcrypt/src/aes.c: add NEED_AES_TABLES gate around AesSetKey_C() implementations (fixes WOLFSSL_KCAPI_AES builds, probably among others). wolfcrypt/src/sp_int.c: add missing casts to clear -Wconversions. --- src/ssl.c | 2 +- wolfcrypt/src/aes.c | 4 ++++ wolfcrypt/src/sp_int.c | 10 +++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 275fa5f71..32d81e7aa 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -30149,7 +30149,7 @@ static int set_curves_list(WOLFSSL* ssl, WOLFSSL_CTX *ctx, const char* names) char name[MAX_CURVE_NAME_SZ]; byte groups_len = 0; #ifdef WOLFSSL_SMALL_STACK - void *heap = ssl? ssl->heap : ctx ? ctx->heap : NULL; (void)heap; + void *heap = ssl? ssl->heap : ctx ? ctx->heap : NULL; int *groups; #else int groups[WOLFSSL_MAX_GROUP_COUNT]; diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 2c6ac8960..c5fc0c3c4 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -3885,6 +3885,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt( * and we need both HW and SW. */ #ifdef NEED_SOFTWARE_AES_SETKEY +#ifdef NEED_AES_TABLES + #ifndef WC_AES_BITSLICED /* Set the AES key and expand. * @@ -4125,6 +4127,8 @@ static void AesSetKey_C(Aes* aes, const byte* key, word32 keySz, int dir) } #endif /* WC_AES_BITSLICED */ +#endif /* NEED_AES_TABLES */ + /* Software AES - SetKey */ static WARN_UNUSED_RESULT int wc_AesSetKeyLocal( Aes* aes, const byte* userKey, word32 keylen, const byte* iv, int dir, diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 1af72f84e..73da134ea 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -7687,7 +7687,7 @@ static void sp_clamp_ct(sp_int* a) unsigned int used = a->used; unsigned int mask = (unsigned int)-1; - for (i = a->used-1; i >= 0; i--) { + for (i = (int)a->used - 1; i >= 0; i--) { used -= ((unsigned int)(a->dp[i] == 0)) & mask; mask &= (unsigned int)0 - (a->dp[i] == 0); } @@ -17072,7 +17072,9 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct) } else { for (i = 0; i < m->used * 2; i++) { - a->dp[i] &= (sp_int_digit)(sp_int_sdigit)ctMaskIntGTE(a->used-1, i); + a->dp[i] &= + (sp_int_digit) + (sp_int_sdigit)ctMaskIntGTE((int)(a->used-1), (int)i); } } @@ -17195,7 +17197,9 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct) } else { for (i = 0; i < m->used * 2; i++) { - a->dp[i] &= (sp_int_digit)(sp_int_sdigit)ctMaskIntGTE(a->used-1, i); + a->dp[i] &= + (sp_int_digit) + (sp_int_sdigit)ctMaskIntGTE((int)(a->used-1), (int)i); } }