Skip to content

[Question] how to handle ASN.1 Choice? #247

@hnvn

Description

@hnvn

I try to parse this following ASN.1 structure

//   ASN.1 structure of CMS SignedData
//    
//      ContentInfo ::= SEQUENCE {
//        contentType ContentType,
//        content [0] EXPLICIT ANY DEFINED BY contentType 
//      }
//
//      ContentType ::= OBJECT IDENTIFIER
//      
//      SignedData ::= SEQUENCE {
//        version CMSVersion,
//        digestAlgorithms DigestAlgorithmIdentifiers,
//        encapContentInfo EncapsulatedContentInfo,
//        certificates [0] IMPLICIT CertificateSet OPTIONAL,
//        crls [1] IMPLICIT RevocationInfoChoices OPTIONAL,
//        signerInfos SignerInfos 
//      }
// 
//      SignerInfos ::= SET OF SignerInfo
// 
//      CertificateSet ::= SET OF CertificateChoices
// 
//      DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
// 
//      RevocationInfoChoices ::= SET OF RevocationInfoChoice
//
//      EncapsulatedContentInfo ::= SEQUENCE {
//        eContentType ContentType,
//        eContent [0] EXPLICIT OCTET STRING OPTIONAL 
//      }
//
//      CertificateChoices ::= CHOICE {
//        certificate Certificate,
//        extendedCertificate [0] IMPLICIT ExtendedCertificate,  -- Obsolete
//        v1AttrCert [1] IMPLICIT AttributeCertificateV1,        -- Obsolete
//        v2AttrCert [2] IMPLICIT AttributeCertificateV2,
//        other [3] IMPLICIT OtherCertificateFormat 
//      }

I am confused about CHOICE and have no idea how to parse this kind of data structure. It's very pleased if anyone experienced with this data structure can help me out. Thanks in advance.

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