Skip to content

Commit a9e3f63

Browse files
committed
Merge remote-tracking branch 'ata/abort-factory-reset'
2 parents 4bae1a4 + d143187 commit a9e3f63

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/reset.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,25 @@ void reset_reset(bool status)
4848
{
4949
keystore_lock();
5050
#if !defined(TESTING)
51-
if (!securechip_update_keys()) {
51+
bool sc_result_update_keys = false;
52+
for (int retries = 0; retries < 5; retries++) {
53+
sc_result_update_keys = securechip_update_keys();
54+
if (sc_result_update_keys) {
55+
break;
56+
}
57+
}
58+
if (!sc_result_update_keys) {
5259
Abort("Could not reset secure chip.");
5360
}
5461
#if APP_U2F == 1
55-
if (!securechip_u2f_counter_set(0)) {
62+
bool sc_result_u2f_counter_set = false;
63+
for (int retries = 0; retries < 5; retries++) {
64+
sc_result_u2f_counter_set = securechip_u2f_counter_set(0);
65+
if (sc_result_u2f_counter_set) {
66+
break;
67+
}
68+
}
69+
if (!sc_result_u2f_counter_set) {
5670
Abort("Could not initialize U2F counter.");
5771
}
5872
#endif

src/securechip/securechip.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,12 @@ bool securechip_monotonic_increments_remaining(uint32_t* remaining_out)
605605

606606
bool securechip_random(uint8_t* rand_out)
607607
{
608-
return atcab_random(rand_out) == ATCA_SUCCESS;
608+
for (int retries = 0; retries < 5; retries++) {
609+
if (atcab_random(rand_out) == ATCA_SUCCESS) {
610+
return true;
611+
}
612+
}
613+
return false;
609614
}
610615

611616
// Length of priv_key must be 32 bytes

0 commit comments

Comments
 (0)