::
- 52-2 [1,1,1054]-4 . . . . eContent: [0] EXPLICIT BER OCTET STRING 1046 bytes
+ 52-2I [1,1,1054]I . . . . eContent: [0] EXPLICIT BER OCTET STRING 1046 bytes
^ ^ ^ ^
12 13 9 10
Possible other flags like OPTIONAL and DEFAULT, if value equals to the
default one, specified in the schema.
:12:
- Only applicable to BER encoded data. If object has indefinite length
- encoding, then subtract 2 bytes EOC from its length. If object has
- explicit tag with indefinite length, then subtract another EOC bytes.
- In example above, ``eContent`` field has both indefinite field encoding
- and indefinite length explicit tag. ``BIT STRING``, ``OCTET STRING``
- (and its derivatives), ``SEQUENCE``, ``SET``, ``SEQUENCE OF``, ``SET
- OF``, ``ANY`` could have indefinite length coding.
+ Only applicable to BER encoded data. Indefinite length encoding mark.
:13:
Only applicable to BER encoded data. If object has BER-specific
encoding, then ``BER`` will be shown. It does not depend on indefinite
- length encoding. ``BOOLEAN``, ``BIT STRING``, ``OCTET STRING`` (and its
- derivatives) could be BERed.
+ length encoding. ``EOC``, ``BOOLEAN``, ``BIT STRING``, ``OCTET STRING``
+ (and its derivatives) could be BERed.
As command line utility
-----------------------
EOC = b"\x00\x00"
EOC_LEN = len(EOC)
LENINDEF = b"\x80" # length indefinite mark
+LENINDEF_PP_CHAR = "∞"
########################################################################
def expl_tlvlen(self):
return self.expl_tlen + self.expl_llen + self.expl_vlen
+ def pps_lenindef(self, decode_path):
+ if self.lenindef:
+ yield _pp(
+ asn1_type_name="EOC",
+ obj_name="",
+ decode_path=decode_path,
+ offset=(
+ self.offset + self.tlvlen -
+ (EOC_LEN * 2 if self.expl_lenindef else EOC_LEN)
+ ),
+ tlen=1,
+ llen=1,
+ vlen=0,
+ bered=True,
+ )
+ if self.expl_lenindef:
+ yield _pp(
+ asn1_type_name="EOC",
+ obj_name="EXPLICIT",
+ decode_path=decode_path,
+ offset=self.expl_offset + self.expl_tlvlen - EOC_LEN,
+ tlen=1,
+ llen=1,
+ vlen=0,
+ bered=True,
+ )
+
class DecodePathDefBy(object):
"""DEFINED BY representation inside decode path
):
cols = []
if with_offsets:
- col = "%5d%s" % (
+ col = "%5d%s%s" % (
pp.offset,
(
" " if pp.expl_offset is None else
("-%d" % (pp.offset - pp.expl_offset))
),
+ LENINDEF_PP_CHAR if pp.expl_lenindef else " ",
)
cols.append(_colorize(col, "red", with_colours, ()))
- col = "[%d,%d,%4d]" % (pp.tlen, pp.llen, pp.vlen)
- col = _colorize(col, "green", with_colours, ())
- ber_deoffset = 0
- if pp.expl_lenindef:
- ber_deoffset += 2
- if pp.lenindef:
- ber_deoffset += 2
- col += (
- " " if ber_deoffset == 0 else
- _colorize(("-%d" % ber_deoffset), "red", with_colours)
+ col = "[%d,%d,%4d]%s" % (
+ pp.tlen,
+ pp.llen,
+ pp.vlen,
+ LENINDEF_PP_CHAR if pp.lenindef else " "
)
+ col = _colorize(col, "green", with_colours, ())
cols.append(col)
if len(pp.decode_path) > 0:
cols.append(" ." * (len(pp.decode_path)))
def pp_console_blob(pp):
- cols = [" " * len("XXXXXYY [X,X,XXXX]YY")]
+ cols = [" " * len("XXXXXYYZ [X,X,XXXX]Z")]
if len(pp.decode_path) > 0:
cols.append(" ." * (len(pp.decode_path) + 1))
if isinstance(pp.blob, binary_type):
expl_lenindef=self.expl_lenindef,
bered=self.bered,
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class Integer(Obj):
expl_vlen=self.expl_vlen if self.expled else None,
expl_lenindef=self.expl_lenindef,
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class BitString(Obj):
yield defined.pps(
decode_path=decode_path + (DecodePathDefBy(defined_by),)
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class OctetString(Obj):
yield defined.pps(
decode_path=decode_path + (DecodePathDefBy(defined_by),)
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class Null(Obj):
expl_vlen=self.expl_vlen if self.expled else None,
expl_lenindef=self.expl_lenindef,
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class ObjectIdentifier(Obj):
expl_vlen=self.expl_vlen if self.expled else None,
expl_lenindef=self.expl_lenindef,
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class Enumerated(Integer):
expl_vlen=self.expl_vlen if self.expled else None,
expl_lenindef=self.expl_lenindef,
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class UTF8String(CommonString):
expl_vlen=self.expl_vlen if self.expled else None,
expl_lenindef=self.expl_lenindef,
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class GeneralizedTime(UTCTime):
)
if self.ready:
yield self.value.pps(decode_path=decode_path + (self.choice,))
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class PrimitiveTypes(Choice):
yield defined.pps(
decode_path=decode_path + (DecodePathDefBy(defined_by),)
)
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
########################################################################
if value is None:
continue
yield value.pps(decode_path=decode_path + (name,))
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class Set(Sequence):
)
for i, value in enumerate(self._value):
yield value.pps(decode_path=decode_path + (str(i),))
+ for pp in self.pps_lenindef(decode_path):
+ yield pp
class SetOf(SequenceOf):