Skip to content

wip: add der::Cow enum #1778

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

dishmaker
Copy link
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
Contributor Author

I have a skill issue
image

@baloo
Copy link
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)

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