Skip to content

Commit 1b45383

Browse files
peterdettmansipa
authored andcommitted
Add precompiler guards on comb constants
1 parent ad91bd9 commit 1b45383

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ecmult_gen.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949

5050
#endif
5151

52+
#if !(1 <= COMB_BLOCKS && COMB_BLOCKS <= 256)
53+
# error "COMB_BLOCKS must be in the range [1, 256]"
54+
#endif
55+
#if !(1 <= COMB_TEETH && COMB_TEETH <= 8)
56+
# error "COMB_TEETH must be in the range [1, 8]"
57+
#endif
58+
#if !(1 <= COMB_SPACING && COMB_SPACING <= 256)
59+
# error "COMB_SPACING must be in the range [1, 256]"
60+
#endif
61+
5262
/* The remaining COMB_* parameters are derived values, don't modify these. */
5363
#define COMB_BITS (COMB_BLOCKS * COMB_TEETH * COMB_SPACING)
5464
#define COMB_GROUPED ((COMB_SPACING == 1) && ((32 % COMB_TEETH) == 0))
@@ -57,6 +67,10 @@
5767
#define COMB_POINTS_TOTAL (COMB_BLOCKS * COMB_POINTS)
5868
#define COMB_MASK (COMB_POINTS - 1)
5969

70+
#if !(256 <= COMB_BITS && COMB_BITS <= 288)
71+
# error "COMB_BITS must be in the range [256, 288]"
72+
#endif
73+
6074
#else
6175

6276
#if ECMULT_GEN_PREC_BITS != 2 && ECMULT_GEN_PREC_BITS != 4 && ECMULT_GEN_PREC_BITS != 8

0 commit comments

Comments
 (0)