gpg: use pinentry UI for initialization and agent

This commit is contained in:
Roman Zeyde
2018-03-07 13:19:02 +02:00
parent 64064b5ecc
commit 17ea941add
2 changed files with 18 additions and 3 deletions

View File

@@ -77,19 +77,23 @@ class AgentStop(Exception):
"""Raised to close the agent."""
# pylint: disable=too-many-instance-attributes
class Handler(object):
"""GPG agent requests' handler."""
# pylint: disable=too-many-instance-attributes
def _get_options(self):
return self.options
def __init__(self, device, pubkey_bytes):
"""C-tor."""
self.reset()
device.ui.options_getter = self._get_options
self.client = client.Client(device=device)
# Cache public keys from GnuPG
self.pubkey_bytes = pubkey_bytes
# "Clone" existing GPG version
self.version = keyring.gpg_version()
self.reset()
self.handlers = {
b'RESET': lambda *_: self.reset(),
b'OPTION': lambda _, args: self.handle_option(*args),