Skip to content

Commit 26b0fd4

Browse files
committed
Fix solo key {set-pin,change-pin,verify} and solo key credential info
1 parent 952abb2 commit 26b0fd4

3 files changed

Lines changed: 27 additions & 24 deletions

File tree

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: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from cryptography.hazmat.backends import default_backend
55
from fido2.attestation import Attestation
66
from fido2.ctap2 import Ctap2, CredentialManagement
7+
from fido2.ctap2.pin import ClientPin
78
from fido2.hid import CTAPHID
89
from fido2.utils import hmac_sha256
910
from fido2.webauthn import PublicKeyCredentialCreationOptions
@@ -79,12 +80,12 @@ def reset(
7980
Ctap2(self.get_current_hid_device()).reset()
8081

8182
def change_pin(self, old_pin, new_pin):
82-
client = self.get_current_fido_client()
83-
client.client_pin.change_pin(old_pin, new_pin)
83+
client = ClientPin(self.ctap2)
84+
client.change_pin(old_pin, new_pin)
8485

8586
def set_pin(self, new_pin):
86-
client = self.get_current_fido_client()
87-
client.client_pin.set_pin(new_pin)
87+
client = ClientPin(self.ctap2)
88+
client.set_pin(new_pin)
8889

8990
def make_credential(self, pin=None):
9091
client = self.get_current_fido_client()
@@ -97,25 +98,24 @@ def make_credential(self, pin=None):
9798
challenge,
9899
[{"type": "public-key", "alg": -8}, {"type": "public-key", "alg": -7}],
99100
)
100-
result = client.make_credential(options, pin=pin)
101+
result = client.make_credential(options)
101102
attest = result.attestation_object
102103
data = result.client_data
103104
try:
104105
attest.verify(data.hash)
105106
except AttributeError:
106107
verifier = Attestation.for_type(attest.fmt)
107-
verifier().verify(attest.att_statement, attest.auth_data, data.hash)
108+
verifier().verify(attest.att_stmt, attest.auth_data, data.hash)
108109
print("Register valid")
109-
x5c = attest.att_statement["x5c"][0]
110+
x5c = attest.att_stmt["x5c"][0]
110111
cert = x509.load_der_x509_certificate(x5c, default_backend())
111112

112113
return cert
113114

114115
def cred_mgmt(self, pin):
115-
client = self.get_current_fido_client()
116-
token = client.client_pin.get_pin_token(pin)
117-
return CredentialManagement(ctap2, client.client_pin.protocol, token)
118-
ctap2 = Ctap2(self.get_current_hid_device())
116+
client = ClientPin(self.ctap2)
117+
token = client.get_pin_token(pin)
118+
return CredentialManagement(self.ctap2, client.protocol, token)
119119

120120
def enter_solo_bootloader(
121121
self,
@@ -144,7 +144,7 @@ def sign_hash(self, credential_id, dgst, pin):
144144
ctap2 = Ctap2(self.get_current_hid_device())
145145
client = self.get_current_fido_client()
146146
if pin:
147-
pin_token = client.client_pin.get_pin_token(pin)
147+
pin_token = client.ClientPin.get_pin_token(pin)
148148
pin_auth = hmac_sha256(pin_token, dgst)[:16]
149149
return ctap2.send_cbor(
150150
0x50,

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)