def authenticate(self, message_hash, app_hash, key_handle): """Sign a message with a security key using CTAP version 1""" self._poll() if self.dev.error == 'nocred': raise ApduError(APDU.WRONG_DATA, b'') elif self.dev.error == 'err': raise ApduError(0, b'') flags, counter, sig = self._sign(message_hash, app_hash, key_handle, SSH_SK_USER_PRESENCE_REQD) return Byte(flags) + UInt32(counter) + sig
def register(self, client_data_hash, app_hash): """Enroll a new security key using CTAP version 1""" # pylint: disable=unused-argument self._poll() if self.dev.error == 'err': raise ApduError(0, b'') public_key, key_handle = self._enroll(SSH_SK_ECDSA) return _Registration(public_key, key_handle)
def _poll(self): """Simulate needing to poll the security device""" if not self._polled: self._polled = True raise ApduError(APDU.USE_NOT_SATISFIED, b'')