X-Git-Url: http://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=keystructs.h;h=18a9ba4ce12ca29017bafab63e256ed5d3ecc8a4;hp=4aa8bcb9be37021bc0fa4068723c386544521d0a;hb=76f079e5ebdb34acaaa2462a8d915ee06d3c8425;hpb=5e1b22d763640c4d7a09d07920403d8d491b4410 diff --git a/keystructs.h b/keystructs.h index 4aa8bcb..18a9ba4 100644 --- a/keystructs.h +++ b/keystructs.h @@ -1,5 +1,6 @@ -/* - * keystructs.h - Structures for OpenPGP keys +/** + * @file keystructs.h + * @brief Structures for OpenPGP keys * * Copyright 2002 Jonathan McDowell * @@ -13,8 +14,7 @@ * more details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * this program. If not, see . */ #ifndef __KEYSTRUCTS_H__ @@ -26,100 +26,105 @@ #include "ll.h" +/* + * Fingerprint lengths + * + * v3 MD5 fingerprint is 16 bytes + * v4 SHA-1 fingerprint is 20 + * v5 SHA2-256 fingerprint is 32 + */ +#define FINGERPRINT_V3_LEN 16 +#define FINGERPRINT_V4_LEN 20 +#define FINGERPRINT_V5_LEN 32 +#define MAX_FINGERPRINT_LEN 32 + /** - * struct openpgp_packet - Stores an OpenPGP packet. - * @tag: The packet tag (ie type). - * @newformat: Indicates if this is a new format packet. - * @length: The length of the packet. - * @data: The actual packet + * @brief Stores the fingerprint of an OpenPGP key + */ +struct openpgp_fingerprint { + /** Length of fingerprint. 16 bytes for v3, 20 for v4 */ + size_t length; + /** Fingerprint data. Only the first length bytes are valid */ + uint8_t fp[MAX_FINGERPRINT_LEN]; +}; + +/** + * @brief Stores an OpenPGP packet. * - * This structure holds any form of OpenPGP packet with minimum common - * details decoded out. + * This structure holds any form of OpenPGP packet with minimum common + * details decoded out. */ struct openpgp_packet { + /** The packet tag (i.e. type). */ unsigned int tag; + /** Indicates if this is a new format packet. */ bool newformat; + /** The length of the packet. */ size_t length; + /** The actual packet data. */ unsigned char *data; }; /** - * struct openpgp_packet_list - A linked list of OpenPGP packets. - * @packet: The actual packet structure. - * @next: A pointer to the next packet in the list. + * @brief A linked list of OpenPGP packets. * - * This structure is used to hold a linked list of packets, for example - * all the signatures of a public key's UID. + * This structure is used to hold a linked list of packets, for example + * all the signatures of a public key's UID. */ struct openpgp_packet_list { + /** The actual packet structure. */ struct openpgp_packet *packet; + /** A pointer to the next packet in the list. */ struct openpgp_packet_list *next; }; /** - * struct openpgp_signedpacket_list - A packet with signatures. - * @uid: The OpenPGP packet that's signed. - * @sigs: A list of sigs for the packet. - * @next: A pointer to the next packet with signatures. + * @brief A packet with signatures. * - * This structure holds an OpenPGP packet along with signatures that are - * over this packet. It also links to the next signed packet. It's usually - * used to hold a UID or subkey with their associated signatures. + * This structure holds an OpenPGP packet along with signatures that are + * over this packet. It also links to the next signed packet. It's usually + * used to hold a UID or subkey with their associated signatures. */ struct openpgp_signedpacket_list { + /** The OpenPGP packet that's signed. */ struct openpgp_packet *packet; + /** A linked list of sigs for the packet. */ struct openpgp_packet_list *sigs; + /** Pointer to the last sig in the sigs linked list */ struct openpgp_packet_list *last_sig; + /** A pointer to the next packet with signatures. */ struct openpgp_signedpacket_list *next; }; /** - * struct openpgp_publickey - An OpenPGP public key complete with sigs. - * @publickey: The OpenPGP packet for the public key. - * @revoked: True if the key is revoked. - * @sigs: Any signatures directly on the publickey packet. - * @uids: The list of UIDs with signatures for this key. - * @subkeys: The list of subkeys with signatures for this key. - * @next: The next public key. + * @brief An OpenPGP public key complete with sigs. */ struct openpgp_publickey { + /** The OpenPGP packet for the public key. */ struct openpgp_packet *publickey; + /** True if the key is revoked. */ bool revoked; + /** Any signatures directly on the @a publickey packet. */ struct openpgp_packet_list *sigs; + /** Pointer to the end of the @a sigs list */ struct openpgp_packet_list *last_sig; + /** The list of UIDs with signatures for this key. */ struct openpgp_signedpacket_list *uids; + /** Pointer to the end of the @a uids list */ struct openpgp_signedpacket_list *last_uid; + /** The list of subkeys with signatures for this key. */ struct openpgp_signedpacket_list *subkeys; + /** Pointer to the end of the @a subkey list */ struct openpgp_signedpacket_list *last_subkey; + /** The next public key. */ struct openpgp_publickey *next; }; /** - * struct stats_key - holds key details suitable for doing stats on. - * @keyid: The keyid. - * @colour: Used for marking during DFS/BFS. - * @parent: The key that lead us to this one for DFS/BFS. - * @sigs: A linked list of the signatures on this key. - * @gotsigs: A bool indicating if we've initialized the sigs element yet. - * @disabled: If we shouldn't consider the key in calculations. - * @revoked: If the key is revoked (and shouldn't be considered). - */ -struct stats_key { - uint64_t keyid; - int colour; - uint64_t parent; - struct ll *sigs; - struct ll *signs; - bool gotsigs; - bool disabled; - bool revoked; -}; - -/** - * struct skshash - holds an SKS key hash (md5 over sorted packet list) - * @hash: The 128 bit MD5 hash of the sorted packet list from the key + * @brief Holds an SKS key hash (md5 over sorted packet list) */ struct skshash { + /** The 128 bit MD5 hash of the sorted packet list from the key */ uint8_t hash[16]; };