Skip to content

Commit 9f7752b

Browse files
Alexander ZilberkantOren Cohen
authored andcommitted
Replace PID and UID order in file name
PID should come first to create - to prevent timing attacks. Each partition can only request its own files. Thus starting lookup from the PID makes more sence.
1 parent e7df858 commit 9f7752b

File tree

1 file changed

+8
-8
lines changed
  • components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_PSA_SRV_IMPL

1 file changed

+8
-8
lines changed

components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_PSA_SRV_IMPL/pits_impl.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,20 @@ static void generate_fn(char *tdb_filename, uint32_t tdb_filename_size, uint32_t
106106

107107
uint8_t filename_idx = 0;
108108

109-
// Iterate on UID; each time convert 6 bits of UID into a character; first iteration must be done
109+
// Iterate on PID; each time convert 6 bits of PID into a character; first iteration must be done
110110
do {
111-
tdb_filename[filename_idx++] = base64_coding_table[uid & 0x3F];
112-
uid = uid >> 6;
113-
} while (uid != 0);
111+
tdb_filename[filename_idx++] = base64_coding_table[pid & 0x3F];
112+
pid = pid >> 6;
113+
} while (pid != 0);
114114

115115
// Write delimiter
116116
tdb_filename[filename_idx++] = '#';
117117

118-
// Iterate on PID; each time convert 6 bits of PID into a character; first iteration must be done
118+
// Iterate on UID; each time convert 6 bits of UID into a character; first iteration must be done
119119
do {
120-
tdb_filename[filename_idx++] = base64_coding_table[pid & 0x3F];
121-
pid = pid >> 6;
122-
} while (pid != 0);
120+
tdb_filename[filename_idx++] = base64_coding_table[uid & 0x3F];
121+
uid = uid >> 6;
122+
} while (uid != 0);
123123

124124
tdb_filename[filename_idx++] = '\0';
125125
MBED_ASSERT(filename_idx <= PSA_ITS_FILENAME_MAX_LEN);

0 commit comments

Comments
 (0)