From b1bd6cb6908e636385097f43ae193eecf789f70b Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Mon, 23 Apr 2018 22:59:11 +0300 Subject: [PATCH] gpg: refactor GETINFO handling into a separate method --- libagent/gpg/agent.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libagent/gpg/agent.py b/libagent/gpg/agent.py index 92bb2d7..0079fe4 100644 --- a/libagent/gpg/agent.py +++ b/libagent/gpg/agent.py @@ -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 = {