Subject: Re: self-sign v3

From: [email-masked] ("Hal Finney")
Date: Wed, 27 Jul 2005 13:45:46 -0700 (PDT)

welintin son writes:
> I'm trying to export a key in PGP v3, but unfortunaly i'm having
> problems with the
> self-signature type 0x10. I can export the PubKey but the hash doesn't
> match, i did like is
> explained in the RFC 2440 as follows :
> ...
> I did like this : 
>
> MD5(0x99(pkt type), 0x00  0x80(key size - big endian), 128bytes(key data), 
> 26bytes(user name - just the "name <email>"), 0x10(sig class), 0x42
> 0xe7 0xc9 0x18(creation time timestamp - big endian));

I think probably what you did wrong is that your 128 bytes of key data is
not the entire pubkey packet, but rather just the key modulus.  You need
to hash the structure described in section 5.5.2: the version number,
key creation time, etc.  This will typically be more than 128 bytes, for
a 1024 bit key.  The two length bytes should reflect the size of the key
data packet, and then the key data packet body should be hashed.  The rest
of it - the user name and the 5 bytes from the signature packet - looks OK.

Hope this helps -

Hal "Finney