uncrustify as demanded.
[oweals/gnunet.git] / src / include / gnunet_revocation_service.h
1 /*
2       This file is part of GNUnet
3       Copyright (C) 2013 GNUnet e.V.
4
5       GNUnet is free software: you can redistribute it and/or modify it
6       under the terms of the GNU Affero General Public License as published
7       by the Free Software Foundation, either version 3 of the License,
8       or (at your option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       Affero General Public License for more details.
14
15       You should have received a copy of the GNU Affero General Public License
16       along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20
21 #ifndef GNUNET_REVOCATION_SERVICE_H_
22 #define GNUNET_REVOCATION_SERVICE_H_
23
24 /**
25  * @author Christian Grothoff
26  *
27  * @file
28  * API to perform and access key revocations
29  *
30  * @defgroup revocation  Revocation service
31  * Perform and access key revocations.
32  *
33  * @see [Documentation](https://gnunet.org/revocation-subsystem)
34  *
35  * @{
36  */
37
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #if 0                           /* keep Emacsens' auto-indent happy */
42 }
43 #endif
44 #endif
45
46 #include "gnunet_util_lib.h"
47
48 /**
49  * Version of the key revocation API.
50  */
51 #define GNUNET_REVOCATION_VERSION 0x00000000
52
53 /**
54  * Handle for the key revocation query.
55  */
56 struct GNUNET_REVOCATION_Query;
57
58 /**
59  * Callback to call with the result of a key revocation query.
60  *
61  * @param cls closure
62  * @param is_valid #GNUNET_NO of the key is/was revoked,
63  *                 #GNUNET_YES if the key is still valid,
64  *                 #GNUNET_SYSERR if we had trouble querying the service
65  *
66  */
67 typedef void (*GNUNET_REVOCATION_Callback) (void *cls,
68                                             int is_valid);
69
70
71 /**
72  * Check if a key was revoked.
73  *
74  * @param cfg the configuration to use
75  * @param key key to check for revocation
76  * @param func funtion to call with the result of the check
77  * @param func_cls closure to pass to @a func
78  * @return handle to use in #GNUNET_REVOCATION_query_cancel to stop REVOCATION from invoking the callback
79  */
80 struct GNUNET_REVOCATION_Query *
81 GNUNET_REVOCATION_query(const struct GNUNET_CONFIGURATION_Handle *cfg,
82                         const struct GNUNET_CRYPTO_EcdsaPublicKey *key,
83                         GNUNET_REVOCATION_Callback func, void *func_cls);
84
85
86 /**
87  * Cancel key revocation check.
88  *
89  * @param q query to cancel
90  */
91 void
92 GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q);
93
94
95 /**
96  * Handle for the key revocation operation.
97  */
98 struct GNUNET_REVOCATION_Handle;
99
100
101 /**
102  * Perform key revocation.
103  *
104  * @param cfg the configuration to use
105  * @param key public key of the key to revoke
106  * @param sig signature to use on the revocation (should have been
107  *            created using #GNUNET_REVOCATION_sign_revocation).
108  * @param pow proof of work to use (should have been created by
109  *            iteratively calling #GNUNET_REVOCATION_check_pow)
110  * @param func funtion to call with the result of the check
111  *             (called with `is_valid` being #GNUNET_NO if
112  *              the revocation worked).
113  * @param func_cls closure to pass to @a func
114  * @return handle to use in #GNUNET_REVOCATION_revoke_cancel to stop REVOCATION from invoking the callback
115  */
116 struct GNUNET_REVOCATION_Handle *
117 GNUNET_REVOCATION_revoke(const struct GNUNET_CONFIGURATION_Handle *cfg,
118                          const struct GNUNET_CRYPTO_EcdsaPublicKey *key,
119                          const struct GNUNET_CRYPTO_EcdsaSignature *sig,
120                          uint64_t pow,
121                          GNUNET_REVOCATION_Callback func, void *func_cls);
122
123
124 /**
125  * Cancel key revocation.
126  *
127  * @param h operation to cancel
128  */
129 void
130 GNUNET_REVOCATION_revoke_cancel(struct GNUNET_REVOCATION_Handle *h);
131
132
133 /**
134  * Check if the given proof-of-work value
135  * would be acceptable for revoking the given key.
136  *
137  * @param key key to check for
138  * @param pow proof of work value
139  * @param matching_bits how many bits must match (configuration)
140  * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
141  */
142 int
143 GNUNET_REVOCATION_check_pow(const struct GNUNET_CRYPTO_EcdsaPublicKey *key,
144                             uint64_t pow,
145                             unsigned int matching_bits);
146
147
148 /**
149  * Create a revocation signature.
150  *
151  * @param key private key of the key to revoke
152  * @param sig where to write the revocation signature
153  */
154 void
155 GNUNET_REVOCATION_sign_revocation(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
156                                   struct GNUNET_CRYPTO_EcdsaSignature *sig);
157
158
159 #if 0                           /* keep Emacsens' auto-indent happy */
160 {
161 #endif
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #endif /* GNUNET_REVOCATION_SERVICE_H_ */
167
168 /** @} */ /* end of group revocation */