aboutsummaryrefslogtreecommitdiff
path: root/asn1crypto
diff options
context:
space:
mode:
authorwbond <will@wbond.net>2019-09-23 07:17:03 -0400
committerwbond <will@wbond.net>2019-09-23 07:17:03 -0400
commite2d7e4c8fcbe175831b4b8c66f8a96efd3cbe69c (patch)
treefb788d6539c21a2a26c68c04ee8d7b3c324e2cc8 /asn1crypto
parent2199e11bcb179f679f9880a6aa2047da880efae2 (diff)
downloadasn1crypto-e2d7e4c8fcbe175831b4b8c66f8a96efd3cbe69c.tar.gz
Fix encoding of tag values over 30
Diffstat (limited to 'asn1crypto')
-rw-r--r--asn1crypto/parser.py8
1 files changed, 5 insertions, 3 deletions
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)