From 938a5dcd5dd1c9210cb221181038f73fa9e2400f Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Tue, 15 Sep 2020 12:24:07 -0400 Subject: [PATCH] mceliece, ntru, ntruprime: satisfy test_boolean (in int32_sort)" --- crypto_kem/mceliece348864/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece348864f/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece460896/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece460896f/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece6688128/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece6688128f/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece6960119/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece6960119f/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece8192128/avx/int32_sort.c | 5 +++-- crypto_kem/mceliece8192128f/avx/int32_sort.c | 5 +++-- crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.c | 11 +++++++---- crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.h | 3 +-- crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.c | 11 +++++++---- crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.h | 3 +-- crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.c | 11 +++++++---- crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.h | 3 +-- crypto_kem/ntrulpr653/avx2/crypto_sort_int32.c | 5 +++-- crypto_kem/ntrulpr761/avx2/crypto_sort_int32.c | 5 +++-- crypto_kem/ntrulpr857/avx2/crypto_sort_int32.c | 5 +++-- crypto_kem/sntrup653/avx2/crypto_sort_int32.c | 5 +++-- crypto_kem/sntrup761/avx2/crypto_sort_int32.c | 5 +++-- crypto_kem/sntrup857/avx2/crypto_sort_int32.c | 5 +++-- 22 files changed, 72 insertions(+), 50 deletions(-) diff --git a/crypto_kem/mceliece348864/avx/int32_sort.c b/crypto_kem/mceliece348864/avx/int32_sort.c index daf93da4..54295975 100644 --- a/crypto_kem/mceliece348864/avx/int32_sort.c +++ b/crypto_kem/mceliece348864/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece348864f/avx/int32_sort.c b/crypto_kem/mceliece348864f/avx/int32_sort.c index 4284a598..a282f5c2 100644 --- a/crypto_kem/mceliece348864f/avx/int32_sort.c +++ b/crypto_kem/mceliece348864f/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece460896/avx/int32_sort.c b/crypto_kem/mceliece460896/avx/int32_sort.c index d9577389..cdddf86a 100644 --- a/crypto_kem/mceliece460896/avx/int32_sort.c +++ b/crypto_kem/mceliece460896/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece460896f/avx/int32_sort.c b/crypto_kem/mceliece460896f/avx/int32_sort.c index f88bfc74..cc7e347a 100644 --- a/crypto_kem/mceliece460896f/avx/int32_sort.c +++ b/crypto_kem/mceliece460896f/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece6688128/avx/int32_sort.c b/crypto_kem/mceliece6688128/avx/int32_sort.c index 4421fdf1..da5f0e57 100644 --- a/crypto_kem/mceliece6688128/avx/int32_sort.c +++ b/crypto_kem/mceliece6688128/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece6688128f/avx/int32_sort.c b/crypto_kem/mceliece6688128f/avx/int32_sort.c index 4be2b525..02bf18bb 100644 --- a/crypto_kem/mceliece6688128f/avx/int32_sort.c +++ b/crypto_kem/mceliece6688128f/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece6960119/avx/int32_sort.c b/crypto_kem/mceliece6960119/avx/int32_sort.c index 39785008..270ba5b6 100644 --- a/crypto_kem/mceliece6960119/avx/int32_sort.c +++ b/crypto_kem/mceliece6960119/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece6960119f/avx/int32_sort.c b/crypto_kem/mceliece6960119f/avx/int32_sort.c index 9c38802a..fdfc419d 100644 --- a/crypto_kem/mceliece6960119f/avx/int32_sort.c +++ b/crypto_kem/mceliece6960119f/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece8192128/avx/int32_sort.c b/crypto_kem/mceliece8192128/avx/int32_sort.c index a7eca2ba..145dfa8e 100644 --- a/crypto_kem/mceliece8192128/avx/int32_sort.c +++ b/crypto_kem/mceliece8192128/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/mceliece8192128f/avx/int32_sort.c b/crypto_kem/mceliece8192128f/avx/int32_sort.c index d18b3a73..e5942540 100644 --- a/crypto_kem/mceliece8192128f/avx/int32_sort.c +++ b/crypto_kem/mceliece8192128f/avx/int32_sort.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.c b/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.c index 12c5ea15..cef509b6 100644 --- a/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.c +++ b/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.c @@ -1,8 +1,8 @@ +#include "crypto_sort_int32.h" +#include // Based on supercop-20200820/crypto_sort/int32/avx2 -#include "crypto_sort_int32.h" -#include #define int32 int32_t typedef __m256i int32x8; @@ -469,8 +469,11 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) { + flip = 1; + } + flipflip = 1 - flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.h b/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.h index 5a121e16..fdc31858 100644 --- a/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.h +++ b/crypto_kem/ntruhps2048509/avx2/crypto_sort_int32.h @@ -1,11 +1,10 @@ #ifndef CRYPTO_SORT #define CRYPTO_SORT - #include "params.h" - #include #include + void PQCLEAN_NTRUHPS2048509_AVX2_crypto_sort_int32(int32_t *x, size_t n); #endif diff --git a/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.c b/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.c index e9a81a7f..874b4cd7 100644 --- a/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.c +++ b/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.c @@ -1,8 +1,8 @@ +#include "crypto_sort_int32.h" +#include // Based on supercop-20200820/crypto_sort/int32/avx2 -#include "crypto_sort_int32.h" -#include #define int32 int32_t typedef __m256i int32x8; @@ -469,8 +469,11 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) { + flip = 1; + } + flipflip = 1 - flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.h b/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.h index 12f221b0..84d40c07 100644 --- a/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.h +++ b/crypto_kem/ntruhps2048677/avx2/crypto_sort_int32.h @@ -1,11 +1,10 @@ #ifndef CRYPTO_SORT #define CRYPTO_SORT - #include "params.h" - #include #include + void PQCLEAN_NTRUHPS2048677_AVX2_crypto_sort_int32(int32_t *x, size_t n); #endif diff --git a/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.c b/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.c index 47b06efd..d4c16d25 100644 --- a/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.c +++ b/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.c @@ -1,8 +1,8 @@ +#include "crypto_sort_int32.h" +#include // Based on supercop-20200820/crypto_sort/int32/avx2 -#include "crypto_sort_int32.h" -#include #define int32 int32_t typedef __m256i int32x8; @@ -469,8 +469,11 @@ static void int32_sort_2power(int32 *x, size_t n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) { + flip = 1; + } + flipflip = 1 - flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.h b/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.h index 63d91ade..209e2188 100644 --- a/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.h +++ b/crypto_kem/ntruhps4096821/avx2/crypto_sort_int32.h @@ -1,11 +1,10 @@ #ifndef CRYPTO_SORT #define CRYPTO_SORT - #include "params.h" - #include #include + void PQCLEAN_NTRUHPS4096821_AVX2_crypto_sort_int32(int32_t *x, size_t n); #endif diff --git a/crypto_kem/ntrulpr653/avx2/crypto_sort_int32.c b/crypto_kem/ntrulpr653/avx2/crypto_sort_int32.c index 9a3a3bf6..f54b8934 100644 --- a/crypto_kem/ntrulpr653/avx2/crypto_sort_int32.c +++ b/crypto_kem/ntrulpr653/avx2/crypto_sort_int32.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, long long n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/ntrulpr761/avx2/crypto_sort_int32.c b/crypto_kem/ntrulpr761/avx2/crypto_sort_int32.c index 4b4e018c..bcac3bb9 100644 --- a/crypto_kem/ntrulpr761/avx2/crypto_sort_int32.c +++ b/crypto_kem/ntrulpr761/avx2/crypto_sort_int32.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, long long n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/ntrulpr857/avx2/crypto_sort_int32.c b/crypto_kem/ntrulpr857/avx2/crypto_sort_int32.c index 3f87a657..d6563d78 100644 --- a/crypto_kem/ntrulpr857/avx2/crypto_sort_int32.c +++ b/crypto_kem/ntrulpr857/avx2/crypto_sort_int32.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, long long n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/sntrup653/avx2/crypto_sort_int32.c b/crypto_kem/sntrup653/avx2/crypto_sort_int32.c index c0927747..de880bf7 100644 --- a/crypto_kem/sntrup653/avx2/crypto_sort_int32.c +++ b/crypto_kem/sntrup653/avx2/crypto_sort_int32.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, long long n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/sntrup761/avx2/crypto_sort_int32.c b/crypto_kem/sntrup761/avx2/crypto_sort_int32.c index ffe126ea..9c3b88c3 100644 --- a/crypto_kem/sntrup761/avx2/crypto_sort_int32.c +++ b/crypto_kem/sntrup761/avx2/crypto_sort_int32.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, long long n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) { diff --git a/crypto_kem/sntrup857/avx2/crypto_sort_int32.c b/crypto_kem/sntrup857/avx2/crypto_sort_int32.c index a086fc93..6879a1d3 100644 --- a/crypto_kem/sntrup857/avx2/crypto_sort_int32.c +++ b/crypto_kem/sntrup857/avx2/crypto_sort_int32.c @@ -462,8 +462,9 @@ static void int32_sort_2power(int32 *x, long long n, int flagdown) { } q = n >> 3; - flip = (p << 1 == q); - flipflip = !flip; + flip = 0; + if (p << 1 == q) flip = 1; + flipflip = 1-flip; for (j = 0; j < q; j += p + p) { for (k = j; k < j + p + p; k += p) { for (i = k; i < k + p; i += 8) {