From 09d3f1e1e68000e673cb17362bc14ef5f09b1ef0 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Tue, 1 Sep 2020 15:16:45 -0400 Subject: [PATCH] NTRU Prime: More changes for MS compiler --- crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541.c | 2 +- crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541round.c | 2 +- crypto_kem/ntrulpr653/avx2/kem.c | 2 +- crypto_kem/ntrulpr653/clean/crypto_decode_653x1541.c | 2 +- crypto_kem/ntrulpr653/clean/crypto_encode_653x1541.c | 2 +- crypto_kem/ntrulpr653/clean/kem.c | 2 +- crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531.c | 2 +- crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531round.c | 2 +- crypto_kem/ntrulpr761/avx2/kem.c | 2 +- crypto_kem/ntrulpr761/clean/crypto_decode_761x1531.c | 2 +- crypto_kem/ntrulpr761/clean/crypto_encode_761x1531.c | 2 +- crypto_kem/ntrulpr761/clean/kem.c | 2 +- crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723.c | 2 +- crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723round.c | 2 +- crypto_kem/ntrulpr857/avx2/kem.c | 2 +- crypto_kem/ntrulpr857/clean/crypto_decode_857x1723.c | 2 +- crypto_kem/ntrulpr857/clean/crypto_encode_857x1723.c | 2 +- crypto_kem/ntrulpr857/clean/kem.c | 2 +- crypto_kem/sntrup653/avx2/crypto_encode_653x1541.c | 2 +- crypto_kem/sntrup653/avx2/crypto_encode_653x1541round.c | 2 +- crypto_kem/sntrup653/avx2/crypto_encode_653x4621.c | 4 ++-- crypto_kem/sntrup653/clean/crypto_decode_653x1541.c | 2 +- crypto_kem/sntrup653/clean/crypto_decode_653x4621.c | 2 +- crypto_kem/sntrup653/clean/crypto_encode_653x1541.c | 2 +- crypto_kem/sntrup653/clean/crypto_encode_653x4621.c | 8 ++++---- crypto_kem/sntrup761/avx2/crypto_encode_761x1531.c | 2 +- crypto_kem/sntrup761/avx2/crypto_encode_761x1531round.c | 2 +- crypto_kem/sntrup761/avx2/crypto_encode_761x4591.c | 4 ++-- crypto_kem/sntrup761/clean/crypto_decode_761x1531.c | 2 +- crypto_kem/sntrup761/clean/crypto_decode_761x4591.c | 2 +- crypto_kem/sntrup761/clean/crypto_encode_761x1531.c | 2 +- crypto_kem/sntrup761/clean/crypto_encode_761x4591.c | 8 ++++---- crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c | 2 +- crypto_kem/sntrup857/avx2/crypto_encode_857x1723.c | 2 +- crypto_kem/sntrup857/avx2/crypto_encode_857x1723round.c | 2 +- crypto_kem/sntrup857/avx2/crypto_encode_857x5167.c | 4 ++-- crypto_kem/sntrup857/clean/crypto_decode_857x1723.c | 2 +- crypto_kem/sntrup857/clean/crypto_decode_857x5167.c | 2 +- crypto_kem/sntrup857/clean/crypto_encode_857x1723.c | 2 +- crypto_kem/sntrup857/clean/crypto_encode_857x5167.c | 8 ++++---- 40 files changed, 52 insertions(+), 52 deletions(-) diff --git a/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541.c b/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541.c index 081783f3..7e69db37 100644 --- a/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541.c +++ b/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541.c @@ -282,5 +282,5 @@ void PQCLEAN_NTRULPR653_AVX2_crypto_encode_653x1541(unsigned char *out, const vo r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541round.c b/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541round.c index d994ed24..575630e2 100644 --- a/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541round.c +++ b/crypto_kem/ntrulpr653/avx2/crypto_encode_653x1541round.c @@ -284,5 +284,5 @@ void PQCLEAN_NTRULPR653_AVX2_crypto_encode_653x1541round(unsigned char *out, con r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr653/avx2/kem.c b/crypto_kem/ntrulpr653/avx2/kem.c index efa4a044..98b7b970 100644 --- a/crypto_kem/ntrulpr653/avx2/kem.c +++ b/crypto_kem/ntrulpr653/avx2/kem.c @@ -48,7 +48,7 @@ static Fq Fq_bigfreeze(uint32 x) { x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= q; - x += (-(x >> 31)) & (uint32)q; + x += (~(x >> 31) + 1) & (uint32)q; return (Fq) x; } diff --git a/crypto_kem/ntrulpr653/clean/crypto_decode_653x1541.c b/crypto_kem/ntrulpr653/clean/crypto_decode_653x1541.c index edd6d15f..cbe3372f 100644 --- a/crypto_kem/ntrulpr653/clean/crypto_decode_653x1541.c +++ b/crypto_kem/ntrulpr653/clean/crypto_decode_653x1541.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/ntrulpr653/clean/crypto_encode_653x1541.c b/crypto_kem/ntrulpr653/clean/crypto_encode_653x1541.c index 77a5cde1..47f8f5ba 100644 --- a/crypto_kem/ntrulpr653/clean/crypto_encode_653x1541.c +++ b/crypto_kem/ntrulpr653/clean/crypto_encode_653x1541.c @@ -123,5 +123,5 @@ void PQCLEAN_NTRULPR653_CLEAN_crypto_encode_653x1541(unsigned char *out, const v r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr653/clean/kem.c b/crypto_kem/ntrulpr653/clean/kem.c index a4970a69..3b83e0e3 100644 --- a/crypto_kem/ntrulpr653/clean/kem.c +++ b/crypto_kem/ntrulpr653/clean/kem.c @@ -48,7 +48,7 @@ static Fq Fq_bigfreeze(uint32 x) { x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= q; - x += (-(x >> 31)) & (uint32)q; + x += (~(x >> 31) + 1) & (uint32)q; return (Fq) x; } diff --git a/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531.c b/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531.c index b9cb299e..ebf65b92 100644 --- a/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531.c +++ b/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531.c @@ -297,5 +297,5 @@ void PQCLEAN_NTRULPR761_AVX2_crypto_encode_761x1531(unsigned char *out, const vo r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531round.c b/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531round.c index bd73145b..799b2ae6 100644 --- a/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531round.c +++ b/crypto_kem/ntrulpr761/avx2/crypto_encode_761x1531round.c @@ -299,5 +299,5 @@ void PQCLEAN_NTRULPR761_AVX2_crypto_encode_761x1531round(unsigned char *out, con r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr761/avx2/kem.c b/crypto_kem/ntrulpr761/avx2/kem.c index cedf347e..9836b530 100644 --- a/crypto_kem/ntrulpr761/avx2/kem.c +++ b/crypto_kem/ntrulpr761/avx2/kem.c @@ -48,7 +48,7 @@ static Fq Fq_bigfreeze(uint32 x) { x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= q; - x += (-(x >> 31)) & (uint32)q; + x += (~(x >> 31) + 1) & (uint32)q; return (Fq) x; } diff --git a/crypto_kem/ntrulpr761/clean/crypto_decode_761x1531.c b/crypto_kem/ntrulpr761/clean/crypto_decode_761x1531.c index 904358f0..7617f528 100644 --- a/crypto_kem/ntrulpr761/clean/crypto_decode_761x1531.c +++ b/crypto_kem/ntrulpr761/clean/crypto_decode_761x1531.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/ntrulpr761/clean/crypto_encode_761x1531.c b/crypto_kem/ntrulpr761/clean/crypto_encode_761x1531.c index e8750688..e68e1840 100644 --- a/crypto_kem/ntrulpr761/clean/crypto_encode_761x1531.c +++ b/crypto_kem/ntrulpr761/clean/crypto_encode_761x1531.c @@ -115,5 +115,5 @@ void PQCLEAN_NTRULPR761_CLEAN_crypto_encode_761x1531(unsigned char *out, const v r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr761/clean/kem.c b/crypto_kem/ntrulpr761/clean/kem.c index b3c55589..ac6ed628 100644 --- a/crypto_kem/ntrulpr761/clean/kem.c +++ b/crypto_kem/ntrulpr761/clean/kem.c @@ -48,7 +48,7 @@ static Fq Fq_bigfreeze(uint32 x) { x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= q; - x += (-(x >> 31)) & (uint32)q; + x += (~(x >> 31) + 1) & (uint32)q; return (Fq) x; } diff --git a/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723.c b/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723.c index 0ea0103d..4d986557 100644 --- a/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723.c +++ b/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723.c @@ -279,5 +279,5 @@ void PQCLEAN_NTRULPR857_AVX2_crypto_encode_857x1723(unsigned char *out, const vo R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723round.c b/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723round.c index 946000c0..d0e5b304 100644 --- a/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723round.c +++ b/crypto_kem/ntrulpr857/avx2/crypto_encode_857x1723round.c @@ -281,5 +281,5 @@ void PQCLEAN_NTRULPR857_AVX2_crypto_encode_857x1723round(unsigned char *out, con R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr857/avx2/kem.c b/crypto_kem/ntrulpr857/avx2/kem.c index 28b44266..d1e3990e 100644 --- a/crypto_kem/ntrulpr857/avx2/kem.c +++ b/crypto_kem/ntrulpr857/avx2/kem.c @@ -48,7 +48,7 @@ static Fq Fq_bigfreeze(uint32 x) { x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= q; - x += (-(x >> 31)) & (uint32)q; + x += (~(x >> 31) + 1) & (uint32)q; return (Fq) x; } diff --git a/crypto_kem/ntrulpr857/clean/crypto_decode_857x1723.c b/crypto_kem/ntrulpr857/clean/crypto_decode_857x1723.c index 0720915e..df7d76db 100644 --- a/crypto_kem/ntrulpr857/clean/crypto_decode_857x1723.c +++ b/crypto_kem/ntrulpr857/clean/crypto_decode_857x1723.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/ntrulpr857/clean/crypto_encode_857x1723.c b/crypto_kem/ntrulpr857/clean/crypto_encode_857x1723.c index 0efa1a68..5fa2db62 100644 --- a/crypto_kem/ntrulpr857/clean/crypto_encode_857x1723.c +++ b/crypto_kem/ntrulpr857/clean/crypto_encode_857x1723.c @@ -126,5 +126,5 @@ void PQCLEAN_NTRULPR857_CLEAN_crypto_encode_857x1723(unsigned char *out, const v R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/ntrulpr857/clean/kem.c b/crypto_kem/ntrulpr857/clean/kem.c index c714d458..4fb3e074 100644 --- a/crypto_kem/ntrulpr857/clean/kem.c +++ b/crypto_kem/ntrulpr857/clean/kem.c @@ -48,7 +48,7 @@ static Fq Fq_bigfreeze(uint32 x) { x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= (uint32) (q * ((x * (uint64)q31) >> 31)); x -= q; - x += (-(x >> 31)) & (uint32)q; + x += (~(x >> 31) + 1) & (uint32)q; return (Fq) x; } diff --git a/crypto_kem/sntrup653/avx2/crypto_encode_653x1541.c b/crypto_kem/sntrup653/avx2/crypto_encode_653x1541.c index 36cbb7ee..c4c1c9c8 100644 --- a/crypto_kem/sntrup653/avx2/crypto_encode_653x1541.c +++ b/crypto_kem/sntrup653/avx2/crypto_encode_653x1541.c @@ -282,5 +282,5 @@ void PQCLEAN_SNTRUP653_AVX2_crypto_encode_653x1541(unsigned char *out, const voi r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup653/avx2/crypto_encode_653x1541round.c b/crypto_kem/sntrup653/avx2/crypto_encode_653x1541round.c index b2e34128..cccf060e 100644 --- a/crypto_kem/sntrup653/avx2/crypto_encode_653x1541round.c +++ b/crypto_kem/sntrup653/avx2/crypto_encode_653x1541round.c @@ -284,5 +284,5 @@ void PQCLEAN_SNTRUP653_AVX2_crypto_encode_653x1541round(unsigned char *out, cons r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup653/avx2/crypto_encode_653x4621.c b/crypto_kem/sntrup653/avx2/crypto_encode_653x4621.c index 530a9ce3..de000f6e 100644 --- a/crypto_kem/sntrup653/avx2/crypto_encode_653x4621.c +++ b/crypto_kem/sntrup653/avx2/crypto_encode_653x4621.c @@ -58,7 +58,7 @@ void PQCLEAN_SNTRUP653_AVX2_crypto_encode_653x4621(unsigned char *out, const voi writing += 16; out += 32; } - R[326] = ((R0[652] + 2310) & 16383); + R[326] = (uint16) (((R0[652] + 2310) & 16383)); reading = (uint16 *) R; writing = R; @@ -284,5 +284,5 @@ void PQCLEAN_SNTRUP653_AVX2_crypto_encode_653x4621(unsigned char *out, const voi R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup653/clean/crypto_decode_653x1541.c b/crypto_kem/sntrup653/clean/crypto_decode_653x1541.c index acaf947a..3c5f24ac 100644 --- a/crypto_kem/sntrup653/clean/crypto_decode_653x1541.c +++ b/crypto_kem/sntrup653/clean/crypto_decode_653x1541.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/sntrup653/clean/crypto_decode_653x4621.c b/crypto_kem/sntrup653/clean/crypto_decode_653x4621.c index 59a0b93e..4a942293 100644 --- a/crypto_kem/sntrup653/clean/crypto_decode_653x4621.c +++ b/crypto_kem/sntrup653/clean/crypto_decode_653x4621.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/sntrup653/clean/crypto_encode_653x1541.c b/crypto_kem/sntrup653/clean/crypto_encode_653x1541.c index 1c04c23a..f5b169a0 100644 --- a/crypto_kem/sntrup653/clean/crypto_encode_653x1541.c +++ b/crypto_kem/sntrup653/clean/crypto_encode_653x1541.c @@ -123,5 +123,5 @@ void PQCLEAN_SNTRUP653_CLEAN_crypto_encode_653x1541(unsigned char *out, const vo r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup653/clean/crypto_encode_653x4621.c b/crypto_kem/sntrup653/clean/crypto_encode_653x4621.c index 09d6378f..325c5c36 100644 --- a/crypto_kem/sntrup653/clean/crypto_encode_653x4621.c +++ b/crypto_kem/sntrup653/clean/crypto_encode_653x4621.c @@ -15,8 +15,8 @@ void PQCLEAN_SNTRUP653_CLEAN_crypto_encode_653x4621(unsigned char *out, const vo uint32 r2; for (i = 0; i < 326; ++i) { - r0 = (R0[2 * i] + 2310) & 16383; - r1 = (R0[2 * i + 1] + 2310) & 16383; + r0 = (uint16) ((R0[2 * i] + 2310) & 16383); + r1 = (uint16) ((R0[2 * i + 1] + 2310) & 16383); r2 = r0 + r1 * (uint32)4621; *out++ = (unsigned char) r2; r2 >>= 8; @@ -24,7 +24,7 @@ void PQCLEAN_SNTRUP653_CLEAN_crypto_encode_653x4621(unsigned char *out, const vo r2 >>= 8; R[i] = (uint16) r2; } - R[326] = (R0[652] + 2310) & 16383; + R[326] = (uint16) ((R0[652] + 2310) & 16383); for (i = 0; i < 163; ++i) { r0 = R[2 * i]; @@ -123,5 +123,5 @@ void PQCLEAN_SNTRUP653_CLEAN_crypto_encode_653x4621(unsigned char *out, const vo R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup761/avx2/crypto_encode_761x1531.c b/crypto_kem/sntrup761/avx2/crypto_encode_761x1531.c index eeff059c..c293a1b1 100644 --- a/crypto_kem/sntrup761/avx2/crypto_encode_761x1531.c +++ b/crypto_kem/sntrup761/avx2/crypto_encode_761x1531.c @@ -297,5 +297,5 @@ void PQCLEAN_SNTRUP761_AVX2_crypto_encode_761x1531(unsigned char *out, const voi r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup761/avx2/crypto_encode_761x1531round.c b/crypto_kem/sntrup761/avx2/crypto_encode_761x1531round.c index 0687a689..7aa27f42 100644 --- a/crypto_kem/sntrup761/avx2/crypto_encode_761x1531round.c +++ b/crypto_kem/sntrup761/avx2/crypto_encode_761x1531round.c @@ -299,5 +299,5 @@ void PQCLEAN_SNTRUP761_AVX2_crypto_encode_761x1531round(unsigned char *out, cons r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup761/avx2/crypto_encode_761x4591.c b/crypto_kem/sntrup761/avx2/crypto_encode_761x4591.c index 20bafd0e..128cd4bb 100644 --- a/crypto_kem/sntrup761/avx2/crypto_encode_761x4591.c +++ b/crypto_kem/sntrup761/avx2/crypto_encode_761x4591.c @@ -58,7 +58,7 @@ void PQCLEAN_SNTRUP761_AVX2_crypto_encode_761x4591(unsigned char *out, const voi writing += 16; out += 32; } - R[380] = ((R0[760] + 2295) & 16383); + R[380] = (uint16) (((R0[760] + 2295) & 16383)); reading = (uint16 *) R; writing = R; @@ -304,5 +304,5 @@ void PQCLEAN_SNTRUP761_AVX2_crypto_encode_761x4591(unsigned char *out, const voi r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup761/clean/crypto_decode_761x1531.c b/crypto_kem/sntrup761/clean/crypto_decode_761x1531.c index 7d5f926b..bc72c01f 100644 --- a/crypto_kem/sntrup761/clean/crypto_decode_761x1531.c +++ b/crypto_kem/sntrup761/clean/crypto_decode_761x1531.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/sntrup761/clean/crypto_decode_761x4591.c b/crypto_kem/sntrup761/clean/crypto_decode_761x4591.c index 0054517b..8402fcd2 100644 --- a/crypto_kem/sntrup761/clean/crypto_decode_761x4591.c +++ b/crypto_kem/sntrup761/clean/crypto_decode_761x4591.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/sntrup761/clean/crypto_encode_761x1531.c b/crypto_kem/sntrup761/clean/crypto_encode_761x1531.c index 3ef8b3f1..412fa7a4 100644 --- a/crypto_kem/sntrup761/clean/crypto_encode_761x1531.c +++ b/crypto_kem/sntrup761/clean/crypto_encode_761x1531.c @@ -115,5 +115,5 @@ void PQCLEAN_SNTRUP761_CLEAN_crypto_encode_761x1531(unsigned char *out, const vo r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup761/clean/crypto_encode_761x4591.c b/crypto_kem/sntrup761/clean/crypto_encode_761x4591.c index 1f82a69b..c7364539 100644 --- a/crypto_kem/sntrup761/clean/crypto_encode_761x4591.c +++ b/crypto_kem/sntrup761/clean/crypto_encode_761x4591.c @@ -15,8 +15,8 @@ void PQCLEAN_SNTRUP761_CLEAN_crypto_encode_761x4591(unsigned char *out, const vo uint32 r2; for (i = 0; i < 380; ++i) { - r0 = (R0[2 * i] + 2295) & 16383; - r1 = (R0[2 * i + 1] + 2295) & 16383; + r0 = (uint16) ((R0[2 * i] + 2295) & 16383); + r1 = (uint16) ((R0[2 * i + 1] + 2295) & 16383); r2 = r0 + r1 * (uint32)4591; *out++ = (unsigned char) r2; r2 >>= 8; @@ -24,7 +24,7 @@ void PQCLEAN_SNTRUP761_CLEAN_crypto_encode_761x4591(unsigned char *out, const vo r2 >>= 8; R[i] = (uint16) r2; } - R[380] = (R0[760] + 2295) & 16383; + R[380] = (uint16) ((R0[760] + 2295) & 16383); for (i = 0; i < 190; ++i) { r0 = R[2 * i]; @@ -143,5 +143,5 @@ void PQCLEAN_SNTRUP761_CLEAN_crypto_encode_761x4591(unsigned char *out, const vo r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c b/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c index 59b6969d..8280c00e 100644 --- a/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c +++ b/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c @@ -112,7 +112,7 @@ void PQCLEAN_SNTRUP857_AVX2_crypto_decode_857x5167(void *v, const unsigned char a2 = a0 = R9[i]; a0 = mulhi(a0, -28) - mulhi(mullo(a0, -886), 74); /* -44...37 */ a0 += (a0 >> 15) & 74; /* 0...73 */ - a1 = (int16) (a2 - a0) >> 1; + a1 = (int16) ((a2 - a0) >> 1); a1 = mullo(a1, 7085); /* invalid inputs might need reduction mod 74 */ diff --git a/crypto_kem/sntrup857/avx2/crypto_encode_857x1723.c b/crypto_kem/sntrup857/avx2/crypto_encode_857x1723.c index 605677b3..cb14f97e 100644 --- a/crypto_kem/sntrup857/avx2/crypto_encode_857x1723.c +++ b/crypto_kem/sntrup857/avx2/crypto_encode_857x1723.c @@ -279,5 +279,5 @@ void PQCLEAN_SNTRUP857_AVX2_crypto_encode_857x1723(unsigned char *out, const voi R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup857/avx2/crypto_encode_857x1723round.c b/crypto_kem/sntrup857/avx2/crypto_encode_857x1723round.c index 87439d76..39fad8f2 100644 --- a/crypto_kem/sntrup857/avx2/crypto_encode_857x1723round.c +++ b/crypto_kem/sntrup857/avx2/crypto_encode_857x1723round.c @@ -281,5 +281,5 @@ void PQCLEAN_SNTRUP857_AVX2_crypto_encode_857x1723round(unsigned char *out, cons R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup857/avx2/crypto_encode_857x5167.c b/crypto_kem/sntrup857/avx2/crypto_encode_857x5167.c index 896f12cb..36713cbb 100644 --- a/crypto_kem/sntrup857/avx2/crypto_encode_857x5167.c +++ b/crypto_kem/sntrup857/avx2/crypto_encode_857x5167.c @@ -58,7 +58,7 @@ void PQCLEAN_SNTRUP857_AVX2_crypto_encode_857x5167(unsigned char *out, const voi writing += 16; out += 32; } - R[428] = ((R0[856] + 2583) & 16383); + R[428] = (uint16) (((R0[856] + 2583) & 16383)); reading = (uint16 *) R; writing = R; @@ -327,5 +327,5 @@ void PQCLEAN_SNTRUP857_AVX2_crypto_encode_857x5167(unsigned char *out, const voi r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup857/clean/crypto_decode_857x1723.c b/crypto_kem/sntrup857/clean/crypto_decode_857x1723.c index 3664a899..ad76a8d5 100644 --- a/crypto_kem/sntrup857/clean/crypto_decode_857x1723.c +++ b/crypto_kem/sntrup857/clean/crypto_decode_857x1723.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/sntrup857/clean/crypto_decode_857x5167.c b/crypto_kem/sntrup857/clean/crypto_decode_857x5167.c index 67a01738..0bb0c283 100644 --- a/crypto_kem/sntrup857/clean/crypto_decode_857x5167.c +++ b/crypto_kem/sntrup857/clean/crypto_decode_857x5167.c @@ -54,7 +54,7 @@ static void uint32_divmod_uint14(uint32 *q, uint16 *r, uint32 x, uint16 m) { x -= m; *q += 1; - mask = -(x >> 31); + mask = (~(x >> 31) + 1); x += mask & (uint32)m; *q += mask; /* x < m */ diff --git a/crypto_kem/sntrup857/clean/crypto_encode_857x1723.c b/crypto_kem/sntrup857/clean/crypto_encode_857x1723.c index 9fc987d2..12e20987 100644 --- a/crypto_kem/sntrup857/clean/crypto_encode_857x1723.c +++ b/crypto_kem/sntrup857/clean/crypto_encode_857x1723.c @@ -126,5 +126,5 @@ void PQCLEAN_SNTRUP857_CLEAN_crypto_encode_857x1723(unsigned char *out, const vo R[0] = (uint16) r2; r0 = R[0]; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; } diff --git a/crypto_kem/sntrup857/clean/crypto_encode_857x5167.c b/crypto_kem/sntrup857/clean/crypto_encode_857x5167.c index 43318fb3..a5af7e6b 100644 --- a/crypto_kem/sntrup857/clean/crypto_encode_857x5167.c +++ b/crypto_kem/sntrup857/clean/crypto_encode_857x5167.c @@ -15,8 +15,8 @@ void PQCLEAN_SNTRUP857_CLEAN_crypto_encode_857x5167(unsigned char *out, const vo uint32 r2; for (i = 0; i < 428; ++i) { - r0 = (R0[2 * i] + 2583) & 16383; - r1 = (R0[2 * i + 1] + 2583) & 16383; + r0 = (uint16) ((R0[2 * i] + 2583) & 16383); + r1 = (uint16) ((R0[2 * i + 1] + 2583) & 16383); r2 = r0 + r1 * (uint32)5167; *out++ = (unsigned char) r2; r2 >>= 8; @@ -24,7 +24,7 @@ void PQCLEAN_SNTRUP857_CLEAN_crypto_encode_857x5167(unsigned char *out, const vo r2 >>= 8; R[i] = (uint16) r2; } - R[428] = (R0[856] + 2583) & 16383; + R[428] = (uint16) ((R0[856] + 2583) & 16383); for (i = 0; i < 214; ++i) { r0 = R[2 * i]; @@ -134,5 +134,5 @@ void PQCLEAN_SNTRUP857_CLEAN_crypto_encode_857x5167(unsigned char *out, const vo r0 = R[0]; *out++ = (unsigned char) r0; r0 >>= 8; - *out++ = (unsigned char) r0; /*clang-analyzer-deadcode.DeadStores*/ /*r0 >>= 8;*/ + *out++ = (unsigned char) r0; }