diff options
Diffstat (limited to 'src/include/gnunet_secretsharing_service.h')
-rw-r--r-- | src/include/gnunet_secretsharing_service.h | 92 |
1 files changed, 56 insertions, 36 deletions
diff --git a/src/include/gnunet_secretsharing_service.h b/src/include/gnunet_secretsharing_service.h index 40c98b857..9bacee06e 100644 --- a/src/include/gnunet_secretsharing_service.h +++ b/src/include/gnunet_secretsharing_service.h | |||
@@ -119,7 +119,8 @@ struct GNUNET_SECRETSHARING_DecryptionHandle; | |||
119 | /** | 119 | /** |
120 | * Public key of a group sharing a secret. | 120 | * Public key of a group sharing a secret. |
121 | */ | 121 | */ |
122 | struct GNUNET_SECRETSHARING_PublicKey { | 122 | struct GNUNET_SECRETSHARING_PublicKey |
123 | { | ||
123 | uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)]; | 124 | uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)]; |
124 | }; | 125 | }; |
125 | 126 | ||
@@ -127,7 +128,8 @@ struct GNUNET_SECRETSHARING_PublicKey { | |||
127 | /** | 128 | /** |
128 | * Encrypted field element. | 129 | * Encrypted field element. |
129 | */ | 130 | */ |
130 | struct GNUNET_SECRETSHARING_Ciphertext { | 131 | struct GNUNET_SECRETSHARING_Ciphertext |
132 | { | ||
131 | uint32_t c1_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)]; | 133 | uint32_t c1_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)]; |
132 | uint32_t c2_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)]; | 134 | uint32_t c2_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)]; |
133 | }; | 135 | }; |
@@ -139,7 +141,8 @@ struct GNUNET_SECRETSHARING_Ciphertext { | |||
139 | * Note that we are not operating in GF(2^n), thus not every | 141 | * Note that we are not operating in GF(2^n), thus not every |
140 | * bit pattern is a valid plain text. | 142 | * bit pattern is a valid plain text. |
141 | */ | 143 | */ |
142 | struct GNUNET_SECRETSHARING_Plaintext { | 144 | struct GNUNET_SECRETSHARING_Plaintext |
145 | { | ||
143 | /** | 146 | /** |
144 | * Value of the message. | 147 | * Value of the message. |
145 | */ | 148 | */ |
@@ -167,10 +170,14 @@ struct GNUNET_SECRETSHARING_Plaintext { | |||
167 | */ | 170 | */ |
168 | typedef void | 171 | typedef void |
169 | (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, | 172 | (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, |
170 | struct GNUNET_SECRETSHARING_Share *my_share, | 173 | struct GNUNET_SECRETSHARING_Share * |
171 | struct GNUNET_SECRETSHARING_PublicKey *public_key, | 174 | my_share, |
175 | struct | ||
176 | GNUNET_SECRETSHARING_PublicKey * | ||
177 | public_key, | ||
172 | unsigned int num_ready_peers, | 178 | unsigned int num_ready_peers, |
173 | const struct GNUNET_PeerIdentity *ready_peers); | 179 | const struct |
180 | GNUNET_PeerIdentity *ready_peers); | ||
174 | 181 | ||
175 | 182 | ||
176 | /** | 183 | /** |
@@ -182,7 +189,9 @@ typedef void | |||
182 | */ | 189 | */ |
183 | typedef void | 190 | typedef void |
184 | (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, | 191 | (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, |
185 | const struct GNUNET_SECRETSHARING_Plaintext *plaintext); | 192 | const struct |
193 | GNUNET_SECRETSHARING_Plaintext * | ||
194 | plaintext); | ||
186 | 195 | ||
187 | 196 | ||
188 | /** | 197 | /** |
@@ -202,15 +211,16 @@ typedef void | |||
202 | * @param cls closure for @a cb | 211 | * @param cls closure for @a cb |
203 | */ | 212 | */ |
204 | struct GNUNET_SECRETSHARING_Session * | 213 | struct GNUNET_SECRETSHARING_Session * |
205 | GNUNET_SECRETSHARING_create_session(const struct GNUNET_CONFIGURATION_Handle *cfg, | 214 | GNUNET_SECRETSHARING_create_session (const struct |
206 | unsigned int num_peers, | 215 | GNUNET_CONFIGURATION_Handle *cfg, |
207 | const struct GNUNET_PeerIdentity *peers, | 216 | unsigned int num_peers, |
208 | const struct GNUNET_HashCode *session_id, | 217 | const struct GNUNET_PeerIdentity *peers, |
209 | struct GNUNET_TIME_Absolute start, | 218 | const struct GNUNET_HashCode *session_id, |
210 | struct GNUNET_TIME_Absolute deadline, | 219 | struct GNUNET_TIME_Absolute start, |
211 | unsigned int threshold, | 220 | struct GNUNET_TIME_Absolute deadline, |
212 | GNUNET_SECRETSHARING_SecretReadyCallback cb, | 221 | unsigned int threshold, |
213 | void *cls); | 222 | GNUNET_SECRETSHARING_SecretReadyCallback cb, |
223 | void *cls); | ||
214 | 224 | ||
215 | 225 | ||
216 | /** | 226 | /** |
@@ -220,7 +230,7 @@ GNUNET_SECRETSHARING_create_session(const struct GNUNET_CONFIGURATION_Handle *cf | |||
220 | * @param s session to destroy | 230 | * @param s session to destroy |
221 | */ | 231 | */ |
222 | void | 232 | void |
223 | GNUNET_SECRETSHARING_session_destroy(struct GNUNET_SECRETSHARING_Session *s); | 233 | GNUNET_SECRETSHARING_session_destroy (struct GNUNET_SECRETSHARING_Session *s); |
224 | 234 | ||
225 | 235 | ||
226 | /** | 236 | /** |
@@ -237,9 +247,12 @@ GNUNET_SECRETSHARING_session_destroy(struct GNUNET_SECRETSHARING_Session *s); | |||
237 | * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid (invalid range) | 247 | * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid (invalid range) |
238 | */ | 248 | */ |
239 | int | 249 | int |
240 | GNUNET_SECRETSHARING_encrypt(const struct GNUNET_SECRETSHARING_PublicKey *public_key, | 250 | GNUNET_SECRETSHARING_encrypt (const struct |
241 | const struct GNUNET_SECRETSHARING_Plaintext *plaintext, | 251 | GNUNET_SECRETSHARING_PublicKey *public_key, |
242 | struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext); | 252 | const struct |
253 | GNUNET_SECRETSHARING_Plaintext *plaintext, | ||
254 | struct GNUNET_SECRETSHARING_Ciphertext * | ||
255 | result_ciphertext); | ||
243 | 256 | ||
244 | 257 | ||
245 | /** | 258 | /** |
@@ -259,13 +272,14 @@ GNUNET_SECRETSHARING_encrypt(const struct GNUNET_SECRETSHARING_PublicKey *public | |||
259 | * @return handle to cancel the operation | 272 | * @return handle to cancel the operation |
260 | */ | 273 | */ |
261 | struct GNUNET_SECRETSHARING_DecryptionHandle * | 274 | struct GNUNET_SECRETSHARING_DecryptionHandle * |
262 | GNUNET_SECRETSHARING_decrypt(const struct GNUNET_CONFIGURATION_Handle *cfg, | 275 | GNUNET_SECRETSHARING_decrypt (const struct GNUNET_CONFIGURATION_Handle *cfg, |
263 | struct GNUNET_SECRETSHARING_Share *share, | 276 | struct GNUNET_SECRETSHARING_Share *share, |
264 | const struct GNUNET_SECRETSHARING_Ciphertext *ciphertext, | 277 | const struct |
265 | struct GNUNET_TIME_Absolute start, | 278 | GNUNET_SECRETSHARING_Ciphertext *ciphertext, |
266 | struct GNUNET_TIME_Absolute deadline, | 279 | struct GNUNET_TIME_Absolute start, |
267 | GNUNET_SECRETSHARING_DecryptCallback decrypt_cb, | 280 | struct GNUNET_TIME_Absolute deadline, |
268 | void *decrypt_cb_cls); | 281 | GNUNET_SECRETSHARING_DecryptCallback decrypt_cb, |
282 | void *decrypt_cb_cls); | ||
269 | 283 | ||
270 | 284 | ||
271 | /** | 285 | /** |
@@ -277,7 +291,8 @@ GNUNET_SECRETSHARING_decrypt(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
277 | * @param dh to cancel | 291 | * @param dh to cancel |
278 | */ | 292 | */ |
279 | void | 293 | void |
280 | GNUNET_SECRETSHARING_decrypt_cancel(struct GNUNET_SECRETSHARING_DecryptionHandle *dh); | 294 | GNUNET_SECRETSHARING_decrypt_cancel (struct |
295 | GNUNET_SECRETSHARING_DecryptionHandle *dh); | ||
281 | 296 | ||
282 | 297 | ||
283 | /** | 298 | /** |
@@ -290,7 +305,7 @@ GNUNET_SECRETSHARING_decrypt_cancel(struct GNUNET_SECRETSHARING_DecryptionHandle | |||
290 | * @return The share, or NULL on error. | 305 | * @return The share, or NULL on error. |
291 | */ | 306 | */ |
292 | struct GNUNET_SECRETSHARING_Share * | 307 | struct GNUNET_SECRETSHARING_Share * |
293 | GNUNET_SECRETSHARING_share_read(const void *data, size_t len, size_t *readlen); | 308 | GNUNET_SECRETSHARING_share_read (const void *data, size_t len, size_t *readlen); |
294 | 309 | ||
295 | 310 | ||
296 | /** | 311 | /** |
@@ -305,21 +320,26 @@ GNUNET_SECRETSHARING_share_read(const void *data, size_t len, size_t *readlen); | |||
305 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure. | 320 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure. |
306 | */ | 321 | */ |
307 | int | 322 | int |
308 | GNUNET_SECRETSHARING_share_write(const struct GNUNET_SECRETSHARING_Share *share, | 323 | GNUNET_SECRETSHARING_share_write (const struct |
309 | void *buf, size_t buflen, size_t *writelen); | 324 | GNUNET_SECRETSHARING_Share *share, |
325 | void *buf, size_t buflen, size_t *writelen); | ||
310 | 326 | ||
311 | 327 | ||
312 | void | 328 | void |
313 | GNUNET_SECRETSHARING_share_destroy(struct GNUNET_SECRETSHARING_Share *share); | 329 | GNUNET_SECRETSHARING_share_destroy (struct GNUNET_SECRETSHARING_Share *share); |
314 | 330 | ||
315 | 331 | ||
316 | int | 332 | int |
317 | GNUNET_SECRETSHARING_plaintext_generate(struct GNUNET_SECRETSHARING_Plaintext *plaintext, | 333 | GNUNET_SECRETSHARING_plaintext_generate (struct |
318 | gcry_mpi_t exponent); | 334 | GNUNET_SECRETSHARING_Plaintext * |
335 | plaintext, | ||
336 | gcry_mpi_t exponent); | ||
319 | 337 | ||
320 | int | 338 | int |
321 | GNUNET_SECRETSHARING_plaintext_generate_i(struct GNUNET_SECRETSHARING_Plaintext *plaintext, | 339 | GNUNET_SECRETSHARING_plaintext_generate_i (struct |
322 | int64_t exponent); | 340 | GNUNET_SECRETSHARING_Plaintext * |
341 | plaintext, | ||
342 | int64_t exponent); | ||
323 | 343 | ||
324 | 344 | ||
325 | #if 0 /* keep Emacsens' auto-indent happy */ | 345 | #if 0 /* keep Emacsens' auto-indent happy */ |