Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 def setUpClass(cls):
     with open_device()[0] as conn:
         controller = OpgpController(SmartCardProtocol(conn))
         controller.reset()
Exemplo n.º 8
0
 def reconnect(self):
     self.conn.close()
     self.conn = open_device()[0]
     self.controller = OpgpController(SmartCardProtocol(self.conn))
Exemplo n.º 9
0
 def setUp(self):
     self.conn = open_device()[0]
     self.controller = OpgpController(SmartCardProtocol(self.conn))
Exemplo n.º 10
0
 def setUpClass(cls):
     with open_device() as dev:
         controller = OpgpController(dev.driver)
         controller.reset()
Exemplo n.º 11
0
 def reconnect(self):
     self.dev.driver.close()
     self.dev = open_device()
     self.controller = OpgpController(self.dev.driver)
Exemplo n.º 12
0
 def setUp(self):
     self.dev = open_device()
     self.controller = OpgpController(self.dev.driver)