Abstract Syntax Notation One ASN 1 ASN 1
											Abstract Syntax Notation One: - ASN. 1 • • • ASN. 1 is more than a syntax; it’s a language Addresses both syntax and semantics Two type of syntax • Abstract syntax: syntax set of rules that specify data type and structure for information storage • Transfer syntax: syntax set of rules for communicating information between systems Makes application layer protocols independent of lower layer protocols Can generate machine-readable code: Basic Encoding Rules (BER) BER is used in management modules
											http: //www. strongsec. com/zhw/KSy_ASN 1. pdf Abstract Syntax & Transfer Syntax
											Backus-Nauer Form (BNF) Definition: (Production) <name> : : = <definition> Rules: <digit> : : = 0|1|2|3|4|5|6|7|8|9 <number> : : = <digit> | <digit><number> <op> : : = +|-|x|/ <SAE> : : = <number>|<SAE><op><SAE> Example: • 9 is primitive 9 • 19 is construct of 1 and 9 • 619 is construct of 6 and 19
											Data Type and Value • • Assignments • <Boolean. Type> : : = BOOLEAN • <Boolean. Value> : : = TRUE | FALSE Primitive ASN. 1 data types in SNMPv 1 • • • INTEGER OCTET STRING OBJECT IDENTIFIER NULL All in Capital letters keywords
											Type and Value Assignments
											Subtype Syntax: <subtype name> : : = <type> ( <constraint> ) Examples: Counter : : = INTEGER ( 0. . 4294967295 ) Ip. Address : : = OCTET STRING ( SIZE(4) ) Spring : : = Months ( march | april | may ) Summer : : = Months ( june | july | august ) Small. Prime : : = INTEGER ( 2 | 3 | 5 | 7 | 11 ) Export. Key : : = BIT STRING ( SIZE(40) )
											ASN. 1 Data Types n Basic Types n n BOOLEAN, INTEGER, BIT STRING, OCTET STRING, NULL, OBJECT IDENTIFIER, REAL, ENUMERATED, Numeric. String, Printable. String, IA 5 String, UTCTime, Generalized. Time, Character. String Constructed Types n n n CHOICE SEQUENCE, SEQUENCE OF SET, SET OF https: //www. oss. com/asn 1/resources/asn 1 -made-simple/types. html
											Example Married : : = BOOLEAN Age : : = INTEGER Picture : : = BIT STRING Form : : = SEQUENCE { name Printable. String, age Age, married Married, marriage-certificate Picture }
											Example Payment-method : : = CHOICE { check Check-number, credit-card SEQUENCE { number Card-number, expiry-date Date } }
											Data Type: Example 1 Personnel. Record : : = SET { Name, title Graphic. String, division CHOICE { marketing [0] SEQUENCE {Sector, Country}, research [1] CHOICE {product-based [0] NULL, basic [1] NULL}, production [2] SEQUENCE {Product-line, Country } } } Tag
											Data Type: Example 2 Trade-message : : = SEQUENCE { invoice-no INTEGER, name Graphic. String, details SEQUENCE OF SEQUENCE { part-no INTEGER, quantity INTEGER }, charge REAL, authenticator Security-Type }
											Enumerated Integer Ip. Route. Type : : = INTEGER { other(1), invalid(2), direct(3), indirect(4) }
											Object Name internet OBJECT IDENTIFIER : : = { iso(1) org(3) dod(6) internet(1) } private OBJECT IDENTIFIER : : = { internet 4 } The object identifier (OID) of internet is 1. 3. 6. 1 The object identifier (OID) of private is 1. 3. 6. 1. 4
											ASN. 1 Module • ASN. 1 module is a group of assignments person-name Person-Name : : = { first "John", middle "I", last "Smith" } • • person-name module name Person-name module
											Module <module name> DEFINITIONS : : = BEGIN <name> : : = <definition> … <name> : : = <definition> END
											Foo. Protocol DEFINITIONS : : = BEGIN Foo. Question : : = SEQUENCE { tracking. Number INTEGER, question IA 5 String } Foo. Answer : : = SEQUENCE { question. Number INTEGER, answer BOOLEAN } END https: //zh. wikipedia. org/wiki/ASN. 1
											ASN. 1 Keyword Examples CHOICE SEQUENCE OF SET OF INTEGER NULL OCTET STRING List of alternatives Ordered list maker Ordered array of repetitive data Unordered list maker Unordered list of repetitive data Any negative or non-negative number A placeholder String of octets (8 -bit bytes) OBJECT IDENTIFIER A sequence of non-negative numbers to uniquely identify an object
											ASN. 1 Symbols Symbol Meaning : : = Defined as | or, alternative, options of a list - Signed number -- Following the symbol are comments {} Start and end of a list [] Start and end of a tag () Start and end of subtype . . Range
											ASN. 1 Data Type Conventions Data Types Convention Example Object name Initial lowercase letter sys. Descr, ether. Stats. Pkts Application data type Initial uppercase letter Counter, Ip. Address Module Initial uppercase letter Personnel. Record Macro, MIB module All uppercase letters RMON-MIB Keywords INTEGER, BEGIN
											Data Type: Structure & Tag • Structure defines how data type is built • Tag uniquely identifies the data type
											Structure • Simple Page. Number : : = INTEGER Chapter. Number : : = INTEGER • Structured / Construct Book. Page. Number : : = SEQUENCE {Chapter. Number, Separator, Page. Number} • • Tagged • Derived from another type; given a new ID • In Fig. 3 -14, INTEGER is either universal or application specific Other • CHOICE, ANY
											Structured Type n SEQUENCE n n SEQUENCE OF n n Ordered array of repetitive data SET n n Ordered list maker Unordered list maker SET OF n Unordered list of repetitive data
											Tag • • • Tag uniquely identifies a data type Comprises class and tag number Class: • Universal - always true • Application - only in the application used • Context-specific - specific context in application • Private - used extensively by commercial vendors
											Tag Examples BOOLEAN INTEGER Page. Number product-based Universal 1 Universal 2 [APPLICATION 3] Context-specific under research [0] Counter : : = [APPLICATION 1] INTEGER (0. . 4294967295)
											Informal description of personnel record Name: John P Smith Title: Director Employee Number 51 Date of Hire: 17 September 1971 Name of Spouse; Mary T Smith Number of Children 2 Child Information Name Ralph T Smith Date of Birth 11 November 1957 Child Information Name Susan B Jones Date of Birth 17 July 1959
											ASN. 1 description of the record structure Personnel. Record : : = [APPLICATION 0] IMPLICIT SET { Name, title [0] Visible. String, number Employee. Number, date. Of. Hire [1] Date, name. Of. Spouse [2] Name, children [3] IMPLICIT SEQUENCE OF Child. Information DEFAULT { } } Child. Information : : = SET { Name, date. Of. Birth [0] Date } Name : : = [APPLICATION 1] IMPLICIT SEQUENCE { given. Name Visible. String, initial Visible. String, family. Name Visible. String } Employee. Number : : = [APPLICATION 2] IMPLICIT INTEGER Date : : = [APPLICATION 3] IMPLICIT Visible. String -- YYYYMMDD
											ASN. 1 description of a record value { {given. Name “John”, initial “T”, family. Name “Smith”}, title “Director” number “ 51” date. Of. Hire “ 19710917” name. Of. Spouse {given. Name “Mary”, initial “T”, family. Name “Smith”}, children { { {given. Name “Ralph”, initial “T”, family. Name “Smith”}, date. Of. Birth “ 19571111” }, { {given. Name “Susan”, initial “B”, family. Name “Jones”} date. Of. Birth “ 19590717” } } }
											Transfer Encoding Contact : : = SEQUENCE { name Visible. String, phone Numeric. String } -- BER, CER, DER, PER, XER, JER, … Basic Encoding Rules (BER) 30 19 80 0 A 4 A 6 F 686 E 20536 D 697468 81 0 B 3938372036353433323130 Packed Encoding Rules (PER) 0 A 4 A 6 F 68 6 E 20 53 6 D 69 74 68 0 B A 9 80 76 54 32 10 XML Encoding Rules (XER) <? xml version="1. 0" encoding="UTF-8"? > <Contact> <name>John Smith</name> <phone>987 6543210</phone> </Contact> JSON Encoding Rules (JER) { "name" : "John Smith", "phone" : "987 6543210" } https: //www. oss. com/asn 1/resources/asn 1 -made-simple/introduction. html
											BER Encoding n n BER (Basic Encoding Rule) TLV Encoding Structure P/C: Primitive/Construct 0/1 T: Tag
											TLV INTEGER Primitive: T L V SEQUENCE Construct: T L V T V L V
											
											Universal Class Tag Binary Hex Tag 00 0 00010 00101 00 0 00110 00 1 10000 02 04 05 06 30 Universal Universal Tag Name 2 4 5 6 16 INTEGER OCTET STRING NULL OBJECT IDENTIFIER SEQUENCE / SEQUENCE OF Page 127
											Tag numbers 31
											
											1000 0000
											30 0 A 1 A 04 4 A 61 6 E 65 51 02 00 80
											
											Example: SNMP Message Tag Message : : = SEQUENCE { version INTEGER { version-1(0) }, community OCTET STRING, data ANY } 30 02 04
											Example: SNMP Message Type 30: SEQUENCE Length 82 01 c 0: 448 octets 82: 10000010
											Type 30: SEQUENCE Length 32: 50 octets
											8. Macros <macroname> MACRO : : = BEGIN TYPE NOTATION : : = <syntax. Of. New. Type> VALUE NOTATION : : = <syntax. Of. New. Value> <auxiliary. Assignments> END
											Macro Examlple ERROR MACRO : : = BEGIN TYPE NOTATION : : = Parameter VALUE NOTATION : : = value (VALUE CHOICE { local. Value INTEGER, global. Value OBJECT IDENTIFIER }) Parameter : : = "PARAMETER'' Named. Type | empty Named. Type : : = identifier type | type END Bad. Queue. Name ERROR PARAMETER Queue. Name : : = 0
											Macro Example OBJECT-TYPE MACRO : : = BEGIN TYPE NOTATION : : = "SYNTAX" type (TYPE Object. Syntax) "ACCESS" Access "STATUS" Status VALUE NOTATION : : = value (VALUE Object. Name) Access : : = "read-only" | "read-write“ | "write-only | "not-accessible" Status : : = "mandatory” | "optional“ END | "obsolete"
											Object-Type Example sys. Name OBJECT-TYPE SYNTAX Display. String (SIZE (0. . 255)) ACCESS read-write STATUS mandatory : : = { system 5 }
											Marco Example 2 CAR MACRO: : = BEGIN TYPE NOTATION : : = Brand Engine Car. Type Year VALUE NOTATION : : = value (VALUE OBJECT IDENTIFIER) Brand : : = “BRAND” value (Printable. String) Engine : : = “CC” Ccs : : = Cc | Ccs”, ” Cc Cc : : = value (INTEGER (600. . 5000)) Car. Type : : = “STYLE” CType : : = “Sedan” | “Liftback” | “SUV” | “Other” Year : : = “YEAR” value (INTEGER) END
											Camry CAR BRAND Toyota CC 2000, 2400, 3000 STYLE Sedan YEAR 2006 : : = {toyota 3}
- Slides: 46