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.h132
1 files changed, 3 insertions, 129 deletions
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h
index de5eedbb9..427be62ac 100644
--- a/src/include/gnunet_revocation_service.h
+++ b/src/include/gnunet_revocation_service.h
@@ -22,6 +22,7 @@
22#define GNUNET_REVOCATION_SERVICE_H_ 22#define GNUNET_REVOCATION_SERVICE_H_
23 23
24 24
25#include "gnunet_gnsrecord_lib.h"
25#include "gnunet_identity_service.h" 26#include "gnunet_identity_service.h"
26 27
27/** 28/**
@@ -56,71 +57,6 @@ extern "C"
56 */ 57 */
57#define GNUNET_REVOCATION_VERSION 0x00000001 58#define GNUNET_REVOCATION_VERSION 0x00000001
58 59
59/**
60 * Maximum length of a revocation
61 */
62#define GNUNET_REVOCATION_MAX_PROOF_SIZE sizeof(struct GNUNET_REVOCATION_PowP) +\
63 sizeof(struct GNUNET_CRYPTO_PublicKey) +\
64 1024 //FIXME max sig_len
65
66/**
67 * The proof-of-work narrowing factor.
68 * The number of PoWs that are calculates as part of revocation.
69 */
70#define POW_COUNT 32
71
72
73GNUNET_NETWORK_STRUCT_BEGIN
74
75/**
76 * Struct for a proof of work as part of the revocation.
77 */
78struct GNUNET_REVOCATION_PowP
79{
80 /**
81 * The timestamp of the revocation
82 */
83 struct GNUNET_TIME_AbsoluteNBO timestamp;
84
85 /**
86 * The TTL of this revocation (purely informational)
87 */
88 struct GNUNET_TIME_RelativeNBO ttl;
89
90 /**
91 * The PoWs
92 */
93 uint64_t pow[POW_COUNT] GNUNET_PACKED;
94
95 /** followed by the public key type, the key and a signature **/
96};
97
98
99/**
100 * The signature object we use for the PoW
101 */
102struct GNUNET_REVOCATION_SignaturePurposePS
103{
104 /**
105 * The signature purpose
106 */
107 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
108
109 /**
110 * The timestamp of the revocation
111 */
112 struct GNUNET_TIME_AbsoluteNBO timestamp;
113
114 /** Followed by the zone public key type and key **/
115};
116
117GNUNET_NETWORK_STRUCT_END
118
119
120/**
121 * Handle to a running proof-of-work calculation.
122 */
123struct GNUNET_REVOCATION_PowCalculationHandle;
124 60
125/** 61/**
126 * Handle for the key revocation query. 62 * Handle for the key revocation query.
@@ -176,7 +112,7 @@ struct GNUNET_REVOCATION_Handle;
176 * 112 *
177 * @param cfg the configuration to use 113 * @param cfg the configuration to use
178 * @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
179 * iteratively calling #GNUNET_REVOCATION_pow_round) 115 * iteratively calling #GNUNET_CRYPTO_pow_round)
180 * @param func function to call with the result of the check 116 * @param func function to call with the result of the check
181 * (called with `is_valid` being #GNUNET_NO if 117 * (called with `is_valid` being #GNUNET_NO if
182 * the revocation worked). 118 * the revocation worked).
@@ -185,7 +121,7 @@ struct GNUNET_REVOCATION_Handle;
185 */ 121 */
186struct GNUNET_REVOCATION_Handle * 122struct GNUNET_REVOCATION_Handle *
187GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, 123GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
188 const struct GNUNET_REVOCATION_PowP *pow, 124 const struct GNUNET_GNSRECORD_PowP *pow,
189 GNUNET_REVOCATION_Callback func, void *func_cls); 125 GNUNET_REVOCATION_Callback func, void *func_cls);
190 126
191 127
@@ -198,68 +134,6 @@ void
198GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h); 134GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
199 135
200 136
201/**
202 * Check if the given proof-of-work is valid.
203 *
204 * @param pow proof of work
205 * @param matching_bits how many bits must match (configuration)
206 * @param epoch_duration length of single epoch in configuration
207 * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
208 */
209enum GNUNET_GenericReturnValue
210GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
211 unsigned int matching_bits,
212 struct GNUNET_TIME_Relative epoch_duration);
213
214
215/**
216 * Initializes a fresh PoW computation.
217 *
218 * @param key the key to calculate the PoW for.
219 * @param pow the pow object to work with in the calculation.
220 */
221void
222GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key,
223 struct GNUNET_REVOCATION_PowP *pow);
224
225
226/**
227 * Starts a proof-of-work calculation given the pow object as well as
228 * target epochs and difficulty.
229 *
230 * @param pow the PoW to based calculations on.
231 * @param epochs the number of epochs for which the PoW must be valid.
232 * @param difficulty the base difficulty of the PoW.
233 * @return a handle for use in PoW rounds
234 */
235struct GNUNET_REVOCATION_PowCalculationHandle*
236GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_PowP *pow,
237 int epochs,
238 unsigned int difficulty);
239
240
241/**
242 * Calculate a single round in the key revocation PoW.
243 *
244 * @param pc handle to the PoW, initially called with NULL.
245 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
246 */
247enum GNUNET_GenericReturnValue
248GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
249
250
251/**
252 * Stop a PoW calculation
253 *
254 * @param pc the calculation to clean up
255 * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
256 * valid
257 */
258void
259GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
260
261size_t
262GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow);
263 137
264 138
265#if 0 /* keep Emacsens' auto-indent happy */ 139#if 0 /* keep Emacsens' auto-indent happy */