Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

const-oid: fix large arc handling in encoder #1522

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

tarcieri
Copy link
Member

BER encodings were being miscomputed for certain large arcs.

The previous method was a bit wacky (in addition to being buggy) and attempted to encode each arc backwards within the BER output buffer.

This switches to a new method which splits the upper 7 bits from an arc and encodes that as a byte, continuing until all bytes of the arc have been encoded, which is much more straightforward.

The problematic cases which were reported have now been corrected.

Fixes #1520

cc @zhengyao-lin

BER encodings were being miscomputed for certain large arcs.

The previous method was a bit wacky (in addition to being buggy) and
attempted to encode each arc backwards within the BER output buffer.

This switches to a new method which splits the upper 7 bits from an arc
and encodes that as a byte, continuing until all bytes of the arc have
been encoded, which is much more straightforward.

The problematic cases which were reported have now been corrected.

Fixes #1520
@tarcieri
Copy link
Member Author

Note: with const_mut_refs now stable (rust-lang/rust#57349) and shipping in Rust 1.83, we will be able to completely rewrite all of the parsing/encoding logic in a much more straightforward way before the next release.

This PR isn't great, but at least stops the bleeding.

@tarcieri tarcieri merged commit 7c4638b into master Sep 18, 2024
113 checks passed
@tarcieri tarcieri deleted the const-oid/fix-oid-encoder branch September 18, 2024 18:31
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.

Incorrect Object Identifier DER Encoding
1 participant