]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - tests/test_pyderasn.py
Check that explicit tag is not out-of-bounds
[pyderasn.git] / tests / test_pyderasn.py
index c85a90a3e3e4dc737a553b3eb98aa97126e3e8f1..adad7e9b88f9ef475e7e56b1d2f7931b836b7541 100644 (file)
@@ -5922,3 +5922,13 @@ class TestX690PrefixedType(TestCase):
             VisibleString("Jones", impl=tag_ctxp(2)).encode(),
             hexdec("82054A6F6E6573"),
         )
+
+
+class TestExplOOB(TestCase):
+    def runTest(self):
+        expl = tag_ctxc(123)
+        raw = Integer(123).encode() + Integer(234).encode()
+        raw = b"".join((expl, len_encode(len(raw)), raw))
+        with assertRaisesRegex(self, DecodeError, "explicit tag out-of-bound"):
+            Integer(expl=expl).decode(raw)
+        Integer(expl=expl).decode(raw, ctx={"allow_expl_oob": True})