Introduce versioning in the config files
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
diff --git a/include/mbedtls/build_info.h b/include/mbedtls/build_info.h
index ab4ceff..2498a73 100644
--- a/include/mbedtls/build_info.h
+++ b/include/mbedtls/build_info.h
@@ -36,13 +36,26 @@
#include MBEDTLS_CONFIG_FILE
#endif
+#if !defined(MBEDTLS_CONFIG_VERSION) || \
+ MBEDTLS_CONFIG_VERSION != 1
+#error "Invalid config version, MBEDTLS_CONFIG_VERSION != 1"
+#endif
+
/* Target and application specific configurations
*
* Allow user to override any previous default.
*
*/
+#if defined(MBEDTLS_USER_CONFIG_VERSION)
+#error "MBEDTLS_USER_CONFIG_VERSION defined outside MBEDTLS_USER_CONFIG_FILE"
+#endif
+
#if defined(MBEDTLS_USER_CONFIG_FILE)
#include MBEDTLS_USER_CONFIG_FILE
+#if !defined(MBEDTLS_USER_CONFIG_VERSION) || \
+ MBEDTLS_USER_CONFIG_VERSION != MBEDTLS_CONFIG_VERSION
+#error "Version mismatch between config file and MBEDTLS_USER_CONFIG_FILE"
+#endif
#endif
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h
index 5212fb3..af2c438 100644
--- a/include/mbedtls/mbedtls_config.h
+++ b/include/mbedtls/mbedtls_config.h
@@ -24,6 +24,8 @@
* limitations under the License.
*/
+#define MBEDTLS_CONFIG_VERSION 1
+
/**
* \name SECTION: System support
*