Skip to content

Commit 63242cf

Browse files
author
Cruz Monrreal
authored
Merge pull request #9939 from kfnta/fix_for_secure_partition
Fix for secure partition
2 parents 120e43e + f106718 commit 63242cf

File tree

6 files changed

+73934
-73883
lines changed

6 files changed

+73934
-73883
lines changed

components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_partition.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ static void psa_asymmetric_operation(void)
641641

642642
psa_write(msg.handle, 1,
643643
&signature_length, sizeof(signature_length));
644+
mbedtls_free(hash);
644645
mbedtls_free(signature);
645646
break;
646647
}
@@ -663,6 +664,7 @@ static void psa_asymmetric_operation(void)
663664
hash = mbedtls_calloc(1, msg.in_size[2]);
664665
if (hash == NULL) {
665666
status = PSA_ERROR_INSUFFICIENT_MEMORY;
667+
mbedtls_free(signature);
666668
break;
667669
}
668670

@@ -1200,20 +1202,19 @@ static void psa_key_management_operation(void)
12001202
}
12011203

12021204
case PSA_GET_KEY_INFORMATION: {
1203-
psa_key_type_t type;
1204-
size_t bits;
1205+
psa_key_type_t type = 0;
1206+
size_t bits = 0;
12051207

1206-
if (!psa_crypto_access_control_is_handle_permitted(psa_key_mng.handle,
1207-
partition_id)) {
1208+
if (psa_crypto_access_control_is_handle_permitted(psa_key_mng.handle,
1209+
partition_id)) {
1210+
status = psa_get_key_information(psa_key_mng.handle, &type, &bits);
1211+
} else {
12081212
status = PSA_ERROR_INVALID_HANDLE;
1209-
break;
12101213
}
12111214

1212-
status = psa_get_key_information(psa_key_mng.handle,
1213-
&type, &bits);
1214-
if (msg.out_size[0] >= sizeof(psa_key_type_t))
1215-
psa_write(msg.handle, 0,
1216-
&type, sizeof(psa_key_type_t));
1215+
if (msg.out_size[0] >= sizeof(psa_key_type_t)) {
1216+
psa_write(msg.handle, 0, &type, sizeof(psa_key_type_t));
1217+
}
12171218
if (msg.out_size[1] >= sizeof(size_t)) {
12181219
psa_write(msg.handle, 1, &bits, sizeof(size_t));
12191220
}
@@ -1637,6 +1638,8 @@ void psa_crypto_generator_operations(void)
16371638
label,
16381639
msg.in_size[2],//label length
16391640
psa_crypto_ipc.capacity);
1641+
mbedtls_free(label);
1642+
mbedtls_free(salt);
16401643

16411644
break;
16421645
}
@@ -1666,7 +1669,7 @@ void psa_crypto_generator_operations(void)
16661669
private_key,
16671670
msg.in_size[1],//private_key length
16681671
psa_crypto_ipc.alg);
1669-
1672+
mbedtls_free(private_key);
16701673
break;
16711674
}
16721675

0 commit comments

Comments
 (0)