@@ -126,7 +126,7 @@ static void sw_reset(void) {
126
126
/**
127
127
* Configures flash info pages to store device certificates.
128
128
*/
129
- static status_t config_certificate_flash_pages (void ) {
129
+ static status_t config_and_erase_certificate_flash_pages (void ) {
130
130
const flash_ctrl_info_page_t * kCertFlashInfoPages [] = {
131
131
& kFlashCtrlInfoPageUdsCertificate ,
132
132
& kFlashCtrlInfoPageCdi0Certificate ,
@@ -137,6 +137,12 @@ static status_t config_certificate_flash_pages(void) {
137
137
flash_ctrl_info_perms_set (kCertFlashInfoPages [i ],
138
138
kCertificateFlashInfoPerms );
139
139
}
140
+ TRY (flash_ctrl_info_erase (& kFlashCtrlInfoPageUdsCertificate ,
141
+ kFlashCtrlEraseTypePage ));
142
+ TRY (flash_ctrl_info_erase (& kFlashCtrlInfoPageCdi0Certificate ,
143
+ kFlashCtrlEraseTypePage ));
144
+ TRY (flash_ctrl_info_erase (& kFlashCtrlInfoPageCdi1Certificate ,
145
+ kFlashCtrlEraseTypePage ));
140
146
return OK_STATUS ();
141
147
}
142
148
@@ -211,7 +217,7 @@ static status_t personalize_dice_certificates(ujson_t *uj) {
211
217
TRY (ujson_deserialize_manuf_certgen_inputs_t (uj , & certgen_inputs ));
212
218
213
219
// Configure certificate flash info page permissions.
214
- TRY (config_certificate_flash_pages ());
220
+ TRY (config_and_erase_certificate_flash_pages ());
215
221
216
222
// Initialize entropy complex / KMAC for key manager operations.
217
223
TRY (entropy_complex_init ());
@@ -232,14 +238,7 @@ static status_t personalize_dice_certificates(ujson_t *uj) {
232
238
TRY (dice_uds_cert_build (& certgen_inputs , & uds_pubkey_id ,
233
239
dice_certs .uds_tbs_certificate ,
234
240
& dice_certs .uds_tbs_certificate_size ));
235
- TRY (flash_ctrl_info_erase (& kFlashCtrlInfoPageUdsCertificate ,
236
- kFlashCtrlEraseTypePage ));
237
- TRY (flash_ctrl_info_write (
238
- & kFlashCtrlInfoPageUdsCertificate ,
239
- kFlashInfoFieldUdsCertificate .byte_offset ,
240
- dice_certs .uds_tbs_certificate_size / sizeof (uint32_t ),
241
- dice_certs .uds_tbs_certificate ));
242
- LOG_INFO ("Generated UDS certificate." );
241
+ LOG_INFO ("Generated UDS TBS certificate." );
243
242
244
243
// Generate CDI_0 keys and cert.
245
244
compute_keymgr_owner_int_binding (& certgen_inputs );
@@ -249,8 +248,6 @@ static status_t personalize_dice_certificates(ujson_t *uj) {
249
248
TRY (dice_cdi_0_cert_build (& certgen_inputs , & uds_pubkey_id , & cdi_0_pubkey_id ,
250
249
dice_certs .cdi_0_certificate ,
251
250
& dice_certs .cdi_0_certificate_size ));
252
- TRY (flash_ctrl_info_erase (& kFlashCtrlInfoPageCdi0Certificate ,
253
- kFlashCtrlEraseTypePage ));
254
251
TRY (flash_ctrl_info_write (
255
252
& kFlashCtrlInfoPageCdi0Certificate ,
256
253
kFlashInfoFieldCdi0Certificate .byte_offset ,
@@ -266,8 +263,6 @@ static status_t personalize_dice_certificates(ujson_t *uj) {
266
263
TRY (dice_cdi_1_cert_build (& certgen_inputs , & cdi_0_pubkey_id ,
267
264
dice_certs .cdi_1_certificate ,
268
265
& dice_certs .cdi_1_certificate_size ));
269
- TRY (flash_ctrl_info_erase (& kFlashCtrlInfoPageCdi1Certificate ,
270
- kFlashCtrlEraseTypePage ));
271
266
TRY (flash_ctrl_info_write (
272
267
& kFlashCtrlInfoPageCdi1Certificate ,
273
268
kFlashInfoFieldCdi1Certificate .byte_offset ,
@@ -284,8 +279,6 @@ static status_t personalize_dice_certificates(ujson_t *uj) {
284
279
TRY (ujson_deserialize_manuf_endorsed_certs_t (uj , & endorsed_certs ));
285
280
286
281
// Write the endorsed UDS certificate to flash and ack to host.
287
- TRY (flash_ctrl_info_erase (& kFlashCtrlInfoPageUdsCertificate ,
288
- kFlashCtrlEraseTypePage ));
289
282
TRY (flash_ctrl_info_write (
290
283
& kFlashCtrlInfoPageUdsCertificate ,
291
284
kFlashInfoFieldUdsCertificate .byte_offset ,
0 commit comments