From 7b93f968f186a1ef195933a5e9fd469de4c06757 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Wed, 2 Sep 2020 17:30:26 -0400 Subject: [PATCH] NTRU Prime: avoid narrowing in loop iteration --- crypto_kem/ntrulpr653/clean/crypto_sort_int32.c | 3 ++- crypto_kem/ntrulpr761/clean/crypto_sort_int32.c | 3 ++- crypto_kem/ntrulpr857/clean/crypto_sort_int32.c | 3 ++- crypto_kem/sntrup653/clean/crypto_sort_int32.c | 3 ++- crypto_kem/sntrup761/clean/crypto_sort_int32.c | 3 ++- crypto_kem/sntrup857/clean/crypto_sort_int32.c | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crypto_kem/ntrulpr653/clean/crypto_sort_int32.c b/crypto_kem/ntrulpr653/clean/crypto_sort_int32.c index cdb63739..3f27c9f1 100644 --- a/crypto_kem/ntrulpr653/clean/crypto_sort_int32.c +++ b/crypto_kem/ntrulpr653/clean/crypto_sort_int32.c @@ -16,7 +16,8 @@ /* assume 2 <= n <= 0x40000000 */ void PQCLEAN_NTRULPR653_CLEAN_crypto_sort_int32(int32_t *x, long long n) { - int32 top, p, q, r, i, j; + int32 top, p, q, r, i; + long long j; top = 1; while (top < n - top) { diff --git a/crypto_kem/ntrulpr761/clean/crypto_sort_int32.c b/crypto_kem/ntrulpr761/clean/crypto_sort_int32.c index f46d6fe5..a23017c3 100644 --- a/crypto_kem/ntrulpr761/clean/crypto_sort_int32.c +++ b/crypto_kem/ntrulpr761/clean/crypto_sort_int32.c @@ -16,7 +16,8 @@ /* assume 2 <= n <= 0x40000000 */ void PQCLEAN_NTRULPR761_CLEAN_crypto_sort_int32(int32_t *x, long long n) { - int32 top, p, q, r, i, j; + int32 top, p, q, r, i; + long long j; top = 1; while (top < n - top) { diff --git a/crypto_kem/ntrulpr857/clean/crypto_sort_int32.c b/crypto_kem/ntrulpr857/clean/crypto_sort_int32.c index 5321e8b8..354d5803 100644 --- a/crypto_kem/ntrulpr857/clean/crypto_sort_int32.c +++ b/crypto_kem/ntrulpr857/clean/crypto_sort_int32.c @@ -16,7 +16,8 @@ /* assume 2 <= n <= 0x40000000 */ void PQCLEAN_NTRULPR857_CLEAN_crypto_sort_int32(int32_t *x, long long n) { - int32 top, p, q, r, i, j; + int32 top, p, q, r, i; + long long j; top = 1; while (top < n - top) { diff --git a/crypto_kem/sntrup653/clean/crypto_sort_int32.c b/crypto_kem/sntrup653/clean/crypto_sort_int32.c index 04475629..e6fc17a5 100644 --- a/crypto_kem/sntrup653/clean/crypto_sort_int32.c +++ b/crypto_kem/sntrup653/clean/crypto_sort_int32.c @@ -16,7 +16,8 @@ /* assume 2 <= n <= 0x40000000 */ void PQCLEAN_SNTRUP653_CLEAN_crypto_sort_int32(int32_t *x, long long n) { - int32 top, p, q, r, i, j; + int32 top, p, q, r, i; + long long j; top = 1; while (top < n - top) { diff --git a/crypto_kem/sntrup761/clean/crypto_sort_int32.c b/crypto_kem/sntrup761/clean/crypto_sort_int32.c index d6b6f7b8..014421db 100644 --- a/crypto_kem/sntrup761/clean/crypto_sort_int32.c +++ b/crypto_kem/sntrup761/clean/crypto_sort_int32.c @@ -16,7 +16,8 @@ /* assume 2 <= n <= 0x40000000 */ void PQCLEAN_SNTRUP761_CLEAN_crypto_sort_int32(int32_t *x, long long n) { - int32 top, p, q, r, i, j; + int32 top, p, q, r, i; + long long j; top = 1; while (top < n - top) { diff --git a/crypto_kem/sntrup857/clean/crypto_sort_int32.c b/crypto_kem/sntrup857/clean/crypto_sort_int32.c index 49ce3678..4d70426b 100644 --- a/crypto_kem/sntrup857/clean/crypto_sort_int32.c +++ b/crypto_kem/sntrup857/clean/crypto_sort_int32.c @@ -16,7 +16,8 @@ /* assume 2 <= n <= 0x40000000 */ void PQCLEAN_SNTRUP857_CLEAN_crypto_sort_int32(int32_t *x, long long n) { - int32 top, p, q, r, i, j; + int32 top, p, q, r, i; + long long j; top = 1; while (top < n - top) {