Skip to content

Application tags for Choice in der #1958

@yguenduez

Description

@yguenduez

Hello dear all,

sorry for my newb question. I wanted to know, if there is a possibility to decode (and possibly encode) something like this for der:

Identifier ::= [APPLICATION 328] CHOICE {
    hash_over_key OCTET STRING (SIZE(8))
}

I tried with deriving Choice:

#[derive(Choice)]
pub enum Identifier<'a> {
    #[asn1(type = "OCTET STRING")]
    HashOverKey(OctetStringRef<'a>),
}

// This is currently not possible due to conflicting trait implementations
impl FixedTag for Identifier<'_> {
    const TAG: Tag = Tag::Application {
        constructed: true,
        number: TagNumber(328),
    };
}

But sadly FixedTag is already implemented by a blank implementation of Choice. I've seen a similar solved issue with Sequence, which was solved by deriving DecodeValue and EncodeValue and then manully implementing FixedTag: see here

Do you see any possibility to achieve something similar with Choice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions