1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-22 04:22:07 +00:00

core: do not prompt for passphrase if 'always' setting is enabled

This commit is contained in:
Tomas Susanka 2019-12-11 15:25:22 +00:00 committed by Pavol Rusnak
parent 466dc4732d
commit ece351c5e5
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -27,21 +27,27 @@ async def get(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()
ack = await ctx.call(request, PassphraseAck)
if ack.on_device:
if ack.passphrase is not None:
raise wire.ProcessError("Passphrase provided when it should not be")
passphrase = await request_from_user_on_device(ctx)
else:
if ack.passphrase is None:
raise wire.ProcessError("Passphrase not provided")
passphrase = ack.passphrase
return await request_from_user_on_device(ctx)
if len(passphrase) > _MAX_PASSPHRASE_LEN:
raise wire.DataError("Maximum passphrase length is %d" % _MAX_PASSPHRASE_LEN)
return passphrase
if ack.passphrase is None:
raise wire.ProcessError("Passphrase not provided")
return ack.passphrase
async def request_from_user_on_device(ctx: wire.Context) -> str: