summaryrefslogtreecommitdiff
path: root/src/credential/gnunet-service-credential.c
diff options
context:
space:
mode:
authorAndreas Ebner <pansy007@googlemail.com>2019-08-18 13:46:05 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-07 12:17:29 +0200
commit6ad2e1f1dce42e5c998425e80f48d512638e278e (patch)
treebb8e2d7d10aca751dc5711746c802c061846aff0 /src/credential/gnunet-service-credential.c
parent7b749c91759eb75eda5cac1e02954cc82ef27db3 (diff)
downloadgnunet-6ad2e1f1dce42e5c998425e80f48d512638e278e.tar.gz
gnunet-6ad2e1f1dce42e5c998425e80f48d512638e278e.zip
Bidirectional implementation finished, more complex tests for bidirectional, cleanup fix, todos done:
- fixed cleanup to not cause errors and uncommented it again - added new tests for AND, linked roles and fw/bw - fixed an older bug to make test ..own_and2.sh work - replaced bidirectional matching of bw with unresolved_attribute.. (because it contains all the subject attributes/roles) - introduced extra function for bidirectional match handling (is the same for bw and fw and pretty long) - commandline: if not specified to use bw or fw search -> assume it's bidirectional - moved the bidirecitonal matching list to vrh and removed it from being global - valgrind on service (one error remaining, to be solved in future commits) - use the vrh->dsq_head/tail for the cleanup stuff
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r--src/credential/gnunet-service-credential.c368
1 files changed, 218 insertions, 150 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 9de16bf72..ee02042c8 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -293,6 +293,16 @@ struct VerifyRequestHandle
293 struct DelegationChainEntry *delegation_chain_tail; 293 struct DelegationChainEntry *delegation_chain_tail;
294 294
295 /** 295 /**
296 * List for bidirectional matching
297 */
298 struct DelegationSetQueueEntry *dsq_head;
299
300 /**
301 * List for bidirectional matching
302 */
303 struct DelegationSetQueueEntry *dsq_tail;
304
305 /**
296 * Issuer public key 306 * Issuer public key
297 */ 307 */
298 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; 308 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
@@ -357,12 +367,12 @@ struct VerifyRequestHandle
357/** 367/**
358 * Head of the DLL. 368 * Head of the DLL.
359 */ 369 */
360static struct VerifyRequestHandle *vrh_head; 370static struct VerifyRequestHandle *vrh_head = NULL;
361 371
362/** 372/**
363 * Tail of the DLL. 373 * Tail of the DLL.
364 */ 374 */
365static struct VerifyRequestHandle *vrh_tail; 375static struct VerifyRequestHandle *vrh_tail = NULL;
366 376
367/** 377/**
368 * Handle to the statistics service 378 * Handle to the statistics service
@@ -374,11 +384,6 @@ static struct GNUNET_STATISTICS_Handle *statistics;
374 */ 384 */
375static struct GNUNET_GNS_Handle *gns; 385static struct GNUNET_GNS_Handle *gns;
376 386
377//TODO vrh dependent
378static struct DelegationSetQueueEntry *dsq_head;
379static struct DelegationSetQueueEntry *dsq_tail;
380
381
382/** 387/**
383 * Handle to namestore service 388 * Handle to namestore service
384 */ 389 */
@@ -429,6 +434,45 @@ cleanup_delegation_set (struct DelegationSetQueueEntry *ds_entry)
429} 434}
430 435
431static void 436static void
437cleanup_dsq_list (struct VerifyRequestHandle *vrh)
438{
439 struct DelegationSetQueueEntry *ds_entry;
440
441 if (NULL == vrh->dsq_head)
442 return;
443
444 for (ds_entry = vrh->dsq_head; NULL != vrh->dsq_head;
445 ds_entry = vrh->dsq_head)
446 {
447 GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry);
448 GNUNET_free_non_null (ds_entry->issuer_key);
449 GNUNET_free_non_null (ds_entry->issuer_attribute);
450 GNUNET_free_non_null (ds_entry->attr_trailer);
451 // those fields are only set/used in bw search
452 if (ds_entry->from_bw)
453 {
454 GNUNET_free_non_null (ds_entry->lookup_attribute);
455 GNUNET_free_non_null (ds_entry->unresolved_attribute_delegation);
456 }
457 if (NULL != ds_entry->lookup_request)
458 {
459 GNUNET_GNS_lookup_cancel (ds_entry->lookup_request);
460 ds_entry->lookup_request = NULL;
461 }
462 if (NULL != ds_entry->delegation_chain_entry)
463 {
464 GNUNET_free_non_null (
465 ds_entry->delegation_chain_entry->subject_attribute);
466 GNUNET_free_non_null (ds_entry->delegation_chain_entry->issuer_attribute);
467 GNUNET_free (ds_entry->delegation_chain_entry);
468 }
469 //TODO: Free dq_entry, how?
470 //GNUNET_free (ds_entry->parent_queue_entry);
471 GNUNET_free (ds_entry);
472 }
473}
474
475static void
432cleanup_handle (struct VerifyRequestHandle *vrh) 476cleanup_handle (struct VerifyRequestHandle *vrh)
433{ 477{
434 struct DelegateRecordEntry *del_entry; 478 struct DelegateRecordEntry *del_entry;
@@ -438,7 +482,8 @@ cleanup_handle (struct VerifyRequestHandle *vrh)
438 GNUNET_GNS_lookup_cancel (vrh->lookup_request); 482 GNUNET_GNS_lookup_cancel (vrh->lookup_request);
439 vrh->lookup_request = NULL; 483 vrh->lookup_request = NULL;
440 } 484 }
441 cleanup_delegation_set (vrh->root_set); 485 //cleanup_delegation_set (vrh->root_set);
486 cleanup_dsq_list (vrh);
442 GNUNET_free_non_null (vrh->issuer_attribute); 487 GNUNET_free_non_null (vrh->issuer_attribute);
443 for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head; 488 for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
444 del_entry = vrh->del_chain_head) 489 del_entry = vrh->del_chain_head)
@@ -491,7 +536,6 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
491 struct DelegationChainResultMessage *rmsg; 536 struct DelegationChainResultMessage *rmsg;
492 struct DelegationChainEntry *dce; 537 struct DelegationChainEntry *dce;
493 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; 538 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size];
494 //TODO rename all methods using credential
495 struct GNUNET_CREDENTIAL_Delegate dele[vrh->del_chain_size]; 539 struct GNUNET_CREDENTIAL_Delegate dele[vrh->del_chain_size];
496 struct DelegateRecordEntry *del; 540 struct DelegateRecordEntry *del;
497 struct DelegateRecordEntry *tmp; 541 struct DelegateRecordEntry *tmp;
@@ -574,7 +618,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
574 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); 618 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env);
575 GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh); 619 GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh);
576 //TODO fix cleanup with bidirectional 620 //TODO fix cleanup with bidirectional
577 //cleanup_handle (vrh); 621 cleanup_handle (vrh);
578 622
579 GNUNET_STATISTICS_update (statistics, 623 GNUNET_STATISTICS_update (statistics,
580 "Completed verifications", 624 "Completed verifications",
@@ -639,6 +683,84 @@ partial_match (char *tmp_trail,
639} 683}
640 684
641static void 685static void
686print_deleset (struct DelegationSetQueueEntry *dsentry, char *text)
687{
688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
689 "%s %s.%s <- %s.%s\n",
690 text,
691 GNUNET_CRYPTO_ecdsa_public_key_to_string (
692 &dsentry->delegation_chain_entry->issuer_key),
693 dsentry->delegation_chain_entry->issuer_attribute,
694 GNUNET_CRYPTO_ecdsa_public_key_to_string (
695 &dsentry->delegation_chain_entry->subject_key),
696 dsentry->delegation_chain_entry->subject_attribute);
697}
698
699static int
700handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry,
701 struct DelegationSetQueueEntry *match_entry,
702 struct VerifyRequestHandle *vrh)
703{
704 struct DelegationSetQueueEntry *old_fw_parent;
705 struct DelegationSetQueueEntry *fw_entry = actual_entry;
706 struct DelegationSetQueueEntry *last_entry = match_entry;
707 // parent fixing, combine backward and forward chain parts
708 while (NULL != fw_entry->parent_queue_entry)
709 {
710 old_fw_parent = fw_entry->parent_queue_entry->parent_set;
711 // set parent
712 fw_entry->parent_queue_entry->parent_set = last_entry;
713
714 last_entry = fw_entry;
715 fw_entry = old_fw_parent;
716 }
717 // set last entry of chain as actual_entry
718 //actual_entry = last_entry;
719 // set refcount, loop all delegations
720 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head;
721 del_entry != NULL;
722 del_entry = del_entry->next)
723 {
724 if (0 != memcmp (&last_entry->delegation_chain_entry->subject_key,
725 &del_entry->delegate->issuer_key,
726 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
727 continue;
728 if (0 != strcmp (last_entry->delegation_chain_entry->subject_attribute,
729 del_entry->delegate->issuer_attribute))
730 continue;
731
732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found delegate.\n");
733 // increase refcount of the start delegation
734 del_entry->refcount++;
735 }
736 // backtrack
737 for (struct DelegationSetQueueEntry *tmp_set = last_entry;
738 NULL != tmp_set->parent_queue_entry;
739 tmp_set = tmp_set->parent_queue_entry->parent_set)
740 {
741 tmp_set->parent_queue_entry->required_solutions--;
742
743 // add new found entry to vrh
744 vrh->delegation_chain_size++;
745 GNUNET_CONTAINER_DLL_insert (vrh->delegation_chain_head,
746 vrh->delegation_chain_tail,
747 tmp_set->delegation_chain_entry);
748
749 // if one node on the path still needs solutions, this current
750 // patch cannot fullfil the conditions and therefore stops here
751 // however, it is in the vrh and can be used by the other paths
752 // related to this path/collection/verification
753 if (0 < tmp_set->parent_queue_entry->required_solutions)
754 {
755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
756 "Chain requires more solutions, waiting...\n");
757 return GNUNET_NO;
758 }
759 }
760 return GNUNET_YES;
761}
762
763static void
642forward_resolution (void *cls, 764forward_resolution (void *cls,
643 uint32_t rd_count, 765 uint32_t rd_count,
644 const struct GNUNET_GNSRECORD_Data *rd) 766 const struct GNUNET_GNSRECORD_Data *rd)
@@ -747,7 +869,6 @@ forward_resolution (void *cls,
747 869
748 // Start: Credential Chain Entry 870 // Start: Credential Chain Entry
749 // issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject) 871 // issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject)
750 // TODO: new ds_entry struct with subject_key (or one for both with contact_key or sth)
751 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); 872 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
752 GNUNET_memcpy (ds_entry->issuer_key, 873 GNUNET_memcpy (ds_entry->issuer_key,
753 &del->subject_key, 874 &del->subject_key,
@@ -816,41 +937,44 @@ forward_resolution (void *cls,
816 } 937 }
817 } 938 }
818 939
819 // TODO testing area 940 // Check for bidirectional crossmatch
820 941 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
821 // Check list 942 del_entry != NULL;
822 for (struct DelegationSetQueueEntry *del_entry = dsq_head; 943 del_entry = del_entry->next)
823 del_entry != NULL;
824 del_entry = del_entry->next)
825 { 944 {
826 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"--fw-------- %s.%s <- %s.%s\n", 945 // only check entries not by backward algorithm
827 GNUNET_CRYPTO_ecdsa_public_key_to_string(&del_entry->delegation_chain_entry->issuer_key), 946 if (del_entry->from_bw)
828 del_entry->delegation_chain_entry->issuer_attribute,
829 GNUNET_CRYPTO_ecdsa_public_key_to_string(&del_entry->delegation_chain_entry->subject_key),
830 del_entry->delegation_chain_entry->subject_attribute);
831
832 // only check entries not added by forward algorithm
833 if(del_entry->from_bw)
834 { 947 {
835 // key of list entry matches actual key 948 // key of list entry matches actual key
836 if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key, 949 if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key,
837 &ds_entry->delegation_chain_entry->issuer_key, 950 &ds_entry->delegation_chain_entry->issuer_key,
838 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) 951 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
839 { 952 {
840 // compare entry subject attributes to this trailer (iss attr + old trailer) 953 // compare entry subject attributes to this trailer (iss attr + old trailer)
841 if (0 == strcmp (del_entry->delegation_chain_entry->subject_attribute, 954 if (0 == strcmp (del_entry->unresolved_attribute_delegation,
842 ds_entry->attr_trailer)) 955 ds_entry->attr_trailer))
843 { 956 {
844 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"--fw-------- Found match with above!\n"); 957 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
958 "Forward: %s!\n",
959 del_entry->unresolved_attribute_delegation);
960 print_deleset (del_entry, "Forward:");
961 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
962 "Forward: Found match with above!\n");
963
964 // one node on the path still needs solutions: return
965 if (GNUNET_NO ==
966 handle_bidirectional_match (ds_entry, del_entry, vrh))
967 return;
968
845 send_lookup_response (vrh); 969 send_lookup_response (vrh);
846 return; 970 return;
847 } 971 }
848 } 972 }
849 } 973 }
850 } 974 }
851 // No crossmatch/bidirectional result, add this ds_entry for the bw algo to match 975 // No crossmatch/bidirectional found, add this ds_entry for the bw algo to match
852 ds_entry->from_bw = false; 976 ds_entry->from_bw = false;
853 GNUNET_CONTAINER_DLL_insert (dsq_head, dsq_tail, ds_entry); 977 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
854 978
855 // Starting a new GNS lookup 979 // Starting a new GNS lookup
856 vrh->pending_lookups++; 980 vrh->pending_lookups++;
@@ -879,17 +1003,6 @@ forward_resolution (void *cls,
879} 1003}
880 1004
881static void 1005static void
882print_deleset(struct DelegationSetQueueEntry *dsentry, char* text)
883{
884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"%s %s.%s <- %s.%s\n",
885 text,
886 GNUNET_CRYPTO_ecdsa_public_key_to_string(&dsentry->delegation_chain_entry->issuer_key),
887 dsentry->delegation_chain_entry->issuer_attribute,
888 GNUNET_CRYPTO_ecdsa_public_key_to_string(&dsentry->delegation_chain_entry->subject_key),
889 dsentry->delegation_chain_entry->subject_attribute);
890}
891
892static void
893backward_resolution (void *cls, 1006backward_resolution (void *cls,
894 uint32_t rd_count, 1007 uint32_t rd_count,
895 const struct GNUNET_GNSRECORD_Data *rd) 1008 const struct GNUNET_GNSRECORD_Data *rd)
@@ -987,9 +1100,10 @@ backward_resolution (void *cls,
987 1100
988 ds_entry->parent_queue_entry = dq_entry; // current_delegation; 1101 ds_entry->parent_queue_entry = dq_entry; // current_delegation;
989 1102
990 GNUNET_CONTAINER_DLL_insert (dq_entry->set_entries_head, 1103 // TODO required? everything in dsq_head list, change cleanup
1104 /*GNUNET_CONTAINER_DLL_insert (dq_entry->set_entries_head,
991 dq_entry->set_entries_tail, 1105 dq_entry->set_entries_tail,
992 ds_entry); 1106 ds_entry);*/
993 1107
994 /** 1108 /**
995 * Check if this delegation already matches one of our credentials 1109 * Check if this delegation already matches one of our credentials
@@ -1000,7 +1114,7 @@ backward_resolution (void *cls,
1000 del_pointer = del_pointer->next) 1114 del_pointer = del_pointer->next)
1001 { 1115 {
1002 // If key and attribute match credential: continue and backtrack 1116 // If key and attribute match credential: continue and backtrack
1003 if (0 != memcmp (&set->subject_key, 1117 if (0 != memcmp (&set[j].subject_key,
1004 &del_pointer->delegate->issuer_key, 1118 &del_pointer->delegate->issuer_key,
1005 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) 1119 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
1006 continue; 1120 continue;
@@ -1033,7 +1147,7 @@ backward_resolution (void *cls,
1033 break; 1147 break;
1034 } 1148 }
1035 1149
1036 // if the break above is not called the condition of the for is met 1150 // if the break above is not called the condition of the for is met
1037 if (NULL == tmp_set->parent_queue_entry) 1151 if (NULL == tmp_set->parent_queue_entry)
1038 { 1152 {
1039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n"); 1153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n");
@@ -1073,94 +1187,33 @@ backward_resolution (void *cls,
1073 ds_entry->attr_trailer = GNUNET_strdup (next_attr); 1187 ds_entry->attr_trailer = GNUNET_strdup (next_attr);
1074 } 1188 }
1075 1189
1076 1190 // Check for bidirectional crossmatch
1077 // TODO testing area 1191 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
1078 // Check list 1192 del_entry != NULL;
1079 for (struct DelegationSetQueueEntry *del_entry = dsq_head; 1193 del_entry = del_entry->next)
1080 del_entry != NULL;
1081 del_entry = del_entry->next)
1082 { 1194 {
1083 print_deleset(del_entry, "-----bw----- "); 1195 // only check entries added by forward algorithm
1084 1196 if (!del_entry->from_bw)
1085 // only check entries not added by forward algorithm
1086 if(!del_entry->from_bw)
1087 { 1197 {
1088 // key of list entry matches actual key 1198 // key of list entry matches actual key
1089 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key, 1199 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
1090 &ds_entry->delegation_chain_entry->subject_key, 1200 &ds_entry->delegation_chain_entry->subject_key,
1091 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) 1201 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
1092 { 1202 {
1093 // compare entry subject attributes to this trailer (iss attr + old trailer) 1203 // compare entry subject attributes to this trailer (iss attr + old trailer)
1094 if (0 == strcmp (del_entry->attr_trailer, 1204 if (0 == strcmp (del_entry->attr_trailer,
1095 ds_entry->delegation_chain_entry->subject_attribute)) 1205 ds_entry->unresolved_attribute_delegation))
1096 { 1206 {
1097 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"--bw-------- Found match with above!\n"); 1207 print_deleset (del_entry, "Backward:");
1098 1208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1099 //TODO parents are not set correctly, for FW parents are going down in the chain 1209 "Backward: Found match with above!\n");
1100 // and for BW parents are going up
1101 // therefore: parent fixing needs to be done and then the stuff from above
1102 // backtrack(required solutions) and refcount++
1103 // might need some functions cuz its getting real big in here
1104
1105 struct DelegationSetQueueEntry *old_fw_parent;
1106 struct DelegationSetQueueEntry *fw_entry = del_entry;
1107 struct DelegationSetQueueEntry *bw_entry = ds_entry;
1108 // parentset and add
1109 while(NULL != fw_entry->parent_queue_entry)
1110 {
1111 print_deleset(fw_entry, "-----in while----- ");
1112 old_fw_parent = fw_entry->parent_queue_entry->parent_set;
1113 // set parent
1114 fw_entry->parent_queue_entry->parent_set = bw_entry;
1115 1210
1116 bw_entry = fw_entry; 1211 // if one node on the path still needs solutions: return
1117 fw_entry = old_fw_parent; 1212 if (GNUNET_NO ==
1118 } 1213 handle_bidirectional_match (del_entry, ds_entry, vrh))
1119 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NACH WHILE\n"); 1214 break;
1120 // set last entry of chain as actual ds_entry
1121 ds_entry = bw_entry;
1122 // set refcount, loop all delegations
1123 for (del_pointer = vrh->del_chain_head; del_pointer != NULL;
1124 del_pointer = del_pointer->next)
1125 {
1126 if (0 != memcmp (&ds_entry->delegation_chain_entry->subject_key,
1127 &del_pointer->delegate->issuer_key,
1128 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
1129 continue;
1130 if (0 != strcmp (ds_entry->delegation_chain_entry->subject_attribute,
1131 del_pointer->delegate->issuer_attribute))
1132 continue;
1133
1134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found delegate.\n");
1135 // increase refcount of the start delegation
1136 del_pointer->refcount++;
1137 }
1138 // backtrack
1139 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
1140 tmp_set = tmp_set->parent_queue_entry->parent_set)
1141 {
1142 //TODO set refcount
1143 print_deleset(tmp_set, "-----ENDSET----- ");
1144 tmp_set->parent_queue_entry->required_solutions--;
1145 1215
1146 // add new found entry to vrh 1216 // Send lookup response
1147 vrh->delegation_chain_size++;
1148 GNUNET_CONTAINER_DLL_insert (vrh->delegation_chain_head,
1149 vrh->delegation_chain_tail,
1150 tmp_set->delegation_chain_entry);
1151
1152 // if one node on the path still needs solutions, this current
1153 // patch cannot fullfil the conditions and therefore stops here
1154 // however, it is in the vrh and can be used by the other paths
1155 // related to this path/collection/verification
1156 if (0 < tmp_set->parent_queue_entry->required_solutions)
1157 {
1158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Chain requires more solutions, waiting...\n");
1159 return;
1160 }
1161 }
1162 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NACH FOR\n");
1163
1164 send_lookup_response (vrh); 1217 send_lookup_response (vrh);
1165 return; 1218 return;
1166 } 1219 }
@@ -1168,11 +1221,11 @@ backward_resolution (void *cls,
1168 } 1221 }
1169 } 1222 }
1170 // No crossmatch/bidirectional result, add this ds_entry for the bw algo to match 1223 // No crossmatch/bidirectional result, add this ds_entry for the bw algo to match
1171 ds_entry->from_bw = true; 1224 ds_entry->from_bw = true;
1172 GNUNET_CONTAINER_DLL_insert (dsq_head, dsq_tail, ds_entry);
1173
1174 1225
1226 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1175 1227
1228 // Starting a new GNS lookup
1176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1229 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1177 "Looking up %s\n", 1230 "Looking up %s\n",
1178 ds_entry->lookup_attribute); 1231 ds_entry->lookup_attribute);
@@ -1225,6 +1278,13 @@ delegation_chain_bw_resolution_start (void *cls)
1225 return; 1278 return;
1226 } 1279 }
1227 1280
1281 // Pre-check with vrh->dele_chain_.. if match issuer_key
1282 // Backward: check every cred entry if match issuer key
1283 // otherwise: start at issuer and go down till match
1284 // A.a <- ...
1285 // X.x <- C
1286 // Y.y <- C
1287 // if not X.x or Y.y == A.a stat at A
1228 for (del_entry = vrh->del_chain_head; del_entry != NULL; 1288 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1229 del_entry = del_entry->next) 1289 del_entry = del_entry->next)
1230 { 1290 {
@@ -1283,19 +1343,6 @@ delegation_chain_fw_resolution_start (void *cls)
1283 // set to 0 and increase on each lookup: for fw multiple lookups (may be) started 1343 // set to 0 and increase on each lookup: for fw multiple lookups (may be) started
1284 vrh->pending_lookups = 0; 1344 vrh->pending_lookups = 0;
1285 1345
1286 //TODO no pre-check with vrh->dele_chain_bla if match issuer_key
1287 //otherwise: start mutliple lookups for each vrh->dele_chain
1288 // A.a <- ...
1289 // X.x <- C
1290 // Y.y <- C
1291 // wenn X.x oder Y.y nicht == A.a dann starte bei X und bei Y
1292
1293 // bei backward: check every cred entry if match issuer key
1294 // otherwise: start at issuer and go down till match
1295 // A.a <- ...
1296 // X.x <- C
1297 // Y.y <- C
1298 // wenn X.x oder Y.y nicht == A.a dann starte von A
1299 if (0 == vrh->del_chain_size) 1346 if (0 == vrh->del_chain_size)
1300 { 1347 {
1301 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n"); 1348 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n");
@@ -1303,7 +1350,12 @@ delegation_chain_fw_resolution_start (void *cls)
1303 return; 1350 return;
1304 } 1351 }
1305 1352
1306 // Check if one of the delegations of the subject already match 1353 // Pre-check with vrh->dele_chain_.. if match issuer_key
1354 // otherwise FW: start mutliple lookups for each vrh->dele_chain
1355 // A.a <- ...
1356 // X.x <- C
1357 // Y.y <- C
1358 // if not X.x or Y.y == A.a start at X and at Y
1307 for (del_entry = vrh->del_chain_head; del_entry != NULL; 1359 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1308 del_entry = del_entry->next) 1360 del_entry = del_entry->next)
1309 { 1361 {
@@ -1337,7 +1389,6 @@ delegation_chain_fw_resolution_start (void *cls)
1337 1389
1338 ds_entry = GNUNET_new (struct DelegationSetQueueEntry); 1390 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1339 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); 1391 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
1340 // TODO: new ds_entry struct with subject_key (or one for both with contact_key or sth)
1341 GNUNET_memcpy (ds_entry->issuer_key, 1392 GNUNET_memcpy (ds_entry->issuer_key,
1342 &del_entry->delegate->subject_key, 1393 &del_entry->delegate->subject_key,
1343 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); 1394 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
@@ -1416,6 +1467,13 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
1416 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); 1467 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1417 vrh->resolution_algo = ntohs (v_msg->resolution_algo); 1468 vrh->resolution_algo = ntohs (v_msg->resolution_algo);
1418 1469
1470 vrh->del_chain_head = NULL;
1471 vrh->del_chain_tail = NULL;
1472 vrh->dsq_head = NULL;
1473 vrh->dsq_tail = NULL;
1474 vrh->del_chain_head = NULL;
1475 vrh->del_chain_tail = NULL;
1476
1419 GNUNET_SERVICE_client_continue (vrh->client); 1477 GNUNET_SERVICE_client_continue (vrh->client);
1420 if (0 == strlen (issuer_attribute)) 1478 if (0 == strlen (issuer_attribute))
1421 { 1479 {
@@ -1467,12 +1525,14 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
1467 } 1525 }
1468 1526
1469 // Switch resolution algo 1527 // Switch resolution algo
1470 if(GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo && GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo) 1528 if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo &&
1529 GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo)
1471 { 1530 {
1472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "--------BOTH\n"); 1531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "--------BOTH\n");
1473 delegation_chain_fw_resolution_start (vrh); 1532 delegation_chain_fw_resolution_start (vrh);
1474 delegation_chain_bw_resolution_start (vrh); 1533 delegation_chain_bw_resolution_start (vrh);
1475 } else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo) 1534 }
1535 else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo)
1476 { 1536 {
1477 delegation_chain_bw_resolution_start (vrh); 1537 delegation_chain_bw_resolution_start (vrh);
1478 } 1538 }
@@ -1498,13 +1558,14 @@ delegate_collection_finished (void *cls)
1498 struct VerifyRequestHandle *vrh = cls; 1558 struct VerifyRequestHandle *vrh = cls;
1499 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n"); 1559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n");
1500 1560
1501 //TODO correct calls 1561 // if both are set: bidirectional search, meaning start both chain resolutions
1502 if(GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo && GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo) 1562 if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo &&
1563 GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo)
1503 { 1564 {
1504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "--------BOTH\n");
1505 delegation_chain_fw_resolution_start (vrh); 1565 delegation_chain_fw_resolution_start (vrh);
1506 delegation_chain_bw_resolution_start (vrh); 1566 delegation_chain_bw_resolution_start (vrh);
1507 }else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo) 1567 }
1568 else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo)
1508 { 1569 {
1509 delegation_chain_bw_resolution_start (vrh); 1570 delegation_chain_bw_resolution_start (vrh);
1510 } 1571 }
@@ -1581,6 +1642,13 @@ handle_collect (void *cls, const struct CollectMessage *c_msg)
1581 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); 1642 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1582 vrh->resolution_algo = ntohs (c_msg->resolution_algo); 1643 vrh->resolution_algo = ntohs (c_msg->resolution_algo);
1583 1644
1645 vrh->del_chain_head = NULL;
1646 vrh->del_chain_tail = NULL;
1647 vrh->dsq_head = NULL;
1648 vrh->dsq_tail = NULL;
1649 vrh->del_chain_head = NULL;
1650 vrh->del_chain_tail = NULL;
1651
1584 if (0 == strlen (issuer_attribute)) 1652 if (0 == strlen (issuer_attribute))
1585 { 1653 {
1586 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n"); 1654 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");