Tamas Ban | a71bc97 | 2024-09-16 13:57:38 +0200 | [diff] [blame^] | 1 | From 1052a755db3b99a52babcfbf4dae711da8e4fd16 Mon Sep 17 00:00:00 2001 |
| 2 | From: David Vincze <david.vincze@arm.com> |
| 3 | Date: Wed, 15 Jan 2025 19:31:41 +0000 |
| 4 | Subject: [PATCH] Remove or disable unused functions in PSA Crypto layer |
| 5 | |
| 6 | - Remove unused HKDF function from the PSA Crypto adaptor |
| 7 | layer to prevent build errors due to disabled MbedTLS |
| 8 | support that it depends on. HKDF is currently not |
| 9 | supported properly by the PSA Crypto adaptor layer. |
| 10 | - Disable unused functions to avoid unnecessary build |
| 11 | dependencies. |
| 12 | |
| 13 | --- |
| 14 | crypto_adapters/t_cose_psa_crypto.c | 53 ----------------------------- |
| 15 | crypto_adapter s/t_cose_psa_crypto.h | 6 ++-- |
| 16 | 2 files changed, 3 insertions(+), 56 deletions(-) |
| 17 | |
| 18 | diff --git a/crypto_adapters/t_cose_psa_crypto.c b/crypto_adapters/t_cose_psa_crypto.c |
| 19 | index 80d1961..2095002 100644 |
| 20 | --- a/crypto_adapters/t_cose_psa_crypto.c |
| 21 | +++ b/crypto_adapters/t_cose_psa_crypto.c |
| 22 | @@ -43,9 +43,6 @@ |
| 23 | #include <mbedtls/nist_kw.h> |
| 24 | #endif /* T_COSE_DISABLE_KEYWRAP */ |
| 25 | |
| 26 | -#include <mbedtls/hkdf.h> |
| 27 | -#include <mbedtls/md.h> |
| 28 | - |
| 29 | #include "t_cose_util.h" |
| 30 | #include "t_cose_psa_crypto.h" |
| 31 | |
| 32 | @@ -1600,56 +1597,6 @@ t_cose_crypto_ecdh(struct t_cose_key private_key, |
| 33 | |
| 34 | |
| 35 | |
| 36 | - |
| 37 | -/* |
| 38 | - * See documentation in t_cose_crypto.h |
| 39 | - */ |
| 40 | -enum t_cose_err_t |
| 41 | -t_cose_crypto_hkdf(const int32_t cose_hash_algorithm_id, |
| 42 | - const struct q_useful_buf_c salt, |
| 43 | - const struct q_useful_buf_c ikm, |
| 44 | - const struct q_useful_buf_c info, |
| 45 | - const struct q_useful_buf okm_buffer) |
| 46 | -{ |
| 47 | - int psa_result; |
| 48 | - const mbedtls_md_info_t *md_info; |
| 49 | - mbedtls_md_type_t hash_type; |
| 50 | - |
| 51 | - switch(cose_hash_algorithm_id) { |
| 52 | - case T_COSE_ALGORITHM_SHA_256: |
| 53 | - hash_type = MBEDTLS_MD_SHA256; |
| 54 | - break; |
| 55 | - case T_COSE_ALGORITHM_SHA_384: |
| 56 | - hash_type = MBEDTLS_MD_SHA384; |
| 57 | - break; |
| 58 | - case T_COSE_ALGORITHM_SHA_512: |
| 59 | - hash_type = MBEDTLS_MD_SHA512; |
| 60 | - break; |
| 61 | - default: |
| 62 | - hash_type = MBEDTLS_MD_NONE; |
| 63 | - break; |
| 64 | - } |
| 65 | - |
| 66 | - md_info = mbedtls_md_info_from_type(hash_type); |
| 67 | - if(md_info == NULL) { |
| 68 | - return T_COSE_ERR_UNSUPPORTED_HASH; |
| 69 | - } |
| 70 | - |
| 71 | - psa_result = mbedtls_hkdf(md_info, |
| 72 | - salt.ptr, salt.len, |
| 73 | - ikm.ptr, ikm.len, |
| 74 | - info.ptr, info.len, |
| 75 | - okm_buffer.ptr, okm_buffer.len); |
| 76 | - if(psa_result != PSA_SUCCESS) { |
| 77 | - return T_COSE_ERR_HKDF_FAIL; |
| 78 | - } |
| 79 | - |
| 80 | - return T_COSE_SUCCESS; |
| 81 | -} |
| 82 | - |
| 83 | - |
| 84 | - |
| 85 | - |
| 86 | /* |
| 87 | * See documentation in t_cose_crypto.h |
| 88 | */ |
| 89 | diff --git a/crypto_adapters/t_cose_psa_crypto.h b/crypto_adapters/t_cose_psa_crypto.h |
| 90 | index bf4963c..5718f81 100644 |
| 91 | --- a/crypto_adapters/t_cose_psa_crypto.h |
| 92 | +++ b/crypto_adapters/t_cose_psa_crypto.h |
| 93 | @@ -14,9 +14,9 @@ |
| 94 | |
| 95 | #include <psa/crypto.h> |
| 96 | |
| 97 | -#define PSA_CRYPTO_HAS_RESTARTABLE_SIGNING \ |
| 98 | - ((MBEDTLS_VERSION_MAJOR == 3 && MBEDTLS_VERSION_MINOR >= 4) || \ |
| 99 | - MBEDTLS_VERSION_MAJOR > 3) |
| 100 | +/* #define PSA_CRYPTO_HAS_RESTARTABLE_SIGNING \ |
| 101 | + * ((MBEDTLS_VERSION_MAJOR == 3 && MBEDTLS_VERSION_MINOR >= 4) || \ |
| 102 | + * MBEDTLS_VERSION_MAJOR > 3) */ |
| 103 | |
| 104 | #if PSA_CRYPTO_HAS_RESTARTABLE_SIGNING |
| 105 | struct t_cose_psa_crypto_context { |
| 106 | -- |
| 107 | 2.34.1 |