GNUnet 0.22.2
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 "gnunet_util_lib.h"
41#include "gnunet_dht_block_types.h"
42#include "gnunet_protocols.h"
44#include "gnunet_core_service.h"
45#include "gnunet_setu_service.h"
46#include "revocation.h"
47#include <gcrypt.h>
48
49
53struct PeerEntry
54{
59
64
69
74};
75
76
81
87
91static const struct GNUNET_CONFIGURATION_Handle *cfg;
92
97
102
107
112
117
122
126static unsigned long long revocation_work_required;
127
132
138
139
146static struct PeerEntry *
148{
149 struct PeerEntry *peer_entry;
150
151 peer_entry = GNUNET_new (struct PeerEntry);
152 peer_entry->id = *peer;
155 &peer_entry->id,
156 peer_entry,
158 return peer_entry;
159}
160
161
171{
172 const struct GNUNET_GNSRECORD_PowP *pow
173 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
174
175 if (GNUNET_YES !=
177 (unsigned int) revocation_work_required,
179 {
181 "Proof of work invalid!\n");
182 GNUNET_break_op (0);
183 return GNUNET_NO;
184 }
185 return GNUNET_YES;
186}
187
188
197static void *
199 struct GNUNET_SERVICE_Client *client,
200 struct GNUNET_MQ_Handle *mq)
201{
202 return client;
203}
204
205
213static void
215 struct GNUNET_SERVICE_Client *client,
216 void *app_cls)
217{
218 GNUNET_assert (client == app_cls);
219}
220
221
222static int
224 const struct QueryMessage *qm)
225{
226 uint16_t size;
227
228 size = ntohs (qm->header.size);
229 if (size <= sizeof(struct RevokeMessage) ||
230 (size > UINT16_MAX))
231 {
232 GNUNET_break (0);
233 return GNUNET_SYSERR;
234 }
235 return GNUNET_OK;
236
237}
238
239
246static void
248 const struct QueryMessage *qm)
249{
250 struct GNUNET_SERVICE_Client *client = cls;
251 struct GNUNET_CRYPTO_PublicKey zone;
252 struct GNUNET_MQ_Envelope *env;
253 struct QueryResponseMessage *qrm;
254 struct GNUNET_HashCode hc;
255 int res;
256 size_t key_len;
257 size_t read;
258
259 key_len = ntohl (qm->key_len);
260 if ((GNUNET_SYSERR ==
262 &zone, &read)) ||
263 (read != key_len))
264 {
266 "Unable to parse query public key\n");
268 return;
269 }
270 GNUNET_CRYPTO_hash (&qm[1],
271 key_len,
272 &hc);
274 &hc);
276 (GNUNET_NO == res)
277 ? "Received revocation check for valid key `%s' from client\n"
278 : "Received revocation check for revoked key `%s' from client\n",
279 GNUNET_h2s (&hc));
280 env = GNUNET_MQ_msg (qrm,
282 qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
284 env);
286}
287
288
298do_flood (void *cls,
299 const struct GNUNET_PeerIdentity *target,
300 void *value)
301{
302 const struct RevokeMessage *rm = cls;
303 struct PeerEntry *pe = value;
304 struct GNUNET_MQ_Envelope *e;
305 struct RevokeMessage *cp;
306
307 if (NULL == pe->mq)
308 return GNUNET_OK; /* peer connected to us via SET,
309 but we have no direct CORE
310 connection for flooding */
311 e = GNUNET_MQ_msg_extra (cp,
312 htonl (rm->pow_size),
314 *cp = *rm;
315 memcpy (&cp[1],
316 &rm[1],
317 htonl (rm->pow_size));
319 "Flooding revocation to `%s'\n",
320 GNUNET_i2s (target));
321 GNUNET_MQ_send (pe->mq,
322 e);
323 return GNUNET_OK;
324}
325
326
337publicize_rm (const struct RevokeMessage *rm)
338{
339 struct RevokeMessage *cp;
340 struct GNUNET_HashCode hc;
341 struct GNUNET_SETU_Element e;
342 ssize_t pklen;
343 const struct GNUNET_GNSRECORD_PowP *pow
344 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
345 const struct GNUNET_CRYPTO_PublicKey *pk
346 = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
347
350 if (0 > pklen)
351 {
352 GNUNET_break_op (0);
353 return GNUNET_SYSERR;
354 }
356 pklen,
357 &hc);
358 if (GNUNET_YES ==
360 &hc))
361 {
363 "Duplicate revocation received from peer. Ignored.\n");
364 return GNUNET_OK;
365 }
366 if (GNUNET_OK !=
368 {
369 GNUNET_break_op (0);
370 return GNUNET_SYSERR;
371 }
372 /* write to disk */
373 if (sizeof(struct RevokeMessage) !=
375 rm,
376 sizeof(struct RevokeMessage)))
377 {
379 "write");
380 return GNUNET_NO;
381 }
382 if (GNUNET_OK !=
384 {
386 "sync");
387 return GNUNET_NO;
388 }
389 /* keep copy in memory */
390 cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
393 &hc,
394 cp,
396 /* add to set for future connections */
397 e.size = htons (rm->header.size);
399 e.data = rm;
400 if (GNUNET_OK !=
402 &e,
403 NULL,
404 NULL))
405 {
406 GNUNET_break (0);
407 return GNUNET_OK;
408 }
409 else
410 {
412 "Added revocation info to SET\n");
413 }
414 /* flood to neighbours */
416 &do_flood,
417 cp);
418 return GNUNET_OK;
419}
420
421
422static int
424 const struct RevokeMessage *rm)
425{
426 uint16_t size;
427
428 size = ntohs (rm->header.size);
429 if (size <= sizeof(struct RevokeMessage) ||
430 (size > UINT16_MAX))
431 {
432 GNUNET_break (0);
433 return GNUNET_SYSERR;
434 }
435 return GNUNET_OK;
436
437}
438
439
446static void
448 const struct RevokeMessage *rm)
449{
450 struct GNUNET_SERVICE_Client *client = cls;
451 struct GNUNET_MQ_Envelope *env;
452 struct RevocationResponseMessage *rrm;
453 int ret;
454
456 "Received REVOKE message from client\n");
457 if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
458 {
459 GNUNET_break_op (0);
461 return;
462 }
463 env = GNUNET_MQ_msg (rrm,
465 rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
467 env);
469}
470
471
472static int
474 const struct RevokeMessage *rm)
475{
476 uint16_t size;
477
478 size = ntohs (rm->header.size);
479 if (size <= sizeof(struct RevokeMessage))
480 {
481 GNUNET_break (0);
482 return GNUNET_SYSERR;
483 }
484 return GNUNET_OK;
485
486}
487
488
495static void
497 const struct RevokeMessage *rm)
498{
500 "Received REVOKE message\n");
502 publicize_rm (rm));
503}
504
505
516static void
517add_revocation (void *cls,
518 const struct GNUNET_SETU_Element *element,
519 uint64_t current_size,
521{
522 struct PeerEntry *peer_entry = cls;
523 const struct RevokeMessage *rm;
524
525 switch (status)
526 {
528 if (element->size != sizeof(struct RevokeMessage))
529 {
530 GNUNET_break_op (0);
531 return;
532 }
534 {
537 "# unsupported revocations received via set union"),
538 1,
539 GNUNET_NO);
540 return;
541 }
542 rm = element->data;
543 (void) handle_p2p_revoke (NULL,
544 rm);
547 "# revocation messages received via set union"),
548 1, GNUNET_NO);
549 break;
552 _ ("Error computing revocation set union with %s\n"),
553 GNUNET_i2s (&peer_entry->id));
554 peer_entry->so = NULL;
556 gettext_noop ("# revocation set unions failed"),
557 1,
558 GNUNET_NO);
559 break;
561 peer_entry->so = NULL;
564 "# revocation set unions completed"),
565 1,
566 GNUNET_NO);
567 break;
568 default:
569 GNUNET_break (0);
570 break;
571 }
572}
573
574
581static void
583{
584 struct PeerEntry *peer_entry = cls;
585
587 "Starting set exchange with peer `%s'\n",
588 GNUNET_i2s (&peer_entry->id));
589 peer_entry->transmit_task = NULL;
590 GNUNET_assert (NULL == peer_entry->so);
591 peer_entry->so = GNUNET_SETU_prepare (&peer_entry->id,
593 NULL,
594 (struct GNUNET_SETU_Option[]) { { 0 } },
596 peer_entry);
597 if (GNUNET_OK !=
598 GNUNET_SETU_commit (peer_entry->so,
600 {
602 _ ("SET service crashed, terminating revocation service\n"));
604 return;
605 }
606}
607
608
616static void *
618 const struct GNUNET_PeerIdentity *peer,
619 struct GNUNET_MQ_Handle *mq)
620{
621 struct PeerEntry *peer_entry;
622 struct GNUNET_HashCode my_hash;
623 struct GNUNET_HashCode peer_hash;
624
625 if (0 == GNUNET_memcmp (peer,
626 &my_identity))
627 {
628 return NULL;
629 }
630
632 "Peer `%s' connected to us\n",
633 GNUNET_i2s (peer));
635 "# peers connected",
636 1,
637 GNUNET_NO);
639 peer);
640 if (NULL != peer_entry)
641 {
642 /* This can happen if "core"'s notification is a tad late
643 and CADET+SET were faster and already produced a
644 #handle_revocation_union_request() for us to deal
645 with. This should be rare, but isn't impossible. */
646 peer_entry->mq = mq;
647 return peer_entry;
648 }
649 peer_entry = new_peer_entry (peer);
650 peer_entry->mq = mq;
652 sizeof(my_identity),
653 &my_hash);
654 GNUNET_CRYPTO_hash (peer,
655 sizeof(*peer),
656 &peer_hash);
657 if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
658 &peer_hash))
659 {
661 "Starting SET operation with peer `%s'\n",
662 GNUNET_i2s (peer));
663 peer_entry->transmit_task =
666 peer_entry);
667 }
668 return peer_entry;
669}
670
671
680static void
682 const struct GNUNET_PeerIdentity *peer,
683 void *internal_cls)
684{
685 struct PeerEntry *peer_entry = internal_cls;
686
687 if (0 == GNUNET_memcmp (peer,
688 &my_identity))
689 return;
690 GNUNET_assert (NULL != peer_entry);
692 "Peer `%s' disconnected from us\n",
693 GNUNET_i2s (peer));
696 peer,
697 peer_entry));
698 if (NULL != peer_entry->transmit_task)
699 {
701 peer_entry->transmit_task = NULL;
702 }
703 if (NULL != peer_entry->so)
704 {
705 GNUNET_SETU_operation_cancel (peer_entry->so);
706 peer_entry->so = NULL;
707 }
708 GNUNET_free (peer_entry);
710 "# peers connected",
711 -1,
712 GNUNET_NO);
713}
714
715
724static int
725free_entry (void *cls,
726 const struct GNUNET_HashCode *key,
727 void *value)
728{
730 return GNUNET_OK;
731}
732
733
739static void
740shutdown_task (void *cls)
741{
742 if (NULL != revocation_set)
743 {
745 revocation_set = NULL;
746 }
748 {
751 }
752 if (NULL != core_api)
753 {
755 core_api = NULL;
756 }
757 if (NULL != stats)
758 {
760 stats = NULL;
761 }
762 if (NULL != peers)
763 {
765 peers = NULL;
766 }
767 if (NULL != revocation_db)
768 {
770 revocation_db = NULL;
771 }
773 &free_entry,
774 NULL);
776}
777
778
785static void
786core_init (void *cls,
787 const struct GNUNET_PeerIdentity *identity)
788{
789 if (NULL == identity)
790 {
792 "Connection to core FAILED!\n");
794 return;
795 }
797}
798
799
815static void
817 const struct GNUNET_PeerIdentity *other_peer,
818 const struct GNUNET_MessageHeader *context_msg,
820{
821 struct PeerEntry *peer_entry;
822
823 if (NULL == request)
824 {
825 GNUNET_break (0);
826 return;
827 }
829 "Received set exchange request from peer `%s'\n",
830 GNUNET_i2s (other_peer));
832 other_peer);
833 if (NULL == peer_entry)
834 {
835 peer_entry = new_peer_entry (other_peer);
836 }
837 if (NULL != peer_entry->so)
838 {
839 GNUNET_break_op (0);
840 return;
841 }
842 peer_entry->so = GNUNET_SETU_accept (request,
843 (struct GNUNET_SETU_Option[]) { { 0 } },
845 peer_entry);
846 if (GNUNET_OK !=
847 GNUNET_SETU_commit (peer_entry->so,
849 {
850 GNUNET_break (0);
852 return;
853 }
854}
855
856
864static void
865run (void *cls,
866 const struct GNUNET_CONFIGURATION_Handle *c,
868{
869 struct GNUNET_MQ_MessageHandler core_handlers[] = {
870 GNUNET_MQ_hd_var_size (p2p_revoke,
872 struct RevokeMessage,
873 NULL),
875 };
876 char *fn;
877 uint64_t left;
878 ssize_t ksize;
879 struct RevokeMessage *rm;
880 struct GNUNET_HashCode hc;
882 const struct GNUNET_CRYPTO_PublicKey *pk;
883
884 GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
885 strlen ("revocation-set-union-application-id"),
887 if (GNUNET_OK !=
889 "REVOCATION",
890 "DATABASE",
891 &fn))
892 {
894 "REVOCATION",
895 "DATABASE");
897 return;
898 }
899 cfg = c;
901 GNUNET_NO);
903 NULL);
904 if (GNUNET_OK !=
906 "REVOCATION",
907 "WORKBITS",
909 {
911 "REVOCATION",
912 "WORKBITS");
914 GNUNET_free (fn);
915 return;
916 }
917 if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
918 {
920 "REVOCATION",
921 "WORKBITS",
922 _ ("Value is too large.\n"));
924 GNUNET_free (fn);
925 return;
926 }
927 if (GNUNET_OK !=
929 "REVOCATION",
930 "EPOCH_DURATION",
932 {
934 "REVOCATION",
935 "EPOCH_DURATION");
937 GNUNET_free (fn);
938 return;
939 }
940
946 NULL);
954 if (NULL == revocation_db)
955 {
957 "REVOCATION",
958 "DATABASE",
959 _ ("Could not open revocation database file!"));
961 GNUNET_free (fn);
962 return;
963 }
964 if (GNUNET_OK !=
966 left = 0;
967 while (left > sizeof(struct RevokeMessage))
968 {
969 rm = GNUNET_new (struct RevokeMessage);
970 if (sizeof(struct RevokeMessage) !=
972 rm,
973 sizeof(struct RevokeMessage)))
974 {
976 "read",
977 fn);
978 GNUNET_free (rm);
980 GNUNET_free (fn);
981 return;
982 }
983 pow = (struct GNUNET_GNSRECORD_PowP *) &rm[1];
984 pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
986 if (0 > ksize)
987 {
988 GNUNET_break_op (0);
989 GNUNET_free (rm);
990 GNUNET_free (fn);
991 return;
992 }
994 ksize,
995 &hc);
998 &hc,
999 rm,
1001 }
1002 GNUNET_free (fn);
1003
1005 GNUNET_YES);
1006 /* Connect to core service and register core handlers */
1007 core_api = GNUNET_CORE_connect (cfg, /* Main configuration */
1008 NULL, /* Closure passed to functions */
1009 &core_init, /* Call core_init once connected */
1010 &handle_core_connect, /* Handle connects */
1011 &handle_core_disconnect, /* Handle disconnects */
1012 core_handlers); /* Register these handlers */
1013 if (NULL == core_api)
1014 {
1016 return;
1017 }
1018 stats = GNUNET_STATISTICS_create ("revocation",
1019 cfg);
1020}
1021
1022
1028 "revocation",
1030 &run,
1033 NULL,
1034 GNUNET_MQ_hd_var_size (query_message,
1036 struct QueryMessage,
1037 NULL),
1038 GNUNET_MQ_hd_var_size (revoke_message,
1040 struct RevokeMessage,
1041 NULL),
1043
1044
1045#if defined(__linux__) && defined(__GLIBC__)
1046#include <malloc.h>
1047
1048void
1049GNUNET_REVOCATION_memory_init (void);
1053void __attribute__ ((constructor))
1054GNUNET_REVOCATION_memory_init ()
1055{
1056 mallopt (M_TRIM_THRESHOLD, 4 * 1024);
1057 mallopt (M_TOP_PAD, 1 * 1024);
1058 malloc_trim (0);
1059}
1060
1061
1062#endif
1063
1064
1065/* end of gnunet-service-revocation.c */
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define gettext_noop(String)
Definition: gettext.h:74
static int ret
Final status code.
Definition: gnunet-arm.c:93
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:39
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_SETU_ListenHandle * revocation_union_listen_handle
Handle for us listening to incoming revocation set union requests.
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
static struct GNUNET_DISK_FileHandle * revocation_db
File handle for the revocation database.
static void transmit_task_cb(void *cls)
The timeout for performing the set union has expired, run the set operation on the revocation certifi...
static void core_init(void *cls, const struct GNUNET_PeerIdentity *identity)
Called on core init/fail.
static struct GNUNET_PeerIdentity my_identity
The peer identity of this peer.
static void handle_revoke_message(void *cls, const struct RevokeMessage *rm)
Handle REVOKE message from client.
GNUNET_SERVICE_MAIN(GNUNET_OS_project_data_gnunet(), "revocation", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_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.
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_TIME_Relative epoch_duration
Length of an expiration expoch.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
static int free_entry(void *cls, const struct GNUNET_HashCode *key, void *value)
Free all values in a hash map.
static struct PeerEntry * new_peer_entry(const struct GNUNET_PeerIdentity *peer)
Create a new PeerEntry and add it to the peers multipeermap.
static void * handle_core_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a peer connects.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_cls)
Handle client connecting to the service.
static void shutdown_task(void *cls)
Task run during shutdown.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Handle client connecting to the service.
static int check_revoke_message(void *cls, const struct RevokeMessage *rm)
static void handle_query_message(void *cls, const struct QueryMessage *qm)
Handle QUERY message from client.
static struct GNUNET_CORE_Handle * core_api
Handle to the core service (for flooding)
static struct GNUNET_SETU_Handle * revocation_set
Set from all revocations known to us.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Handle network size estimate clients.
static enum GNUNET_GenericReturnValue publicize_rm(const struct RevokeMessage *rm)
Publicize revocation message.
static int check_p2p_revoke(void *cls, const struct RevokeMessage *rm)
static enum GNUNET_GenericReturnValue do_flood(void *cls, const struct GNUNET_PeerIdentity *target, void *value)
Flood the given revocation message to all neighbours.
static struct GNUNET_HashCode revocation_set_union_app_id
Our application ID for set union operations.
static enum GNUNET_GenericReturnValue verify_revoke_message(const struct RevokeMessage *rm)
An revoke message has been received, check that it is well-formed.
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.
static void handle_core_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
static int check_query_message(void *cls, const struct QueryMessage *qm)
static unsigned long long revocation_work_required
Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits.
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.
static void handle_p2p_revoke(void *cls, const struct RevokeMessage *rm)
Core handler for flooded revocation messages.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
Core service; the main API for encrypted P2P communications.
API that can be used to manipulate GNS record data.
struct GNUNET_PQ_ResultSpec __attribute__
Constants for network protocols.
Two-peer set union operations.
API to create, modify and access statistics.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
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:691
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:729
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:1215
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:682
enum GNUNET_GenericReturnValue 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:222
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1408
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1289
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:646
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_check_pow(const struct GNUNET_GNSRECORD_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
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:218
enum GNUNET_GenericReturnValue 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).
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.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash 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.
enum GNUNET_GenericReturnValue 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.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
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).
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.
enum GNUNET_GenericReturnValue 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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:85
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:102
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#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:61
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY
Client to service: was this key revoked?
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE
Service to client: revocation confirmed.
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
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,...
Definition: scheduler.c:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
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:1277
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2418
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2500
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2389
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
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:384
void GNUNET_SETU_operation_cancel(struct GNUNET_SETU_OperationHandle *oh)
Cancel the given set operation.
Definition: setu_api.c:320
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:497
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: setu_api.c:471
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:769
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:851
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:717
GNUNET_SETU_Status
Status for the result callback.
void GNUNET_SETU_listen_cancel(struct GNUNET_SETU_ListenHandle *lh)
Cancel the given listen operation.
Definition: setu_api.c:749
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:429
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
#define GNUNET_TIME_UNIT_SECONDS
One second.
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
messages for key revocation
@ GNUNET_BLOCK_TYPE_REVOCATION
Block type for a revocation message by which a key is revoked.
Internal representation of the hash map.
Internal representation of the hash map.
Context for the core service connection.
Definition: core_api.c:78
An identity key as per LSD0001.
Handle used to access files (and pipes).
Struct for a proof of work as part of the revocation.
uint64_t pow[32]
The PoWs.
A 512-bit hashcode.
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:136
Handle to a client that is connected to a service.
Definition: service.c:249
Handle to a service.
Definition: service.c:116
Element stored in a set.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
Opaque handle to a set.
Definition: setu_api.c:40
Opaque handle to a listen operation.
Definition: setu_api.c:146
Handle to an operation.
Definition: setu_api.c:95
Option for set operations.
Handle for a set operation request from another peer.
Definition: setu_api.c:75
Handle for the service.
Time for relative time used by GNUnet, in microseconds.
Per-peer information.
Definition: peer.c:34
struct GNUNET_PeerIdentity id
The identifier itself.
Definition: peer.c:38
struct GNUNET_SCHEDULER_Task * transmit_task
Tasked used to trigger the set union operation.
struct GNUNET_SETU_OperationHandle * so
Handle to active set union operation (over revocation sets).
struct GNUNET_MQ_Handle * mq
Queue for sending messages to this peer.
Query key revocation status.
Definition: revocation.h:38
uint32_t key_len
Key length.
Definition: revocation.h:47
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_QUERY.
Definition: revocation.h:42
Key revocation response.
Definition: revocation.h:59
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:68
Key revocation response.
Definition: revocation.h:99
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:109
Revoke key.
Definition: revocation.h:80
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE.
Definition: revocation.h:84
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:89