From 9f6b6bbcf30cbbb605caa846d7d3de10615802f4 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 20 May 2018 16:21:53 +0300 Subject: [PATCH] Note about BIT/OCTET STRING primitive/constructed encodings --- pyderasn.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pyderasn.py b/pyderasn.py index b28792c..ee39e57 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -1927,6 +1927,14 @@ class BitString(Obj): ['nonRepudiation', 'keyEncipherment'] >>> b.specs {'nonRepudiation': 1, 'digitalSignature': 0, 'keyEncipherment': 2} + + .. note:: + + Pay attention that BIT STRING can be encoded both in primitive + and constructed forms. Decoder always checks constructed form tag + additionally to specified primitive one. If BER decoding is + :ref:`not enabled `, then decoder will fail, because + of DER restrictions. """ __slots__ = ("tag_constructed", "specs", "defined") tag_default = tag_encode(3) @@ -2357,6 +2365,14 @@ class OctetString(Obj): pyderasn.BoundsError: unsatisfied bounds: 4 <= 5 <= 4 >>> OctetString(b"hell", bounds=(4, 4)) OCTET STRING 4 bytes 68656c6c + + .. note:: + + Pay attention that OCTET STRING can be encoded both in primitive + and constructed forms. Decoder always checks constructed form tag + additionally to specified primitive one. If BER decoding is + :ref:`not enabled `, then decoder will fail, because + of DER restrictions. """ __slots__ = ("tag_constructed", "_bound_min", "_bound_max", "defined") tag_default = tag_encode(4) -- 2.44.0