Follow GPG implementation for subpacket prefix encoding.

Conflicts:
	trezor_agent/gpg/protocol.py
This commit is contained in:
Roman Zeyde
2016-09-28 17:23:11 +03:00
parent 016e864503
commit 91146303a3
2 changed files with 20 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ import os
import pytest
from .. import decode
from .. import decode, protocol
from ... import util
@@ -14,6 +14,15 @@ def test_subpackets():
assert decode.parse_subpackets(util.Reader(s)) == [b'\xAB\xCD', b'\xEF']
def test_subpackets_prefix():
for n in [0, 1, 2, 4, 5, 10, 191, 192, 193,
255, 256, 257, 8383, 8384, 65530]:
item = b'?' * n # create dummy subpacket
prefixed = protocol.subpackets(item)
result = decode.parse_subpackets(util.Reader(io.BytesIO(prefixed)))
assert [item] == result
def test_mpi():
s = io.BytesIO(b'\x00\x09\x01\x23')
assert decode.parse_mpi(util.Reader(s)) == 0x123