GNUnet 0.25.2-11-g84e94e98c
 
Loading...
Searching...
No Matches
gnunet-service-abd.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011-2013 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*/
25#include "platform.h"
26
27#include "gnunet_util_lib.h"
28
29#include "abd.h"
30#include "abd_serialization.h"
31#include "gnunet_abd_service.h"
32#include "gnunet_protocols.h"
34#include <gnunet_gns_service.h>
38
39
40#define GNUNET_ABD_MAX_LENGTH 255
41
43
45
46
79
105
132
214
215
320
321
325static struct VerifyRequestHandle *vrh_head = NULL;
326
330static struct VerifyRequestHandle *vrh_tail = NULL;
331
336
340static struct GNUNET_GNS_Handle *gns;
341
346
347static void
360
361
362static void
364{
365 GNUNET_free (ds_entry->issuer_key);
366 GNUNET_free (ds_entry->issuer_attribute);
367 GNUNET_free (ds_entry->attr_trailer);
368 // those fields are only set/used in bw search
369 if (ds_entry->from_bw)
370 {
371 GNUNET_free (ds_entry->lookup_attribute);
373 }
374 if (NULL != ds_entry->lookup_request)
375 {
377 ds_entry->lookup_request = NULL;
378 }
379 if (NULL != ds_entry->delegation_chain_entry)
380 {
385 }
386 // Free DQ entries
387 for (struct DelegationQueueEntry *dq_entry = ds_entry->queue_entries_head;
388 NULL != ds_entry->queue_entries_head;
389 dq_entry = ds_entry->queue_entries_head)
390 {
392 ds_entry->queue_entries_tail,
393 dq_entry);
394 GNUNET_free (dq_entry);
395 }
396 GNUNET_free (ds_entry);
397}
398
399
400static void
402{
403 struct DelegateRecordEntry *del_entry;
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n");
405
406 if (NULL != vrh->dsq_head)
407 {
408 for (struct DelegationSetQueueEntry *ds_entry = vrh->dsq_head; NULL !=
409 vrh->dsq_head;
410 ds_entry = vrh->dsq_head)
411 {
412 GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry);
413 cleanup_dsq_entry (ds_entry);
414 }
415 }
416 if (NULL != vrh->del_chain_head)
417 {
418 for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
419 del_entry = vrh->del_chain_head)
420 {
422 vrh->del_chain_tail,
423 del_entry);
424 GNUNET_free (del_entry->delegate);
425 GNUNET_free (del_entry);
426 }
427 }
429 GNUNET_free (vrh);
430}
431
432
433static void
434shutdown_task (void *cls)
435{
436 struct VerifyRequestHandle *vrh;
437
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down!\n");
439
440 while (NULL != (vrh = vrh_head))
441 {
442 // ABD_resolver_lookup_cancel (clh->lookup);
444 cleanup_handle (vrh);
445 }
446
447 if (NULL != gns)
448 {
450 gns = NULL;
451 }
452 if (NULL != namestore)
453 {
455 namestore = NULL;
456 }
457 if (NULL != statistics)
458 {
460 statistics = NULL;
461 }
462}
463
464
465static void
467 DelegationChainEntry *ch_entry, bool is_bw)
468{
470 struct GNUNET_MQ_Envelope *env;
471 struct GNUNET_ABD_Delegation *dd;
472 size_t size;
473
474 // Don't report immediate results during collect
475 if (vrh->is_collect)
476 return;
477
478 dd = GNUNET_new (struct GNUNET_ABD_Delegation);
479 dd->issuer_key = ch_entry->issuer_key;
480 dd->subject_key = ch_entry->subject_key;
481 dd->issuer_attribute = ch_entry->issuer_attribute;
482 dd->issuer_attribute_len = strlen (ch_entry->issuer_attribute) + 1;
483 dd->subject_attribute_len = 0;
484 dd->subject_attribute = NULL;
485 if (NULL != ch_entry->subject_attribute)
486 {
487 dd->subject_attribute = ch_entry->subject_attribute;
488 dd->subject_attribute_len = strlen (ch_entry->subject_attribute) + 1;
489 }
490
491
493 dd,
494 0,
495 NULL);
496
497 env = GNUNET_MQ_msg_extra (rmsg,
498 size,
500 // Assign id so that client can find associated request
501 rmsg->id = vrh->request_id;
502 rmsg->is_bw = htons (is_bw);
503 rmsg->size = htonl (size);
504
507 dd,
508 0,
509 NULL,
510 size,
511 (char *) &rmsg[1]));
513
514 GNUNET_free (dd);
515}
516
517
518static void
520{
521 struct GNUNET_MQ_Envelope *env;
522 struct DelegationChainResultMessage *rmsg;
523 struct DelegationChainEntry *dce;
524 struct GNUNET_ABD_Delegation dd[vrh->delegation_chain_size];
525 struct GNUNET_ABD_Delegate dele[vrh->del_chain_size];
526 struct DelegateRecordEntry *del;
527 struct DelegateRecordEntry *tmp;
528 size_t size;
529
530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending response\n");
531 dce = vrh->delegation_chain_head;
532 for (uint32_t i = 0; i < vrh->delegation_chain_size; i++)
533 {
534 dd[i].issuer_key = dce->issuer_key;
535 dd[i].subject_key = dce->subject_key;
537 dd[i].issuer_attribute_len = strlen (dce->issuer_attribute) + 1;
538 dd[i].subject_attribute_len = 0;
539 dd[i].subject_attribute = NULL;
540 if (NULL != dce->subject_attribute)
541 {
543 dd[i].subject_attribute_len = strlen (dce->subject_attribute) + 1;
544 }
545 dce = dce->next;
546 }
547
548 // Remove all not needed credentials
549 for (del = vrh->del_chain_head; NULL != del;)
550 {
551 if (del->refcount > 0)
552 {
553 del = del->next;
554 continue;
555 }
556 tmp = del;
557 del = del->next;
559 GNUNET_free (tmp->delegate);
560 GNUNET_free (tmp);
561 vrh->del_chain_size--;
562 }
563
564 // Get serialized record data
565 // Append at the end of rmsg
566 del = vrh->del_chain_head;
567 for (uint32_t i = 0; i < vrh->del_chain_size; i++)
568 {
569 dele[i].issuer_key = del->delegate->issuer_key;
570 dele[i].subject_key = del->delegate->subject_key;
571 dele[i].issuer_attribute_len = strlen (del->delegate->issuer_attribute) + 1;
572 dele[i].issuer_attribute = del->delegate->issuer_attribute;
573 dele[i].subject_attribute_len = del->delegate->subject_attribute_len;
574 dele[i].subject_attribute = del->delegate->subject_attribute;
575 dele[i].expiration = del->delegate->expiration;
576 dele[i].signature = del->delegate->signature;
577 del = del->next;
578 }
579 size =
581 dd,
582 vrh->del_chain_size,
583 dele);
584 env = GNUNET_MQ_msg_extra (rmsg,
585 size,
587 // Assign id so that client can find associated request
588 rmsg->id = vrh->request_id;
589 rmsg->d_count = htonl (vrh->delegation_chain_size);
590 rmsg->c_count = htonl (vrh->del_chain_size);
591
592 if (0 < vrh->del_chain_size)
593 rmsg->del_found = htonl (GNUNET_YES);
594 else
595 rmsg->del_found = htonl (GNUNET_NO);
596
598 -1 !=
600 dd,
601 vrh->del_chain_size,
602 dele,
603 size,
604 (char *) &rmsg[1]));
605
608 cleanup_handle (vrh);
610 "Completed verifications",
611 1,
612 GNUNET_NO);
613}
614
615
616static char *
617partial_match (char *tmp_trail,
618 char *tmp_subattr,
619 char *parent_trail,
620 char *issuer_attribute)
621{
622 char *saveptr1, *saveptr2;
623 char *trail_token;
624 char *sub_token;
625 char *attr_trailer;
626
627 // tok both, parent->attr_trailer and del->sub_attr to see how far they match,
628 // take rest of parent trailer (only when del->sub_attr token is null), and
629 // create new/actual trailer with del->iss_attr
630 trail_token = strtok_r (tmp_trail, ".", &saveptr1);
631 sub_token = strtok_r (tmp_subattr, ".", &saveptr2);
632 while (NULL != trail_token && NULL != sub_token)
633 {
634 if (0 == strcmp (trail_token, sub_token))
635 {
636 // good, matches, remove
637 }
638 else
639 {
640 // not relevant for solving the chain, end for iteration here
641 return NULL;
642 }
643
644 trail_token = strtok_r (NULL, ".", &saveptr1);
645 sub_token = strtok_r (NULL, ".", &saveptr2);
646 }
647 // skip this entry and go to next for if:
648 // 1. at some point the attr of the trailer and the subject dont match
649 // 2. the trailer is NULL, but the subject has more attributes
650 // Reason: This will lead to "startzone.attribute" but we're looking for a solution
651 // for "<- startzone"
652 if (NULL == trail_token)
653 {
654 return NULL;
655 }
656
657 // do not have to check sub_token == NULL, if both would be NULL
658 // at the same time, the complete match part above should have triggered already
659
660 // otherwise, above while only ends when sub_token == NULL
661 GNUNET_asprintf (&attr_trailer, "%s", trail_token);
662 trail_token = strtok_r (NULL, ".", &saveptr1);
663 while (NULL != trail_token)
664 {
665 GNUNET_asprintf (&attr_trailer, "%s.%s", parent_trail, trail_token);
666 trail_token = strtok_r (NULL, ".", &saveptr1);
667 }
668 GNUNET_asprintf (&attr_trailer, "%s.%s", issuer_attribute, attr_trailer);
669 return attr_trailer;
670}
671
672
673static int
675 struct DelegationSetQueueEntry *match_entry,
676 struct VerifyRequestHandle *vrh)
677{
678 struct DelegationSetQueueEntry *old_fw_parent;
679 struct DelegationSetQueueEntry *fw_entry = actual_entry;
680 struct DelegationSetQueueEntry *last_entry = match_entry;
681 // parent fixing, combine backward and forward chain parts
682 while (NULL != fw_entry->parent_queue_entry)
683 {
684 old_fw_parent = fw_entry->parent_queue_entry->parent_set;
685 // set parent
686 fw_entry->parent_queue_entry->parent_set = last_entry;
687
688 last_entry = fw_entry;
689 fw_entry = old_fw_parent;
690 }
691 // set last entry of chain as actual_entry
692 // actual_entry = last_entry;
693 // set refcount, loop all delegations
694 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head;
695 del_entry != NULL;
696 del_entry = del_entry->next)
697 {
698 if (0 != memcmp (&last_entry->delegation_chain_entry->subject_key,
699 &del_entry->delegate->issuer_key,
700 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
701 continue;
702 if (0 != strcmp (last_entry->delegation_chain_entry->subject_attribute,
703 del_entry->delegate->issuer_attribute))
704 continue;
705
706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found delegate.\n");
707 // increase refcount of the start delegation
708 del_entry->refcount++;
709 }
710 // backtrack
711 for (struct DelegationSetQueueEntry *tmp_set = last_entry;
712 NULL != tmp_set->parent_queue_entry;
713 tmp_set = tmp_set->parent_queue_entry->parent_set)
714 {
715 tmp_set->parent_queue_entry->required_solutions--;
716
717 // add new found entry to vrh
721 tmp_set->delegation_chain_entry);
722
723 // if one node on the path still needs solutions, this current
724 // patch cannot fulfill the conditions and therefore stops here
725 // however, it is in the vrh and can be used by the other paths
726 // related to this path/collection/verification
727 if (0 < tmp_set->parent_queue_entry->required_solutions)
728 {
730 "Chain requires more solutions, waiting...\n");
731 return GNUNET_NO;
732 }
733 }
734 return GNUNET_YES;
735}
736
737
738static void
740 uint32_t rd_count,
741 const struct GNUNET_GNSRECORD_Data *rd)
742{
743 struct VerifyRequestHandle *vrh;
744 struct DelegationSetQueueEntry *current_set;
745 struct DelegationSetQueueEntry *ds_entry;
746 struct DelegationQueueEntry *dq_entry;
747 struct GNUNET_ABD_Delegate *del;
748
749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d entries.\n", rd_count);
750
751 current_set = cls;
752 // set handle to NULL (as el = NULL)
753 current_set->lookup_request = NULL;
754 vrh = current_set->handle;
755 vrh->pending_lookups--;
756
757 // Loop record entries
758 for (uint32_t i = 0; i < rd_count; i++)
759 {
760 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
761 continue;
762
763 // Start deserialize into Delegate
765
766 if (NULL == del)
767 continue;
768
769 // Start: Create DQ Entry
770 dq_entry = GNUNET_new (struct DelegationQueueEntry);
771 // AND delegations are not possible, only 1 solution
772 dq_entry->required_solutions = 1;
773 dq_entry->parent_set = current_set;
774
775 // Insert it into the current set
777 current_set->queue_entries_tail,
778 dq_entry);
779
780 // Start: Create DS Entry
781 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
782 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
783 ds_entry->from_bw = false;
784
785 // (1) A.a <- A.b.c
786 // (2) A.b <- D.d
787 // (3) D.d <- E
788 // (4) E.c <- F.c
789 // (5) F.c <- G
790 // Possibilities:
791 // 1. complete match: trailer = 0, validate
792 // 2. partial match: replace
793 // 3. new solution: replace, add trailer
794
795 // At resolution chain start trailer of parent is NULL
796 if (NULL == current_set->attr_trailer)
797 {
798 // for (5) F.c <- G, remember .c when going upwards
799 ds_entry->attr_trailer = GNUNET_strdup (del->issuer_attribute);
800 }
801 else
802 {
803 if (0 == del->subject_attribute_len)
804 {
805 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: New solution\n");
806 // new solution
807 // create new trailer del->issuer_attribute, ds_entry->attr_trailer
808 GNUNET_asprintf (&ds_entry->attr_trailer,
809 "%s.%s",
810 del->issuer_attribute,
811 current_set->attr_trailer);
812 }
813 else if (0 == strcmp (del->subject_attribute, current_set->attr_trailer))
814 {
815 // complete match
816 // new trailer == issuer attribute (e.g. (5) to (4))
817 ds_entry->attr_trailer = GNUNET_strdup (del->issuer_attribute);
818 }
819 else
820 {
821 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: Partial match\n");
822 // partial match
823 {
824 char *trail = partial_match (GNUNET_strdup (current_set->attr_trailer)
825 ,
826 GNUNET_strdup (del->subject_attribute),
827 current_set->attr_trailer,
828 GNUNET_strdup (del->issuer_attribute));
829
830 // if null: skip this record entry (reasons: mismatch or overmatch, both not relevant)
831 if (NULL == trail)
832 {
834 "Entry not relevant, discarding: %s.%s <- %s.%s\n",
836 &del->issuer_key),
837 del->issuer_attribute,
839 &del->subject_key),
840 del->subject_attribute);
842 continue;
843 }
844 else
845 {
846 ds_entry->attr_trailer = trail;
847 }
848 }
849 }
850 }
851
852
853 // Start: Credential Chain Entry
854 // issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject)
856 GNUNET_memcpy (ds_entry->issuer_key,
857 &del->subject_key,
858 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey));
859
861 ds_entry->delegation_chain_entry->subject_key = del->subject_key;
862 if (0 < del->subject_attribute_len)
864 GNUNET_strdup (del->subject_attribute);
865 ds_entry->delegation_chain_entry->issuer_key = del->issuer_key;
867 GNUNET_strdup (del->issuer_attribute);
868
869 // Found new entry, repoting intermediate result
871
872 // current delegation as parent
873 ds_entry->parent_queue_entry = dq_entry;
874
875 // Check for solution
876 // if: issuer key we looking for
877 if (0 == memcmp (&del->issuer_key,
878 &vrh->issuer_key,
879 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
880 {
881 // if: issuer attr we looking for
882 if (0 == strcmp (del->issuer_attribute, vrh->issuer_attribute))
883 {
884 // if: complete match, meaning new trailer == issuer attr
885 if (0 == strcmp (vrh->issuer_attribute, ds_entry->attr_trailer))
886 {
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: Solution\n");
888
889 // Add found solution into delegation_chain
890 {
891 struct DelegationSetQueueEntry *tmp_set;
892 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
893 tmp_set = tmp_set->parent_queue_entry->parent_set)
894 {
895 if (NULL != tmp_set->delegation_chain_entry)
896 {
900 tmp_set->delegation_chain_entry);
901 }
902 }
903 }
904
905 // Increase refcount for this delegate
906 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head;
907 del_entry != NULL;
908 del_entry = del_entry->next)
909 {
910 if (0 == memcmp (&del_entry->delegate->issuer_key,
912 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
913 {
914 if (0 == strcmp (del_entry->delegate->issuer_attribute,
916 {
917 del_entry->refcount++;
918 }
919 }
920 }
921
924 return;
925 }
926 }
927 }
928
929 // Check for bidirectional crossmatch
930 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
931 del_entry != NULL;
932 del_entry = del_entry->next)
933 {
934 // only check entries not by backward algorithm
935 if (del_entry->from_bw)
936 {
937 // key of list entry matches actual key
938 if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key,
940 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
941 {
942 // compare entry subject attributes to this trailer (iss attr + old trailer)
943 if (0 == strcmp (del_entry->unresolved_attribute_delegation,
944 ds_entry->attr_trailer))
945 {
946 print_deleset (del_entry, "Forward:");
948 "Forward: Found match with above!\n");
949
951 // one node on the path still needs solutions: return
952 if (GNUNET_NO ==
953 handle_bidirectional_match (ds_entry, del_entry, vrh))
954 return;
955
957 return;
958 }
959 }
960 }
961 }
962
963 // Starting a new GNS lookup
964 vrh->pending_lookups++;
965 ds_entry->handle = vrh;
966
968 "Starting to look up trailer %s in zone %s\n",
969 ds_entry->attr_trailer,
971 ;
972
973 ds_entry->lookup_request =
976 &del->issuer_key,
980 ds_entry);
982 }
983
984 if (0 == vrh->pending_lookups)
985 {
986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
988 return;
989 }
990}
991
992
993static void
995 uint32_t rd_count,
996 const struct GNUNET_GNSRECORD_Data *rd)
997{
998 struct VerifyRequestHandle *vrh;
999 const struct GNUNET_ABD_DelegationRecord *sets;
1000 struct DelegateRecordEntry *del_pointer;
1001 struct DelegationSetQueueEntry *current_set;
1002 struct DelegationSetQueueEntry *ds_entry;
1003 struct DelegationSetQueueEntry *tmp_set;
1004 struct DelegationQueueEntry *dq_entry;
1005 char *expanded_attr;
1006 char *lookup_attribute;
1007
1008 current_set = cls;
1009 current_set->lookup_request = NULL;
1010 vrh = current_set->handle;
1011 vrh->pending_lookups--;
1012
1013 // Each OR
1014 for (uint32_t i = 0; i < rd_count; i++)
1015 {
1016 if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type)
1017 continue;
1018
1019 sets = rd[i].data;
1020 struct GNUNET_ABD_DelegationSet set[ntohl (sets->set_count)];
1022 "Found new attribute delegation with %d sets. Creating new Job...\n",
1023 ntohl (sets->set_count));
1024
1025 if (GNUNET_OK !=
1027 sets->data_size),
1028 (const char *) &sets[1],
1029 ntohl (sets->set_count),
1030 set))
1031 {
1032 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to deserialize!\n");
1033 continue;
1034 }
1035 dq_entry = GNUNET_new (struct DelegationQueueEntry);
1036 dq_entry->required_solutions = ntohl (sets->set_count);
1037 dq_entry->parent_set = current_set;
1038
1040 current_set->queue_entries_tail,
1041 dq_entry);
1042 // Each AND
1043 for (uint32_t j = 0; j < ntohl (sets->set_count); j++)
1044 {
1045 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1046 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1047 ds_entry->from_bw = true;
1048
1049 if (NULL != current_set->attr_trailer)
1050 {
1051 if (0 == set[j].subject_attribute_len)
1052 {
1053 GNUNET_asprintf (&expanded_attr, "%s", current_set->attr_trailer);
1054 }
1055 else
1056 {
1057 GNUNET_asprintf (&expanded_attr,
1058 "%s.%s",
1059 set[j].subject_attribute,
1060 current_set->attr_trailer);
1061 }
1062 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expanded to %s\n", expanded_attr);
1063 ds_entry->unresolved_attribute_delegation = expanded_attr;
1064 }
1065 else
1066 {
1067 if (0 != set[j].subject_attribute_len)
1068 {
1070 "Not Expanding %s\n",
1071 set[j].subject_attribute);
1074 }
1075 }
1076
1077 // Add a credential chain entry
1078 ds_entry->delegation_chain_entry =
1081 ds_entry->issuer_key = GNUNET_new (struct
1083 GNUNET_memcpy (ds_entry->issuer_key,
1084 &set[j].subject_key,
1085 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey));
1086 if (0 < set[j].subject_attribute_len)
1089 ds_entry->delegation_chain_entry->issuer_key = *current_set->issuer_key;
1091 GNUNET_strdup (current_set->lookup_attribute);
1092
1093 // Found new entry, repoting intermediate result
1095
1096 ds_entry->parent_queue_entry = dq_entry; // current_delegation;
1097
1101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking for cred match\n");
1102
1103 for (del_pointer = vrh->del_chain_head; del_pointer != NULL;
1104 del_pointer = del_pointer->next)
1105 {
1106 // If key and attribute match credential: continue and backtrack
1107 if (0 != memcmp (&set[j].subject_key,
1108 &del_pointer->delegate->issuer_key,
1109 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
1110 continue;
1112 "Checking if %s matches %s\n",
1114 del_pointer->delegate->issuer_attribute);
1115
1116 if (0 != strcmp (ds_entry->unresolved_attribute_delegation,
1117 del_pointer->delegate->issuer_attribute))
1118 continue;
1119
1120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found issuer\n");
1121 // increase refcount of the start delegation
1122 del_pointer->refcount++;
1123
1124 // Backtrack
1125 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
1126 tmp_set = tmp_set->parent_queue_entry->parent_set)
1127 {
1129 if (NULL != tmp_set->delegation_chain_entry)
1130 {
1131 vrh->delegation_chain_size++;
1134 tmp_set->delegation_chain_entry);
1135 }
1136 if (0 < tmp_set->parent_queue_entry->required_solutions)
1137 break;
1138 }
1139
1140 // if the break above is not called the condition of the for is met
1141 if (NULL == tmp_set->parent_queue_entry)
1142 {
1143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n");
1144 // Found match
1146 return;
1147 }
1148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not all solutions found yet.\n");
1149 continue;
1150 }
1151
1153 "Building new lookup request from %s\n",
1155 // Continue with next/new backward resolution
1156 char issuer_attribute_name[strlen (
1158 + 1];
1159 strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation);
1160 char *next_attr = strtok (issuer_attribute_name, ".");
1161 if (NULL == next_attr)
1162 {
1164 "Failed to parse next attribute\n");
1165 continue;
1166 }
1167 GNUNET_asprintf (&lookup_attribute, "%s", next_attr);
1168 GNUNET_asprintf (&ds_entry->lookup_attribute, "%s", next_attr);
1169 if (strlen (next_attr) ==
1170 strlen (ds_entry->unresolved_attribute_delegation))
1171 {
1172 ds_entry->attr_trailer = NULL;
1173 }
1174 else
1175 {
1176 next_attr += strlen (next_attr) + 1;
1177 ds_entry->attr_trailer = GNUNET_strdup (next_attr);
1178 }
1179
1180 // Check for bidirectional crossmatch
1181 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
1182 del_entry != NULL;
1183 del_entry = del_entry->next)
1184 {
1185 // only check entries added by forward algorithm
1186 if (! del_entry->from_bw)
1187 {
1188 // key of list entry matches actual key
1189 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
1191 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
1192 {
1193 // compare entry subject attributes to this trailer (iss attr + old trailer)
1194 if (0 == strcmp (del_entry->attr_trailer,
1196 {
1197 print_deleset (del_entry, "Backward:");
1199 "Backward: Found match with above!\n");
1200
1201 // if one node on the path still needs solutions: return
1202 if (GNUNET_NO ==
1203 handle_bidirectional_match (del_entry, ds_entry, vrh))
1204 break;
1205
1206 // Send lookup response
1208 return;
1209 }
1210 }
1211 }
1212 }
1213
1214 // Starting a new GNS lookup
1216 "Looking up %s\n",
1217 ds_entry->lookup_attribute);
1218 if (NULL != ds_entry->attr_trailer)
1220 "%s still to go...\n",
1221 ds_entry->attr_trailer);
1222
1223 vrh->pending_lookups++;
1224 ds_entry->handle = vrh;
1225 ds_entry->lookup_request =
1227 lookup_attribute,
1228 ds_entry->issuer_key, // issuer_key,
1232 ds_entry);
1233
1234 GNUNET_free (lookup_attribute);
1235 }
1236 }
1237
1238 if (0 == vrh->pending_lookups)
1239 {
1240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
1242 return;
1243 }
1244}
1245
1246
1252static int
1254{
1255
1256 struct VerifyRequestHandle *vrh = cls;
1257 struct DelegationSetQueueEntry *ds_entry;
1258 struct DelegateRecordEntry *del_entry;
1259
1260 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Backward Resolution...\n");
1261 if (0 == vrh->del_chain_size)
1262 {
1263 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegates found\n");
1265 return 1;
1266 }
1267
1268 // Pre-check with vrh->dele_chain_.. if match issuer_key
1269 // Backward: check every cred entry if match issuer key
1270 // otherwise: start at issuer and go down till match
1271 // A.a <- ...
1272 // X.x <- C
1273 // Y.y <- C
1274 // if not X.x or Y.y == A.a start at A
1275 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1276 del_entry = del_entry->next)
1277 {
1278 if (0 != memcmp (&del_entry->delegate->issuer_key,
1279 &vrh->issuer_key,
1280 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
1281 continue;
1282 if (0 !=
1283 strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
1284 continue;
1285 del_entry->refcount++;
1286 // Found match prematurely
1288 return 1;
1289 }
1290
1291
1292 // Check for attributes from the issuer and follow the chain
1293 // till you get the required subject's attributes
1294 char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1];
1295 strcpy (issuer_attribute_name, vrh->issuer_attribute);
1297 "Looking up %s\n",
1298 issuer_attribute_name);
1299 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1300 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1301 ds_entry->from_bw = true;
1303 GNUNET_memcpy (ds_entry->issuer_key,
1304 &vrh->issuer_key,
1305 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey));
1307
1312
1313 ds_entry->handle = vrh;
1315 ds_entry->unresolved_attribute_delegation = NULL;
1316 vrh->pending_lookups = 1;
1317
1318 // Start with backward resolution
1319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Backward Resolution\n");
1320
1322 issuer_attribute_name,
1323 &vrh->issuer_key, // issuer_key,
1327 ds_entry);
1328 return 0;
1329}
1330
1331
1332static int
1334{
1335
1336 struct VerifyRequestHandle *vrh = cls;
1337 struct DelegationSetQueueEntry *ds_entry;
1338 struct DelegateRecordEntry *del_entry;
1339
1340 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Forward Resolution...\n");
1341 // set to 0 and increase on each lookup: for fw multiple lookups (may be) started
1342 vrh->pending_lookups = 0;
1343
1344 if (0 == vrh->del_chain_size)
1345 {
1346 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n");
1348 return 1;
1349 }
1350
1351 // Pre-check with vrh->dele_chain_.. if match issuer_key
1352 // otherwise FW: start multiple lookups for each vrh->dele_chain
1353 // A.a <- ...
1354 // X.x <- C
1355 // Y.y <- C
1356 // if not X.x or Y.y == A.a start at X and at Y
1357 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1358 del_entry = del_entry->next)
1359 {
1360 if (0 != memcmp (&del_entry->delegate->issuer_key,
1361 &vrh->issuer_key,
1362 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
1363 continue;
1364 if (0 !=
1365 strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
1366 continue;
1367 del_entry->refcount++;
1368 // Found match prematurely
1370 return 1;
1371 }
1372
1373 // None match, therefore start for every delegation found a lookup chain
1374 // Return and end collect process on first chain iss <-> sub found
1375
1376 // ds_entry created belongs to the first lookup, vrh still has the
1377 // issuer+attr we look for
1378 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1379 del_entry = del_entry->next)
1380 {
1381
1383 "Looking for %s.%s\n",
1385 &del_entry->delegate->issuer_key),
1386 del_entry->delegate->issuer_attribute);
1387
1388 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1389 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1390 ds_entry->from_bw = false;
1392 GNUNET_memcpy (ds_entry->issuer_key,
1393 &del_entry->delegate->subject_key,
1394 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey));
1395
1398 del_entry->delegate->subject_key;
1399 ds_entry->delegation_chain_entry->subject_attribute = NULL;
1401 del_entry->delegate->issuer_key;
1404
1405 ds_entry->attr_trailer =
1407 ds_entry->handle = vrh;
1408
1409 vrh->pending_lookups++;
1410 // Start with forward resolution
1411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Forward Resolution\n");
1412
1413 ds_entry->lookup_request =
1416 &del_entry->delegate->issuer_key, // issuer_key,
1420 ds_entry);
1421 }
1422 return 0;
1423}
1424
1425
1426static int
1427check_verify (void *cls, const struct VerifyMessage *v_msg)
1428{
1429 size_t msg_size;
1430 const char *attr;
1431
1432 msg_size = ntohs (v_msg->header.size);
1433 if (msg_size < sizeof (struct VerifyMessage))
1434 {
1435 GNUNET_break (0);
1436 return GNUNET_SYSERR;
1437 }
1438 if (ntohs (v_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1439 {
1440 GNUNET_break (0);
1441 return GNUNET_SYSERR;
1442 }
1443 attr = (const char *) &v_msg[1];
1444
1445 if (strlen (attr) > GNUNET_ABD_MAX_LENGTH)
1446 {
1447 GNUNET_break (0);
1448 return GNUNET_SYSERR;
1449 }
1450 return GNUNET_OK;
1451}
1452
1453
1454static void
1455handle_verify (void *cls, const struct VerifyMessage *v_msg)
1456{
1457 struct VerifyRequestHandle *vrh;
1458 struct GNUNET_SERVICE_Client *client = cls;
1459 struct DelegateRecordEntry *del_entry;
1460 uint32_t delegate_count;
1461 uint32_t delegate_data_size;
1462 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1463 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1464 char *attrptr = attr;
1465 char *delegate_data;
1466 const char *utf_in;
1467
1468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n");
1469 utf_in = (const char *) &v_msg[1];
1470 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1471 GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len));
1472 issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
1473 vrh = GNUNET_new (struct VerifyRequestHandle);
1474 vrh->is_collect = false;
1476 vrh->client = client;
1477 vrh->request_id = v_msg->id;
1478 vrh->issuer_key = v_msg->issuer_key;
1479 vrh->subject_key = v_msg->subject_key;
1480 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1481 vrh->resolution_algo = ntohs (v_msg->resolution_algo);
1482
1483 vrh->del_chain_head = NULL;
1484 vrh->del_chain_tail = NULL;
1485 vrh->dsq_head = NULL;
1486 vrh->dsq_tail = NULL;
1487 vrh->del_chain_head = NULL;
1488 vrh->del_chain_tail = NULL;
1489
1491 if (0 == strlen (issuer_attribute))
1492 {
1493 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1495 return;
1496 }
1497
1498 // Parse delegates from verifaction message
1499 delegate_count = ntohl (v_msg->d_count);
1500 delegate_data_size = ntohs (v_msg->header.size)
1501 - sizeof (struct VerifyMessage)
1502 - ntohs (v_msg->issuer_attribute_len) - 1;
1503 struct GNUNET_ABD_Delegate delegates[delegate_count];
1504 memset (delegates,
1505 0,
1506 sizeof (struct GNUNET_ABD_Delegate) * delegate_count);
1507 delegate_data = (char *) &v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1;
1508 if (GNUNET_OK != GNUNET_ABD_delegates_deserialize (delegate_data_size,
1509 delegate_data,
1510 delegate_count,
1511 delegates))
1512 {
1513 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n");
1515 return;
1516 }
1517
1518 // Prepare vrh delegation chain for later validation
1519 for (uint32_t i = 0; i < delegate_count; i++)
1520 {
1521 del_entry = GNUNET_new (struct DelegateRecordEntry);
1522 del_entry->delegate =
1523 GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate)
1524 + delegates[i].issuer_attribute_len + 1);
1525 GNUNET_memcpy (del_entry->delegate,
1526 &delegates[i],
1527 sizeof (struct GNUNET_ABD_Delegate));
1528 GNUNET_memcpy (&del_entry->delegate[1],
1529 delegates[i].issuer_attribute,
1530 delegates[i].issuer_attribute_len);
1531 del_entry->delegate->issuer_attribute_len =
1532 delegates[i].issuer_attribute_len;
1533 del_entry->delegate->issuer_attribute = (char *) &del_entry->delegate[1];
1535 vrh->del_chain_tail,
1536 del_entry);
1537 vrh->del_chain_size++;
1538 }
1539
1540 // Switch resolution algo
1543 {
1545 return;
1547 }
1549 {
1551 }
1553 {
1555 }
1556}
1557
1558
1559static void
1561{
1562 struct VerifyRequestHandle *vrh = cls;
1564 "Got disconnected from namestore database.\n");
1565 vrh->dele_qe = NULL;
1567}
1568
1569
1570static void
1572{
1573 struct VerifyRequestHandle *vrh = cls;
1574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n");
1575
1576 // if both are set: bidirectional search, meaning start both chain resolutions
1579 {
1580 // if premature match found don't start bw resolution
1582 return;
1584 }
1586 {
1588 }
1590 {
1592 }
1593}
1594
1595
1596static void
1599 key,
1600 const char *label,
1601 unsigned int rd_count,
1602 const struct GNUNET_GNSRECORD_Data *rd)
1603{
1604 struct VerifyRequestHandle *vrh = cls;
1605 struct DelegateRecordEntry *del_entry;
1606 vrh->dele_qe = NULL;
1607
1608 for (uint32_t i = 0; i < rd_count; i++)
1609 {
1610 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
1611 continue;
1612 // only add the entries that are explicitly marked as private
1613 // and therefore symbolize the end of a chain
1614 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
1615 continue;
1616 del_entry = GNUNET_new (struct DelegateRecordEntry);
1617 del_entry->delegate = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].
1618 data_size);
1619 if (NULL == del_entry->delegate)
1620 {
1621 GNUNET_free (del_entry);
1622 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
1623 continue;
1624 }
1626 vrh->del_chain_tail,
1627 del_entry);
1628 vrh->del_chain_size++;
1629 }
1630
1632}
1633
1634
1635static void
1636handle_collect (void *cls, const struct CollectMessage *c_msg)
1637{
1638 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1639 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1640 struct VerifyRequestHandle *vrh;
1641 struct GNUNET_SERVICE_Client *client = cls;
1642 char *attrptr = attr;
1643 const char *utf_in;
1644
1645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received COLLECT message\n");
1646
1647 utf_in = (const char *) &c_msg[1];
1648 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1649
1650 GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len));
1651 issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0';
1652 vrh = GNUNET_new (struct VerifyRequestHandle);
1653 vrh->is_collect = true;
1655 vrh->client = client;
1656 vrh->request_id = c_msg->id;
1657 vrh->issuer_key = c_msg->issuer_key;
1659 );
1660 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1661 vrh->resolution_algo = ntohs (c_msg->resolution_algo);
1662
1663 vrh->del_chain_head = NULL;
1664 vrh->del_chain_tail = NULL;
1665 vrh->dsq_head = NULL;
1666 vrh->dsq_tail = NULL;
1667 vrh->del_chain_head = NULL;
1668 vrh->del_chain_tail = NULL;
1669
1670 if (0 == strlen (issuer_attribute))
1671 {
1672 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1674 return;
1675 }
1676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting delegates for subject\n");
1677
1678 // Get all delegates from subject
1679 vrh->dele_qe =
1681 &c_msg->subject_key,
1684 vrh,
1686 vrh);
1688}
1689
1690
1691static int
1692check_collect (void *cls, const struct CollectMessage *c_msg)
1693{
1694 size_t msg_size;
1695 const char *attr;
1696
1697 msg_size = ntohs (c_msg->header.size);
1698 if (msg_size < sizeof (struct CollectMessage))
1699 {
1700 GNUNET_break (0);
1701 return GNUNET_SYSERR;
1702 }
1703 if (ntohs (c_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1704 {
1705 GNUNET_break (0);
1706 return GNUNET_SYSERR;
1707 }
1708 attr = (const char *) &c_msg[1];
1709
1710 if (('\0' != attr[msg_size - sizeof (struct CollectMessage) - 1]) ||
1711 (strlen (attr) > GNUNET_ABD_MAX_LENGTH))
1712 {
1713 GNUNET_break (0);
1714 return GNUNET_SYSERR;
1715 }
1716 return GNUNET_OK;
1717}
1718
1719
1720static void
1722 struct GNUNET_SERVICE_Client *client,
1723 void *app_ctx)
1724{
1725 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1726}
1727
1728
1729static void *
1731 struct GNUNET_SERVICE_Client *client,
1732 struct GNUNET_MQ_Handle *mq)
1733{
1734 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1735 return client;
1736}
1737
1738
1746static void
1747run (void *cls,
1748 const struct GNUNET_CONFIGURATION_Handle *c,
1750{
1751
1752 gns = GNUNET_GNS_connect (c);
1753 if (NULL == gns)
1754 {
1755 fprintf (stderr, _ ("Failed to connect to GNS\n"));
1756 }
1758 if (NULL == namestore)
1759 {
1760 fprintf (stderr, _ ("Failed to connect to namestore\n"));
1761 }
1762
1765}
1766
1767
1773 "abd",
1775 &run,
1778 NULL,
1781 struct VerifyMessage,
1782 NULL),
1785 struct CollectMessage,
1786 NULL),
1788
1789/* end of gnunet-service-abd.c */
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
IPC messages between ABD API and ABD service.
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_deserialize(const char *data, size_t data_size)
int GNUNET_ABD_delegates_deserialize(size_t len, const char *src, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
Deserialize the given destination.
int GNUNET_ABD_delegation_set_deserialize(size_t len, const char *src, unsigned int d_count, struct GNUNET_ABD_DelegationSet *dsr)
Deserialize the given destination.
ssize_t GNUNET_ABD_delegation_chain_serialize(unsigned int d_count, const struct GNUNET_ABD_Delegation *dd, unsigned int c_count, const struct GNUNET_ABD_Delegate *cd, size_t dest_size, char *dest)
Serizalize the given delegation chain entries and abd.
size_t GNUNET_ABD_delegation_chain_get_size(unsigned int d_count, const struct GNUNET_ABD_Delegation *dd, unsigned int c_count, const struct GNUNET_ABD_Delegate *cd)
Calculate how many bytes we will need to serialize the given delegation chain and abd.
API to serialize and deserialize delegation chains and abds.
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
For ABD reverse lookups.
#define GNUNET_GNSRECORD_TYPE_DELEGATE
For ABD policies.
static int collect
Collect mode.
Definition gnunet-abd.c:133
static int verify
Verify mode.
Definition gnunet-abd.c:128
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_SCHEDULER_Task * shutdown_task
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 int del
Desired action is to remove a record.
static size_t data_size
Number of bytes in data.
static void handle_collect(void *cls, const struct CollectMessage *c_msg)
static struct GNUNET_GNS_Handle * gns
Handle to GNS service.
static struct VerifyRequestHandle * vrh_tail
Tail of the DLL.
static void forward_resolution(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
static int delegation_chain_bw_resolution_start(void *cls)
Result from GNS lookup.
static void cleanup_handle(struct VerifyRequestHandle *vrh)
static int check_verify(void *cls, const struct VerifyMessage *v_msg)
static struct VerifyRequestHandle * vrh_head
Head of the DLL.
static void handle_delegate_collection_error_cb(void *cls)
static void handle_delegate_collection_cb(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
static int handle_bidirectional_match(struct DelegationSetQueueEntry *actual_entry, struct DelegationSetQueueEntry *match_entry, struct VerifyRequestHandle *vrh)
static int delegation_chain_fw_resolution_start(void *cls)
static void cleanup_dsq_entry(struct DelegationSetQueueEntry *ds_entry)
static struct GNUNET_NAMESTORE_Handle * namestore
Handle to namestore service.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *handle)
Process Credential requests.
static void delegate_collection_finished(void *cls)
static char * partial_match(char *tmp_trail, char *tmp_subattr, char *parent_trail, char *issuer_attribute)
static void send_intermediate_response(struct VerifyRequestHandle *vrh, struct DelegationChainEntry *ch_entry, bool is_bw)
static void print_deleset(struct DelegationSetQueueEntry *dsentry, const char *text)
static void backward_resolution(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
static void handle_verify(void *cls, const struct VerifyMessage *v_msg)
static int check_collect(void *cls, const struct CollectMessage *c_msg)
static void send_lookup_response(struct VerifyRequestHandle *vrh)
#define GNUNET_ABD_MAX_LENGTH
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
API to the Credential service.
API to the GNS service.
API that can be used to manipulate GNS record data.
Identity service; implements identity management for GNUnet.
API that can be used to store naming information on a GNUnet node;.
Constants for network protocols.
API to create, modify and access statistics.
GNUNET_ABD_AlgoDirectionFlags
@ GNUNET_ABD_FLAG_BACKWARD
@ GNUNET_ABD_FLAG_FORWARD
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition gns_api.c:289
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_CRYPTO_BlindablePublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS.
Definition gns_api.c:421
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
Definition gns_api.c:313
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition gns_api.c:267
@ GNUNET_GNS_LO_DEFAULT
Defaults, look in cache, then in DHT.
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
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,...)
char * GNUNET_CRYPTO_blindable_public_key_to_string(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Creates a (Base32) string representation of the public key.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ 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_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT
#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT
#define GNUNET_MESSAGE_TYPE_ABD_COLLECT
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition scheduler.c:1339
#define GNUNET_SERVICE_MAIN(pd, service_name, service_options, init_cb, connect_cb, disconnect_cb, cls,...)
Creates the "main" function for a GNUnet service.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition service.c:2544
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2433
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition strings.c:475
static unsigned int size
Size of the "table".
Definition peer.c:68
#define _(String)
GNU gettext support macro.
Definition platform.h:179
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
Message from client to Credential service to collect credentials.
Definition abd.h:36
struct GNUNET_CRYPTO_BlindablePrivateKey subject_key
Subject public key.
Definition abd.h:45
uint16_t resolution_algo
Direction of the resolution algo.
Definition abd.h:60
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
Trust anchor.
Definition abd.h:50
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition abd.h:55
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
Definition abd.h:40
uint32_t id
Unique identifier for this request (for key collisions).
Definition abd.h:65
uint32_t refcount
Number of references in delegation chains.
struct DelegateRecordEntry * prev
DLL.
struct GNUNET_ABD_Delegate * delegate
Payload.
struct DelegateRecordEntry * next
DLL.
struct DelegationChainEntry * prev
DLL.
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
The issuer.
char * subject_attribute
The delegated attribute.
struct DelegationChainEntry * next
DLL.
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
The subject.
char * issuer_attribute
The issued attribute.
Message from ABD service to client: new results.
Definition abd.h:152
uint32_t id
Unique identifier for this request (for key collisions).
Definition abd.h:161
Message from ABD service to client: new results.
Definition abd.h:119
uint32_t del_found
Indicates if credential has been found at all.
Definition abd.h:133
uint32_t d_count
The number of delegations in the response.
Definition abd.h:138
uint32_t id
Unique identifier for this request (for key collisions).
Definition abd.h:128
uint32_t c_count
The number of credentials in the response.
Definition abd.h:143
DLL used for delegations Used for OR delegations.
struct DelegationQueueEntry * next
DLL.
struct DelegationQueueEntry * prev
DLL.
uint32_t required_solutions
Required solutions.
struct DelegationSetQueueEntry * parent_set
Parent set.
DLL for delegation sets Used for AND delegation set.
char * lookup_attribute
The current attribute to look up.
struct DelegationQueueEntry * parent_queue_entry
Parent QueueEntry.
char * attr_trailer
Trailing attribute context.
struct DelegationSetQueueEntry * prev
DLL.
struct GNUNET_CRYPTO_BlindablePublicKey * issuer_key
Issuer key.
char * issuer_attribute
Issuer attribute delegated to.
struct DelegationChainEntry * delegation_chain_entry
The delegation chain entry.
struct VerifyRequestHandle * handle
Verify handle.
struct DelegationQueueEntry * parent
Parent attribute delegation.
char * unresolved_attribute_delegation
Still to resolve delegation as string.
struct DelegationQueueEntry * queue_entries_head
Queue entries of this set.
struct DelegationSetQueueEntry * next
DLL.
struct DelegationQueueEntry * queue_entries_tail
Queue entries of this set.
bool from_bw
True if added by backward resolution.
struct GNUNET_GNS_LookupRequest * lookup_request
GNS handle.
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
The issuer of the credential.
const char * subject_attribute
The subject attribute.
const char * issuer_attribute
The issuer attribute.
uint32_t issuer_attribute_len
Length of the issuer attribute.
uint32_t subject_attribute_len
Length of the subject attribute.
struct GNUNET_CRYPTO_BlindableKeySignature signature
Signature of this credential.
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Public key of the subject this credential was issued to.
The attribute delegation record.
The attribute delegation record.
const char * subject_attribute
The subject attribute.
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Public key of the subject this attribute was delegated to.
uint32_t issuer_attribute_len
Length of the attribute.
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Public key of the subject this attribute was delegated to.
uint32_t subject_attribute_len
Length of the attribute.
const char * issuer_attribute
The attribute.
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
The issuer of the delegation.
const char * subject_attribute
The attribute.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
const void * data
Binary value stored in the DNS record.
Connection to the GNS service.
Definition gns_api.h:36
Handle to a lookup request.
Definition gns_api.c:48
Handle to a message queue.
Definition mq.c:87
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Handle to a client that is connected to a service.
Definition service.c:249
Handle to a service.
Definition service.c:116
Handle for the service.
Message from client to Credential service to verify attributes.
Definition abd.h:75
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
Trust anchor.
Definition abd.h:89
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
Definition abd.h:79
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Subject public key.
Definition abd.h:84
uint16_t resolution_algo
Direction of the resolution algo.
Definition abd.h:104
uint32_t id
Unique identifier for this request (for key collisions).
Definition abd.h:109
uint32_t d_count
Number of delegates.
Definition abd.h:94
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition abd.h:99
Handle to a lookup operation from api.
struct VerifyRequestHandle * prev
We keep these in a DLL.
struct GNUNET_NAMESTORE_QueueEntry * dele_qe
Delegate iterator for lookup.
struct GNUNET_SERVICE_Client * client
Handle to the requesting client.
uint32_t request_id
request id
struct DelegationQueueEntry * current_delegation
Current Delegation Pointer.
struct VerifyRequestHandle * next
We keep these in a DLL.
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
Issuer public key.
enum GNUNET_ABD_AlgoDirectionFlags resolution_algo
Direction of the resolution algo.
uint32_t del_chain_size
Delegate DLL size.
uint64_t pending_lookups
Pending lookups.
struct DelegationSetQueueEntry * dsq_head
List for bidirectional matching.
uint32_t delegation_chain_size
Size of delegation tree.
struct DelegationSetQueueEntry * dsq_tail
List for bidirectional matching.
struct DelegationChainEntry * delegation_chain_tail
Children of this attribute.
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Subject public key.
struct DelegateRecordEntry * del_chain_head
Delegate DLL.
bool is_collect
True if created by a collect request.
struct DelegateRecordEntry * del_chain_tail
Delegate DLL.
char * issuer_attribute
Issuer attribute.
struct DelegationChainEntry * delegation_chain_head
Children of this attribute.