From 9f22f1dde04e7cc327ff4ff929aa6a4858524d36 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Wed, 14 Nov 2018 21:12:13 -0800 Subject: [PATCH] Set bit 5 for SEQUENCE 0x10 and SET 0x11 to indicate constructed encoding --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 73aa565..4e454d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -836,7 +836,13 @@ fn encode_tag(c: ASN1Class, t: &BigUint) -> Vec { let cbyte = encode_class(c); match t.to_u8() { - Some(x) if x < 31 => { + Some(mut x) if x < 31 => { + if x == 0x10 || x == 0x11 { + // SEQUENCE and SET mut have the constructed encoding form (bit 5) set + // See: https://docs.microsoft.com/en-us/windows/desktop/seccertenroll/about-encoded-tag-bytes + x |= 0b00_10_00_00; + } + vec![cbyte | x] } _ => { -- 2.53.0