The Unix Janitor
The Unix Janitor

Reputation: 558

how to tell what kind of asn1 i'm receiving

Im slowly getting my head around asn1 notation. Encoding asn1 from an struct seems to quite easy.However decoding asn1 to my application is harder. I want to know if I have an application that receives data on say udp port 600, and this can be a number of asn1 structures, how do i tell which asn1 structure i should be decoding into?

So, when i receive asn1 packets, do we first determine it's type and the decode it depending on its type?

or does my asn1 compiler handle of this for me?

finding examples of this stuff is hard...even for google ;-) .

A tutorial that outlines the building of simple network server using asn1 would be awesome!

Upvotes: 0

Views: 861

Answers (1)

Dan Breslau
Dan Breslau

Reputation: 11522

ASN.1 corresponds roughly to the Presentation Layer of the OSI seven-layer cake. It relies on the Application Layer to determine what types of information is being exchanged between the endpoints. So, there's no universal header or identifier that would indicate which protocol or syntax is being presented by the ASN.1 stream. That could be implied by the port number, or made explicit by an additional protocol layer (e.g., HTTP.)


EDIT (responding to your comment): The ASN.1 standard defines four "classes" of tags: UNIVERSAL, APPLICATION, PRIVATE, and CONTEXT-SPECIFIC. APPLICATION basically means that the tag is defined for use within a specific application (i.e., it's not pre-defined as part of ASN.1.) But an APPLICATION tag doesn't carry enough information to specify (or even hint at) which application is in use.

(Actually, there's very little semantic difference among "APPLICATION", "PRIVATE", and "CONTEXT-SPECIFIC"; these three classes are used mostly for historical and stylistic reasons.)

Upvotes: 1

Related Questions