From: Sergey Matveev Date: Mon, 13 Apr 2020 08:12:22 +0000 (+0300) Subject: Long tag form must not contain zero byte X-Git-Tag: 7.7~1 X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=commitdiff_plain;h=35c86385b3c8d004e3b5efea7aa2b95e7608309b Long tag form must not contain zero byte --- diff --git a/VERSION b/VERSION index 38abeb2..25b629b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.6 +7.7 diff --git a/doc/install.rst b/doc/install.rst index eb9c266..b74a184 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -4,11 +4,11 @@ Install Preferable way is to :ref:`download ` tarball with the signature from `official website `__:: - $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.6.tar.xz - $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.6.tar.xz.sig - $ gpg --verify pyderasn-7.6.tar.xz.sig pyderasn-7.6.tar.xz - $ xz --decompress --stdout pyderasn-7.6.tar.xz | tar xf - - $ cd pyderasn-7.6 + $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.7.tar.xz + $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.7.tar.xz.sig + $ gpg --verify pyderasn-7.7.tar.xz.sig pyderasn-7.7.tar.xz + $ xz --decompress --stdout pyderasn-7.7.tar.xz | tar xf - + $ cd pyderasn-7.7 $ python setup.py install # or copy pyderasn.py (+six.py, possibly termcolor.py) to your PYTHONPATH @@ -21,7 +21,7 @@ You can also find it mirrored on :ref:`download ` page. You could use pip (**no** OpenPGP authentication is performed!) with PyPI:: $ cat > requirements.txt < 1 and indexbytes(data, 1) & 0x7F == 0: + raise DecodeError("leading zero byte in tag value") i += 1 return data[:i], i, data[i:] diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py index 9a38fdd..fcf8781 100644 --- a/tests/test_pyderasn.py +++ b/tests/test_pyderasn.py @@ -276,6 +276,13 @@ class TestTagCoder(TestCase): with self.assertRaises(DecodeError): len_decode(octets) + @given(tag_classes, tag_forms, integers(min_value=31)) + def test_leading_zero_byte(self, klass, form, num): + raw = tag_encode(klass=klass, form=form, num=num) + raw = b"".join((raw[:1], b"\x80", raw[1:])) + with assertRaisesRegex(self, DecodeError, "leading zero byte"): + tag_strip(raw) + class TestLenCoder(TestCase): @settings(max_examples=LONG_TEST_MAX_EXAMPLES)