From 1113fdce69cbe360f2f0f0627c84866048d52675 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Sun, 25 Oct 2020 22:35:59 -0400 Subject: [PATCH] HQC: remove bitmask macro --- crypto_kem/hqc-rmrs-128/META.yml | 4 ++-- crypto_kem/hqc-rmrs-128/avx2/parameters.h | 3 +-- crypto_kem/hqc-rmrs-128/avx2/vector.c | 2 +- crypto_kem/hqc-rmrs-128/clean/parameters.h | 3 +-- crypto_kem/hqc-rmrs-192/META.yml | 4 ++-- crypto_kem/hqc-rmrs-192/avx2/parameters.h | 3 +-- crypto_kem/hqc-rmrs-192/clean/parameters.h | 3 +-- crypto_kem/hqc-rmrs-256/META.yml | 4 ++-- crypto_kem/hqc-rmrs-256/avx2/parameters.h | 3 +-- crypto_kem/hqc-rmrs-256/clean/parameters.h | 3 +-- test/duplicate_consistency/hqc-rmrs-128_avx2.yml | 2 ++ 11 files changed, 15 insertions(+), 19 deletions(-) diff --git a/crypto_kem/hqc-rmrs-128/META.yml b/crypto_kem/hqc-rmrs-128/META.yml index 012c333d..2aa72230 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-10-01 via https://github.com/jschanck/package-pqclean/tree/196a2f2f/hqc + version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/4924a647/hqc - name: avx2 - version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/196a2f2f/hqc + version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/4924a647/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-rmrs-128/avx2/parameters.h b/crypto_kem/hqc-rmrs-128/avx2/parameters.h index ced2018b..ee9efd25 100644 --- a/crypto_kem/hqc-rmrs-128/avx2/parameters.h +++ b/crypto_kem/hqc-rmrs-128/avx2/parameters.h @@ -103,8 +103,7 @@ #define PARAM_FFT 5 #define RS_POLY_COEFS 89,69,153,116,176,117,111,75,73,233,242,233,65,210,21,139,103,173,67,118,105,210,174,110,74,69,228,82,255,181,1 -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) -#define RED_MASK BITMASK(PARAM_N, 64) +#define RED_MASK 0x1f #define SHA512_BYTES 64 #define SEED_BYTES 40 #define SEEDEXPANDER_MAX_LENGTH 4294967295 diff --git a/crypto_kem/hqc-rmrs-128/avx2/vector.c b/crypto_kem/hqc-rmrs-128/avx2/vector.c index 0ac8da49..1fe644ec 100644 --- a/crypto_kem/hqc-rmrs-128/avx2/vector.c +++ b/crypto_kem/hqc-rmrs-128/avx2/vector.c @@ -111,7 +111,7 @@ void PQCLEAN_HQCRMRS128_AVX2_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); PQCLEAN_HQCRMRS128_AVX2_load8_arr(v, VEC_N_SIZE_64, rand_bytes, VEC_N_SIZE_BYTES); - v[VEC_N_SIZE_64 - 1] &= BITMASK(PARAM_N, 64); + v[VEC_N_SIZE_64 - 1] &= RED_MASK; } diff --git a/crypto_kem/hqc-rmrs-128/clean/parameters.h b/crypto_kem/hqc-rmrs-128/clean/parameters.h index 00f99bdd..2ecb16d1 100644 --- a/crypto_kem/hqc-rmrs-128/clean/parameters.h +++ b/crypto_kem/hqc-rmrs-128/clean/parameters.h @@ -90,8 +90,7 @@ #define PARAM_FFT 5 #define RS_POLY_COEFS 89,69,153,116,176,117,111,75,73,233,242,233,65,210,21,139,103,173,67,118,105,210,174,110,74,69,228,82,255,181,1 -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) -#define RED_MASK BITMASK(PARAM_N, 64) +#define RED_MASK 0x1f #define SHA512_BYTES 64 #define SEED_BYTES 40 #define SEEDEXPANDER_MAX_LENGTH 4294967295 diff --git a/crypto_kem/hqc-rmrs-192/META.yml b/crypto_kem/hqc-rmrs-192/META.yml index ea2964ac..d03d18e8 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-10-01 via https://github.com/jschanck/package-pqclean/tree/196a2f2f/hqc + version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/4924a647/hqc - name: avx2 - version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/196a2f2f/hqc + version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/4924a647/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-rmrs-192/avx2/parameters.h b/crypto_kem/hqc-rmrs-192/avx2/parameters.h index 51d6076a..c893b7b7 100644 --- a/crypto_kem/hqc-rmrs-192/avx2/parameters.h +++ b/crypto_kem/hqc-rmrs-192/avx2/parameters.h @@ -101,8 +101,7 @@ #define PARAM_FFT 5 #define RS_POLY_COEFS 45,216,239,24,253,104,27,40,107,50,163,210,227,134,224,158,119,13,158,1,238,164,82,43,15,232,246,142,50,189,29,232,1 -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) -#define RED_MASK BITMASK(PARAM_N, 64) +#define RED_MASK 0x7ff #define SHA512_BYTES 64 #define SEED_BYTES 40 #define SEEDEXPANDER_MAX_LENGTH 4294967295 diff --git a/crypto_kem/hqc-rmrs-192/clean/parameters.h b/crypto_kem/hqc-rmrs-192/clean/parameters.h index 137d7498..e47f86eb 100644 --- a/crypto_kem/hqc-rmrs-192/clean/parameters.h +++ b/crypto_kem/hqc-rmrs-192/clean/parameters.h @@ -90,8 +90,7 @@ #define PARAM_FFT 5 #define RS_POLY_COEFS 45,216,239,24,253,104,27,40,107,50,163,210,227,134,224,158,119,13,158,1,238,164,82,43,15,232,246,142,50,189,29,232,1 -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) -#define RED_MASK BITMASK(PARAM_N, 64) +#define RED_MASK 0x7ff #define SHA512_BYTES 64 #define SEED_BYTES 40 #define SEEDEXPANDER_MAX_LENGTH 4294967295 diff --git a/crypto_kem/hqc-rmrs-256/META.yml b/crypto_kem/hqc-rmrs-256/META.yml index 2dddd708..df72e6e1 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-10-01 via https://github.com/jschanck/package-pqclean/tree/196a2f2f/hqc + version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/4924a647/hqc - name: avx2 - version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/196a2f2f/hqc + version: hqc-submission_2020-10-01 via https://github.com/jschanck/package-pqclean/tree/4924a647/hqc supported_platforms: - architecture: x86_64 operating_systems: diff --git a/crypto_kem/hqc-rmrs-256/avx2/parameters.h b/crypto_kem/hqc-rmrs-256/avx2/parameters.h index aa2d4537..5c61888b 100644 --- a/crypto_kem/hqc-rmrs-256/avx2/parameters.h +++ b/crypto_kem/hqc-rmrs-256/avx2/parameters.h @@ -101,8 +101,7 @@ #define PARAM_FFT 5 #define RS_POLY_COEFS 49,167,49,39,200,121,124,91,240,63,148,71,150,123,87,101,32,215,159,71,201,115,97,210,186,183,141,217,123,12,31,243,180,219,152,239,99,141,4,246,191,144,8,232,47,27,141,178,130,64,124,47,39,188,216,48,199,187,1 -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) -#define RED_MASK BITMASK(PARAM_N, 64) +#define RED_MASK 0x1fffffffff #define SHA512_BYTES 64 #define SEED_BYTES 40 #define SEEDEXPANDER_MAX_LENGTH 4294967295 diff --git a/crypto_kem/hqc-rmrs-256/clean/parameters.h b/crypto_kem/hqc-rmrs-256/clean/parameters.h index 29beb895..69d0f17c 100644 --- a/crypto_kem/hqc-rmrs-256/clean/parameters.h +++ b/crypto_kem/hqc-rmrs-256/clean/parameters.h @@ -90,8 +90,7 @@ #define PARAM_FFT 5 #define RS_POLY_COEFS 49,167,49,39,200,121,124,91,240,63,148,71,150,123,87,101,32,215,159,71,201,115,97,210,186,183,141,217,123,12,31,243,180,219,152,239,99,141,4,246,191,144,8,232,47,27,141,178,130,64,124,47,39,188,216,48,199,187,1 -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) -#define RED_MASK BITMASK(PARAM_N, 64) +#define RED_MASK 0x1fffffffff #define SHA512_BYTES 64 #define SEED_BYTES 40 #define SEEDEXPANDER_MAX_LENGTH 4294967295 diff --git a/test/duplicate_consistency/hqc-rmrs-128_avx2.yml b/test/duplicate_consistency/hqc-rmrs-128_avx2.yml index 1ea16bef..9fa2db91 100644 --- a/test/duplicate_consistency/hqc-rmrs-128_avx2.yml +++ b/test/duplicate_consistency/hqc-rmrs-128_avx2.yml @@ -37,6 +37,7 @@ consistency_checks: - kem.c - parsing.c - reed_muller.c + - vector.c - source: scheme: hqc-rmrs-256 implementation: clean @@ -65,3 +66,4 @@ consistency_checks: - kem.c - parsing.c - reed_muller.c + - vector.c