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_set_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 
136 
137 
144 static struct PeerEntry *
146 {
147  struct PeerEntry *peer_entry;
148 
149  peer_entry = GNUNET_new (struct PeerEntry);
150  peer_entry->id = *peer;
153  &peer_entry->id,
154  peer_entry,
156  return peer_entry;
157 }
158 
159 
167 static int
169 {
170  if (GNUNET_YES !=
172  rm->proof_of_work,
173  (unsigned int) revocation_work_required))
174  {
176  "Proof of work invalid!\n");
177  GNUNET_break_op (0);
178  return GNUNET_NO;
179  }
180  if (GNUNET_OK !=
182  &rm->purpose,
183  &rm->signature,
184  &rm->public_key))
185  {
186  GNUNET_break_op (0);
187  return GNUNET_NO;
188  }
189  return GNUNET_YES;
190 }
191 
192 
201 static void *
202 client_connect_cb (void *cls,
203  struct GNUNET_SERVICE_Client *client,
204  struct GNUNET_MQ_Handle *mq)
205 {
206  return client;
207 }
208 
209 
217 static void
219  struct GNUNET_SERVICE_Client *client,
220  void *app_cls)
221 {
222  GNUNET_assert (client == app_cls);
223 }
224 
225 
232 static void
234  const struct QueryMessage *qm)
235 {
236  struct GNUNET_SERVICE_Client *client = cls;
237  struct GNUNET_MQ_Envelope *env;
238  struct QueryResponseMessage *qrm;
239  struct GNUNET_HashCode hc;
240  int res;
241 
242  GNUNET_CRYPTO_hash (&qm->key,
243  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
244  &hc);
245  res = GNUNET_CONTAINER_multihashmap_contains (revocation_map,
246  &hc);
248  (GNUNET_NO == res)
249  ? "Received revocation check for valid key `%s' from client\n"
250  : "Received revocation check for revoked key `%s' from client\n",
251  GNUNET_h2s (&hc));
252  env = GNUNET_MQ_msg (qrm,
254  qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
256  env);
258 }
259 
260 
269 static int
270 do_flood (void *cls,
271  const struct GNUNET_PeerIdentity *target,
272  void *value)
273 {
274  const struct RevokeMessage *rm = cls;
275  struct PeerEntry *pe = value;
276  struct GNUNET_MQ_Envelope *e;
277  struct RevokeMessage *cp;
278 
279  if (NULL == pe->mq)
280  return GNUNET_OK; /* peer connected to us via SET,
281  but we have no direct CORE
282  connection for flooding */
283  e = GNUNET_MQ_msg (cp,
285  *cp = *rm;
287  "Flooding revocation to `%s'\n",
288  GNUNET_i2s (target));
289  GNUNET_MQ_send (pe->mq,
290  e);
291  return GNUNET_OK;
292 }
293 
294 
304 static int
305 publicize_rm (const struct RevokeMessage *rm)
306 {
307  struct RevokeMessage *cp;
308  struct GNUNET_HashCode hc;
309  struct GNUNET_SET_Element e;
310 
312  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
313  &hc);
314  if (GNUNET_YES ==
316  &hc))
317  {
319  "Duplicate revocation received from peer. Ignored.\n");
320  return GNUNET_OK;
321  }
322  if (GNUNET_OK !=
324  {
325  GNUNET_break_op (0);
326  return GNUNET_SYSERR;
327  }
328  /* write to disk */
329  if (sizeof(struct RevokeMessage) !=
330  GNUNET_DISK_file_write (revocation_db,
331  rm,
332  sizeof(struct RevokeMessage)))
333  {
335  "write");
336  return GNUNET_NO;
337  }
338  if (GNUNET_OK !=
339  GNUNET_DISK_file_sync (revocation_db))
340  {
342  "sync");
343  return GNUNET_NO;
344  }
345  /* keep copy in memory */
346  cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
348  GNUNET_CONTAINER_multihashmap_put (revocation_map,
349  &hc,
350  cp,
352  /* add to set for future connections */
353  e.size = htons (rm->header.size);
355  e.data = rm;
356  if (GNUNET_OK !=
357  GNUNET_SET_add_element (revocation_set,
358  &e,
359  NULL,
360  NULL))
361  {
362  GNUNET_break (0);
363  return GNUNET_OK;
364  }
365  else
366  {
368  "Added revocation info to SET\n");
369  }
370  /* flood to neighbours */
372  &do_flood,
373  cp);
374  return GNUNET_OK;
375 }
376 
377 
384 static void
386  const struct RevokeMessage *rm)
387 {
388  struct GNUNET_SERVICE_Client *client = cls;
389  struct GNUNET_MQ_Envelope *env;
390  struct RevocationResponseMessage *rrm;
391  int ret;
392 
394  "Received REVOKE message from client\n");
395  if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
396  {
397  GNUNET_break_op (0);
399  return;
400  }
401  env = GNUNET_MQ_msg (rrm,
403  rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
405  env);
407 }
408 
409 
416 static void
417 handle_p2p_revoke (void *cls,
418  const struct RevokeMessage *rm)
419 {
421  "Received REVOKE message\n");
423  publicize_rm (rm));
424 }
425 
426 
437 static void
438 add_revocation (void *cls,
439  const struct GNUNET_SET_Element *element,
440  uint64_t current_size,
442 {
443  struct PeerEntry *peer_entry = cls;
444  const struct RevokeMessage *rm;
445 
446  switch (status)
447  {
449  if (element->size != sizeof(struct RevokeMessage))
450  {
451  GNUNET_break_op (0);
452  return;
453  }
455  {
457  gettext_noop (
458  "# unsupported revocations received via set union"),
459  1,
460  GNUNET_NO);
461  return;
462  }
463  rm = element->data;
464  (void) handle_p2p_revoke (NULL,
465  rm);
467  gettext_noop (
468  "# revocation messages received via set union"),
469  1, GNUNET_NO);
470  break;
471 
474  _ ("Error computing revocation set union with %s\n"),
475  GNUNET_i2s (&peer_entry->id));
476  peer_entry->so = NULL;
478  gettext_noop ("# revocation set unions failed"),
479  1,
480  GNUNET_NO);
481  break;
482 
484  break;
485 
487  peer_entry->so = NULL;
489  gettext_noop (
490  "# revocation set unions completed"),
491  1,
492  GNUNET_NO);
493  break;
494 
495  default:
496  GNUNET_break (0);
497  break;
498  }
499 }
500 
501 
508 static void
509 transmit_task_cb (void *cls)
510 {
511  struct PeerEntry *peer_entry = cls;
512 
514  "Starting set exchange with peer `%s'\n",
515  GNUNET_i2s (&peer_entry->id));
516  peer_entry->transmit_task = NULL;
517  GNUNET_assert (NULL == peer_entry->so);
518  peer_entry->so = GNUNET_SET_prepare (&peer_entry->id,
520  NULL,
522  (struct GNUNET_SET_Option[]) { { 0 } },
524  peer_entry);
525  if (GNUNET_OK !=
526  GNUNET_SET_commit (peer_entry->so,
527  revocation_set))
528  {
530  _ ("SET service crashed, terminating revocation service\n"));
532  return;
533  }
534 }
535 
536 
544 static void *
546  const struct GNUNET_PeerIdentity *peer,
547  struct GNUNET_MQ_Handle *mq)
548 {
549  struct PeerEntry *peer_entry;
550  struct GNUNET_HashCode my_hash;
551  struct GNUNET_HashCode peer_hash;
552 
553  if (0 == GNUNET_memcmp (peer,
554  &my_identity))
555  {
556  return NULL;
557  }
558 
560  "Peer `%s' connected to us\n",
561  GNUNET_i2s (peer));
563  "# peers connected",
564  1,
565  GNUNET_NO);
566  peer_entry = GNUNET_CONTAINER_multipeermap_get (peers,
567  peer);
568  if (NULL != peer_entry)
569  {
570  /* This can happen if "core"'s notification is a tad late
571  and CADET+SET were faster and already produced a
572  #handle_revocation_union_request() for us to deal
573  with. This should be rare, but isn't impossible. */
574  peer_entry->mq = mq;
575  return peer_entry;
576  }
577  peer_entry = new_peer_entry (peer);
578  peer_entry->mq = mq;
580  sizeof(my_identity),
581  &my_hash);
582  GNUNET_CRYPTO_hash (peer,
583  sizeof(*peer),
584  &peer_hash);
585  if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
586  &peer_hash))
587  {
589  "Starting SET operation with peer `%s'\n",
590  GNUNET_i2s (peer));
591  peer_entry->transmit_task =
594  peer_entry);
595  }
596  return peer_entry;
597 }
598 
599 
608 static void
610  const struct GNUNET_PeerIdentity *peer,
611  void *internal_cls)
612 {
613  struct PeerEntry *peer_entry = internal_cls;
614 
615  if (0 == GNUNET_memcmp (peer,
616  &my_identity))
617  return;
618  GNUNET_assert (NULL != peer_entry);
620  "Peer `%s' disconnected from us\n",
621  GNUNET_i2s (peer));
624  peer,
625  peer_entry));
626  if (NULL != peer_entry->transmit_task)
627  {
629  peer_entry->transmit_task = NULL;
630  }
631  if (NULL != peer_entry->so)
632  {
633  GNUNET_SET_operation_cancel (peer_entry->so);
634  peer_entry->so = NULL;
635  }
636  GNUNET_free (peer_entry);
638  "# peers connected",
639  -1,
640  GNUNET_NO);
641 }
642 
643 
652 static int
653 free_entry (void *cls,
654  const struct GNUNET_HashCode *key,
655  void *value)
656 {
657  GNUNET_free (value);
658  return GNUNET_OK;
659 }
660 
661 
667 static void
668 shutdown_task (void *cls)
669 {
670  if (NULL != revocation_set)
671  {
672  GNUNET_SET_destroy (revocation_set);
673  revocation_set = NULL;
674  }
675  if (NULL != revocation_union_listen_handle)
676  {
677  GNUNET_SET_listen_cancel (revocation_union_listen_handle);
678  revocation_union_listen_handle = NULL;
679  }
680  if (NULL != core_api)
681  {
682  GNUNET_CORE_disconnect (core_api);
683  core_api = NULL;
684  }
685  if (NULL != stats)
686  {
688  stats = NULL;
689  }
690  if (NULL != peers)
691  {
693  peers = NULL;
694  }
695  if (NULL != revocation_db)
696  {
697  GNUNET_DISK_file_close (revocation_db);
698  revocation_db = NULL;
699  }
701  &free_entry,
702  NULL);
703  GNUNET_CONTAINER_multihashmap_destroy (revocation_map);
704 }
705 
706 
713 static void
714 core_init (void *cls,
715  const struct GNUNET_PeerIdentity *identity)
716 {
717  if (NULL == identity)
718  {
720  "Connection to core FAILED!\n");
722  return;
723  }
725 }
726 
727 
743 static void
745  const struct GNUNET_PeerIdentity *other_peer,
746  const struct GNUNET_MessageHeader *context_msg,
747  struct GNUNET_SET_Request *request)
748 {
749  struct PeerEntry *peer_entry;
750 
751  if (NULL == request)
752  {
753  GNUNET_break (0);
754  return;
755  }
757  "Received set exchange request from peer `%s'\n",
758  GNUNET_i2s (other_peer));
759  peer_entry = GNUNET_CONTAINER_multipeermap_get (peers,
760  other_peer);
761  if (NULL == peer_entry)
762  {
763  peer_entry = new_peer_entry (other_peer);
764  }
765  if (NULL != peer_entry->so)
766  {
767  GNUNET_break_op (0);
768  return;
769  }
770  peer_entry->so = GNUNET_SET_accept (request,
772  (struct GNUNET_SET_Option[]) { { 0 } },
774  peer_entry);
775  if (GNUNET_OK !=
776  GNUNET_SET_commit (peer_entry->so,
777  revocation_set))
778  {
779  GNUNET_break (0);
781  return;
782  }
783 }
784 
785 
793 static void
794 run (void *cls,
795  const struct GNUNET_CONFIGURATION_Handle *c,
797 {
798  struct GNUNET_MQ_MessageHandler core_handlers[] = {
799  GNUNET_MQ_hd_fixed_size (p2p_revoke,
801  struct RevokeMessage,
802  NULL),
804  };
805  char *fn;
806  uint64_t left;
807  struct RevokeMessage *rm;
808  struct GNUNET_HashCode hc;
809 
810  GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
811  strlen ("revocation-set-union-application-id"),
813  if (GNUNET_OK !=
815  "REVOCATION",
816  "DATABASE",
817  &fn))
818  {
820  "REVOCATION",
821  "DATABASE");
823  return;
824  }
825  cfg = c;
826  revocation_map = GNUNET_CONTAINER_multihashmap_create (16,
827  GNUNET_NO);
828  if (GNUNET_OK !=
830  "REVOCATION",
831  "WORKBITS",
833  {
835  "REVOCATION",
836  "WORKBITS");
838  GNUNET_free (fn);
839  return;
840  }
841  if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
842  {
844  "REVOCATION",
845  "WORKBITS",
846  _ ("Value is too large.\n"));
848  GNUNET_free (fn);
849  return;
850  }
851  revocation_set = GNUNET_SET_create (cfg,
853  revocation_union_listen_handle
854  = GNUNET_SET_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?
Client gets only elements that have been added to the set.
static void shutdown_task(void *cls)
Task run during shutdown.
int GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1500
struct GNUNET_SET_ListenHandle * GNUNET_SET_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op_type, const struct GNUNET_HashCode *app_id, GNUNET_SET_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: set_api.c:1017
Create file if it doesn&#39;t exist.
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.
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
struct GNUNET_CRYPTO_EcdsaSignature signature
Signature confirming revocation.
Definition: revocation.h:99
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:1345
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_SET_add_element(struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
Add an element to the given set.
Definition: set_api.c:687
int GNUNET_CRYPTO_ecdsa_verify(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:1046
Context for the core service connection.
Definition: core_api.c:77
Handle for a set operation request from another peer.
Definition: set_api.c:115
Per-peer information.
Handle to a service.
Definition: service.c:116
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:2437
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_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:1300
struct GNUNET_SET_OperationHandle * so
Handle to active set union operation (over revocation sets).
Element stored in a set.
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 GNUNET_SET_Handle * GNUNET_SET_create(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op)
Create an empty set, supporting the specified operation.
Definition: set_api.c:657
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_TIME_UNIT_SECONDS
One second.
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...
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Must have purpose GNUNET_SIGNATURE_PURPOSE_REVOCATION, size expands over the public key...
Definition: revocation.h:105
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.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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.
struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: set_api.c:813
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:36
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:526
Handle for the service.
static int free_entry(void *cls, const struct GNUNET_HashCode *key, void *value)
Free all values in a hash map.
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
Success, all elements have been sent (and received).
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...
const void * data
Actual data of the element.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
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
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: set_api.c:772
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:1253
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
Revoke key.
Definition: revocation.h:79
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:58
The other peer refused to to the operation with us, or something went wrong.
static struct GNUNET_SET_Handle * revocation_set
Set from all revocations known to us.
Success, all elements have been returned (but the other peer might still be receiving some from us...
#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
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set...
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.
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.
GNUNET_SET_Status
Status for the result callback.
messages for key revocation
uint16_t status
See PRISM_STATUS_*-constants.
uint64_t proof_of_work
Number that causes a hash collision with the public_key.
Definition: revocation.h:94
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:2324
Message handler for a specific message type.
static int res
static struct GNUNET_HashCode revocation_set_union_app_id
Our application ID for set union operations.
Opaque handle to a set.
Definition: set_api.c:49
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:68
#define GNUNET_SIGNATURE_PURPOSE_REVOCATION
Signature for confirming a key revocation.
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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_cls)
Handle client connecting to the service.
static void add_revocation(void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
Callback for set operation results.
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_SET_listen_cancel(struct GNUNET_SET_ListenHandle *lh)
Cancel the given listen operation.
Definition: set_api.c:1051
Option for set operations.
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:117
#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.
Handle to an operation.
Definition: set_api.c:135
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE.
Definition: revocation.h:84
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).
int GNUNET_SET_commit(struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
Commit a set to be used with a set operation.
Definition: set_api.c:1128
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:51
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:85
static void handle_revocation_union_request(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
Called when another peer wants to do a set operation with the local peer.
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:294
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.
uint16_t size
Number of bytes in the buffer pointed to by data.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
Open the file for both reading and writing.
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.
Opaque handle to a listen operation.
Definition: set_api.c:186
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static struct GNUNET_SET_ListenHandle * revocation_union_listen_handle
Handle for us listening to incoming revocation set union requests.
void GNUNET_SET_operation_cancel(struct GNUNET_SET_OperationHandle *oh)
Cancel the given set operation.
Definition: set_api.c:516
static struct GNUNET_CORE_Handle * core_api
Handle to the core service (for flooding)
Header for all communications.
struct GNUNET_CRYPTO_EcdsaPublicKey public_key
Key to revoke.
Definition: revocation.h:110
#define GNUNET_YES
Definition: gnunet_common.h:77
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:353
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:128
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.
Set union, return all elements that are in at least one of the sets.
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:1268
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:2243
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t element_type
Application-specific element type.
struct GNUNET_SET_OperationHandle * GNUNET_SET_accept(struct GNUNET_SET_Request *request, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SET_listen().
Definition: set_api.c:1085
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
int GNUNET_REVOCATION_check_pow(const struct GNUNET_CRYPTO_EcdsaPublicKey *key, uint64_t pow, unsigned int matching_bits)
Check if the given proof-of-work value would be acceptable for revoking the given key...
uint32_t reserved
For alignment.
Definition: revocation.h:89
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966