diff --git a/crypto_kem/ntrulpr653/avx2/crypto_core_multsntrup653.c b/crypto_kem/ntrulpr653/avx2/crypto_core_multsntrup653.c index 8c754b1f..74df5a9d 100644 --- a/crypto_kem/ntrulpr653/avx2/crypto_core_multsntrup653.c +++ b/crypto_kem/ntrulpr653/avx2/crypto_core_multsntrup653.c @@ -298,7 +298,7 @@ int PQCLEAN_NTRULPR653_AVX2_crypto_core_multsntrup653(unsigned char *outbytes, c mult768(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 768; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/ntrulpr653/clean/crypto_encode_653x3.c b/crypto_kem/ntrulpr653/clean/crypto_encode_653x3.c index 2dc3dffc..0b328e94 100644 --- a/crypto_kem/ntrulpr653/clean/crypto_encode_653x3.c +++ b/crypto_kem/ntrulpr653/clean/crypto_encode_653x3.c @@ -10,10 +10,10 @@ void PQCLEAN_NTRULPR653_CLEAN_crypto_encode_653x3(unsigned char *s, const void * int i; for (i = 0; i < p / 4; ++i) { - x = *f++ + 1; - x += (uint8) ((*f++ + 1) << 2); - x += (uint8) ((*f++ + 1) << 4); - x += (uint8) ((*f++ + 1) << 6); + x = (uint8) (*f++ + 1); + x = (uint8) (x + ((*f++ + 1) << 2)); + x = (uint8) (x + ((*f++ + 1) << 4)); + x = (uint8) (x + ((*f++ + 1) << 6)); *s++ = x; } x = *f++ + 1; diff --git a/crypto_kem/ntrulpr761/avx2/crypto_core_multsntrup761.c b/crypto_kem/ntrulpr761/avx2/crypto_core_multsntrup761.c index c5a1ce0d..b78302d2 100644 --- a/crypto_kem/ntrulpr761/avx2/crypto_core_multsntrup761.c +++ b/crypto_kem/ntrulpr761/avx2/crypto_core_multsntrup761.c @@ -298,7 +298,7 @@ int PQCLEAN_NTRULPR761_AVX2_crypto_core_multsntrup761(unsigned char *outbytes, c mult768(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 768; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/ntrulpr761/clean/crypto_encode_761x3.c b/crypto_kem/ntrulpr761/clean/crypto_encode_761x3.c index 7f9bd4d4..68be7bb0 100644 --- a/crypto_kem/ntrulpr761/clean/crypto_encode_761x3.c +++ b/crypto_kem/ntrulpr761/clean/crypto_encode_761x3.c @@ -5,15 +5,15 @@ #define p 761 void PQCLEAN_NTRULPR761_CLEAN_crypto_encode_761x3(unsigned char *s, const void *v) { - const uint8 *f = v; + const uint8 *f = (const uint8 *)v; uint8 x; int i; for (i = 0; i < p / 4; ++i) { - x = *f++ + 1; - x += (uint8) ((*f++ + 1) << 2); - x += (uint8) ((*f++ + 1) << 4); - x += (uint8) ((*f++ + 1) << 6); + x = (uint8) (*f++ + 1); + x = (uint8) (x + ((*f++ + 1) << 2)); + x = (uint8) (x + ((*f++ + 1) << 4)); + x = (uint8) (x + ((*f++ + 1) << 6)); *s++ = x; } x = *f++ + 1; diff --git a/crypto_kem/ntrulpr857/avx2/crypto_core_multsntrup857.c b/crypto_kem/ntrulpr857/avx2/crypto_core_multsntrup857.c index 9138df20..e4e12728 100644 --- a/crypto_kem/ntrulpr857/avx2/crypto_core_multsntrup857.c +++ b/crypto_kem/ntrulpr857/avx2/crypto_core_multsntrup857.c @@ -405,7 +405,7 @@ int PQCLEAN_NTRULPR857_AVX2_crypto_core_multsntrup857(unsigned char *outbytes, c mult1024(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 1024; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/ntrulpr857/clean/crypto_encode_857x3.c b/crypto_kem/ntrulpr857/clean/crypto_encode_857x3.c index d0646e88..e4660fa7 100644 --- a/crypto_kem/ntrulpr857/clean/crypto_encode_857x3.c +++ b/crypto_kem/ntrulpr857/clean/crypto_encode_857x3.c @@ -10,10 +10,10 @@ void PQCLEAN_NTRULPR857_CLEAN_crypto_encode_857x3(unsigned char *s, const void * int i; for (i = 0; i < p / 4; ++i) { - x = *f++ + 1; - x += (uint8) ((*f++ + 1) << 2); - x += (uint8) ((*f++ + 1) << 4); - x += (uint8) ((*f++ + 1) << 6); + x = (uint8) (*f++ + 1); + x = (uint8) (x + ((*f++ + 1) << 2)); + x = (uint8) (x + ((*f++ + 1) << 4)); + x = (uint8) (x + ((*f++ + 1) << 6)); *s++ = x; } x = *f++ + 1; diff --git a/crypto_kem/sntrup653/avx2/crypto_core_multsntrup653.c b/crypto_kem/sntrup653/avx2/crypto_core_multsntrup653.c index 7af7050b..6793709d 100644 --- a/crypto_kem/sntrup653/avx2/crypto_core_multsntrup653.c +++ b/crypto_kem/sntrup653/avx2/crypto_core_multsntrup653.c @@ -298,7 +298,7 @@ int PQCLEAN_SNTRUP653_AVX2_crypto_core_multsntrup653(unsigned char *outbytes, co mult768(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 768; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/sntrup653/clean/crypto_core_inv3sntrup653.c b/crypto_kem/sntrup653/clean/crypto_core_inv3sntrup653.c index ef09babe..d63459a5 100644 --- a/crypto_kem/sntrup653/clean/crypto_core_inv3sntrup653.c +++ b/crypto_kem/sntrup653/clean/crypto_core_inv3sntrup653.c @@ -74,7 +74,7 @@ int PQCLEAN_SNTRUP653_CLEAN_crypto_core_inv3sntrup653(unsigned char *outbytes, c v[0] = 0; sign = -g[0] * f[0]; - swap = int16_negative_mask(-(int16) delta) & int16_nonzero_mask(g[0]); + swap = int16_negative_mask((int16) - delta) & int16_nonzero_mask(g[0]); delta ^= swap & (delta ^ -delta); delta += 1; @@ -102,7 +102,7 @@ int PQCLEAN_SNTRUP653_CLEAN_crypto_core_inv3sntrup653(unsigned char *outbytes, c sign = f[0]; for (i = 0; i < p; ++i) { - out[i] = (small) sign * v[p - 1 - i]; + out[i] = (small) (sign * v[p - 1 - i]); } out[p] = (small) int16_nonzero_mask((int16) delta); diff --git a/crypto_kem/sntrup653/clean/crypto_encode_653x3.c b/crypto_kem/sntrup653/clean/crypto_encode_653x3.c index 61ae2eed..4fc93036 100644 --- a/crypto_kem/sntrup653/clean/crypto_encode_653x3.c +++ b/crypto_kem/sntrup653/clean/crypto_encode_653x3.c @@ -10,10 +10,10 @@ void PQCLEAN_SNTRUP653_CLEAN_crypto_encode_653x3(unsigned char *s, const void *v int i; for (i = 0; i < p / 4; ++i) { - x = *f++ + 1; - x += (uint8) ((*f++ + 1) << 2); - x += (uint8) ((*f++ + 1) << 4); - x += (uint8) ((*f++ + 1) << 6); + x = (uint8) (*f++ + 1); + x = (uint8) (x + ((*f++ + 1) << 2)); + x = (uint8) (x + ((*f++ + 1) << 4)); + x = (uint8) (x + ((*f++ + 1) << 6)); *s++ = x; } x = *f++ + 1; diff --git a/crypto_kem/sntrup761/avx2/crypto_core_multsntrup761.c b/crypto_kem/sntrup761/avx2/crypto_core_multsntrup761.c index 87253477..7ee2997a 100644 --- a/crypto_kem/sntrup761/avx2/crypto_core_multsntrup761.c +++ b/crypto_kem/sntrup761/avx2/crypto_core_multsntrup761.c @@ -298,7 +298,7 @@ int PQCLEAN_SNTRUP761_AVX2_crypto_core_multsntrup761(unsigned char *outbytes, co mult768(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 768; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/sntrup761/clean/crypto_core_inv3sntrup761.c b/crypto_kem/sntrup761/clean/crypto_core_inv3sntrup761.c index 99342bce..1aba59e9 100644 --- a/crypto_kem/sntrup761/clean/crypto_core_inv3sntrup761.c +++ b/crypto_kem/sntrup761/clean/crypto_core_inv3sntrup761.c @@ -74,7 +74,7 @@ int PQCLEAN_SNTRUP761_CLEAN_crypto_core_inv3sntrup761(unsigned char *outbytes, c v[0] = 0; sign = -g[0] * f[0]; - swap = int16_negative_mask(-(int16) delta) & int16_nonzero_mask(g[0]); + swap = int16_negative_mask((int16) - delta) & int16_nonzero_mask(g[0]); delta ^= swap & (delta ^ -delta); delta += 1; @@ -102,7 +102,7 @@ int PQCLEAN_SNTRUP761_CLEAN_crypto_core_inv3sntrup761(unsigned char *outbytes, c sign = f[0]; for (i = 0; i < p; ++i) { - out[i] = (small) sign * v[p - 1 - i]; + out[i] = (small) (sign * v[p - 1 - i]); } out[p] = (small) int16_nonzero_mask((int16) delta); diff --git a/crypto_kem/sntrup761/clean/crypto_encode_761x3.c b/crypto_kem/sntrup761/clean/crypto_encode_761x3.c index 32d00f3b..7bb35adb 100644 --- a/crypto_kem/sntrup761/clean/crypto_encode_761x3.c +++ b/crypto_kem/sntrup761/clean/crypto_encode_761x3.c @@ -5,15 +5,15 @@ #define p 761 void PQCLEAN_SNTRUP761_CLEAN_crypto_encode_761x3(unsigned char *s, const void *v) { - const uint8 *f = v; + const uint8 *f = (const uint8 *)v; uint8 x; int i; for (i = 0; i < p / 4; ++i) { - x = *f++ + 1; - x += (uint8) ((*f++ + 1) << 2); - x += (uint8) ((*f++ + 1) << 4); - x += (uint8) ((*f++ + 1) << 6); + x = (uint8) (*f++ + 1); + x = (uint8) (x + ((*f++ + 1) << 2)); + x = (uint8) (x + ((*f++ + 1) << 4)); + x = (uint8) (x + ((*f++ + 1) << 6)); *s++ = x; } x = *f++ + 1; diff --git a/crypto_kem/sntrup857/avx2/crypto_core_multsntrup857.c b/crypto_kem/sntrup857/avx2/crypto_core_multsntrup857.c index 898c7297..dbaabc56 100644 --- a/crypto_kem/sntrup857/avx2/crypto_core_multsntrup857.c +++ b/crypto_kem/sntrup857/avx2/crypto_core_multsntrup857.c @@ -405,7 +405,7 @@ int PQCLEAN_SNTRUP857_AVX2_crypto_core_multsntrup857(unsigned char *outbytes, co mult1024(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 1024; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/sntrup857/clean/crypto_core_inv3sntrup857.c b/crypto_kem/sntrup857/clean/crypto_core_inv3sntrup857.c index 6ea2adcb..c053c761 100644 --- a/crypto_kem/sntrup857/clean/crypto_core_inv3sntrup857.c +++ b/crypto_kem/sntrup857/clean/crypto_core_inv3sntrup857.c @@ -74,7 +74,7 @@ int PQCLEAN_SNTRUP857_CLEAN_crypto_core_inv3sntrup857(unsigned char *outbytes, c v[0] = 0; sign = -g[0] * f[0]; - swap = int16_negative_mask(-(int16) delta) & int16_nonzero_mask(g[0]); + swap = int16_negative_mask((int16) - delta) & int16_nonzero_mask(g[0]); delta ^= swap & (delta ^ -delta); delta += 1; @@ -102,7 +102,7 @@ int PQCLEAN_SNTRUP857_CLEAN_crypto_core_inv3sntrup857(unsigned char *outbytes, c sign = f[0]; for (i = 0; i < p; ++i) { - out[i] = (small) sign * v[p - 1 - i]; + out[i] = (small) (sign * v[p - 1 - i]); } out[p] = (small) int16_nonzero_mask((int16) delta); diff --git a/crypto_kem/sntrup857/clean/crypto_encode_857x3.c b/crypto_kem/sntrup857/clean/crypto_encode_857x3.c index 2db8d7ea..75002c0f 100644 --- a/crypto_kem/sntrup857/clean/crypto_encode_857x3.c +++ b/crypto_kem/sntrup857/clean/crypto_encode_857x3.c @@ -10,10 +10,10 @@ void PQCLEAN_SNTRUP857_CLEAN_crypto_encode_857x3(unsigned char *s, const void *v int i; for (i = 0; i < p / 4; ++i) { - x = *f++ + 1; - x += (uint8) ((*f++ + 1) << 2); - x += (uint8) ((*f++ + 1) << 4); - x += (uint8) ((*f++ + 1) << 6); + x = (uint8) (*f++ + 1); + x = (uint8) (x + ((*f++ + 1) << 2)); + x = (uint8) (x + ((*f++ + 1) << 4)); + x = (uint8) (x + ((*f++ + 1) << 6)); *s++ = x; } x = *f++ + 1;