Skip to content

Commit 168080d

Browse files
gaborgvargaadeaarm
authored andcommitted
t_cose: Updating Patch 0007
The issue addressed by this patch has been fixed in the upstream repository. The associated pull request has been reviewed, approved, and merged. This update replaces the previous patch file with the latest version, ensuring that the TF-M patch remains fully in sync with the upstream t_cose repository. Signed-off-by: G. Varga, Gabor <Gabor.G.Varga@arm.com> Change-Id: I9cbfbae69a142ed23e2a2d44070b1cfa02b5d5dd
1 parent 28902bc commit 168080d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/ext/t_cose/0007-Refining-signature-buffer-size.patch

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From efc0be2279a82664ed2d87ad51573e39222b8c1c Mon Sep 17 00:00:00 2001
1+
From 12c9638cef18730910ab8afc0cf8dc999ba6c7d9 Mon Sep 17 00:00:00 2001
22
From: "G. Varga, Gabor" <Gabor.G.Varga@arm.com>
3-
Date: Wed, 9 Jul 2025 14:21:03 +0200
3+
Date: Tue, 29 Jul 2025 14:17:06 +0200
44
Subject: [PATCH] Refining signature buffer size
55

66
When using t_cose with the PSA Crypto adaptor layer,
@@ -13,29 +13,29 @@ inside the PSA Crypto service and can exceed internal limits like
1313
CRYPTO_IOVEC_BUFFER_SIZE.
1414

1515
This patch addresses the issue by computing the expected signature size
16-
using t_cose_crypto_sig_size() and passing the smaller of the two sizes
17-
to psa_sign_hash(). If the signature size query fails, the original
18-
buffer size is used as a fallback to maintain compatibility.
16+
using t_cose_crypto_sig_size() and validating it against the actual size
17+
of the provided buffer. If the expected size exceeds the available
18+
buffer length, the function returns T_COSE_ERR_SIG_BUFFER_SIZE,
19+
preventing a potentially unsafe call into psa_sign_hash().
1920

2021
Signed-off-by: G. Varga, Gabor <Gabor.G.Varga@arm.com>
21-
Change-Id: I97ab1633b6acf6de25bdbf4cf76c3666568c53c1
22+
Change-Id: If70d36e930decb05a2bd45c2b31edf74a5cbea9f
2223
---
23-
crypto_adapters/t_cose_psa_crypto.c | 13 ++++++++++++-
24-
1 file changed, 12 insertions(+), 1 deletion(-)
24+
crypto_adapters/t_cose_psa_crypto.c | 12 +++++++++++-
25+
1 file changed, 11 insertions(+), 1 deletion(-)
2526

2627
diff --git a/crypto_adapters/t_cose_psa_crypto.c b/crypto_adapters/t_cose_psa_crypto.c
27-
index 2095002..018c52b 100644
28+
index 2095002..0d32cba 100644
2829
--- a/crypto_adapters/t_cose_psa_crypto.c
2930
+++ b/crypto_adapters/t_cose_psa_crypto.c
30-
@@ -239,6 +239,17 @@ t_cose_crypto_sign(int32_t cose_algorithm_id,
31+
@@ -239,6 +239,16 @@ t_cose_crypto_sign(int32_t cose_algorithm_id,
3132

3233
signing_key_psa = (psa_key_handle_t)signing_key.key.handle;
3334

3435
+ /* Determine signature size and validate against buffer size */
3536
+ return_value = t_cose_crypto_sig_size(cose_algorithm_id, signing_key, &signature_len);
3637
+ if (return_value != T_COSE_SUCCESS) {
37-
+ /* Fallback: use entire buffer */
38-
+ signature_len = signature_buffer.len;
38+
+ goto Done;
3939
+ } else if (signature_len > signature_buffer.len) {
4040
+ /* Determined size too large for provided buffer */
4141
+ return_value = T_COSE_ERR_SIG_BUFFER_SIZE;
@@ -45,7 +45,7 @@ index 2095002..018c52b 100644
4545
/* It is assumed that this call is checking the signature_buffer
4646
* length and won't write off the end of it.
4747
*/
48-
@@ -248,7 +259,7 @@ t_cose_crypto_sign(int32_t cose_algorithm_id,
48+
@@ -248,7 +258,7 @@ t_cose_crypto_sign(int32_t cose_algorithm_id,
4949
hash_to_sign.ptr,
5050
hash_to_sign.len,
5151
signature_buffer.ptr, /* Sig buf */

0 commit comments

Comments
 (0)