From 6cf952a2ce05018a2dede367a47986c63c9175d6 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Wed, 9 Sep 2020 16:52:51 -0400 Subject: [PATCH] Remove BITMASK macro --- crypto_kem/hqc-128/avx2/parameters.h | 3 +-- crypto_kem/hqc-128/avx2/vector.c | 2 +- crypto_kem/hqc-128/clean/parameters.h | 3 +-- crypto_kem/hqc-128/clean/vector.c | 2 +- crypto_kem/hqc-192/avx2/parameters.h | 3 +-- crypto_kem/hqc-192/avx2/vector.c | 2 +- crypto_kem/hqc-192/clean/parameters.h | 3 +-- crypto_kem/hqc-192/clean/vector.c | 2 +- crypto_kem/hqc-256/avx2/parameters.h | 3 +-- crypto_kem/hqc-256/avx2/vector.c | 2 +- crypto_kem/hqc-256/clean/parameters.h | 3 +-- crypto_kem/hqc-256/clean/vector.c | 2 +- crypto_kem/hqc-rmrs-128/avx2/parameters.h | 4 +--- crypto_kem/hqc-rmrs-128/avx2/vector.c | 2 +- crypto_kem/hqc-rmrs-128/clean/parameters.h | 4 +--- crypto_kem/hqc-rmrs-128/clean/vector.c | 2 +- crypto_kem/hqc-rmrs-192/avx2/parameters.h | 4 +--- crypto_kem/hqc-rmrs-192/avx2/vector.c | 2 +- crypto_kem/hqc-rmrs-192/clean/parameters.h | 4 +--- crypto_kem/hqc-rmrs-192/clean/vector.c | 2 +- crypto_kem/hqc-rmrs-256/avx2/parameters.h | 4 +--- crypto_kem/hqc-rmrs-256/avx2/vector.c | 2 +- crypto_kem/hqc-rmrs-256/clean/parameters.h | 4 +--- crypto_kem/hqc-rmrs-256/clean/vector.c | 2 +- 24 files changed, 24 insertions(+), 42 deletions(-) diff --git a/crypto_kem/hqc-128/avx2/parameters.h b/crypto_kem/hqc-128/avx2/parameters.h index c222237b..14768d8d 100644 --- a/crypto_kem/hqc-128/avx2/parameters.h +++ b/crypto_kem/hqc-128/avx2/parameters.h @@ -10,8 +10,7 @@ #include "vector.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-128/avx2/vector.c b/crypto_kem/hqc-128/avx2/vector.c index 6ba48234..0a100b7a 100644 --- a/crypto_kem/hqc-128/avx2/vector.c +++ b/crypto_kem/hqc-128/avx2/vector.c @@ -116,7 +116,7 @@ void PQCLEAN_HQC128_AVX2_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-128/clean/parameters.h b/crypto_kem/hqc-128/clean/parameters.h index ec26b193..efa9045c 100644 --- a/crypto_kem/hqc-128/clean/parameters.h +++ b/crypto_kem/hqc-128/clean/parameters.h @@ -10,8 +10,7 @@ #include "vector.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-128/clean/vector.c b/crypto_kem/hqc-128/clean/vector.c index 4984f8b5..1079bc16 100644 --- a/crypto_kem/hqc-128/clean/vector.c +++ b/crypto_kem/hqc-128/clean/vector.c @@ -148,7 +148,7 @@ void PQCLEAN_HQC128_CLEAN_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-192/avx2/parameters.h b/crypto_kem/hqc-192/avx2/parameters.h index 2e9656fd..99643ff6 100644 --- a/crypto_kem/hqc-192/avx2/parameters.h +++ b/crypto_kem/hqc-192/avx2/parameters.h @@ -10,8 +10,7 @@ #include "vector.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-192/avx2/vector.c b/crypto_kem/hqc-192/avx2/vector.c index 40149c42..f5f79a87 100644 --- a/crypto_kem/hqc-192/avx2/vector.c +++ b/crypto_kem/hqc-192/avx2/vector.c @@ -116,7 +116,7 @@ void PQCLEAN_HQC192_AVX2_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-192/clean/parameters.h b/crypto_kem/hqc-192/clean/parameters.h index 76d98d6b..af336033 100644 --- a/crypto_kem/hqc-192/clean/parameters.h +++ b/crypto_kem/hqc-192/clean/parameters.h @@ -10,8 +10,7 @@ #include "vector.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-192/clean/vector.c b/crypto_kem/hqc-192/clean/vector.c index add1f3ac..8cf72e12 100644 --- a/crypto_kem/hqc-192/clean/vector.c +++ b/crypto_kem/hqc-192/clean/vector.c @@ -148,7 +148,7 @@ void PQCLEAN_HQC192_CLEAN_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-256/avx2/parameters.h b/crypto_kem/hqc-256/avx2/parameters.h index ce4398e2..5ec18b53 100644 --- a/crypto_kem/hqc-256/avx2/parameters.h +++ b/crypto_kem/hqc-256/avx2/parameters.h @@ -10,8 +10,7 @@ #include "vector.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-256/avx2/vector.c b/crypto_kem/hqc-256/avx2/vector.c index bc9a065d..d5740714 100644 --- a/crypto_kem/hqc-256/avx2/vector.c +++ b/crypto_kem/hqc-256/avx2/vector.c @@ -116,7 +116,7 @@ void PQCLEAN_HQC256_AVX2_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-256/clean/parameters.h b/crypto_kem/hqc-256/clean/parameters.h index 57ea9a46..cfd09cd1 100644 --- a/crypto_kem/hqc-256/clean/parameters.h +++ b/crypto_kem/hqc-256/clean/parameters.h @@ -10,8 +10,7 @@ #include "vector.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-256/clean/vector.c b/crypto_kem/hqc-256/clean/vector.c index 3b3c5f8a..2aa4ffcf 100644 --- a/crypto_kem/hqc-256/clean/vector.c +++ b/crypto_kem/hqc-256/clean/vector.c @@ -148,7 +148,7 @@ void PQCLEAN_HQC256_CLEAN_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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/avx2/parameters.h b/crypto_kem/hqc-rmrs-128/avx2/parameters.h index ab9c1488..31380e1a 100644 --- a/crypto_kem/hqc-rmrs-128/avx2/parameters.h +++ b/crypto_kem/hqc-rmrs-128/avx2/parameters.h @@ -11,9 +11,7 @@ #include "api.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ - +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-rmrs-128/avx2/vector.c b/crypto_kem/hqc-rmrs-128/avx2/vector.c index ff97279d..86a97259 100644 --- a/crypto_kem/hqc-rmrs-128/avx2/vector.c +++ b/crypto_kem/hqc-rmrs-128/avx2/vector.c @@ -116,7 +116,7 @@ void PQCLEAN_HQCRMRS128_AVX2_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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 0aa2be8e..c78a6c9b 100644 --- a/crypto_kem/hqc-rmrs-128/clean/parameters.h +++ b/crypto_kem/hqc-rmrs-128/clean/parameters.h @@ -11,9 +11,7 @@ #include "api.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ - +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-rmrs-128/clean/vector.c b/crypto_kem/hqc-rmrs-128/clean/vector.c index c3927fd5..018d0545 100644 --- a/crypto_kem/hqc-rmrs-128/clean/vector.c +++ b/crypto_kem/hqc-rmrs-128/clean/vector.c @@ -148,7 +148,7 @@ void PQCLEAN_HQCRMRS128_CLEAN_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-192/avx2/parameters.h b/crypto_kem/hqc-rmrs-192/avx2/parameters.h index d8422a66..7c55d7fd 100644 --- a/crypto_kem/hqc-rmrs-192/avx2/parameters.h +++ b/crypto_kem/hqc-rmrs-192/avx2/parameters.h @@ -11,9 +11,7 @@ #include "api.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ - +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-rmrs-192/avx2/vector.c b/crypto_kem/hqc-rmrs-192/avx2/vector.c index b82b92c4..754c6503 100644 --- a/crypto_kem/hqc-rmrs-192/avx2/vector.c +++ b/crypto_kem/hqc-rmrs-192/avx2/vector.c @@ -116,7 +116,7 @@ void PQCLEAN_HQCRMRS192_AVX2_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-192/clean/parameters.h b/crypto_kem/hqc-rmrs-192/clean/parameters.h index a417245e..a984510d 100644 --- a/crypto_kem/hqc-rmrs-192/clean/parameters.h +++ b/crypto_kem/hqc-rmrs-192/clean/parameters.h @@ -11,9 +11,7 @@ #include "api.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ - +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-rmrs-192/clean/vector.c b/crypto_kem/hqc-rmrs-192/clean/vector.c index 05db4963..d6f02e2a 100644 --- a/crypto_kem/hqc-rmrs-192/clean/vector.c +++ b/crypto_kem/hqc-rmrs-192/clean/vector.c @@ -148,7 +148,7 @@ void PQCLEAN_HQCRMRS192_CLEAN_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-256/avx2/parameters.h b/crypto_kem/hqc-rmrs-256/avx2/parameters.h index 3f4a6085..3ff20c34 100644 --- a/crypto_kem/hqc-rmrs-256/avx2/parameters.h +++ b/crypto_kem/hqc-rmrs-256/avx2/parameters.h @@ -11,9 +11,7 @@ #include "api.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ - +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-rmrs-256/avx2/vector.c b/crypto_kem/hqc-rmrs-256/avx2/vector.c index 75c251c5..c2fc9f9d 100644 --- a/crypto_kem/hqc-rmrs-256/avx2/vector.c +++ b/crypto_kem/hqc-rmrs-256/avx2/vector.c @@ -116,7 +116,7 @@ void PQCLEAN_HQCRMRS256_AVX2_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) { seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, 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-256/clean/parameters.h b/crypto_kem/hqc-rmrs-256/clean/parameters.h index 4732b419..99576b13 100644 --- a/crypto_kem/hqc-rmrs-256/clean/parameters.h +++ b/crypto_kem/hqc-rmrs-256/clean/parameters.h @@ -11,9 +11,7 @@ #include "api.h" -#define CEIL_DIVIDE(a, b) (((a)/(b)) + ((a) % (b) == 0 ? 0 : 1)) /*!< Divide a by b and ceil the result*/ -#define BITMASK(a, size) ((1UL << ((a) % (size))) - 1) /*!< Create a mask*/ - +#define CEIL_DIVIDE(a, b) (((a)+(b)-1)/(b)) /*!< Divide a by b and ceil the result*/ /* #define PARAM_N Define the parameter n of the scheme diff --git a/crypto_kem/hqc-rmrs-256/clean/vector.c b/crypto_kem/hqc-rmrs-256/clean/vector.c index 94ee03f3..11688269 100644 --- a/crypto_kem/hqc-rmrs-256/clean/vector.c +++ b/crypto_kem/hqc-rmrs-256/clean/vector.c @@ -148,7 +148,7 @@ void PQCLEAN_HQCRMRS256_CLEAN_vect_set_random(AES_XOF_struct *ctx, uint64_t *v) seedexpander(ctx, rand_bytes, VEC_N_SIZE_BYTES); memcpy(v, rand_bytes, VEC_N_SIZE_BYTES); - v[VEC_N_SIZE_64 - 1] &= BITMASK(PARAM_N, 64); + v[VEC_N_SIZE_64 - 1] &= RED_MASK; }