GNUnet 0.21.1
messenger_api_message.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2024 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"
30#include "gnunet_signatures.h"
31
33{
36};
37
39{
42};
43
46{
47 struct GNUNET_MESSENGER_Message *message = GNUNET_new (struct
49
50 message->header.kind = kind;
51
52 switch (message->header.kind)
53 {
55 message->body.name.name = NULL;
56 break;
58 message->body.text.text = NULL;
59 break;
61 message->body.file.uri = NULL;
62 break;
64 message->body.privacy.length = 0;
65 message->body.privacy.data = NULL;
66 break;
68 message->body.transcript.length = 0;
69 message->body.transcript.data = NULL;
70 break;
72 message->body.tag.tag = NULL;
73 break;
74 default:
75 break;
76 }
77
78 return message;
79}
80
81
84{
85 GNUNET_assert (message);
86
87 struct GNUNET_MESSENGER_Message *copy = GNUNET_new (struct
89
90 GNUNET_memcpy (copy, message, sizeof(struct GNUNET_MESSENGER_Message));
91
92 switch (message->header.kind)
93 {
95 copy->body.name.name = message->body.name.name? GNUNET_strdup (
96 message->body.name.name) : NULL;
97 break;
99 copy->body.text.text = message->body.text.text? GNUNET_strdup (
100 message->body.text.text) : NULL;
101 break;
103 copy->body.file.uri = message->body.file.uri? GNUNET_strdup (
104 message->body.file.uri) : NULL;
105 break;
108 copy->body.privacy.length) : NULL;
109
110 if (copy->body.privacy.data)
111 GNUNET_memcpy (copy->body.privacy.data, message->body.privacy.data,
112 copy->body.privacy.length);
113
114 break;
117 copy->body.transcript.length) : NULL;
118
119 if (copy->body.transcript.data)
121 copy->body.transcript.length);
122
123 break;
125 copy->body.tag.tag = message->body.tag.tag? GNUNET_strdup (
126 message->body.tag.tag) : NULL;
127 break;
128 default:
129 break;
130 }
131
132 return copy;
133}
134
135
136void
139{
140 GNUNET_assert ((message) && (header));
141
142 enum GNUNET_MESSENGER_MessageKind kind = message->header.kind;
143
144 GNUNET_memcpy (&(message->header), header,
145 sizeof(struct GNUNET_MESSENGER_MessageHeader));
146
147 message->header.kind = kind;
148}
149
150
151static void
154{
155 switch (kind)
156 {
158 if (body->name.name)
160 break;
162 if (body->text.text)
164 break;
166 if (body->file.uri)
168 break;
171 break;
174 break;
176 if (body->tag.tag)
178 break;
179 default:
180 break;
181 }
182}
183
184
185void
187{
188 GNUNET_assert (message);
189
190 destroy_message_body (message->header.kind, &(message->body));
191}
192
193
194void
196{
197 GNUNET_assert (message);
198
199 destroy_message_body (message->header.kind, &(message->body));
200
201 GNUNET_free (message);
202}
203
204
207{
208 GNUNET_assert (message);
209
210 if ((GNUNET_MESSENGER_KIND_JOIN == message->header.kind) ||
212 (GNUNET_MESSENGER_KIND_NAME == message->header.kind) ||
213 (GNUNET_MESSENGER_KIND_KEY == message->header.kind) ||
215 return GNUNET_YES;
216 else
217 return GNUNET_NO;
218}
219
220
221static void
223 struct GNUNET_MESSENGER_ShortMessage *shortened)
224{
225 shortened->kind = message->header.kind;
226
227 GNUNET_memcpy (&(shortened->body), &(message->body), sizeof(struct
229}
230
231
232static void
234 struct GNUNET_MESSENGER_Message *message)
235{
236 destroy_message_body (message->header.kind, &(message->body));
237
238 message->header.kind = shortened->kind;
239
240 GNUNET_memcpy (&(message->body), &(shortened->body),
241 sizeof(struct GNUNET_MESSENGER_MessageBody));
242}
243
244
245#define member_size(type, member) sizeof(((type*) NULL)->member)
246
247static uint16_t
249{
250 uint16_t length = 0;
251
252 switch (kind)
253 {
255 length += member_size (struct GNUNET_MESSENGER_Message,
257 break;
260 break;
262 length += member_size (struct GNUNET_MESSENGER_Message, body.id.id);
263 break;
266 break;
268 length += member_size (struct GNUNET_MESSENGER_Message,
270 break;
273 break;
277 break;
282 break;
285 break;
288 length += member_size (struct GNUNET_MESSENGER_Message,
290 break;
292 length += member_size (struct GNUNET_MESSENGER_Message,
294 length += member_size (struct GNUNET_MESSENGER_Message,
296 break;
298 length += member_size (struct GNUNET_MESSENGER_Message,
300 break;
302 length += member_size (struct GNUNET_MESSENGER_Message,
304 break;
307 break;
308 default:
309 break;
310 }
311
312 return length;
313}
314
315
316typedef uint32_t kind_t;
317
318uint16_t
320 enum GNUNET_GenericReturnValue include_header)
321{
322 uint16_t length = 0;
323
324 if (GNUNET_YES == include_header)
325 {
329 }
330
331 length += sizeof(kind_t);
332
333 return length + get_message_body_kind_size (kind);
334}
335
336
337static uint16_t
340{
341 uint16_t length = 0;
342
343 switch (kind)
344 {
347 break;
349 length += (body->name.name ? strlen (body->name.name) : 0);
350 break;
353 break;
355 length += (body->text.text ? strlen (body->text.text) : 0);
356 break;
358 length += (body->file.uri ? strlen (body->file.uri) : 0);
359 break;
361 length += body->privacy.length;
362 break;
365 length += body->transcript.length;
366 break;
368 length += (body->tag.tag ? strlen (body->tag.tag) : 0);
369 break;
370 default:
371 break;
372 }
373
374 return length;
375}
376
377
378uint16_t
380 enum GNUNET_GenericReturnValue include_header)
381{
382 GNUNET_assert (message);
383
384 uint16_t length = 0;
385
386 if (GNUNET_YES == include_header)
388 &(message->header.signature));
389
390 length += get_message_kind_size (message->header.kind, include_header);
391 length += get_message_body_size (message->header.kind, &(message->body));
392
393 return length;
394}
395
396
397static uint16_t
399 enum GNUNET_GenericReturnValue include_body)
400{
401 const uint16_t minimum_size = sizeof(struct GNUNET_HashCode) + sizeof(kind_t);
402
403 if (message)
404 return minimum_size + get_message_body_kind_size (message->kind)
405 + (include_body == GNUNET_YES?
406 get_message_body_size (message->kind, &(message->body)) : 0);
407 else
408 return minimum_size;
409}
410
411
412static uint16_t
414{
415 uint16_t padding = 0;
416 uint16_t kind_size;
417
418 for (unsigned int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++)
419 {
421 GNUNET_YES);
422
423 if (kind_size > padding)
424 padding = kind_size;
425 }
426
427 return padding + GNUNET_MESSENGER_PADDING_MIN;
428}
429
430
431#define max(x, y) (x > y? x : y)
432
433static uint16_t
434calc_padded_length (uint16_t length)
435{
436 static uint16_t usual_padding = 0;
437
438 if (! usual_padding)
439 usual_padding = calc_usual_padding ();
440
441 const uint16_t padded_length = max (
443 usual_padding
444 );
445
446 if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL0)
448
449 if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL1)
451
452 if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL2)
454
456
457}
458
459
460#define min(x, y) (x < y? x : y)
461
462#define encode_step_ext(dst, offset, src, size) do { \
463 GNUNET_memcpy (dst + offset, src, size); \
464 offset += size; \
465} while (0)
466
467#define encode_step(dst, offset, src) do { \
468 encode_step_ext (dst, offset, src, sizeof(*src)); \
469} while (0)
470
471#define encode_step_key(dst, offset, src, length) do { \
472 ssize_t result = GNUNET_CRYPTO_write_public_key_to_buffer ( \
473 src, dst + offset, length - offset \
474 ); \
475 if (result < 0) \
476 GNUNET_break (0); \
477 else \
478 offset += result; \
479} while (0)
480
481#define encode_step_signature(dst, offset, src, length) do { \
482 ssize_t result = GNUNET_CRYPTO_write_signature_to_buffer ( \
483 src, dst + offset, length - offset \
484 ); \
485 if (result < 0) \
486 GNUNET_break (0); \
487 else \
488 offset += result; \
489} while (0)
490
491static void
493 const struct GNUNET_MESSENGER_MessageBody *body,
494 uint16_t length,
495 char *buffer,
496 uint16_t offset)
497{
498 uint32_t value0, value1;
499 switch (kind)
500 {
502 value0 = GNUNET_htobe32 (body->info.messenger_version);
503
504 encode_step (buffer, offset, &value0);
505 break;
507 encode_step_key (buffer, offset, &(body->join.key), length);
508 break;
510 if (body->name.name)
511 encode_step_ext (buffer, offset, body->name.name, min (length - offset,
512 strlen (
513 body->name.name)));
514 break;
516 encode_step_key (buffer, offset, &(body->key.key), length);
517 break;
519 encode_step (buffer, offset, &(body->peer.peer));
520 break;
522 encode_step (buffer, offset, &(body->id.id));
523 break;
525 encode_step (buffer, offset, &(body->miss.peer));
526 break;
528 encode_step (buffer, offset, &(body->merge.previous));
529 break;
531 encode_step (buffer, offset, &(body->request.hash));
532 break;
534 encode_step (buffer, offset, &(body->invite.door));
535 encode_step (buffer, offset, &(body->invite.key));
536 break;
538 if (body->text.text)
539 encode_step_ext (buffer, offset, body->text.text, min (length - offset,
540 strlen (
541 body->text.text)));
542 break;
544 encode_step (buffer, offset, &(body->file.key));
545 encode_step (buffer, offset, &(body->file.hash));
546 encode_step_ext (buffer, offset, body->file.name, sizeof(body->file.name));
547 if (body->file.uri)
548 encode_step_ext (buffer, offset, body->file.uri, min (length - offset,
549 strlen (
550 body->file.uri)));
551 break;
553 encode_step (buffer, offset, &(body->privacy.key));
554 encode_step_ext (buffer, offset, body->privacy.data, min (length - offset,
555 body->privacy.
556 length));
557 break;
559 encode_step (buffer, offset, &(body->deletion.hash));
560 encode_step (buffer, offset, &(body->deletion.delay));
561 break;
563 value0 = GNUNET_htobe32 (body->connection.amount);
564 value1 = GNUNET_htobe32 (body->connection.flags);
565
566 encode_step (buffer, offset, &value0);
567 encode_step (buffer, offset, &value1);
568 break;
570 encode_step (buffer, offset, &(body->ticket.identifier));
571 break;
573 encode_step (buffer, offset, &(body->transcript.hash));
574 encode_step_key (buffer, offset, &(body->transcript.key), length);
575 encode_step_ext (buffer, offset, body->transcript.data, min (length
576 - offset,
577 body->
578 transcript.
579 length));
580 break;
582 encode_step (buffer, offset, &(body->tag.hash));
583 if (body->tag.tag)
584 encode_step_ext (buffer, offset, body->tag.tag, min (length - offset,
585 strlen (
586 body->tag.tag)));
587 break;
588 default:
589 break;
590 }
591
592 if (offset >= length)
593 return;
594
595 const uint16_t padding = length - offset;
596 const uint16_t used_padding = sizeof(padding) + sizeof(char);
597
598 GNUNET_assert (padding >= used_padding);
599
600 buffer[offset++] = '\0';
601
602 if (padding > used_padding)
604 padding - used_padding);
605
606 GNUNET_memcpy (buffer + length - sizeof(padding), &padding, sizeof(padding));
607}
608
609
610void
612 uint16_t length,
613 char *buffer,
614 enum GNUNET_GenericReturnValue include_header)
615{
616 GNUNET_assert ((message) && (buffer));
617
618 uint16_t offset = 0;
619
620 if (GNUNET_YES == include_header)
621 encode_step_signature (buffer, offset, &(message->header.signature),
622 length);
623
624 const kind_t kind = GNUNET_htobe32 ((kind_t) message->header.kind);
625
626 if (GNUNET_YES == include_header)
627 {
628 encode_step (buffer, offset, &(message->header.timestamp));
629 encode_step (buffer, offset, &(message->header.sender_id));
630 encode_step (buffer, offset, &(message->header.previous));
631 }
632
633 encode_step (buffer, offset, &kind);
634
635 encode_message_body (message->header.kind, &(message->body),
636 length, buffer, offset);
637}
638
639
640static void
642 uint16_t length,
643 char *buffer)
644{
645 struct GNUNET_HashCode hash;
646 uint16_t offset = sizeof(hash);
647
648 const kind_t kind = GNUNET_htobe32 ((kind_t) message->kind);
649
650 encode_step (buffer, offset, &kind);
651
652 encode_message_body (message->kind, &(message->body), length, buffer, offset);
653
655 buffer + sizeof(hash),
656 length - sizeof(hash),
657 &hash);
658
659 GNUNET_memcpy (buffer, &hash, sizeof(hash));
660}
661
662
663#define decode_step_ext(src, offset, dst, size) do { \
664 GNUNET_memcpy (dst, src + offset, size); \
665 offset += size; \
666} while (0)
667
668#define decode_step(src, offset, dst) do { \
669 decode_step_ext (src, offset, dst, sizeof(*dst)); \
670} while (0)
671
672#define decode_step_malloc(src, offset, dst, size, zero) do { \
673 dst = GNUNET_malloc (size + zero); \
674 if (zero) dst[size] = 0; \
675 decode_step_ext (src, offset, dst, size); \
676} while (0)
677
678#define decode_step_key(src, offset, dst, length) do { \
679 enum GNUNET_GenericReturnValue result; \
680 size_t read; \
681 result = GNUNET_CRYPTO_read_public_key_from_buffer ( \
682 src + offset, length - offset, dst, &read \
683 ); \
684 if (GNUNET_SYSERR == result) \
685 GNUNET_break (0); \
686 else \
687 offset += read; \
688} while (0)
689
690static uint16_t
692 struct GNUNET_MESSENGER_MessageBody *body,
693 uint16_t length,
694 const char *buffer,
695 uint16_t offset)
696{
697 uint16_t padding = 0;
698
699 GNUNET_memcpy (&padding, buffer + length - sizeof(padding), sizeof(padding));
700
701 if (padding > length - offset)
702 padding = 0;
703
704 const uint16_t end_zero = length - padding;
705
706 if ((padding) && (buffer[end_zero] != '\0'))
707 padding = 0;
708
709 length -= padding;
710
711 uint32_t value0, value1;
712 switch (*kind)
713 {
715 decode_step (buffer, offset, &value0);
716
717 body->info.messenger_version = GNUNET_be32toh (value0);
718 break;
720 decode_step_key (buffer, offset, &(body->join.key), length);
721 break;
723 if (length > offset)
724 decode_step_malloc (buffer, offset, body->name.name, length - offset, 1);
725 else
726 body->name.name = NULL;
727 break;
729 decode_step_key (buffer, offset, &(body->key.key), length);
730 break;
732 decode_step (buffer, offset, &(body->peer.peer));
733 break;
735 decode_step (buffer, offset, &(body->id.id));
736 break;
738 decode_step (buffer, offset, &(body->miss.peer));
739 break;
741 decode_step (buffer, offset, &(body->merge.previous));
742 break;
744 decode_step (buffer, offset, &(body->request.hash));
745 break;
747 decode_step (buffer, offset, &(body->invite.door));
748 decode_step (buffer, offset, &(body->invite.key));
749 break;
751 if (length > offset)
752 decode_step_malloc (buffer, offset, body->text.text, length - offset, 1);
753 else
754 body->text.text = NULL;
755 break;
757 decode_step (buffer, offset, &(body->file.key));
758 decode_step (buffer, offset, &(body->file.hash));
759 decode_step_ext (buffer, offset, body->file.name, sizeof(body->file.name));
760 if (length > offset)
761 decode_step_malloc (buffer, offset, body->file.uri, length - offset, 1);
762 else
763 body->file.uri = NULL;
764 break;
766 decode_step (buffer, offset, &(body->privacy.key));
767
768 body->privacy.length = (length - offset);
769 decode_step_malloc (buffer, offset, body->privacy.data, length - offset, 0);
770 break;
772 decode_step (buffer, offset, &(body->deletion.hash));
773 decode_step (buffer, offset, &(body->deletion.delay));
774 break;
776 decode_step (buffer, offset, &value0);
777 decode_step (buffer, offset, &value1);
778
779 body->connection.amount = GNUNET_be32toh (value0);
780 body->connection.flags = GNUNET_be32toh (value1);
781 break;
783 decode_step (buffer, offset, &(body->ticket.identifier));
784 break;
786 decode_step (buffer, offset, &(body->transcript.hash));
787 decode_step_key (buffer, offset, &(body->transcript.key), length);
788
789 body->transcript.length = (length - offset);
790 decode_step_malloc (buffer, offset, body->transcript.data, length - offset,
791 0);
792 break;
794 decode_step (buffer, offset, &(body->tag.hash));
795 if (length > offset)
796 decode_step_malloc (buffer, offset, body->tag.tag, length - offset, 1);
797 else
798 body->tag.tag = NULL;
799 break;
800 default:
802 break;
803 }
804
805 return padding;
806}
807
808
811 uint16_t length,
812 const char *buffer,
813 enum GNUNET_GenericReturnValue include_header,
814 uint16_t *padding)
815{
817 (message) &&
818 (buffer) &&
820 include_header))
821 );
822
823 uint16_t offset = 0;
824
825 if (GNUNET_YES == include_header)
826 {
828 &(message->header.signature), buffer, length - offset
829 );
830
831 if (result < 0)
832 return GNUNET_NO;
833 else
834 offset += result;
835 }
836
837 const uint16_t count = length - offset;
838
840 include_header))
841 return GNUNET_NO;
842
843 kind_t kind;
844
845 if (GNUNET_YES == include_header)
846 {
847 decode_step (buffer, offset, &(message->header.timestamp));
848 decode_step (buffer, offset, &(message->header.sender_id));
849 decode_step (buffer, offset, &(message->header.previous));
850 }
851
852 decode_step (buffer, offset, &kind);
853
855 kind);
856
857 if (count < get_message_kind_size (message->header.kind, include_header))
858 return GNUNET_NO;
859
860 const uint16_t result = decode_message_body (&(message->header.kind),
861 &(message->body), length, buffer,
862 offset);
863
864 if (padding)
865 *padding = result;
866
867 return GNUNET_YES;
868}
869
870
873 uint16_t length,
874 const char *buffer)
875{
876 struct GNUNET_HashCode expected, hash;
877 uint16_t offset = sizeof(hash);
878
879 if (length < get_short_message_size (NULL, GNUNET_NO))
880 return GNUNET_NO;
881
882 GNUNET_memcpy (&hash, buffer, sizeof(hash));
883
885 buffer + sizeof(hash),
886 length - sizeof(hash),
887 &expected
888 );
889
890 if (0 != GNUNET_CRYPTO_hash_cmp (&hash, &expected))
891 return GNUNET_NO;
892
893 kind_t kind;
894
895 decode_step (buffer, offset, &kind);
896
897 message->kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh (kind);
898
899 if (length < get_short_message_size (message, GNUNET_NO))
900 return GNUNET_NO;
901
902 decode_message_body (&(message->kind), &(message->body), length, buffer,
903 offset);
904
905 if (GNUNET_MESSENGER_KIND_UNKNOWN == message->kind)
906 return GNUNET_NO;
907
908 return GNUNET_YES;
909}
910
911
912void
914 uint16_t length,
915 const char *buffer,
916 struct GNUNET_HashCode *hash)
917{
918 GNUNET_assert ((message) && (buffer) && (hash));
919
920 const ssize_t offset = GNUNET_CRYPTO_signature_get_length (
921 &(message->header.signature)
922 );
923
924 GNUNET_CRYPTO_hash (buffer + offset, length - offset, hash);
925}
926
927
928void
930 uint16_t length,
931 char *buffer,
932 const struct GNUNET_HashCode *hash,
933 const struct GNUNET_CRYPTO_PrivateKey *key)
934{
935 GNUNET_assert ((message) && (buffer) && (hash) && (key));
936
937 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sign message by member: %s\n",
938 GNUNET_h2s (hash));
939
940 struct GNUNET_MESSENGER_MessageSignature signature;
941
943 signature.purpose.size = htonl (sizeof(signature));
944
945 GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode));
946 GNUNET_CRYPTO_sign (key, &signature, &(message->header.signature));
947
948 message->header.signature.type = key->type;
949
950 uint16_t offset = 0;
951 encode_step_signature (buffer, offset, &(message->header.signature), length);
952}
953
954
955void
957 uint16_t length,
958 char *buffer,
959 const struct GNUNET_HashCode *hash,
960 const struct GNUNET_CONFIGURATION_Handle *cfg)
961{
962 GNUNET_assert ((message) && (buffer) && (hash) && (cfg));
963
964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sign message by peer: %s\n",
965 GNUNET_h2s (hash));
966
967 struct GNUNET_MESSENGER_MessageSignature signature;
968
970 signature.purpose.size = htonl (sizeof(signature));
971
972 GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode));
974 &(message->header.signature.
975 eddsa_signature));
976
978
979 uint16_t offset = 0;
980 encode_step_signature (buffer, offset, &(message->header.signature), length);
981}
982
983
986 const struct GNUNET_HashCode *hash,
987 const struct GNUNET_CRYPTO_PublicKey *key)
988{
989 GNUNET_assert ((message) && (hash) && (key));
990
991 if (key->type != message->header.signature.type)
992 return GNUNET_SYSERR;
993
994 struct GNUNET_MESSENGER_MessageSignature signature;
995
997 signature.purpose.size = htonl (sizeof(signature));
998
999 GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode));
1000
1003 &(message->header.signature), key);
1004}
1005
1006
1009 const struct GNUNET_HashCode *hash,
1010 const struct GNUNET_PeerIdentity *identity)
1011{
1012 GNUNET_assert ((message) && (hash) && (identity));
1013
1014 if (ntohl (GNUNET_PUBLIC_KEY_TYPE_EDDSA) != message->header.signature.type)
1015 return GNUNET_SYSERR;
1016
1017 struct GNUNET_MESSENGER_MessageSignature signature;
1018
1020 signature.purpose.size = htonl (sizeof(signature));
1021
1022 GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode));
1023
1026 &(message->header.signature.
1027 eddsa_signature), identity);
1028}
1029
1030
1033 const struct GNUNET_CRYPTO_PublicKey *key)
1034{
1035 GNUNET_assert ((message) && (key));
1036
1037 if (GNUNET_YES == is_service_message (message))
1038 return GNUNET_NO;
1039
1040 struct GNUNET_MESSENGER_ShortMessage shortened;
1041
1042 fold_short_message (message, &shortened);
1043
1044 const uint16_t length = get_short_message_size (&shortened, GNUNET_YES);
1045 const uint16_t padded_length = calc_padded_length (
1047 );
1048
1050 message->body.privacy.data = GNUNET_malloc (padded_length);
1051 message->body.privacy.length = padded_length;
1052
1053 const uint16_t encoded_length = (
1055 );
1056
1057 encode_short_message (&shortened, encoded_length, message->body.privacy.data);
1058
1060 encoded_length,
1061 key,
1062 message->body.privacy.data,
1063 padded_length))
1064 {
1065 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Encrypting message failed!\n");
1066
1067 unfold_short_message (&shortened, message);
1068 return GNUNET_NO;
1069 }
1070
1071 destroy_message_body (shortened.kind, &(shortened.body));
1072 return GNUNET_YES;
1073}
1074
1075
1078 const struct GNUNET_CRYPTO_PrivateKey *key)
1079{
1080 GNUNET_assert ((message) && (key));
1081
1082 const uint16_t padded_length = message->body.privacy.length;
1083
1084 if (padded_length < GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES)
1085 {
1087 "Message length too short to decrypt!\n");
1088
1089 return GNUNET_NO;
1090 }
1091
1092 const uint16_t encoded_length = (
1094 );
1095
1097 padded_length,
1098 key,
1099 message->body.privacy.data,
1100 encoded_length))
1101 {
1102 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Decrypting message failed!\n");
1103
1104 return GNUNET_NO;
1105 }
1106
1107 struct GNUNET_MESSENGER_ShortMessage shortened;
1108
1109 if (GNUNET_YES != decode_short_message (&shortened,
1110 encoded_length,
1111 message->body.privacy.data))
1112 {
1114 "Decoding decrypted message failed!\n");
1115
1116 return GNUNET_NO;
1117 }
1118
1119 unfold_short_message (&shortened, message);
1120 return GNUNET_YES;
1121}
1122
1123
1126 const struct GNUNET_CRYPTO_PublicKey *key)
1127{
1128 GNUNET_assert ((message) && (key));
1129
1130 if (GNUNET_YES == is_service_message (message))
1131 return NULL;
1132
1133 struct GNUNET_MESSENGER_Message *transcript = create_message (
1135
1136 if (! transcript)
1137 {
1138 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Transcribing message failed!\n");
1139 return NULL;
1140 }
1141
1142 GNUNET_memcpy (&(transcript->body.transcript.key), key,
1143 sizeof(transcript->body.transcript.key));
1144
1145 struct GNUNET_MESSENGER_ShortMessage shortened;
1146
1147 fold_short_message (message, &shortened);
1148
1149 const uint16_t data_length = get_short_message_size (
1150 &shortened, GNUNET_YES);
1151
1152 transcript->body.transcript.data = GNUNET_malloc (data_length);
1153 transcript->body.transcript.length = data_length;
1154
1155 encode_short_message (&shortened, data_length,
1156 transcript->body.transcript.data);
1157
1158 return transcript;
1159}
1160
1161
1164{
1165 GNUNET_assert (message);
1166
1168 return GNUNET_NO;
1169
1170 const uint16_t data_length = message->body.transcript.length;
1171
1172 struct GNUNET_MESSENGER_ShortMessage shortened;
1173 if (GNUNET_YES != decode_short_message (&shortened,
1174 data_length,
1175 message->body.transcript.data))
1176 {
1178 "Decoding decrypted message failed!\n");
1179
1180 return GNUNET_NO;
1181 }
1182
1183 unfold_short_message (&shortened, message);
1184 return GNUNET_YES;
1185}
1186
1187
1188struct GNUNET_MQ_Envelope*
1190 struct GNUNET_HashCode *hash,
1193 const void *cls)
1194{
1195 GNUNET_assert (message);
1196
1198 "Packing message kind=%u and sender: %s\n",
1199 message->header.kind, GNUNET_sh2s (&(message->header.sender_id)));
1200
1201 struct GNUNET_MessageHeader *header;
1202
1203 const uint16_t length = get_message_size (message, GNUNET_YES);
1204 const uint16_t padded_length = calc_padded_length (length);
1205
1206 struct GNUNET_MQ_Envelope *env;
1207 char *buffer;
1208
1210 {
1211 env = GNUNET_MQ_msg_extra (header, padded_length,
1213
1214 buffer = (char*) &(header[1]);
1215 }
1216 else
1217 {
1218 env = NULL;
1219
1220 buffer = GNUNET_malloc (padded_length);
1221 }
1222
1223 encode_message (message, padded_length, buffer, GNUNET_YES);
1224
1225 if (hash)
1226 {
1227 hash_message (message, length, buffer, hash);
1228
1229 if (sign)
1230 sign (cls, message, length, buffer, hash);
1231 }
1232
1234 GNUNET_free (buffer);
1235
1236 return env;
1237}
1238
1239
1242{
1243 switch (message->header.kind)
1244 {
1250 return GNUNET_YES;
1251 default:
1252 return GNUNET_NO;
1253 }
1254}
1255
1256
1259{
1260 if (GNUNET_YES == is_peer_message (message))
1261 return GNUNET_YES;
1262
1263 switch (message->header.kind)
1264 {
1266 return GNUNET_YES; // Reserved for connection handling only!
1268 return GNUNET_YES; // Reserved for member handling only!
1270 return GNUNET_YES; // Reserved for member handling only!
1272 return GNUNET_YES; // Reserved for member name handling only!
1274 return GNUNET_YES; // Reserved for member key handling only!
1276 return GNUNET_YES; // Reserved for connection handling only!
1278 return GNUNET_YES; // Reserved for member id handling only!
1280 return GNUNET_YES; // Reserved for connection handling only!
1282 return GNUNET_YES; // Reserved for peers only!
1284 return GNUNET_YES; // Requests should not apply individually! (inefficieny)
1286 return GNUNET_NO;
1288 return GNUNET_NO;
1290 return GNUNET_NO;
1292 return GNUNET_YES; // Prevent duplicate encryption breaking all access!
1294 return GNUNET_YES; // Deletion should not apply individually! (inefficieny)
1296 return GNUNET_YES; // Reserved for connection handling only!
1298 return GNUNET_NO;
1300 return GNUNET_NO;
1302 return GNUNET_NO;
1303 default:
1304 return GNUNET_SYSERR;
1305 }
1306}
1307
1308
1311{
1312 if (GNUNET_YES == is_peer_message (message))
1313 return GNUNET_SYSERR; // Requires signature of peer rather than member!
1314
1315 switch (message->header.kind)
1316 {
1318 return GNUNET_SYSERR; // Reserved for connection handling only!
1320 return GNUNET_NO; // Use #GNUNET_MESSENGER_enter_room(...) instead!
1322 return GNUNET_NO; // Use #GNUNET_MESSENGER_close_room(...) instead!
1324 return GNUNET_YES;
1326 return GNUNET_NO; // Use #GNUNET_MESSENGER_set_key(...) instead!
1328 return GNUNET_SYSERR; // Use #GNUNET_MESSENGER_open_room(...) instead!
1330 return GNUNET_NO; // Reserved for member id handling only!
1332 return GNUNET_SYSERR; // Reserved for connection handling only!
1334 return GNUNET_SYSERR; // Reserved for peers only!
1336 return GNUNET_NO; // Use #GNUNET_MESSENGER_get_message(...) instead!
1338 return GNUNET_YES;
1340 return GNUNET_YES;
1342 return GNUNET_YES;
1344 return GNUNET_NO; // Use #GNUNET_MESSENGER_send_message(...) with a contact instead!
1346 return GNUNET_NO; // Use #GNUNET_MESSENGER_delete_message(...) instead!
1348 return GNUNET_SYSERR; // Reserved for connection handling only!
1350 return GNUNET_NO; // Use #GNUNET_MESSENGER_send_ticket(...) instead!
1352 return GNUNET_NO; // Use #GNUNET_MESSENGER_send_message(...) with a contact instead!
1354 return GNUNET_YES;
1355 default:
1356 return GNUNET_SYSERR;
1357 }
1358}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static int result
Global testing status.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
static enum @44 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_sign_by_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
Sign a given block with a specific purpose using the host's peer identity.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_verify_peer_identity(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_PeerIdentity *identity)
Verify a given signature with a peer's identity.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:221
ssize_t GNUNET_CRYPTO_read_signature_from_buffer(struct GNUNET_CRYPTO_Signature *sig, const void *buffer, size_t len)
Reads a GNUNET_CRYPTO_Signature from a compact buffer.
Definition: crypto_pkey.c:226
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:68
#define GNUNET_log(kind,...)
#define GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES
#define GNUNET_be32toh(x)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_PublicKey *pub, void *result, size_t result_size)
Encrypt a block with GNUNET_CRYPTO_PublicKey and derives a GNUNET_CRYPTO_EcdhePublicKey which is requ...
Definition: crypto_pkey.c:416
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_PrivateKey *priv, void *result, size_t result_size)
Decrypt a given block with GNUNET_CRYPTO_PrivateKey and a given GNUNET_CRYPTO_EcdhePublicKey using ec...
Definition: crypto_pkey.c:467
ssize_t GNUNET_CRYPTO_signature_get_length(const struct GNUNET_CRYPTO_Signature *sig)
Get the compacted length of a GNUNET_CRYPTO_Signature.
Definition: crypto_pkey.c:189
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_CRYPTO_sign(priv, ps, sig)
Sign a given block with GNUNET_CRYPTO_PrivateKey.
#define GNUNET_CRYPTO_signature_verify(purp, ps, sig, pub)
Verify a given signature with GNUNET_CRYPTO_PublicKey.
#define GNUNET_htobe32(x)
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ 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_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MESSENGER_MessageKind
Enum for the different supported kinds of messages.
#define GNUNET_MESSENGER_KIND_MAX
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_INVITE
The invite kind.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_TAG
The tag kind.
@ GNUNET_MESSENGER_KIND_FILE
The file kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
@ GNUNET_MESSENGER_KIND_TRANSCRIPT
The transcript kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_TEXT
The text kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_CONNECTION
The connection kind.
@ GNUNET_MESSENGER_KIND_TICKET
The ticket kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
static void destroy_message_body(enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESSENGER_MessageBody *body)
#define decode_step(src, offset, dst)
#define encode_step_ext(dst, offset, src, size)
static uint16_t get_short_message_size(const struct GNUNET_MESSENGER_ShortMessage *message, enum GNUNET_GenericReturnValue include_body)
enum GNUNET_GenericReturnValue verify_message(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_PublicKey *key)
Verifies the signature of a given message and its hash with a specific public key.
static uint16_t get_message_body_kind_size(enum GNUNET_MESSENGER_MessageKind kind)
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, enum GNUNET_GenericReturnValue include_header)
Encodes a given message into a buffer of a maximal length in bytes.
void sign_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_PrivateKey *key)
Signs the hash of a message with a given private key and writes the signature into the buffer as well...
enum GNUNET_GenericReturnValue is_service_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message contains service critical information.
enum GNUNET_GenericReturnValue encrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *key)
Encrypts a message using a given public key and replaces its body and kind with the now private encry...
static uint16_t get_message_body_size(enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body)
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
static void fold_short_message(const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_ShortMessage *shortened)
#define decode_step_key(src, offset, dst, length)
static uint16_t calc_padded_length(uint16_t length)
enum GNUNET_GenericReturnValue filter_message_sending(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message should be sent by a client.
#define decode_step_malloc(src, offset, dst, size, zero)
#define encode_step(dst, offset, src)
static void encode_message_body(enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, char *buffer, uint16_t offset)
enum GNUNET_GenericReturnValue is_peer_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message can be sent by the service without usage of a clients priv...
static void encode_short_message(const struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, char *buffer)
static enum GNUNET_GenericReturnValue decode_short_message(struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, const char *buffer)
enum GNUNET_GenericReturnValue verify_message_by_peer(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_PeerIdentity *identity)
Verifies the signature of a given message and its hash with a specific peer's identity.
void hash_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer with a length in bytes from a message.
struct GNUNET_MESSENGER_Message * create_message(enum GNUNET_MESSENGER_MessageKind kind)
Creates and allocates a new message with a specific kind.
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const GNUNET_MESSENGER_SignFunction sign, enum GNUNET_MESSENGER_PackMode mode, const void *cls)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...
#define decode_step_ext(src, offset, dst, size)
static void unfold_short_message(struct GNUNET_MESSENGER_ShortMessage *shortened, struct GNUNET_MESSENGER_Message *message)
enum GNUNET_GenericReturnValue decrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PrivateKey *key)
Decrypts a private message using a given private key and replaces its body and kind with the inner en...
#define encode_step_signature(dst, offset, src, length)
static uint16_t calc_usual_padding()
static uint16_t decode_message_body(enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, const char *buffer, uint16_t offset)
uint32_t kind_t
#define min(x, y)
#define max(x, y)
void copy_message_header(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_MessageHeader *header)
Copy message header details from another message to a given message.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, enum GNUNET_GenericReturnValue include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
struct GNUNET_MESSENGER_Message * transcribe_message(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *key)
Transcribes a message as a new transcript message using a given public key from the recipient of the ...
void sign_message_by_peer(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CONFIGURATION_Handle *cfg)
Signs the hash of a message with the peer identity of a given config and writes the signature into th...
enum GNUNET_GenericReturnValue read_transcript_message(struct GNUNET_MESSENGER_Message *message)
Read the original message from a transcript message and replaces its body and kind with the inner enc...
#define encode_step_key(dst, offset, src, length)
enum GNUNET_GenericReturnValue is_message_session_bound(const struct GNUNET_MESSENGER_Message *message)
Returns if the message should be bound to a member session.
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message, enum GNUNET_GenericReturnValue include_header)
Returns the exact size in bytes to encode a given message.
enum GNUNET_GenericReturnValue decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, enum GNUNET_GenericReturnValue include_header, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
#define member_size(type, member)
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.
#define GNUNET_MESSENGER_MAX_MESSAGE_SIZE
GNUNET_MESSENGER_PackMode
@ GNUNET_MESSENGER_PACK_MODE_ENVELOPE
#define GNUNET_MESSENGER_PADDING_LEVEL0
#define GNUNET_MESSENGER_PADDING_MIN
void(* GNUNET_MESSENGER_SignFunction)(const void *cls, struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash)
#define GNUNET_MESSENGER_PADDING_LEVEL2
#define GNUNET_MESSENGER_PADDING_LEVEL1
#define GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE
Signature of a chat message.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
uint32_t type
Type of signature.
A 512-bit hashcode.
The unified body of a GNUNET_MESSENGER_Message.
struct GNUNET_MESSENGER_MessagePrivate privacy
struct GNUNET_MESSENGER_MessageConnection connection
struct GNUNET_MESSENGER_MessageText text
struct GNUNET_MESSENGER_MessageRequest request
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_MESSENGER_MessageName name
struct GNUNET_MESSENGER_MessageTranscript transcript
struct GNUNET_MESSENGER_MessageFile file
struct GNUNET_MESSENGER_MessageTag tag
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_MESSENGER_MessageInvite invite
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_MESSENGER_MessagePeer peer
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_MESSENGER_MessageTicket ticket
struct GNUNET_MESSENGER_MessageInfo info
uint32_t amount
The amount of connections of a peer.
uint32_t flags
The flags about the connections of a peer.
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.
char * uri
The uri of the encrypted file.
struct GNUNET_HashCode hash
The hash of the original file.
struct GNUNET_CRYPTO_SymmetricSessionKey key
The symmetric key to decrypt the file.
char name[NAME_MAX]
The name of the original file.
The header of a GNUNET_MESSENGER_Message.
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_CRYPTO_Signature signature
The signature of the senders private key.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
uint32_t messenger_version
The version of GNUnet Messenger API.
struct GNUNET_HashCode key
The hash identifying the port of the room.
struct GNUNET_PeerIdentity door
The peer identity of an open door to a room.
struct GNUNET_CRYPTO_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_CRYPTO_PublicKey key
The new public key which replaces the current senders public key.
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_PeerIdentity peer
The peer identity of a disconnected door to a room.
char * name
The new name which replaces the current senders name.
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
uint16_t length
The length of the encrypted message.
struct GNUNET_CRYPTO_EcdhePublicKey key
The ECDH key to decrypt the message.
char * data
The data of the encrypted message.
struct GNUNET_HashCode hash
The hash of the requested message.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
struct GNUNET_HashCode hash
The hash of the message to tag.
char * text
The containing text.
struct GNUNET_RECLAIM_Identifier identifier
The identifier of a RECLAIM ticket.
uint16_t length
The length of the transcribed message.
struct GNUNET_HashCode hash
The hash of the original message.
struct GNUNET_CRYPTO_PublicKey key
The key from the recipient of the original message.
char * data
The data of the transcribed message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessageBody body
enum GNUNET_MESSENGER_MessageKind kind
Header for all communications.
The identity of the host (wraps the signing key of the peer).