GNUnet  0.11.x
gnunet-service-revocation.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2013, 2014, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
38 #include "platform.h"
39 #include <math.h>
40 #include "gnunet_util_lib.h"
41 #include "gnunet_block_lib.h"
42 #include "gnunet_constants.h"
43 #include "gnunet_protocols.h"
44 #include "gnunet_signatures.h"
46 #include "gnunet_core_service.h"
48 #include "gnunet_setu_service.h"
49 #include "revocation.h"
50 #include <gcrypt.h>
51 
52 
56 struct PeerEntry
57 {
62 
67 
72 
77 };
78 
79 
84 
90 
94 static const struct GNUNET_CONFIGURATION_Handle *cfg;
95 
100 
105 
110 
115 
120 
125 
129 static unsigned long long revocation_work_required;
130 
135 
141 
142 
149 static struct PeerEntry *
151 {
152  struct PeerEntry *peer_entry;
153 
154  peer_entry = GNUNET_new (struct PeerEntry);
155  peer_entry->id = *peer;
158  &peer_entry->id,
159  peer_entry,
161  return peer_entry;
162 }
163 
164 
172 static int
174 {
176  (unsigned
179  {
181  "Proof of work invalid!\n");
182  GNUNET_break_op (0);
183  return GNUNET_NO;
184  }
185  return GNUNET_YES;
186 }
187 
188 
197 static void *
198 client_connect_cb (void *cls,
199  struct GNUNET_SERVICE_Client *client,
200  struct GNUNET_MQ_Handle *mq)
201 {
202  return client;
203 }
204 
205 
213 static void
215  struct GNUNET_SERVICE_Client *client,
216  void *app_cls)
217 {
218  GNUNET_assert (client == app_cls);
219 }
220 
221 
228 static void
230  const struct QueryMessage *qm)
231 {
232  struct GNUNET_SERVICE_Client *client = cls;
233  struct GNUNET_MQ_Envelope *env;
234  struct QueryResponseMessage *qrm;
235  struct GNUNET_HashCode hc;
236  int res;
237 
238  GNUNET_CRYPTO_hash (&qm->key,
239  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
240  &hc);
241  res = GNUNET_CONTAINER_multihashmap_contains (revocation_map,
242  &hc);
244  (GNUNET_NO == res)
245  ? "Received revocation check for valid key `%s' from client\n"
246  : "Received revocation check for revoked key `%s' from client\n",
247  GNUNET_h2s (&hc));
248  env = GNUNET_MQ_msg (qrm,
250  qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
252  env);
254 }
255 
256 
265 static int
266 do_flood (void *cls,
267  const struct GNUNET_PeerIdentity *target,
268  void *value)
269 {
270  const struct RevokeMessage *rm = cls;
271  struct PeerEntry *pe = value;
272  struct GNUNET_MQ_Envelope *e;
273  struct RevokeMessage *cp;
274 
275  if (NULL == pe->mq)
276  return GNUNET_OK; /* peer connected to us via SET,
277  but we have no direct CORE
278  connection for flooding */
279  e = GNUNET_MQ_msg (cp,
281  *cp = *rm;
283  "Flooding revocation to `%s'\n",
284  GNUNET_i2s (target));
285  GNUNET_MQ_send (pe->mq,
286  e);
287  return GNUNET_OK;
288 }
289 
290 
300 static int
301 publicize_rm (const struct RevokeMessage *rm)
302 {
303  struct RevokeMessage *cp;
304  struct GNUNET_HashCode hc;
305  struct GNUNET_SETU_Element e;
306 
308  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
309  &hc);
310  if (GNUNET_YES ==
312  &hc))
313  {
315  "Duplicate revocation received from peer. Ignored.\n");
316  return GNUNET_OK;
317  }
318  if (GNUNET_OK !=
320  {
321  GNUNET_break_op (0);
322  return GNUNET_SYSERR;
323  }
324  /* write to disk */
325  if (sizeof(struct RevokeMessage) !=
326  GNUNET_DISK_file_write (revocation_db,
327  rm,
328  sizeof(struct RevokeMessage)))
329  {
331  "write");
332  return GNUNET_NO;
333  }
334  if (GNUNET_OK !=
335  GNUNET_DISK_file_sync (revocation_db))
336  {
338  "sync");
339  return GNUNET_NO;
340  }
341  /* keep copy in memory */
342  cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
344  GNUNET_CONTAINER_multihashmap_put (revocation_map,
345  &hc,
346  cp,
348  /* add to set for future connections */
349  e.size = htons (rm->header.size);
351  e.data = rm;
352  if (GNUNET_OK !=
353  GNUNET_SETU_add_element (revocation_set,
354  &e,
355  NULL,
356  NULL))
357  {
358  GNUNET_break (0);
359  return GNUNET_OK;
360  }
361  else
362  {
364  "Added revocation info to SET\n");
365  }
366  /* flood to neighbours */
368  &do_flood,
369  cp);
370  return GNUNET_OK;
371 }
372 
373 
380 static void
382  const struct RevokeMessage *rm)
383 {
384  struct GNUNET_SERVICE_Client *client = cls;
385  struct GNUNET_MQ_Envelope *env;
386  struct RevocationResponseMessage *rrm;
387  int ret;
388 
390  "Received REVOKE message from client\n");
391  if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
392  {
393  GNUNET_break_op (0);
395  return;
396  }
397  env = GNUNET_MQ_msg (rrm,
399  rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
401  env);
403 }
404 
405 
412 static void
413 handle_p2p_revoke (void *cls,
414  const struct RevokeMessage *rm)
415 {
417  "Received REVOKE message\n");
419  publicize_rm (rm));
420 }
421 
422 
433 static void
434 add_revocation (void *cls,
435  const struct GNUNET_SETU_Element *element,
436  uint64_t current_size,
438 {
439  struct PeerEntry *peer_entry = cls;
440  const struct RevokeMessage *rm;
441 
442  switch (status)
443  {
445  if (element->size != sizeof(struct RevokeMessage))
446  {
447  GNUNET_break_op (0);
448  return;
449  }
451  {
453  gettext_noop (
454  "# unsupported revocations received via set union"),
455  1,
456  GNUNET_NO);
457  return;
458  }
459  rm = element->data;
460  (void) handle_p2p_revoke (NULL,
461  rm);
463  gettext_noop (
464  "# revocation messages received via set union"),
465  1, GNUNET_NO);
466  break;
469  _ ("Error computing revocation set union with %s\n"),
470  GNUNET_i2s (&peer_entry->id));
471  peer_entry->so = NULL;
473  gettext_noop ("# revocation set unions failed"),
474  1,
475  GNUNET_NO);
476  break;
478  peer_entry->so = NULL;
480  gettext_noop (
481  "# revocation set unions completed"),
482  1,
483  GNUNET_NO);
484  break;
485  default:
486  GNUNET_break (0);
487  break;
488  }
489 }
490 
491 
498 static void
499 transmit_task_cb (void *cls)
500 {
501  struct PeerEntry *peer_entry = cls;
502 
504  "Starting set exchange with peer `%s'\n",
505  GNUNET_i2s (&peer_entry->id));
506  peer_entry->transmit_task = NULL;
507  GNUNET_assert (NULL == peer_entry->so);
508  peer_entry->so = GNUNET_SETU_prepare (&peer_entry->id,
510  NULL,
511  (struct GNUNET_SETU_Option[]) { { 0 } },
513  peer_entry);
514  if (GNUNET_OK !=
515  GNUNET_SETU_commit (peer_entry->so,
516  revocation_set))
517  {
519  _ ("SET service crashed, terminating revocation service\n"));
521  return;
522  }
523 }
524 
525 
533 static void *
535  const struct GNUNET_PeerIdentity *peer,
536  struct GNUNET_MQ_Handle *mq)
537 {
538  struct PeerEntry *peer_entry;
539  struct GNUNET_HashCode my_hash;
540  struct GNUNET_HashCode peer_hash;
541 
542  if (0 == GNUNET_memcmp (peer,
543  &my_identity))
544  {
545  return NULL;
546  }
547 
549  "Peer `%s' connected to us\n",
550  GNUNET_i2s (peer));
552  "# peers connected",
553  1,
554  GNUNET_NO);
555  peer_entry = GNUNET_CONTAINER_multipeermap_get (peers,
556  peer);
557  if (NULL != peer_entry)
558  {
559  /* This can happen if "core"'s notification is a tad late
560  and CADET+SET were faster and already produced a
561  #handle_revocation_union_request() for us to deal
562  with. This should be rare, but isn't impossible. */
563  peer_entry->mq = mq;
564  return peer_entry;
565  }
566  peer_entry = new_peer_entry (peer);
567  peer_entry->mq = mq;
569  sizeof(my_identity),
570  &my_hash);
571  GNUNET_CRYPTO_hash (peer,
572  sizeof(*peer),
573  &peer_hash);
574  if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
575  &peer_hash))
576  {
578  "Starting SET operation with peer `%s'\n",
579  GNUNET_i2s (peer));
580  peer_entry->transmit_task =
583  peer_entry);
584  }
585  return peer_entry;
586 }
587 
588 
597 static void
599  const struct GNUNET_PeerIdentity *peer,
600  void *internal_cls)
601 {
602  struct PeerEntry *peer_entry = internal_cls;
603 
604  if (0 == GNUNET_memcmp (peer,
605  &my_identity))
606  return;
607  GNUNET_assert (NULL != peer_entry);
609  "Peer `%s' disconnected from us\n",
610  GNUNET_i2s (peer));
613  peer,
614  peer_entry));
615  if (NULL != peer_entry->transmit_task)
616  {
618  peer_entry->transmit_task = NULL;
619  }
620  if (NULL != peer_entry->so)
621  {
622  GNUNET_SETU_operation_cancel (peer_entry->so);
623  peer_entry->so = NULL;
624  }
625  GNUNET_free (peer_entry);
627  "# peers connected",
628  -1,
629  GNUNET_NO);
630 }
631 
632 
641 static int
642 free_entry (void *cls,
643  const struct GNUNET_HashCode *key,
644  void *value)
645 {
646  GNUNET_free (value);
647  return GNUNET_OK;
648 }
649 
650 
656 static void
657 shutdown_task (void *cls)
658 {
659  if (NULL != revocation_set)
660  {
661  GNUNET_SETU_destroy (revocation_set);
662  revocation_set = NULL;
663  }
664  if (NULL != revocation_union_listen_handle)
665  {
666  GNUNET_SETU_listen_cancel (revocation_union_listen_handle);
667  revocation_union_listen_handle = NULL;
668  }
669  if (NULL != core_api)
670  {
671  GNUNET_CORE_disconnect (core_api);
672  core_api = NULL;
673  }
674  if (NULL != stats)
675  {
677  stats = NULL;
678  }
679  if (NULL != peers)
680  {
682  peers = NULL;
683  }
684  if (NULL != revocation_db)
685  {
686  GNUNET_DISK_file_close (revocation_db);
687  revocation_db = NULL;
688  }
690  &free_entry,
691  NULL);
692  GNUNET_CONTAINER_multihashmap_destroy (revocation_map);
693 }
694 
695 
702 static void
703 core_init (void *cls,
704  const struct GNUNET_PeerIdentity *identity)
705 {
706  if (NULL == identity)
707  {
709  "Connection to core FAILED!\n");
711  return;
712  }
714 }
715 
716 
732 static void
734  const struct GNUNET_PeerIdentity *other_peer,
735  const struct GNUNET_MessageHeader *context_msg,
737 {
738  struct PeerEntry *peer_entry;
739 
740  if (NULL == request)
741  {
742  GNUNET_break (0);
743  return;
744  }
746  "Received set exchange request from peer `%s'\n",
747  GNUNET_i2s (other_peer));
748  peer_entry = GNUNET_CONTAINER_multipeermap_get (peers,
749  other_peer);
750  if (NULL == peer_entry)
751  {
752  peer_entry = new_peer_entry (other_peer);
753  }
754  if (NULL != peer_entry->so)
755  {
756  GNUNET_break_op (0);
757  return;
758  }
759  peer_entry->so = GNUNET_SETU_accept (request,
760  (struct GNUNET_SETU_Option[]) { { 0 } },
762  peer_entry);
763  if (GNUNET_OK !=
764  GNUNET_SETU_commit (peer_entry->so,
765  revocation_set))
766  {
767  GNUNET_break (0);
769  return;
770  }
771 }
772 
773 
781 static void
782 run (void *cls,
783  const struct GNUNET_CONFIGURATION_Handle *c,
785 {
786  struct GNUNET_MQ_MessageHandler core_handlers[] = {
787  GNUNET_MQ_hd_fixed_size (p2p_revoke,
789  struct RevokeMessage,
790  NULL),
792  };
793  char *fn;
794  uint64_t left;
795  struct RevokeMessage *rm;
796  struct GNUNET_HashCode hc;
797 
798  GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
799  strlen ("revocation-set-union-application-id"),
801  if (GNUNET_OK !=
803  "REVOCATION",
804  "DATABASE",
805  &fn))
806  {
808  "REVOCATION",
809  "DATABASE");
811  return;
812  }
813  cfg = c;
814  revocation_map = GNUNET_CONTAINER_multihashmap_create (16,
815  GNUNET_NO);
816  if (GNUNET_OK !=
818  "REVOCATION",
819  "WORKBITS",
821  {
823  "REVOCATION",
824  "WORKBITS");
826  GNUNET_free (fn);
827  return;
828  }
829  if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
830  {
832  "REVOCATION",
833  "WORKBITS",
834  _ ("Value is too large.\n"));
836  GNUNET_free (fn);
837  return;
838  }
839  if (GNUNET_OK !=
841  "REVOCATION",
842  "EPOCH_DURATION",
843  &epoch_duration))
844  {
846  "REVOCATION",
847  "EPOCH_DURATION");
849  GNUNET_free (fn);
850  return;
851  }
852 
853  revocation_set = GNUNET_SETU_create (cfg);
854  revocation_union_listen_handle
855  = GNUNET_SETU_listen (cfg,
858  NULL);
859  revocation_db = GNUNET_DISK_file_open (fn,
866  if (NULL == revocation_db)
867  {
869  "REVOCATION",
870  "DATABASE",
871  _ ("Could not open revocation database file!"));
873  GNUNET_free (fn);
874  return;
875  }
876  if (GNUNET_OK !=
878  left = 0;
879  while (left > sizeof(struct RevokeMessage))
880  {
881  rm = GNUNET_new (struct RevokeMessage);
882  if (sizeof(struct RevokeMessage) !=
883  GNUNET_DISK_file_read (revocation_db,
884  rm,
885  sizeof(struct RevokeMessage)))
886  {
888  "read",
889  fn);
890  GNUNET_free (rm);
892  GNUNET_free (fn);
893  return;
894  }
895  GNUNET_break (0 == ntohl (rm->reserved));
897  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
898  &hc);
900  GNUNET_CONTAINER_multihashmap_put (revocation_map,
901  &hc,
902  rm,
904  }
905  GNUNET_free (fn);
906 
908  NULL);
910  GNUNET_YES);
911  /* Connect to core service and register core handlers */
912  core_api = GNUNET_CORE_connect (cfg, /* Main configuration */
913  NULL, /* Closure passed to functions */
914  &core_init, /* Call core_init once connected */
915  &handle_core_connect, /* Handle connects */
916  &handle_core_disconnect, /* Handle disconnects */
917  core_handlers); /* Register these handlers */
918  if (NULL == core_api)
919  {
921  return;
922  }
923  stats = GNUNET_STATISTICS_create ("revocation",
924  cfg);
925 }
926 
927 
932  ("revocation",
934  &run,
937  NULL,
938  GNUNET_MQ_hd_fixed_size (query_message,
940  struct QueryMessage,
941  NULL),
942  GNUNET_MQ_hd_fixed_size (revoke_message,
944  struct RevokeMessage,
945  NULL),
947 
948 
949 #if defined(__linux__) && defined(__GLIBC__)
950 #include <malloc.h>
951 
955 void __attribute__ ((constructor))
956 GNUNET_REVOCATION_memory_init ()
957 {
958  mallopt (M_TRIM_THRESHOLD, 4 * 1024);
959  mallopt (M_TOP_PAD, 1 * 1024);
960  malloc_trim (0);
961 }
962 
963 
964 #endif
965 
966 
967 /* end of gnunet-service-revocation.c */
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY
Client to service: was this key revoked?
struct GNUNET_REVOCATION_PowP proof_of_work
Number that causes a hash collision with the public_key.
Definition: revocation.h:95
static void shutdown_task(void *cls)
Task run during shutdown.
Handle for a set operation request from another peer.
Definition: setu_api.c:73
int GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1433
static struct GNUNET_SETU_ListenHandle * revocation_union_listen_handle
Handle for us listening to incoming revocation set union requests.
Create file if it doesn&#39;t exist.
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: setu_api.c:508
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static int do_flood(void *cls, const struct GNUNET_PeerIdentity *target, void *value)
Flood the given revocation message to all neighbours.
static void handle_p2p_revoke(void *cls, const struct RevokeMessage *rm)
Core handler for flooded revocation messages.
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
static void * handle_core_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a peer connects.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
static void handle_query_message(void *cls, const struct QueryMessage *qm)
Handle QUERY message from client.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1280
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
int GNUNET_SETU_commit(struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set)
Commit a set to be used with a set operation.
Definition: setu_api.c:837
struct GNUNET_CRYPTO_EcdsaPublicKey key
The revoked public key.
Context for the core service connection.
Definition: core_api.c:77
Per-peer information.
Handle to a service.
Definition: service.c:116
const void * data
Actual data of the element.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2436
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:732
static int verify_revoke_message(const struct RevokeMessage *rm)
An revoke message has been received, check that it is well-formed.
struct GNUNET_SETU_OperationHandle * so
Handle to active set union operation (over revocation sets).
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1331
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
Block type for a revocation message by which a key is revoked.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_TIME_UNIT_SECONDS
One second.
Option for set operations.
static struct GNUNET_CONTAINER_MultiHashMap * revocation_map
Hash map with all revoked keys, maps the hash of the public key to the respective struct RevokeMessag...
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
static int publicize_rm(const struct RevokeMessage *rm)
Publicize revocation message.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Handle client connecting to the service.
static struct Experiment * e
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static void core_init(void *cls, const struct GNUNET_PeerIdentity *identity)
Called on core init/fail.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
static struct GNUNET_DISK_FileHandle * revocation_db
File handle for the revocation database.
Query key revocation status.
Definition: revocation.h:37
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
Handle for the service.
static int free_entry(void *cls, const struct GNUNET_HashCode *key, void *value)
Free all values in a hash map.
struct GNUNET_SETU_Handle * GNUNET_SETU_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set, supporting the specified operation.
Definition: setu_api.c:383
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
Opaque handle to a listen operation.
Definition: setu_api.c:144
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
static void transmit_task_cb(void *cls)
The timeout for performing the set union has expired, run the set operation on the revocation certifi...
Handle to a client that is connected to a service.
Definition: service.c:250
static struct GNUNET_PeerIdentity my_identity
The peer identity of this peer.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
The other peer refused to do the operation with us, or something went wrong.
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
GNUNET_SETU_Status
Status for the result callback.
Revoke key.
Definition: revocation.h:80
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
Key revocation response.
Definition: revocation.h:59
Opaque handle to a set.
Definition: setu_api.c:38
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
Success, all elements have been sent (and received).
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:820
GNUNET_SERVICE_MAIN("revocation", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(query_message, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, struct QueryMessage, NULL), GNUNET_MQ_hd_fixed_size(revoke_message, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, struct RevokeMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
uint16_t element_type
Application-specific element type.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE
Service to client: revocation confirmed.
messages for key revocation
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_accept(struct GNUNET_SETU_Request *request, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SETU_listen().
Definition: setu_api.c:774
Element should be added to the result set of the local peer, i.e.
uint16_t status
See PRISM_STATUS_*-constants.
Internal representation of the hash map.
A 512-bit hashcode.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2323
Message handler for a specific message type.
static int res
Handle to an operation.
Definition: setu_api.c:93
static struct GNUNET_HashCode revocation_set_union_app_id
Our application ID for set union operations.
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:69
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_cls)
Handle client connecting to the service.
struct GNUNET_SETU_ListenHandle * GNUNET_SETU_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETU_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: setu_api.c:708
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:692
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:730
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: setu_api.c:470
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Key revocation response.
Definition: revocation.h:102
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
int GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:257
struct GNUNET_MQ_Handle * mq
Queue for sending messages to this peer.
struct GNUNET_SCHEDULER_Task * transmit_task
Tasked used to trigger the set union operation.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE.
Definition: revocation.h:85
Handle to a message queue.
Definition: mq.c:85
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
Everybody can read.
static void handle_revoke_message(void *cls, const struct RevokeMessage *rm)
Handle REVOKE message from client.
enum RadiotapType __attribute__
The identity of the host (wraps the signing key of the peer).
static unsigned long long revocation_work_required
Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits.
struct GNUNET_CRYPTO_EcdsaPublicKey key
Key to check.
Definition: revocation.h:52
static struct PeerEntry * new_peer_entry(const struct GNUNET_PeerIdentity *peer)
Create a new PeerEntry and add it to the peers multipeermap.
configuration data
Definition: configuration.c:84
void GNUNET_SETU_operation_cancel(struct GNUNET_SETU_OperationHandle *oh)
Cancel the given set operation.
Definition: setu_api.c:319
static struct GNUNET_TIME_Relative epoch_duration
Length of an expiration expoch.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:311
static void add_revocation(void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
Callback for set operation results.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
Open the file for both reading and writing.
static void handle_revocation_union_request(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
Called when another peer wants to do a set operation with the local peer.
int GNUNET_SETU_add_element(struct GNUNET_SETU_Handle *set, const struct GNUNET_SETU_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Add an element to the given set.
Definition: setu_api.c:428
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Handle network size estimate clients.
static void handle_core_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_SETU_listen_cancel(struct GNUNET_SETU_ListenHandle *lh)
Cancel the given listen operation.
Definition: setu_api.c:740
static struct GNUNET_CORE_Handle * core_api
Handle to the core service (for flooding)
Header for all communications.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
static struct GNUNET_SETU_Handle * revocation_set
Set from all revocations known to us.
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:113
struct GNUNET_PeerIdentity id
What is the identity of the peer?
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1203
Handle used to access files (and pipes).
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2242
uint16_t size
Number of bytes in the buffer pointed to by data.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_check_pow(const struct GNUNET_REVOCATION_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define gettext_noop(String)
Definition: gettext.h:69
uint32_t reserved
For alignment.
Definition: revocation.h:90
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
Element stored in a set.