pc-dart icon indicating copy to clipboard operation
pc-dart copied to clipboard

[Question] how to handle ASN.1 Choice?

Open hnvn opened this issue 4 months ago • 0 comments

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.

hnvn avatar Oct 12 '24 10:10 hnvn