Ethereal-dev: [Ethereal-dev] Help decoding ASN.1 ID 0

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Yaniv Kaul <ykaul@xxxxxxxxxxxxxx>
Date: Wed, 28 May 2003 12:57:47 +0200
I'm trying to add ASN.1 certificate parsing to Ethereal. I'll start with SSL, then do something generic, which can be used by SSL, SSH, IKE and possibly others I'm not aware of. However, I'm having problem using asn1_id_decode(), as for ID=0 it only moves asn1->offset 1 byte ahead, instead of 2 bytes. If I 'manually' move it, everything's ok. Here's what I'm trying to dissect, I'd appreciate if knowledgable people could help me out here:
30 82 02 DF  (Certificate SEQUENCE, length 0x02DF)
   30 82 01 C7  (TBSCertificate SEQUENCE, length 0x1C7)
       A0 03        (ID=0, length 3 - this is where I'm stuck)
02 01 02 (Integer, length =1, value =2 - which is the Version number of the certificate - val=2 means X.590v3)

The relevant piece of my code is:
ret = asn1_id_decode(&hnd, &cls, &con, &tag);
if(ret == ASN1_ERR_NOERROR) {
   proto_tree_add_text(subtree, tvb, cert_len, 2, "ID %d",tag);
   cert_len += 2;
   hnd.offset++; /* My much needed hack! */


I believe the problem is in asn1.h, in line 191:
if (*tag == 0x1F) {


Any help will be greatly appreciated.
Relevant RFC is 3280, if anyone's interested.

Y.