Use C99 uint32_t rather than u_int32_t
[onak.git] / keyid.h
1 /*
2  * keyid.h - Routines to calculate key IDs.
3  *
4  * Copyright 2002,2011 Jonathan McDowell <noodles@earth.li>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 51
17  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __KEYID_H__
21 #define __KEYID_H__
22
23 #include <inttypes.h>
24
25 #include "keystructs.h"
26
27 /**
28  *      get_keyid - Given a public key returns the keyid.
29  *      @publickey: The key to calculate the id for.
30  *
31  *      This function returns the key id for a given public key.
32  */
33 uint64_t get_keyid(struct openpgp_publickey *publickey);
34
35 /**
36  *      get_fingerprint - Given a public key returns the fingerprint.
37  *      @publickey: The key to calculate the id for.
38  *      @fingerprint: The fingerprint (must be at least 20 bytes of space). 
39  *      @len: The length of the returned fingerprint.
40  *
41  *      This function returns the fingerprint for a given public key. As Type 3
42  *      fingerprints are 16 bytes and Type 4 are 20 the len field indicates
43  *      which we've returned.
44  */
45 unsigned char *get_fingerprint(struct openpgp_packet *packet,
46         unsigned char *fingerprint,
47         size_t *len);
48
49 /**
50  *      get_packetid - Given a PGP packet returns the keyid.
51  *      @packet: The packet to calculate the id for.
52  *
53  *      This function returns the key id for a given PGP packet.
54  */
55 uint64_t get_packetid(struct openpgp_packet *packet);
56
57 /**
58  *      get_skshash - Given a public key returns the SKS hash for it.
59  *      @publickey: The key to calculate the hash for.
60  *      @skshash: Hash structure to sort the result in.
61  *
62  *      This function returns the SKS hash for a given public key. This
63  *      is an MD5 hash over a sorted list of all of the packets that
64  *      make up the key. The caller should allocate the memory for the
65  *      hash.
66  */
67 void get_skshash(struct openpgp_publickey *publickey, struct skshash *hash);
68
69 /**
70  *      parse_skshash - Parse a string into an SKS hash structure.
71  *      @search: The string representing the SKS hash.
72  *      @hash: A pointer to the structure to store the hash in.
73  *
74  *      Takes a string and tries to parse it as an SKS hash hex
75  *      representation. Puts the hash into the supplied structure
76  *      if successful. Returns 1 if we parsed something ok, 0 if
77  *      we failed.
78  */
79 int parse_skshash(char *search, struct skshash *hash);
80
81 #endif /* __KEYID_H__ */