mirror of
https://github.com/romanz/amodem.git
synced 2026-02-07 09:28:02 +08:00
HACK: fixup tests
This commit is contained in:
@@ -50,6 +50,7 @@ def pksign(keygrip, digest, algo):
|
||||
|
||||
|
||||
def iterlines(conn):
|
||||
"""Iterate over input, split by lines."""
|
||||
while True:
|
||||
line = keyring.recvline(conn)
|
||||
if line is None:
|
||||
|
||||
@@ -24,7 +24,6 @@ def connect_to_agent(sock_path='~/.gnupg/S.gpg-agent', sp=subprocess):
|
||||
|
||||
def communicate(sock, msg):
|
||||
"""Send a message and receive a single line."""
|
||||
msg += '\n'
|
||||
sendline(sock, msg.encode('ascii'))
|
||||
return recvline(sock)
|
||||
|
||||
|
||||
@@ -78,9 +78,12 @@ def _serialize_ed25519(vk):
|
||||
|
||||
|
||||
def _compute_keygrip(params):
|
||||
exp = ''.join('(1:{}{}:{})'.format(name, len(value), value)
|
||||
for name, value in params)
|
||||
return hashlib.sha1(exp).digest()
|
||||
parts = []
|
||||
for name, value in params:
|
||||
exp = '1:{}{}'.format(name, len(value))
|
||||
parts.append(b'(' + exp.encode('ascii') + value + b')')
|
||||
|
||||
return hashlib.sha1(b''.join(parts)).digest()
|
||||
|
||||
|
||||
def _keygrip_nist256(vk):
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_make_signature():
|
||||
def signer_func(digest):
|
||||
assert digest == (b'\xd0\xe5]|\x8bP\xe6\x91\xb3\xe8+\xf4A\xf0`(\xb1'
|
||||
b'\xc7\xf4;\x86\x97s\xdb\x9a\xda\xee< \xcb\x9e\x00')
|
||||
return b'SIGNATURE'
|
||||
return (7, 8)
|
||||
|
||||
sig = proto.make_signature(
|
||||
signer_func=signer_func,
|
||||
@@ -65,7 +65,7 @@ def test_make_signature():
|
||||
unhashed_subpackets=[],
|
||||
sig_type=25)
|
||||
assert sig == (b'\x04\x19\x16\x08\x00\x06\x05\x02'
|
||||
b'\x00\x00\x00\x01\x00\x00\xd0\xe5SIGNATURE')
|
||||
b'\x00\x00\x00\x01\x00\x00\xd0\xe5\x00\x03\x07\x00\x04\x08')
|
||||
|
||||
|
||||
def test_nist256p1():
|
||||
|
||||
Reference in New Issue
Block a user