1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 07:35:38 +00:00

NTRU: more explicit casts for MS compiler

This commit is contained in:
John M. Schanck 2020-08-24 10:56:18 -04:00 committed by Kris Kwiatkowski
parent f772093fd4
commit 2f56d17d67
8 changed files with 24 additions and 24 deletions

View File

@ -23,9 +23,9 @@ auxiliary-submitters:
- Zhenfei Zhang - Zhenfei Zhang
implementations: implementations:
- name: clean - name: clean
version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation
- name: avx2 - name: avx2
version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation
supported_platforms: supported_platforms:
- architecture: x86_64 - architecture: x86_64
operating_systems: operating_systems:

View File

@ -44,7 +44,7 @@ void PQCLEAN_NTRUHPS2048509_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
v.coeffs[0] = 0; v.coeffs[0] = 0;
sign = mod3(2 * g.coeffs[0] * f.coeffs[0]); sign = mod3((uint8_t) (2 * g.coeffs[0] * f.coeffs[0]));
swap = both_negative_mask(-delta, -(int) g.coeffs[0]); swap = both_negative_mask(-delta, -(int) g.coeffs[0]);
delta ^= swap & (delta ^ -delta); delta ^= swap & (delta ^ -delta);
delta += 1; delta += 1;
@ -59,10 +59,10 @@ void PQCLEAN_NTRUHPS2048509_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
g.coeffs[i] = mod3(g.coeffs[i] + sign * f.coeffs[i]); g.coeffs[i] = mod3((uint8_t) (g.coeffs[i] + sign * f.coeffs[i]));
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
w.coeffs[i] = mod3(w.coeffs[i] + sign * v.coeffs[i]); w.coeffs[i] = mod3((uint8_t) (w.coeffs[i] + sign * v.coeffs[i]));
} }
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
g.coeffs[i] = g.coeffs[i + 1]; g.coeffs[i] = g.coeffs[i + 1];
@ -72,7 +72,7 @@ void PQCLEAN_NTRUHPS2048509_CLEAN_poly_S3_inv(poly *r, const poly *a) {
sign = f.coeffs[0]; sign = f.coeffs[0];
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
r->coeffs[i] = mod3(sign * v.coeffs[NTRU_N - 2 - i]); r->coeffs[i] = mod3((uint8_t) (sign * v.coeffs[NTRU_N - 2 - i]));
} }
r->coeffs[NTRU_N - 1] = 0; r->coeffs[NTRU_N - 1] = 0;
} }

View File

@ -23,9 +23,9 @@ auxiliary-submitters:
- Zhenfei Zhang - Zhenfei Zhang
implementations: implementations:
- name: clean - name: clean
version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation
- name: avx2 - name: avx2
version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation
supported_platforms: supported_platforms:
- architecture: x86_64 - architecture: x86_64
operating_systems: operating_systems:

View File

@ -44,7 +44,7 @@ void PQCLEAN_NTRUHPS2048677_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
v.coeffs[0] = 0; v.coeffs[0] = 0;
sign = mod3(2 * g.coeffs[0] * f.coeffs[0]); sign = mod3((uint8_t) (2 * g.coeffs[0] * f.coeffs[0]));
swap = both_negative_mask(-delta, -(int) g.coeffs[0]); swap = both_negative_mask(-delta, -(int) g.coeffs[0]);
delta ^= swap & (delta ^ -delta); delta ^= swap & (delta ^ -delta);
delta += 1; delta += 1;
@ -59,10 +59,10 @@ void PQCLEAN_NTRUHPS2048677_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
g.coeffs[i] = mod3(g.coeffs[i] + sign * f.coeffs[i]); g.coeffs[i] = mod3((uint8_t) (g.coeffs[i] + sign * f.coeffs[i]));
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
w.coeffs[i] = mod3(w.coeffs[i] + sign * v.coeffs[i]); w.coeffs[i] = mod3((uint8_t) (w.coeffs[i] + sign * v.coeffs[i]));
} }
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
g.coeffs[i] = g.coeffs[i + 1]; g.coeffs[i] = g.coeffs[i + 1];
@ -72,7 +72,7 @@ void PQCLEAN_NTRUHPS2048677_CLEAN_poly_S3_inv(poly *r, const poly *a) {
sign = f.coeffs[0]; sign = f.coeffs[0];
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
r->coeffs[i] = mod3(sign * v.coeffs[NTRU_N - 2 - i]); r->coeffs[i] = mod3((uint8_t) (sign * v.coeffs[NTRU_N - 2 - i]));
} }
r->coeffs[NTRU_N - 1] = 0; r->coeffs[NTRU_N - 1] = 0;
} }

