44from cryptography .hazmat .backends import default_backend
55from fido2 .attestation import Attestation
66from fido2 .ctap2 import Ctap2 , CredentialManagement
7+ from fido2 .ctap2 .pin import ClientPin
78from fido2 .hid import CTAPHID
89from fido2 .utils import hmac_sha256
910from 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 ,
0 commit comments