diff --git a/src/seedsigner/controller.py b/src/seedsigner/controller.py index 4b1027ef1..ec5c239ef 100644 --- a/src/seedsigner/controller.py +++ b/src/seedsigner/controller.py @@ -12,6 +12,7 @@ from PIL.Image import Image from seedsigner.gui.toast import BaseToastOverlayManagerThread +from seedsigner.helpers.secure_delete import wipe_dict, wipe_private_key, wipe_value from seedsigner.models.psbt_parser import PSBTParser from seedsigner.models.seed import Seed from seedsigner.models.seed_storage import SeedStorage @@ -20,6 +21,7 @@ from seedsigner.models.settings import SettingsConstants from seedsigner.models.singleton import Singleton from seedsigner.models.threads import BaseThread +from seedsigner.models.wif import WIFKey from seedsigner.models.settings_definition import SettingsConstants from seedsigner.views.screensaver import ScreensaverScreen from seedsigner.views.view import Destination, View @@ -135,13 +137,23 @@ def run(self): controller = Controller.get_instance() buttons = HardwareButtons.get_instance() while self.keep_running: - wipe_minutes = controller.settings.get_value(SettingsConstants.SETTING__WIPE_TIMER) - if wipe_minutes and wipe_minutes != SettingsConstants.WIPE_TIMER__DISABLED: - controller.wipe_timer_ms = wipe_minutes * 60 * 1000 - cur = int(time.time() * 1000) - if controller.wipe_timer_ms and cur - buttons.last_input_time > controller.wipe_timer_ms: - controller.handle_wipe_timeout() - buttons.update_last_input_time() + # This thread is the only thing that runs the inactivity wipe. An + # exception that ended it would turn the wipe off, without a word, + # for the rest of the session. + try: + wipe_minutes = controller.settings.get_value(SettingsConstants.SETTING__WIPE_TIMER) + if wipe_minutes and wipe_minutes != SettingsConstants.WIPE_TIMER__DISABLED: + controller.wipe_timer_ms = wipe_minutes * 60 * 1000 + cur = int(time.time() * 1000) + if controller.wipe_timer_ms and cur - buttons.last_input_time > controller.wipe_timer_ms: + try: + controller.handle_wipe_timeout() + finally: + # A failed wipe is retried after the next full + # interval, not every second. + buttons.update_last_input_time() + except Exception: + logger.exception("Inactivity wipe failed; the timer keeps running") time.sleep(1) @@ -573,6 +585,10 @@ def run(self): if next_destination.View_cls == MainMenuView: # Home always wipes the back_stack self.clear_back_stack() + + # A WIF or BIP38 key never enters SeedStorage: once the + # psbt state below drops it, nothing else can zero it. + self.wipe_psbt_wif_keys() # Home always wipes the back_stack/state of temp vars self.resume_main_flow = None @@ -793,12 +809,69 @@ def handle_wipe_timeout(self): except Exception: logger.debug("Error wiping seed on auto-wipe", exc_info=True) self.storage.seeds = [] - self.storage.clear_pending_seed() + # A half-finished seed entry keeps its words in SeedStorage rather than + # in a Seed, so those buffers need clearing too. Each clear is looked up + # and called on its own: whatever one of them does, the wipe still has + # to finish. + for clear_buffer in ("clear_pending_seed", "discard_pending_mnemonic", + "discard_pending_slip39_shares"): + clear = getattr(self.storage, clear_buffer, None) + if clear is None: + logger.warning("Storage has no %s; those buffers stay", clear_buffer) + continue + try: + clear() + except Exception: + logger.debug("Error in %s on auto-wipe", clear_buffer, exc_info=True) if self._storage2: + # The key typed or scanned to decrypt an EncryptedQR. + encryptedqr = self._storage2.encryptedqr + self._wipe_step("the EncryptedQR key", wipe_value, + getattr(encryptedqr, "encryption_key", None)) self._storage2.clear_encryptedqr() + # psbt_seed can hold a WIFKey, which never enters storage.seeds and so + # is missed by the loop above. The parser can hold one that psbt_seed + # has already let go of: Back from the overview and a signature that + # did not verify both clear psbt_seed alone. Wiped here, before + # anything below lets go of the references. + parser = self.psbt_parser + signers = [self.psbt_seed] + parser_seed = getattr(parser, "seed", None) + if parser_seed is not self.psbt_seed: + signers.append(parser_seed) + for signer in signers: + if signer is None: + continue + try: + signer.wipe() + except Exception: + logger.debug("Error wiping a psbt signer on auto-wipe", exc_info=True) + + # The parser also keeps a root key of its own. From a BIP-39 seed it is + # a new HDKey, which wiping the seed does not reach. Zeroed here only: + # an XprvSeed hands the parser its own root, and a route that keeps + # the seed, such as Home, must leave that intact. + if parser is not None: + self._wipe_step("the psbt parser's root key", wipe_private_key, + getattr(parser, "root", None)) + + # GlobalPlatform card master keys: plaintext ENC/MAC/DEK that can + # re-key or unlock a JavaCard, so they cannot outlive the session. + # Only the keys are secret; the "type" tag is a code constant. + self._wipe_step("the JavaCard keys", wipe_dict, self.javacard_keys, + ("key", "enc", "mac", "dek")) + self.javacard_keys = None + + self._wipe_step("the smartcard session secrets", + self._wipe_smartcard_session_secrets) + # Raw password-generator entropy (dice rolls / BIP85 bytes) must not - # survive the inactivity wipe either. + # survive the inactivity wipe either. The password type and entropy + # source next to it are code constants, not secrets. + self._wipe_step("the password entropy", wipe_dict, + self.password_generator_entropy_cache, + ("roll_data", "entropy_bytes")) self.password_generator_entropy_cache = None self.psbt = None @@ -834,6 +907,55 @@ def handle_wipe_timeout(self): HardwareButtons.get_instance().trigger_override() + @staticmethod + def _wipe_step(what: str, wipe, *args) -> None: + """Run one zeroing step of the inactivity wipe, logging a failure. + + Every secret has to be zeroed even when zeroing another one fails, so + no step may raise into the ones after it. + """ + try: + wipe(*args) + except Exception: + logger.debug("Error wiping %s on auto-wipe", what, exc_info=True) + + + def _wipe_smartcard_session_secrets(self): + """Zero the smartcard session secrets where they are held. + + The card PINs and the Satodime unlock secrets are lists of ints, and + the OpenPGP admin PIN is a str. Setting the attributes to None only + drops the references. The connector's own copy of the PIN goes back + to None rather than an empty list: pysatochip reuses a cached PIN + that is not None, and an empty one would cost a PIN try. + """ + connector = self.Satochip_Connector + for secret in (self.Satochip_PIN, getattr(connector, "pin", None), self.GPG_Admin_PIN): + wipe_value(secret) + for secret in (self.Satodime_unlock_secrets or {}).values(): + wipe_value(secret) + for _card_id, secret in (self.Satodime_unlock_nicknames or {}).values(): + wipe_value(secret) + if connector is not None: + connector.pin = None + + + def wipe_psbt_wif_keys(self): + """Zero any WIF key the psbt flow holds, in psbt_seed or in the parser. + + Back from the overview and a signature that did not verify clear + psbt_seed alone, so the parser can be the last holder. A stored seed + is left alone: it outlives the flow, and an XprvSeed shares its root + key with the parser. + """ + for signer in (self.psbt_seed, getattr(self.psbt_parser, "seed", None)): + if isinstance(signer, WIFKey): + try: + signer.wipe() + except Exception: + logger.debug("Error wiping a WIF key", exc_info=True) + + def handle_exception(self, e) -> Destination: """ Displays a user-friendly error screen and includes debugging info to help @@ -888,6 +1010,9 @@ def is_screensaver_start_allowed(self) -> bool: - The current active view allows screensaver activity. """ from seedsigner.views import MainMenuView - # Confusingly, the top item in the `BackStack` is actually the *current* View - active_view = self.back_stack[-1].view if self.back_stack else MainMenuView() + # Confusingly, the top item in the `BackStack` is actually the *current* View. + # A Destination has no view until it has run, and the inactivity wipe + # leaves one for the main menu that the loop has yet to run. + top = self.back_stack[-1] if self.back_stack else None + active_view = getattr(top, "view", None) or MainMenuView() return not self.is_screensaver_running and active_view.is_screensaver_allowed diff --git a/src/seedsigner/helpers/secure_delete.py b/src/seedsigner/helpers/secure_delete.py index 8d6c8cc1b..315b97921 100644 --- a/src/seedsigner/helpers/secure_delete.py +++ b/src/seedsigner/helpers/secure_delete.py @@ -77,14 +77,19 @@ def _collect_wordlist_ids() -> frozenset: def _is_shared(obj) -> bool: """Return True if *obj* appears to be shared or immortal. - Two detection mechanisms are used: + Three detection mechanisms are used: 1. **Wordlist-ID check**: if ``id(obj)`` is in the pre-computed set of BIP-39 / SLIP-39 wordlist entry IDs the string is always considered shared. This is reliable on all CPython versions because the wordlist objects are module-level singletons that live for the entire process. - 2. **Refcount check**: if the reference count returned by + 2. **Length check**: CPython keeps a single object for each one-byte + bytes value and each Latin-1 one-character str. Before 3.11 their + refcounts are ordinary, so the refcount check cannot tell them from + a private copy. + + 3. **Refcount check**: if the reference count returned by ``sys.getrefcount`` is at or above ``_SHARED_REFCOUNT_LIMIT`` the string is considered shared. This catches immortal strings on CPython 3.12+ (where the sentinel refcount is ~4 billion) as well as @@ -97,6 +102,8 @@ def _is_shared(obj) -> bool: """ if isinstance(obj, str) and id(obj) in _WORDLIST_IDS: return True + if isinstance(obj, (str, bytes)) and len(obj) == 1: + return True return sys.getrefcount(obj) >= _SHARED_REFCOUNT_LIMIT @@ -122,6 +129,15 @@ def wipe_bytes(b: bytes | bytearray | None) -> None: b[i] = 0 return if isinstance(b, bytes) and len(b) > 0: + # Same guard as wipe_string(): a bytes object the interpreter shares + # would be zeroed for every other user of it. + if _is_shared(b): + logger.warning( + "wipe_bytes: refusing to wipe shared/immortal bytes " + "(refcount=%d)", + sys.getrefcount(b), + ) + return _wipe_buffer(b, len(b)) @@ -163,4 +179,50 @@ def wipe_list(lst: list | None) -> None: wipe_bytes(item) elif isinstance(item, str): wipe_string(item) + # The slots give a secret away too. An int element (a PIN digit, a byte of + # an unlock secret) has no buffer to zero, only the cached int it points + # at, and a wordlist word the guard left alone is known by its address. + # clear() frees the slot array with those pointers still in it. + for index in range(len(lst)): + lst[index] = 0 lst.clear() + + +def wipe_value(value) -> None: + """Wipe one secret held as str, bytes, bytearray or list; ignore the rest.""" + if isinstance(value, (bytes, bytearray)): + wipe_bytes(value) + elif isinstance(value, str): + wipe_string(value) + elif isinstance(value, list): + wipe_list(value) + + +def wipe_dict(d: dict | None, keys) -> None: + """Wipe the values stored under *keys*, then clear the dict. + + Only the named values are wiped. A dict of secrets carries metadata too, + such as a type tag or a source name, and that is usually a code constant. + On CPython < 3.12 a constant is not immortal and has fewer references than + _SHARED_REFCOUNT_LIMIT, so wipe_string() would zero it in place for every + other user of the same object. + """ + if d is None: + return + for key in keys: + wipe_value(d.get(key)) + d.clear() + + +def wipe_private_key(key) -> None: + """Zero an embit private key in place: a PrivateKey, or a private HDKey. + + A public key is left alone. It is not secret, and it can be shared with + state that still needs it. + """ + if key is None or not getattr(key, "is_private", False): + return + inner = getattr(key, "key", key) + wipe_bytes(getattr(inner, "_secret", None)) + if inner is not key: + wipe_bytes(getattr(key, "chain_code", None)) diff --git a/src/seedsigner/models/seed.py b/src/seedsigner/models/seed.py index c2e01d6a1..31a9db318 100644 --- a/src/seedsigner/models/seed.py +++ b/src/seedsigner/models/seed.py @@ -9,7 +9,7 @@ from embit.networks import NETWORKS from typing import List -from seedsigner.helpers.secure_delete import wipe_bytes, wipe_string, wipe_list +from seedsigner.helpers.secure_delete import wipe_bytes, wipe_string, wipe_list, wipe_private_key from seedsigner.models.settings import SettingsConstants from seedsigner.models import aezeed @@ -338,6 +338,8 @@ def __init__(self, mnemonics: List[str], slip39_passphrase: str = "") -> None: # Passphrase used to decrypt the shares self._slip39_passphrase: str = unicodedata.normalize("NFKD", slip39_passphrase) if slip39_passphrase else "" + self._mnemonic: List[str] = [] + self._passphrase: str = "" self.seed_bytes: bytes = None self.master_secret: bytes | None = None self._initial_master_secret: bytes | None = None @@ -489,6 +491,7 @@ def __init__(self, xprv: str) -> None: self._xprv = normalized self._root = root self._wordlist_language_code = SettingsConstants.WORDLIST_LANGUAGE__ENGLISH + self._mnemonic: List[str] = [] self._passphrase = "" self.seed_bytes = None self.master_secret = None @@ -535,6 +538,9 @@ def wipe(self): """Securely clear xprv-specific fields, then delegate to parent.""" wipe_string(self._xprv) self._xprv = "" + # The HDKey parsed from the xprv holds the key and chain code in bytes + # of its own; dropping the reference leaves them in freed memory. + wipe_private_key(self._root) self._root = None super().wipe() diff --git a/src/seedsigner/models/seed_storage.py b/src/seedsigner/models/seed_storage.py index 05a5e0a09..f2b04b66b 100644 --- a/src/seedsigner/models/seed_storage.py +++ b/src/seedsigner/models/seed_storage.py @@ -1,8 +1,11 @@ +import logging from typing import List from seedsigner.helpers.secure_delete import wipe_bytes, wipe_list from seedsigner.models.seed import Seed, ElectrumSeed, AezeedSeed, Slip39Seed, InvalidSeedException from seedsigner.models.settings_definition import SettingsConstants +logger = logging.getLogger(__name__) + class SeedStorage: @@ -37,9 +40,16 @@ def finalize_pending_seed(self) -> Seed: def clear_pending_seed(self): - if self.pending_seed is not None: - self.pending_seed.wipe() - self.pending_seed = None + # Zeroing the secret material is best-effort, as in + # Controller.discard_seed(): a failed wipe must not leave the caller + # holding on to a seed it asked to drop. + try: + if self.pending_seed is not None: + self.pending_seed.wipe() + except Exception: + logger.debug("Error wiping pending seed", exc_info=True) + finally: + self.pending_seed = None def validate_mnemonic(self, mnemonic: List[str]) -> bool: diff --git a/src/seedsigner/models/wif.py b/src/seedsigner/models/wif.py index ef37f5d2d..5bfa4cc8e 100644 --- a/src/seedsigner/models/wif.py +++ b/src/seedsigner/models/wif.py @@ -3,6 +3,7 @@ from embit import ec, hashes +from seedsigner.helpers.secure_delete import wipe_private_key, wipe_string from seedsigner.models.seed import InvalidSeedException from seedsigner.models.settings import SettingsConstants @@ -17,6 +18,17 @@ def __init__(self, wif: str): raise InvalidSeedException("Invalid WIF") from e self.wif = wif + def wipe(self): + """Zero the key material, to the same contract as Seed.wipe(). + + A WIFKey never enters SeedStorage, so nothing else zeroes it; dropping + the reference would leave the secret in freed heap pages. + """ + wipe_private_key(self.privkey) + self.privkey = None + wipe_string(self.wif) + self.wif = "" + def get_fingerprint(self, network: str = SettingsConstants.MAINNET) -> str: """Return BIP32-style fingerprint for the key's public key.""" pub = self.privkey.get_public_key() diff --git a/tests/test_controller.py b/tests/test_controller.py index c9a578f3b..f5b023562 100644 --- a/tests/test_controller.py +++ b/tests/test_controller.py @@ -273,9 +273,11 @@ def wipe(self): seeds = [FakeSeed(), FakeSeed()] controller._storage = SimpleNamespace(seeds=seeds, clear_pending_seed=lambda: None) controller._storage2 = None + # Private copies: the wipe zeroes these in place, and a literal here + # would be the code object's own constant. controller.password_generator_entropy_cache = { - "roll_data": "1234512345", - "entropy_bytes": b"\x00\x01\x02\x03", + "roll_data": "".join("1234512345"), + "entropy_bytes": bytearray(b"\x00\x01\x02\x03"), } toasts = [] import seedsigner.gui.toast as gui_toast diff --git a/tests/test_secure_delete.py b/tests/test_secure_delete.py index b46c576c0..9fc2b22ea 100644 --- a/tests/test_secure_delete.py +++ b/tests/test_secure_delete.py @@ -10,8 +10,11 @@ from seedsigner.helpers.secure_delete import ( _is_shared, + wipe_bytes, + wipe_dict, wipe_list, wipe_string, + wipe_value, ) @@ -114,3 +117,67 @@ def test_full_lifecycle_wordlist_integrity(): f"WORDLIST[{i}] corrupted after discard: " f"expected {original_wordlist[i]!r}, got {bip39.WORDLIST[i]!r}" ) + + +def test_wipe_list_overwrites_int_elements_before_clearing(): + """A PIN or an unlock secret held as list(bytes) has no buffer of its own + to zero: the secret is which cached int each slot points at. clear() alone + frees the slot array with those pointers still in it.""" + + class RecordingList(list): + def __init__(self, items): + super().__init__(items) + self.writes = [] + + def __setitem__(self, index, value): + self.writes.append((index, value)) + super().__setitem__(index, value) + + pin = RecordingList(b"123456") + + wipe_list(pin) + + assert pin.writes == [(i, 0) for i in range(6)] + assert pin == [] + + +def test_wipe_dict_zeroes_only_the_named_values(): + """Metadata next to a secret is often a code constant (a type tag, a + source name). On CPython < 3.12 zeroing one in place corrupts it for the + whole process, so only the values named as secret are wiped.""" + key = "".join("00112233445566778899AABBCCDDEEFF") + tag = "".join("single") + d = {"type": tag, "key": key} + + wipe_dict(d, ("key",)) + + assert key == "\x00" * len(key) + assert tag == "single" + assert d == {} + + +def test_wipe_value_ignores_what_it_cannot_zero(): + """A value of another type is left alone rather than guessed at: a str + walked as a list would hand wipe_string() its one-character pieces.""" + for value in (None, 7, ("a", "b"), object()): + wipe_value(value) + + secret = "".join("hunter2") + wipe_value(secret) + assert secret == "\x00" * len("hunter2") + + +def test_wipe_bytes_skips_a_shared_one_byte_object(): + """CPython keeps one object per one-byte value. Zeroing it in place would + turn that byte into NUL for every bytes value that uses it.""" + one_byte = bytes([7]) + + wipe_bytes(one_byte) + + assert bytes([7])[0] == 7 + + +def test_one_character_str_is_shared(): + """The same holds for one-character strings; before 3.11 their refcount + is ordinary, so only the length gives them away.""" + assert _is_shared("".join(["q"])) diff --git a/tests/test_wipe_paths.py b/tests/test_wipe_paths.py new file mode 100644 index 000000000..c7f9d4127 --- /dev/null +++ b/tests/test_wipe_paths.py @@ -0,0 +1,587 @@ +# pylint: disable=missing-function-docstring +# Must import base before any seedsigner modules +from base import BaseTest, FlowStep, FlowTest + +from seedsigner.models.seed import Slip39Seed, XprvSeed +from seedsigner.models.seed_storage import SeedStorage + + +XPRV = ( + "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi" +) + +# One SLIP-39 share, threshold 1 of 1 (same fixture style as tests/test_seed.py) +SLIP39_SHARE = ( + "testify swimming academic academic column loyalty smear include exotic " + "bedroom exotic wrist lobe cover grief golden smart junior estimate learn" +) + +# A mainnet WIF private key (test vector; never funded) +WIF = "L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ" + +# A 12-word BIP-39 mnemonic, entered one word at a time below +MNEMONIC = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about".split() + + +def fresh(text: str) -> str: + """Return a private copy of a fixture string. + + wipe() zeroes a str's buffer in place, so handing a module-level constant + straight to a Seed destroys the fixture for every later test in the run. + """ + return "".join(list(text)) + + +def run_inactivity_wipe(controller, monkeypatch): + """Fire the inactivity wipe with the toast stubbed out.""" + import seedsigner.gui.toast as gui_toast + + monkeypatch.setattr(controller, "activate_toast", lambda toast: None) + monkeypatch.setattr(gui_toast, "InfoToast", lambda label_text=None: label_text) + controller.handle_wipe_timeout() + + +class DummyLoadingScreenThread: + def __init__(self, *args, **kwargs): + pass + + def start(self): + pass + + def stop(self): + pass + + +class TestFixtureCopiesAreIndependent(BaseTest): + """A wiped copy must not take the shared fixture down with it.""" + + def test_fresh_returns_a_separate_object(self): + copy = fresh(XPRV) + + assert copy == XPRV + assert copy is not XPRV + + def test_wiping_a_copy_leaves_the_fixture_intact(self): + seed = XprvSeed(fresh(XPRV)) + + seed.wipe() + + assert XPRV.startswith("xprv") + assert SLIP39_SHARE.startswith("testify") + + +class TestSeedSubclassWipe(BaseTest): + """Seed.wipe() must work for every Seed subclass, not just BIP-39 seeds.""" + + def test_xprv_seed_wipe_does_not_raise(self): + seed = XprvSeed(fresh(XPRV)) + + seed.wipe() + + assert seed._xprv == "" + assert seed._root is None + + def test_xprv_seed_wipe_zeroes_the_root_key(self): + # The HDKey parsed from the xprv holds the key in bytes of its own: + # clearing the string and dropping _root leaves those in freed memory. + seed = XprvSeed(fresh(XPRV)) + secret = seed._root.key._secret + chain_code = seed._root.chain_code + + seed.wipe() + + assert secret == bytes(len(secret)) + assert chain_code == bytes(len(chain_code)) + + def test_slip39_seed_wipe_does_not_raise(self, monkeypatch): + monkeypatch.setattr( + "seedsigner.gui.screens.screen.LoadingScreenThread", DummyLoadingScreenThread + ) + seed = Slip39Seed(mnemonics=[fresh(SLIP39_SHARE)]) + + seed.wipe() + + assert seed._shares == [] + assert seed.seed_bytes is None + assert seed.master_secret is None + + +class TestClearPendingSeed(BaseTest): + """A pending seed must be dropped even when wiping it fails.""" + + def test_pending_seed_is_dropped_when_wipe_raises(self): + class ExplodingSeed: + def wipe(self): + raise AttributeError("no _mnemonic") + + storage = SeedStorage() + storage.set_pending_seed(ExplodingSeed()) + + # Best-effort, like Controller.discard_seed(): the caller is dropping a + # secret and must not be left holding it because the wipe failed. + storage.clear_pending_seed() + + assert storage.pending_seed is None + + +class TestWipeTimeoutCompletes(BaseTest): + """One failing wipe must not skip the rest of the inactivity cleanup.""" + + def test_remaining_data_is_cleared_when_a_seed_wipe_raises(self, monkeypatch): + from types import SimpleNamespace + from seedsigner.controller import Controller + + controller = Controller.get_instance() + + class ExplodingSeed: + def wipe(self): + raise AttributeError("no _mnemonic") + + def exploding_clear_pending_seed(): + raise AttributeError("no _mnemonic") + + controller._storage = SimpleNamespace( + seeds=[ExplodingSeed()], clear_pending_seed=exploding_clear_pending_seed + ) + controller._storage2 = None + controller.password_generator_entropy_cache = {"entropy_bytes": bytearray(b"\x00\x01")} + controller.psbt_seed = "not None" + + run_inactivity_wipe(controller, monkeypatch) + + assert controller.password_generator_entropy_cache is None + assert controller.psbt_seed is None + assert controller.auto_wiped is True + + def test_a_failing_step_does_not_skip_the_later_ones(self, monkeypatch): + from seedsigner.controller import Controller + + class ExplodingDict(dict): + def __getattribute__(self, name): + if name in ("get", "values", "items", "clear"): + raise RuntimeError("boom") + return super().__getattribute__(name) + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + controller.javacard_keys = ExplodingDict(type="single", key=fresh("00" * 16)) + entropy_bytes = bytearray(b"\x11\x22\x33\x44") + controller.password_generator_entropy_cache = {"entropy_bytes": entropy_bytes} + admin_pin = fresh("12345678") + controller.GPG_Admin_PIN = admin_pin + + run_inactivity_wipe(controller, monkeypatch) + + assert controller.javacard_keys is None + assert entropy_bytes == bytearray(len(entropy_bytes)) + assert admin_pin == "\x00" * len(admin_pin) + assert controller.auto_wiped is True + + +class TestWipeTimeoutClearsPartialEntry(BaseTest): + """Half-entered secrets live in SeedStorage, not in a Seed; wipe those too.""" + + def test_partially_entered_mnemonic_and_slip39_shares_are_cleared(self, monkeypatch): + from seedsigner.controller import Controller + + controller = Controller.get_instance() + storage = SeedStorage() + + storage.init_pending_mnemonic(num_words=12) + for index, word in enumerate(MNEMONIC): + storage.update_pending_mnemonic(word, index) + + storage.add_slip39_share_mnemonic(fresh(SLIP39_SHARE)) + + controller._storage = storage + controller._storage2 = None + + run_inactivity_wipe(controller, monkeypatch) + + assert storage.pending_mnemonic == [] + assert storage._pending_slip39_share == [] + assert storage._pending_slip39_shares == [] + assert storage._slip39_first_share is None + + +class TestWipeTimeoutClearsCardAndKeyMaterial(BaseTest): + """Secrets that never live in a Seed are missed unless named explicitly.""" + + def test_javacard_keys_are_wiped(self, monkeypatch): + from seedsigner.controller import Controller + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + enc = fresh("404142434445464748494a4b4c4d4e4f") + controller.javacard_keys = {"type": fresh("set"), "enc": enc, "mac": enc, "dek": enc} + + run_inactivity_wipe(controller, monkeypatch) + + assert controller.javacard_keys is None + assert enc == "\x00" * len(enc) + + def test_javacard_key_type_is_left_intact(self, monkeypatch): + # The type tag is a code constant in production. Only the keys are + # secret; zeroing the tag in place corrupts it for the whole process. + from seedsigner.controller import Controller + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + key_type = fresh("single") + key = fresh("00112233445566778899AABBCCDDEEFF") + controller.javacard_keys = {"type": key_type, "key": key} + + run_inactivity_wipe(controller, monkeypatch) + + assert key == "\x00" * len(key) + assert key_type == "single" + + def test_wif_psbt_seed_is_wiped(self, monkeypatch): + from seedsigner.controller import Controller + from seedsigner.models.wif import WIFKey + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + key = WIFKey(fresh(WIF)) + secret = key.privkey._secret + controller.psbt_seed = key + + run_inactivity_wipe(controller, monkeypatch) + + assert controller.psbt_seed is None + assert key.wif == "" + assert secret == bytes(len(secret)) + + def test_password_generator_entropy_is_zeroed_not_just_dropped(self, monkeypatch): + from seedsigner.controller import Controller + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + entropy_bytes = bytearray(b"\x11\x22\x33\x44") + roll_data = fresh("123456123456") + controller.password_generator_entropy_cache = { + "roll_data": roll_data, + "entropy_bytes": entropy_bytes, + } + + run_inactivity_wipe(controller, monkeypatch) + + assert controller.password_generator_entropy_cache is None + assert entropy_bytes == bytearray(len(entropy_bytes)) + assert roll_data == "\x00" * len(roll_data) + + def test_password_entropy_labels_are_left_intact(self, monkeypatch): + # password_type and entropy_source are module constants in + # production; only the rolls and the entropy bytes are secret. + from seedsigner.controller import Controller + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + password_type = fresh("dice_rolls") + entropy_source = fresh("dice") + roll_data = fresh("123456123456") + controller.password_generator_entropy_cache = { + "password_type": password_type, + "strength_bits": 128, + "entropy_source": entropy_source, + "word_count": None, + "roll_data": roll_data, + "entropy_bytes": None, + } + + run_inactivity_wipe(controller, monkeypatch) + + assert roll_data == "\x00" * len(roll_data) + assert password_type == "dice_rolls" + assert entropy_source == "dice" + + def test_code_constants_in_the_dicts_survive(self, monkeypatch): + # The same check through the code that builds the dicts. On CPython + # < 3.12 a code constant is not immortal and has fewer references than + # the shared-string limit, so wiping it in place would break the key + # file parser and every comparison with the constant until reboot. + # 3.12+ refuses to wipe the constants anyway: only the 3.10 lane, the + # Python the device runs, can fail here. + from seedsigner.controller import Controller + from seedsigner.views import tools_views + from seedsigner.views.smartcard_views import _parse_javacard_keys + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + key_file = "single: 00112233445566778899AABBCCDDEEFF" + controller.javacard_keys = _parse_javacard_keys(key_file) + tools_views._cache_password_entropy( + controller, + password_type=tools_views.PASSWORD_TYPE_DICE_ROLLS, + strength_bits=128, + entropy_source=tools_views.PASSWORD_ENTROPY_DICE, + word_count=None, + roll_data=fresh("123456123456"), + ) + + run_inactivity_wipe(controller, monkeypatch) + + assert _parse_javacard_keys(key_file)["type"] == fresh("single") + assert tools_views.PASSWORD_TYPE_DICE_ROLLS == fresh("dice_rolls") + assert tools_views.PASSWORD_ENTROPY_DICE == fresh("dice") + + def test_encryptedqr_key_is_zeroed(self, monkeypatch): + from seedsigner.controller import Controller + from seedsigner.models.encryptedqr import EncryptedQR, EncryptedQRStorage + + controller = Controller.get_instance() + controller._storage = SeedStorage() + storage2 = EncryptedQRStorage() + encryptedqr = EncryptedQR() + encryption_key = fresh("correct horse battery staple") + encryptedqr.set_encryption_key(encryption_key) + storage2.set_encryptedqr(encryptedqr) + controller._storage2 = storage2 + + run_inactivity_wipe(controller, monkeypatch) + + assert storage2.encryptedqr is None + assert encryption_key == "\x00" * len(encryption_key) + + +class TestWipeTimeoutClearsPsbtParserKeys(BaseTest): + """The psbt parser keeps a root key of its own, apart from psbt_seed.""" + + def test_parser_root_derived_from_the_seed_is_zeroed(self, monkeypatch): + # A BIP-39 seed hands the parser a new HDKey, so wiping the seed does + # not reach the parser's copy of the master key. + from seedsigner.controller import Controller + from seedsigner.models.psbt_parser import PSBTParser + from seedsigner.models.seed import Seed + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + seed = Seed([fresh(word) for word in MNEMONIC]) + parser = PSBTParser(None, seed=seed) + parser._set_root() + secret = parser.root.key._secret + chain_code = parser.root.chain_code + controller.psbt_seed = seed + controller.psbt_parser = parser + + run_inactivity_wipe(controller, monkeypatch) + + assert controller.psbt_parser is None + assert secret == bytes(len(secret)) + assert chain_code == bytes(len(chain_code)) + + def test_wif_key_held_only_by_the_parser_is_zeroed(self, monkeypatch): + # Back from the psbt overview, and a signature that did not verify, + # both set psbt_seed = None while the parser still holds the key. + from seedsigner.controller import Controller + from seedsigner.models.psbt_parser import PSBTParser + from seedsigner.models.wif import WIFKey + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + key = WIFKey(fresh(WIF)) + secret = key.privkey._secret + parser = PSBTParser(None, seed=key) + parser._set_root() + controller.psbt_seed = None + controller.psbt_parser = parser + + run_inactivity_wipe(controller, monkeypatch) + + assert key.wif == "" + assert secret == bytes(len(secret)) + + def test_public_parser_root_is_left_intact(self, monkeypatch): + # The card flow builds the parser from the card's xpub. It is not + # secret, so there is nothing to zero. + from embit import bip32 + from seedsigner.controller import Controller + from seedsigner.models.psbt_parser import PSBTParser + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + xpub = bip32.HDKey.from_string(fresh(XPRV)).to_public().to_string() + root = bip32.HDKey.from_string(xpub) + controller.psbt_parser = PSBTParser(None, root=root) + + run_inactivity_wipe(controller, monkeypatch) + + assert root.to_string() == xpub + + +class TestWipeTimeoutClearsSmartcardSecrets(BaseTest): + """Card PINs and unlock secrets are lists of ints; zero them, not just drop them.""" + + def test_card_pins_and_unlock_secrets_are_zeroed(self, monkeypatch): + from types import SimpleNamespace + from seedsigner.controller import Controller + from seedsigner.helpers import seedkeeper_utils + + controller = Controller.get_instance() + controller._storage = SeedStorage() + controller._storage2 = None + card_pin = list(b"123456") + connector_pin = list(b"123456") + controller.Satochip_PIN = card_pin + controller.Satochip_Connector = SimpleNamespace(pin=connector_pin) + seedkeeper_utils.cache_satodime_unlock_secret( + controller, "card", bytes(range(1, 21)), nickname="name" + ) + unlock_secret = controller.Satodime_unlock_secrets["card"] + named_unlock_secret = controller.Satodime_unlock_nicknames["name"][1] + admin_pin = fresh("12345678") + controller.GPG_Admin_PIN = admin_pin + + run_inactivity_wipe(controller, monkeypatch) + + assert card_pin == [] + assert connector_pin == [] + assert unlock_secret == [] + assert named_unlock_secret == [] + assert admin_pin == "\x00" * len(admin_pin) + assert controller.Satochip_PIN is None + assert controller.Satochip_Connector is None + assert controller.Satodime_unlock_secrets is None + assert controller.Satodime_unlock_nicknames is None + assert controller.GPG_Admin_PIN is None + + +class TestWipeTimerSurvivesAFailedWipe(BaseTest): + """The timer thread is the only thing that runs the inactivity wipe.""" + + def test_timer_keeps_running_after_the_wipe_raises(self, monkeypatch): + import sys + import threading + from types import SimpleNamespace + from seedsigner.controller import Controller, WipeTimerThread + + timer = WipeTimerThread() + timer.keep_running = True + wipes = [] + + def handle_wipe_timeout(): + wipes.append(len(wipes)) + if len(wipes) == 1: + raise RuntimeError("boom") + timer.keep_running = False + + # A controller and buttons of this test's own. The timer the app + # started holds the real ones, so it is left alone: stopping it and + # waiting for it could wait forever. + controller = SimpleNamespace( + settings=SimpleNamespace(get_value=lambda attr_name: 5), + wipe_timer_ms=None, + handle_wipe_timeout=handle_wipe_timeout, + ) + buttons = SimpleNamespace(last_input_time=0, update_last_input_time=lambda: None) + monkeypatch.setattr(Controller, "get_instance", classmethod(lambda cls: controller)) + # The module the timer imports its buttons from, whatever an earlier + # test left there. + monkeypatch.setitem(sys.modules, "seedsigner.hardware.buttons", SimpleNamespace( + HardwareButtons=SimpleNamespace(get_instance=lambda: buttons) + )) + + runner = threading.Thread(target=timer.run, daemon=True) + runner.start() + runner.join(10) + timer.keep_running = False + + assert not runner.is_alive() + assert wipes == [0, 1] + + +class TestHomeZeroesWifSigningKeys(FlowTest): + """A WIF key never enters SeedStorage. Home ends its flow and drops it.""" + + def test_home_zeroes_a_wif_psbt_seed(self): + from seedsigner.models.wif import WIFKey + from seedsigner.views.view import MainMenuView + + key = WIFKey(fresh(WIF)) + secret = key.privkey._secret + self.controller.psbt_seed = key + + self.run_sequence([FlowStep(MainMenuView)]) + + assert self.controller.psbt_seed is None + assert key.wif == "" + assert secret == bytes(len(secret)) + + def test_home_zeroes_a_wif_key_only_the_parser_holds(self): + from seedsigner.models.psbt_parser import PSBTParser + from seedsigner.models.wif import WIFKey + from seedsigner.views.view import MainMenuView + + key = WIFKey(fresh(WIF)) + secret = key.privkey._secret + parser = PSBTParser(None, seed=key) + parser._set_root() + self.controller.psbt_seed = None + self.controller.psbt_parser = parser + + self.run_sequence([FlowStep(MainMenuView)]) + + assert key.wif == "" + assert secret == bytes(len(secret)) + + def test_home_leaves_a_stored_seed_intact(self): + # A stored seed outlives the psbt flow. An XprvSeed hands the parser + # its own root, so zeroing the parser's root here would break it. + from seedsigner.models.psbt_parser import PSBTParser + from seedsigner.views.view import MainMenuView + + seed = XprvSeed(fresh(XPRV)) + secret = seed._root.key._secret + original = bytes(bytearray(secret)) + parser = PSBTParser(None, seed=seed) + parser._set_root() + self.controller.storage.seeds.append(seed) + self.controller.psbt_seed = seed + self.controller.psbt_parser = parser + + self.run_sequence([FlowStep(MainMenuView)]) + + assert seed._xprv == XPRV + assert secret == original + + +class TestWifKeyWipe(BaseTest): + """WIFKey holds a private key, so it needs the same wipe() as a Seed.""" + + def test_wipe_clears_the_wif_and_the_secret(self): + from seedsigner.models.wif import WIFKey + + key = WIFKey(fresh(WIF)) + secret = key.privkey._secret + + key.wipe() + + assert key.wif == "" + assert key.privkey is None + assert secret == bytes(len(secret)) + + +class TestTheDeviceWorksAfterAWipe(BaseTest): + """ + The wipe leaves the main menu on the back stack for the loop to run next. + Until it has run it has no view, and the screensaver's check read one: + every device with the Wipe Timer on showed a System Error after a wipe. + """ + + def test_the_screensaver_check_works_after_a_wipe(self): + from seedsigner.controller import Controller + + controller = Controller.get_instance() + controller.handle_wipe_timeout() + + assert controller.is_screensaver_start_allowed in (True, False) diff --git a/uv.lock b/uv.lock new file mode 100644 index 000000000..c39ebf54a --- /dev/null +++ b/uv.lock @@ -0,0 +1,171 @@ +version = 1 +revision = 3 +requires-python = ">=3.10" +resolution-markers = [ + "python_full_version >= '3.14'", + "python_full_version < '3.14'", +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "exceptiongroup" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" }, +] + +[[package]] +name = "iniconfig" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" }, +] + +[[package]] +name = "packaging" +version = "26.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" }, +] + +[[package]] +name = "pluggy" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, +] + +[[package]] +name = "pygments" +version = "2.21.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c", size = 5005329, upload-time = "2026-08-17T08:02:48.824Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" }, +] + +[[package]] +name = "pytest" +version = "9.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e4/47/b9efed96c114afcfa3c9d3fe98a76a1d14c74a9e266d397cf6eb64be5e01/pytest-9.1.1.tar.gz", hash = "sha256:1088fbde8f2b49d95a549a195707afa7a76a3ce9bcadc26b6d71f0ffda5fe313", size = 1636369, upload-time = "2026-06-19T10:58:32.857Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/24/25/1de2678b631f5a49215c6c96fff41ba892b0a34df68d6d80292b1b48aa7f/pytest-9.1.1-py3-none-any.whl", hash = "sha256:37a86b45efb9a47a61a36449063e8e18d0cab3161329fc099eb21783169c4f0c", size = 386536, upload-time = "2026-06-19T10:58:31.347Z" }, +] + +[[package]] +name = "pytest-order" +version = "1.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/97/d8/82a5dc2aad3392f66c9741960fcbeeb45dd4d62eedb218aed6c52eea36eb/pytest_order-1.5.0.tar.gz", hash = "sha256:96acd7587b5a2855dcaa4a898288103d202894a61afd813adbc9b77aab04d90d", size = 54136, upload-time = "2026-06-13T05:39:41.636Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fd/5c/bd6a85b44beb8bd74c0e86ab699ef0e096e260dc90458b84fc54c28e4335/pytest_order-1.5.0-py3-none-any.whl", hash = "sha256:667ba2b7303fe2c529848663e0a41dfb0cc4d64f09f87272e4a9a1751efb52b2", size = 16634, upload-time = "2026-06-13T05:39:40.431Z" }, +] + +[[package]] +name = "seedsigner" +version = "0.8.7" +source = { editable = "." } + +[package.optional-dependencies] +dev = [ + { name = "pytest-order" }, +] + +[package.metadata] +requires-dist = [{ name = "pytest-order", marker = "extra == 'dev'", specifier = ">=1.0" }] +provides-extras = ["dev"] + +[[package]] +name = "tomli" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/22/de/48c59722572767841493b26183a0d1cc411d54fd759c5607c4590b6563a6/tomli-2.4.1.tar.gz", hash = "sha256:7c7e1a961a0b2f2472c1ac5b69affa0ae1132c39adcb67aba98568702b9cc23f", size = 17543, upload-time = "2026-03-25T20:22:03.828Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f4/11/db3d5885d8528263d8adc260bb2d28ebf1270b96e98f0e0268d32b8d9900/tomli-2.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f8f0fc26ec2cc2b965b7a3b87cd19c5c6b8c5e5f436b984e85f486d652285c30", size = 154704, upload-time = "2026-03-25T20:21:10.473Z" }, + { url = "https://files.pythonhosted.org/packages/6d/f7/675db52c7e46064a9aa928885a9b20f4124ecb9bc2e1ce74c9106648d202/tomli-2.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4ab97e64ccda8756376892c53a72bd1f964e519c77236368527f758fbc36a53a", size = 149454, upload-time = "2026-03-25T20:21:12.036Z" }, + { url = "https://files.pythonhosted.org/packages/61/71/81c50943cf953efa35bce7646caab3cf457a7d8c030b27cfb40d7235f9ee/tomli-2.4.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:96481a5786729fd470164b47cdb3e0e58062a496f455ee41b4403be77cb5a076", size = 237561, upload-time = "2026-03-25T20:21:13.098Z" }, + { url = "https://files.pythonhosted.org/packages/48/c1/f41d9cb618acccca7df82aaf682f9b49013c9397212cb9f53219e3abac37/tomli-2.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5a881ab208c0baf688221f8cecc5401bd291d67e38a1ac884d6736cbcd8247e9", size = 243824, upload-time = "2026-03-25T20:21:14.569Z" }, + { url = "https://files.pythonhosted.org/packages/22/e4/5a816ecdd1f8ca51fb756ef684b90f2780afc52fc67f987e3c61d800a46d/tomli-2.4.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:47149d5bd38761ac8be13a84864bf0b7b70bc051806bc3669ab1cbc56216b23c", size = 242227, upload-time = "2026-03-25T20:21:15.712Z" }, + { url = "https://files.pythonhosted.org/packages/6b/49/2b2a0ef529aa6eec245d25f0c703e020a73955ad7edf73e7f54ddc608aa5/tomli-2.4.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ec9bfaf3ad2df51ace80688143a6a4ebc09a248f6ff781a9945e51937008fcbc", size = 247859, upload-time = "2026-03-25T20:21:17.001Z" }, + { url = "https://files.pythonhosted.org/packages/83/bd/6c1a630eaca337e1e78c5903104f831bda934c426f9231429396ce3c3467/tomli-2.4.1-cp311-cp311-win32.whl", hash = "sha256:ff2983983d34813c1aeb0fa89091e76c3a22889ee83ab27c5eeb45100560c049", size = 97204, upload-time = "2026-03-25T20:21:18.079Z" }, + { url = "https://files.pythonhosted.org/packages/42/59/71461df1a885647e10b6bb7802d0b8e66480c61f3f43079e0dcd315b3954/tomli-2.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:5ee18d9ebdb417e384b58fe414e8d6af9f4e7a0ae761519fb50f721de398dd4e", size = 108084, upload-time = "2026-03-25T20:21:18.978Z" }, + { url = "https://files.pythonhosted.org/packages/b8/83/dceca96142499c069475b790e7913b1044c1a4337e700751f48ed723f883/tomli-2.4.1-cp311-cp311-win_arm64.whl", hash = "sha256:c2541745709bad0264b7d4705ad453b76ccd191e64aa6f0fc66b69a293a45ece", size = 95285, upload-time = "2026-03-25T20:21:20.309Z" }, + { url = "https://files.pythonhosted.org/packages/c1/ba/42f134a3fe2b370f555f44b1d72feebb94debcab01676bf918d0cb70e9aa/tomli-2.4.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c742f741d58a28940ce01d58f0ab2ea3ced8b12402f162f4d534dfe18ba1cd6a", size = 155924, upload-time = "2026-03-25T20:21:21.626Z" }, + { url = "https://files.pythonhosted.org/packages/dc/c7/62d7a17c26487ade21c5422b646110f2162f1fcc95980ef7f63e73c68f14/tomli-2.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7f86fd587c4ed9dd76f318225e7d9b29cfc5a9d43de44e5754db8d1128487085", size = 150018, upload-time = "2026-03-25T20:21:23.002Z" }, + { url = "https://files.pythonhosted.org/packages/5c/05/79d13d7c15f13bdef410bdd49a6485b1c37d28968314eabee452c22a7fda/tomli-2.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ff18e6a727ee0ab0388507b89d1bc6a22b138d1e2fa56d1ad494586d61d2eae9", size = 244948, upload-time = "2026-03-25T20:21:24.04Z" }, + { url = "https://files.pythonhosted.org/packages/10/90/d62ce007a1c80d0b2c93e02cab211224756240884751b94ca72df8a875ca/tomli-2.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:136443dbd7e1dee43c68ac2694fde36b2849865fa258d39bf822c10e8068eac5", size = 253341, upload-time = "2026-03-25T20:21:25.177Z" }, + { url = "https://files.pythonhosted.org/packages/1a/7e/caf6496d60152ad4ed09282c1885cca4eea150bfd007da84aea07bcc0a3e/tomli-2.4.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:5e262d41726bc187e69af7825504c933b6794dc3fbd5945e41a79bb14c31f585", size = 248159, upload-time = "2026-03-25T20:21:26.364Z" }, + { url = "https://files.pythonhosted.org/packages/99/e7/c6f69c3120de34bbd882c6fba7975f3d7a746e9218e56ab46a1bc4b42552/tomli-2.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:5cb41aa38891e073ee49d55fbc7839cfdb2bc0e600add13874d048c94aadddd1", size = 253290, upload-time = "2026-03-25T20:21:27.46Z" }, + { url = "https://files.pythonhosted.org/packages/d6/2f/4a3c322f22c5c66c4b836ec58211641a4067364f5dcdd7b974b4c5da300c/tomli-2.4.1-cp312-cp312-win32.whl", hash = "sha256:da25dc3563bff5965356133435b757a795a17b17d01dbc0f42fb32447ddfd917", size = 98141, upload-time = "2026-03-25T20:21:28.492Z" }, + { url = "https://files.pythonhosted.org/packages/24/22/4daacd05391b92c55759d55eaee21e1dfaea86ce5c571f10083360adf534/tomli-2.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:52c8ef851d9a240f11a88c003eacb03c31fc1c9c4ec64a99a0f922b93874fda9", size = 108847, upload-time = "2026-03-25T20:21:29.386Z" }, + { url = "https://files.pythonhosted.org/packages/68/fd/70e768887666ddd9e9f5d85129e84910f2db2796f9096aa02b721a53098d/tomli-2.4.1-cp312-cp312-win_arm64.whl", hash = "sha256:f758f1b9299d059cc3f6546ae2af89670cb1c4d48ea29c3cacc4fe7de3058257", size = 95088, upload-time = "2026-03-25T20:21:30.677Z" }, + { url = "https://files.pythonhosted.org/packages/07/06/b823a7e818c756d9a7123ba2cda7d07bc2dd32835648d1a7b7b7a05d848d/tomli-2.4.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:36d2bd2ad5fb9eaddba5226aa02c8ec3fa4f192631e347b3ed28186d43be6b54", size = 155866, upload-time = "2026-03-25T20:21:31.65Z" }, + { url = "https://files.pythonhosted.org/packages/14/6f/12645cf7f08e1a20c7eb8c297c6f11d31c1b50f316a7e7e1e1de6e2e7b7e/tomli-2.4.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:eb0dc4e38e6a1fd579e5d50369aa2e10acfc9cace504579b2faabb478e76941a", size = 149887, upload-time = "2026-03-25T20:21:33.028Z" }, + { url = "https://files.pythonhosted.org/packages/5c/e0/90637574e5e7212c09099c67ad349b04ec4d6020324539297b634a0192b0/tomli-2.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c7f2c7f2b9ca6bdeef8f0fa897f8e05085923eb091721675170254cbc5b02897", size = 243704, upload-time = "2026-03-25T20:21:34.51Z" }, + { url = "https://files.pythonhosted.org/packages/10/8f/d3ddb16c5a4befdf31a23307f72828686ab2096f068eaf56631e136c1fdd/tomli-2.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f3c6818a1a86dd6dca7ddcaaf76947d5ba31aecc28cb1b67009a5877c9a64f3f", size = 251628, upload-time = "2026-03-25T20:21:36.012Z" }, + { url = "https://files.pythonhosted.org/packages/e3/f1/dbeeb9116715abee2485bf0a12d07a8f31af94d71608c171c45f64c0469d/tomli-2.4.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:d312ef37c91508b0ab2cee7da26ec0b3ed2f03ce12bd87a588d771ae15dcf82d", size = 247180, upload-time = "2026-03-25T20:21:37.136Z" }, + { url = "https://files.pythonhosted.org/packages/d3/74/16336ffd19ed4da28a70959f92f506233bd7cfc2332b20bdb01591e8b1d1/tomli-2.4.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:51529d40e3ca50046d7606fa99ce3956a617f9b36380da3b7f0dd3dd28e68cb5", size = 251674, upload-time = "2026-03-25T20:21:38.298Z" }, + { url = "https://files.pythonhosted.org/packages/16/f9/229fa3434c590ddf6c0aa9af64d3af4b752540686cace29e6281e3458469/tomli-2.4.1-cp313-cp313-win32.whl", hash = "sha256:2190f2e9dd7508d2a90ded5ed369255980a1bcdd58e52f7fe24b8162bf9fedbd", size = 97976, upload-time = "2026-03-25T20:21:39.316Z" }, + { url = "https://files.pythonhosted.org/packages/6a/1e/71dfd96bcc1c775420cb8befe7a9d35f2e5b1309798f009dca17b7708c1e/tomli-2.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:8d65a2fbf9d2f8352685bc1364177ee3923d6baf5e7f43ea4959d7d8bc326a36", size = 108755, upload-time = "2026-03-25T20:21:40.248Z" }, + { url = "https://files.pythonhosted.org/packages/83/7a/d34f422a021d62420b78f5c538e5b102f62bea616d1d75a13f0a88acb04a/tomli-2.4.1-cp313-cp313-win_arm64.whl", hash = "sha256:4b605484e43cdc43f0954ddae319fb75f04cc10dd80d830540060ee7cd0243cd", size = 95265, upload-time = "2026-03-25T20:21:41.219Z" }, + { url = "https://files.pythonhosted.org/packages/3c/fb/9a5c8d27dbab540869f7c1f8eb0abb3244189ce780ba9cd73f3770662072/tomli-2.4.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:fd0409a3653af6c147209d267a0e4243f0ae46b011aa978b1080359fddc9b6cf", size = 155726, upload-time = "2026-03-25T20:21:42.23Z" }, + { url = "https://files.pythonhosted.org/packages/62/05/d2f816630cc771ad836af54f5001f47a6f611d2d39535364f148b6a92d6b/tomli-2.4.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a120733b01c45e9a0c34aeef92bf0cf1d56cfe81ed9d47d562f9ed591a9828ac", size = 149859, upload-time = "2026-03-25T20:21:43.386Z" }, + { url = "https://files.pythonhosted.org/packages/ce/48/66341bdb858ad9bd0ceab5a86f90eddab127cf8b046418009f2125630ecb/tomli-2.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:559db847dc486944896521f68d8190be1c9e719fced785720d2216fe7022b662", size = 244713, upload-time = "2026-03-25T20:21:44.474Z" }, + { url = "https://files.pythonhosted.org/packages/df/6d/c5fad00d82b3c7a3ab6189bd4b10e60466f22cfe8a08a9394185c8a8111c/tomli-2.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:01f520d4f53ef97964a240a035ec2a869fe1a37dde002b57ebc4417a27ccd853", size = 252084, upload-time = "2026-03-25T20:21:45.62Z" }, + { url = "https://files.pythonhosted.org/packages/00/71/3a69e86f3eafe8c7a59d008d245888051005bd657760e96d5fbfb0b740c2/tomli-2.4.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7f94b27a62cfad8496c8d2513e1a222dd446f095fca8987fceef261225538a15", size = 247973, upload-time = "2026-03-25T20:21:46.937Z" }, + { url = "https://files.pythonhosted.org/packages/67/50/361e986652847fec4bd5e4a0208752fbe64689c603c7ae5ea7cb16b1c0ca/tomli-2.4.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ede3e6487c5ef5d28634ba3f31f989030ad6af71edfb0055cbbd14189ff240ba", size = 256223, upload-time = "2026-03-25T20:21:48.467Z" }, + { url = "https://files.pythonhosted.org/packages/8c/9a/b4173689a9203472e5467217e0154b00e260621caa227b6fa01feab16998/tomli-2.4.1-cp314-cp314-win32.whl", hash = "sha256:3d48a93ee1c9b79c04bb38772ee1b64dcf18ff43085896ea460ca8dec96f35f6", size = 98973, upload-time = "2026-03-25T20:21:49.526Z" }, + { url = "https://files.pythonhosted.org/packages/14/58/640ac93bf230cd27d002462c9af0d837779f8773bc03dee06b5835208214/tomli-2.4.1-cp314-cp314-win_amd64.whl", hash = "sha256:88dceee75c2c63af144e456745e10101eb67361050196b0b6af5d717254dddf7", size = 109082, upload-time = "2026-03-25T20:21:50.506Z" }, + { url = "https://files.pythonhosted.org/packages/d5/2f/702d5e05b227401c1068f0d386d79a589bb12bf64c3d2c72ce0631e3bc49/tomli-2.4.1-cp314-cp314-win_arm64.whl", hash = "sha256:b8c198f8c1805dc42708689ed6864951fd2494f924149d3e4bce7710f8eb5232", size = 96490, upload-time = "2026-03-25T20:21:51.474Z" }, + { url = "https://files.pythonhosted.org/packages/45/4b/b877b05c8ba62927d9865dd980e34a755de541eb65fffba52b4cc495d4d2/tomli-2.4.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:d4d8fe59808a54658fcc0160ecfb1b30f9089906c50b23bcb4c69eddc19ec2b4", size = 164263, upload-time = "2026-03-25T20:21:52.543Z" }, + { url = "https://files.pythonhosted.org/packages/24/79/6ab420d37a270b89f7195dec5448f79400d9e9c1826df982f3f8e97b24fd/tomli-2.4.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7008df2e7655c495dd12d2a4ad038ff878d4ca4b81fccaf82b714e07eae4402c", size = 160736, upload-time = "2026-03-25T20:21:53.674Z" }, + { url = "https://files.pythonhosted.org/packages/02/e0/3630057d8eb170310785723ed5adcdfb7d50cb7e6455f85ba8a3deed642b/tomli-2.4.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1d8591993e228b0c930c4bb0db464bdad97b3289fb981255d6c9a41aedc84b2d", size = 270717, upload-time = "2026-03-25T20:21:55.129Z" }, + { url = "https://files.pythonhosted.org/packages/7a/b4/1613716072e544d1a7891f548d8f9ec6ce2faf42ca65acae01d76ea06bb0/tomli-2.4.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:734e20b57ba95624ecf1841e72b53f6e186355e216e5412de414e3c51e5e3c41", size = 278461, upload-time = "2026-03-25T20:21:56.228Z" }, + { url = "https://files.pythonhosted.org/packages/05/38/30f541baf6a3f6df77b3df16b01ba319221389e2da59427e221ef417ac0c/tomli-2.4.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8a650c2dbafa08d42e51ba0b62740dae4ecb9338eefa093aa5c78ceb546fcd5c", size = 274855, upload-time = "2026-03-25T20:21:57.653Z" }, + { url = "https://files.pythonhosted.org/packages/77/a3/ec9dd4fd2c38e98de34223b995a3b34813e6bdadf86c75314c928350ed14/tomli-2.4.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:504aa796fe0569bb43171066009ead363de03675276d2d121ac1a4572397870f", size = 283144, upload-time = "2026-03-25T20:21:59.089Z" }, + { url = "https://files.pythonhosted.org/packages/ef/be/605a6261cac79fba2ec0c9827e986e00323a1945700969b8ee0b30d85453/tomli-2.4.1-cp314-cp314t-win32.whl", hash = "sha256:b1d22e6e9387bf4739fbe23bfa80e93f6b0373a7f1b96c6227c32bef95a4d7a8", size = 108683, upload-time = "2026-03-25T20:22:00.214Z" }, + { url = "https://files.pythonhosted.org/packages/12/64/da524626d3b9cc40c168a13da8335fe1c51be12c0a63685cc6db7308daae/tomli-2.4.1-cp314-cp314t-win_amd64.whl", hash = "sha256:2c1c351919aca02858f740c6d33adea0c5deea37f9ecca1cc1ef9e884a619d26", size = 121196, upload-time = "2026-03-25T20:22:01.169Z" }, + { url = "https://files.pythonhosted.org/packages/5a/cd/e80b62269fc78fc36c9af5a6b89c835baa8af28ff5ad28c7028d60860320/tomli-2.4.1-cp314-cp314t-win_arm64.whl", hash = "sha256:eab21f45c7f66c13f2a9e0e1535309cee140182a9cdae1e041d02e47291e8396", size = 100393, upload-time = "2026-03-25T20:22:02.137Z" }, + { url = "https://files.pythonhosted.org/packages/7b/61/cceae43728b7de99d9b847560c262873a1f6c98202171fd5ed62640b494b/tomli-2.4.1-py3-none-any.whl", hash = "sha256:0d85819802132122da43cb86656f8d1f8c6587d54ae7dcaf30e90533028b49fe", size = 14583, upload-time = "2026-03-25T20:22:03.012Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, +]