From cadd556b3aecf8cdf5dbfb467e4e152b217dc530 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Thu, 12 Jul 2018 13:46:55 -0600 Subject: [PATCH] cast result of bitwise not back to original type to prevent compiler warnings --- src/internal.c | 2 +- src/tls.c | 4 ++-- wolfcrypt/src/ecc.c | 2 +- wolfcrypt/src/misc.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/internal.c b/src/internal.c index 32d85303e..0cab33147 100644 --- a/src/internal.c +++ b/src/internal.c @@ -12145,7 +12145,7 @@ int TimingPadVerify(WOLFSSL* ssl, const byte* input, int padLen, int macSz, good |= MaskMac(input, pLen, ssl->specs.hash_size, verify); /* Non-zero on failure. */ - good = ~(word32)good; + good = (byte)~(word32)good; good &= good >> 4; good &= good >> 2; good &= good >> 1; diff --git a/src/tls.c b/src/tls.c index bb5e7a5af..cec1b15d8 100644 --- a/src/tls.c +++ b/src/tls.c @@ -1129,8 +1129,8 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in, b = in[k - WOLFSSL_TLS_HMAC_INNER_SZ]; b = ctMaskSel(atEoc, b, 0x80); - b &= ~(word32)pastEoc; - b &= ~(word32)isOutBlock | isEocBlock; + b &= (unsigned char)~(word32)pastEoc; + b &= ((unsigned char)~(word32)isOutBlock) | isEocBlock; if (j >= blockSz - 8) { b = ctMaskSel(isOutBlock, b, lenBytes[j - (blockSz - 8)]); diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 438694057..a61f92cc1 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -1353,7 +1353,7 @@ static int wc_ecc_curve_load(const ecc_set_type* dp, ecc_curve_spec** pCurve, curve->dp = dp; /* set dp info */ /* determine items to load */ - load_items = (~(word32)curve->load_mask & load_mask); + load_items = (((byte)~(word32)curve->load_mask) & load_mask); curve->load_mask |= load_items; /* load items */ diff --git a/wolfcrypt/src/misc.c b/wolfcrypt/src/misc.c index 7c0f01c2f..ec4e51b12 100644 --- a/wolfcrypt/src/misc.c +++ b/wolfcrypt/src/misc.c @@ -344,7 +344,7 @@ STATIC WC_INLINE byte ctMaskEq(int a, int b) /* Constant time - select b when mask is set and a otherwise. */ STATIC WC_INLINE byte ctMaskSel(byte m, byte a, byte b) { - return (a & ~(word32)m) | (b & m); + return (a & ((byte)~(word32)m)) | (b & m); } /* Constant time - bit set when a <= b. */