Generate a secure key if it is not found.

Should fix #23.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2023-11-06 11:48:32 +01:00
parent 85298062cd
commit 04238509ee
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
3 changed files with 7 additions and 5 deletions

View File

@ -442,7 +442,7 @@ def attestation(vdr, args):
vdr.upload_ea(cert.public_bytes(Encoding.DER))
def main(args):
print('Pico Fido Tool v1.5')
print('Pico Fido Tool v1.6')
print('Author: Pol Henarejos')
print('Report bugs to https://github.com/polhenarejos/pico-fido/issues')
print('')

View File

@ -51,7 +51,9 @@ def get_secure_key():
try:
backend = get_backend(False)
key = backend.get_password(DOMAIN, USERNAME)[0]
except keyring.errors.KeyringError:
if (key is None):
raise TypeError
except (keyring.errors.KeyringError, TypeError):
try:
key = generate_secure_key(False)[0] # It should be True, but secure enclave causes python segfault
except keyring.errors.PasswordSetError:

View File

@ -1,6 +1,4 @@
import sys
import os
import base64
DOMAIN = "PicoKeys.com"
USERNAME = "Pico-Fido"
@ -39,6 +37,8 @@ def get_secure_key():
key = None
try:
key = keyring.get_password(DOMAIN, USERNAME)
except keyring.errors.KeyringError:
if (key is None):
raise TypeError
except (keyring.errors.KeyringError, TypeError):
key = generate_secure_key()
return get_d(key.encode())