Skip to content

Conversation

dishmaker
Copy link
Contributor

@dishmaker dishmaker commented Aug 22, 2025

Depends on #1980

#[derive(Sequence)]
pub struct OidAndImplicitSequence<'a> {
    oid: ObjectIdentifier,

    #[asn1(context_specific = "0", tag_mode = "IMPLICIT")]
    data: SequenceRef<'a>,
}

pub struct SequenceRef<'a> {
/// Body of the `SEQUENCE`.
body: &'a BytesRef,
}

impl<'a> SequenceRef<'a> {
/// Create a new [`SequenceRef`] from the provided DER bytes.
pub fn new(slice: &'a [u8]) -> Result<Self> {
Copy link
Member

Choose a reason for hiding this comment

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

This is one I don't understand.
How does that not break invariants?

SequenceRef::from_der should already work? I'm missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from_der would parse tag and length first, then the contents.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, they do two different things: from_der would need the tag/length header, where this is just the "value" portion sans header

Copy link
Member

@baloo baloo Aug 23, 2025

Choose a reason for hiding this comment

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

That makes more sense.
But then I would say the comment could probably use an update (as is, it would definitely have tripped me up).

Something like /// Create a new [SequenceRef] from the DER bytes of the inner value or something along those lines.

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.

4 participants