I'm trying to grasp the concepts of ASN.1 and the encoding scheme (say DER) and would like to have a sanity check.
What I got so far is that ASN.1 defines abstract data types (INTEGER, BOOLEAN, etc., some are more complicated), and it allows you to define data structures in an abstract way, such as:
World-Schema DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Rocket ::= SEQUENCE
{
range INTEGER, -- huge (see a special directive above)
name UTF8String (SIZE(1..16)),
message UTF8String DEFAULT "Hello World" ,
fuel ENUMERATED {solid, liquid, gas},
speed CHOICE
{
mph INTEGER,
kmph INTEGER
} OPTIONAL,
payload SEQUENCE OF UTF8String
}
END
This defines a structure of a "Rocket" by defining certain fields for it. DER as an encoding scheme come into play only when I want to encode an object, i.e., concrete values of this data structure. So basically I can somehow tell my computer: According to this ASN.1 module, serialize the following JSON file:
{
"range":340282366920938463463374607431768211455,
"name":"Falcon",
"fuel":"solid",
"speed":{"mph":18000},
"payload":["Car", "GPS"]
}
And it'll generate a stream of bits conforming to a certain standard, defined by the DER standard. (X.690 for the manner of sake). Now every receiver of this bit stream (that knows that it's a DER encoded data) will know to interpret this message in terms of ASN.1.
One thing I can't really explain to myself is: do we have to define an interface? I mean, once we have the language (ASN.1) which defines the data types (INTEGER, STRING, etc.) - one can assemble messages, encode them, and send them, and they can be understood. Why does defining an interface between us is important?
Please correct me if I'm getting it all the wrong way.
question from:
https://stackoverflow.com/questions/65942138/basic-understanding-of-asn-1