Skip to content

Commit b87befb

Browse files
tomi-fontkartben
authored andcommitted
secure_storage: its: improve return codes
Some minor improvements. Signed-off-by: Tomi Fontanilles <[email protected]>
1 parent 8cf71d0 commit b87befb

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

subsys/secure_storage/src/its/store/settings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ psa_status_t secure_storage_its_store_remove(secure_storage_its_uid_t uid)
120120
secure_storage_its_store_settings_get_name(uid, name);
121121

122122
ret = settings_delete(name);
123-
124123
LOG_DBG("%s %s. (%d)", ret ? "Failed to delete" : "Deleted", name, ret);
124+
125125
return ret ? PSA_ERROR_STORAGE_FAILURE : PSA_SUCCESS;
126126
}

subsys/secure_storage/src/its/store/zms.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ psa_status_t secure_storage_its_store_get(secure_storage_its_uid_t uid, size_t d
108108

109109
psa_status_t secure_storage_its_store_remove(secure_storage_its_uid_t uid)
110110
{
111-
int zms_ret;
111+
int ret;
112112
const uint32_t zms_id = zms_id_from(uid);
113113

114114
if (has_forbidden_bits_set(uid)) {
115115
return PSA_ERROR_INVALID_ARGUMENT;
116116
}
117117

118-
zms_ret = zms_delete(&s_zms, zms_id);
119-
LOG_DBG("%s 0x%x. (%d)", zms_ret ? "Failed to delete" : "Deleted", zms_id, zms_ret);
120-
BUILD_ASSERT(PSA_SUCCESS == 0);
121-
return zms_ret;
118+
ret = zms_delete(&s_zms, zms_id);
119+
LOG_DBG("%s 0x%x. (%d)", ret ? "Failed to delete" : "Deleted", zms_id, ret);
120+
121+
return ret ? PSA_ERROR_STORAGE_FAILURE : PSA_SUCCESS;
122122
}

subsys/secure_storage/src/its/transform/aead.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static psa_status_t psa_aead_crypt(psa_key_usage_t operation, secure_storage_its
3131
psa_set_key_lifetime(&key_attributes, PSA_KEY_LIFETIME_VOLATILE);
3232
psa_set_key_type(&key_attributes, key_type);
3333
psa_set_key_algorithm(&key_attributes, alg);
34-
psa_set_key_bits(&key_attributes, sizeof(key) * 8);
34+
psa_set_key_bits(&key_attributes, PSA_BYTES_TO_BITS(sizeof(key)));
3535

3636
/* Avoid calling psa_aead_*crypt() because that would require importing keys into
3737
* PSA Crypto. This gets called from PSA Crypto for storing persistent keys so,
@@ -113,7 +113,7 @@ psa_status_t secure_storage_its_transform_from_store(
113113
psa_storage_create_flags_t *create_flags)
114114
{
115115
if (stored_data_len < STORED_ENTRY_LEN(0)) {
116-
return PSA_ERROR_STORAGE_FAILURE;
116+
return PSA_ERROR_DATA_CORRUPT;
117117
}
118118

119119
psa_status_t ret;

subsys/secure_storage/src/its/transform/aead_get.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ psa_status_t secure_storage_its_transform_aead_get_key(
7575
if (hwinfo_ret != 0) {
7676
hwinfo_ret = hwinfo_get_device_id(data.device_id, sizeof(data.device_id));
7777
if (hwinfo_ret <= 0) {
78+
LOG_DBG("Failed to retrieve the device ID. (%zd)", hwinfo_ret);
7879
return PSA_ERROR_HARDWARE_FAILURE;
7980
}
8081
if (hwinfo_ret < sizeof(data.device_id)) {

0 commit comments

Comments
 (0)