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 {
175  struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1];
177  (unsigned
180  {
182  "Proof of work invalid!\n");
183  GNUNET_break_op (0);
184  return GNUNET_NO;
185  }
186  return GNUNET_YES;
187 }
188 
189 
198 static void *
199 client_connect_cb (void *cls,
200  struct GNUNET_SERVICE_Client *client,
201  struct GNUNET_MQ_Handle *mq)
202 {
203  return client;
204 }
205 
206 
214 static void
216  struct GNUNET_SERVICE_Client *client,
217  void *app_cls)
218 {
219  GNUNET_assert (client == app_cls);
220 }
221 
222 
229 static void
231  const struct QueryMessage *qm)
232 {
233  struct GNUNET_SERVICE_Client *client = cls;
234  struct GNUNET_MQ_Envelope *env;
235  struct QueryResponseMessage *qrm;
236  struct GNUNET_HashCode hc;
237  int res;
238 
239  GNUNET_CRYPTO_hash (&qm->key,
240  sizeof(struct GNUNET_IDENTITY_PublicKey),
241  &hc);
242  res = GNUNET_CONTAINER_multihashmap_contains (revocation_map,
243  &hc);
245  (GNUNET_NO == res)
246  ? "Received revocation check for valid key `%s' from client\n"
247  : "Received revocation check for revoked key `%s' from client\n",
248  GNUNET_h2s (&hc));
249  env = GNUNET_MQ_msg (qrm,
251  qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
253  env);
255 }
256 
257 
266 static int
267 do_flood (void *cls,
268  const struct GNUNET_PeerIdentity *target,
269  void *value)
270 {
271  const struct RevokeMessage *rm = cls;
272  struct PeerEntry *pe = value;
273  struct GNUNET_MQ_Envelope *e;
274  struct RevokeMessage *cp;
275 
276  if (NULL == pe->mq)
277  return GNUNET_OK; /* peer connected to us via SET,
278  but we have no direct CORE
279  connection for flooding */
280  e = GNUNET_MQ_msg_extra (cp,
281  htonl (rm->pow_size),
283  *cp = *rm;
284  memcpy (&cp[1], &rm[1], htonl (rm->pow_size));
286  "Flooding revocation to `%s'\n",
287  GNUNET_i2s (target));
288  GNUNET_MQ_send (pe->mq,
289  e);
290  return GNUNET_OK;
291 }
292 
293 
303 static int
304 publicize_rm (const struct RevokeMessage *rm)
305 {
306  struct RevokeMessage *cp;
307  struct GNUNET_HashCode hc;
308  struct GNUNET_SETU_Element e;
309  const struct GNUNET_IDENTITY_PublicKey *pk;
310 
311  struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1];
312  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
313  GNUNET_CRYPTO_hash (pk,
315  &hc);
316  if (GNUNET_YES ==
318  &hc))
319  {
321  "Duplicate revocation received from peer. Ignored.\n");
322  return GNUNET_OK;
323  }
324  if (GNUNET_OK !=
326  {
327  GNUNET_break_op (0);
328  return GNUNET_SYSERR;
329  }
330  /* write to disk */
331  if (sizeof(struct RevokeMessage) !=
332  GNUNET_DISK_file_write (revocation_db,
333  rm,
334  sizeof(struct RevokeMessage)))
335  {
337  "write");
338  return GNUNET_NO;
339  }
340  if (GNUNET_OK !=
341  GNUNET_DISK_file_sync (revocation_db))
342  {
344  "sync");
345  return GNUNET_NO;
346  }
347  /* keep copy in memory */
348  cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
350  GNUNET_CONTAINER_multihashmap_put (revocation_map,
351  &hc,
352  cp,
354  /* add to set for future connections */
355  e.size = htons (rm->header.size);
357  e.data = rm;
358  if (GNUNET_OK !=
359  GNUNET_SETU_add_element (revocation_set,
360  &e,
361  NULL,
362  NULL))
363  {
364  GNUNET_break (0);
365  return GNUNET_OK;
366  }
367  else
368  {
370  "Added revocation info to SET\n");
371  }
372  /* flood to neighbours */
374  &do_flood,
375  cp);
376  return GNUNET_OK;
377 }
378 
379 
380 static int
382  const struct RevokeMessage *rm)
383 {
384  uint16_t size;
385 
386  size = ntohs (rm->header.size);
387  if (size <= sizeof(struct RevokeMessage))
388  {
389  GNUNET_break (0);
390  return GNUNET_SYSERR;
391  }
392  return GNUNET_OK;
393 
394 }
395 
396 
403 static void
405  const struct RevokeMessage *rm)
406 {
407  struct GNUNET_SERVICE_Client *client = cls;
408  struct GNUNET_MQ_Envelope *env;
409  struct RevocationResponseMessage *rrm;
410  int ret;
411 
413  "Received REVOKE message from client\n");
414  if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
415  {
416  GNUNET_break_op (0);
418  return;
419  }
420  env = GNUNET_MQ_msg (rrm,
422  rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
424  env);
426 }
427 
428 
429 static int
430 check_p2p_revoke (void *cls,
431  const struct RevokeMessage *rm)
432 {
433  uint16_t size;
434 
435  size = ntohs (rm->header.size);
436  if (size <= sizeof(struct RevokeMessage))
437  {
438  GNUNET_break (0);
439  return GNUNET_SYSERR;
440  }
441  return GNUNET_OK;
442 
443 }
444 
445 
452 static void
453 handle_p2p_revoke (void *cls,
454  const struct RevokeMessage *rm)
455 {
457  "Received REVOKE message\n");
459  publicize_rm (rm));
460 }
461 
462 
473 static void
474 add_revocation (void *cls,
475  const struct GNUNET_SETU_Element *element,
476  uint64_t current_size,
478 {
479  struct PeerEntry *peer_entry = cls;
480  const struct RevokeMessage *rm;
481 
482  switch (status)
483  {
485  if (element->size != sizeof(struct RevokeMessage))
486  {
487  GNUNET_break_op (0);
488  return;
489  }
491  {
493  gettext_noop (
494  "# unsupported revocations received via set union"),
495  1,
496  GNUNET_NO);
497  return;
498  }
499  rm = element->data;
500  (void) handle_p2p_revoke (NULL,
501  rm);
503  gettext_noop (
504  "# revocation messages received via set union"),
505  1, GNUNET_NO);
506  break;
509  _ ("Error computing revocation set union with %s\n"),
510  GNUNET_i2s (&peer_entry->id));
511  peer_entry->so = NULL;
513  gettext_noop ("# revocation set unions failed"),
514  1,
515  GNUNET_NO);
516  break;
518  peer_entry->so = NULL;
520  gettext_noop (
521  "# revocation set unions completed"),
522  1,
523  GNUNET_NO);
524  break;
525  default:
526  GNUNET_break (0);
527  break;
528  }
529 }
530 
531 
538 static void
539 transmit_task_cb (void *cls)
540 {
541  struct PeerEntry *peer_entry = cls;
542 
544  "Starting set exchange with peer `%s'\n",
545  GNUNET_i2s (&peer_entry->id));
546  peer_entry->transmit_task = NULL;
547  GNUNET_assert (NULL == peer_entry->so);
548  peer_entry->so = GNUNET_SETU_prepare (&peer_entry->id,
550  NULL,
551  (struct GNUNET_SETU_Option[]) { { 0 } },
553  peer_entry);
554  if (GNUNET_OK !=
555  GNUNET_SETU_commit (peer_entry->so,
556  revocation_set))
557  {
559  _ ("SET service crashed, terminating revocation service\n"));
561  return;
562  }
563 }
564 
565 
573 static void *
575  const struct GNUNET_PeerIdentity *peer,
576  struct GNUNET_MQ_Handle *mq)
577 {
578  struct PeerEntry *peer_entry;
579  struct GNUNET_HashCode my_hash;
580  struct GNUNET_HashCode peer_hash;
581 
582  if (0 == GNUNET_memcmp (peer,
583  &my_identity))
584  {
585  return NULL;
586  }
587 
589  "Peer `%s' connected to us\n",
590  GNUNET_i2s (peer));
592  "# peers connected",
593  1,
594  GNUNET_NO);
595  peer_entry = GNUNET_CONTAINER_multipeermap_get (peers,
596  peer);
597  if (NULL != peer_entry)
598  {
599  /* This can happen if "core"'s notification is a tad late
600  and CADET+SET were faster and already produced a
601  #handle_revocation_union_request() for us to deal
602  with. This should be rare, but isn't impossible. */
603  peer_entry->mq = mq;
604  return peer_entry;
605  }
606  peer_entry = new_peer_entry (peer);
607  peer_entry->mq = mq;
609  sizeof(my_identity),
610  &my_hash);
611  GNUNET_CRYPTO_hash (peer,
612  sizeof(*peer),
613  &peer_hash);
614  if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
615  &peer_hash))
616  {
618  "Starting SET operation with peer `%s'\n",
619  GNUNET_i2s (peer));
620  peer_entry->transmit_task =
623  peer_entry);
624  }
625  return peer_entry;
626 }
627 
628 
637 static void
639  const struct GNUNET_PeerIdentity *peer,
640  void *internal_cls)
641 {
642  struct PeerEntry *peer_entry = internal_cls;
643 
644  if (0 == GNUNET_memcmp (peer,
645  &my_identity))
646  return;
647  GNUNET_assert (NULL != peer_entry);
649  "Peer `%s' disconnected from us\n",
650  GNUNET_i2s (peer));
653  peer,
654  peer_entry));
655  if (NULL != peer_entry->transmit_task)
656  {
658  peer_entry->transmit_task = NULL;
659  }
660  if (NULL != peer_entry->so)
661  {
662  GNUNET_SETU_operation_cancel (peer_entry->so);
663  peer_entry->so = NULL;
664  }
665  GNUNET_free (peer_entry);
667  "# peers connected",
668  -1,
669  GNUNET_NO);
670 }
671 
672 
681 static int
682 free_entry (void *cls,
683  const struct GNUNET_HashCode *key,
684  void *value)
685 {
686  GNUNET_free (value);
687  return GNUNET_OK;
688 }
689 
690 
696 static void
697 shutdown_task (void *cls)
698 {
699  if (NULL != revocation_set)
700  {
701  GNUNET_SETU_destroy (revocation_set);
702  revocation_set = NULL;
703  }
704  if (NULL != revocation_union_listen_handle)
705  {
706  GNUNET_SETU_listen_cancel (revocation_union_listen_handle);
707  revocation_union_listen_handle = NULL;
708  }
709  if (NULL != core_api)
710  {
711  GNUNET_CORE_disconnect (core_api);
712  core_api = NULL;
713  }
714  if (NULL != stats)
715  {
717  stats = NULL;
718  }
719  if (NULL != peers)
720  {
722  peers = NULL;
723  }
724  if (NULL != revocation_db)
725  {
726  GNUNET_DISK_file_close (revocation_db);
727  revocation_db = NULL;
728  }
730  &free_entry,
731  NULL);
732  GNUNET_CONTAINER_multihashmap_destroy (revocation_map);
733 }
734 
735 
742 static void
743 core_init (void *cls,
744  const struct GNUNET_PeerIdentity *identity)
745 {
746  if (NULL == identity)
747  {
749  "Connection to core FAILED!\n");
751  return;
752  }
754 }
755 
756 
772 static void
774  const struct GNUNET_PeerIdentity *other_peer,
775  const struct GNUNET_MessageHeader *context_msg,
777 {
778  struct PeerEntry *peer_entry;
779 
780  if (NULL == request)
781  {
782  GNUNET_break (0);
783  return;
784  }
786  "Received set exchange request from peer `%s'\n",
787  GNUNET_i2s (other_peer));
788  peer_entry = GNUNET_CONTAINER_multipeermap_get (peers,
789  other_peer);
790  if (NULL == peer_entry)
791  {
792  peer_entry = new_peer_entry (other_peer);
793  }
794  if (NULL != peer_entry->so)
795  {
796  GNUNET_break_op (0);
797  return;
798  }
799  peer_entry->so = GNUNET_SETU_accept (request,
800  (struct GNUNET_SETU_Option[]) { { 0 } },
802  peer_entry);
803  if (GNUNET_OK !=
804  GNUNET_SETU_commit (peer_entry->so,
805  revocation_set))
806  {
807  GNUNET_break (0);
809  return;
810  }
811 }
812 
813 
821 static void
822 run (void *cls,
823  const struct GNUNET_CONFIGURATION_Handle *c,
825 {
826  struct GNUNET_MQ_MessageHandler core_handlers[] = {
827  GNUNET_MQ_hd_var_size (p2p_revoke,
829  struct RevokeMessage,
830  NULL),
832  };
833  char *fn;
834  uint64_t left;
835  struct RevokeMessage *rm;
836  struct GNUNET_HashCode hc;
837  const struct GNUNET_IDENTITY_PublicKey *pk;
838 
839  GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
840  strlen ("revocation-set-union-application-id"),
842  if (GNUNET_OK !=
844  "REVOCATION",
845  "DATABASE",
846  &fn))
847  {
849  "REVOCATION",
850  "DATABASE");
852  return;
853  }
854  cfg = c;
855  revocation_map = GNUNET_CONTAINER_multihashmap_create (16,
856  GNUNET_NO);
857  if (GNUNET_OK !=
859  "REVOCATION",
860  "WORKBITS",
862  {
864  "REVOCATION",
865  "WORKBITS");
867  GNUNET_free (fn);
868  return;
869  }
870  if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
871  {
873  "REVOCATION",
874  "WORKBITS",
875  _ ("Value is too large.\n"));
877  GNUNET_free (fn);
878  return;
879  }
880  if (GNUNET_OK !=
882  "REVOCATION",
883  "EPOCH_DURATION",
884  &epoch_duration))
885  {
887  "REVOCATION",
888  "EPOCH_DURATION");
890  GNUNET_free (fn);
891  return;
892  }
893 
894  revocation_set = GNUNET_SETU_create (cfg);
895  revocation_union_listen_handle
896  = GNUNET_SETU_listen (cfg,
899  NULL);
900  revocation_db = GNUNET_DISK_file_open (fn,
907  if (NULL == revocation_db)
908  {
910  "REVOCATION",
911  "DATABASE",
912  _ ("Could not open revocation database file!"));
914  GNUNET_free (fn);
915  return;
916  }
917  if (GNUNET_OK !=
919  left = 0;
920  while (left > sizeof(struct RevokeMessage))
921  {
922  rm = GNUNET_new (struct RevokeMessage);
923  if (sizeof(struct RevokeMessage) !=
924  GNUNET_DISK_file_read (revocation_db,
925  rm,
926  sizeof(struct RevokeMessage)))
927  {
929  "read",
930  fn);
931  GNUNET_free (rm);
933  GNUNET_free (fn);
934  return;
935  }
936  struct GNUNET_REVOCATION_PowP *pow = (struct
937  GNUNET_REVOCATION_PowP *) &rm[1];
938  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
939  GNUNET_CRYPTO_hash (pk,
941  &hc);
943  GNUNET_CONTAINER_multihashmap_put (revocation_map,
944  &hc,
945  rm,
947  }
948  GNUNET_free (fn);
949 
951  NULL);
953  GNUNET_YES);
954  /* Connect to core service and register core handlers */
955  core_api = GNUNET_CORE_connect (cfg, /* Main configuration */
956  NULL, /* Closure passed to functions */
957  &core_init, /* Call core_init once connected */
958  &handle_core_connect, /* Handle connects */
959  &handle_core_disconnect, /* Handle disconnects */
960  core_handlers); /* Register these handlers */
961  if (NULL == core_api)
962  {
964  return;
965  }
966  stats = GNUNET_STATISTICS_create ("revocation",
967  cfg);
968 }
969 
970 
975  ("revocation",
977  &run,
980  NULL,
981  GNUNET_MQ_hd_fixed_size (query_message,
983  struct QueryMessage,
984  NULL),
985  GNUNET_MQ_hd_var_size (revoke_message,
987  struct RevokeMessage,
988  NULL),
990 
991 
992 #if defined(__linux__) && defined(__GLIBC__)
993 #include <malloc.h>
994 
998 void __attribute__ ((constructor))
999 GNUNET_REVOCATION_memory_init ()
1000 {
1001  mallopt (M_TRIM_THRESHOLD, 4 * 1024);
1002  mallopt (M_TOP_PAD, 1 * 1024);
1003  malloc_trim (0);
1004 }
1005 
1006 
1007 #endif
1008 
1009 
1010 /* end of gnunet-service-revocation.c */
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY
Client to service: was this key revoked?
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
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:2438
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.
Struct for a proof of work as part of the revocation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_TIME_UNIT_SECONDS
One second.
Option for set operations.
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:976
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)...
struct GNUNET_IDENTITY_PublicKey key
Key to check.
Definition: revocation.h:52
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.
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:90
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...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
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...
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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
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:2325
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.
uint64_t pow[32]
The PoWs.
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 unsigned int size
Size of the "table".
Definition: peer.c:67
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:99
#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.
An identity key as per LSD0001.
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
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
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.
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)
static int check_revoke_message(void *cls, const struct RevokeMessage *rm)
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_var_size(revoke_message, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, struct RevokeMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
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:110
static int check_p2p_revoke(void *cls, const struct RevokeMessage *rm)
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:2244
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
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.