Skip to content

Commit efa00df

Browse files
committed
der: Add test for overly-long encodings of bit strings.
1 parent 6c70388 commit efa00df

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/der.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,18 @@ mod tests {
753753
Err(Error::BadDer)
754754
));
755755

756+
// Zero bits must be stripped before encoding.
757+
for pad in 0..=7 {
758+
assert_eq!(
759+
bit_string_flags(untrusted::Input::from(&[pad, 0])).err(),
760+
Some(Error::BadDer)
761+
);
762+
assert_eq!(
763+
bit_string_flags(untrusted::Input::from(&[pad, 1, 0])).err(),
764+
Some(Error::BadDer),
765+
);
766+
}
767+
756768
// invalid padding for empty set
757769
for pad in 1..=255 {
758770
assert_eq!(

0 commit comments

Comments
 (0)