3 * @brief Structures for OpenPGP keys
5 * Copyright 2002 Jonathan McDowell <noodles@earth.li>
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.
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
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <https://www.gnu.org/licenses/>.
20 #ifndef __KEYSTRUCTS_H__
21 #define __KEYSTRUCTS_H__
30 * v3 MD5 fingerprint is 16 bytes
31 * v4 SHA-1 fingerprint is 20
32 * v5 SHA2-256 fingerprint is 32
34 #define MAX_FINGERPRINT_LEN 32
37 * @brief Stores the fingerprint of an OpenPGP key
39 struct openpgp_fingerprint {
40 /** Length of fingerprint. 16 bytes for v3, 20 for v4 */
42 /** Fingerprint data. Only the first length bytes are valid */
43 uint8_t fp[MAX_FINGERPRINT_LEN];
47 * @brief Stores an OpenPGP packet.
49 * This structure holds any form of OpenPGP packet with minimum common
50 * details decoded out.
52 struct openpgp_packet {
53 /** The packet tag (i.e. type). */
55 /** Indicates if this is a new format packet. */
57 /** The length of the packet. */
59 /** The actual packet data. */
64 * @brief A linked list of OpenPGP packets.
66 * This structure is used to hold a linked list of packets, for example
67 * all the signatures of a public key's UID.
69 struct openpgp_packet_list {
70 /** The actual packet structure. */
71 struct openpgp_packet *packet;
72 /** A pointer to the next packet in the list. */
73 struct openpgp_packet_list *next;
77 * @brief A packet with signatures.
79 * This structure holds an OpenPGP packet along with signatures that are
80 * over this packet. It also links to the next signed packet. It's usually
81 * used to hold a UID or subkey with their associated signatures.
83 struct openpgp_signedpacket_list {
84 /** The OpenPGP packet that's signed. */
85 struct openpgp_packet *packet;
86 /** A linked list of sigs for the packet. */
87 struct openpgp_packet_list *sigs;
88 /** Pointer to the last sig in the sigs linked list */
89 struct openpgp_packet_list *last_sig;
90 /** A pointer to the next packet with signatures. */
91 struct openpgp_signedpacket_list *next;
95 * @brief An OpenPGP public key complete with sigs.
97 struct openpgp_publickey {
98 /** The OpenPGP packet for the public key. */
99 struct openpgp_packet *publickey;
100 /** True if the key is revoked. */
102 /** Any signatures directly on the @a publickey packet. */
103 struct openpgp_packet_list *sigs;
104 /** Pointer to the end of the @a sigs list */
105 struct openpgp_packet_list *last_sig;
106 /** The list of UIDs with signatures for this key. */
107 struct openpgp_signedpacket_list *uids;
108 /** Pointer to the end of the @a uids list */
109 struct openpgp_signedpacket_list *last_uid;
110 /** The list of subkeys with signatures for this key. */
111 struct openpgp_signedpacket_list *subkeys;
112 /** Pointer to the end of the @a subkey list */
113 struct openpgp_signedpacket_list *last_subkey;
114 /** The next public key. */
115 struct openpgp_publickey *next;
119 * @brief Holds an SKS key hash (md5 over sorted packet list)
122 /** The 128 bit MD5 hash of the sorted packet list from the key */
126 #endif /* __KEYSTRUCTS_H__ */