Skip to content

Commit 64a3419

Browse files
authored
Merge pull request #15050 from rwalton-arm/TF-Mv1.4.0
Update to TF-M v1.4.0
2 parents eff8fda + a43103f commit 64a3419

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2142
-1116
lines changed

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ if("TFM_V8M" IN_LIST MBED_TARGET_LABELS)
1818
INTERFACE
1919
TARGET_TFM_V8M/src/cmsis_nvic_virtual.c
2020
TARGET_TFM_V8M/src/tfm_mbed_boot.c
21-
TARGET_TFM_V8M/src/tfm_ns_interface.c
2221
TARGET_TFM_V8M/src/tfm_psa_ns_api.c
2322
)
2423
endif()

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/TARGET_TFM_V8M/src/tfm_psa_ns_api.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
2+
* Copyright (c) 2018-2021, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*
@@ -8,6 +8,7 @@
88
#include "psa/client.h"
99
#include "tfm_ns_interface.h"
1010
#include "tfm_api.h"
11+
#include "tfm_psa_call_param.h"
1112

1213
/**** API functions ****/
1314

@@ -47,23 +48,17 @@ psa_status_t psa_call(psa_handle_t handle, int32_t type,
4748
psa_outvec *out_vec,
4849
size_t out_len)
4950
{
50-
/* FixMe: sanity check can be added to offload some NS thread checks from
51-
* TFM secure API
52-
*/
53-
54-
/* Due to v8M restrictions, TF-M NS API needs to add another layer of
55-
* serialization in order for NS to pass arguments to S
56-
*/
57-
const struct tfm_control_parameter_t ctrl_param = {
58-
.type = type,
59-
.in_len = in_len,
60-
.out_len = out_len,
61-
};
51+
if ((type > INT16_MAX) ||
52+
(type < INT16_MIN) ||
53+
(in_len > UINT8_MAX) ||
54+
(out_len > UINT8_MAX)) {
55+
return PSA_ERROR_PROGRAMMER_ERROR;
56+
}
6257

6358
return tfm_ns_interface_dispatch(
6459
(veneer_fn)tfm_psa_call_veneer,
6560
(uint32_t)handle,
66-
(uint32_t)&ctrl_param,
61+
PARAM_PACK(type, in_len, out_len),
6762
(uint32_t)in_vec,
6863
(uint32_t)out_vec);
6964
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
TF-Mv1.3.0
1+
TF-Mv1.4.0

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/psa/client.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
extern "C" {
1818
#endif
1919

20+
#ifndef IOVEC_LEN
21+
#define IOVEC_LEN(arr) ((uint32_t)(sizeof(arr)/sizeof(arr[0])))
22+
#endif
23+
2024
/*********************** PSA Client Macros and Types *************************/
2125

2226
/**
@@ -126,6 +130,14 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t version);
126130
/**
127131
* \brief Call an RoT Service on an established connection.
128132
*
133+
* \note FF-M 1.0 proposes 6 parameters for psa_call but the secure gateway ABI
134+
* support at most 4 parameters. TF-M chooses to encode 'in_len',
135+
* 'out_len', and 'type' into a 32-bit integer to improve efficiency.
136+
* Compared with struct-based encoding, this method saves extra memory
137+
* check and memory copy operation. The disadvantage is that the 'type'
138+
* range has to be reduced into a 16-bit integer. So with this encoding,
139+
* the valid range for 'type' is 0-32767.
140+
*
129141
* \param[in] handle A handle to an established connection.
130142
* \param[in] type The request type.
131143
* Must be zero( \ref PSA_IPC_CALL) or positive.

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/psa/crypto.h

Lines changed: 461 additions & 139 deletions
Large diffs are not rendered by default.

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/psa/crypto_client_struct.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ extern "C" {
3131
* data structure internally. */
3232
struct psa_client_key_attributes_s
3333
{
34+
uint16_t type;
35+
uint16_t bits;
3436
uint32_t lifetime;
3537
psa_key_id_t id;
36-
uint32_t alg;
3738
uint32_t usage;
38-
size_t bits;
39-
uint16_t type;
39+
uint32_t alg;
4040
};
4141

4242
#define PSA_CLIENT_KEY_ATTRIBUTES_INIT {0, 0, 0, 0, 0, 0}

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/psa/crypto_compat.h

Lines changed: 2 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -43,197 +43,6 @@ static inline int psa_key_handle_is_null(psa_key_handle_t handle)
4343
return(handle == 0);
4444
}
4545

46-
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
47-
48-
/*
49-
* Mechanism for declaring deprecated values
50-
*/
51-
#if defined(MBEDTLS_DEPRECATED_WARNING) && !defined(MBEDTLS_PSA_DEPRECATED)
52-
#define MBEDTLS_PSA_DEPRECATED __attribute__((deprecated))
53-
#else
54-
#define MBEDTLS_PSA_DEPRECATED
55-
#endif
56-
57-
typedef MBEDTLS_PSA_DEPRECATED size_t mbedtls_deprecated_size_t;
58-
typedef MBEDTLS_PSA_DEPRECATED psa_status_t mbedtls_deprecated_psa_status_t;
59-
typedef MBEDTLS_PSA_DEPRECATED psa_key_usage_t mbedtls_deprecated_psa_key_usage_t;
60-
typedef MBEDTLS_PSA_DEPRECATED psa_ecc_family_t mbedtls_deprecated_psa_ecc_family_t;
61-
typedef MBEDTLS_PSA_DEPRECATED psa_dh_family_t mbedtls_deprecated_psa_dh_family_t;
62-
typedef MBEDTLS_PSA_DEPRECATED psa_ecc_family_t psa_ecc_curve_t;
63-
typedef MBEDTLS_PSA_DEPRECATED psa_dh_family_t psa_dh_group_t;
64-
typedef MBEDTLS_PSA_DEPRECATED psa_algorithm_t mbedtls_deprecated_psa_algorithm_t;
65-
66-
#define PSA_KEY_TYPE_GET_CURVE PSA_KEY_TYPE_ECC_GET_FAMILY
67-
#define PSA_KEY_TYPE_GET_GROUP PSA_KEY_TYPE_DH_GET_FAMILY
68-
69-
#define MBEDTLS_DEPRECATED_CONSTANT( type, value ) \
70-
( (mbedtls_deprecated_##type) ( value ) )
71-
72-
/*
73-
* Deprecated PSA Crypto error code definitions (PSA Crypto API <= 1.0 beta2)
74-
*/
75-
#define PSA_ERROR_UNKNOWN_ERROR \
76-
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_GENERIC_ERROR )
77-
#define PSA_ERROR_OCCUPIED_SLOT \
78-
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_ALREADY_EXISTS )
79-
#define PSA_ERROR_EMPTY_SLOT \
80-
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_DOES_NOT_EXIST )
81-
#define PSA_ERROR_INSUFFICIENT_CAPACITY \
82-
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_INSUFFICIENT_DATA )
83-
#define PSA_ERROR_TAMPERING_DETECTED \
84-
MBEDTLS_DEPRECATED_CONSTANT( psa_status_t, PSA_ERROR_CORRUPTION_DETECTED )
85-
86-
/*
87-
* Deprecated PSA Crypto numerical encodings (PSA Crypto API <= 1.0 beta3)
88-
*/
89-
#define PSA_KEY_USAGE_SIGN \
90-
MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_SIGN_HASH )
91-
#define PSA_KEY_USAGE_VERIFY \
92-
MBEDTLS_DEPRECATED_CONSTANT( psa_key_usage_t, PSA_KEY_USAGE_VERIFY_HASH )
93-
94-
/*
95-
* Deprecated PSA Crypto size calculation macros (PSA Crypto API <= 1.0 beta3)
96-
*/
97-
#define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE \
98-
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGNATURE_MAX_SIZE )
99-
#define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) \
100-
MBEDTLS_DEPRECATED_CONSTANT( size_t, PSA_SIGN_OUTPUT_SIZE( key_type, key_bits, alg ) )
101-
102-
/*
103-
* Deprecated PSA Crypto function names (PSA Crypto API <= 1.0 beta3)
104-
*/
105-
MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_sign( psa_key_handle_t key,
106-
psa_algorithm_t alg,
107-
const uint8_t *hash,
108-
size_t hash_length,
109-
uint8_t *signature,
110-
size_t signature_size,
111-
size_t *signature_length );
112-
113-
MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_verify( psa_key_handle_t key,
114-
psa_algorithm_t alg,
115-
const uint8_t *hash,
116-
size_t hash_length,
117-
const uint8_t *signature,
118-
size_t signature_length );
119-
120-
121-
/*
122-
* Size-specific elliptic curve families.
123-
*/
124-
#define PSA_ECC_CURVE_SECP160K1 \
125-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
126-
#define PSA_ECC_CURVE_SECP192K1 \
127-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
128-
#define PSA_ECC_CURVE_SECP224K1 \
129-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
130-
#define PSA_ECC_CURVE_SECP256K1 \
131-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
132-
#define PSA_ECC_CURVE_SECP160R1 \
133-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
134-
#define PSA_ECC_CURVE_SECP192R1 \
135-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
136-
#define PSA_ECC_CURVE_SECP224R1 \
137-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
138-
#define PSA_ECC_CURVE_SECP256R1 \
139-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
140-
#define PSA_ECC_CURVE_SECP384R1 \
141-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
142-
#define PSA_ECC_CURVE_SECP521R1 \
143-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
144-
#define PSA_ECC_CURVE_SECP160R2 \
145-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 )
146-
#define PSA_ECC_CURVE_SECT163K1 \
147-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
148-
#define PSA_ECC_CURVE_SECT233K1 \
149-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
150-
#define PSA_ECC_CURVE_SECT239K1 \
151-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
152-
#define PSA_ECC_CURVE_SECT283K1 \
153-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
154-
#define PSA_ECC_CURVE_SECT409K1 \
155-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
156-
#define PSA_ECC_CURVE_SECT571K1 \
157-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
158-
#define PSA_ECC_CURVE_SECT163R1 \
159-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
160-
#define PSA_ECC_CURVE_SECT193R1 \
161-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
162-
#define PSA_ECC_CURVE_SECT233R1 \
163-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
164-
#define PSA_ECC_CURVE_SECT283R1 \
165-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
166-
#define PSA_ECC_CURVE_SECT409R1 \
167-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
168-
#define PSA_ECC_CURVE_SECT571R1 \
169-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
170-
#define PSA_ECC_CURVE_SECT163R2 \
171-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
172-
#define PSA_ECC_CURVE_SECT193R2 \
173-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
174-
#define PSA_ECC_CURVE_BRAINPOOL_P256R1 \
175-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
176-
#define PSA_ECC_CURVE_BRAINPOOL_P384R1 \
177-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
178-
#define PSA_ECC_CURVE_BRAINPOOL_P512R1 \
179-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
180-
#define PSA_ECC_CURVE_CURVE25519 \
181-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
182-
#define PSA_ECC_CURVE_CURVE448 \
183-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
184-
185-
/*
186-
* Curves that changed name due to PSA specification.
187-
*/
188-
#define PSA_ECC_CURVE_SECP_K1 \
189-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_K1 )
190-
#define PSA_ECC_CURVE_SECP_R1 \
191-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R1 )
192-
#define PSA_ECC_CURVE_SECP_R2 \
193-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECP_R2 )
194-
#define PSA_ECC_CURVE_SECT_K1 \
195-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_K1 )
196-
#define PSA_ECC_CURVE_SECT_R1 \
197-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R1 )
198-
#define PSA_ECC_CURVE_SECT_R2 \
199-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_SECT_R2 )
200-
#define PSA_ECC_CURVE_BRAINPOOL_P_R1 \
201-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_BRAINPOOL_P_R1 )
202-
#define PSA_ECC_CURVE_MONTGOMERY \
203-
MBEDTLS_DEPRECATED_CONSTANT( psa_ecc_family_t, PSA_ECC_FAMILY_MONTGOMERY )
204-
205-
/*
206-
* Finite-field Diffie-Hellman families.
207-
*/
208-
#define PSA_DH_GROUP_FFDHE2048 \
209-
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
210-
#define PSA_DH_GROUP_FFDHE3072 \
211-
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
212-
#define PSA_DH_GROUP_FFDHE4096 \
213-
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
214-
#define PSA_DH_GROUP_FFDHE6144 \
215-
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
216-
#define PSA_DH_GROUP_FFDHE8192 \
217-
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
218-
219-
/*
220-
* Diffie-Hellman families that changed name due to PSA specification.
221-
*/
222-
#define PSA_DH_GROUP_RFC7919 \
223-
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_RFC7919 )
224-
#define PSA_DH_GROUP_CUSTOM \
225-
MBEDTLS_DEPRECATED_CONSTANT( psa_dh_family_t, PSA_DH_FAMILY_CUSTOM )
226-
227-
/*
228-
* Deprecated PSA Crypto stream cipher algorithms (PSA Crypto API <= 1.0 beta3)
229-
*/
230-
#define PSA_ALG_ARC4 \
231-
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER)
232-
#define PSA_ALG_CHACHA20 \
233-
MBEDTLS_DEPRECATED_CONSTANT(psa_algorithm_t, PSA_ALG_STREAM_CIPHER)
234-
235-
#endif /* MBEDTLS_DEPRECATED_REMOVED */
236-
23746
/** Open a handle to an existing persistent key.
23847
*
23948
* Open a handle to a persistent key. A key is persistent if it was created
@@ -287,6 +96,8 @@ MBEDTLS_PSA_DEPRECATED psa_status_t psa_asymmetric_verify( psa_key_handle_t key,
28796
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
28897
* \retval #PSA_ERROR_CORRUPTION_DETECTED
28998
* \retval #PSA_ERROR_STORAGE_FAILURE
99+
* \retval #PSA_ERROR_DATA_INVALID
100+
* \retval #PSA_ERROR_DATA_CORRUPT
290101
* \retval #PSA_ERROR_BAD_STATE
291102
* The library has not been previously initialized by psa_crypto_init().
292103
* It is implementation-dependent whether a failure to initialize

0 commit comments

Comments
 (0)