GNUnet 0.27.0
 
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 identifier,
44 sizeof (*identifier));
45
46 identifier->code.group_bit = 0;
47 identifier->code.level_bits = 0;
48}
49
50
55 previous,
57{
58 const struct GNUNET_CRYPTO_SymmetricSessionKey *previous_key;
59
60 GNUNET_assert ((announcement) && (previous) && (key));
61
62 previous_key = get_epoch_announcement_key (previous);
63
64 if (! previous_key)
65 return GNUNET_SYSERR;
66
68 key,
69 sizeof (*key),
72 previous_key,
73 sizeof (*previous_key),
76 return GNUNET_SYSERR;
77 else
78 return GNUNET_OK;
79}
80
81
87{
89 const struct GNUNET_MESSENGER_EpochAnnouncement *previous;
90
92
94
95 if (! announcement)
96 return NULL;
97
99
100 if ((GNUNET_YES == valid) && (previous) &&
101 (GNUNET_YES != previous->valid))
102 previous = NULL;
103
104 if (previous)
105 identifier = &(previous->identifier);
106
107 if (identifier)
108 GNUNET_memcpy (&(announcement->identifier), identifier,
109 sizeof (announcement->identifier));
110 else
112
113 GNUNET_assert (! announcement->identifier.code.group_bit);
114
115 announcement->announcement_expiration = GNUNET_TIME_absolute_get_zero_ ();
116 announcement->appeal = NULL;
117
118 announcement->appeal_task = NULL;
119
120 announcement->epoch = epoch;
123 announcement->shared_key = NULL;
124 announcement->query = NULL;
125
127
128 announcement->valid = GNUNET_YES;
129 announcement->stored = GNUNET_NO;
130
131 if (previous)
132 {
134
136 previous,
137 &key))
138 {
140
141 announcement->valid = previous->valid;
142 }
143 }
144
145 return announcement;
146}
147
148
149void
152{
154
155 if (announcement->messages)
157
158 if (announcement->membership)
160
161 if (announcement->shared_key)
162 GNUNET_free (announcement->shared_key);
163
164 if (announcement->query)
166
167 if (announcement->appeal_task)
169
170 if (announcement->appeal)
171 GNUNET_free (announcement->appeal);
172
174}
175
176
177uint32_t
185
186
187uint32_t
196
197
207
208
218
219
220static void
222{
224 struct GNUNET_HashCode event;
225
226 GNUNET_assert (cls);
227
228 announcement = cls;
229 announcement->appeal_task = NULL;
230
232 return;
233
235 GNUNET_YES))
236 return;
237
239}
240
241
242void
246{
247 struct GNUNET_TIME_Absolute timepoint;
248
250
252
253 if (! announcement->appeal)
255 else if (GNUNET_TIME_absolute_cmp (*(announcement->appeal), >, timepoint))
256 return;
257
258 GNUNET_memcpy (announcement->appeal, &timepoint, sizeof (timepoint));
259
260 if (announcement->appeal_task)
262
264 *(announcement->appeal),
268}
269
270
275{
276 struct GNUNET_TIME_Relative time;
277
279
280 if (! announcement->appeal)
281 return GNUNET_NO;
282
284
286 return GNUNET_NO;
287
288 return GNUNET_YES;
289}
290
291
292static void
295
296void
300 shared_key,
301 enum GNUNET_GenericReturnValue write_record)
302{
304
305 if ((GNUNET_NO == write_record) && (shared_key))
306 announcement->stored = GNUNET_YES;
307
308 if (announcement->shared_key)
309 return;
310
311 announcement->shared_key = GNUNET_new (struct
313
314 if (! announcement->shared_key)
315 return;
316
317 if (shared_key)
318 GNUNET_memcpy (announcement->shared_key, shared_key,
319 sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey));
320 else
322
324
325 if (GNUNET_YES != announcement->stored)
327
329}
330
331
340
341
346 const struct
348 previous)
349{
350 const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key;
352
353 GNUNET_assert ((announcement) && (previous));
354
356
357 if (! shared_key)
358 return GNUNET_SYSERR;
359
361 return GNUNET_SYSERR;
362
363 if (0 == GNUNET_memcmp (shared_key, &key))
364 return GNUNET_YES;
365 else
366 return GNUNET_NO;
367}
368
369
370static void
373 const struct GNUNET_HashCode *hash,
374 enum GNUNET_GenericReturnValue update)
375{
376 const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key;
377
378 GNUNET_assert ((announcement) && (hash));
379
381
382 GNUNET_assert ((shared_key) && (announcement->epoch) && (announcement->epoch->
383 room));
384
386 hash, shared_key, update))
388}
389
390
393 const struct GNUNET_HashCode *hash,
394 void *value)
395{
397
398 GNUNET_assert ((cls) && (hash));
399
400 announcement = cls;
401
403 return GNUNET_YES;
404}
405
406
407static void
420
421
422void
425 const struct GNUNET_MESSENGER_Message *
426 message,
427 const struct GNUNET_HashCode *hash)
428{
429 GNUNET_assert ((announcement) && (message) && (hash) &&
431
433 {
435 messages, hash))
436 return;
437
439 hash, NULL,
441 return;
442 }
443
445}
446
447
451 const struct GNUNET_HashCode *hash,
452 const struct GNUNET_MESSENGER_Message *
453 message,
454 struct GNUNET_MESSENGER_Contact *contact,
456{
458
459 GNUNET_assert ((announcement) && (hash) && (message) && (contact));
460
461 if (GNUNET_YES != is_epoch_member (announcement->epoch, contact))
462 return GNUNET_SYSERR;
463
465 hash,
466 message,
467 contact,
468 sent);
469
470 if (GNUNET_YES != result)
471 return result;
472
474 return GNUNET_YES;
475}
476
477
481 const struct GNUNET_HashCode *hash,
482 const struct GNUNET_MESSENGER_Message *
483 message,
484 struct GNUNET_MESSENGER_Contact *contact)
485{
486 GNUNET_assert ((announcement) && (hash) && (message) && (contact));
487
489 return GNUNET_SYSERR;
490
492 hash, contact);
493}
494
495
499 const struct GNUNET_MESSENGER_Contact *contact)
500{
502
503 return is_epoch_membership_member (announcement->membership, contact);
504}
505
506
511 struct GNUNET_HashCode *hash,
512 enum GNUNET_GenericReturnValue other)
513{
514 GNUNET_assert ((announcement) && (hash));
515
517 announcement->membership, hash, other);
518}
519
520
521void
524 const struct GNUNET_MESSENGER_Contact *
525 contact)
526{
527 const struct GNUNET_MESSENGER_Message *message;
528 struct GNUNET_MESSENGER_EpochAnnouncement *previous;
529 struct GNUNET_MESSENGER_Epoch *epoch;
530
532
533 if (GNUNET_NO == announcement->valid)
534 return;
535
536 if ((contact) && (GNUNET_YES != is_epoch_member (announcement->epoch,
537 contact)))
538 return;
539
540 announcement->valid = GNUNET_NO;
542
543 message = get_room_message (announcement->epoch->room,
544 &(announcement->epoch->hash));
545
546 if (! message)
547 goto skip_traversal;
548
549 switch (message->header.kind)
550 {
552 epoch = get_room_epoch (
553 announcement->epoch->room, &(message->body.join.epoch), GNUNET_NO);
554
555 if (epoch)
556 previous = get_epoch_announcement (
557 epoch, &(announcement->identifier), GNUNET_SYSERR);
558 else
559 previous = NULL;
560 break;
562 epoch = get_room_epoch (
563 announcement->epoch->room, &(message->body.leave.epoch), GNUNET_NO);
564
565 if (epoch)
566 previous = get_epoch_announcement (
567 epoch, &(announcement->identifier), GNUNET_SYSERR);
568 else
569 previous = NULL;
570 break;
572 epoch = get_room_epoch (
573 announcement->epoch->room, &(message->body.merge.epochs[0]), GNUNET_NO);
574
575 if (epoch)
576 {
577 previous = get_epoch_announcement (
578 epoch, &(announcement->identifier), GNUNET_SYSERR);
579
580 if ((previous) &&
582 announcement)))
583 previous = NULL;
584 }
585 else
586 previous = NULL;
587
588 if (! previous)
589 {
590 epoch = get_room_epoch (
591 announcement->epoch->room, &(message->body.merge.epochs[1]), GNUNET_NO);
592
593 if (epoch)
594 previous = get_epoch_announcement (
595 epoch, &(announcement->identifier), GNUNET_SYSERR);
596 }
597 break;
598 default:
599 previous = NULL;
600 break;
601 }
602
603 if ((previous) &&
605 announcement)))
606 previous = NULL;
607
608 if (previous)
609 invalidate_epoch_announcement (previous, contact);
610
611skip_traversal:
612 if (announcement->epoch->main_announcement != announcement)
613 return;
614
615 announcement->epoch->main_announcement = get_epoch_announcement (
616 announcement->epoch, NULL, GNUNET_YES);
617}
618
619
622 )
623{
625 const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key;
627 struct GNUNET_MESSENGER_Message *message;
628
630
632
633 if (! key)
634 return GNUNET_SYSERR;
635
637 announcement->announcement_expiration);
638
640 return GNUNET_NO;
641
644
645 private_key = get_epoch_private_key (announcement->epoch,
646 timeout);
647
648 if (! private_key)
649 return GNUNET_SYSERR;
650
652
653 message = create_message_announcement (&(announcement->identifier),
654 private_key,
655 key,
656 timeout);
657
658 if (! message)
659 return GNUNET_SYSERR;
660
661 send_epoch_message (announcement->epoch, message);
662
663 announcement->announcement_expiration = GNUNET_TIME_absolute_add (
665
666 return GNUNET_OK;
667}
668
669
672 const struct GNUNET_HashCode *key,
673 void *value)
674{
675 struct GNUNET_HashCode *event;
676
677 GNUNET_assert ((cls) && (key));
678
679 event = cls;
680
681 GNUNET_memcpy (event, key, sizeof (*event));
682 return GNUNET_NO;
683}
684
685
689 const struct GNUNET_HashCode *event)
690{
691 const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key;
693 struct GNUNET_HashCode event_hash;
694 struct GNUNET_MESSENGER_Message *message;
695
697
699 private_key = get_epoch_private_key (announcement->epoch,
700 timeout);
701
702 if (! private_key)
703 return GNUNET_SYSERR;
704
706
707 if ((! event) ||
709 membership->members
710 , event)))
711 {
713 return GNUNET_SYSERR;
714
717 &event_hash);
718
719 event = &event_hash;
720 }
721
722 message = create_message_appeal (event,
723 private_key,
724 timeout);
725
726 if (! message)
727 return GNUNET_SYSERR;
728
730 send_epoch_message (announcement->epoch, message);
731 return GNUNET_OK;
732}
733
734
738 const struct GNUNET_HashCode *event)
739{
740 struct GNUNET_MESSENGER_Room *room;
742 const struct GNUNET_MESSENGER_Message *appeal_message;
743 const struct GNUNET_CRYPTO_EcdhePublicKey *public_key;
744 struct GNUNET_MESSENGER_Message *message;
745
746 GNUNET_assert ((announcement) && (event));
747
748 room = announcement->epoch->room;
750
751 if (! key)
752 return GNUNET_SYSERR;
753
754 appeal_message = get_room_message (room, event);
755
756 if (! appeal_message)
757 return GNUNET_SYSERR;
758
759 if (GNUNET_MESSENGER_KIND_APPEAL != appeal_message->header.kind)
760 return GNUNET_SYSERR;
761
763 membership->members,
764 &(appeal_message->
766 ))
767 return GNUNET_SYSERR;
768
769 public_key = &(appeal_message->body.appeal.key);
770 message = create_message_access (event,
771 public_key,
772 key);
773
774 if (! message)
775 return GNUNET_SYSERR;
776
777 send_epoch_message (announcement->epoch, message);
778 return GNUNET_OK;
779}
780
781
785{
787 struct GNUNET_MESSENGER_Message *message;
788
790
792
793 if (! key)
794 return GNUNET_SYSERR;
795
796 message = create_message_revolution (&(announcement->identifier),
797 key);
798
799 if (! message)
800 return GNUNET_SYSERR;
801
802 send_epoch_message (announcement->epoch, message);
803 return GNUNET_OK;
804}
805
806
811 const struct
813 const struct GNUNET_HashCode *event)
814{
815 struct GNUNET_MESSENGER_Room *room;
817 const struct GNUNET_MESSENGER_Message *announcement_message;
818 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
819 const struct GNUNET_CRYPTO_SymmetricSessionKey *group_key;
820 struct GNUNET_MESSENGER_Message *message;
821
822 GNUNET_assert ((announcement) && (group) && (event));
823
824 room = group->epoch->room;
826
827 if (! key)
828 return GNUNET_SYSERR;
829
830 if (! group->identifier.code.group_bit)
831 return GNUNET_SYSERR;
832
833 announcement_message = get_room_message (room, event);
834
835 if ((! announcement_message) ||
836 (GNUNET_MESSENGER_KIND_ANNOUNCEMENT != announcement_message->header.kind))
837 return GNUNET_SYSERR;
838
839 identifier = &(announcement_message->body.announcement.identifier);
840
841 if (0 != GNUNET_memcmp (&(announcement->identifier), identifier))
842 return GNUNET_SYSERR;
843
844 if (GNUNET_YES != verify_message_by_key (announcement_message, key))
845 return GNUNET_SYSERR;
846
847 group_key = get_epoch_group_key (group);
848
849 if (! group_key)
850 return GNUNET_SYSERR;
851
852 message = create_message_authorization (&(group->identifier),
853 event,
854 group_key,
855 key);
856
857 if (! message)
858 return GNUNET_SYSERR;
859
860 send_epoch_message (announcement->epoch, message);
861 return GNUNET_OK;
862}
863
864
865void
868 const struct GNUNET_MESSENGER_Message *message,
869 const struct GNUNET_HashCode *hash,
870 struct GNUNET_MESSENGER_Contact *sender,
872{
875
876 GNUNET_assert ((announcement) && (message) && (hash) && (sender));
877
879
880 if (key)
881 {
882 if (GNUNET_OK != verify_message_by_key (message, key))
883 return;
884
887 &(announcement->epoch->hash),
888 &(announcement->identifier),
889 sender);
890
893 {
895 return;
896 }
897 }
898
900 hash,
901 message,
902 sender,
903 sent))
904 return;
905
906 if ((GNUNET_YES != sent) &&
908 {
909 const struct GNUNET_MESSENGER_Contact *contact;
910
911 contact = get_handle_contact (
912 get_room_handle (announcement->epoch->room),
913 get_room_key (announcement->epoch->room));
914
916
918 get_message_timeout (message),
920 announcement->membership));
921 }
922 else if (announcement->epoch->main_group)
924 get_message_timeout (message),
925 get_epoch_group_position_factor (announcement->epoch->main_group));
926 else
928
929 delay_room_action (announcement->epoch->room, hash, timeout);
930}
931
932
933void
936 const struct GNUNET_MESSENGER_Message *
937 message,
938 const struct GNUNET_HashCode *hash,
939 struct GNUNET_MESSENGER_Contact *sender,
941{
943
944 GNUNET_assert ((announcement) && (message) && (hash) && (sender));
945
946 if (GNUNET_YES == is_room_public (announcement->epoch->room))
947 return;
948
949 if ((GNUNET_YES == sent) && (GNUNET_YES == announcement->valid))
951 announcement->epoch,
953
956 return;
957
958 timeout = get_message_timeout (message);
959
961 return;
962
964}
965
966
967void
970 const struct GNUNET_MESSENGER_Message *
971 message,
972 const struct GNUNET_HashCode *hash)
973{
974 const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key;
975 struct GNUNET_CRYPTO_HpkePrivateKey private_hpke;
976 struct GNUNET_CRYPTO_SymmetricSessionKey shared_key;
977 const struct GNUNET_MESSENGER_Message *appeal_message;
978
979 GNUNET_assert ((announcement) && (message) && (hash));
980
981 private_key = get_epoch_private_key (announcement->epoch,
983
984 if (! private_key)
985 {
987 "Private key for decrypting shared key is missing!\n");
988 return;
989 }
990 GNUNET_memcpy (&private_hpke.ecdhe_key,
991 private_key,
992 sizeof *private_key);
994 message,
995 &private_hpke,
996 &shared_key))
997 return;
998
1000 return;
1001
1003
1004 appeal_message = get_room_message (
1005 announcement->epoch->room,
1006 &(message->body.access.event));
1007
1008 if ((announcement->epoch->main_group) &&
1009 (appeal_message) &&
1010 (GNUNET_MESSENGER_KIND_APPEAL == appeal_message->header.kind) &&
1011 (GNUNET_YES == is_epoch_group_compatible (announcement->epoch->main_group,
1012 announcement->epoch)) &&
1014 announcement->epoch->main_group, announcement)))
1016 announcement, announcement->epoch->main_group,
1017 &(appeal_message->body.appeal.event));
1018
1020}
1021
1022
1023static void
1025 enum GNUNET_ErrorCode ec)
1026{
1028
1029 GNUNET_assert (cls);
1030
1031 announcement = cls;
1032
1033 if (GNUNET_EC_NONE != ec)
1035 "Error writing epoch key record: %d\n", (int) ec);
1036
1037 announcement->query = NULL;
1038}
1039
1040
1041void
1044 enum GNUNET_GenericReturnValue deleted)
1045{
1046 const struct GNUNET_MESSENGER_Handle *handle;
1047 const struct GNUNET_HashCode *hash;
1048 const struct GNUNET_ShortHashCode *identifier;
1049 const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key;
1050
1051 GNUNET_assert ((announcement) && (announcement->epoch));
1052
1053 handle = get_room_handle (announcement->epoch->room);
1054
1055 if (! handle)
1056 return;
1057
1058 hash = &(announcement->epoch->hash);
1059 identifier = &(announcement->identifier.hash);
1060
1061 if (GNUNET_YES == deleted)
1062 {
1063 shared_key = NULL;
1064 }
1065 else
1066 {
1067 shared_key = announcement->shared_key;
1068
1069 if (! shared_key)
1070 return;
1071 }
1072
1074 handle, announcement->epoch->room,
1075 hash, identifier, shared_key,
1076 GNUNET_YES == announcement->valid?
1081 &(announcement->query));
1082}
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_symmetric_create_session_key(struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Create a new random session key.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#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.
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...
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...
static enum GNUNET_GenericReturnValue derive_epoch_announcement_key(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_EpochAnnouncement *previous, struct GNUNET_CRYPTO_SymmetricSessionKey *key)
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...
const struct GNUNET_CRYPTO_SymmetricSessionKey * get_epoch_announcement_key(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns the secret key of a given epoch announcement or NULL.
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.
void set_epoch_announcement_key(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key, enum GNUNET_GenericReturnValue write_record)
Sets the secret key of a given epoch announcement to a shared 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.
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.
const struct GNUNET_CRYPTO_SymmetricSessionKey * 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_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_SymmetricSessionKey *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...
enum GNUNET_GenericReturnValue extract_access_message_key(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_HpkePrivateKey *key, struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key)
Extracts the shared epoch or group key from an access message using the private ephemeral key from an...
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 verify_message_by_key(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_SymmetricSessionKey *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_SymmetricSessionKey *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_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_SymmetricSessionKey *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_authorization(const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_SymmetricSessionKey *group_key, const struct GNUNET_CRYPTO_SymmetricSessionKey *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_access(const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_EcdhePublicKey *public_key, const struct GNUNET_CRYPTO_SymmetricSessionKey *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 update_room_secret_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_SymmetricSessionKey *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...
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 ...
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