summaryrefslogtreecommitdiff
path: root/src/credential/gnunet-service-credential.c
diff options
context:
space:
mode:
authorAndreas Ebner <pansy007@googlemail.com>2019-08-04 13:52:03 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-07 12:16:50 +0200
commit15b0d71a635f02f5e0291a695d35a65698fdea05 (patch)
tree5afc234a0ce848019d1098f3852fde06f14dcd98 /src/credential/gnunet-service-credential.c
parent93cd93a1330fb38add615f797ac9a87fc252ff98 (diff)
downloadgnunet-15b0d71a635f02f5e0291a695d35a65698fdea05.tar.gz
gnunet-15b0d71a635f02f5e0291a695d35a65698fdea05.zip
Clean up and renaming
- renamed a lot of variables/functions that no longer serve credential but delegate - correct printouts likewise - cleaned up test_credential_own.sh to use credential service issuer side storage - removed credential related parameters from VerifyRequestHandle struct
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r--src/credential/gnunet-service-credential.c217
1 files changed, 80 insertions, 137 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index da43334df..2d954f823 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -303,32 +303,17 @@ struct VerifyRequestHandle
303 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; 303 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
304 304
305 /** 305 /**
306 * Credential DLL 306 * Delegate DLL
307 */
308 struct CredentialRecordEntry *cred_chain_head;
309
310 /**
311 * Credential DLL
312 */
313 struct CredentialRecordEntry *cred_chain_tail;
314
315 /**
316 * Credential DLL size
317 */
318 uint32_t cred_chain_size;
319
320 /**
321 * Credential DLL
322 */ 307 */
323 struct DelegateRecordEntry *del_chain_head; 308 struct DelegateRecordEntry *del_chain_head;
324 309
325 /** 310 /**
326 * Credential DLL 311 * Delegate DLL
327 */ 312 */
328 struct DelegateRecordEntry *del_chain_tail; 313 struct DelegateRecordEntry *del_chain_tail;
329 314
330 /** 315 /**
331 * Credential DLL size 316 * Delegate DLL size
332 */ 317 */
333 uint32_t del_chain_size; 318 uint32_t del_chain_size;
334 319
@@ -358,19 +343,9 @@ struct VerifyRequestHandle
358 enum direction resolution_algo; 343 enum direction resolution_algo;
359 344
360 /** 345 /**
361 * Credential iterator 346 * Delegate iterator for lookup
362 */
363 struct GNUNET_NAMESTORE_ZoneIterator *cred_collection_iter;
364
365 /**
366 * Credential iterator
367 */ 347 */
368 struct GNUNET_NAMESTORE_QueueEntry *dele_qe; 348 struct GNUNET_NAMESTORE_QueueEntry *dele_qe;
369
370 /**
371 * Collect task
372 */
373 struct GNUNET_SCHEDULER_Task *collect_next_task;
374}; 349};
375 350
376 351
@@ -443,7 +418,7 @@ cleanup_delegation_set (struct DelegationSetQueueEntry *ds_entry)
443static void 418static void
444cleanup_handle (struct VerifyRequestHandle *vrh) 419cleanup_handle (struct VerifyRequestHandle *vrh)
445{ 420{
446 struct CredentialRecordEntry *cr_entry; 421 struct DelegateRecordEntry *del_entry;
447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n"); 422 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n");
448 if (NULL != vrh->lookup_request) { 423 if (NULL != vrh->lookup_request) {
449 GNUNET_GNS_lookup_cancel (vrh->lookup_request); 424 GNUNET_GNS_lookup_cancel (vrh->lookup_request);
@@ -451,13 +426,13 @@ cleanup_handle (struct VerifyRequestHandle *vrh)
451 } 426 }
452 cleanup_delegation_set (vrh->root_set); 427 cleanup_delegation_set (vrh->root_set);
453 GNUNET_free_non_null (vrh->issuer_attribute); 428 GNUNET_free_non_null (vrh->issuer_attribute);
454 for (cr_entry = vrh->cred_chain_head; NULL != vrh->cred_chain_head; 429 for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
455 cr_entry = vrh->cred_chain_head) { 430 del_entry = vrh->del_chain_head) {
456 GNUNET_CONTAINER_DLL_remove (vrh->cred_chain_head, 431 GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head,
457 vrh->cred_chain_tail, 432 vrh->del_chain_tail,
458 cr_entry); 433 del_entry);
459 GNUNET_free_non_null (cr_entry->credential); 434 GNUNET_free_non_null (del_entry->delegate);
460 GNUNET_free (cr_entry); 435 GNUNET_free (del_entry);
461 } 436 }
462 GNUNET_free (vrh); 437 GNUNET_free (vrh);
463} 438}
@@ -497,10 +472,9 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
497 struct DelegationChainResultMessage *rmsg; 472 struct DelegationChainResultMessage *rmsg;
498 struct DelegationChainEntry *dce; 473 struct DelegationChainEntry *dce;
499 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; 474 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size];
500 //TODO rename cred/cd
501 //TODO rename all methods using credential 475 //TODO rename all methods using credential
502 struct GNUNET_CREDENTIAL_Delegate cred[vrh->del_chain_size]; 476 struct GNUNET_CREDENTIAL_Delegate dele[vrh->del_chain_size];
503 struct DelegateRecordEntry *cd; 477 struct DelegateRecordEntry *del;
504 struct DelegateRecordEntry *tmp; 478 struct DelegateRecordEntry *tmp;
505 size_t size; 479 size_t size;
506 480
@@ -521,13 +495,13 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
521 } 495 }
522 496
523 // Remove all not needed credentials 497 // Remove all not needed credentials
524 for (cd = vrh->del_chain_head; NULL != cd;) { 498 for (del = vrh->del_chain_head; NULL != del;) {
525 if (cd->refcount > 0) { 499 if (del->refcount > 0) {
526 cd = cd->next; 500 del = del->next;
527 continue; 501 continue;
528 } 502 }
529 tmp = cd; 503 tmp = del;
530 cd = cd->next; 504 del = del->next;
531 GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head, 505 GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head,
532 vrh->del_chain_tail, 506 vrh->del_chain_tail,
533 tmp); 507 tmp);
@@ -536,25 +510,23 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
536 vrh->del_chain_size--; 510 vrh->del_chain_size--;
537 } 511 }
538 512
539 /** 513 // Get serialized record data
540 * Get serialized record data 514 // Append at the end of rmsg
541 * Append at the end of rmsg 515 del = vrh->del_chain_head;
542 */
543 cd = vrh->del_chain_head;
544 for (uint32_t i = 0; i < vrh->del_chain_size; i++) { 516 for (uint32_t i = 0; i < vrh->del_chain_size; i++) {
545 cred[i].issuer_key = cd->delegate->issuer_key; 517 dele[i].issuer_key = del->delegate->issuer_key;
546 cred[i].subject_key = cd->delegate->subject_key; 518 dele[i].subject_key = del->delegate->subject_key;
547 cred[i].issuer_attribute_len 519 dele[i].issuer_attribute_len
548 = strlen (cd->delegate->issuer_attribute) + 1; 520 = strlen (del->delegate->issuer_attribute) + 1;
549 cred[i].issuer_attribute = cd->delegate->issuer_attribute; 521 dele[i].issuer_attribute = del->delegate->issuer_attribute;
550 cred[i].expiration = cd->delegate->expiration; 522 dele[i].expiration = del->delegate->expiration;
551 cred[i].signature = cd->delegate->signature; 523 dele[i].signature = del->delegate->signature;
552 cd = cd->next; 524 del = del->next;
553 } 525 }
554 size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size, 526 size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size,
555 dd, 527 dd,
556 vrh->del_chain_size, 528 vrh->del_chain_size,
557 cred); 529 dele);
558 env = GNUNET_MQ_msg_extra (rmsg, 530 env = GNUNET_MQ_msg_extra (rmsg,
559 size, 531 size,
560 GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT); 532 GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT);
@@ -564,16 +536,16 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
564 rmsg->c_count = htonl (vrh->del_chain_size); 536 rmsg->c_count = htonl (vrh->del_chain_size);
565 537
566 if (0 < vrh->del_chain_size) 538 if (0 < vrh->del_chain_size)
567 rmsg->cred_found = htonl (GNUNET_YES); 539 rmsg->del_found = htonl (GNUNET_YES);
568 else 540 else
569 rmsg->cred_found = htonl (GNUNET_NO); 541 rmsg->del_found = htonl (GNUNET_NO);
570 542
571 GNUNET_assert ( 543 GNUNET_assert (
572 -1 544 -1
573 != GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, 545 != GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size,
574 dd, 546 dd,
575 vrh->del_chain_size, 547 vrh->del_chain_size,
576 cred, 548 dele,
577 size, 549 size,
578 (char *)&rmsg[1])); 550 (char *)&rmsg[1]));
579 551
@@ -648,7 +620,7 @@ partial_match(char *tmp_trail, char *tmp_subattr, char *parent_trail, char *issu
648} 620}
649 621
650static void 622static void
651test_resolution (void *cls, 623forward_resolution (void *cls,
652 uint32_t rd_count, 624 uint32_t rd_count,
653 const struct GNUNET_GNSRECORD_Data *rd) 625 const struct GNUNET_GNSRECORD_Data *rd)
654{ 626{
@@ -773,7 +745,7 @@ test_resolution (void *cls,
773 { 745 {
774 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found: Solution\n"); 746 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found: Solution\n");
775 747
776 // Add to delegation_chain 748 // Add found solution into delegation_chain
777 struct DelegationSetQueueEntry *tmp_set; 749 struct DelegationSetQueueEntry *tmp_set;
778 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry; 750 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
779 tmp_set = tmp_set->parent_queue_entry->parent_set) { 751 tmp_set = tmp_set->parent_queue_entry->parent_set) {
@@ -784,9 +756,6 @@ test_resolution (void *cls,
784 tmp_set->delegation_chain_entry); 756 tmp_set->delegation_chain_entry);
785 } 757 }
786 } 758 }
787 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "tmpentrylast %s %s\n",
788 GNUNET_CRYPTO_ecdsa_public_key_to_string(&vrh->delegation_chain_head->subject_key),
789 vrh->delegation_chain_head->subject_attribute);
790 759
791 // Increase refcount for this delegate 760 // Increase refcount for this delegate
792 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) { 761 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) {
@@ -819,7 +788,7 @@ test_resolution (void *cls,
819 &del->issuer_key, 788 &del->issuer_key,
820 GNUNET_GNSRECORD_TYPE_DELEGATE, 789 GNUNET_GNSRECORD_TYPE_DELEGATE,
821 GNUNET_GNS_LO_DEFAULT, 790 GNUNET_GNS_LO_DEFAULT,
822 &test_resolution, 791 &forward_resolution,
823 ds_entry); 792 ds_entry);
824 } 793 }
825 794
@@ -875,8 +844,6 @@ backward_resolution (void *cls,
875 dq_entry->required_solutions = ntohl (sets->set_count); 844 dq_entry->required_solutions = ntohl (sets->set_count);
876 dq_entry->parent_set = current_set; 845 dq_entry->parent_set = current_set;
877 846
878 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# New OR entry into queue\n");
879
880 GNUNET_CONTAINER_DLL_insert (current_set->queue_entries_head, 847 GNUNET_CONTAINER_DLL_insert (current_set->queue_entries_head,
881 current_set->queue_entries_tail, 848 current_set->queue_entries_tail,
882 dq_entry); 849 dq_entry);
@@ -953,7 +920,6 @@ backward_resolution (void *cls,
953 // Backtrack 920 // Backtrack
954 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry; 921 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
955 tmp_set = tmp_set->parent_queue_entry->parent_set) { 922 tmp_set = tmp_set->parent_queue_entry->parent_set) {
956 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# %s\n", tmp_set->unresolved_attribute_delegation);
957 tmp_set->parent_queue_entry->required_solutions--; 923 tmp_set->parent_queue_entry->required_solutions--;
958 if (NULL != tmp_set->delegation_chain_entry) { 924 if (NULL != tmp_set->delegation_chain_entry) {
959 vrh->delegation_chain_size++; 925 vrh->delegation_chain_size++;
@@ -982,7 +948,6 @@ backward_resolution (void *cls,
982 issuer_attribute_name[strlen (ds_entry->unresolved_attribute_delegation) 948 issuer_attribute_name[strlen (ds_entry->unresolved_attribute_delegation)
983 + 1]; 949 + 1];
984 strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation); 950 strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation);
985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Issuer Att Name: %s\n", issuer_attribute_name);
986 char *next_attr = strtok (issuer_attribute_name, "."); 951 char *next_attr = strtok (issuer_attribute_name, ".");
987 if (NULL == next_attr) { 952 if (NULL == next_attr) {
988 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 953 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1036,7 +1001,7 @@ backward_resolution (void *cls,
1036 * @param cls the closure (our client lookup handle) 1001 * @param cls the closure (our client lookup handle)
1037 */ 1002 */
1038static void 1003static void
1039delegation_chain_resolution_start (void *cls) 1004delegation_chain_bw_resolution_start (void *cls)
1040{ 1005{
1041 struct VerifyRequestHandle *vrh = cls; 1006 struct VerifyRequestHandle *vrh = cls;
1042 struct DelegationSetQueueEntry *ds_entry; 1007 struct DelegationSetQueueEntry *ds_entry;
@@ -1064,10 +1029,9 @@ delegation_chain_resolution_start (void *cls)
1064 return; 1029 return;
1065 } 1030 }
1066 1031
1067 /** 1032
1068 * Check for attributes from the issuer and follow the chain 1033 //Check for attributes from the issuer and follow the chain
1069 * till you get the required subject's attributes 1034 //till you get the required subject's attributes
1070 */
1071 char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1]; 1035 char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1];
1072 strcpy (issuer_attribute_name, vrh->issuer_attribute); 1036 strcpy (issuer_attribute_name, vrh->issuer_attribute);
1073 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1083,8 +1047,9 @@ delegation_chain_resolution_start (void *cls)
1083 ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute); 1047 ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute);
1084 vrh->root_set = ds_entry; 1048 vrh->root_set = ds_entry;
1085 vrh->pending_lookups = 1; 1049 vrh->pending_lookups = 1;
1050
1086 // Start with backward resolution 1051 // Start with backward resolution
1087 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Start Backward Resolution\n"); 1052 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Backward Resolution\n");
1088 1053
1089 ds_entry->lookup_request = GNUNET_GNS_lookup (gns, 1054 ds_entry->lookup_request = GNUNET_GNS_lookup (gns,
1090 issuer_attribute_name, 1055 issuer_attribute_name,
@@ -1146,8 +1111,6 @@ delegation_chain_fw_resolution_start (void *cls)
1146 // ds_entry created belongs to the first lookup, vrh still has the 1111 // ds_entry created belongs to the first lookup, vrh still has the
1147 // issuer+attr we look for 1112 // issuer+attr we look for
1148 for (del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) { 1113 for (del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) {
1149 //char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1];
1150 //strcpy (issuer_attribute_name, vrh->issuer_attribute);
1151 1114
1152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1153 "Looking for %s.%s\n", 1116 "Looking for %s.%s\n",
@@ -1159,23 +1122,20 @@ delegation_chain_fw_resolution_start (void *cls)
1159 GNUNET_memcpy (ds_entry->issuer_key, 1122 GNUNET_memcpy (ds_entry->issuer_key,
1160 &del_entry->delegate->subject_key, 1123 &del_entry->delegate->subject_key,
1161 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); 1124 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
1162 //ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute);
1163 ds_entry->attr_trailer = GNUNET_strdup(del_entry->delegate->issuer_attribute); 1125 ds_entry->attr_trailer = GNUNET_strdup(del_entry->delegate->issuer_attribute);
1164 ds_entry->handle = vrh; 1126 ds_entry->handle = vrh;
1165 // TODO: no lookup attribute for forward?
1166 //ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute);
1167 1127
1168 vrh->root_set = ds_entry; 1128 vrh->root_set = ds_entry;
1169 vrh->pending_lookups ++; 1129 vrh->pending_lookups ++;
1170 // Start with forward resolution 1130 // Start with forward resolution
1171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Start Forward Resolution\n"); 1131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Forward Resolution\n");
1172 1132
1173 ds_entry->lookup_request = GNUNET_GNS_lookup (gns, 1133 ds_entry->lookup_request = GNUNET_GNS_lookup (gns,
1174 GNUNET_GNS_EMPTY_LABEL_AT, 1134 GNUNET_GNS_EMPTY_LABEL_AT,
1175 &del_entry->delegate->issuer_key, // issuer_key, 1135 &del_entry->delegate->issuer_key, // issuer_key,
1176 GNUNET_GNSRECORD_TYPE_DELEGATE, 1136 GNUNET_GNSRECORD_TYPE_DELEGATE,
1177 GNUNET_GNS_LO_DEFAULT, 1137 GNUNET_GNS_LO_DEFAULT,
1178 &test_resolution, 1138 &forward_resolution,
1179 ds_entry); 1139 ds_entry);
1180 } 1140 }
1181} 1141}
@@ -1210,12 +1170,12 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
1210 struct VerifyRequestHandle *vrh; 1170 struct VerifyRequestHandle *vrh;
1211 struct GNUNET_SERVICE_Client *client = cls; 1171 struct GNUNET_SERVICE_Client *client = cls;
1212 struct DelegateRecordEntry *del_entry; 1172 struct DelegateRecordEntry *del_entry;
1213 uint32_t credentials_count; 1173 uint32_t delegate_count;
1214 uint32_t credential_data_size; 1174 uint32_t delegate_data_size;
1215 char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; 1175 char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
1216 char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; 1176 char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
1217 char *attrptr = attr; 1177 char *attrptr = attr;
1218 char *credential_data; 1178 char *delegate_data;
1219 const char *utf_in; 1179 const char *utf_in;
1220 1180
1221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n"); 1181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n");
@@ -1240,39 +1200,39 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
1240 } 1200 }
1241 1201
1242 // Parse delegates from verifaction message 1202 // Parse delegates from verifaction message
1243 credentials_count = ntohl (v_msg->c_count); 1203 delegate_count = ntohl (v_msg->d_count);
1244 credential_data_size = ntohs (v_msg->header.size) 1204 delegate_data_size = ntohs (v_msg->header.size)
1245 - sizeof (struct VerifyMessage) 1205 - sizeof (struct VerifyMessage)
1246 - ntohs (v_msg->issuer_attribute_len) - 1; 1206 - ntohs (v_msg->issuer_attribute_len) - 1;
1247 struct GNUNET_CREDENTIAL_Delegate credentials[credentials_count]; 1207 struct GNUNET_CREDENTIAL_Delegate delegates[delegate_count];
1248 memset (credentials, 1208 memset (delegates,
1249 0, 1209 0,
1250 sizeof (struct GNUNET_CREDENTIAL_Delegate) * credentials_count); 1210 sizeof (struct GNUNET_CREDENTIAL_Delegate) * delegate_count);
1251 credential_data = (char *)&v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1; 1211 delegate_data = (char *)&v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1;
1252 if (GNUNET_OK 1212 if (GNUNET_OK
1253 != GNUNET_CREDENTIAL_credentials_deserialize (credential_data_size, 1213 != GNUNET_CREDENTIAL_delegates_deserialize (delegate_data_size,
1254 credential_data, 1214 delegate_data,
1255 credentials_count, 1215 delegate_count,
1256 credentials)) { 1216 delegates)) {
1257 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize credentials!\n"); 1217 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n");
1258 send_lookup_response (vrh); 1218 send_lookup_response (vrh);
1259 return; 1219 return;
1260 } 1220 }
1261 1221
1262 // Prepare vrh delegation chain for later validation 1222 // Prepare vrh delegation chain for later validation
1263 for (uint32_t i = 0; i < credentials_count; i++) { 1223 for (uint32_t i = 0; i < delegate_count; i++) {
1264 del_entry = GNUNET_new (struct DelegateRecordEntry); 1224 del_entry = GNUNET_new (struct DelegateRecordEntry);
1265 del_entry->delegate 1225 del_entry->delegate
1266 = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_Delegate) 1226 = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_Delegate)
1267 + credentials[i].issuer_attribute_len + 1); 1227 + delegates[i].issuer_attribute_len + 1);
1268 GNUNET_memcpy (del_entry->delegate, 1228 GNUNET_memcpy (del_entry->delegate,
1269 &credentials[i], 1229 &delegates[i],
1270 sizeof (struct GNUNET_CREDENTIAL_Delegate)); 1230 sizeof (struct GNUNET_CREDENTIAL_Delegate));
1271 GNUNET_memcpy (&del_entry->delegate[1], 1231 GNUNET_memcpy (&del_entry->delegate[1],
1272 credentials[i].issuer_attribute, 1232 delegates[i].issuer_attribute,
1273 credentials[i].issuer_attribute_len); 1233 delegates[i].issuer_attribute_len);
1274 del_entry->delegate->issuer_attribute_len 1234 del_entry->delegate->issuer_attribute_len
1275 = credentials[i].issuer_attribute_len; 1235 = delegates[i].issuer_attribute_len;
1276 del_entry->delegate->issuer_attribute = (char *)&del_entry->delegate[1]; 1236 del_entry->delegate->issuer_attribute = (char *)&del_entry->delegate[1];
1277 GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head, 1237 GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head,
1278 vrh->del_chain_tail, 1238 vrh->del_chain_tail,
@@ -1282,10 +1242,8 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
1282 1242
1283 // Switch resolution algo 1243 // Switch resolution algo
1284 if(Backward == vrh->resolution_algo){ 1244 if(Backward == vrh->resolution_algo){
1285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++backward\n"); 1245 delegation_chain_bw_resolution_start (vrh);
1286 delegation_chain_resolution_start (vrh);
1287 } else if (Forward == vrh->resolution_algo){ 1246 } else if (Forward == vrh->resolution_algo){
1288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++forward\n");
1289 delegation_chain_fw_resolution_start (vrh); 1247 delegation_chain_fw_resolution_start (vrh);
1290 } else{ 1248 } else{
1291 //TODO 1249 //TODO
@@ -1293,26 +1251,24 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
1293} 1251}
1294 1252
1295static void 1253static void
1296handle_cred_collection_error_cb (void *cls) 1254handle_delegate_collection_error_cb (void *cls)
1297{ 1255{
1298 struct VerifyRequestHandle *vrh = cls; 1256 struct VerifyRequestHandle *vrh = cls;
1299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1300 "Got disconnected from namestore database.\n"); 1258 "Got disconnected from namestore database.\n");
1301 vrh->cred_collection_iter = NULL; 1259 vrh->dele_qe = NULL;
1302 send_lookup_response (vrh); 1260 send_lookup_response (vrh);
1303} 1261}
1304 1262
1305static void 1263static void
1306handle_cred_collection_finished_cb (void *cls) 1264delegate_collection_finished (void *cls)
1307{ 1265{
1308 struct VerifyRequestHandle *vrh = cls; 1266 struct VerifyRequestHandle *vrh = cls;
1309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting credentials.\n"); 1267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n");
1310 vrh->cred_collection_iter = NULL; 1268
1311 if(Backward == vrh->resolution_algo){ 1269 if(Backward == vrh->resolution_algo){
1312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++backward\n"); 1270 delegation_chain_bw_resolution_start (vrh);
1313 delegation_chain_resolution_start (vrh);
1314 } else if (Forward == vrh->resolution_algo){ 1271 } else if (Forward == vrh->resolution_algo){
1315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++forward\n");
1316 delegation_chain_fw_resolution_start (vrh); 1272 delegation_chain_fw_resolution_start (vrh);
1317 } else{ 1273 } else{
1318 //TODO 1274 //TODO
@@ -1320,7 +1276,7 @@ handle_cred_collection_finished_cb (void *cls)
1320} 1276}
1321 1277
1322static void 1278static void
1323tmp_handle_cred_collection_cb (void *cls, 1279handle_delegate_collection_cb (void *cls,
1324 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, 1280 const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
1325 const char *label, 1281 const char *label,
1326 unsigned int rd_count, 1282 unsigned int rd_count,
@@ -1350,9 +1306,8 @@ tmp_handle_cred_collection_cb (void *cls,
1350 del_entry); 1306 del_entry);
1351 vrh->del_chain_size++; 1307 vrh->del_chain_size++;
1352 } 1308 }
1353 // No need to collect next, should have all already 1309
1354 //vrh->collect_next_task = GNUNET_SCHEDULER_add_now (&collect_next, vrh); 1310 delegate_collection_finished(vrh);
1355 handle_cred_collection_finished_cb(vrh);
1356} 1311}
1357 1312
1358static void 1313static void
@@ -1386,27 +1341,15 @@ handle_collect (void *cls, const struct CollectMessage *c_msg)
1386 send_lookup_response (vrh); 1341 send_lookup_response (vrh);
1387 return; 1342 return;
1388 } 1343 }
1389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting credentials for subject\n"); 1344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting delegates for subject\n");
1390 /** 1345
1391 * First, get attribute from subject 1346 // Get all delegates from subject
1392 */
1393 // TODO NAMESTORE_lookup auf empty label statt iteration, iteration genutzt da nicht wusste welches label
1394 /*vrh->cred_collection_iter = GNUNET_NAMESTORE_zone_iteration_start (
1395 namestore,
1396 &c_msg->subject_key,
1397 &handle_cred_collection_error_cb,
1398 vrh,
1399 &handle_cred_collection_cb,
1400 vrh,
1401 &handle_cred_collection_finished_cb,
1402 vrh);*/
1403 //TODO rename tmp_handle_... and test_resolution..
1404 vrh->dele_qe = GNUNET_NAMESTORE_records_lookup (namestore, 1347 vrh->dele_qe = GNUNET_NAMESTORE_records_lookup (namestore,
1405 &c_msg->subject_key, 1348 &c_msg->subject_key,
1406 GNUNET_GNS_EMPTY_LABEL_AT, 1349 GNUNET_GNS_EMPTY_LABEL_AT,
1407 &handle_cred_collection_error_cb, 1350 &handle_delegate_collection_error_cb,
1408 vrh, 1351 vrh,
1409 &tmp_handle_cred_collection_cb, 1352 &handle_delegate_collection_cb,
1410 vrh); 1353 vrh);
1411 GNUNET_SERVICE_client_continue (vrh->client); 1354 GNUNET_SERVICE_client_continue (vrh->client);
1412} 1355}