]> the.earth.li Git - onak.git/blob - merge.h
Fix compilation with later versions of Nettle
[onak.git] / merge.h
1 /*
2  * merge.h - Routines to merge OpenPGP public keys.
3  *
4  * Copyright 2002-2005,2007,2011 Jonathan McDowell <noodles@earth.li>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __MERGE_H__
20
21 #include "keystructs.h"
22
23 /**
24  *      compare_packets - Check to see if 2 OpenPGP packets are the same.
25  *      @a: The first packet to compare.
26  *      @b: The second packet to compare.
27  *
28  *      Takes 2 packets and returns 0 if they are the same, -1 if a is
29  *      less than b, or 1 if a is greater than b.
30  */
31 int compare_packets(struct openpgp_packet *a, struct openpgp_packet *b);
32
33 /**
34  *      merge_keys - Takes 2 public keys and merges them.
35  *      @a: The old key. The merged key is returned in this structure.
36  *      @b: The new key. The changed from old to new keys are returned in this
37  *              structure.
38  *
39  *      This function takes 2 keys and merges them. It then returns the merged
40  *      key in a and the difference between this new key and the original a
41  *      in b (ie newb contains the minimum amount of detail necessary to
42  *      convert olda to newa). The intention is that olda is provided from
43  *      internal storage and oldb from the remote user. newa is then stored in
44  *      internal storage and newb is sent to all our keysync peers.
45  */
46 int merge_keys(struct openpgp_publickey *a, struct openpgp_publickey *b);
47
48 /**
49  *      find_packet - Checks to see if an OpenPGP packet exists in a list.
50  *      @packet_list: The list of packets to look in.
51  *      @packet: The packet to look for.
52  *
53  *      Walks through the packet_list checking to see if the packet given is
54  *      present in it. Returns true if it is.
55  */
56 bool find_packet(struct openpgp_packet_list *packet_list,
57                         struct openpgp_packet *packet);
58
59 /**
60  *      get_signed_packet - Gets a signed packet from a list.
61  *      @packet_list: The list of packets to look in.
62  *      @packet: The packet to look for.
63  *
64  *      Walks through the signedpacket_list looking for the supplied packet and
65  *      returns it if found. Otherwise returns NULL.
66  */
67 struct openpgp_signedpacket_list *find_signed_packet(
68                 struct openpgp_signedpacket_list *packet_list,
69                 struct openpgp_packet *packet);
70
71 /**
72  *      merge_packet_sigs - Takes 2 signed packets and merges their sigs.
73  *      @old: The old signed packet.
74  *      @new: The new signed packet.
75  *
76  *      Takes 2 signed packet list structures and the sigs of the packets on
77  *      the head of these structures. These packets must both be the same and
78  *      the fully merged structure is returned in old and the minimal
79  *      difference to get from old to new in new.
80  */
81 int merge_packet_sigs(struct openpgp_signedpacket_list *old,
82                         struct openpgp_signedpacket_list *new);
83
84 #endif