[Go] der Encoding and ASN.1

Source: Internet
Author: User

Reprint Address: http://blog.csdn.net/taolinke/article/details/6220403

DER (distinguished Encoding rules, recognizable encoding rule).

ASN.1 Abstract Syntax Markup (abstract Syntax Notation one) ASN.1 is a ISO/ITU-T standard that describes a data format for representing, encoding, transmitting, and decoding data.

Der is one of ASN.1 's many coding schemes.

ASN.1 defines the abstract syntax of information but does not restrict the the-the-information is encoded. Various ASN.1 Encoding rules provide the transfer syntax (a concrete representation) of the data values whose abstract sy Ntax is described in ASN.1.

The standard ASN.1 encoding rules include:

    • Basic Encoding Rules (BER)
    • Canonical Encoding Rules (CER)
    • Distinguished Encoding Rules (DER)
    • XML Encoding Rules (XER)
    • Packed Encoding Rules (PER)
    • Generic String Encoding Rules (gser)

ASN.1 together with specific ASN.1 encoding rules facilitates the exchange of structured data especially between APPLICAT Ion programs over networks by describing data structures in a-on-the-are independent of machine architecture and Impleme Ntation language.

Application layer protocols such as electronic mail, X.500 and LDAP directory services, (VoIP), BACnet an D SNMP use ASN.1 to describe the Protocol data units (PDUS) they exchange. It is also extensively used in the Access and non-access Strata of UMTS. There is many other application domains of ASN.1 [1].

A particularly useful new application of ASN.1 is Fast infoset. Fast Infoset is an international standard that specifies a binary encoding format for the XML information Set (XML INF Oset ) As a alternative to the XML document format. IT aims to provide more efficient serialization than the text-based XML format.

Example

Data structures of Fooprotocol defined using the ASN.1 notation:

Fooprotocol definitions:: = BEGIN      fooquestion:: = SEQUENCE {         trackingnumber INTEGER,         question       IA5String     }      fooanswer:: = SEQUENCE {         questionnumber INTEGER,         answer         BOOLEAN     }  

This could is a specification published by creators of Foo protocol. ASN.1 does not define conversation flows. The textual description of the protocol.

Assuming a message, which complies with Foo protocol and which would be sent to the receiving party. This particular message (PDU) is:

Myquestion fooquestion:: = {     trackingnumber     5,     question           "Anybody There?"}  

To send the above message through the network one needs to encode it to a string of bits. ASN.1 defines various algorithms to accomplish that task, called Encoding rules. There is plenty of them; One of the simplest is distinguished Encoding Rules (DER).

The Foo protocol specification should explicitly name one set of encoding rules to use, so the users of the Foo protocol Know which one they should use.

[edit] Example encoded in DER

Below is the data structure shown above encoded in the DER format (all numbers be in hexadecimal):

--Tag indicating SEQUENCE--length in octets-  -tag indicating INTEGER--length in octets--value
   16--tag indicating ia5string 0e--Length in octets 6e + 6f----value   

(Note:der uses a pattern of tag-length-value triplets)

So what one actually gets is the string of octets:

The scope of ASN.1 and DER ends here. It is possible to transmit the encoded message to the party by any means (utilizing TCP or any other protocol). The party should is able to decode, the octets back using DER.

("Anybody There?" in ASCII)

[Go] der Encoding and ASN.1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.