From e2d7e4c8fcbe175831b4b8c66f8a96efd3cbe69c Mon Sep 17 00:00:00 2001 From: wbond Date: Mon, 23 Sep 2019 07:17:03 -0400 Subject: Fix encoding of tag values over 30 --- asn1crypto/parser.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'asn1crypto') diff --git a/asn1crypto/parser.py b/asn1crypto/parser.py index 07f53ab..0a19135 100644 --- a/asn1crypto/parser.py +++ b/asn1crypto/parser.py @@ -270,11 +270,13 @@ def _dump_header(class_, method, tag, contents): id_num |= method << 5 if tag >= 31: - header += chr_cls(id_num | 31) + cont_bit = 0 while tag > 0: - continuation_bit = 0x80 if tag > 0x7F else 0 - header += chr_cls(continuation_bit | (tag & 0x7F)) + header = chr_cls(cont_bit | (tag & 0x7f)) + header + if not cont_bit: + cont_bit = 0x80 tag = tag >> 7 + header = chr_cls(id_num | 31) + header else: header += chr_cls(id_num | tag) -- cgit v1.2.3