Use C99 uint32_t rather than u_int32_t
[onak.git] / keystructs.h
1 /*
2  * keystructs.h - Structures for OpenPGP keys
3  *
4  * Copyright 2002 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 __KEYSTRUCTS_H__
21 #define __KEYSTRUCTS_H__
22
23 #include <inttypes.h>
24 #include <stdbool.h>
25 #include <stdlib.h>
26
27 #include "ll.h"
28
29 /**
30  *      struct openpgp_packet - Stores an OpenPGP packet.
31  *      @tag: The packet tag (ie type).
32  *      @newformat: Indicates if this is a new format packet.
33  *      @length: The length of the packet.
34  *      @data: The actual packet
35  *
36  *      This structure holds any form of OpenPGP packet with minimum common
37  *      details decoded out.
38  */
39 struct openpgp_packet {
40         unsigned int tag;
41         bool newformat;
42         size_t length;
43         unsigned char *data;
44 };
45
46 /**
47  *      struct openpgp_packet_list - A linked list of OpenPGP packets.
48  *      @packet: The actual packet structure.
49  *      @next: A pointer to the next packet in the list.
50  *
51  *      This structure is used to hold a linked list of packets, for example
52  *      all the signatures of a public key's UID.
53  */
54 struct openpgp_packet_list {
55         struct openpgp_packet *packet;
56         struct openpgp_packet_list *next;
57 };
58
59 /**
60  *      struct openpgp_signedpacket_list - A packet with signatures.
61  *      @uid: The OpenPGP packet that's signed.
62  *      @sigs: A list of sigs for the packet.
63  *      @next: A pointer to the next packet with signatures.
64  *
65  *      This structure holds an OpenPGP packet along with signatures that are
66  *      over this packet. It also links to the next signed packet. It's usually
67  *      used to hold a UID or subkey with their associated signatures.
68  */
69 struct openpgp_signedpacket_list {
70         struct openpgp_packet *packet;
71         struct openpgp_packet_list *sigs;
72         struct openpgp_packet_list *last_sig;
73         struct openpgp_signedpacket_list *next;
74 };
75
76 /**
77  *      struct openpgp_publickey - An OpenPGP public key complete with sigs.
78  *      @publickey: The OpenPGP packet for the public key.
79  *      @revoked: True if the key is revoked.
80  *      @sigs: Any signatures directly on the publickey packet.
81  *      @uids: The list of UIDs with signatures for this key.
82  *      @subkeys: The list of subkeys with signatures for this key.
83  *      @next: The next public key.
84  */
85 struct openpgp_publickey {
86         struct openpgp_packet                   *publickey;
87         bool                                     revoked;
88         struct openpgp_packet_list              *sigs;
89         struct openpgp_packet_list              *last_sig;
90         struct openpgp_signedpacket_list        *uids;
91         struct openpgp_signedpacket_list        *last_uid;
92         struct openpgp_signedpacket_list        *subkeys;
93         struct openpgp_signedpacket_list        *last_subkey;
94         struct openpgp_publickey                *next;
95 };
96
97 /**
98  *      struct stats_key - holds key details suitable for doing stats on.
99  *      @keyid: The keyid.
100  *      @colour: Used for marking during DFS/BFS.
101  *      @parent: The key that lead us to this one for DFS/BFS.
102  *      @sigs: A linked list of the signatures on this key.
103  *      @gotsigs: A bool indicating if we've initialized the sigs element yet.
104  *      @disabled: If we shouldn't consider the key in calculations.
105  *      @revoked: If the key is revoked (and shouldn't be considered).
106  */
107 struct stats_key {
108         uint64_t keyid;
109         int colour;
110         uint64_t parent;
111         struct ll *sigs;
112         struct ll *signs;
113         bool gotsigs;
114         bool disabled;
115         bool revoked;
116 };
117
118 /**
119  *      struct skshash - holds an SKS key hash (md5 over sorted packet list)
120  *      @hash: The 128 bit MD5 hash of the sorted packet list from the key
121  */
122 struct skshash {
123         uint8_t hash[16];
124 };
125
126 #endif /* __KEYSTRUCTS_H__ */