cscvs to tla changeset 43
[onak.git] / parsekey.h
1 /*
2  * parsekey.h - Routines to parse an OpenPGP key.
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2002 Project Purple
7  */
8
9 #ifndef __PARSEKEY_H__
10 #define __PARSEKEY_H__
11
12 #include "keystructs.h"
13
14 /**
15  *      add_key - Takes a key and adds it to the keyserver.
16  *      @key: The public key to add.
17  *
18  *      This function takes a public key and adds it to the keyserver.
19  *      It first of all sees if we already have the key locally. If we do then
20  *      we retrieve it and merge the two keys. We then store the resulting key
21  *      (or just the original we received if we don't already have it). We then
22  *      send out the appropriate updates to our keyserver peers.
23  */
24 int add_key(struct openpgp_publickey *key);
25
26 /**
27  *      parse_keys - Process a stream of packets for public keys + sigs.
28  *      @packets: The packet list to parse.
29  *      @keys: The returned list of public keys.
30  *
31  *      This function takes an list of OpenPGP packets and attempts to parse it
32  *      into a list of public keys with signatures and subkeys.
33  *
34  *      Returns a count of how many keys we parsed.
35  */
36 int parse_keys(struct openpgp_packet_list *packets,
37                 struct openpgp_publickey **keys);
38
39 /**
40  *      debug_packet - Print debug info about a packet
41  *      @packet: The packet to display.
42  *
43  *      This function takes an OpenPGP packet and displays some information
44  *      about it to stdout. Useful for debugging purposes or curiousity about
45  *      an OpenPGP packet stream.
46  */
47 int debug_packet(struct openpgp_packet *packet);
48
49 /**
50  *      read_openpgp_stream - Reads a stream of OpenPGP packets.
51  *      @getchar_func: The function to get the next character from the stream.
52  *      @ctx: A pointer to the context structure for getchar_func.
53  *      @packets: The outputted list of packets.
54  *
55  *      This function uses getchar_func to read characters from an OpenPGP
56  *      packet stream and reads the packets into a linked list of packets
57  *      ready for parsing as a public key or whatever.
58  */
59 int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count,
60                                 unsigned char *c),
61                                 void *ctx,
62                                 struct openpgp_packet_list **packets);
63
64 /**
65  *      write_openpgp_stream - Reads a stream of OpenPGP packets.
66  *      @putchar_func: The function to put the next character to the stream.
67  *      @ctx: A pointer to the context structure for putchar_func.
68  *      @packets: The list of packets.
69  *
70  *      This function uses putchar_func to write characters to an OpenPGP
71  *      packet stream from a linked list of packets.
72  */
73 int write_openpgp_stream(int (*putchar_func)(void *ctx, size_t count,
74                                                 unsigned char *c),
75                                 void *ctx,
76                                 struct openpgp_packet_list *packets);
77
78 /**
79  *      flatten_publickey - Convert a publickey to an OpenPGP packet list.
80  *      @key: The public key.
81  *      @packets: The outputted packet list.
82  *      @list_end: The end of the packet list.
83  *
84  *      This function converts public key structure to a linked list of OpenPGP
85  *      packets ready for outputing or storage. If we're not appending to an
86  *      existing list then both packets & list_end will be pointers to NULLs,
87  *      other wise packets should point to the start of the list and list_end
88  *      to the end so we can append to the end.
89  */
90 int flatten_publickey(struct openpgp_publickey *key,
91                         struct openpgp_packet_list **packets,
92                         struct openpgp_packet_list **list_end);
93
94 #endif /* __PARSEKEY_H__ */