EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Reading a PGP Key ID and Fingerprint

Posted: 12/17/2012 07:32:37
by Frank Munsberg (Standard support level)
Joined: 06/04/2009
Posts: 49

To put it simple, I'm probably doing something wrong. I have a PGP public key file that shows up in GPG4Win with a ID of 6D38F4F6

Now when I'm loading that public key via

SBPGPKeys.TElPGPPublicKey key = new SBPGPKeys.TElPGPPublicKey();

And then read the ID (or the FP) like this:

    [0]: 46
    [1]: 247
    [2]: 112
    [3]: 79
    [4]: 109
    [5]: 56
    [6]: 244
    [7]: 246


The keyfile in itself is valid but the ID's differ. Also the Fingerprints don't match in a similar way. What am I doing wrong?
Posted: 12/17/2012 07:38:48
by Eugene Mayevski (Team)

Both Key ID and Key Fingerprint are binary values - these are hashes of the key.

GnuPG encodes them somehow (either to BASE16 or to BASE64) and probably cuts down the value.

Sincerely yours
Eugene Mayevski
Posted: 12/17/2012 07:46:10
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 442

GnuPG shows only last 4 bytes of KeyID, which are hex-encoded.
And, in your example, they correspond to key id, shown by GnuPG (109 = $6D, 56 = $38, 244 = $F4, 246 = $F6).
Posted: 12/17/2012 08:48:47
by Frank Munsberg (Standard support level)
Joined: 06/04/2009
Posts: 49

Woohoo so I was just being stupid. Google came up with this for hex encoding

string ID = BitConverter.ToString(key.KeyID());

and it seems to work. The output finally makes sense now and the Fingerprint completely matches too. This is good news. Thanks alot! :)



Topic viewed 797 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!