def _migrate_from_version_01() -> None: # Make the U2F counter public and writable even when storage is locked. # U2F counter wasn't public, so we are intentionally not using storage.device module. counter = common.get(common.APP_DEVICE, device.U2F_COUNTER) if counter is not None: device.set_u2f_counter(int.from_bytes(counter, "big")) # Delete the old, non-public U2F_COUNTER. common.delete(common.APP_DEVICE, device.U2F_COUNTER) set_current_version()
def set_sd_salt_auth_key(auth_key: bytes | None) -> None: """ The key used to check the authenticity of the SD card salt. """ if auth_key is not None: if len(auth_key) != SD_SALT_AUTH_KEY_LEN_BYTES: raise ValueError return common.set(_NAMESPACE, _SD_SALT_AUTH_KEY, auth_key, public=True) else: return common.delete(_NAMESPACE, _SD_SALT_AUTH_KEY, public=True)
def set_backed_up() -> None: common.delete(_NAMESPACE, _NEEDS_BACKUP)
def delete() -> None: for index in range(slip39.MAX_SHARE_COUNT * slip39.MAX_GROUP_COUNT): common.delete(common.APP_RECOVERY_SHARES, index)
def end_progress() -> None: _require_progress() common.delete(_NAMESPACE, _IN_PROGRESS) common.delete(_NAMESPACE, _DRY_RUN) common.delete(_NAMESPACE, _SLIP39_IDENTIFIER) common.delete(_NAMESPACE, _SLIP39_THRESHOLD) common.delete(_NAMESPACE, _REMAINING) common.delete(_NAMESPACE, _SLIP39_ITERATION_EXPONENT) common.delete(_NAMESPACE, _SLIP39_GROUP_COUNT) recovery_shares.delete()
def delete_all() -> None: for i in range(MAX_RESIDENT_CREDENTIALS): common.delete(common.APP_WEBAUTHN, i + _RESIDENT_CREDENTIAL_START_KEY)
def delete(index: int) -> None: if not 0 <= index < MAX_RESIDENT_CREDENTIALS: raise ValueError # invalid credential index common.delete(common.APP_WEBAUTHN, index + _RESIDENT_CREDENTIAL_START_KEY)