Search code examples
asn.1ber

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?


Solution

  • 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.