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