Skip to content

Commit c5034bb

Browse files
committed
Fix solo key {set-pin,change-pin,verify}
1 parent e42953f commit c5034bb

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

solo/cli/key.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,9 @@ def verify(pin, serial, udp):
349349

350350
key = solo.client.find(serial, udp=udp)
351351

352-
if (
353-
key.client
354-
and ("clientPin" in key.client.info.options)
355-
and key.client.info.options["clientPin"]
356-
and not pin
357-
):
358-
pin = getpass.getpass("PIN: ")
359-
360352
# Any longer and this needs to go in a submodule
361-
print("Please press the button on your Solo key")
362353
try:
363-
cert = key.make_credential(pin=pin)
354+
cert = key.make_credential()
364355
except Fido2ClientError as e:
365356
cause = str(e.cause)
366357
if "PIN required" in cause:

solo/devices/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def make_credential(self, pin=None):
104104
attest.verify(data.hash)
105105
except AttributeError:
106106
verifier = Attestation.for_type(attest.fmt)
107-
verifier().verify(attest.att_statement, attest.auth_data, data.hash)
107+
verifier().verify(attest.att_stmt, attest.auth_data, data.hash)
108108
print("Register valid")
109-
x5c = attest.att_statement["x5c"][0]
109+
x5c = attest.att_stmt["x5c"][0]
110110
cert = x509.load_der_x509_certificate(x5c, default_backend())
111111

112112
return cert

solo/devices/solo_v1.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,29 @@
66
import time
77
from threading import Event
88

9-
from fido2.client import Fido2Client
9+
from fido2.client import Fido2Client, UserInteraction
1010
from fido2.ctap import CtapError
1111
from fido2.ctap1 import Ctap1
1212
from fido2.ctap2 import Ctap2
1313
from fido2.hid import CTAPHID, CtapHidDevice
1414
from intelhex import IntelHex
15+
from getpass import getpass
1516

1617
from .. import exceptions, helpers
1718
from ..commands import SoloBootloader, SoloExtension
1819
from .base import SoloClient
1920

21+
# Handle user interaction
22+
class CliInteraction(UserInteraction):
23+
def prompt_up(self):
24+
print("\nTouch your authenticator device now...\n")
25+
26+
def request_pin(self, permissions, rd_id):
27+
return getpass("Enter PIN: ")
28+
29+
def request_uv(self, permissions, rd_id):
30+
print("User Verification required.")
31+
return True
2032

2133
class Client(SoloClient):
2234
def __init__(
@@ -71,7 +83,7 @@ def find_device(self, dev=None, solo_serial=None):
7183
self.ctap2 = None
7284

7385
try:
74-
self.client = Fido2Client(dev, self.origin)
86+
self.client = Fido2Client(dev, self.origin, user_interaction=CliInteraction())
7587
except CtapError:
7688
print("Not using FIDO2 interface.")
7789
self.client = None

0 commit comments

Comments
 (0)