diff --git a/firmware/config.c b/firmware/config.c index 8e52a2918..d8a28ccfc 100644 --- a/firmware/config.c +++ b/firmware/config.c @@ -51,6 +51,7 @@ static const uint32_t CONFIG_MAGIC_V10 = 0x726f7473; // 'stor' as uint32_t #define APP 0x0100 #define FLAG_PUBLIC 0x8000 +#define FLAGS_WRITE 0xC000 static const uint16_t KEY_UUID = 0 | APP | FLAG_PUBLIC; // bytes(12) static const uint16_t KEY_VERSION = 1 | APP; // uint32 @@ -61,7 +62,7 @@ static const uint16_t KEY_PASSPHRASE_PROTECTION = 5 | APP; // boo static const uint16_t KEY_HOMESCREEN = 6 | APP | FLAG_PUBLIC; // bytes(1024) static const uint16_t KEY_NEEDS_BACKUP = 7 | APP; // bool static const uint16_t KEY_FLAGS = 8 | APP; // uint32 -static const uint16_t KEY_U2F_COUNTER = 9 | APP | FLAG_PUBLIC; // uint32 +static const uint16_t KEY_U2F_COUNTER = 9 | APP | FLAGS_WRITE; // uint32 static const uint16_t KEY_UNFINISHED_BACKUP = 11 | APP; // bool static const uint16_t KEY_AUTO_LOCK_DELAY_MS = 12 | APP; // uint32 static const uint16_t KEY_NO_BACKUP = 13 | APP; // bool @@ -837,18 +838,14 @@ bool config_getFlags(uint32_t *flags) uint32_t config_nextU2FCounter(void) { - // TODO Implement efficient version. - uint32_t counter = 0; - uint16_t len = 0; - storage_get(KEY_U2F_COUNTER, &counter, sizeof(counter), &len); - counter++; - storage_set(KEY_U2F_COUNTER, &counter, sizeof(counter)); - return counter; + uint32_t u2fcounter = 0; + storage_next_counter(KEY_U2F_COUNTER, &u2fcounter); + return u2fcounter; } void config_setU2FCounter(uint32_t u2fcounter) { - storage_set(KEY_U2F_COUNTER, &u2fcounter, sizeof(u2fcounter)); + storage_set_counter(KEY_U2F_COUNTER, u2fcounter); } uint32_t config_getAutoLockDelayMs() diff --git a/vendor/trezor-storage b/vendor/trezor-storage index 049780201..5c2765740 160000 --- a/vendor/trezor-storage +++ b/vendor/trezor-storage @@ -1 +1 @@ -Subproject commit 0497802014edf03cdcce8cb70889d5a6e0bd3361 +Subproject commit 5c2765740db064c99fe54cbae79f74a3d767973c