Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
ASN.1
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Encodings == ASN.1 is closely associated with a set of encoding rules that specify how to represent a data structure as a series of bytes. The standard ASN.1 encoding rules include: {| class="wikitable" |+ ASN.1 Encoding Rules |- style="vertical-align:bottom;" ! rowspan=2 {{verth|Encoding rules}} ! colspan=2 | Object identifier ! rowspan=2 | Object descriptor value ! rowspan=2 {{verth|Specification}} ! rowspan=2 {{verth|Unit of serialization}} ! rowspan=2 {{verth|Encoded elements <br/>discernable without <br/>foreknowledge of <br/>specification}} ! rowspan=2 {{verth|Octet aligned}} ! rowspan=2 {{verth|Encoding control <br/>notation rules defined}} ! rowspan=2 | Description |- style="vertical-align:bottom;" ! Dotted ! {{abbr|IRI|Internationalized resource identifier}} |- | {{verth|[[Basic Encoding Rules]]<br/>(BER)<ref>[https://www.itu.int/rec/T-REC-X.690-201508-I/en ITU-T X.690 - Basic Encoding Rules (BER)]</ref>}} | 2.1.1 | /ASN.1/Basic-Encoding | Basic Encoding of a single ASN.1 type | ITU X.690 | Octet | {{Yes}} | {{Yes}} | {{No}} | The first specified encoding rules. Encodes elements as tag-length-value (TLV) sequences. Typically provides several options as to how data values are to be encoded. This is one of the most flexible encoding rules. |- | {{verth|[[Distinguished Encoding Rules]]<br/>(DER)<ref>[https://www.itu.int/rec/T-REC-X.690-201508-I/en ITU-T X.690 - Distinguished Encoding Rules (DER)]</ref>}} | 2.1.2.1 | /ASN.1/BER{{nbh}}Derived/<wbr/>Distinguished{{nbh}}Encoding | Distinguished encoding of a single ASN.1 type | ITU X.690 | Octet | {{Yes}} | {{Yes}} | {{No}} | A restricted subset of the Basic Encoding Rules (BER). Typically used for things that are digitally-signed because, since the DER allow for fewer options for encoding, and because DER-encoded values are more likely to be re-encoded on the exact same bytes, digital signatures produced by a given abstract value will be the same across implementations and digital signatures produced over DER-encoded data will be less susceptible to collision-based attacks. |- | {{verth|[[Canonical Encoding Rules]]<br/>(CER)<ref>[https://www.itu.int/rec/T-REC-X.690-201508-I/en ITU-T X.690 - Canonical Encoding Rules (CER)]</ref>}} | 2.1.2.0 | /ASN.1/<wbr/>BER{{nbh}}Derived/<wbr/>Canonical{{nbh}}Encoding | Canonical encoding of a single ASN.1 type | ITU X.690 | Octet | {{Yes}} | {{Yes}} | {{No}} | A restricted subset of the Basic Encoding Rules (BER). Employs almost all of the same restrictions as the Distinguished Encoding Rules (DER), but the noteworthy difference is that the CER specify that many large values (especially strings) are to be "chopped up" into individual substring elements at the 1000-byte or 1000-character mark (depending on the data type). |- | {{verth|Basic Packed<br/>Encoding Rules<br/>(PER) Aligned<ref name=":0">[https://www.itu.int/rec/T-REC-X.691-201508-I/en ITU-T X.691 - Packed Encoding Rules (PER)]</ref>}} | 2.1.3.0.0 | /ASN.1/<wbr/>Packed{{nbh}}Encoding/<wbr/>Basic/Aligned | Packed encoding of a single ASN.1 type (basic aligned) | ITU X.691 | Bit | {{No}} | {{Yes}} | {{No}} | Encodes values on bits, but if the bits encoded are not evenly divisible by eight, padding bits are added until an integral number of octets encode the value. Capable of producing very compact encodings, but at the expense of complexity, and the PER are highly dependent upon constraints placed on data types. |- | {{verth|Basic Packed<br/>Encoding Rules<br/>(PER) Unaligned<ref name=":0" />}} | 2.1.3.0.1 | /ASN.1/<wbr/>Packed{{nbh}}Encoding/<wbr/>Basic/Unaligned | Packed encoding of a single ASN.1 type (basic unaligned) | ITU X.691 | Bit | {{No}} | {{No}} | {{No}} | A variant of the Aligned Basic Packed Encoding Rules (PER), but it does not pad data values with bits to produce an integral number of octets. |- | {{verth|Canonical Packed<br/>Encoding Rules<br/>(CPER) Aligned<ref name=":0" />}} | 2.1.3.1.0 | /ASN.1/<wbr/>Packed{{nbh}}Encoding/<wbr/>Canonical/Aligned | Packed encoding of a single ASN.1 type (canonical aligned) | ITU X.691 | Bit | {{No}} | {{Yes}} | {{No}} | A variant of the Packed Encoding Rules (PER) that specifies a single way of encoding values. The Canonical Packed Encoding Rules have a similar relationship to the Packed Encoding Rules that the Distinguished Encoding Rules (DER) and the Canonical Encoding Rules (CER) have to the Basic Encoding Rules (BER). |- | {{verth|Canonical Packed<br/>Encoding Rules<br/>(CPER) Unaligned<ref name=":0" />}} | 2.1.3.1.1 | /ASN.1/<wbr/>Packed{{nbh}}Encoding/<wbr/>Canonical/Unaligned | Packed encoding of a single ASN.1 type (canonical unaligned) | ITU X.691 | Bit | {{No}} | {{No}} | {{No}} | A variant of the Aligned Canonical Packed Encoding Rules (CPER), but it does not pad data values with bits to produce an integral number of octets. |- | {{verth|Basic XML<br/>Encoding Rules<br/>(XER)<ref name=":1">[https://www.itu.int/rec/T-REC-X.693/en ITU-T X.693 - XML Encoding Rules (XER)]</ref>}} | 2.1.5.0 | /ASN.1/XML{{nbh}}Encoding/<wbr/>Basic | Basic XML encoding of a single ASN.1 type | ITU X.693 | Character | {{Yes}} | {{Yes}} | {{Yes}} | Encodes ASN.1 data as XML. |- | {{verth|Canonical XML<br/>Encoding Rules<br/>(CXER)<ref name=":1" />}} | 2.1.5.1 | /ASN.1/XML{{nbh}}Encoding/<wbr/>Canonical | Canonical XML encoding of a single ASN.1 type | ITU X.693 | Character | {{Yes}} | {{Yes}} | {{Yes}} | |- | {{verth|Extended XML<br/>Encoding Rules<br/>(EXER)<ref name=":1" />}} | 2.1.5.2 | /ASN.1/XML{{nbh}}Encoding/<wbr/>Extended | Extended XML encoding of a single ASN.1 type | ITU X.693 | Character | {{Yes}} | {{Yes}} | {{Yes}} | |- | {{verth|Octet<br/>Encoding Rules<br/>(OER)<ref name=":2">[https://www.itu.int/rec/T-REC-X.696-201508-I/en ITU-T X.696 - Octet Encoding Rules (OER)]</ref>}} | 2.1.6.0 | | Basic OER encoding of a single ASN.1 type | ITU X.696 | Octet | {{No}} | {{Yes}} | | A set of encoding rules that encodes values on octets, but does not encode tags or length determinants like the Basic Encoding Rules (BER). Data values encoded using the Octet Encoding Rules often look like those found in "record-based" protocols. The Octet Encoding Rules (OER) were designed to be easy to implement and to produce encodings more compact than those produced by the Basic Encoding Rules (BER). In addition to reducing the effort of developing encoder/decoders, the use of OER can decrease bandwidth utilization (though not as much as the Packed Encoding Rules), save CPU cycles, and lower encoding/decoding latency. |- | {{verth|Canonical<br/>Encoding Rules<br/>(OER)<ref name=":2" />}} | 2.1.6.1 | | Canonical OER encoding of a single ASN.1 type | ITU X.696 | Octet | {{No}} | {{Yes}} | | |- | {{verth|JSON<br/>Encoding Rules<br/>(JER)<ref>[https://www.itu.int/rec/T-REC-X.697/en ITU-T X.697 - JavaScript Object Notation Encoding Rules (JER)]</ref>}} | | | | ITU X.697 | Character | {{Yes}} | {{Yes}} | {{Yes}} | Encodes ASN.1 data as JSON. |- | {{verth|Generic String<br/>Encoding Rules<br/>(GSER)<ref>{{IETF RFC|3641}} - Generic String Encoding Rules (GSER)</ref>}} | 1.2.36.<wbr/>79672281.<wbr/>0.0 | | Generic String Encoding Rules (GSER) | {{IETF RFC|3641}} | Character | | {{Yes}} | {{No}} | An incomplete specification for encoding rules that produce human-readable values. The purpose of GSER is to represent encoded data to the user or input data from the user, in a very straightforward format. GSER was originally designed for the [[Lightweight Directory Access Protocol]] (LDAP) and is rarely used outside of it. The use of GSER in actual protocols is discouraged since not all character string encodings supported by ASN.1 can be reproduced in it. |- | {{verth|BACnet<br/>Encoding Rules}} | | | | ASHRAE 135 | Octet | {{Yes}} | {{Yes}} | {{Yes}} | Encodes elements as tag-length-value (TLV) sequences like the Basic Encoding Rules (BER). |- | {{verth|Signalling Specific<br/>Encoding Rules<br/>(SER)}} | | | | France Telecom R&D Internal Document | Octet | {{Yes}} | {{Yes}} | | Used primarily in telecommunications related protocols, such as GSM and SS7. Designed to produce an identical encoding from ASN.1 that previously-existing protocols not specified in ASN.1 would produce. |- | {{verth|Lightweight<br/>Encoding Rules<br/>(LWER)}} | | | | Internal document by INRIA. | Memory Word | | {{Yes}} | | Originates from an internal document produced by [[French Institute for Research in Computer Science and Automation|INRIA]] detailing the "Flat Tree Light Weight Syntax" (FTLWS). Abandoned in 1997 due to the superior performance of the Packed Encoding Rules (PER). Optionally Big-Endian or Little-Endian transmission as well as 8-bit, 16-bit, and 32-bit memory words. (Therefore, there are six variants, since there are six combinations of those options.) |- | {{verth|Minimum Bit<br/>Encoding Rules<br/>(MBER)}} | | | | | Bit | | | | Proposed in the 1980s. Meant to be as compact as possible, like the Packed Encoding Rules (PER). |- | {{verth|NEMA Packed<br/>Encoding Rules}} | | | | | Bit | | | | An incomplete encoding rule specification produced by NEMA. It is incomplete because it cannot encode and decode all ASN.1 data types. Compact like the Packed Encoding Rules (PER). |- | {{verth|High Speed<br/>Coding Rules}} | | | | "Coding Rules for High Speed Networks" | | | | | Definition of these encoding rules were a byproduct of INRIA's work on the Flat Tree Light Weight Syntax (FTLWS). |} ===Encoding Control Notation=== ASN.1 recommendations provide a number of predefined encoding rules. If none of the existing encoding rules are suitable, the [[Encoding Control Notation|Encoding Control Notation (ECN)]] provides a way for a user to define his or her own customized encoding rules. === Relation to Privacy-Enhanced Mail (PEM) Encoding === [[Privacy-Enhanced Mail|Privacy-Enhanced Mail (PEM)]] encoding is entirely unrelated to ASN.1 and its codecs, but encoded ASN.1 data, which is often binary, is often PEM-encoded so that it can be transmitted as textual data, e.g. over SMTP relays, or through copy/paste buffers.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)