diff --git a/src/tls13.c b/src/tls13.c index 824ad08b696..8b49cc33bcf 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -8577,7 +8577,10 @@ static WC_INLINE int DecodeTls13SigAlg(byte* input, byte* hashAlgo, break; #endif case NEW_SA_MAJOR: - *hashAlgo = GetNewSAHashAlgo(input[1]); + { + enum wc_MACAlgorithm mac = GetNewSAHashAlgo(input[1]); + *hashAlgo = (byte)mac; + } /* PSS encryption: 0x080[4-6] */ if (input[1] >= RSA_PSS_RSAE_SHA256_MINOR && diff --git a/src/wolfio.c b/src/wolfio.c index c6ffe7da11b..e438e8fe7f5 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -3286,7 +3286,11 @@ int LwIPNativeSend(WOLFSSL* ssl, char* buf, int sz, void* ctx) err_t ret; WOLFSSL_LWIP_NATIVE_STATE* nlwip = (WOLFSSL_LWIP_NATIVE_STATE*)ctx; - ret = tcp_write(nlwip->pcb, buf, sz, TCP_WRITE_FLAG_COPY); + if (sz < 0 || sz > (int)WOLFSSL_MAX_16BIT) { + return BAD_FUNC_ARG; + } + + ret = tcp_write(nlwip->pcb, buf, (u16_t)sz, TCP_WRITE_FLAG_COPY); if (ret != ERR_OK) { sz = WOLFSSL_FATAL_ERROR; } diff --git a/wolfcrypt/src/fe_low_mem.c b/wolfcrypt/src/fe_low_mem.c index f1c5eddd340..61b88769043 100644 --- a/wolfcrypt/src/fe_low_mem.c +++ b/wolfcrypt/src/fe_low_mem.c @@ -546,7 +546,7 @@ void fe_load(byte *x, word32 c) word32 i; for (i = 0; i < sizeof(c); i++) { - x[i] = c; + x[i] = (byte)c; c >>= 8; } @@ -636,7 +636,7 @@ void lm_sub(byte* r, const byte* a, const byte* b) c = 218; for (i = 0; i + 1 < F25519_SIZE; i++) { c += 65280 + ((word32)a[i]) - ((word32)b[i]); - r[i] = c; + r[i] = (byte)c; c >>= 8; } @@ -646,7 +646,7 @@ void lm_sub(byte* r, const byte* a, const byte* b) for (i = 0; i < F25519_SIZE; i++) { c += r[i]; - r[i] = c; + r[i] = (byte)c; c >>= 8; } } @@ -661,7 +661,7 @@ void lm_neg(byte* r, const byte* a) c = 218; for (i = 0; i + 1 < F25519_SIZE; i++) { c += 65280 - ((word32)a[i]); - r[i] = c; + r[i] = (byte)c; c >>= 8; } @@ -671,7 +671,7 @@ void lm_neg(byte* r, const byte* a) for (i = 0; i < F25519_SIZE; i++) { c += r[i]; - r[i] = c; + r[i] = (byte)c; c >>= 8; } } @@ -693,7 +693,7 @@ void fe_mul__distinct(byte *r, const byte *a, const byte *b) c += ((word32)a[j]) * ((word32)b[i + F25519_SIZE - j]) * 38; - r[i] = c; + r[i] = (byte)c; } r[31] &= 127; @@ -701,7 +701,7 @@ void fe_mul__distinct(byte *r, const byte *a, const byte *b) for (i = 0; i < F25519_SIZE; i++) { c += r[i]; - r[i] = c; + r[i] = (byte)c; c >>= 8; } } @@ -724,7 +724,7 @@ void fe_mul_c(byte *r, const byte *a, word32 b) for (i = 0; i < F25519_SIZE; i++) { c >>= 8; c += b * ((word32)a[i]); - r[i] = c; + r[i] = (byte)c; } r[31] &= 127; @@ -733,7 +733,7 @@ void fe_mul_c(byte *r, const byte *a, word32 b) for (i = 0; i < F25519_SIZE; i++) { c += r[i]; - r[i] = c; + r[i] = (byte)c; c >>= 8; } }