regarding non-minimal encoding in BER, is set/sequence possible to do so?
- User
regarding non-minimal encoding in BER, is set/sequence possible to do so?
- Assistant
Yes, with Basic Encoding Rules (BER), it is possible to have non-minimal encoding for SET or SEQUENCE. This is because BER allows flexibility in how data is encoded, which includes multiple options for encoding the same data. However, this flexibility can lead to non-minimal encodings, which occur when a more verbose representation is used than necessary.
- User
besides length encoding using long form, can you have non-minimal encoding in set/sequence's value?
- Assistant
- User
what is "chunking" in set/sequence? i thought they already fragment by chunks by their nature
- Assistant
- User
i see. so chunking has to do with the inner TLVs instead of the parent(set/sequence). so its not really relevant.
- Assistant
Exactly! You're spot on.
The concept of "chunking" indeed deals with the (Tag-Length-Value representations) rather than the parent container (like a or ) itself. It specifically applies to the encoding of within a structure (e.g., OCTET STRING, constructed types, or other components) when using in .
- User
""" 2. Redundant Optional or Default Values In ASN.1, some elements of a SEQUENCE or SET may be marked as optional or have default values:
Under BER, encoders may explicitly include default values or optional fields in the encoding, even if they are not necessary to convey the same logical data. For example, encoding a default value like 0 instead of omitting it results in a non-minimal representation. Under DER, only non-default values or explicitly set values can be included, ensuring minimal and deterministic encoding. """ can you elaborate on default/optional values? ive never heard about this in BER. like does it mean some TLV have default values?? how? not specifying them?
- Assistant
- User
""" MySequence ::= SEQUENCE { mandatoryField INTEGER, optionalField INTEGER OPTIONAL, defaultField INTEGER DEFAULT 0 } """
regarding this, must mandatory field come before optional/default fields? because if optional/default fields sit between mandatory fields, it makes it hard to know if the provided field at that position is an override of optional/default or is mandatory....
- Assistant
- User
""" If multiple fields in a SEQUENCE share the same type (e.g., multiple INTEGER fields), ASN.1 allows the use of explicit or implicit tagging to uniquely tag each field. For example:
MySequence ::= SEQUENCE { field1 INTEGER, field2 INTEGER OPTIONAL, -- Both are INTEGER, but field2 is optional. field3 INTEGER DEFAULT 0 -- field3 is INTEGER but has a default value. } To eliminate ambiguity, tagging can be added:
MySequence ::= SEQUENCE { field1 [0] INTEGER, field2 [1] INTEGER OPTIONAL, field3 [2] INTEGER DEFAULT 0 } These numbered tags ([0], [1], [2]) uniquely identify each field, even if they're not all present in a particular encoding. It also makes decoding trivial, as the tags directly map to fields. """ i dont get this at all. do those numbered tags appear in actual encoding or what
- Assistant