Skip to content

wip: add der::Cow enum#1778

Closed
dishmaker wants to merge 3 commits intoRustCrypto:masterfrom
dishmaker:dishmaker/cow
Closed

wip: add der::Cow enum#1778
dishmaker wants to merge 3 commits intoRustCrypto:masterfrom
dishmaker:dishmaker/cow

Conversation

@dishmaker
Copy link
Copy Markdown
Contributor

@dishmaker dishmaker commented Apr 22, 2025

Use case:

#[derive(Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)]
#[allow(missing_docs)]
pub struct TbsCertificateInnerCow<'a, P: Profile = Rfc5280> {
    /// The certificate version.
    ///
    /// Note that this value defaults to Version 1 per the RFC. However,
    /// fields such as `issuer_unique_id`, `subject_unique_id` and `extensions`
    /// require later versions. Care should be taken in order to ensure
    /// standards compliance.
    #[asn1(context_specific = "0", default = "Default::default")]
    pub(crate) version: Version,

    pub(crate) serial_number: SerialNumber<P>,
    pub(crate) signature: AlgorithmIdentifier,
    pub(crate) issuer: NameCow<'a>,
    pub(crate) validity: Validity<P>,
    pub(crate) subject: NameCow<'a>,
    pub(crate) subject_public_key_info: SubjectPublicKeyInfoCow<'a>,

    #[asn1(context_specific = "1", tag_mode = "IMPLICIT", optional = "true")]
    pub(crate) issuer_unique_id: Option<DerCow<BitStringRef<'a>>>,

    #[asn1(context_specific = "2", tag_mode = "IMPLICIT", optional = "true")]
    pub(crate) subject_unique_id: Option<DerCow<BitStringRef<'a>>>,

    #[asn1(context_specific = "3", tag_mode = "EXPLICIT", optional = "true")]
    pub(crate) extensions: Option<ext::ExtensionsCow<'a>>,
}

@dishmaker dishmaker marked this pull request as draft April 22, 2025 18:22
@dishmaker
Copy link
Copy Markdown
Contributor Author

I have a skill issue
image

@baloo
Copy link
Copy Markdown
Member

baloo commented Apr 22, 2025

I don't know how I feel about this one. I think I would rather duplicate the types to add a *Ref<'a> rather than rely on Cow.

(not a suggestion, or a request to change this PR at this moment, just a vibe)

@tarcieri
Copy link
Copy Markdown
Member

I'd agree this probably doesn't make sense, and would suggest potentially investigating trying to impl the relevant traits to use alloc::borrow::Cow (though I'm not sure &'a TypeRef<'a> would actually work for e.g. Borrow?)

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.

3 participants