diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-08-19 14:13:55 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-08-19 14:13:55 +0000 |
commit | d276b7a5610430cc1e5fe24c21a9957a892b6eaa (patch) | |
tree | ea3eee8b0f882ed291d3f68d3a4493e48395299d /src/include | |
parent | 482d0a0e2045302b4ffacebfa1e48178f6bded55 (diff) | |
download | gnunet-d276b7a5610430cc1e5fe24c21a9957a892b6eaa.tar.gz gnunet-d276b7a5610430cc1e5fe24c21a9957a892b6eaa.zip |
sensor: proof-of-work and signing library functions
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_sensor_util_lib.h | 81 | ||||
-rw-r--r-- | src/include/gnunet_signatures.h | 5 |
2 files changed, 81 insertions, 5 deletions
diff --git a/src/include/gnunet_sensor_util_lib.h b/src/include/gnunet_sensor_util_lib.h index 897fbbaad..d1b1a925e 100644 --- a/src/include/gnunet_sensor_util_lib.h +++ b/src/include/gnunet_sensor_util_lib.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file sensor/sensor_util_lib.c | 22 | * @file sensor/sensor_util_lib.c |
23 | * @brief senor utilities | 23 | * @brief sensor utilities |
24 | * @author Omar Tarabai | 24 | * @author Omar Tarabai |
25 | */ | 25 | */ |
26 | 26 | ||
@@ -210,11 +210,10 @@ struct GNUNET_SENSOR_DashboardAnomalyEntry | |||
210 | }; | 210 | }; |
211 | 211 | ||
212 | GNUNET_NETWORK_STRUCT_BEGIN | 212 | GNUNET_NETWORK_STRUCT_BEGIN |
213 | |||
214 | /** | 213 | /** |
215 | * Used to communicate brief information about a sensor. | 214 | * Used to communicate brief information about a sensor. |
216 | */ | 215 | */ |
217 | struct GNUNET_SENSOR_SensorBriefMessage | 216 | struct GNUNET_SENSOR_SensorBriefMessage |
218 | { | 217 | { |
219 | 218 | ||
220 | /** | 219 | /** |
@@ -281,7 +280,7 @@ struct GNUNET_SENSOR_SensorFullMessage | |||
281 | * Used to communicate sensor values to | 280 | * Used to communicate sensor values to |
282 | * collection points (SENSORDASHBAORD service) | 281 | * collection points (SENSORDASHBAORD service) |
283 | */ | 282 | */ |
284 | struct GNUNET_SENSOR_ValueMessage | 283 | struct GNUNET_SENSOR_ValueMessage |
285 | { | 284 | { |
286 | 285 | ||
287 | /** | 286 | /** |
@@ -355,7 +354,6 @@ struct GNUNET_SENSOR_AnomalyReportMessage | |||
355 | }; | 354 | }; |
356 | 355 | ||
357 | GNUNET_NETWORK_STRUCT_END | 356 | GNUNET_NETWORK_STRUCT_END |
358 | |||
359 | /** | 357 | /** |
360 | * Given two version numbers as major and minor, compare them. | 358 | * Given two version numbers as major and minor, compare them. |
361 | * | 359 | * |
@@ -397,6 +395,79 @@ GNUNET_SENSOR_get_default_sensor_dir (); | |||
397 | void | 395 | void |
398 | GNUNET_SENSOR_destroy_sensors (struct GNUNET_CONTAINER_MultiHashMap *sensors); | 396 | GNUNET_SENSOR_destroy_sensors (struct GNUNET_CONTAINER_MultiHashMap *sensors); |
399 | 397 | ||
398 | |||
399 | struct GNUNET_SENSOR_crypto_pow_context; | ||
400 | |||
401 | /** | ||
402 | * Block carrying arbitrary data + its proof-of-work + signature | ||
403 | */ | ||
404 | struct GNUNET_SENSOR_crypto_pow_block | ||
405 | { | ||
406 | |||
407 | /** | ||
408 | * Proof-of-work value | ||
409 | */ | ||
410 | uint64_t pow; | ||
411 | |||
412 | /** | ||
413 | * Data signature | ||
414 | */ | ||
415 | struct GNUNET_CRYPTO_EddsaSignature signature; | ||
416 | |||
417 | /** | ||
418 | * Purpose of signing, data is allocated after this. | ||
419 | */ | ||
420 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
421 | |||
422 | }; | ||
423 | |||
424 | |||
425 | /** | ||
426 | * Continuation called with a status result. | ||
427 | * | ||
428 | * @param cls closure | ||
429 | * @param pow Proof-of-work value | ||
430 | * @param purpose Signed block (size, purpose, data) | ||
431 | * @param signature Signature, NULL on error | ||
432 | */ | ||
433 | typedef void (*GNUNET_SENSOR_UTIL_pow_callback) (void *cls, | ||
434 | struct | ||
435 | GNUNET_SENSOR_crypto_pow_block | ||
436 | * block); | ||
437 | |||
438 | |||
439 | /** | ||
440 | * Cancel an operation started by #GNUNET_SENSOR_crypto_pow_sign(). | ||
441 | * Call only before callback function passed to #GNUNET_SENSOR_crypto_pow_sign() | ||
442 | * is called with the result. | ||
443 | */ | ||
444 | void | ||
445 | GNUNET_SENSOR_crypto_pow_sign_cancel (struct GNUNET_SENSOR_crypto_pow_context | ||
446 | *cx); | ||
447 | |||
448 | |||
449 | /** | ||
450 | * Calculate proof-of-work and sign a message. | ||
451 | * | ||
452 | * @param msg Message to calculate pow and sign | ||
453 | * @param msg_size size of msg | ||
454 | * @param timestamp Timestamp to add to the message to protect against replay attacks | ||
455 | * @param public_key Public key of the origin peer, to protect against redirect attacks | ||
456 | * @param private_key Private key of the origin peer to sign the result | ||
457 | * @param matching_bits Number of leading zeros required in the result hash | ||
458 | * @param callback Callback function to call with the result | ||
459 | * @param callback_cls Closure for callback | ||
460 | * @return Operation context | ||
461 | */ | ||
462 | struct GNUNET_SENSOR_crypto_pow_context * | ||
463 | GNUNET_SENSOR_crypto_pow_sign (void *msg, size_t msg_size, | ||
464 | struct GNUNET_TIME_Absolute *timestamp, | ||
465 | struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | ||
466 | struct GNUNET_CRYPTO_EddsaPrivateKey | ||
467 | *private_key, int matching_bits, | ||
468 | GNUNET_SENSOR_UTIL_pow_callback callback, | ||
469 | void *callback_cls); | ||
470 | |||
400 | #if 0 /* keep Emacsens' auto-indent happy */ | 471 | #if 0 /* keep Emacsens' auto-indent happy */ |
401 | { | 472 | { |
402 | #endif | 473 | #endif |
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h index a2a41a256..5c1abb5ff 100644 --- a/src/include/gnunet_signatures.h +++ b/src/include/gnunet_signatures.h | |||
@@ -171,6 +171,11 @@ extern "C" | |||
171 | */ | 171 | */ |
172 | #define GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST 24 | 172 | #define GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST 24 |
173 | 173 | ||
174 | /** | ||
175 | * Signature for a sensor anomaly report message. | ||
176 | */ | ||
177 | #define GNUNET_SIGNATURE_PURPOSE_SENSOR_ANOMALY_REPORT 25 | ||
178 | |||
174 | 179 | ||
175 | #if 0 /* keep Emacsens' auto-indent happy */ | 180 | #if 0 /* keep Emacsens' auto-indent happy */ |
176 | { | 181 | { |