GNUnet 0.28.0-dev.3-20-gf1136b0b8
 
Loading...
Searching...
No Matches
messenger_api_epoch_announcement.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2024--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 */
27
28#include "gnunet_common.h"
29#include "gnunet_util_lib.h"
30#include "messenger_api_epoch.h"
34#include "messenger_api_room.h"
35
36static void
38 identifier)
39{
40 GNUNET_assert (identifier);
41
43 sizeof (*identifier));
44
45 identifier->code.group_bit = 0;
46 identifier->code.level_bits = 0;
47}
48
49
54 previous,
56{
57 const struct GNUNET_CRYPTO_AeadSecretKey *previous_key;
58
59 GNUNET_assert ((announcement) && (previous) && (key));
60
61 previous_key = get_epoch_announcement_key (previous);
62
63 if (! previous_key)
64 return GNUNET_SYSERR;
65
67 key,
68 sizeof (*key),
71 previous_key,
72 sizeof (*previous_key),
75 return GNUNET_SYSERR;
76 else
77 return GNUNET_OK;
78}
79
80
86{
88 const struct GNUNET_MESSENGER_EpochAnnouncement *previous;
89
91
93
94 if (! announcement)
95 return NULL;
96
98
99 if ((GNUNET_YES == valid) && (previous) &&
100 (GNUNET_YES != previous->valid))
101 previous = NULL;
102
103 if (previous)
104 identifier = &(previous->identifier);
105
106 if (identifier)
107 GNUNET_memcpy (&(announcement->identifier), identifier,
108 sizeof (announcement->identifier));
109 else
111
112 GNUNET_assert (! announcement->identifier.code.group_bit);
113
114 announcement->announcement_expiration = GNUNET_TIME_absolute_get_zero_ ();
115 announcement->appeal = NULL;
116
117 announcement->appeal_task = NULL;
118
119 announcement->epoch = epoch;
122 announcement->shared_key = NULL;
123 announcement->query = NULL;
124
126
127 announcement->valid = GNUNET_YES;
128 announcement->stored = GNUNET_NO;
129
130 if (previous)
131 {
133
135 previous,
136 &key))
137 {
139
140 announcement->valid = previous->valid;
141 }
142 }
143
144 return announcement;
145}
146
147
148void
151{
153
154 if (announcement->messages)
156
157 if (announcement->membership)
159
160 if (announcement->shared_key)
161 GNUNET_free (announcement->shared_key);
162
163 if (announcement->query)
165
166 if (announcement->appeal_task)
168
169 if (announcement->appeal)
170 GNUNET_free (announcement->appeal);
171
173}
174
175
176uint32_t
184
185
186uint32_t
195
196
206
207
217
218
219static void
221{
223 struct GNUNET_HashCode event;
224
225 GNUNET_assert (cls);
226
227 announcement = cls;
228 announcement->appeal_task = NULL;
229
231 return;
232
234 GNUNET_YES))
235 return;
236
238}
239
240
241void
245{
246 struct GNUNET_TIME_Absolute timepoint;
247
249
251
252 if (! announcement->appeal)
254 else if (GNUNET_TIME_absolute_cmp (*(announcement->appeal), >, timepoint))
255 return;
256
257 GNUNET_memcpy (announcement->appeal, &timepoint, sizeof (timepoint));
258
259 if (announcement->appeal_task)
261
263 *(announcement->appeal),
267}
268
269
274{
275 struct GNUNET_TIME_Relative time;
276
278
279 if (! announcement->appeal)
280 return GNUNET_NO;
281
283
285 return GNUNET_NO;
286
287 return GNUNET_YES;
288}
289
290
291static void
294
295void
298 const struct GNUNET_CRYPTO_AeadSecretKey *
299 shared_key,
300 enum GNUNET_GenericReturnValue write_record)
301{
303
304 if ((GNUNET_NO == write_record) && (shared_key))
305 announcement->stored = GNUNET_YES;
306
307 if (announcement->shared_key)
308 return;
309
310 announcement->shared_key = GNUNET_new (struct
312
313 if (! announcement->shared_key)
314 return;
315
316 if (shared_key)
317 GNUNET_memcpy (announcement->shared_key, shared_key,
318 sizeof (struct GNUNET_CRYPTO_AeadSecretKey));
319 else
321
323
324 if (GNUNET_YES != announcement->stored)
326
328}
329
330
331const struct GNUNET_CRYPTO_AeadSecretKey*
339
340
345 const struct
347 previous)
348{
349 const struct GNUNET_CRYPTO_AeadSecretKey *shared_key;
351
352 GNUNET_assert ((announcement) && (previous));
353
355
356 if (! shared_key)
357 return GNUNET_SYSERR;
358
360 return GNUNET_SYSERR;
361
362 if (0 == GNUNET_memcmp (shared_key, &key))
363 return GNUNET_YES;
364 else
365 return GNUNET_NO;
366}
367
368
369static void
372 const struct GNUNET_HashCode *hash,
373 enum GNUNET_GenericReturnValue update)
374{
375 const struct GNUNET_CRYPTO_AeadSecretKey *shared_key;
376
377 GNUNET_assert ((announcement) && (hash));
378
380
381 GNUNET_assert ((shared_key) && (announcement->epoch) && (announcement->epoch->
382 room));
383
385 hash, shared_key, update))
387}
388
389
392 const struct GNUNET_HashCode *hash,
393 void *value)
394{
396
397 GNUNET_assert ((cls) && (hash));
398
399 announcement = cls;
400
402 return GNUNET_YES;
403}
404
405
406static void
419
420
421void
424 const struct GNUNET_MESSENGER_Message *
425 message,
426 const struct GNUNET_HashCode *hash)
427{
428 GNUNET_assert ((announcement) && (message) && (hash) &&
430
432 {
434 messages, hash))
435 return;
436
438 hash, NULL,
440 return;
441 }
442
444}
445
446
450 const struct GNUNET_HashCode *hash,
451 const struct GNUNET_MESSENGER_Message *
452 message,
453 struct GNUNET_MESSENGER_Contact *contact,
455{
457
458 GNUNET_assert ((announcement) && (hash) && (message) && (contact));
459
460 if (GNUNET_YES != is_epoch_member (announcement->epoch, contact))
461 return GNUNET_SYSERR;
462
464 hash,
465 message,
466 contact,
467 sent);
468
469 if (GNUNET_YES != result)
470 return result;
471
473 return GNUNET_YES;
474}
475
476
480 const struct GNUNET_HashCode *hash,
481 const struct GNUNET_MESSENGER_Message *
482 message,
483 struct GNUNET_MESSENGER_Contact *contact)
484{
485 GNUNET_assert ((announcement) && (hash) && (message) && (contact));
486
488 return GNUNET_SYSERR;
489
491 hash, contact);
492}
493
494
498 const struct GNUNET_MESSENGER_Contact *contact)
499{
501
502 return is_epoch_membership_member (announcement->membership, contact);
503}
504
505
510 struct GNUNET_HashCode *hash,
511 enum GNUNET_GenericReturnValue other)
512{
513 GNUNET_assert ((announcement) && (hash));
514
516 announcement->membership, hash, other);
517}
518
519
520void
523 const struct GNUNET_MESSENGER_Contact *
524 contact)
525{
526 const struct GNUNET_MESSENGER_Message *message;
527 struct GNUNET_MESSENGER_EpochAnnouncement *previous;
528 struct GNUNET_MESSENGER_Epoch *epoch;
529
531
532 if (GNUNET_NO == announcement->valid)
533 return;
534
535 if ((contact) && (GNUNET_YES != is_epoch_member (announcement->epoch,
536 contact)))
537 return;
538
539 announcement->valid = GNUNET_NO;
541
542 message = get_room_message (announcement->epoch->room,
543 &(announcement->epoch->hash));
544
545 if (! message)
546 goto skip_traversal;
547
548 switch (message->header.kind)
549 {
551 epoch = get_room_epoch (
552 announcement->epoch->room, &(message->body.join.epoch), GNUNET_NO);
553
554 if (epoch)
555 previous = get_epoch_announcement (
556 epoch, &(announcement->identifier), GNUNET_SYSERR);
557 else
558 previous = NULL;
559 break;
561 epoch = get_room_epoch (
562 announcement->epoch->room, &(message->body.leave.epoch), GNUNET_NO);
563
564 if (epoch)
565 previous = get_epoch_announcement (
566 epoch, &(announcement->identifier), GNUNET_SYSERR);
567 else
568 previous = NULL;
569 break;
571 epoch = get_room_epoch (
572 announcement->epoch->room, &(message->body.merge.epochs[0]), GNUNET_NO);
573
574 if (epoch)
575 {
576 previous = get_epoch_announcement (
577 epoch, &(announcement->identifier), GNUNET_SYSERR);
578
579 if ((previous) &&
581 announcement)))
582 previous = NULL;
583 }
584 else
585 previous = NULL;
586
587 if (! previous)
588 {
589 epoch = get_room_epoch (
590 announcement->epoch->room, &(message->body.merge.epochs[1]), GNUNET_NO);
591
592 if (epoch)
593 previous = get_epoch_announcement (
594 epoch, &(announcement->identifier), GNUNET_SYSERR);
595 }
596 break;
597 default:
598 previous = NULL;
599 break;
600 }
601
602 if ((previous) &&
604 announcement)))
605 previous = NULL;
606
607 if (previous)
608 invalidate_epoch_announcement (previous, contact);
609
610skip_traversal:
611 if (announcement->epoch->main_announcement != announcement)
612 return;
613
614 announcement->epoch->main_announcement = get_epoch_announcement (
615 announcement->epoch, NULL, GNUNET_YES);
616}
617
618
621 )
622{
623 const struct GNUNET_CRYPTO_AeadSecretKey *key;
624 const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key;
626 struct GNUNET_MESSENGER_Message *message;
627
629
631
632 if (! key)
633 return GNUNET_SYSERR;
634
636 announcement->announcement_expiration);
637
639 return GNUNET_NO;
640
643
644 private_key = get_epoch_private_key (announcement->epoch,
645 timeout);
646
647 if (! private_key)
648 return GNUNET_SYSERR;
649
651
652 message = create_message_announcement (&(announcement->identifier),
653 private_key,
654 key,
655 timeout);
656
657 if (! message)
658 return GNUNET_SYSERR;
659
660 send_epoch_message (announcement->epoch, message);
661
662 announcement->announcement_expiration = GNUNET_TIME_absolute_add (
664
665 return GNUNET_OK;
666}
667
668
671 const struct GNUNET_HashCode *key,
672 void *value)
673{
674 struct GNUNET_HashCode *event;
675
676 GNUNET_assert ((cls) && (key));
677
678 event = cls;
679
680 GNUNET_memcpy (event, key, sizeof (*event));
681 return GNUNET_NO;
682}
683
684
688 const struct GNUNET_HashCode *event)
689{
690 const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key;
692 struct GNUNET_HashCode event_hash;
693 struct GNUNET_MESSENGER_Message *message;
694
696
698 private_key = get_epoch_private_key (announcement->epoch,
699 timeout);
700
701 if (! private_key)
702 return GNUNET_SYSERR;
703
705
706 if ((! event) ||
708 membership->members
709 , event)))
710 {
712 return GNUNET_SYSERR;
713
716 &event_hash);
717
718 event = &event_hash;
719 }
720
721 message = create_message_appeal (event,
722 private_key,
723 timeout);
724
725 if (! message)
726 return GNUNET_SYSERR;
727
729 send_epoch_message (announcement->epoch, message);
730 return GNUNET_OK;
731}
732
733
737 const struct GNUNET_HashCode *event)
738{
739 struct GNUNET_MESSENGER_Room *room;
740 const struct GNUNET_CRYPTO_AeadSecretKey *key;
741 const struct GNUNET_MESSENGER_Message *appeal_message;
742 const struct GNUNET_CRYPTO_EcdhePublicKey *public_key;
743 struct GNUNET_MESSENGER_Message *message;
744
745 GNUNET_assert ((announcement) && (event));
746
747 room = announcement->epoch->room;
749
750 if (! key)
751 return GNUNET_SYSERR;
752
753 appeal_message = get_room_message (room, event);
754
755 if (! appeal_message)
756 return GNUNET_SYSERR;
757
758 if (GNUNET_MESSENGER_KIND_APPEAL != appeal_message->header.kind)
759 return GNUNET_SYSERR;
760
762 membership->members,
763 &(appeal_message->
765 ))
766 return GNUNET_SYSERR;
767
768 public_key = &(appeal_message->body.appeal.key);
769 message = create_message_access (event,
770 public_key,
771 key);
772
773 if (! message)
774 return GNUNET_SYSERR;
775
776 send_epoch_message (announcement->epoch, message);
777 return GNUNET_OK;
778}
779
780
784{
785 const struct GNUNET_CRYPTO_AeadSecretKey *key;
786 struct GNUNET_MESSENGER_Message *message;
787
789
791
792 if (! key)
793 return GNUNET_SYSERR;
794
795 message = create_message_revolution (&(announcement->identifier),
796 key);
797
798 if (! message)
799 return GNUNET_SYSERR;
800
801 send_epoch_message (announcement->epoch, message);
802 return GNUNET_OK;
803}
804
805
810 const struct
812 const struct GNUNET_HashCode *event)
813{
814 struct GNUNET_MESSENGER_Room *room;
815 const struct GNUNET_CRYPTO_AeadSecretKey *key;
816 const struct GNUNET_MESSENGER_Message *announcement_message;
817 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
818 const struct GNUNET_CRYPTO_AeadSecretKey *group_key;
819 struct GNUNET_MESSENGER_Message *message;
820
821 GNUNET_assert ((announcement) && (group) && (event));
822
823 room = group->epoch->room;
825
826 if (! key)
827 return GNUNET_SYSERR;
828
829 if (! group->identifier.code.group_bit)
830 return GNUNET_SYSERR;
831
832 announcement_message = get_room_message (room, event);
833
834 if ((! announcement_message) ||
835 (GNUNET_MESSENGER_KIND_ANNOUNCEMENT != announcement_message->header.kind))
836 return GNUNET_SYSERR;
837
838 identifier = &(announcement_message->body.announcement.identifier);
839
840 if (0 != GNUNET_memcmp (&(announcement->identifier), identifier))
841 return GNUNET_SYSERR;
842
843 if (GNUNET_YES != verify_message_by_key (announcement_message, key))
844 return GNUNET_SYSERR;
845
846 group_key = get_epoch_group_key (group);
847
848 if (! group_key)
849 return GNUNET_SYSERR;
850
851 message = create_message_authorization (&(group->identifier),
852 event,
853 group_key,
854 key);
855
856 if (! message)
857 return GNUNET_SYSERR;
858
859 send_epoch_message (announcement->epoch, message);
860 return GNUNET_OK;
861}
862
863
864void
867 const struct GNUNET_MESSENGER_Message *message,
868 const struct GNUNET_HashCode *hash,
869 struct GNUNET_MESSENGER_Contact *sender,
871{
872 const struct GNUNET_CRYPTO_AeadSecretKey *key;
874
875 GNUNET_assert ((announcement) && (message) && (hash) && (sender));
876
878
879 if (key)
880 {
881 if (GNUNET_OK != verify_message_by_key (message, key))
882 return;
883
886 &(announcement->epoch->hash),
887 &(announcement->identifier),
888 sender);
889
892 {
894 return;
895 }
896 }
897
899 hash,
900 message,
901 sender,
902 sent))
903 return;
904
905 if ((GNUNET_YES != sent) &&
907 {
908 const struct GNUNET_MESSENGER_Contact *contact;
909
910 contact = get_handle_contact (
911 get_room_handle (announcement->epoch->room),
912 get_room_key (announcement->epoch->room));
913
915
917 get_message_timeout (message),
919 announcement->membership));
920 }
921 else if (announcement->epoch->main_group)
923 get_message_timeout (message),
924 get_epoch_group_position_factor (announcement->epoch->main_group));
925 else
927
928 delay_room_action (announcement->epoch->room, hash, timeout);
929}
930
931
932void
935 const struct GNUNET_MESSENGER_Message *
936 message,
937 const struct GNUNET_HashCode *hash,
938 struct GNUNET_MESSENGER_Contact *sender,
940{
942
943 GNUNET_assert ((announcement) && (message) && (hash) && (sender));
944
945 if (GNUNET_YES == is_room_public (announcement->epoch->room))
946 return;
947
948 if ((GNUNET_YES == sent) && (GNUNET_YES == announcement->valid))
950 announcement->epoch,
952
955 return;
956
957 timeout = get_message_timeout (message);
958
960 return;
961
963}
964
965
966void
969 const struct GNUNET_MESSENGER_Message *
970 message,
971 const struct GNUNET_HashCode *hash)
972{
973 const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key;
974 struct GNUNET_CRYPTO_HpkePrivateKey private_hpke;
975 struct GNUNET_CRYPTO_AeadSecretKey shared_key;
976 const struct GNUNET_MESSENGER_Message *appeal_message;
977
978 GNUNET_assert ((announcement) && (message) && (hash));
979
980 private_key = get_epoch_private_key (announcement->epoch,
982
983 if (! private_key)
984 {
986 "Private key for decrypting shared key is missing!\n");
987 return;
988 }
989 GNUNET_memcpy (&private_hpke.ecdhe_key,
990 private_key,
991 sizeof *private_key);
993 message,
994 &private_hpke,
995 &shared_key))
996 return;
997
999 return;
1000
1002
1003 appeal_message = get_room_message (
1004 announcement->epoch->room,
1005 &(message->body.access.event));
1006
1007 if ((announcement->epoch->main_group) &&
1008 (appeal_message) &&
1009 (GNUNET_MESSENGER_KIND_APPEAL == appeal_message->header.kind) &&
1010 (GNUNET_YES == is_epoch_group_compatible (announcement->epoch->main_group,
1011 announcement->epoch)) &&
1013 announcement->epoch->main_group, announcement)))
1015 announcement, announcement->epoch->main_group,
1016 &(appeal_message->body.appeal.event));
1017
1019}
1020
1021
1022static void
1024 enum GNUNET_ErrorCode ec)
1025{
1027
1028 GNUNET_assert (cls);
1029
1030 announcement = cls;
1031
1032 if (GNUNET_EC_NONE != ec)
1034 "Error writing epoch key record: %d\n", (int) ec);
1035
1036 announcement->query = NULL;
1037}
1038
1039
1040void
1043 enum GNUNET_GenericReturnValue deleted)
1044{
1045 const struct GNUNET_MESSENGER_Handle *handle;
1046 const struct GNUNET_HashCode *hash;
1047 const struct GNUNET_ShortHashCode *identifier;
1048 const struct GNUNET_CRYPTO_AeadSecretKey *shared_key;
1049
1050 GNUNET_assert ((announcement) && (announcement->epoch));
1051
1052 handle = get_room_handle (announcement->epoch->room);
1053
1054 if (! handle)
1055 return;
1056
1057 hash = &(announcement->epoch->hash);
1058 identifier = &(announcement->identifier.hash);
1059
1060 if (GNUNET_YES == deleted)
1061 {
1062 shared_key = NULL;
1063 }
1064 else
1065 {
1066 shared_key = announcement->shared_key;
1067
1068 if (! shared_key)
1069 return;
1070 }
1071
1073 handle, announcement->epoch->room,
1074 hash, identifier, shared_key,
1075 GNUNET_YES == announcement->valid?
1080 &(announcement->query));
1081}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition gnunet-arm.c:118
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static int result
Global testing status.
struct GNUNET_REGEX_Announcement * announcement
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NONE
No error (success).
void GNUNET_CRYPTO_random_block(void *buffer, size_t length)
Fill block with a random values.
#define GNUNET_CRYPTO_hkdf_gnunet(result, out_len, xts, xts_len, skm, skm_len,...)
A peculiar HKDF instantiation that tried to mimic Truncated NMAC.
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).
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback 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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_CRYPTO_kdf_arg_auto(d)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void GNUNET_CRYPTO_aead_create_key(struct GNUNET_CRYPTO_AeadSecretKey *key)
Create a new AEAD key.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_SCHEDULER_PRIORITY_HIGH
Run with high priority (important requests).
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
@ GNUNET_MESSENGER_KIND_ANNOUNCEMENT
The announcement kind.
@ GNUNET_MESSENGER_KIND_APPEAL
The appeal kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_SECRET
The secret kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_FLAG_EPOCH_NONE
The none flag.
@ GNUNET_MESSENGER_FLAG_EPOCH_VALID
The valid flag.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
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_at_with_priority(struct GNUNET_TIME_Absolute at, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition scheduler.c:1124
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition time.c:133
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_hour_(void)
Return relative time of 1 hour.
Definition time.c:187
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_(void)
Return absolute time of 0ms.
Definition time.c:142
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition time.c:406
bool GNUNET_TIME_relative_is_zero(struct GNUNET_TIME_Relative rel)
Test if rel is zero.
Definition time.c:660
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply_double(struct GNUNET_TIME_Relative rel, double factor)
Multiply relative time by a given factor.
Definition time.c:506
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486
#define GNUNET_TIME_absolute_cmp(t1, op, t2)
Compare two absolute times.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition time.c:452
const struct GNUNET_TIME_Relative get_epoch_private_key_timeout(const struct GNUNET_MESSENGER_Epoch *epoch)
Returns the current relative timeout for the private key (ECDHE) of a given epoch that limits the usa...
uint32_t get_epoch_size(const struct GNUNET_MESSENGER_Epoch *epoch)
Returns the amount of members by a given epoch or zero as long as it's not fully initialized yet.
const struct GNUNET_MESSENGER_EpochAnnouncement * get_epoch_previous_announcement(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier)
Returns the epoch announcement of a previous epoch from a given epoch using a specific announcement i...
void update_epoch_announcement(struct GNUNET_MESSENGER_Epoch *epoch, struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Updates the main announcement of a given epoch, looking into replacing the current main announcement ...
enum GNUNET_GenericReturnValue is_epoch_member(const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
Returns whether a specific contact is member of a given epoch.
const struct GNUNET_CRYPTO_EcdhePrivateKey * get_epoch_private_key(struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_TIME_Relative timeout)
Returns the asymmetric private key (ECDHE) from a handle for a given epoch that can be used for HPKE ...
struct GNUNET_MESSENGER_EpochAnnouncement * get_epoch_announcement(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Returns the epoch announcement of a given epoch using a specific unique identifier or NULL.
void propose_epoch_group(struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_TIME_Relative timeout)
Tries to propose a new group inside a given epoch that will automatically be formed by using the clie...
double get_epoch_position_factor(const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_MESSENGER_EpochMembership *membership)
Returns a relative member position of a specific contact inside a given epoch in relation to its list...
void send_epoch_message(const struct GNUNET_MESSENGER_Epoch *epoch, struct GNUNET_MESSENGER_Message *message)
Sends a created and allocated message in a room of a given epoch enforcing the message gets interpret...
enum GNUNET_GenericReturnValue send_epoch_announcement_appeal(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_HashCode *event)
Tries to send an appeal message by the client responding to a previous event in regards to a given ep...
static void handle_secret_message_with_key(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue update)
static void task_epoch_announcement_appeal(void *cls)
enum GNUNET_GenericReturnValue send_epoch_announcement_access(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_HashCode *event)
Tries to send an access message by the client responding to a previous event in regards to a given ep...
enum GNUNET_GenericReturnValue is_epoch_announcement_appealed(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns whether a given epoch announcement of the client is currently appealing for its secret key fr...
void set_epoch_announcement_key(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_CRYPTO_AeadSecretKey *shared_key, enum GNUNET_GenericReturnValue write_record)
Sets the secret key of a given epoch announcement to a shared key.
enum GNUNET_GenericReturnValue send_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Tries to send an announcement message by the client for a given epoch announcement using its secret k...
uint32_t get_epoch_announcement_size(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns the size of a given epoch announcement in terms of members.
enum GNUNET_GenericReturnValue send_epoch_announcement_authorization(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_HashCode *event)
Tries to send an authorization message by the client responding to a previous event in regards to a g...
enum GNUNET_GenericReturnValue get_epoch_announcement_member_hash(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue other)
Provides an announcement hash of a member from a given epoch announcement.
static void handle_secret_messages_with_key(struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
enum GNUNET_GenericReturnValue is_epoch_announcement_completed(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns whether a given epoch announcement is complete in terms of confirmed announcements from its m...
const struct GNUNET_CRYPTO_AeadSecretKey * get_epoch_announcement_key(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns the secret key of a given epoch announcement or NULL.
static void random_epoch_announcement_identifier(union GNUNET_MESSENGER_EpochIdentifier *identifier)
void set_epoch_announcement_appeal(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, struct GNUNET_TIME_Relative timeout)
Sets a specified timeout for a given epoch announcement of the client for its own appeal of the annou...
struct GNUNET_MESSENGER_EpochAnnouncement * create_epoch_announcement(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Creates and allocates a new epoch announcement for a given epoch using a specific announcement identi...
static enum GNUNET_GenericReturnValue derive_epoch_announcement_key(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_EpochAnnouncement *previous, struct GNUNET_CRYPTO_AeadSecretKey *key)
enum GNUNET_GenericReturnValue send_epoch_announcement_revolution(struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Tries to send a revolution message by the client for a given epoch announcement using its secret key.
enum GNUNET_GenericReturnValue revoke_epoch_announcement_member(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Contact *contact)
Revokes an announcement message with its hash from a given epoch announcement removing the caused con...
void destroy_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Destroys a given epoch announcement and frees its resources.
enum GNUNET_GenericReturnValue is_epoch_announcement_member(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Contact *contact)
Returns whether a specific contact is confirmed member of a given epoch announcement.
void handle_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Contact *sender, enum GNUNET_GenericReturnValue sent)
Handles an announcement message with hash from its sender inside a given epoch announcement as first ...
void invalidate_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Contact *contact)
Invalidates a given epoch announcement by a specific contact.
static enum GNUNET_GenericReturnValue it_handle_secret_message(void *cls, const struct GNUNET_HashCode *hash, void *value)
static enum GNUNET_GenericReturnValue is_epoch_announcement_key_derived_from(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_EpochAnnouncement *previous)
void handle_epoch_announcement_access(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles an access message with hash from its sender inside a given epoch announcement.
void handle_epoch_announcement_message(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles an encrypted message with hash by a given epoch announcement using its secret key for decrypt...
void handle_epoch_announcement_delay(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Contact *sender, enum GNUNET_GenericReturnValue sent)
Handles an announcement message with hash from its sender inside a given epoch announcement as second...
static void cont_write_epoch_announcement_record(void *cls, enum GNUNET_ErrorCode ec)
static enum GNUNET_GenericReturnValue it_store_any_event(void *cls, const struct GNUNET_HashCode *key, void *value)
void write_epoch_announcement_record(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, enum GNUNET_GenericReturnValue deleted)
Writes/Deletes the GNS record of a given epoch announcement depending on a provided flag that states ...
enum GNUNET_GenericReturnValue confirm_epoch_announcement_member(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Contact *contact, enum GNUNET_GenericReturnValue sent)
Confirms an announcement message with its hash to a given epoch announcement as confirmation for a sp...
enum GNUNET_GenericReturnValue is_epoch_announcement_announced(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns whether the client has announced being part of a given epoch announcement owning its secret k...
uint32_t get_epoch_announcement_members_count(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns the current amount of members of a given epoch announcement.
const struct GNUNET_CRYPTO_AeadSecretKey * get_epoch_group_key(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns the secret key of a given epoch group or NULL.
enum GNUNET_GenericReturnValue is_epoch_group_compatible(const struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_Epoch *epoch)
Returns whether a given epoch group is compatible with a specific epoch with its members.
double get_epoch_group_position_factor(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns a relative member position of the client inside a given epoch group in relation to its list o...
enum GNUNET_GenericReturnValue is_epoch_group_missing_announcement(const struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns whether any member of a given epoch group is missing in a provided epoch announcement.
enum GNUNET_GenericReturnValue is_epoch_membership_member(const struct GNUNET_MESSENGER_EpochMembership *membership, const struct GNUNET_MESSENGER_Contact *contact)
Returns whether a specific contact is announced member of a given epoch membership.
enum GNUNET_GenericReturnValue revoke_epoch_membership_announcement(struct GNUNET_MESSENGER_EpochMembership *membership, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Contact *contact)
Drops an announcement message with a provided hash from a given epoch membership to revoke the confir...
enum GNUNET_GenericReturnValue confirm_epoch_membership_announcment(struct GNUNET_MESSENGER_EpochMembership *membership, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Contact *contact, enum GNUNET_GenericReturnValue sent)
Adds an announcement message with its hash to a given epoch membership as confirmation for a specific...
enum GNUNET_GenericReturnValue is_epoch_membership_completed(const struct GNUNET_MESSENGER_EpochMembership *membership)
Returns whether a given epoch membership is complete, meaning that all of its intended members have p...
struct GNUNET_MESSENGER_EpochMembership * create_epoch_membership(uint32_t size)
Creates and allocates a new membership for subgroups of an epoch with specified size.
enum GNUNET_GenericReturnValue get_epoch_membership_member_hash(const struct GNUNET_MESSENGER_EpochMembership *membership, struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue other)
Provides an announcement hash of a member from a given epoch membership.
void destroy_epoch_membership(struct GNUNET_MESSENGER_EpochMembership *membership)
Destroys and frees resources of a given membership.
uint32_t get_epoch_membership_count(const struct GNUNET_MESSENGER_EpochMembership *membership)
Returns the current amount of individual members inside a given epoch membership.
struct GNUNET_MESSENGER_Contact * get_handle_contact(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Returns the contact of a given handle in a room identified by a given key.
enum GNUNET_GenericReturnValue store_handle_epoch_key(const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_ShortHashCode *identifier, const struct GNUNET_CRYPTO_AeadSecretKey *shared_key, uint32_t flags, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls, struct GNUNET_NAMESTORE_QueueEntry **query)
Stores/deletes a shared_key for a given room from a handle in an epoch with certain hash using a spec...
struct GNUNET_TIME_Relative get_message_timeout(const struct GNUNET_MESSENGER_Message *message)
Return the relative timeout of the content from a given message that controls when a delayed handling...
enum GNUNET_GenericReturnValue extract_access_message_key(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_HpkePrivateKey *key, struct GNUNET_CRYPTO_AeadSecretKey *shared_key)
Extracts the shared epoch or group key from an access message using the private ephemeral key from an...
enum GNUNET_GenericReturnValue verify_message_by_key(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_AeadSecretKey *key)
Verifies the hmac of a given message body with a specific shared key.
#define GNUNET_MESSENGER_SALT_EPOCH_KEY
struct GNUNET_MESSENGER_Message * create_message_announcement(const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key, const struct GNUNET_CRYPTO_AeadSecretKey *shared_key, const struct GNUNET_TIME_Relative timeout)
Creates and allocates a new announcement message for an announcement of a given epoch or group under ...
struct GNUNET_MESSENGER_Message * create_message_authorization(const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_AeadSecretKey *group_key, const struct GNUNET_CRYPTO_AeadSecretKey *shared_key)
Creates and allocates a new authorization message to grant access to the shared_key of a specific gro...
struct GNUNET_MESSENGER_Message * create_message_appeal(const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key, const struct GNUNET_TIME_Relative timeout)
Creates and allocates a new appeal message for an epoch announcement using a specific private_key to ...
struct GNUNET_MESSENGER_Message * create_message_revolution(const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_CRYPTO_AeadSecretKey *shared_key)
Creates and allocates a new revolution message for an announced epoch or group selected by its identi...
struct GNUNET_MESSENGER_Message * create_message_access(const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_EcdhePublicKey *public_key, const struct GNUNET_CRYPTO_AeadSecretKey *shared_key)
Creates and allocates a new access message to grant access to the shared_key of an announced epoch or...
void cancel_room_actions_by(struct GNUNET_MESSENGER_Room *room, enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_HashCode *epoch_hash, const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_MESSENGER_Contact *contact)
Searches queued actions to handle messages of a specific message kind in a room with any delay and ca...
const struct GNUNET_MESSENGER_Message * get_room_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a message locally stored from a map for a given hash in a room.
struct GNUNET_MESSENGER_Epoch * get_room_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue recent)
Returns the epoch in a given room from a specific epoch hash that represents the exact message the ep...
enum GNUNET_GenericReturnValue is_room_public(const struct GNUNET_MESSENGER_Room *room)
Returns whether a given room is public or using epoch keys to encrypt private traffic and sync those ...
enum GNUNET_GenericReturnValue update_room_secret_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_AeadSecretKey *key, enum GNUNET_GenericReturnValue update)
Updates a secret message with a given hash in a room for the client API trying to decrypt it with the...
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_Room *room)
Return a the hash representation of a given room.
struct GNUNET_MESSENGER_Handle * get_room_handle(struct GNUNET_MESSENGER_Room *room)
Returns the messenger handle of the room.
void delay_room_action(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Enqueues delayed handling of a message in a room under a given hash once a specific delay has timed o...
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
A public key used for decryption.
struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_key
An ECDHE/X25519 key.
A 512-bit hashcode.
struct GNUNET_CONTAINER_MultiHashMap * messages
union GNUNET_MESSENGER_EpochIdentifier identifier
struct GNUNET_MESSENGER_Epoch * epoch
union GNUNET_MESSENGER_EpochIdentifier identifier
struct GNUNET_MESSENGER_Room * room
struct GNUNET_HashCode event
The hash of the linked announcement or group message event.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the announcement in an epoch.
struct GNUNET_CRYPTO_EcdhePublicKey key
The public key to receive access.
struct GNUNET_HashCode event
The hash of the linked announcement message event.
struct GNUNET_MESSENGER_MessageAnnouncement announcement
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_MESSENGER_MessageLeave leave
struct GNUNET_MESSENGER_MessageAccess access
struct GNUNET_MESSENGER_MessageAppeal appeal
struct GNUNET_MESSENGER_MessageJoin join
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_HashCode epoch
The previous epoch the message was sent from.
struct GNUNET_HashCode epoch
The previous epoch the message was sent from.
struct GNUNET_HashCode epochs[2]
The previous epochs the message was sent from.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
An epoch identifier unifies an epoch identifier code and its 256bit hash representation.
struct GNUNET_MESSENGER_EpochIdentifierCode code