Skip to content

Commit b8ee63f

Browse files
committed
der: fix CONTEXT-SPECIFIC constructed bit check order
1 parent 3ecbef2 commit b8ee63f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

der/src/asn1/internal_macros.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ macro_rules! impl_custom_class {
146146
// Decode IMPLICIT header
147147
let header = Header::decode(reader)?;
148148

149+
// the encoding shall be constructed if the base encoding is constructed
150+
if header.tag.is_constructed() != T::CONSTRUCTED {
151+
return Err(header.tag.non_canonical_error().into());
152+
}
153+
149154
// read_nested checks if header matches decoded length
150155
let value = reader.read_nested(header.length, |reader| {
151156
// Decode inner IMPLICIT value
152157
T::decode_value(reader, header)
153158
})?;
154159

155-
// the encoding shall be constructed if the base encoding is constructed
156-
if header.tag.is_constructed() != T::CONSTRUCTED {
157-
return Err(header.tag.non_canonical_error().into());
158-
}
159-
160160
Ok(Some(Self {
161161
tag_number,
162162
tag_mode: TagMode::Implicit,

0 commit comments

Comments
 (0)