Skip to content

Commit

Permalink
Merge #495: trezor: Return PASSPHRASE_ON_DEVICE if passphrase entry o…
Browse files Browse the repository at this point in the history
…n device is available

551d72f trezor: Return PASSPHRASE_ON_DEVICE if passphrase entry on device is available (Andrew Chow)

Pull request description:

  Somewhere between firmware versions 2.3.0 and 2.3.6, the Trezor T started using a slightly different message which results in our passphrase handling incorrectly giving the passphrase from the host instead of forcing passphrase entry on device. We fix this issue by returning the correct object to indicate that passphrase entry should occur on device.

Top commit has no ACKs.

Tree-SHA512: e6d6fde4a252946217c90b4553d0337247fa08c15e7f2147bdec96f5db9e5982ac2d6bc2877e5c0c1d967eb3574625cb4abc8ea5a5c51ab7b7fcf73291a4d391
  • Loading branch information
achow101 committed Mar 19, 2021
2 parents 87b3f4b + 551d72f commit 0cd94a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hwilib/devices/trezor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
common_err_msgs,
handle_errors,
)
from .trezorlib.client import TrezorClient as Trezor
from .trezorlib.client import TrezorClient as Trezor, PASSPHRASE_ON_DEVICE
from .trezorlib.debuglink import TrezorClientDebugLink
from .trezorlib.exceptions import Cancelled, TrezorFailure
from .trezorlib.transport import (
Expand Down Expand Up @@ -211,7 +211,9 @@ def get_pin(self, code: Optional[int] = None) -> NoReturn:
def disallow_passphrase(self) -> None:
self.return_passphrase = False

def get_passphrase(self, available_on_device: bool) -> str:
def get_passphrase(self, available_on_device: bool) -> object:
if available_on_device:
return PASSPHRASE_ON_DEVICE
if self.return_passphrase:
return self.passphrase
raise ValueError('Passphrase from Host is not allowed for Trezor T')
Expand Down

0 comments on commit 0cd94a8

Please sign in to comment.