Conversation
888fb4a to
d3e136d
Compare
Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
d3e136d to
95bf053
Compare
Contributor
Author
|
Rebased and changed to use the new custom write errors. |
alex
reviewed
Feb 25, 2026
src/types.rs
Outdated
| #[inline] | ||
| fn parse_data(data: &'a [u8]) -> ParseResult<Set<'a>> { | ||
| parse(data, |p| { | ||
| let mut last_element: Option<Tlv<'a>> = None; |
Owner
There was a problem hiding this comment.
Can we de-dupe this between this and SetOf?
Contributor
Author
There was a problem hiding this comment.
Done. SetOf<T> does an extra step that we don't do for Set : for each element, it calls T::parse(element).
The helper function added that deduplicates the logic that checks the order takes a callback so that SetOf can still do that, and Set just passes a no-op.
/// Validates that TLV elements in a SET are in DER canonical order.
/// Calls `per_element` for each successfully read TLV, passing the
/// element and its zero-based index.
fn validate_set_ordering<'a>(
p: &mut Parser<'a>,
mut per_element: impl FnMut(Tlv<'a>, usize) -> ParseResult<()>,
) -> ParseResult<()> {Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
alex
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
asn1::Sethas a similar API toasn1::Sequencefor encoding and decoding, except the order of the elements is checkedFixes #530