1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 03:18:09 +00:00

Revert "Add storage_wipe_ex() which allows to specify the new PIN and the PIN fail count."

This reverts commit d49e3c9f3c.
This commit is contained in:
andrew 2019-01-30 17:31:51 +01:00
parent 7228b299b3
commit 7e8c4e783d
2 changed files with 7 additions and 13 deletions

View File

@ -443,17 +443,17 @@ static secbool pin_logs_init(uint32_t fails)
}
/*
* Initializes the values of VERSION_KEY, EDEK_PVC_KEY, PIN_NOT_SET_KEY and PIN_LOGS_KEY using the given PIN.
* Initializes the values of VERSION_KEY, EDEK_PVC_KEY, PIN_NOT_SET_KEY and PIN_LOGS_KEY using an empty PIN.
* This function should be called to initialize freshly wiped storage.
*/
static void init_wiped_storage(uint32_t new_pin, uint32_t pin_fail_count)
static void init_wiped_storage(void)
{
random_buffer(cached_keys, sizeof(cached_keys));
uint32_t version = NORCOW_VERSION;
ensure(auth_init(), "failed to initialize storage authentication tag");
ensure(storage_set_encrypted(VERSION_KEY, &version, sizeof(version)), "failed to set storage version");
ensure(set_pin(new_pin), "failed to initialize PIN");
ensure(pin_logs_init(pin_fail_count), "failed to initialize PIN logs");
ensure(set_pin(PIN_EMPTY), "failed to initialize PIN");
ensure(pin_logs_init(0), "failed to initialize PIN logs");
if (unlocked != sectrue) {
memzero(cached_keys, sizeof(cached_keys));
}
@ -480,7 +480,7 @@ void storage_init(PIN_UI_WAIT_CALLBACK callback, const uint8_t *salt, const uint
const void *val;
uint16_t len;
if (secfalse == norcow_get(EDEK_PVC_KEY, &val, &len)) {
init_wiped_storage(PIN_EMPTY, 0);
init_wiped_storage();
}
memzero(cached_keys, sizeof(cached_keys));
}
@ -967,18 +967,13 @@ secbool storage_change_pin(uint32_t oldpin, uint32_t newpin)
return ret;
}
void storage_wipe_ex(uint32_t new_pin, uint32_t pin_fail_count)
void storage_wipe(void)
{
norcow_wipe();
norcow_active_version = NORCOW_VERSION;
memzero(authentication_sum, sizeof(authentication_sum));
memzero(cached_keys, sizeof(cached_keys));
init_wiped_storage(new_pin, pin_fail_count);
}
void storage_wipe(void)
{
storage_wipe_ex(PIN_EMPTY, 0);
init_wiped_storage();
}
static void handle_fault(void)

View File

@ -28,7 +28,6 @@ typedef void (*PIN_UI_WAIT_CALLBACK)(uint32_t wait, uint32_t progress);
void storage_init(PIN_UI_WAIT_CALLBACK callback, const uint8_t *salt, const uint16_t salt_len);
void storage_wipe(void);
void storage_wipe_ex(uint32_t new_pin, uint32_t pin_fail_count);
void storage_lock(void);
secbool storage_unlock(const uint32_t pin);
secbool storage_has_pin(void);