]> the.earth.li Git - onak.git/blob - keyid.h
Fix compilation with later versions of Nettle
[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, see <https://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __KEYID_H__
20 #define __KEYID_H__
21
22 #include <inttypes.h>
23
24 #include "keystructs.h"
25 #include "onak.h"
26
27 /**
28  *      fingerprint2keyid - convert a fingerprint to a keyid
29  *      @fingerprint: The fingerprint structure to convert
30  *      @returns: 64 bit keyid
31  *
32  *      This function returns the key id for a given fingerprint. Currently
33  *      only works for v4 fingerprints.
34  */
35 uint64_t fingerprint2keyid(struct openpgp_fingerprint *fingerprint);
36
37 /**
38  *      get_keyid - Given a public key returns the keyid.
39  *      @publickey: The key to calculate the id for.
40  *      @keeyid: The returned keyid
41  *
42  *      This function returns the key id for a given public key.
43  */
44 onak_status_t get_keyid(struct openpgp_publickey *publickey, uint64_t *keyid);
45
46 /**
47  *      get_fingerprint - Given a public key returns the fingerprint.
48  *      @publickey: The key to calculate the id for.
49  *      @fingerprint: The fingerprint structure to store the result in
50  *
51  *      This function returns the fingerprint for a given public key. As Type 3
52  *      fingerprints are 16 bytes and Type 4 are 20 the len field indicates
53  *      which we've returned.
54  */
55 onak_status_t get_fingerprint(struct openpgp_packet *packet,
56         struct openpgp_fingerprint *fingerprint);
57
58 /**
59  *      get_packetid - Given a PGP packet returns the keyid.
60  *      @packet: The packet to calculate the id for.
61  *      @keyid: The returned keyid
62  *
63  *      This function returns the key id for a given PGP packet.
64  */
65 onak_status_t get_packetid(struct openpgp_packet *packet, uint64_t *keyid);
66
67 /**
68  *      get_skshash - Given a public key returns the SKS hash for it.
69  *      @publickey: The key to calculate the hash for.
70  *      @skshash: Hash structure to sort the result in.
71  *
72  *      This function returns the SKS hash for a given public key. This
73  *      is an MD5 hash over a sorted list of all of the packets that
74  *      make up the key. The caller should allocate the memory for the
75  *      hash.
76  */
77 onak_status_t get_skshash(struct openpgp_publickey *publickey,
78         struct skshash *hash);
79
80 /**
81  *      parse_skshash - Parse a string into an SKS hash structure.
82  *      @search: The string representing the SKS hash.
83  *      @hash: A pointer to the structure to store the hash in.
84  *
85  *      Takes a string and tries to parse it as an SKS hash hex
86  *      representation. Puts the hash into the supplied structure
87  *      if successful. Returns 1 if we parsed something ok, 0 if
88  *      we failed.
89  */
90 int parse_skshash(char *search, struct skshash *hash);
91
92 #endif /* __KEYID_H__ */