Add support for calculating SKS style key hashes
[onak.git] / keyid.h
1 /*
2  * keyid.h - Routines to calculate key IDs.
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2002 Project Purple
7  */
8
9 #ifndef __KEYID_H__
10 #define __KEYID_H__
11
12 #include <inttypes.h>
13
14 #include "keystructs.h"
15
16 /**
17  *      get_keyid - Given a public key returns the keyid.
18  *      @publickey: The key to calculate the id for.
19  *
20  *      This function returns the key id for a given public key.
21  */
22 uint64_t get_keyid(struct openpgp_publickey *publickey);
23
24 /**
25  *      get_fingerprint - Given a public key returns the fingerprint.
26  *      @publickey: The key to calculate the id for.
27  *      @fingerprint: The fingerprint (must be at least 20 bytes of space). 
28  *      @len: The length of the returned fingerprint.
29  *
30  *      This function returns the fingerprint for a given public key. As Type 3
31  *      fingerprints are 16 bytes and Type 4 are 20 the len field indicates
32  *      which we've returned.
33  */
34 unsigned char *get_fingerprint(struct openpgp_packet *packet,
35         unsigned char *fingerprint,
36         size_t *len);
37
38 /**
39  *      get_packetid - Given a PGP packet returns the keyid.
40  *      @packet: The packet to calculate the id for.
41  *
42  *      This function returns the key id for a given PGP packet.
43  */
44 uint64_t get_packetid(struct openpgp_packet *packet);
45
46 /**
47  *      get_skshash - Given a public key returns the SKS hash for it.
48  *      @publickey: The key to calculate the hash for.
49  *      @skshash: Hash structure to sort the result in.
50  *
51  *      This function returns the SKS hash for a given public key. This
52  *      is an MD5 hash over a sorted list of all of the packets that
53  *      make up the key. The caller should allocate the memory for the
54  *      hash.
55  */
56 void get_skshash(struct openpgp_publickey *publickey, struct skshash *hash);
57
58 #endif /* __KEYID_H__ */