One function

_dump_header in wbond/asn1crypto

The author described this change as Fix encoding of tag values over 30. It counts as a record because the check below fails on the code as it stood at 2199e11bc and passes on e2d7e4c8f, with nothing else changed between the two runs.

Fix saved2019-09-23
Sharing licenceMIT · LICENSE
Change size+5 3

What the code was meant to do, written into the code itself as a docstring

Constructs the header bytes for an ASN.1 object :param class_: An integer ASN.1 class value: 0 (universal), 1 (application), 2 (context), 3 (private) :param method: An integer ASN.1 method value: 0 (primitive), 1 (constructed) :param tag: An integer ASN.1 tag value :param contents: A byte string of the encoded byte contents :return: A byte string of the ASN.1 DER header

The change

2626 id_num |= method << 5
2727
2828 if tag >= 31:
29- header += chr_cls(id_num | 31)
29+ cont_bit = 0
3030 while tag > 0:
31- continuation_bit = 0x80 if tag > 0x7F else 0
32- header += chr_cls(continuation_bit | (tag & 0x7F))
31+ header = chr_cls(cont_bit | (tag & 0x7f)) + header
32+ if not cont_bit:
33+ cont_bit = 0x80
3334 tag = tag >> 7
35+ header = chr_cls(id_num | 31) + header
3436 else:
3537 header += chr_cls(id_num | tag)
3638

The check that tells the two apart

failpass·tests/test_core.py::CoreTests::test_large_tag_encode

Check file tests/test_core.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it2199e11bcb179f679f9880a6aa2047da880efae2
Broken version dated2019-09-23
Moduleasn1crypto.parser
Units changed_dump_header
Fingerprint400833237d839dd2
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in wbond/asn1crypto