From d0cf55e13a7f0914759fe4f3afd003ff37868269 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Wed, 6 Jul 2022 15:07:57 +0200 Subject: [PATCH 1/3] config: Set preprocessor defaults for ECMULT_* config values This simplifies manual builds and solves one item in #929. --- src/ecmult.h | 3 +++ src/ecmult_gen.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/ecmult.h b/src/ecmult.h index b47d8f4..37c7366 100644 --- a/src/ecmult.h +++ b/src/ecmult.h @@ -11,6 +11,9 @@ #include "scalar.h" #include "scratch.h" +#ifndef ECMULT_WINDOW_SIZE +# define ECMULT_WINDOW_SIZE 15 +#endif /* Noone will ever need more than a window size of 24. The code might * be correct for larger values of ECMULT_WINDOW_SIZE but this is not * tested. diff --git a/src/ecmult_gen.h b/src/ecmult_gen.h index f48f266..8378b8b 100644 --- a/src/ecmult_gen.h +++ b/src/ecmult_gen.h @@ -10,6 +10,9 @@ #include "scalar.h" #include "group.h" +#ifndef ECMULT_GEN_PREC_BITS +# define ECMULT_GEN_PREC_BITS 4 +#endif #if ECMULT_GEN_PREC_BITS != 2 && ECMULT_GEN_PREC_BITS != 4 && ECMULT_GEN_PREC_BITS != 8 # error "Set ECMULT_GEN_PREC_BITS to 2, 4 or 8." #endif From da6514a04a0761f973bb7591a7b41fb235747a3d Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Wed, 6 Jul 2022 15:10:34 +0200 Subject: [PATCH 2/3] config: Introduce DEBUG_CONFIG macro for debug output of config --- src/ecmult.h | 8 ++++++++ src/ecmult_gen.h | 9 +++++++++ src/util.h | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/src/ecmult.h b/src/ecmult.h index 37c7366..e28c602 100644 --- a/src/ecmult.h +++ b/src/ecmult.h @@ -13,7 +13,15 @@ #ifndef ECMULT_WINDOW_SIZE # define ECMULT_WINDOW_SIZE 15 +# ifdef DEBUG_CONFIG +# pragma message DEBUG_CONFIG_MSG("ECMULT_WINDOW_SIZE undefined, assuming default value") +# endif #endif + +#ifdef DEBUG_CONFIG +# pragma message DEBUG_CONFIG_DEF(ECMULT_WINDOW_SIZE) +#endif + /* Noone will ever need more than a window size of 24. The code might * be correct for larger values of ECMULT_WINDOW_SIZE but this is not * tested. diff --git a/src/ecmult_gen.h b/src/ecmult_gen.h index 8378b8b..a430e8d 100644 --- a/src/ecmult_gen.h +++ b/src/ecmult_gen.h @@ -12,10 +12,19 @@ #ifndef ECMULT_GEN_PREC_BITS # define ECMULT_GEN_PREC_BITS 4 +# ifdef DEBUG_CONFIG +# pragma message DEBUG_CONFIG_MSG("ECMULT_GEN_PREC_BITS undefined, assuming default value") +# endif #endif + +#ifdef DEBUG_CONFIG +# pragma message DEBUG_CONFIG_DEF(ECMULT_GEN_PREC_BITS) +#endif + #if ECMULT_GEN_PREC_BITS != 2 && ECMULT_GEN_PREC_BITS != 4 && ECMULT_GEN_PREC_BITS != 8 # error "Set ECMULT_GEN_PREC_BITS to 2, 4 or 8." #endif + #define ECMULT_GEN_PREC_G(bits) (1 << bits) #define ECMULT_GEN_PREC_N(bits) (256 / bits) diff --git a/src/util.h b/src/util.h index dac86bd..0921e34 100644 --- a/src/util.h +++ b/src/util.h @@ -16,6 +16,11 @@ #include #include +#define STR_(x) #x +#define STR(x) STR_(x) +#define DEBUG_CONFIG_MSG(x) "DEBUG_CONFIG: " x +#define DEBUG_CONFIG_DEF(x) DEBUG_CONFIG_MSG(#x "=" STR(x)) + typedef struct { void (*fn)(const char *text, void* data); const void* data; From c27ae451440bdaf68bf8aaa60edb1f4b4614d492 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Wed, 6 Jul 2022 15:38:21 +0200 Subject: [PATCH 3/3] config: Remove basic-config.h It's unused and thus potentially confusing. --- Makefile.am | 1 - src/basic-config.h | 17 ----------------- 2 files changed, 18 deletions(-) delete mode 100644 src/basic-config.h diff --git a/Makefile.am b/Makefile.am index 6eb2245..cc7d91a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,7 +58,6 @@ noinst_HEADERS += src/hash_impl.h noinst_HEADERS += src/field.h noinst_HEADERS += src/field_impl.h noinst_HEADERS += src/bench.h -noinst_HEADERS += src/basic-config.h noinst_HEADERS += contrib/lax_der_parsing.h noinst_HEADERS += contrib/lax_der_parsing.c noinst_HEADERS += contrib/lax_der_privatekey_parsing.h diff --git a/src/basic-config.h b/src/basic-config.h deleted file mode 100644 index 6f7693c..0000000 --- a/src/basic-config.h +++ /dev/null @@ -1,17 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2013, 2014 Pieter Wuille * - * Distributed under the MIT software license, see the accompanying * - * file COPYING or https://www.opensource.org/licenses/mit-license.php.* - ***********************************************************************/ - -#ifndef SECP256K1_BASIC_CONFIG_H -#define SECP256K1_BASIC_CONFIG_H - -#ifdef USE_BASIC_CONFIG - -#define ECMULT_WINDOW_SIZE 15 -#define ECMULT_GEN_PREC_BITS 4 - -#endif /* USE_BASIC_CONFIG */ - -#endif /* SECP256K1_BASIC_CONFIG_H */