View File

@ -23,9 +23,9 @@ auxiliary-submitters:
- Zhenfei Zhang - Zhenfei Zhang
implementations: implementations:
- name: clean - name: clean
version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation
- name: avx2 - name: avx2
version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation
supported_platforms: supported_platforms:
- architecture: x86_64 - architecture: x86_64
operating_systems: operating_systems:

View File

@ -44,7 +44,7 @@ void PQCLEAN_NTRUHPS4096821_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
v.coeffs[0] = 0; v.coeffs[0] = 0;
sign = mod3(2 * g.coeffs[0] * f.coeffs[0]); sign = mod3((uint8_t) (2 * g.coeffs[0] * f.coeffs[0]));
swap = both_negative_mask(-delta, -(int) g.coeffs[0]); swap = both_negative_mask(-delta, -(int) g.coeffs[0]);
delta ^= swap & (delta ^ -delta); delta ^= swap & (delta ^ -delta);
delta += 1; delta += 1;
@ -59,10 +59,10 @@ void PQCLEAN_NTRUHPS4096821_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
g.coeffs[i] = mod3(g.coeffs[i] + sign * f.coeffs[i]); g.coeffs[i] = mod3((uint8_t) (g.coeffs[i] + sign * f.coeffs[i]));
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
w.coeffs[i] = mod3(w.coeffs[i] + sign * v.coeffs[i]); w.coeffs[i] = mod3((uint8_t) (w.coeffs[i] + sign * v.coeffs[i]));
} }
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
g.coeffs[i] = g.coeffs[i + 1]; g.coeffs[i] = g.coeffs[i + 1];
@ -72,7 +72,7 @@ void PQCLEAN_NTRUHPS4096821_CLEAN_poly_S3_inv(poly *r, const poly *a) {
sign = f.coeffs[0]; sign = f.coeffs[0];
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
r->coeffs[i] = mod3(sign * v.coeffs[NTRU_N - 2 - i]); r->coeffs[i] = mod3((uint8_t) (sign * v.coeffs[NTRU_N - 2 - i]));
} }
r->coeffs[NTRU_N - 1] = 0; r->coeffs[NTRU_N - 1] = 0;
} }

View File

@ -23,9 +23,9 @@ auxiliary-submitters:
- Zhenfei Zhang - Zhenfei Zhang
implementations: implementations:
- name: clean - name: clean
version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation
- name: avx2 - name: avx2
version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation
supported_platforms: supported_platforms:
- architecture: x86_64 - architecture: x86_64
operating_systems: operating_systems:

View File

@ -44,7 +44,7 @@ void PQCLEAN_NTRUHRSS701_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
v.coeffs[0] = 0; v.coeffs[0] = 0;
sign = mod3(2 * g.coeffs[0] * f.coeffs[0]); sign = mod3((uint8_t) (2 * g.coeffs[0] * f.coeffs[0]));
swap = both_negative_mask(-delta, -(int) g.coeffs[0]); swap = both_negative_mask(-delta, -(int) g.coeffs[0]);
delta ^= swap & (delta ^ -delta); delta ^= swap & (delta ^ -delta);
delta += 1; delta += 1;
@ -59,10 +59,10 @@ void PQCLEAN_NTRUHRSS701_CLEAN_poly_S3_inv(poly *r, const poly *a) {
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
g.coeffs[i] = mod3(g.coeffs[i] + sign * f.coeffs[i]); g.coeffs[i] = mod3((uint8_t) (g.coeffs[i] + sign * f.coeffs[i]));
} }
for (i = 0; i < NTRU_N; ++i) { for (i = 0; i < NTRU_N; ++i) {
w.coeffs[i] = mod3(w.coeffs[i] + sign * v.coeffs[i]); w.coeffs[i] = mod3((uint8_t) (w.coeffs[i] + sign * v.coeffs[i]));
} }
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
g.coeffs[i] = g.coeffs[i + 1]; g.coeffs[i] = g.coeffs[i + 1];
@ -72,7 +72,7 @@ void PQCLEAN_NTRUHRSS701_CLEAN_poly_S3_inv(poly *r, const poly *a) {
sign = f.coeffs[0]; sign = f.coeffs[0];
for (i = 0; i < NTRU_N - 1; ++i) { for (i = 0; i < NTRU_N - 1; ++i) {
r->coeffs[i] = mod3(sign * v.coeffs[NTRU_N - 2 - i]); r->coeffs[i] = mod3((uint8_t) (sign * v.coeffs[NTRU_N - 2 - i]));
} }
r->coeffs[NTRU_N - 1] = 0; r->coeffs[NTRU_N - 1] = 0;
} }