Skip to content

Error out on non-zero unused bit in DER encoding#97

Merged
partim merged 8 commits into
mainfrom
non-zero-unused-bit
May 11, 2026
Merged

Error out on non-zero unused bit in DER encoding#97
partim merged 8 commits into
mainfrom
non-zero-unused-bit

Conversation

@Koenvh1

@Koenvh1 Koenvh1 commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@Koenvh1 Koenvh1 requested a review from partim April 28, 2026 13:02

@partim partim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three things:

  • This check also needs to happen in CER mode.
  • The check must not happen if bits is empty – I suppose the cleanest way is to do an if let Some(ch) = bits.last().
  • Particularly in light of the previous item: there should be some cases added to the test at the end of the module.

@Koenvh1 Koenvh1 requested a review from partim May 11, 2026 12:08
@partim partim merged commit 1beb99d into main May 11, 2026
12 checks passed
@partim partim deleted the non-zero-unused-bit branch May 11, 2026 14:00
partim added a commit that referenced this pull request Jun 8, 2026
New

* Added `RestrictedString::take_opt_from`. ([#90])

Improvements

* `BIT_STRING` parsing now checks that the unused bits are zero in CER and
  DER modes. ([#97])

Bug fixes

* Fixed `Utf8String` potentially accepting invalid UTF-8. ([#91] by [@sumleo])
* Fixed a panic in `Unsigned::from_bytes` when the input is all zero.
  ([#92] by [@sumleo])
* Fixed incorrect bounds check in `BitString::bit`. ([#93] by [@sumleo])
* Added character set validation to `FromStr` impl for `NumericString`,
  `PrintableString`, and `Ia5String`. ([#95] by [@sumleo])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants