简体   繁体   中英

ASN.1 BER Encoding of EmbeddedPDV

I am writing a Basic Encoding Rules codec in D, and I want to encode an EmbeddedPDV, which is defined according to the ASN.1 below. The problem is that, when encoding identification , I don't know how to make it clear in the BER-encoded binary that I am providing an OBJECT IDENTIFIER associated with the syntax field as opposed to one associated with the transfer-syntax field.

EmbeddedPDV ::= [UNIVERSAL 11] IMPLICIT SEQUENCE {
identification CHOICE {
    syntaxes SEQUENCE {
        abstract OBJECT IDENTIFIER,
        transfer OBJECT IDENTIFIER },
    syntax OBJECT IDENTIFIER,
    presentation-context-id INTEGER,
    context-negotiation SEQUENCE {
        presentation-context-id INTEGER,
        transfer-syntax OBJECT IDENTIFIER },
    transfer-syntax OBJECT IDENTIFIER,
    fixed NULL },
data-value-descriptor ObjectDescriptor OPTIONAL,
data-value OCTET STRING }
(WITH COMPONENTS { ... , data-value-descriptor ABSENT })

I know that, if you are using explicit tagging, there would be context-specific identifier tags for both syntax and transfer-syntax , but the absence of, say, a [0] or [1] before syntax and transfer-syntax respectively makes it unclear how I am supposed to encode this. Is there an assumed context-specific identifier associated with those fields? In other words, should I encode an OBJECT IDENTIFIER with an identifier tag of 0x81 to designate that I am encoding syntax and an identifier tag of 0x82 to designate that I am encoding transfer-syntax ?

The "associated type" for EMBEDDED PDV is given in ITU-T X.680(2015) clause 36.5 and includes "assuming and automatic tagging environment" before giving the definition. This was done to avoid cluttering the text with the implicit tags for each field. This means that inside "identification", the alternative "syntax" has an implicit tag of [1] while "transfer-syntax" has an implicit tag of [4]. This is the definition of the associated type for EMBEDDED PDV content regardless of what tagging context the "EMBEDDED PDV" appears in.

It seems you have ambiguous ASN.1 notation. The only way I can think of to deal with it would be explicit tagging.

If your ASN.1 module has the AUTOMATIC tagging clause in module definition, than your encoder should probably explicitly tag all untagged components in ASN.1 SEQUENCE, SET and CHOICE starting from tag value 0.

That automatic tagging should only be applied when you do not have tagged components already present in the constructed data structure definition you are trying to serialize.

Here is a possibly relevant answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM