mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-15 01:40:57 +00:00
Support entries which are writable even when the storage is locked. Needed for U2F counter on Trezor 1.
This commit is contained in:
parent
0497802014
commit
18fa999974
16
storage.c
16
storage.c
@ -62,6 +62,10 @@
|
||||
// If the top bit of APP is set, then the value is not encrypted.
|
||||
#define FLAG_PUBLIC 0x80
|
||||
|
||||
// If the top two bits of APP are set, then the value is not encrypted and it
|
||||
// can be written even when the storage is locked.
|
||||
#define FLAGS_WRITE 0xC0
|
||||
|
||||
// The length of the guard key in words.
|
||||
#define GUARD_KEY_WORDS 1
|
||||
|
||||
@ -926,7 +930,11 @@ secbool storage_set(const uint16_t key, const void *val, const uint16_t len)
|
||||
const uint8_t app = key >> 8;
|
||||
|
||||
// APP == 0 is reserved for PIN related values
|
||||
if (sectrue != initialized || sectrue != unlocked || app == APP_STORAGE) {
|
||||
if (sectrue != initialized || app == APP_STORAGE) {
|
||||
return secfalse;
|
||||
}
|
||||
|
||||
if (sectrue != unlocked && (app & FLAGS_WRITE) != FLAGS_WRITE) {
|
||||
return secfalse;
|
||||
}
|
||||
|
||||
@ -944,7 +952,11 @@ secbool storage_delete(const uint16_t key)
|
||||
const uint8_t app = key >> 8;
|
||||
|
||||
// APP == 0 is reserved for storage related values
|
||||
if (sectrue != initialized || sectrue != unlocked || app == APP_STORAGE) {
|
||||
if (sectrue != initialized || app == APP_STORAGE) {
|
||||
return secfalse;
|
||||
}
|
||||
|
||||
if (sectrue != unlocked && (app & FLAGS_WRITE) != FLAGS_WRITE) {
|
||||
return secfalse;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user