Don't define N in hrss/internal.h
This was only working because internal.h was being included last.
Change-Id: I927bb87ebb2161d554b5ae45a0f1028b2c1981e7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78907
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
diff --git a/crypto/hrss/hrss.cc b/crypto/hrss/hrss.cc
index e035ff5..81807c2 100644
--- a/crypto/hrss/hrss.cc
+++ b/crypto/hrss/hrss.cc
@@ -275,7 +275,7 @@
#endif // (ARM || AARCH64) && NEON
// Polynomials in this scheme have N terms.
-// #define N 701
+#define N HRSS_N
// Underlying data types and arithmetic operations.
// ------------------------------------------------
diff --git a/crypto/hrss/hrss_test.cc b/crypto/hrss/hrss_test.cc
index d921dc2..fd67e45 100644
--- a/crypto/hrss/hrss_test.cc
+++ b/crypto/hrss/hrss_test.cc
@@ -50,7 +50,7 @@
p.s.v[0] = 0;
p.a.v[0] = 1;
- for (size_t i = 0; i < N - 1; i++) {
+ for (size_t i = 0; i < HRSS_N - 1; i++) {
SCOPED_TRACE(i);
poly3 r;
OPENSSL_memset(&r, 0, sizeof(r));
@@ -485,9 +485,9 @@
return;
}
- alignas(16) uint16_t r[N + 3];
- alignas(16) uint16_t a[N + 3] = {0};
- alignas(16) uint16_t b[N + 3] = {0};
+ alignas(16) uint16_t r[HRSS_N + 3];
+ alignas(16) uint16_t a[HRSS_N + 3] = {0};
+ alignas(16) uint16_t b[HRSS_N + 3] = {0};
uint8_t kCanary[256];
static_assert(sizeof(kCanary) % 32 == 0, "needed for alignment");
diff --git a/crypto/hrss/internal.h b/crypto/hrss/internal.h
index ab7ebc8..753a491 100644
--- a/crypto/hrss/internal.h
+++ b/crypto/hrss/internal.h
@@ -23,10 +23,10 @@
#endif
-#define N 701
+#define HRSS_N 701
#define BITS_PER_WORD (sizeof(crypto_word_t) * 8)
-#define WORDS_PER_POLY ((N + BITS_PER_WORD - 1) / BITS_PER_WORD)
-#define BITS_IN_LAST_WORD (N % BITS_PER_WORD)
+#define WORDS_PER_POLY ((HRSS_N + BITS_PER_WORD - 1) / BITS_PER_WORD)
+#define BITS_IN_LAST_WORD (HRSS_N % BITS_PER_WORD)
struct poly2 {
crypto_word_t v[WORDS_PER_POLY];
@@ -54,7 +54,8 @@
// poly_Rq_mul is defined in assembly. Inputs and outputs must be 16-byte-
// aligned.
extern void poly_Rq_mul(
- uint16_t r[N + 3], const uint16_t a[N + 3], const uint16_t b[N + 3],
+ uint16_t r[HRSS_N + 3], const uint16_t a[HRSS_N + 3],
+ const uint16_t b[HRSS_N + 3],
// The following should be `scratch[POLY_MUL_RQ_SCRATCH_SPACE]` but
// GCC 11.1 has a bug with unions that breaks that.
uint8_t scratch[]);