diff --git a/Makefile.am b/Makefile.am index 58c9635e53..65a3d13ecd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,5 @@ ACLOCAL_AMFLAGS = -I build-aux/m4 +AM_CPPFLAGS = -Iinclude/ lib_LTLIBRARIES = libsecp256k1.la include_HEADERS = include/secp256k1.h @@ -81,15 +82,15 @@ noinst_PROGRAMS += bench_verify bench_sign bench_internal bench_ecmult bench_verify_SOURCES = src/bench_verify.c bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB) # SECP_TEST_INCLUDES are only used here for CRYPTO_CPPFLAGS -bench_verify_CPPFLAGS = -DSECP256K1_BUILD $(SECP_TEST_INCLUDES) +bench_verify_CPPFLAGS = -DSECP256K1_BUILD $(SECP_TEST_INCLUDES) $(AM_CPPFLAGS) bench_sign_SOURCES = src/bench_sign.c bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB) bench_internal_SOURCES = src/bench_internal.c bench_internal_LDADD = $(SECP_LIBS) $(COMMON_LIB) -bench_internal_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES) +bench_internal_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES) $(AM_CPPFLAGS) bench_ecmult_SOURCES = src/bench_ecmult.c bench_ecmult_LDADD = $(SECP_LIBS) $(COMMON_LIB) -bench_ecmult_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES) +bench_ecmult_CPPFLAGS = -DSECP256K1_BUILD $(SECP_INCLUDES) $(AM_CPPFLAGS) endif TESTS = @@ -114,7 +115,7 @@ endif if USE_EXHAUSTIVE_TESTS noinst_PROGRAMS += exhaustive_tests exhaustive_tests_SOURCES = src/tests_exhaustive.c -exhaustive_tests_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/src $(SECP_INCLUDES) +exhaustive_tests_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/src $(SECP_INCLUDES) $(AM_CPPFLAGS) if !ENABLE_COVERAGE exhaustive_tests_CPPFLAGS += -DVERIFY endif @@ -129,10 +130,10 @@ CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) -I$(builddir)/src gen_context_OBJECTS = gen_context.o gen_context_BIN = gen_context$(BUILD_EXEEXT) gen_%.o: src/gen_%.c src/libsecp256k1-config.h - $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@ + $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(AM_CPPFLAGS) $(CFLAGS_FOR_BUILD) -c $< -o $@ $(gen_context_BIN): $(gen_context_OBJECTS) - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $^ -o $@ + $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(AM_CPPFLAGS) $(LDFLAGS_FOR_BUILD) $^ -o $@ $(libsecp256k1_la_OBJECTS): src/ecmult_static_context.h $(tests_OBJECTS): src/ecmult_static_context.h diff --git a/src/bench_ecdh.c b/src/bench_ecdh.c index ab4b8f4244..92dfe73705 100644 --- a/src/bench_ecdh.c +++ b/src/bench_ecdh.c @@ -6,8 +6,8 @@ #include -#include "include/secp256k1.h" -#include "include/secp256k1_ecdh.h" +#include "secp256k1.h" +#include "secp256k1_ecdh.h" #include "util.h" #include "bench.h" diff --git a/src/bench_ecmult.c b/src/bench_ecmult.c index 204e85a5dd..b278a039a5 100644 --- a/src/bench_ecmult.c +++ b/src/bench_ecmult.c @@ -3,18 +3,23 @@ * Distributed under the MIT software license, see the accompanying * * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ + #include +#include +#include -#include "include/secp256k1.h" +#include "secp256k1.h" #include "util.h" #include "hash_impl.h" -#include "field_impl.h" #include "group_impl.h" -#include "scalar_impl.h" #include "ecmult_impl.h" +#include "scalar_impl.h" #include "bench.h" #include "secp256k1.c" +#include "group.h" +#include "hash.h" + #define POINTS 32768 diff --git a/src/bench_internal.c b/src/bench_internal.c index 73b8a24ccb..c2f413ab4e 100644 --- a/src/bench_internal.c +++ b/src/bench_internal.c @@ -4,19 +4,23 @@ * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ #include +#include -#include "include/secp256k1.h" +#include "secp256k1.h" #include "assumptions.h" -#include "util.h" -#include "hash_impl.h" -#include "field_impl.h" +#include "bench.h" +#include "group.h" #include "group_impl.h" -#include "scalar_impl.h" #include "ecmult_const_impl.h" #include "ecmult_impl.h" -#include "bench.h" +#include "field_impl.h" +#include "hash.h" +#include "hash_impl.h" +#include "scalar_impl.h" #include "secp256k1.c" +#include "util.h" + typedef struct { secp256k1_scalar scalar[2]; diff --git a/src/bench_recover.c b/src/bench_recover.c index 3f6270ce84..0cc7be7ef7 100644 --- a/src/bench_recover.c +++ b/src/bench_recover.c @@ -4,11 +4,13 @@ * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ -#include "include/secp256k1.h" -#include "include/secp256k1_recovery.h" +#include "secp256k1.h" +#include "secp256k1_recovery.h" #include "util.h" #include "bench.h" +#include + typedef struct { secp256k1_context *ctx; unsigned char msg[32]; diff --git a/src/bench_schnorrsig.c b/src/bench_schnorrsig.c index f7f591c41d..1df88a5b31 100644 --- a/src/bench_schnorrsig.c +++ b/src/bench_schnorrsig.c @@ -7,11 +7,11 @@ #include #include - -#include "include/secp256k1.h" -#include "include/secp256k1_schnorrsig.h" -#include "util.h" +#include "secp256k1.h" +#include "secp256k1_schnorrsig.h" +#include "secp256k1_extrakeys.h" #include "bench.h" +#include "util.h" typedef struct { secp256k1_context *ctx; diff --git a/src/bench_sign.c b/src/bench_sign.c index 933f367c4b..587432049f 100644 --- a/src/bench_sign.c +++ b/src/bench_sign.c @@ -4,7 +4,9 @@ * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ -#include "include/secp256k1.h" +#include + +#include "secp256k1.h" #include "util.h" #include "bench.h" diff --git a/src/bench_verify.c b/src/bench_verify.c index c56aefd369..9da761ab6e 100644 --- a/src/bench_verify.c +++ b/src/bench_verify.c @@ -5,19 +5,17 @@ ***********************************************************************/ #include -#include -#include "include/secp256k1.h" +#include "secp256k1.h" #include "util.h" #include "bench.h" #ifdef ENABLE_OPENSSL_TESTS -#include -#include #include +#include +#include #endif - typedef struct { secp256k1_context *ctx; unsigned char msg[32]; diff --git a/src/ecmult_gen_impl.h b/src/ecmult_gen_impl.h index 384a67faed..74d31ce690 100644 --- a/src/ecmult_gen_impl.h +++ b/src/ecmult_gen_impl.h @@ -12,6 +12,8 @@ #include "group.h" #include "ecmult_gen.h" #include "hash_impl.h" +#include "field_impl.h" + #ifdef USE_ECMULT_STATIC_PRECOMPUTATION #include "ecmult_static_context.h" #endif diff --git a/src/gen_context.c b/src/gen_context.c index 024c557261..a1fa885b25 100644 --- a/src/gen_context.c +++ b/src/gen_context.c @@ -13,7 +13,7 @@ /* We can't require the precomputed tables when creating them. */ #undef USE_ECMULT_STATIC_PRECOMPUTATION -#include "include/secp256k1.h" +#include "secp256k1.h" #include "assumptions.h" #include "util.h" #include "field_impl.h" diff --git a/src/modules/ecdh/main_impl.h b/src/modules/ecdh/main_impl.h index 1ac67086be..2d7084b61f 100644 --- a/src/modules/ecdh/main_impl.h +++ b/src/modules/ecdh/main_impl.h @@ -7,7 +7,7 @@ #ifndef SECP256K1_MODULE_ECDH_MAIN_H #define SECP256K1_MODULE_ECDH_MAIN_H -#include "include/secp256k1_ecdh.h" +#include "secp256k1_ecdh.h" #include "ecmult_const_impl.h" static int ecdh_hash_function_sha256(unsigned char *output, const unsigned char *x32, const unsigned char *y32, void *data) { diff --git a/src/modules/extrakeys/main_impl.h b/src/modules/extrakeys/main_impl.h index 7390b22718..62d0447401 100644 --- a/src/modules/extrakeys/main_impl.h +++ b/src/modules/extrakeys/main_impl.h @@ -7,8 +7,8 @@ #ifndef SECP256K1_MODULE_EXTRAKEYS_MAIN_H #define SECP256K1_MODULE_EXTRAKEYS_MAIN_H -#include "include/secp256k1.h" -#include "include/secp256k1_extrakeys.h" +#include "secp256k1.h" +#include "secp256k1_extrakeys.h" static SECP256K1_INLINE int secp256k1_xonly_pubkey_load(const secp256k1_context* ctx, secp256k1_ge *ge, const secp256k1_xonly_pubkey *pubkey) { return secp256k1_pubkey_load(ctx, ge, (const secp256k1_pubkey *) pubkey); diff --git a/src/modules/extrakeys/tests_exhaustive_impl.h b/src/modules/extrakeys/tests_exhaustive_impl.h index 0aca4fb72d..92cc186bf8 100644 --- a/src/modules/extrakeys/tests_exhaustive_impl.h +++ b/src/modules/extrakeys/tests_exhaustive_impl.h @@ -8,7 +8,7 @@ #define SECP256K1_MODULE_EXTRAKEYS_TESTS_EXHAUSTIVE_H #include "src/modules/extrakeys/main_impl.h" -#include "include/secp256k1_extrakeys.h" +#include "secp256k1_extrakeys.h" static void test_exhaustive_extrakeys(const secp256k1_context *ctx, const secp256k1_ge* group) { secp256k1_keypair keypair[EXHAUSTIVE_TEST_ORDER - 1]; diff --git a/src/modules/recovery/main_impl.h b/src/modules/recovery/main_impl.h index 7a440a729b..d6feb1e4d8 100644 --- a/src/modules/recovery/main_impl.h +++ b/src/modules/recovery/main_impl.h @@ -7,7 +7,7 @@ #ifndef SECP256K1_MODULE_RECOVERY_MAIN_H #define SECP256K1_MODULE_RECOVERY_MAIN_H -#include "include/secp256k1_recovery.h" +#include "secp256k1_recovery.h" static void secp256k1_ecdsa_recoverable_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, int* recid, const secp256k1_ecdsa_recoverable_signature* sig) { (void)ctx; diff --git a/src/modules/recovery/tests_exhaustive_impl.h b/src/modules/recovery/tests_exhaustive_impl.h index 0ba9409c69..a1aa253482 100644 --- a/src/modules/recovery/tests_exhaustive_impl.h +++ b/src/modules/recovery/tests_exhaustive_impl.h @@ -8,7 +8,7 @@ #define SECP256K1_MODULE_RECOVERY_EXHAUSTIVE_TESTS_H #include "src/modules/recovery/main_impl.h" -#include "include/secp256k1_recovery.h" +#include "secp256k1_recovery.h" void test_exhaustive_recovery_sign(const secp256k1_context *ctx, const secp256k1_ge *group) { int i, j, k; diff --git a/src/modules/schnorrsig/main_impl.h b/src/modules/schnorrsig/main_impl.h index 22e1b33a5a..b4867415d1 100644 --- a/src/modules/schnorrsig/main_impl.h +++ b/src/modules/schnorrsig/main_impl.h @@ -7,8 +7,8 @@ #ifndef SECP256K1_MODULE_SCHNORRSIG_MAIN_H #define SECP256K1_MODULE_SCHNORRSIG_MAIN_H -#include "include/secp256k1.h" -#include "include/secp256k1_schnorrsig.h" +#include "secp256k1.h" +#include "secp256k1_schnorrsig.h" #include "hash.h" /* Initializes SHA256 with fixed midstate. This midstate was computed by applying diff --git a/src/modules/schnorrsig/tests_exhaustive_impl.h b/src/modules/schnorrsig/tests_exhaustive_impl.h index b4a428729f..564d1fb033 100644 --- a/src/modules/schnorrsig/tests_exhaustive_impl.h +++ b/src/modules/schnorrsig/tests_exhaustive_impl.h @@ -7,7 +7,7 @@ #ifndef SECP256K1_MODULE_SCHNORRSIG_TESTS_EXHAUSTIVE_H #define SECP256K1_MODULE_SCHNORRSIG_TESTS_EXHAUSTIVE_H -#include "include/secp256k1_schnorrsig.h" +#include "secp256k1_schnorrsig.h" #include "src/modules/schnorrsig/main_impl.h" static const unsigned char invalid_pubkey_bytes[][32] = { diff --git a/src/secp256k1.c b/src/secp256k1.c index aef3f99ac3..0d5d4c9929 100644 --- a/src/secp256k1.c +++ b/src/secp256k1.c @@ -4,8 +4,11 @@ * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ -#include "include/secp256k1.h" -#include "include/secp256k1_preallocated.h" +#include +#include + +#include "secp256k1.h" +#include "secp256k1_preallocated.h" #include "assumptions.h" #include "util.h" @@ -13,7 +16,6 @@ #include "scalar_impl.h" #include "group_impl.h" #include "ecmult_impl.h" -#include "ecmult_const_impl.h" #include "ecmult_gen_impl.h" #include "ecdsa_impl.h" #include "eckey_impl.h" @@ -39,8 +41,8 @@ } while(0) #ifndef USE_EXTERNAL_DEFAULT_CALLBACKS -#include #include + static void secp256k1_default_illegal_callback_fn(const char* str, void* data) { (void)data; fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str); diff --git a/src/testrand_impl.h b/src/testrand_impl.h index e643778f36..8faa220779 100644 --- a/src/testrand_impl.h +++ b/src/testrand_impl.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "testrand.h" #include "hash.h" diff --git a/src/tests.c b/src/tests.c index a146394305..8cb55f2aa9 100644 --- a/src/tests.c +++ b/src/tests.c @@ -8,23 +8,40 @@ #include "libsecp256k1-config.h" #endif +#include +#include #include #include #include -#include - #include "secp256k1.c" -#include "include/secp256k1.h" -#include "include/secp256k1_preallocated.h" +#include "secp256k1.h" +#include "ecdsa_impl.h" +#include "eckey_impl.h" +#include "ecmult_const_impl.h" +#include "ecmult_gen.h" +#include "ecmult_gen_impl.h" +#include "ecmult_impl.h" +#include "field_impl.h" +#include "group.h" +#include "group_impl.h" +#include "hash.h" +#include "hash_impl.h" + +#include "scalar_impl.h" +#include "scratch.h" +#include "scratch_impl.h" #include "testrand_impl.h" #include "util.h" + #ifdef ENABLE_OPENSSL_TESTS #include #include -#include #include +#include +#include + # if OPENSSL_VERSION_NUMBER < 0x10100000L void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) {*pr = sig->r; *ps = sig->s;} # endif diff --git a/src/tests_exhaustive.c b/src/tests_exhaustive.c index 2bb5381446..f42121af40 100644 --- a/src/tests_exhaustive.c +++ b/src/tests_exhaustive.c @@ -10,8 +10,8 @@ #include #include - -#include +#include +#include #undef USE_ECMULT_STATIC_PRECOMPUTATION @@ -20,11 +20,22 @@ #define EXHAUSTIVE_TEST_ORDER 13 #endif -#include "include/secp256k1.h" +#include "secp256k1.c" +#include "secp256k1.h" #include "assumptions.h" +#include "ecmult_const_impl.h" +#include "ecmult_gen_impl.h" +#include "ecmult_impl.h" +#include "field_impl.h" #include "group.h" -#include "secp256k1.c" +#include "group_impl.h" +#include "scalar_impl.h" +#include "scalar_low.h" +#include "scalar_low_impl.h" +#include "scratch.h" +#include "scratch_impl.h" #include "testrand_impl.h" +#include "util.h" static int count = 2; diff --git a/src/valgrind_ctime_test.c b/src/valgrind_ctime_test.c index cfca5a196e..2a4a4fc9c9 100644 --- a/src/valgrind_ctime_test.c +++ b/src/valgrind_ctime_test.c @@ -4,27 +4,28 @@ * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ -#include #include +#include +#include -#include "include/secp256k1.h" +#include "secp256k1.h" #include "assumptions.h" #include "util.h" #ifdef ENABLE_MODULE_ECDH -# include "include/secp256k1_ecdh.h" +# include "secp256k1_ecdh.h" #endif #ifdef ENABLE_MODULE_RECOVERY -# include "include/secp256k1_recovery.h" +# include "secp256k1_recovery.h" #endif #ifdef ENABLE_MODULE_EXTRAKEYS -# include "include/secp256k1_extrakeys.h" +# include "secp256k1_extrakeys.h" #endif #ifdef ENABLE_MODULE_SCHNORRSIG -#include "include/secp256k1_schnorrsig.h" +#include "secp256k1_schnorrsig.h" #endif void run_tests(secp256k1_context *ctx, unsigned char *key);