1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

bootloader: erase metadata backup after usage

This commit is contained in:
Pavol Rusnak 2017-07-24 14:39:15 +02:00
parent 3d7d0f0734
commit 184529bbfc
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -394,9 +394,10 @@ static void hid_rx_callback(usbd_device *dev, uint8_t ep)
uint8_t hash[32];
sha256_Raw((unsigned char *)FLASH_META_START, FLASH_META_LEN, hash);
// copy metadata back
// restore metadata from backup
erase_metadata_sectors();
restore_metadata(meta_backup);
memset(meta_backup, 0, sizeof(meta_backup));
// compare against known hash computed via the following Python3 script:
// hashlib.sha256(binascii.unhexlify('0F5A693C' * 8192)).hexdigest()
@ -568,8 +569,9 @@ static void hid_rx_callback(usbd_device *dev, uint8_t ep)
}
// erase storage
erase_metadata_sectors();
// copy storage from backup
// restore metadata from backup
restore_metadata(meta_backup);
memset(meta_backup, 0, sizeof(meta_backup));
} else {
// replace "TRZR" in header with 0000 when hash not confirmed
if (!hash_check_ok) {