17
17
#define mbedtls_free free
18
18
#endif
19
19
// ------------------------- Globals ---------------------------
20
- static psa_spm_init_refence_counter = 0 ;
20
+ static uint8_t psa_spm_init_refence_counter = 0 ;
21
21
22
- typede f struct {
22
+ typedef struct {
23
23
psa_key_slot_t key_slot ;
24
24
int32_t owner_pid ;
25
25
} spm_crpyto_key_slot_t ;
@@ -44,7 +44,7 @@ static psa_status_t insert_key_into_spm_slot(psa_handle_t handle, psa_key_slot_t
44
44
45
45
static psa_status_t check_spm_key_acl (psa_handle_t handle , psa_key_slot_t key_slot )
46
46
{
47
- uint32_t current_pid = psa_identity (handle );
47
+ int32_t current_pid = psa_identity (handle );
48
48
49
49
for (uint32_t i = 0 ; i < sizeof (spm_key_slots ) / sizeof (spm_key_slots [0 ]); i ++ ) {
50
50
if ((spm_key_slots [i ].key_slot == key_slot ) &&
@@ -57,7 +57,7 @@ static psa_status_t check_spm_key_acl(psa_handle_t handle, psa_key_slot_t key_sl
57
57
58
58
static void free_spm_key_slot (psa_handle_t handle , psa_key_slot_t key_slot )
59
59
{
60
- uint32_t current_pid = psa_identity (handle );
60
+ int32_t current_pid = psa_identity (handle );
61
61
62
62
for (uint32_t i = 0 ; i < sizeof (spm_key_slots ) / sizeof (spm_key_slots [0 ]); i ++ ) {
63
63
if ((spm_key_slots [i ].key_slot == key_slot ) &&
@@ -181,7 +181,7 @@ static void psa_mac_operation( void )
181
181
case PSA_MAC_SIGN_SETUP :
182
182
{
183
183
status = check_spm_key_acl (msg .handle , psa_crypto .key );
184
- if (staus == PSA_SUCCESS ) {
184
+ if (status == PSA_SUCCESS ) {
185
185
status = psa_mac_sign_setup ( msg .rhandle ,
186
186
psa_crypto .key ,
187
187
psa_crypto .alg );
@@ -192,7 +192,7 @@ static void psa_mac_operation( void )
192
192
case PSA_MAC_VERIFY_SETUP :
193
193
{
194
194
status = check_spm_key_acl (msg .handle , psa_crypto .key );
195
- if (staus == PSA_SUCCESS ) {
195
+ if (status == PSA_SUCCESS ) {
196
196
status = psa_mac_verify_setup ( msg .rhandle ,
197
197
psa_crypto .key ,
198
198
psa_crypto .alg );
@@ -524,7 +524,7 @@ static void psa_asymmetric_operation( void )
524
524
SPM_PANIC ("SPM read length mismatch" );
525
525
}
526
526
status = check_spm_key_acl (msg .handle , psa_crypto .key );
527
- if (staus == PSA_SUCCESS ) {
527
+ if (status == PSA_SUCCESS ) {
528
528
status = psa_asymmetric_sign ( psa_crypto .key ,
529
529
psa_crypto .alg ,
530
530
hash ,
@@ -572,7 +572,7 @@ static void psa_asymmetric_operation( void )
572
572
SPM_PANIC ("SPM read length mismatch" );
573
573
}
574
574
status = check_spm_key_acl (msg .handle , psa_crypto .key );
575
- if (staus == PSA_SUCCESS ) {
575
+ if (status == PSA_SUCCESS ) {
576
576
status = psa_asymmetric_verify ( psa_crypto .key ,
577
577
psa_crypto .alg ,
578
578
hash ,
@@ -617,7 +617,7 @@ static void psa_asymmetric_operation( void )
617
617
break ;
618
618
}
619
619
status = check_spm_key_acl (msg .handle , psa_crypto .key );
620
- if (staus == PSA_SUCCESS ) {
620
+ if (status == PSA_SUCCESS ) {
621
621
if ( psa_crypto .func == PSA_ASYMMETRIC_ENCRYPT )
622
622
status = psa_asymmetric_encrypt ( psa_crypto .key ,
623
623
psa_crypto .alg ,
@@ -726,7 +726,7 @@ static void psa_aead_operation()
726
726
break ;
727
727
}
728
728
status = check_spm_key_acl (msg .handle , psa_crypto .key );
729
- if (staus == PSA_SUCCESS ) {
729
+ if (status == PSA_SUCCESS ) {
730
730
if ( psa_crypto .func == PSA_AEAD_ENCRYPT )
731
731
status = psa_aead_encrypt ( psa_crypto .key ,
732
732
psa_crypto .alg ,
@@ -820,7 +820,7 @@ static void psa_symmetric_operation( void )
820
820
case PSA_CIPHER_ENCRYPT_SETUP :
821
821
{
822
822
status = check_spm_key_acl (msg .handle , psa_crypto_ipc .key );
823
- if (staus == PSA_SUCCESS ) {
823
+ if (status == PSA_SUCCESS ) {
824
824
status = psa_cipher_encrypt_setup ( msg .rhandle ,
825
825
psa_crypto_ipc .key ,
826
826
psa_crypto_ipc .alg );
@@ -830,7 +830,7 @@ static void psa_symmetric_operation( void )
830
830
case PSA_CIPHER_DECRYPT_SETUP :
831
831
{
832
832
status = check_spm_key_acl (msg .handle , psa_crypto_ipc .key );
833
- if (staus == PSA_SUCCESS ) {
833
+ if (status == PSA_SUCCESS ) {
834
834
status = psa_cipher_decrypt_setup ( msg .rhandle ,
835
835
psa_crypto_ipc .key ,
836
836
psa_crypto_ipc .alg );
@@ -1002,7 +1002,7 @@ static void psa_key_management_operation( void )
1002
1002
size_t lifetime_length = msg .out_size [0 ];
1003
1003
psa_key_lifetime_t lifetime ;
1004
1004
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1005
- if (staus == PSA_SUCCESS ) {
1005
+ if (status == PSA_SUCCESS ) {
1006
1006
status = psa_get_key_lifetime ( psa_key_mng .key ,
1007
1007
& lifetime );
1008
1008
}
@@ -1025,7 +1025,7 @@ static void psa_key_management_operation( void )
1025
1025
SPM_PANIC ("SPM read length mismatch" );
1026
1026
}
1027
1027
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1028
- if (staus == PSA_SUCCESS ) {
1028
+ if (status == PSA_SUCCESS ) {
1029
1029
status = psa_set_key_lifetime ( psa_key_mng .key , lifetime );
1030
1030
}
1031
1031
break ;
@@ -1042,7 +1042,7 @@ static void psa_key_management_operation( void )
1042
1042
SPM_PANIC ("SPM read length mismatch" );
1043
1043
}
1044
1044
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1045
- if (staus == PSA_SUCCESS ) {
1045
+ if (status == PSA_SUCCESS ) {
1046
1046
status = psa_set_key_policy (psa_key_mng .key , & policy );
1047
1047
}
1048
1048
break ;
@@ -1052,7 +1052,7 @@ static void psa_key_management_operation( void )
1052
1052
size_t policy_size = msg .out_size [0 ];
1053
1053
psa_key_policy_t policy ;
1054
1054
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1055
- if (staus == PSA_SUCCESS ) {
1055
+ if (status == PSA_SUCCESS ) {
1056
1056
status = psa_get_key_policy ( psa_key_mng .key , & policy );
1057
1057
}
1058
1058
if ( status == PSA_SUCCESS )
@@ -1077,11 +1077,11 @@ static void psa_key_management_operation( void )
1077
1077
SPM_PANIC ("SPM read length mismatch" );
1078
1078
}
1079
1079
status = insert_key_into_spm_slot (msg .handle , psa_key_mng .key );
1080
- if (staus == PSA_SUCCESS ) {
1080
+ if (status == PSA_SUCCESS ) {
1081
1081
status = psa_import_key ( psa_key_mng .key ,
1082
1082
psa_key_mng .type ,
1083
1083
key , key_length );
1084
- if (staus != PSA_SUCCESS ) {
1084
+ if (status != PSA_SUCCESS ) {
1085
1085
free_spm_key_slot (msg .handle , psa_key_mng .key );
1086
1086
}
1087
1087
}
@@ -1091,9 +1091,9 @@ static void psa_key_management_operation( void )
1091
1091
case PSA_DESTROY_KEY :
1092
1092
{
1093
1093
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1094
- if (staus == PSA_SUCCESS ) {
1094
+ if (status == PSA_SUCCESS ) {
1095
1095
status = psa_destroy_key ( psa_key_mng .key );
1096
- if (staus == PSA_SUCCESS ) {
1096
+ if (status == PSA_SUCCESS ) {
1097
1097
free_spm_key_slot (msg .handle , psa_key_mng .key );
1098
1098
}
1099
1099
}
@@ -1104,7 +1104,7 @@ static void psa_key_management_operation( void )
1104
1104
psa_key_type_t type ;
1105
1105
size_t bits ;
1106
1106
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1107
- if (staus == PSA_SUCCESS ) {
1107
+ if (status == PSA_SUCCESS ) {
1108
1108
status = psa_get_key_information ( psa_key_mng .key ,
1109
1109
& type , & bits );
1110
1110
}
@@ -1129,7 +1129,7 @@ static void psa_key_management_operation( void )
1129
1129
break ;
1130
1130
}
1131
1131
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1132
- if (staus == PSA_SUCCESS ) {
1132
+ if (status == PSA_SUCCESS ) {
1133
1133
status = psa_export_key ( psa_key_mng .key , key ,
1134
1134
key_length , & data_length );
1135
1135
}
@@ -1152,7 +1152,7 @@ static void psa_key_management_operation( void )
1152
1152
break ;
1153
1153
}
1154
1154
status = check_spm_key_acl (msg .handle , psa_key_mng .key );
1155
- if (staus == PSA_SUCCESS ) {
1155
+ if (status == PSA_SUCCESS ) {
1156
1156
status = psa_export_public_key ( psa_key_mng .key , key ,
1157
1157
key_length , & data_length );
1158
1158
}
@@ -1196,12 +1196,12 @@ static void psa_key_management_operation( void )
1196
1196
}
1197
1197
}
1198
1198
status = insert_key_into_spm_slot (msg .handle , psa_key_mng .key );
1199
- if (staus == PSA_SUCCESS ) {
1199
+ if (status == PSA_SUCCESS ) {
1200
1200
status = psa_generate_key ( psa_key_mng .key ,
1201
1201
psa_key_mng .type ,
1202
1202
bits ,
1203
1203
parameter , parameter_size );
1204
- if (staus != PSA_SUCCESS ) {
1204
+ if (status != PSA_SUCCESS ) {
1205
1205
free_spm_key_slot (msg .handle , psa_key_mng .key );
1206
1206
}
1207
1207
}
@@ -1419,10 +1419,10 @@ void psa_crypto_generator_operations( void )
1419
1419
SPM_PANIC ("SPM read length mismatch" );
1420
1420
}
1421
1421
status = insert_key_into_spm_slot (msg .handle , psa_crypto_ipc .key );
1422
- if (staus == PSA_SUCCESS ) {
1422
+ if (status == PSA_SUCCESS ) {
1423
1423
status = psa_generator_import_key ( psa_crypto_ipc .key , type ,
1424
1424
bits , msg .rhandle );
1425
- if (staus != PSA_SUCCESS ) {
1425
+ if (status != PSA_SUCCESS ) {
1426
1426
free_spm_key_slot (msg .handle , psa_crypto_ipc .key );
1427
1427
}
1428
1428
}
@@ -1466,7 +1466,7 @@ void psa_crypto_generator_operations( void )
1466
1466
}
1467
1467
1468
1468
status = check_spm_key_acl (msg .handle , psa_crypto_ipc .key );
1469
- if (staus == PSA_SUCCESS ) {
1469
+ if (status == PSA_SUCCESS ) {
1470
1470
status = psa_key_derivation ( msg .rhandle , psa_crypto_ipc .key ,
1471
1471
psa_crypto_ipc .alg ,
1472
1472
salt ,
@@ -1507,7 +1507,6 @@ void psa_crypto_generator_operations( void )
1507
1507
void part_main (void * ptr )
1508
1508
{
1509
1509
uint32_t signals = 0 ;
1510
- psa_status_t status = PSA_SUCCESS ;
1511
1510
1512
1511
while (1 ) {
1513
1512
signals = psa_wait_any ( PSA_BLOCK );
0 commit comments