gpg: move 'iterlines' to keyring
This commit is contained in:
parent
8a51099488
commit
295d52ef10
@ -99,15 +99,6 @@ def pkdecrypt(keygrip, conn):
|
||||
return _serialize_point(shared_secret)
|
||||
|
||||
|
||||
def iterlines(conn):
|
||||
"""Iterate over input, split by lines."""
|
||||
while True:
|
||||
line = keyring.recvline(conn)
|
||||
if line is None:
|
||||
break
|
||||
yield line
|
||||
|
||||
|
||||
def handle_connection(conn):
|
||||
"""Handle connection from GPG binary using the ASSUAN protocol."""
|
||||
keygrip = None
|
||||
@ -116,7 +107,7 @@ def handle_connection(conn):
|
||||
version = keyring.gpg_version()
|
||||
|
||||
keyring.sendline(conn, b'OK')
|
||||
for line in iterlines(conn):
|
||||
for line in keyring.iterlines(conn):
|
||||
parts = line.split(' ')
|
||||
command = parts[0]
|
||||
args = parts[1:]
|
||||
|
@ -52,6 +52,15 @@ def recvline(sock):
|
||||
return result
|
||||
|
||||
|
||||
def iterlines(conn):
|
||||
"""Iterate over input, split by lines."""
|
||||
while True:
|
||||
line = recvline(conn)
|
||||
if line is None:
|
||||
break
|
||||
yield line
|
||||
|
||||
|
||||
def unescape(s):
|
||||
"""Unescape ASSUAN message (0xAB <-> '%AB')."""
|
||||
s = bytearray(s)
|
||||
|
@ -74,3 +74,9 @@ SETHASH 8 4141414141414141414141414141414141414141414141414141414141414141
|
||||
SETKEYDESC Sign+a+new+TREZOR-based+subkey
|
||||
PKSIGN
|
||||
'''
|
||||
|
||||
|
||||
def test_iterlines():
|
||||
sock = FakeSocket()
|
||||
sock.rx.write(b'foo\nbar\nxyz')
|
||||
assert list(keyring.iterlines(sock)) == []
|
||||
|
Loading…
Reference in New Issue
Block a user