mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-23 13:02:03 +00:00
core: do not prompt for passphrase if 'always' setting is enabled
This commit is contained in:
parent
466dc4732d
commit
ece351c5e5
@ -27,21 +27,27 @@ async def get(ctx: wire.Context) -> str:
|
|||||||
|
|
||||||
|
|
||||||
async def request_from_user(ctx: wire.Context) -> str:
|
async def request_from_user(ctx: wire.Context) -> str:
|
||||||
|
passphrase = await _get_from_user(ctx)
|
||||||
|
if len(passphrase) > _MAX_PASSPHRASE_LEN:
|
||||||
|
raise wire.DataError("Maximum passphrase length is %d" % _MAX_PASSPHRASE_LEN)
|
||||||
|
|
||||||
|
return passphrase
|
||||||
|
|
||||||
|
|
||||||
|
async def _get_from_user(ctx: wire.Context) -> str:
|
||||||
|
if storage.device.get_passphrase_always_on_device():
|
||||||
|
return await request_from_user_on_device(ctx)
|
||||||
|
|
||||||
request = PassphraseRequest()
|
request = PassphraseRequest()
|
||||||
ack = await ctx.call(request, PassphraseAck)
|
ack = await ctx.call(request, PassphraseAck)
|
||||||
if ack.on_device:
|
if ack.on_device:
|
||||||
if ack.passphrase is not None:
|
if ack.passphrase is not None:
|
||||||
raise wire.ProcessError("Passphrase provided when it should not be")
|
raise wire.ProcessError("Passphrase provided when it should not be")
|
||||||
passphrase = await request_from_user_on_device(ctx)
|
return await request_from_user_on_device(ctx)
|
||||||
else:
|
|
||||||
if ack.passphrase is None:
|
if ack.passphrase is None:
|
||||||
raise wire.ProcessError("Passphrase not provided")
|
raise wire.ProcessError("Passphrase not provided")
|
||||||
passphrase = ack.passphrase
|
return ack.passphrase
|
||||||
|
|
||||||
if len(passphrase) > _MAX_PASSPHRASE_LEN:
|
|
||||||
raise wire.DataError("Maximum passphrase length is %d" % _MAX_PASSPHRASE_LEN)
|
|
||||||
|
|
||||||
return passphrase
|
|
||||||
|
|
||||||
|
|
||||||
async def request_from_user_on_device(ctx: wire.Context) -> str:
|
async def request_from_user_on_device(ctx: wire.Context) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user