Helper: Recover from failure to unwrap access key.

This commit is contained in:
Dain Nilsson 2022-11-29 11:24:25 +01:00
parent 7a043cb8c3
commit ddbedc0294
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -22,7 +22,7 @@ from .base import (
encode_bytes,
decode_bytes,
)
from ykman.settings import AppData
from ykman.settings import AppData, UnwrapValueError
from yubikit.core import require_version, NotSupportedError
from yubikit.core.smartcard import ApduError, SW
from yubikit.oath import OathSession, CredentialData, OATH_TYPE, HASH_ALGORITHM
@ -71,7 +71,10 @@ class OathNode(RpcNode):
def _get_access_key(self, device_id):
keys = self._get_keys()
if self.session.device_id in keys and self._unlock_keystore():
return bytes.fromhex(keys.get_secret(self.session.device_id))
try:
return bytes.fromhex(keys.get_secret(self.session.device_id))
except UnwrapValueError:
logger.warning("Failed to unwrap access key", exc_info=True)
return None
def __init__(self, connection):