2 * parsekey.h - Routines to parse an OpenPGP key.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
10 #define __PARSEKEY_H__
12 #include "keystructs.h"
15 * parse_keys - Process a stream of packets for public keys + sigs.
16 * @packets: The packet list to parse.
17 * @keys: The returned list of public keys.
19 * This function takes an list of OpenPGP packets and attempts to parse it
20 * into a list of public keys with signatures and subkeys.
22 * Returns a count of how many keys we parsed.
24 int parse_keys(struct openpgp_packet_list *packets,
25 struct openpgp_publickey **keys);
28 * debug_packet - Print debug info about a packet
29 * @packet: The packet to display.
31 * This function takes an OpenPGP packet and displays some information
32 * about it to stdout. Useful for debugging purposes or curiousity about
33 * an OpenPGP packet stream.
35 int debug_packet(struct openpgp_packet *packet);
38 * read_openpgp_stream - Reads a stream of OpenPGP packets.
39 * @getchar_func: The function to get the next character from the stream.
40 * @ctx: A pointer to the context structure for getchar_func.
41 * @packets: The outputted list of packets.
42 * @maxnum: The maximum number of keys to read. 0 means unlimited.
44 * This function uses getchar_func to read characters from an OpenPGP
45 * packet stream and reads the packets into a linked list of packets
46 * ready for parsing as a public key or whatever. maxnum allows you to
47 * specify the maximum number of keys to read. Note that if this is used
48 * then only the public key component of the last key will be returned,
49 * none of the other packets of the key will be read.
51 int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count,
54 struct openpgp_packet_list **packets,
58 * write_openpgp_stream - Reads a stream of OpenPGP packets.
59 * @putchar_func: The function to put the next character to the stream.
60 * @ctx: A pointer to the context structure for putchar_func.
61 * @packets: The list of packets.
63 * This function uses putchar_func to write characters to an OpenPGP
64 * packet stream from a linked list of packets.
66 int write_openpgp_stream(int (*putchar_func)(void *ctx, size_t count,
69 struct openpgp_packet_list *packets);
72 * flatten_publickey - Convert a publickey to an OpenPGP packet list.
73 * @key: The public key.
74 * @packets: The outputted packet list.
75 * @list_end: The end of the packet list.
77 * This function converts public key structure to a linked list of OpenPGP
78 * packets ready for outputing or storage. If we're not appending to an
79 * existing list then both packets & list_end will be pointers to NULLs,
80 * other wise packets should point to the start of the list and list_end
81 * to the end so we can append to the end.
83 int flatten_publickey(struct openpgp_publickey *key,
84 struct openpgp_packet_list **packets,
85 struct openpgp_packet_list **list_end);
87 #endif /* __PARSEKEY_H__ */