aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_revocation_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_revocation_service.h')
-rw-r--r--src/include/gnunet_revocation_service.h140
1 files changed, 10 insertions, 130 deletions
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h
index 8cff948e2..427be62ac 100644
--- a/src/include/gnunet_revocation_service.h
+++ b/src/include/gnunet_revocation_service.h
@@ -21,9 +21,14 @@
21#ifndef GNUNET_REVOCATION_SERVICE_H_ 21#ifndef GNUNET_REVOCATION_SERVICE_H_
22#define GNUNET_REVOCATION_SERVICE_H_ 22#define GNUNET_REVOCATION_SERVICE_H_
23 23
24
25#include "gnunet_gnsrecord_lib.h"
24#include "gnunet_identity_service.h" 26#include "gnunet_identity_service.h"
25 27
26/** 28/**
29 * @addtogroup egos Ego management
30 * @{
31 *
27 * @author Christian Grothoff 32 * @author Christian Grothoff
28 * 33 *
29 * @file 34 * @file
@@ -52,71 +57,6 @@ extern "C"
52 */ 57 */
53#define GNUNET_REVOCATION_VERSION 0x00000001 58#define GNUNET_REVOCATION_VERSION 0x00000001
54 59
55/**
56 * Maximum length of a revocation
57 */
58#define GNUNET_REVOCATION_MAX_PROOF_SIZE sizeof(struct GNUNET_REVOCATION_PowP) +\
59 sizeof(struct GNUNET_IDENTITY_PublicKey) +\
60 1024 //FIXME max sig_len
61
62/**
63 * The proof-of-work narrowing factor.
64 * The number of PoWs that are calculates as part of revocation.
65 */
66#define POW_COUNT 32
67
68
69GNUNET_NETWORK_STRUCT_BEGIN
70
71/**
72 * Struct for a proof of work as part of the revocation.
73 */
74struct GNUNET_REVOCATION_PowP
75{
76 /**
77 * The timestamp of the revocation
78 */
79 struct GNUNET_TIME_AbsoluteNBO timestamp;
80
81 /**
82 * The TTL of this revocation (purely informational)
83 */
84 struct GNUNET_TIME_RelativeNBO ttl;
85
86 /**
87 * The PoWs
88 */
89 uint64_t pow[POW_COUNT] GNUNET_PACKED;
90
91 /** followed by the public key type, the key and a signature **/
92};
93
94
95/**
96 * The signature object we use for the PoW
97 */
98struct GNUNET_REVOCATION_SignaturePurposePS
99{
100 /**
101 * The signature purpose
102 */
103 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
104
105 /**
106 * The timestamp of the revocation
107 */
108 struct GNUNET_TIME_AbsoluteNBO timestamp;
109
110 /** Followed by the zone public key type and key **/
111};
112
113GNUNET_NETWORK_STRUCT_END
114
115
116/**
117 * Handle to a running proof-of-work calculation.
118 */
119struct GNUNET_REVOCATION_PowCalculationHandle;
120 60
121/** 61/**
122 * Handle for the key revocation query. 62 * Handle for the key revocation query.
@@ -148,7 +88,7 @@ typedef void (*GNUNET_REVOCATION_Callback) (void *cls,
148 */ 88 */
149struct GNUNET_REVOCATION_Query * 89struct GNUNET_REVOCATION_Query *
150GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg, 90GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg,
151 const struct GNUNET_IDENTITY_PublicKey *key, 91 const struct GNUNET_CRYPTO_PublicKey *key,
152 GNUNET_REVOCATION_Callback func, void *func_cls); 92 GNUNET_REVOCATION_Callback func, void *func_cls);
153 93
154 94
@@ -172,7 +112,7 @@ struct GNUNET_REVOCATION_Handle;
172 * 112 *
173 * @param cfg the configuration to use 113 * @param cfg the configuration to use
174 * @param pow proof of work to use (should have been created by 114 * @param pow proof of work to use (should have been created by
175 * iteratively calling #GNUNET_REVOCATION_pow_round) 115 * iteratively calling #GNUNET_CRYPTO_pow_round)
176 * @param func function to call with the result of the check 116 * @param func function to call with the result of the check
177 * (called with `is_valid` being #GNUNET_NO if 117 * (called with `is_valid` being #GNUNET_NO if
178 * the revocation worked). 118 * the revocation worked).
@@ -181,7 +121,7 @@ struct GNUNET_REVOCATION_Handle;
181 */ 121 */
182struct GNUNET_REVOCATION_Handle * 122struct GNUNET_REVOCATION_Handle *
183GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, 123GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
184 const struct GNUNET_REVOCATION_PowP *pow, 124 const struct GNUNET_GNSRECORD_PowP *pow,
185 GNUNET_REVOCATION_Callback func, void *func_cls); 125 GNUNET_REVOCATION_Callback func, void *func_cls);
186 126
187 127
@@ -194,68 +134,6 @@ void
194GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h); 134GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
195 135
196 136
197/**
198 * Check if the given proof-of-work is valid.
199 *
200 * @param pow proof of work
201 * @param matching_bits how many bits must match (configuration)
202 * @param epoch_duration length of single epoch in configuration
203 * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
204 */
205enum GNUNET_GenericReturnValue
206GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
207 unsigned int matching_bits,
208 struct GNUNET_TIME_Relative epoch_duration);
209
210
211/**
212 * Initializes a fresh PoW computation.
213 *
214 * @param key the key to calculate the PoW for.
215 * @param pow the pow object to work with in the calculation.
216 */
217void
218GNUNET_REVOCATION_pow_init (const struct GNUNET_IDENTITY_PrivateKey *key,
219 struct GNUNET_REVOCATION_PowP *pow);
220
221
222/**
223 * Starts a proof-of-work calculation given the pow object as well as
224 * target epochs and difficulty.
225 *
226 * @param pow the PoW to based calculations on.
227 * @param epochs the number of epochs for which the PoW must be valid.
228 * @param difficulty the base difficulty of the PoW.
229 * @return a handle for use in PoW rounds
230 */
231struct GNUNET_REVOCATION_PowCalculationHandle*
232GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_PowP *pow,
233 int epochs,
234 unsigned int difficulty);
235
236
237/**
238 * Calculate a single round in the key revocation PoW.
239 *
240 * @param pc handle to the PoW, initially called with NULL.
241 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
242 */
243enum GNUNET_GenericReturnValue
244GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
245
246
247/**
248 * Stop a PoW calculation
249 *
250 * @param pc the calculation to clean up
251 * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
252 * valid
253 */
254void
255GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
256
257size_t
258GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow);
259 137
260 138
261#if 0 /* keep Emacsens' auto-indent happy */ 139#if 0 /* keep Emacsens' auto-indent happy */
@@ -268,3 +146,5 @@ GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow);
268#endif /* GNUNET_REVOCATION_SERVICE_H_ */ 146#endif /* GNUNET_REVOCATION_SERVICE_H_ */
269 147
270/** @} */ /* end of group revocation */ 148/** @} */ /* end of group revocation */
149
150/** @} */ /* end of group addition */