Heimdal

July 21, 2005

ASN.1 IMPLICIT tagging

Filed under: Heimdal — admin @ 10:00 pm

I’ve been cleaned up the new compiler to make it cause less warnings on many platforms. There was less things to fix then I expected, but some LP64 bugs where in there. Signedness warnings from gcc 4 was very helpful. I need to go over the code again with more warnings turned on.

To the topic of today, IMPLICIT (and AUTOMATIC) tagging. Implicit tagging is a space saving optimization. It allows you to save one complete tag (or, not very common, several tags).

If you define a element like this:

[1] IMPLICIT OCTET STRING

It will encoded on wire in BER as

[CONTEXT PRIM 0] [length 1] [ F ]

 

I have marked each of the bytes with square brackets. If the specfication was using EXPLICIT instead, it would instead have been encoded like this, with a total saving of 2 bytes:

[CONTEXT CONS 0] [length 3] [UNIV PRIM Integer ] [ length 1 ] [ F ]

 

Why it this a problem, saving bytes are good, right ? Yes, saving bytes are good, but the amount of complexity in the compiler is not worth it, especially for AUTOMATIC tagging where the compiler figure out where to put tags. And no less for the humans trying to read it, it’s just too much. Thera are only so many features that the poor developer should need to handle at the same time. Information object model, paramerized types, etc, this is just another way from ITU to make sure the poor developers explode when they read about this.

So can Heimdal’s ASN.1 compiler handle this yet ? No, not yet, but since its used on LDAP and X.509, I’ll get around to fixing it some day soon. The problem is that there are no pretty way of fixing it. Either more generated functions, or breaking the API/ABI. If we compiled to byte-code, it might be easier to handle this (because it could just skip all tags until it got to a primitive type or constructed type.

There is a work-around, inline all of the content into the structure. Basicly don’t reference external types for tags where IMPLICIT tagging enviroment used.

Int ::= INTEGER
Broken ::= SEQUENCE {
b[0] IMPLICIT Int
}
Working ::= SEQUENCE {
w[0] IMPLICIT INTEGER
}

 

This is very clumsy when you have to inline larger structures, also the code handling this gets all broken since there is no way to reference intermediate types.

Technorati tag:

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress