GNUnet 0.27.0
 
Loading...
Searching...
No Matches
messenger_api_handle.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--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 */
26
28#include "gnunet_common.h"
30#include "gnunet_util_lib.h"
31#include "messenger_api_epoch.h"
35#include "messenger_api_room.h"
36#include "messenger_api_util.h"
37
38#include <ctype.h>
39
42 const struct GNUNET_HashCode *secret,
44 void *msg_cls)
45{
47
49
51
52 handle->config = config;
53 handle->mq = NULL;
54
56 handle->config,
58 "MESSENGER_GROUP_KEYS");
59
60 if (handle->config)
61 handle->namestore = GNUNET_NAMESTORE_connect (handle->config);
62
63 if (secret)
64 GNUNET_memcpy (&(handle->secret), secret, sizeof (handle->secret));
65 else
66 memset (&(handle->secret), 0, sizeof (handle->secret));
67
68 handle->msg_callback = msg_callback;
69 handle->msg_cls = msg_cls;
70
71 handle->name = NULL;
72 handle->key = NULL;
73 handle->pubkey = NULL;
74
75 handle->reconnect_time = GNUNET_TIME_relative_get_zero_ ();
76 handle->reconnect_task = NULL;
77
78 handle->key_monitor = NULL;
79
81
83
84 return handle;
85}
86
87
90 const struct GNUNET_HashCode *key,
91 void *value)
92{
93 struct GNUNET_MESSENGER_Room *room;
94
96
97 room = value;
98
99 destroy_room (room);
100 return GNUNET_YES;
101}
102
103
104void
106{
108
110
111 if (handle->rooms)
112 {
114 handle->rooms, iterate_destroy_room, NULL);
115
117 }
118
119 if (handle->key_monitor)
121
122 if (handle->reconnect_task)
123 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
124
125 if (handle->mq)
127
128 if (handle->namestore)
130
131 if (handle->name)
132 GNUNET_free (handle->name);
133
134 if (handle->key)
135 GNUNET_free (handle->key);
136
137 if (handle->pubkey)
138 GNUNET_free (handle->pubkey);
139
141}
142
143
144void
146 const char *name)
147{
149
150 if (handle->name)
151 GNUNET_free (handle->name);
152
153 handle->name = name ? GNUNET_strdup (name) : NULL;
154}
155
156
157const char*
159{
161
162 return handle->name;
163}
164
165
166static void
167cb_key_error (void *cls)
168{
170 const char *name;
171
172 GNUNET_assert (cls);
173
174 handle = cls;
176
177 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error on monitoring records: %s\n",
178 name);
179}
180
181
182static void
184 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone,
186{
187 struct GNUNET_MESSENGER_Room *room;
188 const struct GNUNET_HashCode *room_key;
189 struct GNUNET_MESSENGER_Epoch *epoch;
190 union GNUNET_MESSENGER_EpochIdentifier identifier;
191 enum GNUNET_GenericReturnValue valid;
192 struct GNUNET_CRYPTO_SymmetricSessionKey shared_key;
193
194 GNUNET_assert ((handle) && (zone) && (record));
195
196 room = get_handle_room (handle, &(record->key), GNUNET_YES);
197
198 if (! room)
199 return;
200
201 room_key = get_room_key (room);
202
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitor epoch key record of room: %s\n",
205
206 epoch = get_room_epoch (room, &(record->hash), GNUNET_NO);
207
208 if (! epoch)
209 return;
210
212 &identifier,
213 &(record->identifier),
214 sizeof (record->identifier));
216 GNUNET_NO);
217
218 {
221 int32_t checksum;
222
224 &skey, sizeof (skey),
227 &(handle->secret),
228 sizeof (handle->secret),
232 GNUNET_CRYPTO_kdf_arg_auto (&identifier.hash)))
233 return;
234
236 &iv, sizeof (iv),
239 &skey,
240 sizeof (skey),
243 GNUNET_CRYPTO_kdf_arg_auto (&identifier.hash)))
244 return;
245
246 if (-1 == GNUNET_CRYPTO_symmetric_decrypt (&(record->shared_key),
247 sizeof (record->shared_key),
248 &skey,
249 &iv[0],
250 &shared_key))
251 return;
252
253 if (-1 == GNUNET_CRYPTO_symmetric_decrypt (&(record->checksum),
254 sizeof (record->checksum),
255 &skey,
256 &iv[1],
257 &checksum))
258 return;
259
260 GNUNET_CRYPTO_zero_keys (&skey, sizeof (skey));
261
262 if (checksum != GNUNET_CRYPTO_crc32_n (&shared_key, sizeof (shared_key)))
263 {
265 "Epoch key record failed checksum: %s\n",
266 GNUNET_h2s (&(record->key)));
267 goto clear_key;
268 }
269 }
270
271 if (identifier.code.group_bit)
272 {
273 struct GNUNET_MESSENGER_EpochGroup *group;
274
276
277 if (! group)
278 goto clear_key;
279
281 }
282 else
283 {
285
287
288 if (! announcement)
289 goto clear_key;
290
292 }
293
294clear_key:
296}
297
298
299static void
302 *zone,
304 *record)
305{
306 struct GNUNET_MESSENGER_Room *room;
307 const struct GNUNET_HashCode *room_key;
308 struct GNUNET_CRYPTO_HpkePrivateKey encryption_key;
309
310 GNUNET_assert ((handle) && (zone) && (record));
311
312 room = get_handle_room (handle, &(record->key), GNUNET_YES);
313
314 if (! room)
315 return;
316
317 room_key = get_room_key (room);
318
320 "Monitor encryption key record of room: %s\n",
322
323 {
326 uint8_t encryption_key_data[GNUNET_MESSENGER_ENCRYPTION_KEY_DATA_BYTES];
327 size_t encryption_key_len;
328 int32_t encrypted_key_checksum;
329
331 &skey, sizeof (skey),
334 &(handle->secret),
335 sizeof (handle->secret),
338 GNUNET_CRYPTO_kdf_arg (record->nonce_data,
339 sizeof (record->nonce_data))))
340 return;
341
343 &iv, sizeof (iv),
346 &skey,
347 sizeof skey,
349 GNUNET_CRYPTO_kdf_arg (record->nonce_data, sizeof (record->nonce_data))))
350 return;
351
352
353 if (-1 == GNUNET_CRYPTO_symmetric_decrypt (record->encrypted_key_data,
354 sizeof (encryption_key_data),
355 &skey,
356 &iv[0],
357 encryption_key_data))
358 return;
359
360 if (-1 == GNUNET_CRYPTO_symmetric_decrypt (&(record->encrypted_key_checksum)
361 ,
362 sizeof (encrypted_key_checksum),
363 &skey,
364 &iv[1],
365 &encrypted_key_checksum))
366 return;
367
368 GNUNET_CRYPTO_zero_keys (&skey, sizeof (skey));
369
370 if (encrypted_key_checksum != GNUNET_CRYPTO_crc32_n (encryption_key_data,
371 sizeof (
372 encryption_key_data))
373 )
374 {
376 "Encryption key record failed checksum: %s\n",
377 GNUNET_h2s (&(record->key)));
378 return;
379 }
380
382 encryption_key_data, record->encrypted_key_length, &encryption_key, &
383 encryption_key_len))
384 return;
385
386 if (encryption_key_len < record->encrypted_key_length)
387 goto clear_key;
388 }
389
390 add_room_encryption_key (room, &encryption_key);
391
392clear_key:
393 GNUNET_CRYPTO_hpke_sk_clear (&encryption_key);
394}
395
396
397static void
398cb_key_monitor (void *cls,
399 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone,
400 const char *label,
401 unsigned int rd_count,
402 const struct GNUNET_GNSRECORD_Data *rd,
403 struct GNUNET_TIME_Absolute expiry)
404{
406
408 (cls) && (zone) && (label) && (rd_count) && (rd));
409
410 handle = cls;
411
412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitor record with label: %s\n",
413 label);
414
415 switch (rd->record_type)
416 {
418 if ((sizeof (struct GNUNET_MESSENGER_RoomEpochKeyRecord) == rd->data_size)
419 && (rd->data))
421
422 break;
424 if ((sizeof (struct GNUNET_MESSENGER_EncryptionKeyRecord) == rd->data_size)
425 && (rd->data))
427
428 break;
429 default:
430 break;
431 }
432
434}
435
436
440 void *value)
441{
443
445
447
448 if ((cls) && (GNUNET_YES != announcement->stored))
450 else if (! cls)
451 announcement->stored = GNUNET_NO;
452
453 return GNUNET_YES;
454}
455
456
460 void *value)
461{
462 struct GNUNET_MESSENGER_EpochGroup *group;
463
465
466 group = value;
467
468 if ((cls) && (GNUNET_YES != group->stored))
470 else if (! cls)
471 group->stored = GNUNET_NO;
472
473 return GNUNET_YES;
474}
475
476
479 GNUNET_UNUSED const struct GNUNET_HashCode *key,
480 void *value)
481{
482 const struct GNUNET_MESSENGER_Epoch *epoch;
483
485
486 epoch = value;
487
491 cls);
492 return GNUNET_YES;
493}
494
495
498 GNUNET_UNUSED const struct GNUNET_HashCode *key,
499 void *value)
500{
501 const struct GNUNET_MESSENGER_Room *room;
502
504
505 room = value;
506
508 room->epochs,
510 cls);
511 return GNUNET_YES;
512}
513
514
515static void
516cb_key_sync (void *cls)
517{
519 const char *name;
520
521 GNUNET_assert (cls);
522
523 handle = cls;
525
527 "Syncing keys from records completed: %s\n",
528 name);
529
532}
533
534
535void
538{
540
541 if (handle->key_monitor)
542 {
544 handle->key_monitor = NULL;
545 }
546
547 if (! key)
548 {
549 if (handle->key)
550 GNUNET_free (handle->key);
551
552 if (handle->pubkey)
553 GNUNET_free (handle->pubkey);
554
555 handle->key = NULL;
556 handle->pubkey = NULL;
557 return;
558 }
559
560 if (! handle->key)
562
563 if (! handle->pubkey)
565
566 GNUNET_memcpy (handle->key, key, sizeof(*key));
568
569 // Resets epoch and group keys as not stored yet
571 handle->rooms, it_room_store_keys, NULL);
572
574 handle->config,
575 handle->key,
578 handle,
580 handle,
582 handle,
584}
585
586
589{
591
592 if (handle->key)
593 return handle->key;
594
596}
597
598
601{
603
604 if (handle->pubkey)
605 return handle->pubkey;
606
607 return get_anonymous_public_key ();
608}
609
610
613{
615
616 return &(handle->contact_store);
617}
618
619
622 const struct GNUNET_HashCode *key)
623{
624 struct GNUNET_MESSENGER_Room *room;
625 const struct GNUNET_ShortHashCode *contact_id;
626
627 GNUNET_assert ((handle) && (key));
628
630
631 if (! room)
632 return NULL;
633
634 contact_id = get_room_sender_id (room);
635
636 if (! contact_id)
637 return NULL;
638
639 {
641 get_context_from_member (key, contact_id, &context);
642
644 &context,
646 }
647}
648
649
650void
652 const struct GNUNET_HashCode *key)
653{
654 struct GNUNET_MESSENGER_Room *room;
655
656 GNUNET_assert ((handle) && (key));
657
659
660 if (room)
661 room->opened = GNUNET_YES;
662}
663
664
665void
667 const struct GNUNET_PeerIdentity *door,
668 const struct GNUNET_HashCode *key)
669{
670 struct GNUNET_MESSENGER_Room *room;
671
672 GNUNET_assert ((handle) && (door) && (key));
673
675
676 if (room)
677 add_to_list_tunnels (&(room->entries), door, NULL);
678}
679
680
681void
683 const struct GNUNET_HashCode *key)
684{
685 struct GNUNET_MESSENGER_Room *room;
686
687 GNUNET_assert ((handle) && (key));
688
690
692 handle->rooms, key, room)))
693 destroy_room (room);
694}
695
696
699 const struct GNUNET_HashCode *key,
701{
702 struct GNUNET_MESSENGER_Room *room;
703
704 GNUNET_assert ((handle) && (key));
705
707
708 if ((! room) && (GNUNET_YES == init))
709 {
711 GNUNET_memcpy (&(room_key.hash), key, sizeof (struct GNUNET_HashCode));
712
713 room = create_room (handle, &room_key);
714
716 handle->rooms, key, room,
718 {
719 destroy_room (room);
720 return NULL;
721 }
722 }
723
724 return room;
725}
726
727
730 const struct GNUNET_MESSENGER_Room *room,
731 const struct GNUNET_HashCode *hash,
732 const struct GNUNET_ShortHashCode *identifier,
734 shared_key,
735 uint32_t flags,
737 void *cont_cls,
738 struct GNUNET_NAMESTORE_QueueEntry **query)
739{
740 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone;
742 const struct GNUNET_HashCode *room_key;
745 char *label;
746
747 GNUNET_assert ((handle) && (room) && (hash) && (identifier) && (query));
748
749 if (! handle->namestore)
750 return GNUNET_SYSERR;
751
752 zone = get_handle_key (handle);
753
754 if (! zone)
755 return GNUNET_SYSERR;
756
758
759 memset (&data, 0, sizeof (data));
760 memset (&record, 0, sizeof (record));
761
762 room_key = get_room_key (room);
763
764 if (shared_key)
765 {
768 int32_t checksum;
769
771 &skey, sizeof (skey),
774 &(handle->secret),
775 sizeof (handle->secret),
779 GNUNET_CRYPTO_kdf_arg_auto (identifier)))
780 return GNUNET_SYSERR;
781
783 &iv, sizeof (iv),
786 &skey,
787 sizeof (skey),
790 GNUNET_CRYPTO_kdf_arg_auto (identifier)))
791 return GNUNET_SYSERR;
792
793 GNUNET_memcpy (&(record.key), room_key, sizeof (record.key));
794 GNUNET_memcpy (&(record.hash), hash, sizeof (record.hash));
796 &(record.identifier),
797 identifier,
798 sizeof (record.identifier));
799
800 if (-1 == GNUNET_CRYPTO_symmetric_encrypt (shared_key,
801 sizeof (*shared_key),
802 &skey,
803 &iv[0],
804 &(record.shared_key)))
805 return GNUNET_SYSERR;
806
807 checksum = GNUNET_CRYPTO_crc32_n (shared_key, sizeof (*shared_key));
808
809 if (-1 == GNUNET_CRYPTO_symmetric_encrypt (&checksum,
810 sizeof (checksum),
811 &skey,
812 &iv[1],
813 &(record.checksum)))
814 return GNUNET_SYSERR;
815
816 record.flags = flags;
817
819 data.data = &record;
820 data.data_size = sizeof (record);
821 data.expiration_time = expiration.abs_value_us;
823
824 GNUNET_CRYPTO_zero_keys (&skey, sizeof (skey));
825 }
826
827 {
828 char lower_key [9];
829 char lower_hash [9];
830 char lower_id [7];
831 const char *s;
832
833 memset (lower_key, 0, sizeof (lower_key));
834 memset (lower_hash, 0, sizeof (lower_hash));
835 memset (lower_id, 0, sizeof (lower_id));
836
837 s = GNUNET_h2s (room_key);
838 for (size_t i=0; '\0' != s[i]; i++)
839 {
840 GNUNET_assert (i < sizeof (lower_key));
841 lower_key[i] = (char) tolower ((int) s[i]);
842 }
843 s = GNUNET_h2s (hash);
844 for (size_t i=0; '\0' != s[i]; i++)
845 {
846 GNUNET_assert (i < sizeof (lower_hash));
847 lower_hash[i] = (char) tolower ((int) s[i]);
848 }
849
850 s = GNUNET_sh2s (identifier);
851 for (size_t i=0; '\0' != s[i]; i++)
852 {
853 GNUNET_assert (i < sizeof (lower_id));
854 lower_id[i] = (char) tolower ((int) s[i]);
855 }
856
858 &label,
859 "epoch_key_%s%s%s",
860 lower_key,
861 lower_hash,
862 lower_id);
863 }
864
865 if (! label)
866 return GNUNET_SYSERR;
867
868 if (*query)
870
872 "Store epoch key record with label: %s [%d]\n",
873 label,
874 shared_key? 1 : 0);
875
877 handle->namestore,
878 zone,
879 label,
880 shared_key? 1 : 0,
881 &data,
882 cont,
883 cont_cls);
884
885 GNUNET_free (label);
886 return GNUNET_OK;
887}
888
889
892 const struct GNUNET_MESSENGER_Room *room,
894 *encryption_key,
896 void *cont_cls,
897 struct GNUNET_NAMESTORE_QueueEntry **query)
898{
899 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone;
901 const struct GNUNET_HashCode *room_key;
904 struct GNUNET_HashCode nonce_hash;
905 char *label;
906
907 GNUNET_assert ((handle) && (room) && (encryption_key) && (query));
908
909 if (! handle->namestore)
910 return GNUNET_SYSERR;
911
912 zone = get_handle_key (handle);
913
914 if (! zone)
915 return GNUNET_SYSERR;
916
918 room_key = get_room_key (room);
919
920 memset (&data, 0, sizeof (data));
921
922 {
925 uint8_t encryption_key_data [GNUNET_MESSENGER_ENCRYPTION_KEY_DATA_BYTES];
926 int32_t encryption_key_checksum;
927 size_t encryption_key_len;
928 ssize_t offset;
929
930 encryption_key_len = GNUNET_CRYPTO_hpke_sk_get_length (encryption_key);
931
932 if ((0 > encryption_key_len) || (encryption_key_len >
934 )
935 return GNUNET_SYSERR;
936
937 GNUNET_memcpy (&(record.key), room_key, sizeof (record.key));
940
942 &skey, sizeof (skey),
945 &(handle->secret),
946 sizeof (handle->secret),
949 GNUNET_CRYPTO_kdf_arg (record.nonce_data,
950 sizeof (record.nonce_data))))
951 return GNUNET_SYSERR;
952
954 &iv, sizeof (iv),
957 &skey,
958 sizeof (skey),
960 GNUNET_CRYPTO_kdf_arg (record.nonce_data,
961 sizeof record.nonce_data)))
962 return GNUNET_SYSERR;
963
965 encryption_key, encryption_key_data, encryption_key_len);
966
967 if (offset < 0)
968 return GNUNET_SYSERR;
969
970 if (offset < encryption_key_len)
971 encryption_key_len = offset;
972
973 record.encrypted_key_length = encryption_key_len;
974
976 + encryption_key_len,
977 sizeof (encryption_key_data)
978 - encryption_key_len);
979
980 encryption_key_checksum = GNUNET_CRYPTO_crc32_n (encryption_key_data,
981 sizeof (encryption_key_data
982 ));
983
984 if (-1 == GNUNET_CRYPTO_symmetric_encrypt (encryption_key_data,
985 sizeof (encryption_key_data),
986 &skey,
987 &iv[0],
988 record.encrypted_key_data))
989 return GNUNET_SYSERR;
990
991 if (-1 == GNUNET_CRYPTO_symmetric_encrypt (&encryption_key_checksum,
992 sizeof (encryption_key_checksum),
993 &skey,
994 &iv[1],
995 &(record.encrypted_key_checksum))
996 )
997 return GNUNET_SYSERR;
998
999 GNUNET_CRYPTO_hash (record.nonce_data, sizeof (record.nonce_data), &
1000 nonce_hash);
1001
1003 data.data = &record;
1004 data.data_size = sizeof (record);
1005 data.expiration_time = expiration.abs_value_us;
1007
1008 GNUNET_CRYPTO_zero_keys (&skey, sizeof (skey));
1009 }
1010
1011 {
1012 char *lower_key;
1013 char *lower_nonce;
1014 const char *s;
1015
1016 s = GNUNET_h2s (room_key);
1017 lower_key = GNUNET_STRINGS_utf8_tolower (s);
1018 if (! lower_key)
1019 lower_key = GNUNET_strdup (s);
1020
1021 s = GNUNET_h2s (&nonce_hash);
1022 lower_nonce = GNUNET_STRINGS_utf8_tolower (s);
1023 if (! lower_nonce)
1024 lower_nonce = GNUNET_strdup (s);
1025
1027 &label,
1028 "encryption_key_%s%s",
1029 lower_key,
1030 lower_nonce);
1031
1032 if (lower_nonce)
1033 GNUNET_free (lower_nonce);
1034 if (lower_key)
1035 GNUNET_free (lower_key);
1036 }
1037
1038 if (! label)
1039 return GNUNET_SYSERR;
1040
1041 if (*query)
1042 GNUNET_NAMESTORE_cancel (*query);
1043
1045 "Store encryption key record with label: %s [%d]\n",
1046 label,
1047 encryption_key? 1 : 0);
1048
1050 handle->namestore,
1051 zone,
1052 label,
1053 encryption_key? 1 : 0,
1054 &data,
1055 cont,
1056 cont_cls);
1057
1058 GNUNET_free (label);
1059 return GNUNET_OK;
1060}
#define GNUNET_GNSRECORD_TYPE_MESSENGER_ENCRYPTION_KEY
Record type to store encryption keys used in messenger rooms.
#define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_EPOCH_KEY
Record type to store epoch keys from a messenger room.
static char * init
Set to the name of a service to start.
Definition gnunet-arm.c:73
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static pa_context * context
Pulseaudio context.
const struct GNUNET_CONFIGURATION_Handle * config
char * room_key
static char * name
Name (label) of the records to list.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static char * value
Value of the record to add/remove.
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...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
ssize_t GNUNET_CRYPTO_symmetric_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Decrypt a given block using a symmetric sessionkey.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
@ GNUNET_GNSRECORD_FILTER_NONE
No filter flags set.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:41
int32_t GNUNET_CRYPTO_crc32_n(const void *buf, size_t len)
Compute the CRC32 checksum for the first len bytes of the buffer.
Definition crypto_crc.c:99
#define GNUNET_CRYPTO_hkdf_gnunet(result, out_len, xts, xts_len, skm, skm_len,...)
A peculiar HKDF instantiation that tried to mimic Truncated NMAC.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from 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.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the 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...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_key_get_public(const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Retrieves the public key representation of a private key.
#define GNUNET_log(kind,...)
ssize_t GNUNET_CRYPTO_hpke_sk_get_length(const struct GNUNET_CRYPTO_HpkePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_HpkePrivateKey.
ssize_t GNUNET_CRYPTO_write_hpke_sk_to_buffer(const struct GNUNET_CRYPTO_HpkePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_HpkePrivateKey to a compact buffer.
void GNUNET_CRYPTO_hpke_sk_clear(struct GNUNET_CRYPTO_HpkePrivateKey *key)
Clear memory that was used to store a GNUNET_CRYPTO_HpkePrivateKey.
#define GNUNET_CRYPTO_kdf_arg_auto(d)
#define GNUNET_UNUSED
gcc-ism to document unused arguments
#define GNUNET_CRYPTO_kdf_arg(d, s)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_hpke_sk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_HpkePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_HpkePrivateKey from a compact buffer.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSENGER_ENCRYPTION_KEY_DATA_BYTES
void(* GNUNET_MESSENGER_MessageCallback)(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Contact *recipient, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
Method called whenever a message is sent or received from a room.
#define GNUNET_MESSENGER_ENCRYPTION_KEY_NONCE_BYTES
#define GNUNET_MESSENGER_SERVICE_NAME
Identifier of GNUnet MESSENGER Service.
@ GNUNET_MESSENGER_FLAG_EPOCH_VALID
The valid flag.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition mq.c:700
void(* GNUNET_NAMESTORE_ContinuationWithStatus)(void *cls, enum GNUNET_ErrorCode ec)
Continuation called to notify client about result of the operation.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start2(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
Begin monitoring a zone for changes.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
void GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
void GNUNET_NAMESTORE_zone_monitor_next(struct GNUNET_NAMESTORE_ZoneMonitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_NAMESTORE_zone_monitor_start for the next record(s).
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
char * GNUNET_STRINGS_utf8_tolower(const char *input)
Convert the utf-8 input string to lower case.
Definition strings.c:475
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition time.c:133
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_(void)
Return "forever".
Definition time.c:205
void get_context_from_member(const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id, struct GNUNET_HashCode *context)
Calculates the context hash of a member in a room and returns it.
void clear_contact_store(struct GNUNET_MESSENGER_ContactStore *store)
Clears a contact store, wipes its content and deallocates its memory.
void init_contact_store(struct GNUNET_MESSENGER_ContactStore *store)
Initializes a contact store as fully empty.
struct GNUNET_MESSENGER_Contact * get_store_contact(struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_CRYPTO_BlindablePublicKey *pubkey)
Returns a contact using a specific public key.
struct GNUNET_MESSENGER_EpochGroup * get_epoch_group(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Returns the epoch group of a given epoch using a specific unique identifier or NULL.
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 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.
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 ...
void write_epoch_group_record(struct GNUNET_MESSENGER_EpochGroup *group, enum GNUNET_GenericReturnValue deleted)
Writes/Deletes the GNS record of a given epoch group depending on a provided flag that states whether...
void set_epoch_group_key(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key, enum GNUNET_GenericReturnValue write_record)
Sets the secret key of a given epoch group to a shared key.
void entry_handle_room_at(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Adds a tunnel for a room known to a handle identified by a given key to a list of opened connections.
static enum GNUNET_GenericReturnValue iterate_destroy_room(void *cls, const struct GNUNET_HashCode *key, void *value)
static void cb_key_monitor(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
struct GNUNET_MESSENGER_ContactStore * get_handle_contact_store(struct GNUNET_MESSENGER_Handle *handle)
Returns the used contact store of a given handle.
void open_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Marks a room known to a handle identified by a given key as open.
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.
static void read_handle_encryption_key(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const struct GNUNET_MESSENGER_EncryptionKeyRecord *record)
const struct GNUNET_CRYPTO_BlindablePublicKey * get_handle_pubkey(const struct GNUNET_MESSENGER_Handle *handle)
Returns the public key of a given handle.
enum GNUNET_GenericReturnValue store_handle_encryption_key(const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_CRYPTO_HpkePrivateKey *encryption_key, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls, struct GNUNET_NAMESTORE_QueueEntry **query)
Stores an encryption_key for a given room from a handle.
const char * get_handle_name(const struct GNUNET_MESSENGER_Handle *handle)
Returns the current name of a given handle or NULL if no valid name was assigned yet.
void destroy_handle(struct GNUNET_MESSENGER_Handle *handle)
Destroys a handle and frees its memory fully from the client API.
struct GNUNET_MESSENGER_Handle * create_handle(const struct GNUNET_CONFIGURATION_Handle *config, const struct GNUNET_HashCode *secret, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
Creates and allocates a new handle using a given configuration, a secret and a custom message callbac...
static void read_handle_epoch_key(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const struct GNUNET_MESSENGER_RoomEpochKeyRecord *record)
static enum GNUNET_GenericReturnValue it_epoch_store_keys(void *cls, const struct GNUNET_HashCode *key, void *value)
void close_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Destroys and so implicitly closes a room known to a handle identified by a given key.
static void cb_key_error(void *cls)
void set_handle_name(struct GNUNET_MESSENGER_Handle *handle, const char *name)
Sets the name of a handle to a specific name.
static enum GNUNET_GenericReturnValue it_room_store_keys(void *cls, const struct GNUNET_HashCode *key, void *value)
static void cb_key_sync(void *cls)
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...
static enum GNUNET_GenericReturnValue it_group_store_key(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue it_announcement_store_key(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
const struct GNUNET_CRYPTO_BlindablePrivateKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the private key of a given handle.
void set_handle_key(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Sets the keypair of a given handle to the keypair of a specific private key.
struct GNUNET_MESSENGER_Room * get_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key, enum GNUNET_GenericReturnValue init)
Returns the room known to a handle identified by a given key.
void add_to_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HashCode *hash)
Adds a specific peer from a tunnel to the end of the list.
#define GNUNET_MESSENGER_SALT_ENCRYPTION_KEY
#define GNUNET_MESSENGER_SALT_EPOCH_KEY
#define GNUNET_MESSENGER_SALT_EPOCH_IV
#define GNUNET_MESSENGER_SALT_ENCRYPTION_IV
struct GNUNET_MESSENGER_Room * create_room(struct GNUNET_MESSENGER_Handle *handle, const union GNUNET_MESSENGER_RoomKey *key)
Creates and allocates a new room for a handle with a given key for the client API.
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 add_room_encryption_key(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_CRYPTO_HpkePrivateKey *key)
Adds an encryption key by the current user to memory of a given room and will be placed to the second...
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_Room *room)
Return a the hash representation of a given room.
const struct GNUNET_ShortHashCode * get_room_sender_id(const struct GNUNET_MESSENGER_Room *room)
Returns the member id of the room's sender.
void destroy_room(struct GNUNET_MESSENGER_Room *room)
Destroys a room and frees its memory fully from the client API.
const struct GNUNET_CRYPTO_BlindablePrivateKey * get_anonymous_private_key(void)
Returns the private identity key of GNUNET_IDENTITY_ego_get_anonymous() without recalculating it ever...
const struct GNUNET_CRYPTO_BlindablePublicKey * get_anonymous_public_key(void)
Returns the public identity key of GNUNET_IDENTITY_ego_get_anonymous() without recalculating it every...
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
A public key used for decryption.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
A 512-bit hashcode.
An encryption key record specifies an encryption key for a given room that can be identified via a gi...
struct GNUNET_CRYPTO_SymmetricSessionKey * shared_key
union GNUNET_MESSENGER_EpochIdentifier identifier
enum GNUNET_GenericReturnValue valid
enum GNUNET_GenericReturnValue stored
struct GNUNET_CRYPTO_SymmetricSessionKey * shared_key
struct GNUNET_MESSENGER_Epoch * epoch
union GNUNET_MESSENGER_EpochIdentifier identifier
struct GNUNET_CONTAINER_MultiShortmap * announcements
struct GNUNET_CONTAINER_MultiShortmap * groups
struct GNUNET_HashCode hash
GNUNET_MESSENGER_MessageCallback msg_callback
struct GNUNET_HashCode secret
A room epoch key record specifies an epoch key for a given room that can be identified via a given ke...
struct GNUNET_ShortHashCode identifier
The short hash identifying the epoch or group key.
struct GNUNET_CRYPTO_SymmetricSessionKey shared_key
The encrypted shared epoch or group key in the room.
struct GNUNET_HashCode hash
The hash identifying the epoch.
enum GNUNET_GenericReturnValue opened
struct GNUNET_CONTAINER_MultiHashMap * epochs
struct GNUNET_MESSENGER_ListTunnels entries
An QueueEntry used to store information for a pending NAMESTORE record operation.
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition vpn_api.c:44
An epoch identifier unifies an epoch identifier code and its 256bit hash representation.
struct GNUNET_MESSENGER_EpochIdentifierCode code
A room key unifies a room key code and its 512bit hash representation.