GNUnet  0.10.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 {
61 
66 
71 
76 };
77 
78 
83 
89 
93 static const struct GNUNET_CONFIGURATION_Handle *cfg;
94 
99 
104 
109 
114 
119 
124 
128 static unsigned long long revocation_work_required;
129 
135 
136 
143 static struct PeerEntry *
145 {
146  struct PeerEntry *peer_entry;
147 
148  peer_entry = GNUNET_new(struct PeerEntry);
149  peer_entry->id = *peer;
152  &peer_entry->id,
153  peer_entry,
155  return peer_entry;
156 }
157 
158 
166 static int
168 {
169  if (GNUNET_YES !=
171  rm->proof_of_work,
172  (unsigned int)revocation_work_required))
173  {
175  "Proof of work invalid!\n");
176  GNUNET_break_op(0);
177  return GNUNET_NO;
178  }
179  if (GNUNET_OK !=
181  &rm->purpose,
182  &rm->signature,
183  &rm->public_key))
184  {
185  GNUNET_break_op(0);
186  return GNUNET_NO;
187  }
188  return GNUNET_YES;
189 }
190 
191 
200 static void *
202  struct GNUNET_SERVICE_Client *client,
203  struct GNUNET_MQ_Handle *mq)
204 {
205  return client;
206 }
207 
208 
216 static void
218  struct GNUNET_SERVICE_Client *client,
219  void *app_cls)
220 {
221  GNUNET_assert(client == app_cls);
222 }
223 
224 
231 static void
233  const struct QueryMessage *qm)
234 {
235  struct GNUNET_SERVICE_Client *client = cls;
236  struct GNUNET_MQ_Envelope *env;
237  struct QueryResponseMessage *qrm;
238  struct GNUNET_HashCode hc;
239  int res;
240 
241  GNUNET_CRYPTO_hash(&qm->key,
242  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
243  &hc);
244  res = GNUNET_CONTAINER_multihashmap_contains(revocation_map,
245  &hc);
247  (GNUNET_NO == res)
248  ? "Received revocation check for valid key `%s' from client\n"
249  : "Received revocation check for revoked key `%s' from client\n",
250  GNUNET_h2s(&hc));
251  env = GNUNET_MQ_msg(qrm,
253  qrm->is_valid = htonl((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
255  env);
257 }
258 
259 
268 static int
269 do_flood(void *cls,
270  const struct GNUNET_PeerIdentity *target,
271  void *value)
272 {
273  const struct RevokeMessage *rm = cls;
274  struct PeerEntry *pe = value;
275  struct GNUNET_MQ_Envelope *e;
276  struct RevokeMessage *cp;
277 
278  if (NULL == pe->mq)
279  return GNUNET_OK; /* peer connected to us via SET,
280  but we have no direct CORE
281  connection for flooding */
282  e = GNUNET_MQ_msg(cp,
284  *cp = *rm;
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_SET_Element e;
309 
311  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
312  &hc);
313  if (GNUNET_YES ==
315  &hc))
316  {
318  "Duplicate revocation received from peer. Ignored.\n");
319  return GNUNET_OK;
320  }
321  if (GNUNET_OK !=
323  {
324  GNUNET_break_op(0);
325  return GNUNET_SYSERR;
326  }
327  /* write to disk */
328  if (sizeof(struct RevokeMessage) !=
329  GNUNET_DISK_file_write(revocation_db,
330  rm,
331  sizeof(struct RevokeMessage)))
332  {
334  "write");
335  return GNUNET_NO;
336  }
337  if (GNUNET_OK !=
338  GNUNET_DISK_file_sync(revocation_db))
339  {
341  "sync");
342  return GNUNET_NO;
343  }
344  /* keep copy in memory */
345  cp = (struct RevokeMessage *)GNUNET_copy_message(&rm->header);
347  GNUNET_CONTAINER_multihashmap_put(revocation_map,
348  &hc,
349  cp,
351  /* add to set for future connections */
352  e.size = htons(rm->header.size);
354  e.data = rm;
355  if (GNUNET_OK !=
356  GNUNET_SET_add_element(revocation_set,
357  &e,
358  NULL,
359  NULL))
360  {
361  GNUNET_break(0);
362  return GNUNET_OK;
363  }
364  else
365  {
367  "Added revocation info to SET\n");
368  }
369  /* flood to neighbours */
371  &do_flood,
372  cp);
373  return GNUNET_OK;
374 }
375 
376 
383 static void
385  const struct RevokeMessage *rm)
386 {
387  struct GNUNET_SERVICE_Client *client = cls;
388  struct GNUNET_MQ_Envelope *env;
389  struct RevocationResponseMessage *rrm;
390  int ret;
391 
393  "Received REVOKE message from client\n");
394  if (GNUNET_SYSERR == (ret = publicize_rm(rm)))
395  {
396  GNUNET_break_op(0);
398  return;
399  }
400  env = GNUNET_MQ_msg(rrm,
402  rrm->is_valid = htonl((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
404  env);
406 }
407 
408 
415 static void
417  const struct RevokeMessage *rm)
418 {
420  "Received REVOKE message\n");
422  publicize_rm(rm));
423 }
424 
425 
436 static void
437 add_revocation(void *cls,
438  const struct GNUNET_SET_Element *element,
439  uint64_t current_size,
441 {
442  struct PeerEntry *peer_entry = cls;
443  const struct RevokeMessage *rm;
444 
445  switch (status)
446  {
448  if (element->size != sizeof(struct RevokeMessage))
449  {
450  GNUNET_break_op(0);
451  return;
452  }
454  {
456  gettext_noop("# unsupported revocations received via set union"),
457  1,
458  GNUNET_NO);
459  return;
460  }
461  rm = element->data;
462  (void)handle_p2p_revoke(NULL,
463  rm);
465  gettext_noop("# revocation messages received via set union"),
466  1, GNUNET_NO);
467  break;
468 
471  _("Error computing revocation set union with %s\n"),
472  GNUNET_i2s(&peer_entry->id));
473  peer_entry->so = NULL;
475  gettext_noop("# revocation set unions failed"),
476  1,
477  GNUNET_NO);
478  break;
479 
481  break;
482 
484  peer_entry->so = NULL;
486  gettext_noop("# revocation set unions completed"),
487  1,
488  GNUNET_NO);
489  break;
490 
491  default:
492  GNUNET_break(0);
493  break;
494  }
495 }
496 
497 
504 static void
506 {
507  struct PeerEntry *peer_entry = cls;
508 
510  "Starting set exchange with peer `%s'\n",
511  GNUNET_i2s(&peer_entry->id));
512  peer_entry->transmit_task = NULL;
513  GNUNET_assert(NULL == peer_entry->so);
514  peer_entry->so = GNUNET_SET_prepare(&peer_entry->id,
516  NULL,
518  (struct GNUNET_SET_Option[]) { { 0 } },
520  peer_entry);
521  if (GNUNET_OK !=
522  GNUNET_SET_commit(peer_entry->so,
523  revocation_set))
524  {
526  _("SET service crashed, terminating revocation service\n"));
528  return;
529  }
530 }
531 
532 
540 static void *
542  const struct GNUNET_PeerIdentity *peer,
543  struct GNUNET_MQ_Handle *mq)
544 {
545  struct PeerEntry *peer_entry;
546  struct GNUNET_HashCode my_hash;
547  struct GNUNET_HashCode peer_hash;
548 
549  if (0 == GNUNET_memcmp(peer,
550  &my_identity))
551  {
552  return NULL;
553  }
554 
556  "Peer `%s' connected to us\n",
557  GNUNET_i2s(peer));
559  "# peers connected",
560  1,
561  GNUNET_NO);
562  peer_entry = GNUNET_CONTAINER_multipeermap_get(peers,
563  peer);
564  if (NULL != peer_entry)
565  {
566  /* This can happen if "core"'s notification is a tad late
567  and CADET+SET were faster and already produced a
568  #handle_revocation_union_request() for us to deal
569  with. This should be rare, but isn't impossible. */
570  peer_entry->mq = mq;
571  return peer_entry;
572  }
573  peer_entry = new_peer_entry(peer);
574  peer_entry->mq = mq;
576  sizeof(my_identity),
577  &my_hash);
578  GNUNET_CRYPTO_hash(peer,
579  sizeof(*peer),
580  &peer_hash);
581  if (0 < GNUNET_CRYPTO_hash_cmp(&my_hash,
582  &peer_hash))
583  {
585  "Starting SET operation with peer `%s'\n",
586  GNUNET_i2s(peer));
587  peer_entry->transmit_task =
590  peer_entry);
591  }
592  return peer_entry;
593 }
594 
595 
604 static void
606  const struct GNUNET_PeerIdentity *peer,
607  void *internal_cls)
608 {
609  struct PeerEntry *peer_entry = internal_cls;
610 
611  if (0 == GNUNET_memcmp(peer,
612  &my_identity))
613  return;
614  GNUNET_assert(NULL != peer_entry);
616  "Peer `%s' disconnected from us\n",
617  GNUNET_i2s(peer));
620  peer,
621  peer_entry));
622  if (NULL != peer_entry->transmit_task)
623  {
625  peer_entry->transmit_task = NULL;
626  }
627  if (NULL != peer_entry->so)
628  {
629  GNUNET_SET_operation_cancel(peer_entry->so);
630  peer_entry->so = NULL;
631  }
632  GNUNET_free(peer_entry);
634  "# peers connected",
635  -1,
636  GNUNET_NO);
637 }
638 
639 
648 static int
649 free_entry(void *cls,
650  const struct GNUNET_HashCode *key,
651  void *value)
652 {
653  GNUNET_free(value);
654  return GNUNET_OK;
655 }
656 
657 
663 static void
664 shutdown_task(void *cls)
665 {
666  if (NULL != revocation_set)
667  {
668  GNUNET_SET_destroy(revocation_set);
669  revocation_set = NULL;
670  }
671  if (NULL != revocation_union_listen_handle)
672  {
673  GNUNET_SET_listen_cancel(revocation_union_listen_handle);
674  revocation_union_listen_handle = NULL;
675  }
676  if (NULL != core_api)
677  {
678  GNUNET_CORE_disconnect(core_api);
679  core_api = NULL;
680  }
681  if (NULL != stats)
682  {
684  stats = NULL;
685  }
686  if (NULL != peers)
687  {
689  peers = NULL;
690  }
691  if (NULL != revocation_db)
692  {
693  GNUNET_DISK_file_close(revocation_db);
694  revocation_db = NULL;
695  }
697  &free_entry,
698  NULL);
700 }
701 
702 
709 static void
710 core_init(void *cls,
711  const struct GNUNET_PeerIdentity *identity)
712 {
713  if (NULL == identity)
714  {
716  "Connection to core FAILED!\n");
718  return;
719  }
721 }
722 
723 
739 static void
741  const struct GNUNET_PeerIdentity *other_peer,
742  const struct GNUNET_MessageHeader *context_msg,
743  struct GNUNET_SET_Request *request)
744 {
745  struct PeerEntry *peer_entry;
746 
747  if (NULL == request)
748  {
749  GNUNET_break(0);
750  return;
751  }
753  "Received set exchange request from peer `%s'\n",
754  GNUNET_i2s(other_peer));
755  peer_entry = GNUNET_CONTAINER_multipeermap_get(peers,
756  other_peer);
757  if (NULL == peer_entry)
758  {
759  peer_entry = new_peer_entry(other_peer);
760  }
761  if (NULL != peer_entry->so)
762  {
763  GNUNET_break_op(0);
764  return;
765  }
766  peer_entry->so = GNUNET_SET_accept(request,
768  (struct GNUNET_SET_Option[]) { { 0 } },
770  peer_entry);
771  if (GNUNET_OK !=
772  GNUNET_SET_commit(peer_entry->so,
773  revocation_set))
774  {
775  GNUNET_break(0);
777  return;
778  }
779 }
780 
781 
789 static void
790 run(void *cls,
791  const struct GNUNET_CONFIGURATION_Handle *c,
793 {
794  struct GNUNET_MQ_MessageHandler core_handlers[] = {
795  GNUNET_MQ_hd_fixed_size(p2p_revoke,
797  struct RevokeMessage,
798  NULL),
800  };
801  char *fn;
802  uint64_t left;
803  struct RevokeMessage *rm;
804  struct GNUNET_HashCode hc;
805 
806  GNUNET_CRYPTO_hash("revocation-set-union-application-id",
807  strlen("revocation-set-union-application-id"),
809  if (GNUNET_OK !=
811  "REVOCATION",
812  "DATABASE",
813  &fn))
814  {
816  "REVOCATION",
817  "DATABASE");
819  return;
820  }
821  cfg = c;
822  revocation_map = GNUNET_CONTAINER_multihashmap_create(16,
823  GNUNET_NO);
824  if (GNUNET_OK !=
826  "REVOCATION",
827  "WORKBITS",
829  {
831  "REVOCATION",
832  "WORKBITS");
834  GNUNET_free(fn);
835  return;
836  }
837  if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
838  {
840  "REVOCATION",
841  "WORKBITS",
842  _("Value is too large.\n"));
844  GNUNET_free(fn);
845  return;
846  }
847  revocation_set = GNUNET_SET_create(cfg,
849  revocation_union_listen_handle
850  = GNUNET_SET_listen(cfg,
854  NULL);
855  revocation_db = GNUNET_DISK_file_open(fn,
861  if (NULL == revocation_db)
862  {
864  "REVOCATION",
865  "DATABASE",
866  _("Could not open revocation database file!"));
868  GNUNET_free(fn);
869  return;
870  }
871  if (GNUNET_OK !=
873  left = 0;
874  while (left > sizeof(struct RevokeMessage))
875  {
876  rm = GNUNET_new(struct RevokeMessage);
877  if (sizeof(struct RevokeMessage) !=
878  GNUNET_DISK_file_read(revocation_db,
879  rm,
880  sizeof(struct RevokeMessage)))
881  {
883  "read",
884  fn);
885  GNUNET_free(rm);
887  GNUNET_free(fn);
888  return;
889  }
890  GNUNET_break(0 == ntohl(rm->reserved));
892  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
893  &hc);
895  GNUNET_CONTAINER_multihashmap_put(revocation_map,
896  &hc,
897  rm,
899  }
900  GNUNET_free(fn);
901 
903  NULL);
905  GNUNET_YES);
906  /* Connect to core service and register core handlers */
907  core_api = GNUNET_CORE_connect(cfg, /* Main configuration */
908  NULL, /* Closure passed to functions */
909  &core_init, /* Call core_init once connected */
910  &handle_core_connect, /* Handle connects */
911  &handle_core_disconnect, /* Handle disconnects */
912  core_handlers); /* Register these handlers */
913  if (NULL == core_api)
914  {
916  return;
917  }
918  stats = GNUNET_STATISTICS_create("revocation",
919  cfg);
920 }
921 
922 
927  ("revocation",
929  &run,
932  NULL,
933  GNUNET_MQ_hd_fixed_size(query_message,
935  struct QueryMessage,
936  NULL),
937  GNUNET_MQ_hd_fixed_size(revoke_message,
939  struct RevokeMessage,
940  NULL),
942 
943 
944 #if defined(LINUX) && defined(__GLIBC__)
945 #include <malloc.h>
946 
950 void __attribute__ ((constructor))
951 GNUNET_REVOCATION_memory_init()
952 {
953  mallopt(M_TRIM_THRESHOLD, 4 * 1024);
954  mallopt(M_TOP_PAD, 1 * 1024);
955  malloc_trim(0);
956 }
957 
958 #endif
959 
960 
961 /* 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:1492
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:1012
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:96
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:1339
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:682
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:1048
Context for the core service connection.
Definition: core_api.c:76
Handle for a set operation request from another peer.
Definition: set_api.c:113
Per-peer information.
Handle to a service.
Definition: service.c:114
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:2424
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:729
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:1284
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:652
#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:102
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.
#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:808
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:517
static int ret
Final status code.
Definition: gnunet-arm.c:89
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:246
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: set_api.c:767
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:1237
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
Revoke key.
Definition: revocation.h:77
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:57
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:44
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:817
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:91
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:2315
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:48
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:66
#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:690
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:728
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:1046
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:114
#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:254
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:132
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE.
Definition: revocation.h:81
Handle to a message queue.
Definition: mq.c:84
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:1123
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:50
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:83
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:278
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:131
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:182
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:511
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:107
#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:351
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:124
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:1262
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:2234
#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:1080
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:86
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956