Remove dependencies on deprecated PSA Crypto API definitions

In preparation for moving to mbedtls-3.0.0 where legacy support is
removed, dependencies on deprecated API functions and defines are
modified to align as closely as possible with PSA Crypto API 1.0.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I9f6fc833336a883382229c430ea71122bd550bd8
diff --git a/external/psa_arch_tests/add_inherit_toolchain.patch b/external/psa_arch_tests/add_inherit_toolchain.patch
index 2ff7709..58b2f75 100644
--- a/external/psa_arch_tests/add_inherit_toolchain.patch
+++ b/external/psa_arch_tests/add_inherit_toolchain.patch
@@ -29,7 +29,7 @@
  	endif()
 diff --git a/api-tests/tools/cmake/compiler/INHERIT.cmake b/api-tests/tools/cmake/compiler/INHERIT.cmake
 new file mode 100644
-index 0000000..014d667
+index 0000000..b2570c8
 --- /dev/null
 +++ b/api-tests/tools/cmake/compiler/INHERIT.cmake
 @@ -0,0 +1,19 @@
@@ -50,8 +50,8 @@
 +# * limitations under the License.
 +#**/
 +
-+
-+add_definitions(-DHOST_GCC_MISSING_CRYPTO_1_0=1)
++# Add any external definitions from the parent build
++add_definitions(${ARCH_TEST_EXTERNAL_DEFS})
 diff --git a/api-tests/tools/scripts/target_cfg/CMakeLists.txt b/api-tests/tools/scripts/target_cfg/CMakeLists.txt
 index 3210c5f..259eb9c 100644
 --- a/api-tests/tools/scripts/target_cfg/CMakeLists.txt
diff --git a/external/psa_arch_tests/psa_arch_tests.cmake b/external/psa_arch_tests/psa_arch_tests.cmake
index 97e49af..6edf38d 100644
--- a/external/psa_arch_tests/psa_arch_tests.cmake
+++ b/external/psa_arch_tests/psa_arch_tests.cmake
@@ -53,6 +53,7 @@
 			-DCMAKE_TOOLCHAIN_FILE=${TS_EXTERNAL_LIB_TOOLCHAIN_FILE}
 			-DPSA_INCLUDE_PATHS=${PSA_ARCH_TESTS_EXTERNAL_INCLUDE_PATHS}
 			-DSUITE=${TS_ARCH_TEST_SUITE}
+			-DARCH_TEST_EXTERNAL_DEFS=${TS_ARCH_TEST_EXTERNAL_DEFS}
 			-DCMAKE_VERBOSE_MAKEFILE=OFF
 			-DTARGET=tgt_dev_apis_linux
 			-GUnix\ Makefiles
diff --git a/external/t_cose/0002-add-tls3_0_0-compatibility.patch b/external/t_cose/0002-add-tls3_0_0-compatibility.patch
new file mode 100644
index 0000000..20a7d13
--- /dev/null
+++ b/external/t_cose/0002-add-tls3_0_0-compatibility.patch
@@ -0,0 +1,31 @@
+diff --git a/crypto_adapters/t_cose_psa_crypto.c b/crypto_adapters/t_cose_psa_crypto.c
+index 49c5b60..3aa7b58 100644
+--- a/crypto_adapters/t_cose_psa_crypto.c
++++ b/crypto_adapters/t_cose_psa_crypto.c
+@@ -99,7 +99,7 @@ static enum t_cose_err_t psa_status_to_t_cose_error_signing(psa_status_t err)
+            err == PSA_ERROR_INVALID_SIGNATURE   ? T_COSE_ERR_SIG_VERIFY :
+            err == PSA_ERROR_NOT_SUPPORTED       ? T_COSE_ERR_UNSUPPORTED_SIGNING_ALG:
+            err == PSA_ERROR_INSUFFICIENT_MEMORY ? T_COSE_ERR_INSUFFICIENT_MEMORY :
+-           err == PSA_ERROR_TAMPERING_DETECTED  ? T_COSE_ERR_TAMPERING_DETECTED :
++           err == PSA_ERROR_CORRUPTION_DETECTED ? T_COSE_ERR_TAMPERING_DETECTED :
+                                                   T_COSE_ERR_SIG_FAIL;
+ }
+ 
+@@ -152,7 +152,7 @@ t_cose_crypto_pub_key_verify(int32_t               cose_algorithm_id,
+      * Crypto ceases providing backwards compatibility then this code
+      * has to be changed to use psa_verify_hash().
+      */
+-    psa_result = psa_asymmetric_verify(verification_key_psa,
++    psa_result = psa_verify_hash(verification_key_psa,
+                                        psa_alg_id,
+                                        hash_to_verify.ptr,
+                                        hash_to_verify.len,
+@@ -212,7 +212,7 @@ t_cose_crypto_pub_key_sign(int32_t                cose_algorithm_id,
+      * providing backwards compatibility then this code has to be
+      * changed to use psa_sign_hash().
+      */
+-    psa_result = psa_asymmetric_sign(signing_key_psa,
++    psa_result = psa_sign_hash(signing_key_psa,
+                                      psa_alg_id,
+                                      hash_to_sign.ptr,
+                                      hash_to_sign.len,
diff --git a/external/t_cose/t_cose.cmake b/external/t_cose/t_cose.cmake
index 0af40bd..660824b 100644
--- a/external/t_cose/t_cose.cmake
+++ b/external/t_cose/t_cose.cmake
@@ -37,6 +37,7 @@
 
 	PATCH_COMMAND git stash
 		COMMAND git am ${CMAKE_CURRENT_LIST_DIR}/0001-add-install-definition.patch
+		COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/0002-add-tls3_0_0-compatibility.patch
 		COMMAND git reset HEAD~1
 
 )