CSN.1 vs ASN.1
Although their acronyms are similar, CSN.1 is substantially different from ASN.1.
ASN.1 defines an abstract data structure: in other words, an ASN.1 specification tells you, for example, that we have a structure with some fields in it, or a union, an array and so on.
In ASN.1 we describe our data structure as we do when we are declaring C structs.
When we need to actually send the data over the network, we follow the encoding rules we have chosen. These encoding rules, like BER o PER, tell us that a structure is always coded in a given way, an integer is always coded in another way and so on.
Therefore any ASN.1 tools can easily generate a C data structure and some C code able to take a BER or PER coded binary stream and decode it into that C structure.
CSN.1, instead, defines at bit-level the encoded stream. A CSN.1 definition says, for example, that we expect a 1 followed by 8 more bits or a 0 followed by 4 bits and another 0:
< my data > ::= 1 <x: bit(8)> | 0 <y: bit(4)> 0; |
Most of the CSN.1 tools read the CSN.1 specification file and produce a CSN.1 parser; this parser, once compiled, reads the encoded binary stream and when it recognize some valid elements in it invokes a user defined callback function.
In other words, it generates code that will say to you: hey, I found the 1 followed by the 8 bits you were expecting: the 8 bits are 11001001; do whatever you like.
In other words, the data structures need to be deduced from the encoded data by reverse-engineering the CSN.1 code and try to guess the original structures.
|