From 2f56d17d67f2267cc1c786ffcc585569648b61e9 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Mon, 24 Aug 2020 10:56:18 -0400 Subject: [PATCH] NTRU: more explicit casts for MS compiler --- crypto_kem/ntruhps2048509/META.yml | 4 ++-- crypto_kem/ntruhps2048509/clean/poly_s3_inv.c | 8 ++++---- crypto_kem/ntruhps2048677/META.yml | 4 ++-- crypto_kem/ntruhps2048677/clean/poly_s3_inv.c | 8 ++++---- crypto_kem/ntruhps4096821/META.yml | 4 ++-- crypto_kem/ntruhps4096821/clean/poly_s3_inv.c | 8 ++++---- crypto_kem/ntruhrss701/META.yml | 4 ++-- crypto_kem/ntruhrss701/clean/poly_s3_inv.c | 8 ++++---- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/crypto_kem/ntruhps2048509/META.yml b/crypto_kem/ntruhps2048509/META.yml index 043d9686..6caa66fc 100644 --- a/crypto_kem/ntruhps2048509/META.yml +++ b/crypto_kem/ntruhps2048509/META.yml @@ -23,9 +23,9 @@ auxiliary-submitters: - Zhenfei Zhang implementations: - name: clean - version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation - name: avx2 - version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/ntruhps2048509/clean/poly_s3_inv.c b/crypto_kem/ntruhps2048509/clean/poly_s3_inv.c index 92b08480..67047f5c 100644 --- a/crypto_kem/ntruhps2048509/clean/poly_s3_inv.c +++ b/crypto_kem/ntruhps2048509/clean/poly_s3_inv.c @@ -44,7 +44,7 @@ void PQCLEAN_NTRUHPS2048509_CLEAN_poly_S3_inv(poly *r, const poly *a) { } 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]); delta ^= swap & (delta ^ -delta); 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) { - 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) { - 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) { 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]; 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; } diff --git a/crypto_kem/ntruhps2048677/META.yml b/crypto_kem/ntruhps2048677/META.yml index 8fbbd05f..197dfc60 100644 --- a/crypto_kem/ntruhps2048677/META.yml +++ b/crypto_kem/ntruhps2048677/META.yml @@ -23,9 +23,9 @@ auxiliary-submitters: - Zhenfei Zhang implementations: - name: clean - version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation - name: avx2 - version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/ntruhps2048677/clean/poly_s3_inv.c b/crypto_kem/ntruhps2048677/clean/poly_s3_inv.c index 3412f136..19466db0 100644 --- a/crypto_kem/ntruhps2048677/clean/poly_s3_inv.c +++ b/crypto_kem/ntruhps2048677/clean/poly_s3_inv.c @@ -44,7 +44,7 @@ void PQCLEAN_NTRUHPS2048677_CLEAN_poly_S3_inv(poly *r, const poly *a) { } 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]); delta ^= swap & (delta ^ -delta); 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) { - 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) { - 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) { 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]; 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; } diff --git a/crypto_kem/ntruhps4096821/META.yml b/crypto_kem/ntruhps4096821/META.yml index 9da1e89b..a9ea40b3 100644 --- a/crypto_kem/ntruhps4096821/META.yml +++ b/crypto_kem/ntruhps4096821/META.yml @@ -23,9 +23,9 @@ auxiliary-submitters: - Zhenfei Zhang implementations: - name: clean - version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation - name: avx2 - version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/ntruhps4096821/clean/poly_s3_inv.c b/crypto_kem/ntruhps4096821/clean/poly_s3_inv.c index 0f6ec95c..0cd00e97 100644 --- a/crypto_kem/ntruhps4096821/clean/poly_s3_inv.c +++ b/crypto_kem/ntruhps4096821/clean/poly_s3_inv.c @@ -44,7 +44,7 @@ void PQCLEAN_NTRUHPS4096821_CLEAN_poly_S3_inv(poly *r, const poly *a) { } 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]); delta ^= swap & (delta ^ -delta); 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) { - 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) { - 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) { 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]; 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; } diff --git a/crypto_kem/ntruhrss701/META.yml b/crypto_kem/ntruhrss701/META.yml index 36617929..de3c690a 100644 --- a/crypto_kem/ntruhrss701/META.yml +++ b/crypto_kem/ntruhrss701/META.yml @@ -23,9 +23,9 @@ auxiliary-submitters: - Zhenfei Zhang implementations: - name: clean - version: https://github.com/jschanck/ntru/tree/00f73a7f reference implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 reference implementation - name: avx2 - version: https://github.com/jschanck/ntru/tree/00f73a7f avx2 implementation + version: https://github.com/jschanck/ntru/tree/ba431bb8 avx2 implementation supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/ntruhrss701/clean/poly_s3_inv.c b/crypto_kem/ntruhrss701/clean/poly_s3_inv.c index 6100a08f..fd672ca2 100644 --- a/crypto_kem/ntruhrss701/clean/poly_s3_inv.c +++ b/crypto_kem/ntruhrss701/clean/poly_s3_inv.c @@ -44,7 +44,7 @@ void PQCLEAN_NTRUHRSS701_CLEAN_poly_S3_inv(poly *r, const poly *a) { } 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]); delta ^= swap & (delta ^ -delta); 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) { - 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) { - 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) { 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]; 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; }