From 82fdce64a2e8c9b6688d4b5f0f0f1ec235c3ad82 Mon Sep 17 00:00:00 2001 From: Douglas Stebila Date: Sat, 18 May 2019 11:27:45 +0200 Subject: [PATCH] Macro for loop length --- crypto_kem/newhope1024cca/clean/poly.c | 2 +- crypto_kem/newhope1024cpa/clean/poly.c | 2 +- crypto_kem/newhope512cca/clean/poly.c | 2 +- crypto_kem/newhope512cpa/clean/poly.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crypto_kem/newhope1024cca/clean/poly.c b/crypto_kem/newhope1024cca/clean/poly.c index 94422dcf..2ede9dea 100644 --- a/crypto_kem/newhope1024cca/clean/poly.c +++ b/crypto_kem/newhope1024cca/clean/poly.c @@ -151,7 +151,7 @@ void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_decompress(poly *r, const unsigned char * **************************************************/ void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_frommsg(poly *r, const unsigned char *msg) { unsigned int i, j, mask; - for (i = 0; i < 32; i++) { // XXX: MACRO for 32 + for (i = 0; i < NEWHOPE_SYMBYTES; i++) { for (j = 0; j < 8; j++) { mask = -((msg[i] >> j) & 1); r->coeffs[8 * i + j + 0] = mask & (NEWHOPE_Q / 2); diff --git a/crypto_kem/newhope1024cpa/clean/poly.c b/crypto_kem/newhope1024cpa/clean/poly.c index 772fa5a7..5ab00927 100644 --- a/crypto_kem/newhope1024cpa/clean/poly.c +++ b/crypto_kem/newhope1024cpa/clean/poly.c @@ -151,7 +151,7 @@ void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_decompress(poly *r, const unsigned char * **************************************************/ void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_frommsg(poly *r, const unsigned char *msg) { unsigned int i, j, mask; - for (i = 0; i < 32; i++) { // XXX: MACRO for 32 + for (i = 0; i < NEWHOPE_SYMBYTES; i++) { for (j = 0; j < 8; j++) { mask = -((msg[i] >> j) & 1); r->coeffs[8 * i + j + 0] = mask & (NEWHOPE_Q / 2); diff --git a/crypto_kem/newhope512cca/clean/poly.c b/crypto_kem/newhope512cca/clean/poly.c index 7998c417..b8075df5 100644 --- a/crypto_kem/newhope512cca/clean/poly.c +++ b/crypto_kem/newhope512cca/clean/poly.c @@ -151,7 +151,7 @@ void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_decompress(poly *r, const unsigned char *a **************************************************/ void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_frommsg(poly *r, const unsigned char *msg) { unsigned int i, j, mask; - for (i = 0; i < 32; i++) { // XXX: MACRO for 32 + for (i = 0; i < NEWHOPE_SYMBYTES; i++) { for (j = 0; j < 8; j++) { mask = -((msg[i] >> j) & 1); r->coeffs[8 * i + j + 0] = mask & (NEWHOPE_Q / 2); diff --git a/crypto_kem/newhope512cpa/clean/poly.c b/crypto_kem/newhope512cpa/clean/poly.c index 720d8e4f..364c7af6 100644 --- a/crypto_kem/newhope512cpa/clean/poly.c +++ b/crypto_kem/newhope512cpa/clean/poly.c @@ -151,7 +151,7 @@ void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_decompress(poly *r, const unsigned char *a **************************************************/ void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_frommsg(poly *r, const unsigned char *msg) { unsigned int i, j, mask; - for (i = 0; i < 32; i++) { // XXX: MACRO for 32 + for (i = 0; i < NEWHOPE_SYMBYTES; i++) { for (j = 0; j < 8; j++) { mask = -((msg[i] >> j) & 1); r->coeffs[8 * i + j + 0] = mask & (NEWHOPE_Q / 2);