GNUnet 0.29.1-21-g8c89d4373
 
Loading...
Searching...
No Matches
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, 2026 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 "gnunet_common.h"
39#include "gnunet_pils_service.h"
40#include "platform.h"
41#include "gnunet_util_lib.h"
44#include "gnunet_protocols.h"
46#include "gnunet_core_service.h"
47#include "gnunet_setu_service.h"
48#include "revocation.h"
49#include <gcrypt.h>
50
51
55struct PeerEntry
56{
61
66
71
76};
77
78
83
88static struct GNUNET_CONTAINER_MultiHashMap *revocation_map;
89
93static const struct GNUNET_CONFIGURATION_Handle *cfg;
94
99
104
108static struct GNUNET_CONTAINER_MultiPeerMap *peers;
109
114
119
124
128static unsigned long long revocation_work_required;
129
134
140
141
148static struct PeerEntry *
150{
151 struct PeerEntry *peer_entry;
152
153 peer_entry = GNUNET_new (struct PeerEntry);
154 peer_entry->id = *peer;
157 &peer_entry->id,
158 peer_entry,
160 return peer_entry;
161}
162
163
173{
174 const struct GNUNET_GNSRECORD_PowP *pow
175 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
176
177 if (GNUNET_YES !=
179 (unsigned int) revocation_work_required,
181 {
183 "Proof of work invalid!\n");
184 GNUNET_break_op (0);
185 return GNUNET_NO;
186 }
187 return GNUNET_YES;
188}
189
190
199static void *
201 struct GNUNET_SERVICE_Client *client,
202 struct GNUNET_MQ_Handle *mq)
203{
204 return client;
205}
206
207
215static void
217 struct GNUNET_SERVICE_Client *client,
218 void *app_cls)
219{
220 GNUNET_assert (client == app_cls);
221}
222
223
224static int
226 const struct QueryMessage *qm)
227{
228 uint16_t size;
229
230 size = ntohs (qm->header.size);
231 if (size <= sizeof(struct RevokeMessage) ||
232 (size > UINT16_MAX))
233 {
234 GNUNET_break (0);
235 return GNUNET_SYSERR;
236 }
237 return GNUNET_OK;
238
239}
240
241
248static void
250 const struct QueryMessage *qm)
251{
252 struct GNUNET_SERVICE_Client *client = cls;
254 struct GNUNET_MQ_Envelope *env;
255 struct QueryResponseMessage *qrm;
256 struct GNUNET_HashCode hc;
257 int res;
258 size_t key_len;
259 size_t read;
260
261 key_len = ntohl (qm->key_len);
262 if ((GNUNET_SYSERR ==
264 &zone, &read)) ||
265 (read != key_len))
266 {
268 "Unable to parse query public key\n");
270 return;
271 }
272 GNUNET_CRYPTO_hash (&qm[1],
273 key_len,
274 &hc);
276 &hc);
278 (GNUNET_NO == res)
279 ? "Received revocation check for valid key `%s' from client\n"
280 : "Received revocation check for revoked key `%s' from client\n",
281 GNUNET_h2s (&hc));
282 env = GNUNET_MQ_msg (qrm,
284 qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
286 env);
288}
289
290
300do_flood (void *cls,
301 const struct GNUNET_PeerIdentity *target,
302 void *value)
303{
304 const struct RevokeMessage *rm = cls;
305 struct PeerEntry *pe = value;
306 struct GNUNET_MQ_Envelope *e;
307 struct RevokeMessage *cp;
308
309 if (NULL == pe->mq)
310 return GNUNET_OK; /* peer connected to us via SET,
311 but we have no direct CORE
312 connection for flooding */
313 e = GNUNET_MQ_msg_extra (cp,
314 htonl (rm->pow_size),
316 *cp = *rm;
317 memcpy (&cp[1],
318 &rm[1],
319 htonl (rm->pow_size));
321 "Flooding revocation to `%s'\n",
322 GNUNET_i2s (target));
323 GNUNET_MQ_send (pe->mq,
324 e);
325 return GNUNET_OK;
326}
327
328
339publicize_rm (const struct RevokeMessage *rm)
340{
341 struct RevokeMessage *cp;
342 struct GNUNET_HashCode hc;
343 struct GNUNET_SETU_Element e;
344 ssize_t pklen;
345 const struct GNUNET_GNSRECORD_PowP *pow
346 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
348 = (const struct GNUNET_CRYPTO_BlindablePublicKey *) &pow[1];
349
352 if (0 > pklen)
353 {
354 GNUNET_break_op (0);
355 return GNUNET_SYSERR;
356 }
358 pklen,
359 &hc);
360 if (GNUNET_YES ==
362 &hc))
363 {
365 "Duplicate revocation received from peer. Ignored.\n");
366 return GNUNET_OK;
367 }
368 if (GNUNET_OK !=
370 {
371 GNUNET_break_op (0);
372 return GNUNET_SYSERR;
373 }
374 /* write to disk */
375 if (sizeof(struct RevokeMessage) !=
377 rm,
378 sizeof(struct RevokeMessage)))
379 {
381 "write");
382 return GNUNET_NO;
383 }
384 if (GNUNET_OK !=
386 {
388 "sync");
389 return GNUNET_NO;
390 }
391 /* keep copy in memory */
392 cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
395 &hc,
396 cp,
398 /* add to set for future connections */
399 e.size = htons (rm->header.size);
401 e.data = rm;
402 if (GNUNET_OK !=
404 &e,
405 NULL,
406 NULL))
407 {
408 GNUNET_break (0);
409 return GNUNET_OK;
410 }
411 else
412 {
414 "Added revocation info to SET\n");
415 }
416 /* flood to neighbours */
418 &do_flood,
419 cp);
420 return GNUNET_OK;
421}
422
423
424static int
426 const struct RevokeMessage *rm)
427{
428 uint16_t size;
429
430 size = ntohs (rm->header.size);
431 if (size <= sizeof(struct RevokeMessage) ||
432 (size > UINT16_MAX))
433 {
434 GNUNET_break (0);
435 return GNUNET_SYSERR;
436 }
437 return GNUNET_OK;
438
439}
440
441
448static void
450 const struct RevokeMessage *rm)
451{
452 struct GNUNET_SERVICE_Client *client = cls;
453 struct GNUNET_MQ_Envelope *env;
454 struct RevocationResponseMessage *rrm;
455 int ret;
456
458 "Received REVOKE message from client\n");
459 if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
460 {
461 GNUNET_break_op (0);
463 return;
464 }
465 env = GNUNET_MQ_msg (rrm,
467 rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
469 env);
471}
472
473
474static int
476 const struct RevokeMessage *rm)
477{
478 uint16_t size;
479
480 size = ntohs (rm->header.size);
481 if (size <= sizeof(struct RevokeMessage))
482 {
483 GNUNET_break (0);
484 return GNUNET_SYSERR;
485 }
486 return GNUNET_OK;
487
488}
489
490
497static void
499 const struct RevokeMessage *rm)
500{
502 "Received REVOKE message\n");
504 publicize_rm (rm));
505}
506
507
518static void
519add_revocation (void *cls,
520 const struct GNUNET_SETU_Element *element,
521 uint64_t current_size,
523{
524 struct PeerEntry *peer_entry = cls;
525 const struct RevokeMessage *rm;
526
527 switch (status)
528 {
530 if (element->size != sizeof(struct RevokeMessage))
531 {
532 GNUNET_break_op (0);
533 return;
534 }
536 {
539 "# unsupported revocations received via set union"),
540 1,
541 GNUNET_NO);
542 return;
543 }
544 rm = element->data;
545 (void) handle_p2p_revoke (NULL,
546 rm);
549 "# revocation messages received via set union"),
550 1, GNUNET_NO);
551 break;
554 _ ("Error computing revocation set union with %s\n"),
555 GNUNET_i2s (&peer_entry->id));
556 peer_entry->so = NULL;
558 gettext_noop ("# revocation set unions failed"),
559 1,
560 GNUNET_NO);
561 break;
563 peer_entry->so = NULL;
566 "# revocation set unions completed"),
567 1,
568 GNUNET_NO);
569 break;
570 default:
571 GNUNET_break (0);
572 break;
573 }
574}
575
576
583static void
585{
586 struct PeerEntry *peer_entry = cls;
587
589 "Starting set exchange with peer `%s'\n",
590 GNUNET_i2s (&peer_entry->id));
591 peer_entry->transmit_task = NULL;
592 GNUNET_assert (NULL == peer_entry->so);
593 peer_entry->so = GNUNET_SETU_prepare (&peer_entry->id,
595 NULL,
596 (struct GNUNET_SETU_Option[]) { { 0 } },
598 peer_entry);
599 if (GNUNET_OK !=
600 GNUNET_SETU_commit (peer_entry->so,
602 {
604 _ ("SET service crashed, terminating revocation service\n"));
606 return;
607 }
608}
609
610
619static void *
621 const struct GNUNET_PeerIdentity *peer,
622 struct GNUNET_MQ_Handle *mq,
623 enum GNUNET_CORE_PeerClass class)
624{
625 const struct GNUNET_PeerIdentity *my_identity;
626 struct GNUNET_HashCode my_identity_hash;
627 struct PeerEntry *peer_entry;
628 struct GNUNET_HashCode peer_hash;
629
631 GNUNET_assert (NULL != my_identity);
632
633 if (0 == GNUNET_memcmp (peer, my_identity))
634 return NULL;
635
637 "Peer `%s' connected to us\n",
638 GNUNET_i2s (peer));
640 "# peers connected",
641 1,
642 GNUNET_NO);
644 peer);
645 if (NULL != peer_entry)
646 {
647 /* This can happen if "core"'s notification is a tad late
648 and CADET+SET were faster and already produced a
649 #handle_revocation_union_request() for us to deal
650 with. This should be rare, but isn't impossible. */
651 peer_entry->mq = mq;
652 return peer_entry;
653 }
654 peer_entry = new_peer_entry (peer);
655 peer_entry->mq = mq;
657 sizeof(*my_identity),
658 &my_identity_hash);
659 GNUNET_CRYPTO_hash (peer,
660 sizeof(*peer),
661 &peer_hash);
662 if (0 < GNUNET_CRYPTO_hash_cmp (&my_identity_hash,
663 &peer_hash))
664 {
666 "Starting SET operation with peer `%s'\n",
667 GNUNET_i2s (peer));
668 peer_entry->transmit_task =
671 peer_entry);
672 }
673 return peer_entry;
674}
675
676
685static void
687 const struct GNUNET_PeerIdentity *peer,
688 void *internal_cls)
689{
690 const struct GNUNET_PeerIdentity *my_identity;
691 struct PeerEntry *peer_entry = internal_cls;
692
694 GNUNET_assert (NULL != my_identity);
695
696 if (0 == GNUNET_memcmp (peer, my_identity))
697 return;
698 GNUNET_assert (NULL != peer_entry);
700 "Peer `%s' disconnected from us\n",
701 GNUNET_i2s (peer));
704 peer,
705 peer_entry));
706 if (NULL != peer_entry->transmit_task)
707 {
709 peer_entry->transmit_task = NULL;
710 }
711 if (NULL != peer_entry->so)
712 {
713 GNUNET_SETU_operation_cancel (peer_entry->so);
714 peer_entry->so = NULL;
715 }
716 GNUNET_free (peer_entry);
718 "# peers connected",
719 -1,
720 GNUNET_NO);
721}
722
723
732static int
733free_entry (void *cls,
734 const struct GNUNET_HashCode *key,
735 void *value)
736{
738 return GNUNET_OK;
739}
740
741
747static void
748shutdown_task (void *cls)
749{
750 if (NULL != revocation_set)
751 {
753 revocation_set = NULL;
754 }
756 {
759 }
760 if (NULL != core_api)
761 {
763 core_api = NULL;
764 }
765 if (NULL != pils)
766 {
768 pils = NULL;
769 }
770 if (NULL != stats)
771 {
773 stats = NULL;
774 }
775 if (NULL != peers)
776 {
778 peers = NULL;
779 }
780 if (NULL != revocation_db)
781 {
783 revocation_db = NULL;
784 }
786 &free_entry,
787 NULL);
789}
790
791
798static void
799core_init (void *cls,
800 const struct GNUNET_PeerIdentity *identity)
801{
802 if (NULL == identity)
803 {
805 "Connection to core FAILED!\n");
807 return;
808 }
809}
810
811
827static void
829 const struct GNUNET_PeerIdentity *other_peer,
830 const struct GNUNET_MessageHeader *context_msg,
832{
833 struct PeerEntry *peer_entry;
834
835 if (NULL == request)
836 {
837 GNUNET_break (0);
838 return;
839 }
841 "Received set exchange request from peer `%s'\n",
842 GNUNET_i2s (other_peer));
844 other_peer);
845 if (NULL == peer_entry)
846 {
847 peer_entry = new_peer_entry (other_peer);
848 }
849 if (NULL != peer_entry->so)
850 {
851 GNUNET_break_op (0);
852 return;
853 }
854 peer_entry->so = GNUNET_SETU_accept (request,
855 (struct GNUNET_SETU_Option[]) { { 0 } },
857 peer_entry);
858 if (GNUNET_OK !=
859 GNUNET_SETU_commit (peer_entry->so,
861 {
862 GNUNET_break (0);
864 return;
865 }
866}
867
868
876static void
877run (void *cls,
878 const struct GNUNET_CONFIGURATION_Handle *c,
880{
881 struct GNUNET_MQ_MessageHandler core_handlers[] = {
882 GNUNET_MQ_hd_var_size (p2p_revoke,
884 struct RevokeMessage,
885 NULL),
887 };
888 char *fn;
889 uint64_t left;
890 ssize_t ksize;
891 struct RevokeMessage *rm;
892 struct GNUNET_HashCode hc;
895 const struct GNUNET_CORE_ServiceInfo service_info = {
897 .version = { 1, 0 },
898 .version_max = { 1, 0 },
899 .version_min = { 1, 0 },
900 };
901
902 GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
903 strlen ("revocation-set-union-application-id"),
905 if (GNUNET_OK !=
907 "REVOCATION",
908 "DATABASE",
909 &fn))
910 {
912 "REVOCATION",
913 "DATABASE");
915 return;
916 }
917 cfg = c;
919 GNUNET_NO);
921 NULL);
922 if (GNUNET_OK !=
924 "REVOCATION",
925 "WORKBITS",
927 {
929 "REVOCATION",
930 "WORKBITS");
932 GNUNET_free (fn);
933 return;
934 }
935 if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
936 {
938 "REVOCATION",
939 "WORKBITS",
940 _ ("Value is too large.\n"));
942 GNUNET_free (fn);
943 return;
944 }
945 if (GNUNET_OK !=
947 "REVOCATION",
948 "EPOCH_DURATION",
950 {
952 "REVOCATION",
953 "EPOCH_DURATION");
955 GNUNET_free (fn);
956 return;
957 }
958
964 NULL);
972 if (NULL == revocation_db)
973 {
975 "REVOCATION",
976 "DATABASE",
977 _ ("Could not open revocation database file!"));
979 GNUNET_free (fn);
980 return;
981 }
982 if (GNUNET_OK !=
984 left = 0;
985 while (left > sizeof(struct RevokeMessage))
986 {
987 rm = GNUNET_new (struct RevokeMessage);
988 if (sizeof(struct RevokeMessage) !=
990 rm,
991 sizeof(struct RevokeMessage)))
992 {
994 "read",
995 fn);
996 GNUNET_free (rm);
998 GNUNET_free (fn);
999 return;
1000 }
1001 pow = (struct GNUNET_GNSRECORD_PowP *) &rm[1];
1002 pk = (const struct GNUNET_CRYPTO_BlindablePublicKey *) &pow[1];
1004 if (0 > ksize)
1005 {
1006 GNUNET_break_op (0);
1007 GNUNET_free (rm);
1008 GNUNET_free (fn);
1009 return;
1010 }
1012 ksize,
1013 &hc);
1016 &hc,
1017 rm,
1019 }
1020 GNUNET_free (fn);
1021
1023 GNUNET_YES);
1024 pils = GNUNET_PILS_connect (cfg, NULL, NULL);
1025 /* Connect to core service and register core handlers */
1026 core_api = GNUNET_CORE_connect (cfg, /* Main configuration */
1027 NULL, /* Closure passed to functions */
1028 &core_init, /* Call core_init once connected */
1029 &handle_core_connect, /* Handle connects */
1030 &handle_core_disconnect, /* Handle disconnects */
1031 core_handlers, /* Register these handlers */
1032 &service_info);
1033 if (NULL == core_api)
1034 {
1036 return;
1037 }
1038 stats = GNUNET_STATISTICS_create ("revocation",
1039 cfg);
1040}
1041
1042
1048 "revocation",
1050 &run,
1053 NULL,
1054 GNUNET_MQ_hd_var_size (query_message,
1056 struct QueryMessage,
1057 NULL),
1058 GNUNET_MQ_hd_var_size (revoke_message,
1060 struct RevokeMessage,
1061 NULL),
1063
1064
1065#if defined(__linux__) && defined(__GLIBC__)
1066#include <malloc.h>
1067
1068void
1069GNUNET_REVOCATION_memory_init (void);
1070
1074void __attribute__ ((constructor))
1075GNUNET_REVOCATION_memory_init ()
1076{
1077 mallopt (M_TRIM_THRESHOLD, 4 * 1024);
1078 mallopt (M_TOP_PAD, 1 * 1024);
1079 malloc_trim (0);
1080}
1081
1082
1083#endif
1084
1085
1086/* end of gnunet-service-revocation.c */
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_BlindablePrivateKey pk
Private key from command line option, or NULL.
struct GNUNET_SCHEDULER_Task * shutdown_task
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_PeerIdentity my_identity
Identity of this peer.
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 void handle_revoke_message(void *cls, const struct RevokeMessage *rm)
Handle REVOKE message from client.
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 client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_cls)
Handle client connecting to the service.
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_core_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq, enum GNUNET_CORE_PeerClass class)
Method called whenever a peer connects.
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 struct GNUNET_PILS_Handle * pils
Handle to the pils service.
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
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Core service; the main API for encrypted P2P communications.
@ GNUNET_BLOCK_TYPE_REVOCATION
Block type for a revocation message by which a key is revoked.
API that can be used to manipulate GNS record data.
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition pils_api.c:624
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:647
const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity(const struct GNUNET_PILS_Handle *handle)
Return the current peer identity of a given handle.
Definition pils_api.c:875
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, const struct GNUNET_CORE_ServiceInfo *service_info)
Connect to the core service.
Definition core_api.c:698
GNUNET_CORE_PeerClass
The peer class gives a hint about the capabilities of a peer.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition core_api.c:744
@ GNUNET_CORE_SERVICE_REVOCATION
Identifier for revocation service.
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:1307
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:745
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:235
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition disk.c:1506
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition disk.c:1385
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:704
@ 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:40
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.
static struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
static struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
static void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
static void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
static enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
static int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
static enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
static enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
static int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
static enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
static void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *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...
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_blindable_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePublicKey from a compact buffer.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
GNUNET_GenericReturnValue
Named constants for return values.
ssize_t GNUNET_CRYPTO_blindable_pk_get_length(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePublicKey.
Definition crypto_pkey.c:87
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:337
#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.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#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:572
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:1345
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
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:1283
#define GNUNET_SERVICE_MAIN(pd, service_name, service_options, init_cb, connect_cb, disconnect_cb, cls,...)
Creates the "main" function for a GNUnet service.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition service.c:2463
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition service.c:2545
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2434
@ 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:179
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
messages for key revocation
Context for the core service connection.
Definition core_api.c:78
Gnunet service info - identifying compatibility with a range of version of a service communicating ov...
enum GNUNET_CORE_Service service
Identifier of the service on top of CORE.
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.
A handle for the PILS service.
Definition pils_api.c:86
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition scheduler.c:141
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