From a4aef0e55d41a88e338a059909c1b4b191c04149 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Mon, 17 Apr 2023 22:51:55 -0500 Subject: [PATCH] refinements from peer review for #6303. --- wolfcrypt/src/aes.c | 2 +- wolfcrypt/src/dh.c | 2 +- wolfcrypt/src/wc_encrypt.c | 2 +- wolfcrypt/src/wc_port.c | 10 ++-------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index c40e49bec..c44f77bb1 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -10405,7 +10405,7 @@ static WC_INLINE void InitKeyWrapCounter(byte* inOutCtr, word32 value) bytes = sizeof(word32); for (i = 0; i < sizeof(word32); i++) { - inOutCtr[i+sizeof(word32)] = (value >> ((bytes - 1) * 8)) & 0xFF; + inOutCtr[i+sizeof(word32)] = (byte)(value >> ((bytes - 1) * 8)); bytes--; } } diff --git a/wolfcrypt/src/dh.c b/wolfcrypt/src/dh.c index 4dda56728..4cedcae17 100644 --- a/wolfcrypt/src/dh.c +++ b/wolfcrypt/src/dh.c @@ -2944,7 +2944,7 @@ int wc_DhGenerateParams(WC_RNG *rng, int modSz, DhKey *dh) /* force magnitude */ buf[0] |= 0xC0; /* force even */ - buf[bufSz - 1] &= (byte)~1U; + buf[bufSz - 1] &= 0xfe; if (mp_init_multi(tmp, tmp2, &dh->p, &dh->q, &dh->g, 0) != MP_OKAY) { diff --git a/wolfcrypt/src/wc_encrypt.c b/wolfcrypt/src/wc_encrypt.c index e5be5d60b..506ac11e0 100644 --- a/wolfcrypt/src/wc_encrypt.c +++ b/wolfcrypt/src/wc_encrypt.c @@ -411,7 +411,7 @@ int wc_CryptKey(const char* password, int passwordSz, byte* salt, WOLFSSL_ENTER("wc_CryptKey"); if (length < 0) - ret = BAD_LENGTH_E; + return BAD_LENGTH_E; switch (id) { #ifndef NO_DES3 diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index f5bda06ab..b6c59123f 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -1085,10 +1085,7 @@ size_t wc_strlcat(char *dst, const char *src, size_t dstSize) int wc_strcasecmp(const char *s1, const char *s2) { char c1, c2; - for (; - ; - ++s1, ++s2) - { + for (;;++s1, ++s2) { c1 = *s1; if ((c1 >= 'a') && (c1 <= 'z')) c1 -= ('a' - 'A'); @@ -1106,10 +1103,7 @@ int wc_strcasecmp(const char *s1, const char *s2) int wc_strncasecmp(const char *s1, const char *s2, size_t n) { char c1, c2; - for (c1 = 0, c2 = 0; - n > 0; - --n, ++s1, ++s2) - { + for (c1 = 0, c2 = 0; n > 0; --n, ++s1, ++s2) { c1 = *s1; if ((c1 >= 'a') && (c1 <= 'z')) c1 -= ('a' - 'A');