Merge branch 'mbedtls-1.3' into development
* mbedtls-1.3:
Update generated file
Update Changelog for deprecation config flags
Fix tests to work with DEPRECATED_REMOVED
Add POLARSSL_DEPRECATED_{WARNING,REMOVED}
Suppress clang warning we don't want
diff --git a/ChangeLog b/ChangeLog
index cba56d4..8fbdabf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -45,6 +45,10 @@
speed and RAM (heap only for now) usage.
* New script memory.sh helps measuring the ROM and RAM requirements of two
reduced configurations (PSK-CCM and NSA suite B).
+ * Add config flags POLARSSL_DEPRECATED_WARNING (off by default) to produce
+ warnings on use of deprecated functions (with GCC and Clang only).
+ * Add config flags POLARSSL_DEPRECATED_REMOVED (off by default) to produce
+ errors on use of deprecated functions.
Bugfix
* Fix hardclock() (only used in the benchmarking program) with some
diff --git a/include/mbedtls/check_config.h b/include/mbedtls/check_config.h
index 5369d88..de88ae2 100644
--- a/include/mbedtls/check_config.h
+++ b/include/mbedtls/check_config.h
@@ -30,6 +30,11 @@
#ifndef POLARSSL_CHECK_CONFIG_H
#define POLARSSL_CHECK_CONFIG_H
+#if defined(POLARSSL_DEPRECATED_WARNING) && \
+ !defined(__GCC__) && !defined(__clang__)
+#error "POLARSSL_DEPRECATED_WARNING only works with GCC and Clang"
+#endif
+
#if defined(POLARSSL_AESNI_C) && !defined(POLARSSL_HAVE_ASM)
#error "POLARSSL_AESNI_C defined, but not all prerequisites"
#endif
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index bee898c..8b2a858 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -179,6 +179,34 @@
//#define POLARSSL_PLATFORM_FPRINTF_ALT
//#define POLARSSL_PLATFORM_PRINTF_ALT
//#define POLARSSL_PLATFORM_SNPRINTF_ALT
+
+/**
+ * \def POLARSSL_DEPRECATED_WARNING
+ *
+ * Mark deprecated functions so that they generate a warning if used.
+ * Functions deprecated in one version will usually be removed in the next
+ * version. You can enable this to help you prepare the transition to a new
+ * major version by making sure your code is not using these functions.
+ *
+ * This only works with GCC and Clang. With other compilers, you may want to
+ * use POLARSSL_DEPRECATED_REMOVED
+ *
+ * Uncomment to get warnings on using deprecated functions.
+ */
+//#define POLARSSL_DEPRECATED_WARNING
+
+/**
+ * \def POLARSSL_DEPRECATED_REMOVED
+ *
+ * Remove deprecated functions so that they generate an error if used.
+ * Functions deprecated in one version will usually be removed in the next
+ * version. You can enable this to help you prepare the transition to a new
+ * major version by making sure your code is not using these functions.
+ *
+ * Uncomment to get errors on using deprecated functions.
+ */
+//#define POLARSSL_DEPRECATED_REMOVED
+
/* \} name SECTION: System support */
/**
diff --git a/library/version_features.c b/library/version_features.c
index a1c260e..747fc92 100644
--- a/library/version_features.c
+++ b/library/version_features.c
@@ -78,6 +78,12 @@
#if defined(POLARSSL_PLATFORM_SNPRINTF_ALT)
"POLARSSL_PLATFORM_SNPRINTF_ALT",
#endif /* POLARSSL_PLATFORM_SNPRINTF_ALT */
+#if defined(POLARSSL_DEPRECATED_WARNING)
+ "POLARSSL_DEPRECATED_WARNING",
+#endif /* POLARSSL_DEPRECATED_WARNING */
+#if defined(POLARSSL_DEPRECATED_REMOVED)
+ "POLARSSL_DEPRECATED_REMOVED",
+#endif /* POLARSSL_DEPRECATED_REMOVED */
#if defined(POLARSSL_TIMING_ALT)
"POLARSSL_TIMING_ALT",
#endif /* POLARSSL_TIMING_ALT */
diff --git a/tests/scripts/generate_code.pl b/tests/scripts/generate_code.pl
index 6d5d005..5b7f289 100755
--- a/tests/scripts/generate_code.pl
+++ b/tests/scripts/generate_code.pl
@@ -50,8 +50,9 @@
while (@var_req_arr)
{
my $req = shift @var_req_arr;
+ $req =~ s/(!?)(.*)/$1defined($2)/;
- $suite_pre_code .= "#ifdef $req\n";
+ $suite_pre_code .= "#if $req\n";
$suite_post_code .= "#endif /* $req */\n";
}