asn.1der

Can an ASN.1 DER SET have multiple entries of same key?


I have the following Definition:

PersonalName ::= SET {
   surname     [0] IMPLICIT PrintableString
                    (SIZE (1..ub-surname-length)),
   given-name  [1] IMPLICIT PrintableString
                    (SIZE (1..ub-given-name-length)) OPTIONAL,
   initials    [2] IMPLICIT PrintableString
                    (SIZE (1..ub-initials-length)) OPTIONAL,
   generation-qualifier [3] IMPLICIT PrintableString
                    (SIZE (1..ub-generation-qualifier-length))
                    OPTIONAL }

Is it allowed to have e.g. two times surname encoded with this definition?


Solution

  • The answer is in section 3.8.72 (definition of set types) in the T-REC-X680 specification:

    3.8.72 set types: Types defined by referencing a fixed, unordered, list of types (some of which may be declared to be optional); each value in the set type is an unordered list of values, one from each component type.

    NOTE – Where a component type is declared to be optional, a value of the set type need not contain a value of that component type.

    Your BER or DER encoded files contains values and the above clause defines that the value which is of the "set type" shall contain one value for each component type of the set (except for optional components, which according to the Note, can be omitted).