gpg: refactor GETINFO handling into a separate method

This commit is contained in:
Roman Zeyde 2018-04-23 22:59:11 +03:00
parent 766536d2c4
commit b1bd6cb690
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -92,7 +92,7 @@ class Handler(object):
b'OPTION': lambda _, args: self.handle_option(*args),
b'SETKEYDESC': None,
b'NOP': None,
b'GETINFO': lambda conn, _: keyring.sendline(conn, b'D ' + self.version),
b'GETINFO': self.handle_getinfo,
b'AGENT_ID': lambda conn, _: keyring.sendline(conn, b'D TREZOR'), # "Fake" agent ID
b'SIGKEY': lambda _, args: self.set_key(*args),
b'SETKEY': lambda _, args: self.set_key(*args),
@ -115,6 +115,10 @@ class Handler(object):
self.options.append(opt)
log.debug('options: %s', self.options)
def handle_getinfo(self, conn, _args):
"""Handle some of the GETINFO messages."""
keyring.sendline(conn, b'D ' + self.version)
def handle_scd(self, conn, args):
"""No support for smart-card device protocol."""
reply = {