Heimdal

July 25, 2005

hx509 – X.509 and CMS for Heimdal

Filed under: hx509 — admin @ 10:00 pm

This morning I commited a X.509 and CMS implementation to the CVS repository that Heimdal uses. Its not added to Heimdal yet, for that it needs more work. The implementation is based on the CMS framework from the PK-INIT code in Heimdal and uses the ASN.1 library from Heimdal. This, together with the PK-INIT and SPNEGO, have been the driving force behind the update of the ASN.1 library.

It diffrent from the other common free implementation (read OpenSSL) because it centers around the certificate instead of the public/private keys.

Right now it have support for PKCS12, PEM, DER certificate stores, I’ll soon add PKCS11 support.

The CMS interface is somewhat raw, but produces and decodes/verifies SignedData and EnvelopedData. Talking about the interface, I’ll update the API for sure, there needs to be a context variable to pass back errors to the user, com_err might be good, but its not that good.

The reason I started this work is that I found the choices I had to use CMS in PK-INIT was bad and very strange to use. They also didn’t support the operations I need to do, for example search certificates for diffrent critera, use random oids as content types in CMS messages or interface with PKCS11 in a sane way.

Adding PKCS11 support is going to be the intresting part, then I’ll see how much of the API I made up really works with keys that are hiddes inside other devices.

A choice I have to make is what crypto libary I want to support, one way to do it is to use PKCS11 for everything, this way the X.509 and CMS libary will be independent of the crypto support, and the user can choose what crypto provider to use.

The real work is of course adding more tests, its really great to have a large regression testsuite, makes you feel warm inside. Right now there is a small one, but it needs improvements (and for me to commit it).

Technorati tag:

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:

July 13, 2005

New ASN.1 compiler

Filed under: Heimdal — admin @ 10:00 pm

Yesterday I commited the new ASN.1 compiler to Heimdal.Highlighs for the compiler is support for CHOICE and in general better support for tags. This compiler support most of what is needed for PK-INIT, LDAP, X.509, PKCS-12 and many other protocols.

Now I can add lots of neat extentions to the database, and support PK-INIT. The last two weeks I’ve read over the code and written more regression tests. Creating DER data to test the compiler was very boring, I only wrote the primitive types, when I got the the constructed types, I wrote a tool to help me instead. Using the tool suddenly it was very easy to create DER ata.

$ cat test.gen
UNIV CONS Sequence 23
CONTEXT CONS 0 3
UNIV PRIM Integer 1 01
CONTEXT CONS 1 8
UNIV CONS Sequence 6
CONTEXT CONS 127 3
UNIV PRIM Integer 1 01
UNIV PRIM Integer 1 01
CONTEXT CONS 2 3
UNIV PRIM Integer 1 01
$ asn1_gen test.gen
line:   5 offset:   0 class: 0 type: 1 tag:  16 length:  23
[....]
line:  14 offset:  22 class: 0 type: 0 tag:   2 length:   1
line: eof offset: 25
$ asn1_print test.gen.out
UNIV CONS Sequence = 23 bytes {
CONTEXT CONS tag 0 = 3 bytes [0]
UNIV PRIM Integer = integer 1
CONTEXT CONS tag 1 = 8 bytes [1]
UNIV CONS Sequence = 6 bytes {
CONTEXT CONS tag 127 = 3 bytes [127]
UNIV PRIM Integer = integer 1
}
UNIV PRIM Integer = integer 1
CONTEXT CONS tag 2 = 3 bytes [2]
UNIV PRIM Integer = integer 1
}

 

PK-INIT have gotten iself a push lately, it might be ready for WG-LC after Paris IETF meeting, that is great progress. Then maybe we can get Kerberos extentions out the door.

July 2, 2005

libkdc and ASN.1 compiler

Filed under: Heimdal — admin @ 10:00 pm

So the last couple of days I’ve spend at my cousins house in Laguna Hills, CA, USA. Very nice, hacking Heimdal next to the pool in the sun.

I’ve merged in Andrew Bartlett’s code for libkdc from Lorikeet, it was two days of work, much changes that needs to adapted to the rest of the style in Heimdal and remove part of the patch that we can’t accept yet.

Now I’m working on mergeing in the new ASN.1 compiler that Johan started on and I have cleaned up and started to use in PK-INIT. Currently I’m adding more regression test for failure cases, I would like to see more generated testes, it should really be an integral part of the compiler.

The compiler is needed for both the HDB extentions and I would like to see Lukes new SPNEGO code use it. Hopefully I’ll be done by the time I get to Boston next week.

Powered by WordPress