From d1baedb786a78e6d791b8a832bc1fc8b6c3d752f Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Tue, 9 Aug 2022 13:44:53 +0100 Subject: [PATCH] Bignum: extract bignum_mod.h functions Extract functions declared in bignum_mod.h into a source file with a matching name. We are doing this because: - This is a general best practice/convention - We hope that this will make resolving merge conflicts in the future easier - Having them in a unified source file is a premature optimisation at this point This makes library/bignum_new.c empty and therefore it is deleted. Signed-off-by: Janos Follath --- include/mbedtls/mbedtls_config.h | 2 +- library/CMakeLists.txt | 2 +- library/Makefile | 2 +- library/{bignum_new.c => bignum_mod.c} | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-) rename library/{bignum_new.c => bignum_mod.c} (99%) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index ed85e3fd4e..3e25355f79 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -2010,9 +2010,9 @@ * Enable the multi-precision integer library. * * Module: library/bignum.c - * library/bignum_new.c * library/bignum_core.c * library/bignum_mod_raw.c + * library/bignum_mod.c * Caller: library/dhm.c * library/ecp.c * library/ecdsa.c diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 2920c555cb..96c12fb906 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -18,9 +18,9 @@ set(src_crypto asn1write.c base64.c bignum.c - bignum_new.c bignum_core.c bignum_mod_raw.c + bignum_mod.c camellia.c ccm.c chacha20.c diff --git a/library/Makefile b/library/Makefile index 6210878304..49029d86b0 100644 --- a/library/Makefile +++ b/library/Makefile @@ -83,9 +83,9 @@ OBJS_CRYPTO= \ asn1write.o \ base64.o \ bignum.o \ - bignum_new.o \ bignum_core.o \ bignum_mod_raw.o \ + bignum_mod.o \ camellia.o \ ccm.o \ chacha20.o \ diff --git a/library/bignum_new.c b/library/bignum_mod.c similarity index 99% rename from library/bignum_new.c rename to library/bignum_mod.c index 5ff55aaf84..63f917266a 100644 --- a/library/bignum_new.c +++ b/library/bignum_mod.c @@ -26,10 +26,6 @@ #include "mbedtls/platform_util.h" #include "mbedtls/error.h" #include "mbedtls/bignum.h" -#include "bignum_core.h" -#include "bignum_mod.h" -#include "bignum_mod_raw.h" -#include "constant_time_internal.h" #if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" @@ -41,6 +37,11 @@ #define mbedtls_free free #endif +#include "bignum_core.h" +#include "bignum_mod.h" +#include "bignum_mod_raw.h" +#include "constant_time_internal.h" + int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r, mbedtls_mpi_mod_modulus *m, mbedtls_mpi_uint *p,