aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSummer Qin <summer.qin@arm.com>2020-10-15 14:20:21 +0800
committerSummer Qin <summer.qin@arm.com>2020-10-30 14:38:10 +0800
commite8412b43d4b89eeaf2a30ed0ff90963b8d07f21b (patch)
treea130f20852b8965d681c0f8219de31ffe4c33eb8 /lib
parente82831bb618340cec19234468b20ea2a5fdc157b (diff)
downloadtrusted-firmware-m-e8412b43d4b89eeaf2a30ed0ff90963b8d07f21b.tar.gz
Crypto: Upgrade Mbed TLS to 2.24
Set the MBEDCRYPTO_VERSION to 2.24.0, and update the patches for building mbedcrypto in tfm. Change-Id: I6e4467bd13664cae3137eb15c2092b549e256cb2 Signed-off-by: Summer Qin <summer.qin@arm.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/ext/mbedcrypto/0001-Allow-renaming-of-cmake-targets.patch125
-rw-r--r--lib/ext/mbedcrypto/0001-Build-Add-MBEDTLS_TARGET_PREFIX.patch350
-rw-r--r--lib/ext/mbedcrypto/0002-Build-Use-new-style-syntax-in-link-libraries.patch57
-rw-r--r--lib/ext/mbedcrypto/0002-Make-api-documentation-target-optional.patch44
-rw-r--r--lib/ext/mbedcrypto/0003-Add-include-mbedtls-to-include-property-of-targets.patch60
-rw-r--r--lib/ext/mbedcrypto/0003-Remove-overriding-of-CMAKE_BUILD_TYPE.patch (renamed from lib/ext/mbedcrypto/0005-Remove-overriding-of-CMAKE_BUILD_TYPE.patch)8
-rw-r--r--lib/ext/mbedcrypto/0004-Add-variable-to-disable-install-targets.patch47
-rw-r--r--lib/ext/mbedcrypto/0004-BUILD-Update-IAR-support-in-CMakeLists.txt.patch (renamed from lib/ext/mbedcrypto/0007-Update_IAR_support_in_CMakeLists_txt.patch)11
-rw-r--r--lib/ext/mbedcrypto/0006-Alter-mbedtls-link-libraries-to-use-new-syntax.patch35
9 files changed, 418 insertions, 319 deletions
diff --git a/lib/ext/mbedcrypto/0001-Allow-renaming-of-cmake-targets.patch b/lib/ext/mbedcrypto/0001-Allow-renaming-of-cmake-targets.patch
deleted file mode 100644
index eacf0649d..000000000
--- a/lib/ext/mbedcrypto/0001-Allow-renaming-of-cmake-targets.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-From 8e67edf7fa9972eb889728c38fd057d43869c2b9 Mon Sep 17 00:00:00 2001
-From: Raef Coles <raef.coles@arm.com>
-Date: Mon, 15 Jun 2020 09:43:04 +0100
-Subject: [PATCH 1/6] Allow renaming of cmake targets
-
-External projects can use this to rename the cmake targets generated to
-avoid clashes with their own targets, or targets in other external
-dependencies.
-
-Signed-off-by: Raef Coles <raef.coles@arm.com>
----
- library/CMakeLists.txt | 79 ++++++++++++++++++++++++++++++------------
- 1 file changed, 56 insertions(+), 23 deletions(-)
-
-diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
-index 05196e86c..fe74de25d 100644
---- a/library/CMakeLists.txt
-+++ b/library/CMakeLists.txt
-@@ -148,16 +148,45 @@ if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
- message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
- endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
-
-+if(NOT DEFINED mbedtls_target)
-+ set(mbedtls_target "mbedtls")
-+ set(mbedtls_target "mbedtls" PARENT_SCOPE)
-+endif()
-+
-+if(NOT DEFINED mbedx509_target)
-+ set(mbedx509_target "mbedx509")
-+ set(mbedx509_target "mbedx509" PARENT_SCOPE)
-+endif()
-+
-+if(NOT DEFINED mbedcrypto_target)
-+ set(mbedcrypto_target "mbedcrypto")
-+ set(mbedcrypto_target "mbedcrypto" PARENT_SCOPE)
-+endif()
-+
-+if (USE_STATIC_MBEDTLS_LIBRARY)
-+ if(NOT DEFINED mbedtls_static_target)
-+ set(mbedtls_static_target ${mbedtls_target})
-+ set(mbedtls_static_target ${mbedtls_target} PARENT_SCOPE)
-+ endif()
-+
-+ if(NOT DEFINED mbedx509_static_target)
-+ set(mbedx509_static_target ${mbedx509_target})
-+ set(mbedx509_static_target ${mbedx509_target} PARENT_SCOPE)
-+ endif()
-+
-+ if(NOT DEFINED mbedcrypto_static_target)
-+ set(mbedcrypto_static_target ${mbedcrypto_target})
-+ set(mbedcrypto_static_target ${mbedcrypto_target} PARENT_SCOPE)
-+ endif()
-+endif()
-+
- if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
-- set(mbedtls_static_target "mbedtls_static")
-- set(mbedx509_static_target "mbedx509_static")
-- set(mbedcrypto_static_target "mbedcrypto_static")
--elseif(USE_STATIC_MBEDTLS_LIBRARY)
-- set(mbedtls_static_target "mbedtls")
-- set(mbedx509_static_target "mbedx509")
-- set(mbedcrypto_static_target "mbedcrypto")
-+ string(APPEND mbedtls_static_target "_static")
-+ string(APPEND mbedx509_static_target "_static")
-+ string(APPEND mbedcrypto_static_target "_static")
- endif()
-
-+
- if(USE_STATIC_MBEDTLS_LIBRARY)
- add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
- set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
-@@ -180,30 +209,34 @@ endif(USE_STATIC_MBEDTLS_LIBRARY)
-
- if(USE_SHARED_MBEDTLS_LIBRARY)
-
-- add_library(mbedcrypto SHARED ${src_crypto})
-- set_target_properties(mbedcrypto PROPERTIES VERSION 2.23.0 SOVERSION 5)
-- target_link_libraries(mbedcrypto ${libs})
-- target_include_directories(mbedcrypto
-+ add_library(${mbedcrypto_target} SHARED ${src_crypto})
-+ set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.23.0 SOVERSION 5)
-+ target_link_libraries(${mbedcrypto_target} ${libs})
-+ target_include_directories(${mbedcrypto_target}
- PUBLIC ${MBEDTLS_DIR}/include/)
-
-- add_library(mbedx509 SHARED ${src_x509})
-- set_target_properties(mbedx509 PROPERTIES VERSION 2.23.0 SOVERSION 1)
-- target_link_libraries(mbedx509 ${libs} mbedcrypto)
-- target_include_directories(mbedx509
-+ add_library(${mbedx509_target} SHARED ${src_x509})
-+ set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.23.0 SOVERSION 1)
-+ target_link_libraries(${mbedx509_target} ${libs} ${mbedcrypto_target})
-+ target_include_directories(${mbedx509_target}
- PUBLIC ${MBEDTLS_DIR}/include/)
-
-- add_library(mbedtls SHARED ${src_tls})
-- set_target_properties(mbedtls PROPERTIES VERSION 2.23.0 SOVERSION 13)
-- target_link_libraries(mbedtls ${libs} mbedx509)
-- target_include_directories(mbedtls
-- PUBLIC ${MBEDTLS_DIR}/include/)
-+ add_library(${mbedtls_target} SHARED ${src_tls})
-+ set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.23.0 SOVERSION 13)
-+ target_link_libraries(${mbedtls_target} ${libs} ${mbedx509_target})
-+ target_include_directories(${mbedtls_target}
-+ PUBLIC ${${mbedtls_target}_DIR}/include/)
-
-- install(TARGETS mbedtls mbedx509 mbedcrypto
-+ install(TARGETS ${mbedtls_target} ${mbedx509_target} ${mbedcrypto_target}
- DESTINATION ${LIB_INSTALL_DIR}
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
- endif(USE_SHARED_MBEDTLS_LIBRARY)
-
--add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls)
-+if(NOT DEFINED lib_target)
-+ set(lib_target lib)
-+endif()
-+
-+add_custom_target(${lib_target} DEPENDS ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target})
- if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
-- add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static)
-+ add_dependencies(${lib_target} ${mbedcrypto_static_target} ${mbedx509_static_target} ${mbedtls_static_target})
- endif()
---
-2.20.1
-
diff --git a/lib/ext/mbedcrypto/0001-Build-Add-MBEDTLS_TARGET_PREFIX.patch b/lib/ext/mbedcrypto/0001-Build-Add-MBEDTLS_TARGET_PREFIX.patch
new file mode 100644
index 000000000..f19479c2a
--- /dev/null
+++ b/lib/ext/mbedcrypto/0001-Build-Add-MBEDTLS_TARGET_PREFIX.patch
@@ -0,0 +1,350 @@
+From 995c66f702db3a004be1e3d822ffad64b2ad125f Mon Sep 17 00:00:00 2001
+From: Raef Coles <raef.coles@arm.com>
+Date: Tue, 13 Oct 2020 16:30:41 +0100
+Subject: [PATCH 1/2] Build: Add MBEDTLS_TARGET_PREFIX
+
+Allows required targets to have prefixes added to them, so that external
+projects can avoid target names clashing.
+
+Signed-off-by: Raef Coles <raef.coles@arm.com>
+---
+ CMakeLists.txt | 6 +-
+ .../add_MBEDTLS_TARGET_PREFIX_to_cmake.txt | 6 ++
+ library/CMakeLists.txt | 55 ++++++++++++-------
+ programs/aes/CMakeLists.txt | 2 +-
+ programs/fuzz/CMakeLists.txt | 2 +-
+ programs/hash/CMakeLists.txt | 2 +-
+ programs/pkey/CMakeLists.txt | 4 +-
+ programs/psa/CMakeLists.txt | 2 +-
+ programs/random/CMakeLists.txt | 2 +-
+ programs/ssl/CMakeLists.txt | 2 +-
+ programs/test/CMakeLists.txt | 4 +-
+ programs/test/cmake_subproject/CMakeLists.txt | 12 ++--
+ programs/util/CMakeLists.txt | 2 +-
+ programs/x509/CMakeLists.txt | 4 +-
+ tests/CMakeLists.txt | 4 +-
+ 15 files changed, 69 insertions(+), 40 deletions(-)
+ create mode 100644 ChangeLog.d/add_MBEDTLS_TARGET_PREFIX_to_cmake.txt
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 5af4c8124..e4f318b3c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -14,6 +14,10 @@
+ # CMake files. It is related to ZLIB support which is planned to be removed.
+ # When the support is removed, the associated include_directories command
+ # will be removed as well as this note.
++# - MBEDTLS_TARGET_PREFIX: CMake targets are designed to be alterable by calling
++# CMake in order to avoid target name clashes, via the use of
++# MBEDTLS_TARGET_PREFIX. The value of this variable is prefixed to the
++# mbedtls, mbedx509, mbedcrypto and apidoc targets.
+ #
+
+ cmake_minimum_required(VERSION 2.6)
+@@ -273,7 +277,7 @@ if(ENABLE_PROGRAMS)
+ add_subdirectory(programs)
+ endif()
+
+-ADD_CUSTOM_TARGET(apidoc
++ADD_CUSTOM_TARGET(${MBEDTLS_TARGET_PREFIX}apidoc
+ COMMAND doxygen mbedtls.doxyfile
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
+
+diff --git a/ChangeLog.d/add_MBEDTLS_TARGET_PREFIX_to_cmake.txt b/ChangeLog.d/add_MBEDTLS_TARGET_PREFIX_to_cmake.txt
+new file mode 100644
+index 000000000..533f309ab
+--- /dev/null
++++ b/ChangeLog.d/add_MBEDTLS_TARGET_PREFIX_to_cmake.txt
+@@ -0,0 +1,6 @@
++Features
++ * Add MBEDTLS_TARGET_PREFIX CMake variable, which is prefixed to the mbedtls,
++ mbedcrypto, mbedx509 and apidoc CMake target names. This can be used by
++ external CMake projects that include this one to avoid CMake target name
++ clashes. The default value of this variable is "", so default target names
++ are unchanged.
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index 4444b984e..f0315f721 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -150,18 +150,31 @@ if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
+ message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
+ endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
+
+-set(target_libraries "mbedcrypto" "mbedx509" "mbedtls")
++set(mbedtls_target "${MBEDTLS_TARGET_PREFIX}mbedtls")
++set(mbedx509_target "${MBEDTLS_TARGET_PREFIX}mbedx509")
++set(mbedcrypto_target "${MBEDTLS_TARGET_PREFIX}mbedcrypto")
++
++set(mbedtls_target ${mbedtls_target} PARENT_SCOPE)
++set(mbedx509_target ${mbedx509_target} PARENT_SCOPE)
++set(mbedcrypto_target ${mbedcrypto_target} PARENT_SCOPE)
++
++if (USE_STATIC_MBEDTLS_LIBRARY)
++ set(mbedtls_static_target ${mbedtls_target})
++ set(mbedx509_static_target ${mbedx509_target})
++ set(mbedcrypto_static_target ${mbedcrypto_target})
++endif()
++
++set(target_libraries ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target})
+
+ if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
+- set(mbedtls_static_target "mbedtls_static")
+- set(mbedx509_static_target "mbedx509_static")
+- set(mbedcrypto_static_target "mbedcrypto_static")
++ string(APPEND mbedtls_static_target "_static")
++ string(APPEND mbedx509_static_target "_static")
++ string(APPEND mbedcrypto_static_target "_static")
++
+ list(APPEND target_libraries
+- "mbedcrypto_static" "mbedx509_static" "mbedtls_static")
+-elseif(USE_STATIC_MBEDTLS_LIBRARY)
+- set(mbedtls_static_target "mbedtls")
+- set(mbedx509_static_target "mbedx509")
+- set(mbedcrypto_static_target "mbedcrypto")
++ ${mbedcrypto_static_target}
++ ${mbedx509_static_target}
++ ${mbedtls_static_target})
+ endif()
+
+ if(USE_STATIC_MBEDTLS_LIBRARY)
+@@ -179,17 +192,17 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
+ endif(USE_STATIC_MBEDTLS_LIBRARY)
+
+ if(USE_SHARED_MBEDTLS_LIBRARY)
+- add_library(mbedcrypto SHARED ${src_crypto})
+- set_target_properties(mbedcrypto PROPERTIES VERSION 2.24.0 SOVERSION 5)
+- target_link_libraries(mbedcrypto ${libs})
++ add_library(${mbedcrypto_target} SHARED ${src_crypto})
++ set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.24.0 SOVERSION 5)
++ target_link_libraries(${mbedcrypto_target} ${libs})
+
+- add_library(mbedx509 SHARED ${src_x509})
+- set_target_properties(mbedx509 PROPERTIES VERSION 2.24.0 SOVERSION 1)
+- target_link_libraries(mbedx509 ${libs} mbedcrypto)
++ add_library(${mbedx509_target} SHARED ${src_x509})
++ set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.24.0 SOVERSION 1)
++ target_link_libraries(${mbedx509_target} ${libs} ${mbedcrypto_target})
+
+- add_library(mbedtls SHARED ${src_tls})
+- set_target_properties(mbedtls PROPERTIES VERSION 2.24.0 SOVERSION 13)
+- target_link_libraries(mbedtls ${libs} mbedx509)
++ add_library(${mbedtls_target} SHARED ${src_tls})
++ set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.24.0 SOVERSION 13)
++ target_link_libraries(${mbedtls_target} ${libs} ${mbedx509_target})
+ endif(USE_SHARED_MBEDTLS_LIBRARY)
+
+ foreach(target IN LISTS target_libraries)
+@@ -210,7 +223,9 @@ foreach(target IN LISTS target_libraries)
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+ endforeach(target)
+
+-add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls)
++set(lib_target "${MBEDTLS_TARGET_PREFIX}lib")
++
++add_custom_target(${lib_target} DEPENDS ${mbedcrypto_target} ${mbedx509_target} ${mbedtls_target})
+ if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
+- add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static)
++ add_dependencies(${lib_target} ${mbedcrypto_static_target} ${mbedx509_static_target} ${mbedtls_static_target})
+ endif()
+diff --git a/programs/aes/CMakeLists.txt b/programs/aes/CMakeLists.txt
+index 2309789a6..6b8ce2ab4 100644
+--- a/programs/aes/CMakeLists.txt
++++ b/programs/aes/CMakeLists.txt
+@@ -5,7 +5,7 @@ set(executables
+
+ foreach(exe IN LISTS executables)
+ add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
+- target_link_libraries(${exe} mbedcrypto)
++ target_link_libraries(${exe} ${mbedcrypto_target})
+ endforeach()
+
+ install(TARGETS ${executables}
+diff --git a/programs/fuzz/CMakeLists.txt b/programs/fuzz/CMakeLists.txt
+index e2b0eace2..35512c79a 100644
+--- a/programs/fuzz/CMakeLists.txt
++++ b/programs/fuzz/CMakeLists.txt
+@@ -1,5 +1,5 @@
+ set(libs
+- mbedtls
++ ${mbedtls_target}
+ )
+
+ if(USE_PKCS11_HELPER_LIBRARY)
+diff --git a/programs/hash/CMakeLists.txt b/programs/hash/CMakeLists.txt
+index ae294798b..b2f2a1f5c 100644
+--- a/programs/hash/CMakeLists.txt
++++ b/programs/hash/CMakeLists.txt
+@@ -5,7 +5,7 @@ set(executables
+
+ foreach(exe IN LISTS executables)
+ add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
+- target_link_libraries(${exe} mbedcrypto)
++ target_link_libraries(${exe} ${mbedcrypto_target})
+ endforeach()
+
+ install(TARGETS ${executables}
+diff --git a/programs/pkey/CMakeLists.txt b/programs/pkey/CMakeLists.txt
+index b4b3d3042..9c6fe7d49 100644
+--- a/programs/pkey/CMakeLists.txt
++++ b/programs/pkey/CMakeLists.txt
+@@ -5,7 +5,7 @@ set(executables_mbedtls
+
+ foreach(exe IN LISTS executables_mbedtls)
+ add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
+- target_link_libraries(${exe} mbedtls)
++ target_link_libraries(${exe} ${mbedtls_target})
+ endforeach()
+
+ set(executables_mbedcrypto
+@@ -31,7 +31,7 @@ set(executables_mbedcrypto
+
+ foreach(exe IN LISTS executables_mbedcrypto)
+ add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
+- target_link_libraries(${exe} mbedcrypto)
++ target_link_libraries(${exe} ${mbedcrypto_target})
+ endforeach()
+
+ install(TARGETS ${executables_mbedtls} ${executables_mbedcrypto}
+diff --git a/programs/psa/CMakeLists.txt b/programs/psa/CMakeLists.txt
+index 5cbcf7191..23e85fea7 100644
+--- a/programs/psa/CMakeLists.txt
++++ b/programs/psa/CMakeLists.txt
+@@ -6,7 +6,7 @@ set(executables
+
+ foreach(exe IN LISTS executables)
+ add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
+- target_link_libraries(${exe} mbedcrypto)
++ target_link_libraries(${exe} ${mbedcrypto_target})
+ target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
+ endforeach()
+
+diff --git a/programs/random/CMakeLists.txt b/programs/random/CMakeLists.txt
+index 95acb7e10..8df836580 100644
+--- a/programs/random/CMakeLists.txt
++++ b/programs/random/CMakeLists.txt
+@@ -6,7 +6,7 @@ set(executables
+
+ foreach(exe IN LISTS executables)
+ add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
+- target_link_libraries(${exe} mbedcrypto)
++ target_link_libraries(${exe} ${mbedcrypto_target})
+ endforeach()
+
+ install(TARGETS ${executables}
+diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt
+index 28fbfc5a7..ca0a6a429 100644
+--- a/programs/ssl/CMakeLists.txt
++++ b/programs/ssl/CMakeLists.txt
+@@ -2,7 +2,7 @@ set(THREADS_USE_PTHREADS_WIN32 true)
+ find_package(Threads)
+
+ set(libs
+- mbedtls
++ ${mbedtls_target}
+ )
+
+ if(USE_PKCS11_HELPER_LIBRARY)
+diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt
+index 0df0becd9..217741bf9 100644
+--- a/programs/test/CMakeLists.txt
++++ b/programs/test/CMakeLists.txt
+@@ -1,5 +1,5 @@
+ set(libs
+- mbedtls
++ ${mbedtls_target}
+ )
+
+ if(USE_PKCS11_HELPER_LIBRARY)
+@@ -33,7 +33,7 @@ foreach(exe IN LISTS executables_libs executables_mbedcrypto)
+ if (${exe_index} GREATER -1)
+ target_link_libraries(${exe} ${libs})
+ else()
+- target_link_libraries(${exe} mbedcrypto)
++ target_link_libraries(${exe} ${mbedcrypto_target})
+ endif()
+ endforeach()
+
+diff --git a/programs/test/cmake_subproject/CMakeLists.txt b/programs/test/cmake_subproject/CMakeLists.txt
+index 3e32c5fc3..a9fcfde29 100644
+--- a/programs/test/cmake_subproject/CMakeLists.txt
++++ b/programs/test/cmake_subproject/CMakeLists.txt
+@@ -1,5 +1,8 @@
+ cmake_minimum_required(VERSION 2.6)
+
++# Test the target renaming support by adding a prefix to the targets built
++set(MBEDTLS_TARGET_PREFIX subproject_test_)
++
+ # We use the parent Mbed TLS directory as the MBEDTLS_DIR for this test. Other
+ # projects that use Mbed TLS as a subproject are likely to add by their own
+ # relative paths.
+@@ -8,11 +11,12 @@ set(MBEDTLS_DIR ../../../)
+ # Add Mbed TLS as a subdirectory.
+ add_subdirectory(${MBEDTLS_DIR} build)
+
+-# Link against all the Mbed TLS libraries.
++# Link against all the Mbed TLS libraries. Verifies that the targets have been
++# created using the specified prefix
+ set(libs
+- mbedcrypto
+- mbedx509
+- mbedtls
++ subproject_test_mbedcrypto
++ subproject_test_mbedx509
++ subproject_test_mbedtls
+ )
+
+ add_executable(cmake_subproject cmake_subproject.c)
+diff --git a/programs/util/CMakeLists.txt b/programs/util/CMakeLists.txt
+index cb14a3ee6..2a11212ec 100644
+--- a/programs/util/CMakeLists.txt
++++ b/programs/util/CMakeLists.txt
+@@ -1,5 +1,5 @@
+ set(libs
+- mbedcrypto
++ ${mbedcrypto_target}
+ )
+
+ set(executables
+diff --git a/programs/x509/CMakeLists.txt b/programs/x509/CMakeLists.txt
+index f7b5fe1d9..29cbeb800 100644
+--- a/programs/x509/CMakeLists.txt
++++ b/programs/x509/CMakeLists.txt
+@@ -1,5 +1,5 @@
+ set(libs
+- mbedx509
++ ${mbedx509_target}
+ )
+
+ if(USE_PKCS11_HELPER_LIBRARY)
+@@ -23,7 +23,7 @@ foreach(exe IN LISTS executables)
+ target_link_libraries(${exe} ${libs})
+ endforeach()
+
+-target_link_libraries(cert_app mbedtls)
++target_link_libraries(cert_app ${mbedtls_target})
+
+ install(TARGETS ${executables}
+ DESTINATION "bin"
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index cc6866309..580d936c0 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -1,5 +1,5 @@
+ set(libs
+- mbedtls
++ ${mbedtls_target}
+ )
+
+ # Set the project root directory if it's not already defined, as may happen if
+@@ -43,7 +43,7 @@ function(add_test_suite suite_name)
+ add_custom_command(
+ OUTPUT test_suite_${data_name}.c
+ COMMAND ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites --helpers-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function -o .
+- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py mbedtls ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data
++ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py ${mbedtls_target} ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data
+ )
+
+ add_executable(test_suite_${data_name} test_suite_${data_name}.c $<TARGET_OBJECTS:mbedtls_test>)
+--
+2.20.1
+
diff --git a/lib/ext/mbedcrypto/0002-Build-Use-new-style-syntax-in-link-libraries.patch b/lib/ext/mbedcrypto/0002-Build-Use-new-style-syntax-in-link-libraries.patch
new file mode 100644
index 000000000..c4d51500b
--- /dev/null
+++ b/lib/ext/mbedcrypto/0002-Build-Use-new-style-syntax-in-link-libraries.patch
@@ -0,0 +1,57 @@
+From 4762eddfb3e17d50b471cf6dda491047cbd712d6 Mon Sep 17 00:00:00 2001
+From: Raef Coles <raef.coles@arm.com>
+Date: Tue, 13 Oct 2020 16:31:41 +0100
+Subject: [PATCH 2/2] Build: Use new-style syntax in link-libraries
+
+Migrate to new syntax where the PUBLIC attribute is explicitly defined.
+Avoids issues caused sometimes where cmake does not allow the mixing of
+old-style and new-style syntax
+
+Signed-off-by: Raef Coles <raef.coles@arm.com>
+---
+ library/CMakeLists.txt | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index f0315f721..89625558a 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -180,29 +180,29 @@ endif()
+ if(USE_STATIC_MBEDTLS_LIBRARY)
+ add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
+ set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
+- target_link_libraries(${mbedcrypto_static_target} ${libs})
++ target_link_libraries(${mbedcrypto_static_target} PUBLIC ${libs})
+
+ add_library(${mbedx509_static_target} STATIC ${src_x509})
+ set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
+- target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target})
++ target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target})
+
+ add_library(${mbedtls_static_target} STATIC ${src_tls})
+ set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
+- target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
++ target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target})
+ endif(USE_STATIC_MBEDTLS_LIBRARY)
+
+ if(USE_SHARED_MBEDTLS_LIBRARY)
+ add_library(${mbedcrypto_target} SHARED ${src_crypto})
+ set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.24.0 SOVERSION 5)
+- target_link_libraries(${mbedcrypto_target} ${libs})
++ target_link_libraries(${mbedcrypto_target} PUBLIC ${libs})
+
+ add_library(${mbedx509_target} SHARED ${src_x509})
+ set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.24.0 SOVERSION 1)
+- target_link_libraries(${mbedx509_target} ${libs} ${mbedcrypto_target})
++ target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target})
+
+ add_library(${mbedtls_target} SHARED ${src_tls})
+ set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.24.0 SOVERSION 13)
+- target_link_libraries(${mbedtls_target} ${libs} ${mbedx509_target})
++ target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target})
+ endif(USE_SHARED_MBEDTLS_LIBRARY)
+
+ foreach(target IN LISTS target_libraries)
+--
+2.20.1
+
diff --git a/lib/ext/mbedcrypto/0002-Make-api-documentation-target-optional.patch b/lib/ext/mbedcrypto/0002-Make-api-documentation-target-optional.patch
deleted file mode 100644
index 2892a0c67..000000000
--- a/lib/ext/mbedcrypto/0002-Make-api-documentation-target-optional.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 53f18f73c9cee3253c19f67ad0753315eea6a688 Mon Sep 17 00:00:00 2001
-From: Raef Coles <raef.coles@arm.com>
-Date: Mon, 15 Jun 2020 10:16:44 +0100
-Subject: [PATCH 2/6] Make api documentation target optional
-
-Adds a cmake variable BUILD_API_DOCS which controls whether the cmake
-target for the docs will be generated. This can be used to avoid cmake
-target clashes or to otherwise customise the cmake build.
-
-Signed-off-by: Raef Coles <raef.coles@arm.com>
----
- CMakeLists.txt | 9 ++++++---
- 1 file changed, 6 insertions(+), 3 deletions(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 1f675c1ee..5d970b9fd 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -12,6 +12,7 @@ option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library.
- option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF)
-
- option(ENABLE_PROGRAMS "Build mbed TLS programs." ON)
-+option(ENABLE_DOCS "Build api documentation." ON)
-
- option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF)
- option(MBEDTLS_FATAL_WARNINGS "Compiler warnings treated as errors" ON)
-@@ -229,9 +230,11 @@ if(ENABLE_PROGRAMS)
- add_subdirectory(programs)
- endif()
-
--ADD_CUSTOM_TARGET(apidoc
-- COMMAND doxygen mbedtls.doxyfile
-- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
-+if(ENABLE_DOCS)
-+ ADD_CUSTOM_TARGET(apidoc
-+ COMMAND doxygen mbedtls.doxyfile
-+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
-+endif()
-
- if(ENABLE_TESTING)
- enable_testing()
---
-2.20.1
-
diff --git a/lib/ext/mbedcrypto/0003-Add-include-mbedtls-to-include-property-of-targets.patch b/lib/ext/mbedcrypto/0003-Add-include-mbedtls-to-include-property-of-targets.patch
deleted file mode 100644
index 7564f840f..000000000
--- a/lib/ext/mbedcrypto/0003-Add-include-mbedtls-to-include-property-of-targets.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From 37095546fc7eca29d5a790a7d7d0a1314b173dd3 Mon Sep 17 00:00:00 2001
-From: Raef Coles <raef.coles@arm.com>
-Date: Wed, 2 Sep 2020 10:04:05 +0100
-Subject: [PATCH 3/6] Add include/mbedtls to include property of targets
-
-Signed-off-by: Raef Coles <raef.coles@arm.com>
----
- CMakeLists.txt | 3 +--
- library/CMakeLists.txt | 8 ++++++--
- 2 files changed, 7 insertions(+), 4 deletions(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 5d970b9fd..949a50b2b 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -217,14 +217,13 @@ if(ENABLE_ZLIB_SUPPORT)
- endif(ZLIB_FOUND)
- endif(ENABLE_ZLIB_SUPPORT)
-
--add_subdirectory(include)
--
- add_subdirectory(3rdparty)
- include_directories(${thirdparty_inc})
- list(APPEND libs ${thirdparty_lib})
- add_definitions(${thirdparty_def})
-
- add_subdirectory(library)
-+add_subdirectory(include)
-
- if(ENABLE_PROGRAMS)
- add_subdirectory(programs)
-diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
-index fe74de25d..02cd157bb 100644
---- a/library/CMakeLists.txt
-+++ b/library/CMakeLists.txt
-@@ -192,7 +192,9 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
- set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
- target_link_libraries(${mbedcrypto_static_target} ${libs})
- target_include_directories(${mbedcrypto_static_target}
-- PUBLIC ${MBEDTLS_DIR}/include/)
-+ PUBLIC ${MBEDTLS_DIR}/include/
-+ PUBLIC ${MBEDTLS_DIR}/include/mbedtls/
-+ )
-
- add_library(${mbedx509_static_target} STATIC ${src_x509})
- set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
-@@ -213,7 +215,9 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
- set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.23.0 SOVERSION 5)
- target_link_libraries(${mbedcrypto_target} ${libs})
- target_include_directories(${mbedcrypto_target}
-- PUBLIC ${MBEDTLS_DIR}/include/)
-+ PUBLIC ${MBEDTLS_DIR}/include/
-+ PUBLIC ${MBEDTLS_DIR}/include/mbedtls/
-+ )
-
- add_library(${mbedx509_target} SHARED ${src_x509})
- set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.23.0 SOVERSION 1)
---
-2.20.1
-
diff --git a/lib/ext/mbedcrypto/0005-Remove-overriding-of-CMAKE_BUILD_TYPE.patch b/lib/ext/mbedcrypto/0003-Remove-overriding-of-CMAKE_BUILD_TYPE.patch
index 6f1b1b248..f94de4e0a 100644
--- a/lib/ext/mbedcrypto/0005-Remove-overriding-of-CMAKE_BUILD_TYPE.patch
+++ b/lib/ext/mbedcrypto/0003-Remove-overriding-of-CMAKE_BUILD_TYPE.patch
@@ -1,7 +1,7 @@
-From 59cbaee5e961f205c6b62c2f750a3759cb90d2b3 Mon Sep 17 00:00:00 2001
+From 1c4af63fc32e16022f884e29ad3ccbdb8c3ed2f2 Mon Sep 17 00:00:00 2001
From: Raef Coles <raef.coles@arm.com>
Date: Wed, 2 Sep 2020 10:15:02 +0100
-Subject: [PATCH 5/6] Remove overriding of CMAKE_BUILD_TYPE
+Subject: [PATCH 3/4] Remove overriding of CMAKE_BUILD_TYPE
Signed-off-by: Raef Coles <raef.coles@arm.com>
---
@@ -9,10 +9,10 @@ Signed-off-by: Raef Coles <raef.coles@arm.com>
1 file changed, 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 949a50b2b..436ee653d 100644
+index ba9227ff3..a671575b7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
-@@ -95,10 +95,6 @@ option: \n\
+@@ -112,10 +112,6 @@ option: \n\
endif()
endif()
diff --git a/lib/ext/mbedcrypto/0004-Add-variable-to-disable-install-targets.patch b/lib/ext/mbedcrypto/0004-Add-variable-to-disable-install-targets.patch
deleted file mode 100644
index 32ec43975..000000000
--- a/lib/ext/mbedcrypto/0004-Add-variable-to-disable-install-targets.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From b3374d25ef8a478996b5980f98f03c6b0abbd66d Mon Sep 17 00:00:00 2001
-From: Raef Coles <raef.coles@arm.com>
-Date: Wed, 2 Sep 2020 10:12:45 +0100
-Subject: [PATCH 4/6] Add variable to disable install targets
-
-Signed-off-by: Raef Coles <raef.coles@arm.com>
----
- library/CMakeLists.txt | 16 ++++++++++------
- 1 file changed, 10 insertions(+), 6 deletions(-)
-
-diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
-index 02cd157bb..36d6c999a 100644
---- a/library/CMakeLists.txt
-+++ b/library/CMakeLists.txt
-@@ -204,9 +204,11 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
- set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
- target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
-
-- install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target}
-- DESTINATION ${LIB_INSTALL_DIR}
-- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-+ if(INSTALL_MBEDTLS)
-+ install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target}
-+ DESTINATION ${LIB_INSTALL_DIR}
-+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-+ endif()
- endif(USE_STATIC_MBEDTLS_LIBRARY)
-
- if(USE_SHARED_MBEDTLS_LIBRARY)
-@@ -231,9 +233,11 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
- target_include_directories(${mbedtls_target}
- PUBLIC ${${mbedtls_target}_DIR}/include/)
-
-- install(TARGETS ${mbedtls_target} ${mbedx509_target} ${mbedcrypto_target}
-- DESTINATION ${LIB_INSTALL_DIR}
-- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-+ if(INSTALL_MBEDTLS)
-+ install(TARGETS ${mbedtls_target} ${mbedx509_target} ${mbedcrypto_target}
-+ DESTINATION ${LIB_INSTALL_DIR}
-+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-+ endif()
- endif(USE_SHARED_MBEDTLS_LIBRARY)
-
- if(NOT DEFINED lib_target)
---
-2.20.1
-
diff --git a/lib/ext/mbedcrypto/0007-Update_IAR_support_in_CMakeLists_txt.patch b/lib/ext/mbedcrypto/0004-BUILD-Update-IAR-support-in-CMakeLists.txt.patch
index a3a16d982..47c6448c9 100644
--- a/lib/ext/mbedcrypto/0007-Update_IAR_support_in_CMakeLists_txt.patch
+++ b/lib/ext/mbedcrypto/0004-BUILD-Update-IAR-support-in-CMakeLists.txt.patch
@@ -1,7 +1,7 @@
-From d80105c296b616f7fa113fac8d73b0a5622a59d8 Mon Sep 17 00:00:00 2001
+From 2d0f9e77a1165aa78f78436a2f5c185cc65ad6c1 Mon Sep 17 00:00:00 2001
From: TTornblom <thomas.tornblom@iar.com>
Date: Thu, 16 Apr 2020 13:53:38 +0200
-Subject: [PATCH] BUILD: Update IAR support in CMakeLists.txt
+Subject: [PATCH 4/4] BUILD: Update IAR support in CMakeLists.txt
Applied the same change as in mbed-crypto for using this as a sub
project with the IAR toolchain.
@@ -12,10 +12,10 @@ Signed-off-by: TTornblom <thomas.tornblom@iar.com>
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 1e3098cd91..b71230aad3 100644
+index a671575b7..3e59a47ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
-@@ -159,7 +159,10 @@ if(CMAKE_COMPILER_IS_CLANG)
+@@ -193,7 +193,10 @@ if(CMAKE_COMPILER_IS_CLANG)
endif(CMAKE_COMPILER_IS_CLANG)
if(CMAKE_COMPILER_IS_IAR)
@@ -27,3 +27,6 @@ index 1e3098cd91..b71230aad3 100644
endif(CMAKE_COMPILER_IS_IAR)
if(CMAKE_COMPILER_IS_MSVC)
+--
+2.20.1
+
diff --git a/lib/ext/mbedcrypto/0006-Alter-mbedtls-link-libraries-to-use-new-syntax.patch b/lib/ext/mbedcrypto/0006-Alter-mbedtls-link-libraries-to-use-new-syntax.patch
deleted file mode 100644
index 2e979bdfd..000000000
--- a/lib/ext/mbedcrypto/0006-Alter-mbedtls-link-libraries-to-use-new-syntax.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From d5114f2cff5551726f5a6e86000f2eaf603021a9 Mon Sep 17 00:00:00 2001
-From: Raef Coles <raef.coles@arm.com>
-Date: Wed, 2 Sep 2020 10:59:00 +0100
-Subject: [PATCH 6/6] Alter mbedtls link libraries to use new syntax
-
-Signed-off-by: Raef Coles <raef.coles@arm.com>
----
- library/CMakeLists.txt | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
-index 36d6c999a..45de8b785 100644
---- a/library/CMakeLists.txt
-+++ b/library/CMakeLists.txt
-@@ -202,7 +202,7 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
-
- add_library(${mbedtls_static_target} STATIC ${src_tls})
- set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
-- target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
-+ target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target})
-
- if(INSTALL_MBEDTLS)
- install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target}
-@@ -229,7 +229,7 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
-
- add_library(${mbedtls_target} SHARED ${src_tls})
- set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.23.0 SOVERSION 13)
-- target_link_libraries(${mbedtls_target} ${libs} ${mbedx509_target})
-+ target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target})
- target_include_directories(${mbedtls_target}
- PUBLIC ${${mbedtls_target}_DIR}/include/)
-
---
-2.20.1
-