Update Debian Vcs-* fields to point to git repository
[onak.git] / keystructs.h
1 /**
2  * @file keystructs.h
3  * @brief Structures for OpenPGP keys
4  *
5  * Copyright 2002 Jonathan McDowell <noodles@earth.li>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 51
18  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef __KEYSTRUCTS_H__
22 #define __KEYSTRUCTS_H__
23
24 #include <inttypes.h>
25 #include <stdbool.h>
26 #include <stdlib.h>
27
28 #include "ll.h"
29
30 /**
31  * @brief Stores an OpenPGP packet.
32  *
33  * This structure holds any form of OpenPGP packet with minimum common
34  * details decoded out.
35  */
36 struct openpgp_packet {
37         /** The packet tag (i.e. type). */
38         unsigned int tag;
39         /** Indicates if this is a new format packet. */
40         bool newformat;
41         /** The length of the packet. */
42         size_t length;
43         /** The actual packet data. */
44         unsigned char *data;
45 };
46
47 /**
48  * @brief A linked list of OpenPGP packets.
49  *
50  * This structure is used to hold a linked list of packets, for example
51  * all the signatures of a public key's UID.
52  */
53 struct openpgp_packet_list {
54         /** The actual packet structure. */
55         struct openpgp_packet *packet;
56         /** A pointer to the next packet in the list. */
57         struct openpgp_packet_list *next;
58 };
59
60 /**
61  * @brief A packet with signatures.
62  *
63  * This structure holds an OpenPGP packet along with signatures that are
64  * over this packet. It also links to the next signed packet. It's usually
65  * used to hold a UID or subkey with their associated signatures.
66  */
67 struct openpgp_signedpacket_list {
68         /** The OpenPGP packet that's signed. */
69         struct openpgp_packet *packet;
70         /** A linked list of sigs for the packet. */
71         struct openpgp_packet_list *sigs;
72         /** Pointer to the last sig in the sigs linked list */
73         struct openpgp_packet_list *last_sig;
74         /** A pointer to the next packet with signatures. */
75         struct openpgp_signedpacket_list *next;
76 };
77
78 /**
79  * @brief An OpenPGP public key complete with sigs.
80  */
81 struct openpgp_publickey {
82         /** The OpenPGP packet for the public key. */
83         struct openpgp_packet                   *publickey;
84         /** True if the key is revoked. */
85         bool                                     revoked;
86         /** Any signatures directly on the @a publickey packet. */
87         struct openpgp_packet_list              *sigs;
88         /** Pointer to the end of the @a sigs list */
89         struct openpgp_packet_list              *last_sig;
90         /** The list of UIDs with signatures for this key. */
91         struct openpgp_signedpacket_list        *uids;
92         /** Pointer to the end of the @a uids list */
93         struct openpgp_signedpacket_list        *last_uid;
94         /** The list of subkeys with signatures for this key. */
95         struct openpgp_signedpacket_list        *subkeys;
96         /** Pointer to the end of the @a subkey list */
97         struct openpgp_signedpacket_list        *last_subkey;
98         /** The next public key. */
99         struct openpgp_publickey                *next;
100 };
101
102 /**
103  * @brief Holds an SKS key hash (md5 over sorted packet list)
104  */
105 struct skshash {
106         /** The 128 bit MD5 hash of the sorted packet list from the key */
107         uint8_t hash[16];
108 };
109
110 #endif /* __KEYSTRUCTS_H__ */