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/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
)