1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

core/management: get next u2f counter

This commit is contained in:
Tomas Susanka 2019-11-13 10:37:45 +00:00
parent 2a20287882
commit a8b82975a1
3 changed files with 23 additions and 1 deletions

View File

@ -14,4 +14,5 @@ def boot() -> None:
wire.add(MessageType.ApplyFlags, __name__, "apply_flags")
wire.add(MessageType.ChangePin, __name__, "change_pin")
wire.add(MessageType.SetU2FCounter, __name__, "set_u2f_counter")
wire.add(MessageType.GetNextU2FCounter, __name__, "get_next_u2f_counter")
wire.add(MessageType.SdProtect, __name__, "sd_protect")

View File

@ -0,0 +1,20 @@
import storage.device
from trezor import ui, wire
from trezor.messages import ButtonRequestType
from trezor.messages.GetNextU2FCounter import GetNextU2FCounter
from trezor.messages.NextU2FCounter import NextU2FCounter
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
async def get_next_u2f_counter(
ctx: wire.Context, msg: GetNextU2FCounter
) -> NextU2FCounter:
text = Text("Get next U2F counter", ui.ICON_CONFIG)
text.normal("Do you really want to")
text.bold("increase and retrieve")
text.normal("the U2F counter?")
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)
return NextU2FCounter(storage.device.next_u2f_counter())

View File

@ -1,13 +1,14 @@
import storage.device
from trezor import ui, wire
from trezor.messages import ButtonRequestType
from trezor.messages.SetU2FCounter import SetU2FCounter
from trezor.messages.Success import Success
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
async def set_u2f_counter(ctx, msg):
async def set_u2f_counter(ctx: wire.Context, msg: SetU2FCounter) -> Success:
if msg.u2f_counter is None:
raise wire.ProcessError("No value provided")