From 4d56972efc2c9afe2edb27c4d91bf5c1d5ca4ede Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 30 Dec 2017 20:01:33 +0300 Subject: [PATCH] Autodecode BitStrings too --- pyderasn.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyderasn.py b/pyderasn.py index f2ef0d7..acf0e46 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -251,6 +251,7 @@ done. Following types can be automatically decoded (DEFINED BY): * :py:class:`pyderasn.Any` +* :py:class:`pyderasn.BitString` (that is multiple of 8 bits) * :py:class:`pyderasn.OctetString` * :py:class:`pyderasn.SequenceOf`/:py:class:`pyderasn.SetOf` ``Any``/``OctetString``-s @@ -1681,7 +1682,7 @@ class BitString(Obj): >>> b.specs {'nonRepudiation': 1, 'digitalSignature': 0, 'keyEncipherment': 2} """ - __slots__ = ("specs",) + __slots__ = ("specs", "defined") tag_default = tag_encode(3) asn1_type_name = "BIT STRING" @@ -1718,6 +1719,7 @@ class BitString(Obj): ) if value is None: self._value = default + self.defined = None def _bits2octets(self, bits): if len(self.specs) > 0: @@ -1966,6 +1968,11 @@ class BitString(Obj): expl_llen=self.expl_llen if self.expled else None, expl_vlen=self.expl_vlen if self.expled else None, ) + defined_by, defined = self.defined or (None, None) + if defined_by is not None: + yield defined.pps( + decode_path=decode_path + (decode_path_defby(defined_by),) + ) class OctetString(Obj): -- 2.44.0