Skip to content

Commit c82bd61

Browse files
committed
der: Reject non-canonical encodings of ASN.1 bit strings with trailing zero bytes.
1 parent efa00df commit c82bd61

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/der.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ pub(crate) fn bit_string_flags(input: untrusted::Input<'_>) -> Result<BitStringF
388388
return Err(Error::BadDer);
389389
}
390390

391+
// ITU X690-0207 11.2.2: Trailing zero bytes aren't allowed.
392+
if *last == 0 {
393+
return Err(Error::BadDer);
394+
}
395+
391396
Ok(BitStringFlags { raw_bits })
392397
}
393398

0 commit comments

Comments
 (0)