2 * keyid.h - Routines to calculate key IDs.
4 * Copyright 2002,2011 Jonathan McDowell <noodles@earth.li>
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.
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
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.
25 #include "keystructs.h"
29 * fingerprint2keyid - convert a fingerprint to a keyid
30 * @fingerprint: The fingerprint structure to convert
31 * @returns: 64 bit keyid
33 * This function returns the key id for a given fingerprint. Currently
34 * only works for v4 fingerprints.
36 uint64_t fingerprint2keyid(struct openpgp_fingerprint *fingerprint);
39 * get_keyid - Given a public key returns the keyid.
40 * @publickey: The key to calculate the id for.
41 * @keeyid: The returned keyid
43 * This function returns the key id for a given public key.
45 onak_status_t get_keyid(struct openpgp_publickey *publickey, uint64_t *keyid);
48 * get_fingerprint - Given a public key returns the fingerprint.
49 * @publickey: The key to calculate the id for.
50 * @fingerprint: The fingerprint structure to store the result in
52 * This function returns the fingerprint for a given public key. As Type 3
53 * fingerprints are 16 bytes and Type 4 are 20 the len field indicates
54 * which we've returned.
56 onak_status_t get_fingerprint(struct openpgp_packet *packet,
57 struct openpgp_fingerprint *fingerprint);
60 * get_packetid - Given a PGP packet returns the keyid.
61 * @packet: The packet to calculate the id for.
62 * @keyid: The returned keyid
64 * This function returns the key id for a given PGP packet.
66 onak_status_t get_packetid(struct openpgp_packet *packet, uint64_t *keyid);
69 * get_skshash - Given a public key returns the SKS hash for it.
70 * @publickey: The key to calculate the hash for.
71 * @skshash: Hash structure to sort the result in.
73 * This function returns the SKS hash for a given public key. This
74 * is an MD5 hash over a sorted list of all of the packets that
75 * make up the key. The caller should allocate the memory for the
78 onak_status_t get_skshash(struct openpgp_publickey *publickey,
79 struct skshash *hash);
82 * parse_skshash - Parse a string into an SKS hash structure.
83 * @search: The string representing the SKS hash.
84 * @hash: A pointer to the structure to store the hash in.
86 * Takes a string and tries to parse it as an SKS hash hex
87 * representation. Puts the hash into the supplied structure
88 * if successful. Returns 1 if we parsed something ok, 0 if
91 int parse_skshash(char *search, struct skshash *hash);
93 #endif /* __KEYID_H__ */