1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-15 23:05:45 +00:00

fix(core): preallocate storage.debug.reset_internal_entropy

It should allow GC to cleanup `int_entropy`, which can be
allocated in random heap position, causing fragmentation.

[no changelog]
This commit is contained in:
Roman Zeyde 2025-03-24 18:18:34 +02:00 committed by Roman Zeyde
parent f942d13748
commit 8b4936926c
2 changed files with 3 additions and 2 deletions

View File

@ -84,7 +84,7 @@ async def reset_device(msg: ResetDevice) -> Success:
# generate internal entropy
int_entropy = random.bytes(32, True)
if __debug__:
storage.debug.reset_internal_entropy = int_entropy
storage.debug.reset_internal_entropy[:] = int_entropy
entropy_commitment = (
hmac(hmac.SHA256, int_entropy, b"").digest() if msg.entropy_check else None

View File

@ -9,4 +9,5 @@ if __debug__:
layout_watcher = False
reset_internal_entropy: bytes = b""
reset_internal_entropy = bytearray(32)
reset_internal_entropy[:] = bytes()