@@ -97,6 +97,16 @@ static inline psa_status_t get_hash_clone(size_t index, int32_t partition_id,
97
97
return PSA_SUCCESS ;
98
98
}
99
99
100
+ static inline void assemble_psa_key_id (psa_key_id_t * id , size_t bytes_read , int32_t partition_id )
101
+ {
102
+ /* move the 32 bit client representation of psa_key_id_t to the upper 32 bits of the 64 bit
103
+ * server representation of psa_key_id_t.
104
+ * bytes_read is expected to be 4 bytes, as this is the size of psa_key_id_t on the client side. */
105
+ * id <<= bytes_read * 8 ;
106
+ /* the lower 32 bits of the server representation of psa_key_id_t represent the calling partition id. */
107
+ * id |= (uint32_t )partition_id ;
108
+ }
109
+
100
110
// ------------------------- Partition's Main Thread ---------------------------
101
111
static void psa_crypto_init_operation (void )
102
112
{
@@ -1166,6 +1176,13 @@ static void psa_key_management_operation(void)
1166
1176
SPM_PANIC ("SPM read length mismatch" );
1167
1177
}
1168
1178
1179
+ if (id == 0 ) {
1180
+ status = PSA_ERROR_INVALID_ARGUMENT ;
1181
+ break ;
1182
+ }
1183
+
1184
+ assemble_psa_key_id (& id , msg .in_size [1 ], psa_identity (msg .handle ));
1185
+
1169
1186
status = psa_create_key (psa_key_mng .lifetime , id , & psa_key_mng .handle );
1170
1187
if (status == PSA_SUCCESS ) {
1171
1188
psa_write (msg .handle , 0 , & psa_key_mng .handle , sizeof (psa_key_mng .handle ));
@@ -1181,6 +1198,13 @@ static void psa_key_management_operation(void)
1181
1198
SPM_PANIC ("SPM read length mismatch" );
1182
1199
}
1183
1200
1201
+ if (id == 0 ) {
1202
+ status = PSA_ERROR_INVALID_ARGUMENT ;
1203
+ break ;
1204
+ }
1205
+
1206
+ assemble_psa_key_id (& id , msg .in_size [1 ], psa_identity (msg .handle ));
1207
+
1184
1208
status = psa_open_key (psa_key_mng .lifetime , id , & psa_key_mng .handle );
1185
1209
if (status == PSA_SUCCESS ) {
1186
1210
psa_write (msg .handle , 0 , & psa_key_mng .handle , sizeof (psa_key_mng .handle ));
0 commit comments