"""Python ASN.1 DER/BER codec with abstract structures
This library allows you to marshal various structures in ASN.1 DER
-format, unmarshal them in BER/CER/DER ones.
+format, unmarshal BER/CER/DER ones.
>>> i = Integer(123)
>>> raw = i.encode()
def colored(what, *args, **kwargs):
return what
-__version__ = "7.4"
+__version__ = "7.5"
__all__ = (
"agg_octet_string",
"""
return memoryview(mmap(fd.fileno(), 0, prot=PROT_READ))
+
def pureint(value):
if not set(value) <= DECIMALS:
raise ValueError("non-pure integer")
return int(value)
+
def fractions2float(fractions_raw):
pureint(fractions_raw)
return float("0." + fractions_raw)
if len(path) != len(sub_decode_path):
continue
for p1, p2 in zip(path, sub_decode_path):
- if (not p1 is any) and (p1 != p2):
+ if (p1 is not any) and (p1 != p2):
break
else:
return define
yield None
return
_decode_path, obj, tail = result
- if not _decode_path is decode_path:
+ if _decode_path is not decode_path:
yield result
else:
try:
yield None
return
_decode_path, obj, tail = result
- if not _decode_path is decode_path:
+ if _decode_path is not decode_path:
yield result
eoc_expected, tail = tail[:EOC_LEN], tail[EOC_LEN:]
if eoc_expected.tobytes() != EOC:
yield None
return
_decode_path, obj, tail = result
- if not _decode_path is decode_path:
+ if _decode_path is not decode_path:
yield result
if obj.tlvlen < l and not ctx.get("allow_expl_oob", False):
raise DecodeError(
int2byte(0),
octets[offset:offset + 999],
)))
- tail = octets[offset+999:]
+ tail = octets[offset + 999:]
if len(tail) > 0:
tail = int2byte((8 - bit_len % 8) % 8) + tail
write_full(writer, b"".join((
LEN1K,
octets[offset:offset + 1000],
)))
- tail = octets[offset+1000:]
+ tail = octets[offset + 1000:]
if len(tail) > 0:
write_full(writer, b"".join((
OctetString.tag_default,
If you press **d**, then current element will be saved in the
current directory under its decode path name (adding ".0", ".1", etc
suffix if such file already exists). **D** will save it with explicit tag.
+
+ You can also invoke it with ``--browse`` command line argument.
"""
from copy import deepcopy
from os.path import exists as path_exists
[("header", "[TLV]len: "), "%d/%d/%d" % (
pp.tlen, pp.llen, pp.vlen,
)],
+ [("header", "TLVlen: "), "%d" % sum((
+ pp.tlen, pp.llen, pp.vlen,
+ ))],
[("header", "Slice: "), "[%d:%d]" % (
pp.offset, pp.offset + pp.tlen + pp.llen + pp.vlen,
)],
lines.append([" [TLV]len: %d/%d/%d" % (
pp.expl_tlen, pp.expl_llen, pp.expl_vlen,
)])
+ lines.append([" TLVlen: %d" % sum((
+ pp.expl_tlen, pp.expl_llen, pp.expl_vlen,
+ ))])
lines.append([" Slice: [%d:%d]" % (
pp.expl_offset,
pp.expl_offset + pp.expl_tlen + pp.expl_llen + pp.expl_vlen,