From 0fcd954047e8f5f20df040ed505eb1c9070683ce Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Fri, 23 Oct 2020 08:26:41 -0400 Subject: [PATCH] hqc: Add -Wshadow and fix shadowing warnings --- crypto_kem/hqc-128/META.yml | 4 ++-- crypto_kem/hqc-128/avx2/Makefile | 2 +- crypto_kem/hqc-128/avx2/bch.c | 6 +++--- crypto_kem/hqc-128/avx2/code.c | 8 ++++---- crypto_kem/hqc-128/avx2/vector.c | 21 ++++++++++++--------- crypto_kem/hqc-128/clean/Makefile | 2 +- crypto_kem/hqc-192/META.yml | 4 ++-- crypto_kem/hqc-192/avx2/Makefile | 2 +- crypto_kem/hqc-192/avx2/bch.c | 6 +++--- crypto_kem/hqc-192/avx2/code.c | 6 +++--- crypto_kem/hqc-192/avx2/vector.c | 21 ++++++++++++--------- crypto_kem/hqc-192/clean/Makefile | 2 +- crypto_kem/hqc-256/META.yml | 4 ++-- crypto_kem/hqc-256/avx2/Makefile | 2 +- crypto_kem/hqc-256/avx2/bch.c | 6 +++--- crypto_kem/hqc-256/avx2/code.c | 6 +++--- crypto_kem/hqc-256/avx2/vector.c | 21 ++++++++++++--------- crypto_kem/hqc-256/clean/Makefile | 2 +- crypto_kem/hqc-rmrs-128/META.yml | 4 ++-- crypto_kem/hqc-rmrs-128/avx2/Makefile | 2 +- crypto_kem/hqc-rmrs-128/avx2/vector.c | 22 ++++++++++++---------- crypto_kem/hqc-rmrs-128/clean/Makefile | 2 +- crypto_kem/hqc-rmrs-192/META.yml | 4 ++-- crypto_kem/hqc-rmrs-192/avx2/Makefile | 2 +- crypto_kem/hqc-rmrs-192/avx2/vector.c | 22 ++++++++++++---------- crypto_kem/hqc-rmrs-192/clean/Makefile | 2 +- crypto_kem/hqc-rmrs-256/META.yml | 4 ++-- crypto_kem/hqc-rmrs-256/avx2/Makefile | 2 +- crypto_kem/hqc-rmrs-256/avx2/vector.c | 22 ++++++++++++---------- crypto_kem/hqc-rmrs-256/clean/Makefile | 2 +- 30 files changed, 115 insertions(+), 100 deletions(-) diff --git a/crypto_kem/hqc-128/META.yml b/crypto_kem/hqc-128/META.yml index 19eb3b60..d3241d93 100644 --- a/crypto_kem/hqc-128/META.yml +++ b/crypto_kem/hqc-128/META.yml @@ -22,9 +22,9 @@ principal-submitters: - Loïc Bidoux implementations: - name: clean - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc - name: avx2 - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-128/avx2/Makefile b/crypto_kem/hqc-128/avx2/Makefile index 607e047f..191dc9f3 100644 --- a/crypto_kem/hqc-128/avx2/Makefile +++ b/crypto_kem/hqc-128/avx2/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-128_avx2.a HEADERS=alpha_table.h api.h bch.h code.h fft.h gen_matrix.h gf2x.h gf.h hqc.h parameters.h parsing.h repetition.h vector.h OBJECTS=bch.o code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o repetition.o vector.o -CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wshadow -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-128/avx2/bch.c b/crypto_kem/hqc-128/avx2/bch.c index 519c82c6..d385afc6 100644 --- a/crypto_kem/hqc-128/avx2/bch.c +++ b/crypto_kem/hqc-128/avx2/bch.c @@ -146,7 +146,7 @@ void compute_syndromes(__m256i *syndromes, const uint64_t *rcv) { __m256i tmp_repeat; uint32_t *aux; int16_t *alpha_tmp; - uint32_t i; + size_t i, j; uint32_t nzflag; // static variable so that it is stored in the DATA segment // not in the STACK segment @@ -167,11 +167,11 @@ void compute_syndromes(__m256i *syndromes, const uint64_t *rcv) { } // Evaluation of the polynomial corresponding to the vector v in alpha^i for i in {1, ..., 2 * PARAM_DELTA} - for (size_t j = 0; j < SYND_SIZE_256; ++j) { + for (j = 0; j < SYND_SIZE_256; ++j) { S = zero_256; alpha_tmp = table_alpha_ij + (j << 4); - for (size_t i = 0; i < PARAM_N1; ++i) { + for (i = 0; i < PARAM_N1; ++i) { nzflag = ((-(int32_t) tmp_array[i]) >> 31) & 1; tmp_repeat = _mm256_set1_epi64x(nzflag); L = _mm256_cmpeq_epi64(tmp_repeat, un_256); diff --git a/crypto_kem/hqc-128/avx2/code.c b/crypto_kem/hqc-128/avx2/code.c index fe8204d6..01fc9208 100644 --- a/crypto_kem/hqc-128/avx2/code.c +++ b/crypto_kem/hqc-128/avx2/code.c @@ -35,9 +35,9 @@ static inline uint64_t mux(uint64_t a, uint64_t b, int64_t bit) { */ void PQCLEAN_HQC128_AVX2_code_encode(uint64_t *em, const uint64_t *m) { const uint64_t mask[2][2] = {{0x0UL, 0x0UL}, {0x7FFFFFFFUL, 0x3FFFFFFFUL}}; - size_t i, pos_r; + size_t i, j, pos_r; uint64_t bit; - uint64_t idx_r; + uint16_t idx_r; uint64_t select; @@ -71,8 +71,8 @@ void PQCLEAN_HQC128_AVX2_code_encode(uint64_t *em, const uint64_t *m) { /* now we add the message m */ /* systematic encoding */ pos_r = PARAM_N2 * (PARAM_N1 - PARAM_K); - for (int32_t i = 0; i < 4; i++) { - for (int32_t j = 0; j < 64; j++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 64; j++) { bit = (m[i] >> j) & 0x1; diff --git a/crypto_kem/hqc-128/avx2/vector.c b/crypto_kem/hqc-128/avx2/vector.c index 4b66690a..34f8ca41 100644 --- a/crypto_kem/hqc-128/avx2/vector.c +++ b/crypto_kem/hqc-128/avx2/vector.c @@ -36,9 +36,13 @@ void PQCLEAN_HQC128_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 __m256i bit256[PARAM_OMEGA_R]; __m256i bloc256[PARAM_OMEGA_R]; __m256i posCmp256 = _mm256_set_epi64x(3, 2, 1, 0); + __m256i pos256; + __m256i mask256; + __m256i aux; + __m256i i256; uint64_t bloc, pos, bit64; uint8_t inc; - size_t i, j; + size_t i, j, k; i = 0; j = random_bytes_size; @@ -58,7 +62,7 @@ void PQCLEAN_HQC128_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 tmp[i] = tmp[i] % PARAM_N; inc = 1; - for (uint32_t k = 0; k < i; k++) { + for (k = 0; k < i; k++) { if (tmp[k] == tmp[i]) { inc = 0; } @@ -71,19 +75,18 @@ void PQCLEAN_HQC128_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 bloc = tmp[i] >> 6; bloc256[i] = _mm256_set1_epi64x(bloc >> 2); pos = (bloc & 0x3UL); - __m256i pos256 = _mm256_set1_epi64x(pos); - __m256i mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); + pos256 = _mm256_set1_epi64x(pos); + mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); bit64 = 1ULL << (tmp[i] & 0x3f); - __m256i bloc256 = _mm256_set1_epi64x(bit64); - bit256[i] = bloc256 & mask256; + bit256[i] = _mm256_set1_epi64x(bit64)&mask256; } for (i = 0; i < CEIL_DIVIDE(PARAM_N, 256); i++) { - __m256i aux = _mm256_loadu_si256(((__m256i *)v) + i); - __m256i i256 = _mm256_set1_epi64x(i); + aux = _mm256_loadu_si256(((__m256i *)v) + i); + i256 = _mm256_set1_epi64x(i); for (j = 0; j < weight; j++) { - __m256i mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); + mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); aux ^= bit256[j] & mask256; } _mm256_storeu_si256(((__m256i *)v) + i, aux); diff --git a/crypto_kem/hqc-128/clean/Makefile b/crypto_kem/hqc-128/clean/Makefile index a1bbedfc..b31e82ec 100644 --- a/crypto_kem/hqc-128/clean/Makefile +++ b/crypto_kem/hqc-128/clean/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-128_clean.a HEADERS=api.h bch.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h repetition.h vector.h OBJECTS=bch.o code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o repetition.o vector.o -CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wshadow -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-192/META.yml b/crypto_kem/hqc-192/META.yml index e040f063..13b15549 100644 --- a/crypto_kem/hqc-192/META.yml +++ b/crypto_kem/hqc-192/META.yml @@ -22,9 +22,9 @@ principal-submitters: - Loïc Bidoux implementations: - name: clean - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc - name: avx2 - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-192/avx2/Makefile b/crypto_kem/hqc-192/avx2/Makefile index 8e0120ce..2aaa201d 100644 --- a/crypto_kem/hqc-192/avx2/Makefile +++ b/crypto_kem/hqc-192/avx2/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-192_avx2.a HEADERS=alpha_table.h api.h bch.h code.h fft.h gen_matrix.h gf2x.h gf.h hqc.h parameters.h parsing.h repetition.h vector.h OBJECTS=bch.o code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o repetition.o vector.o -CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wshadow -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-192/avx2/bch.c b/crypto_kem/hqc-192/avx2/bch.c index 84edb762..1090cd44 100644 --- a/crypto_kem/hqc-192/avx2/bch.c +++ b/crypto_kem/hqc-192/avx2/bch.c @@ -146,7 +146,7 @@ void compute_syndromes(__m256i *syndromes, const uint64_t *rcv) { __m256i tmp_repeat; uint32_t *aux; int16_t *alpha_tmp; - uint32_t i; + size_t i, j; uint32_t nzflag; // static variable so that it is stored in the DATA segment // not in the STACK segment @@ -167,11 +167,11 @@ void compute_syndromes(__m256i *syndromes, const uint64_t *rcv) { } // Evaluation of the polynomial corresponding to the vector v in alpha^i for i in {1, ..., 2 * PARAM_DELTA} - for (size_t j = 0; j < SYND_SIZE_256; ++j) { + for (j = 0; j < SYND_SIZE_256; ++j) { S = zero_256; alpha_tmp = table_alpha_ij + (j << 4); - for (size_t i = 0; i < PARAM_N1; ++i) { + for (i = 0; i < PARAM_N1; ++i) { nzflag = ((-(int32_t) tmp_array[i]) >> 31) & 1; tmp_repeat = _mm256_set1_epi64x(nzflag); L = _mm256_cmpeq_epi64(tmp_repeat, un_256); diff --git a/crypto_kem/hqc-192/avx2/code.c b/crypto_kem/hqc-192/avx2/code.c index ccc61bdb..8ce6d1e7 100644 --- a/crypto_kem/hqc-192/avx2/code.c +++ b/crypto_kem/hqc-192/avx2/code.c @@ -35,7 +35,7 @@ static inline uint64_t mux(uint64_t a, uint64_t b, int64_t bit) { */ void PQCLEAN_HQC192_AVX2_code_encode(uint64_t *em, const uint64_t *m) { const uint64_t mask[2][2] = {{0x0UL, 0x0UL}, {0x7FFFFFFFFFFFFFFUL, 0x3FFFFFFFFFFFFFFUL}}; - size_t i, pos_r; + size_t i, j, pos_r; uint64_t bit; uint16_t idx_r; uint64_t select; @@ -71,8 +71,8 @@ void PQCLEAN_HQC192_AVX2_code_encode(uint64_t *em, const uint64_t *m) { /* now we add the message m */ /* systematic encoding */ pos_r = PARAM_N2 * (PARAM_N1 - PARAM_K); - for (int32_t i = 0; i < 4; i++) { - for (int32_t j = 0; j < 64; j++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 64; j++) { bit = (m[i] >> j) & 0x1; diff --git a/crypto_kem/hqc-192/avx2/vector.c b/crypto_kem/hqc-192/avx2/vector.c index 53a021e0..698ca3db 100644 --- a/crypto_kem/hqc-192/avx2/vector.c +++ b/crypto_kem/hqc-192/avx2/vector.c @@ -36,9 +36,13 @@ void PQCLEAN_HQC192_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 __m256i bit256[PARAM_OMEGA_R]; __m256i bloc256[PARAM_OMEGA_R]; __m256i posCmp256 = _mm256_set_epi64x(3, 2, 1, 0); + __m256i pos256; + __m256i mask256; + __m256i aux; + __m256i i256; uint64_t bloc, pos, bit64; uint8_t inc; - size_t i, j; + size_t i, j, k; i = 0; j = random_bytes_size; @@ -58,7 +62,7 @@ void PQCLEAN_HQC192_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 tmp[i] = tmp[i] % PARAM_N; inc = 1; - for (uint32_t k = 0; k < i; k++) { + for (k = 0; k < i; k++) { if (tmp[k] == tmp[i]) { inc = 0; } @@ -71,19 +75,18 @@ void PQCLEAN_HQC192_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 bloc = tmp[i] >> 6; bloc256[i] = _mm256_set1_epi64x(bloc >> 2); pos = (bloc & 0x3UL); - __m256i pos256 = _mm256_set1_epi64x(pos); - __m256i mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); + pos256 = _mm256_set1_epi64x(pos); + mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); bit64 = 1ULL << (tmp[i] & 0x3f); - __m256i bloc256 = _mm256_set1_epi64x(bit64); - bit256[i] = bloc256 & mask256; + bit256[i] = _mm256_set1_epi64x(bit64)&mask256; } for (i = 0; i < CEIL_DIVIDE(PARAM_N, 256); i++) { - __m256i aux = _mm256_loadu_si256(((__m256i *)v) + i); - __m256i i256 = _mm256_set1_epi64x(i); + aux = _mm256_loadu_si256(((__m256i *)v) + i); + i256 = _mm256_set1_epi64x(i); for (j = 0; j < weight; j++) { - __m256i mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); + mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); aux ^= bit256[j] & mask256; } _mm256_storeu_si256(((__m256i *)v) + i, aux); diff --git a/crypto_kem/hqc-192/clean/Makefile b/crypto_kem/hqc-192/clean/Makefile index 35c5d36a..375aca08 100644 --- a/crypto_kem/hqc-192/clean/Makefile +++ b/crypto_kem/hqc-192/clean/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-192_clean.a HEADERS=api.h bch.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h repetition.h vector.h OBJECTS=bch.o code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o repetition.o vector.o -CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wshadow -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-256/META.yml b/crypto_kem/hqc-256/META.yml index a9dde214..1c1ce847 100644 --- a/crypto_kem/hqc-256/META.yml +++ b/crypto_kem/hqc-256/META.yml @@ -22,9 +22,9 @@ principal-submitters: - Loïc Bidoux implementations: - name: clean - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc - name: avx2 - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-256/avx2/Makefile b/crypto_kem/hqc-256/avx2/Makefile index 01fd1c07..838c5b91 100644 --- a/crypto_kem/hqc-256/avx2/Makefile +++ b/crypto_kem/hqc-256/avx2/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-256_avx2.a HEADERS=alpha_table.h api.h bch.h code.h fft.h gen_matrix.h gf2x.h gf.h hqc.h parameters.h parsing.h repetition.h vector.h OBJECTS=bch.o code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o repetition.o vector.o -CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wshadow -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-256/avx2/bch.c b/crypto_kem/hqc-256/avx2/bch.c index e6ee3168..2df31250 100644 --- a/crypto_kem/hqc-256/avx2/bch.c +++ b/crypto_kem/hqc-256/avx2/bch.c @@ -146,7 +146,7 @@ void compute_syndromes(__m256i *syndromes, const uint64_t *rcv) { __m256i tmp_repeat; uint32_t *aux; int16_t *alpha_tmp; - uint32_t i; + size_t i, j; uint32_t nzflag; // static variable so that it is stored in the DATA segment // not in the STACK segment @@ -167,11 +167,11 @@ void compute_syndromes(__m256i *syndromes, const uint64_t *rcv) { } // Evaluation of the polynomial corresponding to the vector v in alpha^i for i in {1, ..., 2 * PARAM_DELTA} - for (size_t j = 0; j < SYND_SIZE_256; ++j) { + for (j = 0; j < SYND_SIZE_256; ++j) { S = zero_256; alpha_tmp = table_alpha_ij + (j << 4); - for (size_t i = 0; i < PARAM_N1; ++i) { + for (i = 0; i < PARAM_N1; ++i) { nzflag = ((-(int32_t) tmp_array[i]) >> 31) & 1; tmp_repeat = _mm256_set1_epi64x(nzflag); L = _mm256_cmpeq_epi64(tmp_repeat, un_256); diff --git a/crypto_kem/hqc-256/avx2/code.c b/crypto_kem/hqc-256/avx2/code.c index b5f4a6d7..7f140e0f 100644 --- a/crypto_kem/hqc-256/avx2/code.c +++ b/crypto_kem/hqc-256/avx2/code.c @@ -35,7 +35,7 @@ static inline uint64_t mux(uint64_t a, uint64_t b, int64_t bit) { */ void PQCLEAN_HQC256_AVX2_code_encode(uint64_t *em, const uint64_t *m) { const uint64_t mask[2][3] = {{0x0UL, 0x0UL, 0x0UL}, {0xFFFFFFFFFFFFFFFFUL, 0xFFFFFFFFFFFFFFFFUL, 0x3FFFFFUL}}; - size_t i, pos_r; + size_t i, j, pos_r; uint64_t bit; uint64_t idx_r; uint64_t idx_2; @@ -76,8 +76,8 @@ void PQCLEAN_HQC256_AVX2_code_encode(uint64_t *em, const uint64_t *m) { /* now we add the message m */ /* systematic encoding */ pos_r = PARAM_N2 * (PARAM_N1 - PARAM_K); - for (int32_t i = 0; i < 4; i++) { - for (int32_t j = 0; j < 64; j++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 64; j++) { bit = (m[i] >> j) & 0x1; diff --git a/crypto_kem/hqc-256/avx2/vector.c b/crypto_kem/hqc-256/avx2/vector.c index 610fe47d..a87babc4 100644 --- a/crypto_kem/hqc-256/avx2/vector.c +++ b/crypto_kem/hqc-256/avx2/vector.c @@ -36,9 +36,13 @@ void PQCLEAN_HQC256_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 __m256i bit256[PARAM_OMEGA_R]; __m256i bloc256[PARAM_OMEGA_R]; __m256i posCmp256 = _mm256_set_epi64x(3, 2, 1, 0); + __m256i pos256; + __m256i mask256; + __m256i aux; + __m256i i256; uint64_t bloc, pos, bit64; uint8_t inc; - size_t i, j; + size_t i, j, k; i = 0; j = random_bytes_size; @@ -58,7 +62,7 @@ void PQCLEAN_HQC256_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 tmp[i] = tmp[i] % PARAM_N; inc = 1; - for (uint32_t k = 0; k < i; k++) { + for (k = 0; k < i; k++) { if (tmp[k] == tmp[i]) { inc = 0; } @@ -71,19 +75,18 @@ void PQCLEAN_HQC256_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, uint6 bloc = tmp[i] >> 6; bloc256[i] = _mm256_set1_epi64x(bloc >> 2); pos = (bloc & 0x3UL); - __m256i pos256 = _mm256_set1_epi64x(pos); - __m256i mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); + pos256 = _mm256_set1_epi64x(pos); + mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); bit64 = 1ULL << (tmp[i] & 0x3f); - __m256i bloc256 = _mm256_set1_epi64x(bit64); - bit256[i] = bloc256 & mask256; + bit256[i] = _mm256_set1_epi64x(bit64)&mask256; } for (i = 0; i < CEIL_DIVIDE(PARAM_N, 256); i++) { - __m256i aux = _mm256_loadu_si256(((__m256i *)v) + i); - __m256i i256 = _mm256_set1_epi64x(i); + aux = _mm256_loadu_si256(((__m256i *)v) + i); + i256 = _mm256_set1_epi64x(i); for (j = 0; j < weight; j++) { - __m256i mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); + mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); aux ^= bit256[j] & mask256; } _mm256_storeu_si256(((__m256i *)v) + i, aux); diff --git a/crypto_kem/hqc-256/clean/Makefile b/crypto_kem/hqc-256/clean/Makefile index bd79b1b4..bda7f63a 100644 --- a/crypto_kem/hqc-256/clean/Makefile +++ b/crypto_kem/hqc-256/clean/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-256_clean.a HEADERS=api.h bch.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h repetition.h vector.h OBJECTS=bch.o code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o repetition.o vector.o -CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wshadow -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-rmrs-128/META.yml b/crypto_kem/hqc-rmrs-128/META.yml index 1f77976f..14cab136 100644 --- a/crypto_kem/hqc-rmrs-128/META.yml +++ b/crypto_kem/hqc-rmrs-128/META.yml @@ -22,9 +22,9 @@ principal-submitters: - Loïc Bidoux implementations: - name: clean - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc - name: avx2 - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-rmrs-128/avx2/Makefile b/crypto_kem/hqc-rmrs-128/avx2/Makefile index 35e0362c..1567079d 100644 --- a/crypto_kem/hqc-rmrs-128/avx2/Makefile +++ b/crypto_kem/hqc-rmrs-128/avx2/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-rmrs-128_avx2.a HEADERS=api.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h reed_muller.h reed_solomon.h vector.h OBJECTS=code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o reed_muller.o reed_solomon.o vector.o -CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wshadow -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-rmrs-128/avx2/vector.c b/crypto_kem/hqc-rmrs-128/avx2/vector.c index 0ac5069e..1fe644ec 100644 --- a/crypto_kem/hqc-rmrs-128/avx2/vector.c +++ b/crypto_kem/hqc-rmrs-128/avx2/vector.c @@ -36,9 +36,13 @@ void PQCLEAN_HQCRMRS128_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u __m256i bit256[PARAM_OMEGA_R]; __m256i bloc256[PARAM_OMEGA_R]; __m256i posCmp256 = _mm256_set_epi64x(3, 2, 1, 0); + __m256i pos256; + __m256i mask256; + __m256i aux; + __m256i i256; uint64_t bloc, pos, bit64; uint8_t inc; - size_t i, j; + size_t i, j, k; i = 0; j = random_bytes_size; @@ -58,7 +62,7 @@ void PQCLEAN_HQCRMRS128_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u tmp[i] = tmp[i] % PARAM_N; inc = 1; - for (uint32_t k = 0; k < i; k++) { + for (k = 0; k < i; k++) { if (tmp[k] == tmp[i]) { inc = 0; } @@ -71,19 +75,18 @@ void PQCLEAN_HQCRMRS128_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u bloc = tmp[i] >> 6; bloc256[i] = _mm256_set1_epi64x(bloc >> 2); pos = (bloc & 0x3UL); - __m256i pos256 = _mm256_set1_epi64x(pos); - __m256i mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); + pos256 = _mm256_set1_epi64x(pos); + mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); bit64 = 1ULL << (tmp[i] & 0x3f); - __m256i bloc256 = _mm256_set1_epi64x(bit64); - bit256[i] = bloc256 & mask256; + bit256[i] = _mm256_set1_epi64x(bit64)&mask256; } for (i = 0; i < CEIL_DIVIDE(PARAM_N, 256); i++) { - __m256i aux = _mm256_loadu_si256(((__m256i *)v) + i); - __m256i i256 = _mm256_set1_epi64x(i); + aux = _mm256_loadu_si256(((__m256i *)v) + i); + i256 = _mm256_set1_epi64x(i); for (j = 0; j < weight; j++) { - __m256i mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); + mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); aux ^= bit256[j] & mask256; } _mm256_storeu_si256(((__m256i *)v) + i, aux); @@ -148,7 +151,6 @@ uint8_t PQCLEAN_HQCRMRS128_AVX2_vect_compare(const uint8_t *v1, const uint8_t *v - /** * @brief Resize a vector so that it contains size_o bits * diff --git a/crypto_kem/hqc-rmrs-128/clean/Makefile b/crypto_kem/hqc-rmrs-128/clean/Makefile index b11c576a..5a8b0602 100644 --- a/crypto_kem/hqc-rmrs-128/clean/Makefile +++ b/crypto_kem/hqc-rmrs-128/clean/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-rmrs-128_clean.a HEADERS=api.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h reed_muller.h reed_solomon.h vector.h OBJECTS=code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o reed_muller.o reed_solomon.o vector.o -CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wshadow -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-rmrs-192/META.yml b/crypto_kem/hqc-rmrs-192/META.yml index 43b7c6a0..04239e77 100644 --- a/crypto_kem/hqc-rmrs-192/META.yml +++ b/crypto_kem/hqc-rmrs-192/META.yml @@ -22,9 +22,9 @@ principal-submitters: - Loïc Bidoux implementations: - name: clean - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc - name: avx2 - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-rmrs-192/avx2/Makefile b/crypto_kem/hqc-rmrs-192/avx2/Makefile index 4199cc73..5c78714e 100644 --- a/crypto_kem/hqc-rmrs-192/avx2/Makefile +++ b/crypto_kem/hqc-rmrs-192/avx2/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-rmrs-192_avx2.a HEADERS=api.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h reed_muller.h reed_solomon.h vector.h OBJECTS=code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o reed_muller.o reed_solomon.o vector.o -CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wshadow -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-rmrs-192/avx2/vector.c b/crypto_kem/hqc-rmrs-192/avx2/vector.c index 51d444ae..3f58b19c 100644 --- a/crypto_kem/hqc-rmrs-192/avx2/vector.c +++ b/crypto_kem/hqc-rmrs-192/avx2/vector.c @@ -36,9 +36,13 @@ void PQCLEAN_HQCRMRS192_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u __m256i bit256[PARAM_OMEGA_R]; __m256i bloc256[PARAM_OMEGA_R]; __m256i posCmp256 = _mm256_set_epi64x(3, 2, 1, 0); + __m256i pos256; + __m256i mask256; + __m256i aux; + __m256i i256; uint64_t bloc, pos, bit64; uint8_t inc; - size_t i, j; + size_t i, j, k; i = 0; j = random_bytes_size; @@ -58,7 +62,7 @@ void PQCLEAN_HQCRMRS192_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u tmp[i] = tmp[i] % PARAM_N; inc = 1; - for (uint32_t k = 0; k < i; k++) { + for (k = 0; k < i; k++) { if (tmp[k] == tmp[i]) { inc = 0; } @@ -71,19 +75,18 @@ void PQCLEAN_HQCRMRS192_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u bloc = tmp[i] >> 6; bloc256[i] = _mm256_set1_epi64x(bloc >> 2); pos = (bloc & 0x3UL); - __m256i pos256 = _mm256_set1_epi64x(pos); - __m256i mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); + pos256 = _mm256_set1_epi64x(pos); + mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); bit64 = 1ULL << (tmp[i] & 0x3f); - __m256i bloc256 = _mm256_set1_epi64x(bit64); - bit256[i] = bloc256 & mask256; + bit256[i] = _mm256_set1_epi64x(bit64)&mask256; } for (i = 0; i < CEIL_DIVIDE(PARAM_N, 256); i++) { - __m256i aux = _mm256_loadu_si256(((__m256i *)v) + i); - __m256i i256 = _mm256_set1_epi64x(i); + aux = _mm256_loadu_si256(((__m256i *)v) + i); + i256 = _mm256_set1_epi64x(i); for (j = 0; j < weight; j++) { - __m256i mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); + mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); aux ^= bit256[j] & mask256; } _mm256_storeu_si256(((__m256i *)v) + i, aux); @@ -148,7 +151,6 @@ uint8_t PQCLEAN_HQCRMRS192_AVX2_vect_compare(const uint8_t *v1, const uint8_t *v - /** * @brief Resize a vector so that it contains size_o bits * diff --git a/crypto_kem/hqc-rmrs-192/clean/Makefile b/crypto_kem/hqc-rmrs-192/clean/Makefile index 1f29ed17..79173db0 100644 --- a/crypto_kem/hqc-rmrs-192/clean/Makefile +++ b/crypto_kem/hqc-rmrs-192/clean/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-rmrs-192_clean.a HEADERS=api.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h reed_muller.h reed_solomon.h vector.h OBJECTS=code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o reed_muller.o reed_solomon.o vector.o -CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wshadow -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-rmrs-256/META.yml b/crypto_kem/hqc-rmrs-256/META.yml index 1581efa7..ee566c73 100644 --- a/crypto_kem/hqc-rmrs-256/META.yml +++ b/crypto_kem/hqc-rmrs-256/META.yml @@ -22,9 +22,9 @@ principal-submitters: - Loïc Bidoux implementations: - name: clean - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc - name: avx2 - version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/22134db4/hqc + version: hqc-submission_2020-05-29 via https://github.com/jschanck/package-pqclean/tree/09ab89ed/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-rmrs-256/avx2/Makefile b/crypto_kem/hqc-rmrs-256/avx2/Makefile index 156263ce..deefabd7 100644 --- a/crypto_kem/hqc-rmrs-256/avx2/Makefile +++ b/crypto_kem/hqc-rmrs-256/avx2/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-rmrs-256_avx2.a HEADERS=api.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h reed_muller.h reed_solomon.h vector.h OBJECTS=code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o reed_muller.o reed_solomon.o vector.o -CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -mavx2 -mbmi -mpclmul -Wall -Wextra -Wshadow -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB) diff --git a/crypto_kem/hqc-rmrs-256/avx2/vector.c b/crypto_kem/hqc-rmrs-256/avx2/vector.c index 1d4546ca..83f0e06b 100644 --- a/crypto_kem/hqc-rmrs-256/avx2/vector.c +++ b/crypto_kem/hqc-rmrs-256/avx2/vector.c @@ -36,9 +36,13 @@ void PQCLEAN_HQCRMRS256_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u __m256i bit256[PARAM_OMEGA_R]; __m256i bloc256[PARAM_OMEGA_R]; __m256i posCmp256 = _mm256_set_epi64x(3, 2, 1, 0); + __m256i pos256; + __m256i mask256; + __m256i aux; + __m256i i256; uint64_t bloc, pos, bit64; uint8_t inc; - size_t i, j; + size_t i, j, k; i = 0; j = random_bytes_size; @@ -58,7 +62,7 @@ void PQCLEAN_HQCRMRS256_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u tmp[i] = tmp[i] % PARAM_N; inc = 1; - for (uint32_t k = 0; k < i; k++) { + for (k = 0; k < i; k++) { if (tmp[k] == tmp[i]) { inc = 0; } @@ -71,19 +75,18 @@ void PQCLEAN_HQCRMRS256_AVX2_vect_set_random_fixed_weight(AES_XOF_struct *ctx, u bloc = tmp[i] >> 6; bloc256[i] = _mm256_set1_epi64x(bloc >> 2); pos = (bloc & 0x3UL); - __m256i pos256 = _mm256_set1_epi64x(pos); - __m256i mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); + pos256 = _mm256_set1_epi64x(pos); + mask256 = _mm256_cmpeq_epi64(pos256, posCmp256); bit64 = 1ULL << (tmp[i] & 0x3f); - __m256i bloc256 = _mm256_set1_epi64x(bit64); - bit256[i] = bloc256 & mask256; + bit256[i] = _mm256_set1_epi64x(bit64)&mask256; } for (i = 0; i < CEIL_DIVIDE(PARAM_N, 256); i++) { - __m256i aux = _mm256_loadu_si256(((__m256i *)v) + i); - __m256i i256 = _mm256_set1_epi64x(i); + aux = _mm256_loadu_si256(((__m256i *)v) + i); + i256 = _mm256_set1_epi64x(i); for (j = 0; j < weight; j++) { - __m256i mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); + mask256 = _mm256_cmpeq_epi64(bloc256[j], i256); aux ^= bit256[j] & mask256; } _mm256_storeu_si256(((__m256i *)v) + i, aux); @@ -148,7 +151,6 @@ uint8_t PQCLEAN_HQCRMRS256_AVX2_vect_compare(const uint8_t *v1, const uint8_t *v - /** * @brief Resize a vector so that it contains size_o bits * diff --git a/crypto_kem/hqc-rmrs-256/clean/Makefile b/crypto_kem/hqc-rmrs-256/clean/Makefile index ee19437b..1454fec5 100644 --- a/crypto_kem/hqc-rmrs-256/clean/Makefile +++ b/crypto_kem/hqc-rmrs-256/clean/Makefile @@ -4,7 +4,7 @@ LIB=libhqc-rmrs-256_clean.a HEADERS=api.h code.h fft.h gf2x.h gf.h hqc.h parameters.h parsing.h reed_muller.h reed_solomon.h vector.h OBJECTS=code.o fft.o gf2x.o gf.o hqc.o kem.o parsing.o reed_muller.o reed_solomon.o vector.o -CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) +CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wshadow -Wvla -Werror -Wredundant-decls -Wmissing-prototypes -std=c99 -I../../../common $(EXTRAFLAGS) all: $(LIB)