From 7ea20c7009d4752297eec4a98fa97fc10b560baa Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Fri, 8 Jan 2016 17:30:08 +0200 Subject: [PATCH] test_trezor: verify serialized signature --- trezor_agent/tests/test_trezor.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/trezor_agent/tests/test_trezor.py b/trezor_agent/tests/test_trezor.py index a2c6f4b..540befb 100644 --- a/trezor_agent/tests/test_trezor.py +++ b/trezor_agent/tests/test_trezor.py @@ -1,8 +1,10 @@ +import io import mock import pytest from ..trezor import client from .. import formats +from .. import util ADDR = [2147483661, 2810943954, 3938368396, 3454558782, 3848009040] @@ -107,7 +109,15 @@ def test_ssh_agent(): signature = c.sign_ssh_challenge(label=label, blob=BLOB) key = formats.import_public_key(PUBKEY_TEXT) - assert key['verifier'](sig=signature, msg=BLOB) + serialized_sig = key['verifier'](sig=signature, msg=BLOB) + + stream = io.BytesIO(serialized_sig) + r = util.read_frame(stream) + s = util.read_frame(stream) + assert not stream.read() + assert r[:1] == b'\x00' + assert s[:1] == b'\x00' + assert r[1:] + s[1:] == SIG[1:] def test_utils():