-implement microphone library
[oweals/gnunet.git] / src / include / gnunet_revocation_service.h
1 /*
2       This file is part of GNUnet
3       (C) 2013 Christian Grothoff (and other contributing authors)
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public Licerevocation as published
7       by the Free Software Foundation; either version 3, or (at your
8       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       General Public Licerevocation for more details.
14
15       You should have received a copy of the GNU General Public Licerevocation
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef GNUNET_REVOCATION_SERVICE_H_
22 #define GNUNET_REVOCATION_SERVICE_H_
23
24 /**
25  * @file include/gnunet_revocation_service.h
26  * @brief API to perform and access key revocations
27  * @author Christian Grothoff
28  * @defgroup revocation key revocation service
29  * @{
30  */
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0                           /* keep Emacsens' auto-indent happy */
36 }
37 #endif
38 #endif
39
40 #include "gnunet_util_lib.h"
41
42 /**
43  * Version of the key revocation API.
44  */
45 #define GNUNET_REVOCATION_VERSION 0x00000000
46
47 /**
48  * Handle for the key revocation query.
49  */
50 struct GNUNET_REVOCATION_Query;
51
52 /**
53  * Callback to call with the result of a key revocation query.
54  *
55  * @param cls closure
56  * @param is_valid #GNUNET_NO of the key is/was revoked, 
57  *                 #GNUNET_YES if the key is still valid
58  *
59  */
60 typedef void (*GNUNET_REVOCATION_Callback) (void *cls,
61                                             int is_valid);
62
63
64 /**
65  * Check if a key was revoked.
66  *
67  * @param cfg the configuration to use
68  * @param key key to check for revocation
69  * @param func funtion to call with the result of the check
70  * @param func_cls closure to pass to @a func
71  * @return handle to use in #GNUNET_REVOCATION_query_cancel to stop REVOCATION from invoking the callback
72  */
73 struct GNUNET_REVOCATION_Query *
74 GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg,
75                          const struct GNUNET_CRYPTO_EccPublicSignKey *key,
76                          GNUNET_REVOCATION_Callback func, void *func_cls);
77
78
79 /**
80  * Cancel key revocation check.
81  *
82  * @param q query to cancel
83  */
84 void
85 GNUNET_REVOCATION_query_cancel (struct GNUNET_REVOCATION_Query *q);
86
87
88 /**
89  * Handle for the key revocation operation.
90  */
91 struct GNUNET_REVOCATION_Handle;
92
93
94 /**
95  * Perform key revocation.
96  *
97  * @param cfg the configuration to use
98  * @param key public key of the key to revoke
99  * @param sig signature to use on the revocation (should have been
100  *            created using #GNUNET_REVOCATION_sign_revocation).
101  * @param pow proof of work to use (should have been created by
102  *            iteratively calling #GNUNET_REVOCATION_check_pow)
103  * @param func funtion to call with the result of the check
104  *             (called with `is_valid` being #GNUNET_NO if
105  *              the revocation worked).
106  * @param func_cls closure to pass to @a func
107  * @return handle to use in #GNUNET_REVOCATION_cancel to stop REVOCATION from invoking the callback
108  */
109 struct GNUNET_REVOCATION_Handle *
110 GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
111                           const struct GNUNET_CRYPTO_EccPublicSignKey *key,
112                           const struct GNUNET_CRYPTO_EccSignature *sig,
113                           uint64_t pow,
114                           GNUNET_REVOCATION_Callback func, void *func_cls);
115
116
117 /**
118  * Cancel key revocation.
119  *
120  * @param h operation to cancel
121  */
122 void
123 GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
124
125
126 /**
127  * Check if the given proof-of-work value
128  * would be acceptable for revoking the given key.
129  *
130  * @param key key to check for
131  * @param pow proof of work value
132  * @param matching_bits how many bits must match (configuration)
133  * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
134  */
135 int
136 GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EccPublicSignKey *key,
137                              uint64_t pow,
138                              unsigned int matching_bits);
139
140
141 /**
142  * Create a revocation signature.
143  *
144  * @param key private key of the key to revoke
145  * @param sig where to write the revocation signature
146  */
147 void
148 GNUNET_REVOCATION_sign_revocation (const struct GNUNET_CRYPTO_EccPrivateKey *key,
149                                    struct GNUNET_CRYPTO_EccSignature *sig);
150
151
152 #if 0                           /* keep Emacsens' auto-indent happy */
153 {
154 #endif
155 #ifdef __cplusplus
156 }
157 #endif
158
159 /** @} */ /* end of group revocation */
160
161 #endif /* GNUNET_REVOCATION_SERVICE_H_ */