def openpgp_get_remaining_pin_retries(self): try: with self._open_device(TRANSPORT.CCID) as dev: controller = OpgpController(dev.driver) return controller.get_remaining_pin_tries() except Exception as e: logger.error('Failed to get remaining OpenPGP PIN retries', exc_info=e) return None
def openpgp_reset(self): try: with self._open_device(TRANSPORT.CCID) as dev: controller = OpgpController(dev.driver) controller.reset() return True except Exception as e: logger.error('Failed to reset OpenPGP applet', exc_info=e) return False
def openpgp_get_touch(self): try: with self._open_device(TRANSPORT.CCID) as dev: controller = OpgpController(dev.driver) auth = controller.get_touch(KEY_SLOT.AUTHENTICATE) enc = controller.get_touch(KEY_SLOT.ENCRYPT) sig = controller.get_touch(KEY_SLOT.SIGN) return [auth, enc, sig] except Exception as e: logger.error('Failed to get OpenPGP touch policy', exc_info=e) return None
def openpgp_set_pin_retries(self, admin_pin, pin_retries, reset_code_retries, admin_pin_retries): try: with self._open_device(TRANSPORT.CCID) as dev: controller = OpgpController(dev.driver) controller.set_pin_retries(int(pin_retries), int(reset_code_retries), int(admin_pin_retries), admin_pin.encode()) return True except Exception as e: logger.error('Failed to set OpenPGP PIN retries', exc_info=e) return False
def openpgp_get_version(self): try: with self._open_device(TRANSPORT.CCID) as dev: controller = OpgpController(dev.driver) return controller.version except Exception as e: logger.error('Failed to get OpenPGP applet version', exc_info=e) return None
def openpgp_set_touch(self, admin_pin, auth, enc, sig): try: with self._open_device(TRANSPORT.CCID) as dev: controller = OpgpController(dev.driver) if auth >= 0: controller.set_touch(KEY_SLOT.AUTHENTICATE, int(auth), admin_pin.encode()) if enc >= 0: controller.set_touch(KEY_SLOT.ENCRYPT, int(enc), admin_pin.encode()) if sig >= 0: controller.set_touch(KEY_SLOT.SIGN, int(sig), admin_pin.encode()) return True except Exception as e: logger.error('Failed to set OpenPGP touch policy', exc_info=e) return False
def setUpClass(cls): with open_device()[0] as conn: controller = OpgpController(SmartCardProtocol(conn)) controller.reset()
def reconnect(self): self.conn.close() self.conn = open_device()[0] self.controller = OpgpController(SmartCardProtocol(self.conn))
def setUp(self): self.conn = open_device()[0] self.controller = OpgpController(SmartCardProtocol(self.conn))
def setUpClass(cls): with open_device() as dev: controller = OpgpController(dev.driver) controller.reset()
def reconnect(self): self.dev.driver.close() self.dev = open_device() self.controller = OpgpController(self.dev.driver)
def setUp(self): self.dev = open_device() self.controller = OpgpController(self.dev.driver)