Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>

From 9fb18f0cfba8f97fa71a5e7e7e3e31a43692a8e0 Mon Sep 17 00:00:00 2001
From: Julian Hall <julian.hall@arm.com>
Date: Tue, 11 Jan 2022 09:43:52 +0000
Subject: [PATCH 10/15] Peg to updated t_cose version fc3a4b2c

The current version of TS fails to build due to a regression introduced
by a new t_cose version in the upstream project.
The issue is caused by the t_cose external component incorrectly using
tip of master as the upstream version id, which makes strict dependency
control impossible. Change the upstream version id to an SHA, to enable
controlling compatibility issues introduced by future upstream updates.

At the same time update the dependency to the current latest version.
The upstream project is now compatile with mbedtls 3.0.0 API changes
so the previously required compatibility patch has been removed.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I9491a5210904cc369846da2af45b0f7e5913bed8
---
 .../0002-add-tls3_0_0-compatibility.patch     | 31 -------------------
 external/t_cose/t_cose.cmake                  |  5 ++-
 2 files changed, 2 insertions(+), 34 deletions(-)
 delete mode 100644 external/t_cose/0002-add-tls3_0_0-compatibility.patch

diff --git a/external/t_cose/0002-add-tls3_0_0-compatibility.patch b/external/t_cose/0002-add-tls3_0_0-compatibility.patch
deleted file mode 100644
index 20a7d131..00000000
--- a/external/t_cose/0002-add-tls3_0_0-compatibility.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-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 660824bd..9321466f 100644
--- a/external/t_cose/t_cose.cmake
+++ b/external/t_cose/t_cose.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -16,7 +16,7 @@ endif()
 
 # External component details
 set(T_COSE_URL "https://github.com/laurencelundblade/t_cose.git" CACHE STRING "t_cose repository URL")
-set(T_COSE_REFSPEC "master" CACHE STRING "t_cose git refspec")
+set(T_COSE_REFSPEC "fc3a4b2c7196ff582e8242de8bd4a1bc4eec577f" CACHE STRING "t_cose git refspec")
 set(T_COSE_INSTALL_PATH "${CMAKE_CURRENT_BINARY_DIR}/t_cose_install" CACHE PATH "t_cose installation directory")
 set(T_COSE_PACKAGE_PATH "${T_COSE_INSTALL_PATH}/libt_cose/cmake" CACHE PATH "t_cose CMake package directory")
 
@@ -37,7 +37,6 @@ FetchContent_Declare(
 
 	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
 
 )
-- 
2.25.1

