@@ -174,12 +174,6 @@ def make_credential(serial, host, default_sign_host, user, udp, prompt, pin,
174174 print ("Error: Unknown algorithm(s): " , [a for a , aid in zip (alg .split ("," ), algs ) if aid is None ])
175175 return 1
176176
177- # check for PIN
178- if not pin :
179- pin = getpass .getpass ("PIN (leave empty for no PIN): " )
180- if not pin :
181- pin = None
182-
183177 if default_sign_host :
184178 if host is not None :
185179 print ("Error: Cannot specify both --host and --default-sign-host" )
@@ -188,6 +182,12 @@ def make_credential(serial, host, default_sign_host, user, udp, prompt, pin,
188182 elif host is None :
189183 host = "solokeys.dev"
190184
185+ # check for PIN
186+ if not pin :
187+ pin = getpass .getpass ("PIN (leave empty for no PIN): " )
188+ if not pin :
189+ pin = None
190+
191191 cred_id , pk = solo .hmac_secret .make_credential (
192192 host = host ,
193193 user_id = user ,
@@ -745,6 +745,13 @@ def sign_file(pin, serial, udp, prompt, credential_id, host, filename, sig_file,
745745 if err .code == CtapError .ERR .INVALID_OPTION :
746746 print ("Got CTAP error 0x2C INVALID_OPTION. Are you sure you used an EdDSA credential with Minisign?" )
747747 return 1
748+ elif err .code == CtapError .ERR .INVALID_CREDENTIAL :
749+ print ("Got CTAP error 0x22 INVALID_CREDENTIAL." )
750+ if host .startswith ("solo-sign-hash:" ):
751+ print ("Are you sure you created this credential using a 'solo-sign-hash:...' host?" )
752+ else :
753+ print ("Host should start with 'solo-sign-hash:'" )
754+ return 1
748755 else :
749756 raise
750757
@@ -781,7 +788,17 @@ def sign_file(pin, serial, udp, prompt, credential_id, host, filename, sig_file,
781788 print (f"Signature using key { key_id_hex } written to { sig_file } " )
782789
783790 else :
784- ret = dev .sign_hash (credential_id , dgst .digest (), pin , host )
791+ try :
792+ ret = dev .sign_hash (credential_id , dgst .digest (), pin , host )
793+ except CtapError as err :
794+ if err .code == CtapError .ERR .INVALID_CREDENTIAL :
795+ print ("Got CTAP error 0x22 INVALID_CREDENTIAL." )
796+ if host .startswith ("solo-sign-hash:" ):
797+ print ("Are you sure you created this credential using a 'solo-sign-hash:...' host?" )
798+ else :
799+ print ("Host should start with 'solo-sign-hash:'" )
800+ return 1
801+
785802 signature = ret [1 ]
786803
787804 print (f"Signature (Base64): { base64 .b64encode (signature ).decode ()} " )
0 commit comments