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