Monday, 9 April 2018

ASN.1 Defining types and identifiers

As per convention, a type in ASN.1 is defined using capital letter. Whereas identifiers must begin with lowercase letter.

Example
Employee ::= SEQUENCE {
 firstName VisibleString,
 lastName VisibleString,
 address Address
}

Address ::= SEQUENCE {
 street VisibleString,
 city VisibleString,
 state VisibleString,
 country VisibleString,
 pin INTEGER
}

In the above example,
a.   Employee and Address are types.
b.   firstName, lastName, address, street, city, state, country and pin are identifiers.

You can create an Employee object like below.

employee1 Employee ::= {
 firstName "Hari Krishna",
 lastName "Gurram",
 address {
  street "chowdesrai temple street",
  city "Bangalore",
  state "Karnantaka",
  country "India",
  pin 523145
 }
}

Encoding of above data in XML scheme looks like below.

<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <firstName>Hari Krishna</firstName>
  <lastName>Gurram</lastName>
  <address>
    <street>chowdesrai temple street</street>
    <city>Bangalore</city>
    <state>Karnantaka</state>
    <country>India</country>
    <pin>523145</pin>
  </address>
</Employee>



Previous                                                 Next                                                 Home

No comments:

Post a Comment