aboutsummaryrefslogtreecommitdiff
path: root/src/credential/gnunet-service-credential.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-14 17:35:49 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-14 17:35:49 +0100
commit745f0dc8f07ef5275f829b13524d6afcc251e58a (patch)
tree32c8109d341b614fc6841831a111026713db0481 /src/credential/gnunet-service-credential.c
parent02066879bd7eb841d01e1359021de3bc3aca11e0 (diff)
downloadgnunet-745f0dc8f07ef5275f829b13524d6afcc251e58a.tar.gz
gnunet-745f0dc8f07ef5275f829b13524d6afcc251e58a.zip
-fixes, prettify
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r--src/credential/gnunet-service-credential.c82
1 files changed, 51 insertions, 31 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 8843abfd6..2b3eb8b4c 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -282,16 +282,21 @@ struct VerifyRequestHandle
282 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; 282 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
283 283
284 /** 284 /**
285 * Credential Chain 285 * Credential DLL
286 */ 286 */
287 struct CredentialRecordEntry *cred_chain_head; 287 struct CredentialRecordEntry *cred_chain_head;
288 288
289 /** 289 /**
290 * Credential Chain 290 * Credential DLL
291 */ 291 */
292 struct CredentialRecordEntry *cred_chain_tail; 292 struct CredentialRecordEntry *cred_chain_tail;
293 293
294 /** 294 /**
295 * Credential DLL size
296 */
297 uint32_t cred_chain_size;
298
299 /**
295 * Root Delegation Set 300 * Root Delegation Set
296 */ 301 */
297 struct DelegationSetEntry *root_set; 302 struct DelegationSetEntry *root_set;
@@ -402,7 +407,7 @@ static void
402cleanup_handle (struct VerifyRequestHandle *vrh) 407cleanup_handle (struct VerifyRequestHandle *vrh)
403{ 408{
404 struct CredentialRecordEntry *cr_entry; 409 struct CredentialRecordEntry *cr_entry;
405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
406 "Cleaning up...\n"); 411 "Cleaning up...\n");
407 if (NULL != vrh->lookup_request) 412 if (NULL != vrh->lookup_request)
408 { 413 {
@@ -439,7 +444,7 @@ shutdown_task (void *cls)
439{ 444{
440 struct VerifyRequestHandle *vrh; 445 struct VerifyRequestHandle *vrh;
441 446
442 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
443 "Shutting down!\n"); 448 "Shutting down!\n");
444 449
445 while (NULL != (vrh = vrh_head)) 450 while (NULL != (vrh = vrh_head))
@@ -515,10 +520,12 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
515 struct DelegationChainEntry *dce; 520 struct DelegationChainEntry *dce;
516 size_t size = vrh->credential_size; 521 size_t size = vrh->credential_size;
517 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; 522 struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size];
518 struct GNUNET_CREDENTIAL_Credential cred; 523 struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size];
524 struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
525 struct CredentialRecordEntry *cd;
519 int i; 526 int i;
520 527
521 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
522 "Sending response\n"); 529 "Sending response\n");
523 i = 0; 530 i = 0;
524 for (dce = vrh->delegation_chain_head; 531 for (dce = vrh->delegation_chain_head;
@@ -542,21 +549,29 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
542 * Get serialized record data 549 * Get serialized record data
543 * Append at the end of rmsg 550 * Append at the end of rmsg
544 */ 551 */
545 cred.issuer_key = vrh->credential->issuer_key; 552 i = 0;
546 cred.subject_key = vrh->credential->subject_key; 553 for (cd = vrh->cred_chain_head;
547 cred.issuer_attribute_len = strlen((char*)&vrh->credential[1])+1; 554 NULL != cd;
548 cred.issuer_attribute = (char*)&vrh->credential[1]; 555 cd = cd->next)
556 {
557 crd = cd->data;
558 cred[i].issuer_key = crd->issuer_key;
559 cred[i].subject_key = crd->subject_key;
560 cred[i].issuer_attribute_len = strlen((char*)&crd[1])+1;
561 cred[i].issuer_attribute = (char*)&crd[1];
562 i++;
563 }
549 size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size, 564 size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size,
550 dd, 565 dd,
551 &cred); 566 vrh->cred_chain_size,
552 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 567 cred);
553 "SIZE; %llu count: %d\n",size,vrh->delegation_chain_size);
554 env = GNUNET_MQ_msg_extra (rmsg, 568 env = GNUNET_MQ_msg_extra (rmsg,
555 size, 569 size,
556 GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT); 570 GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT);
557 //Assign id so that client can find associated request 571 //Assign id so that client can find associated request
558 rmsg->id = vrh->request_id; 572 rmsg->id = vrh->request_id;
559 rmsg->d_count = htonl (vrh->delegation_chain_size); 573 rmsg->d_count = htonl (vrh->delegation_chain_size);
574 rmsg->c_count = htonl (vrh->cred_chain_size);
560 575
561 if (NULL != vrh->credential) 576 if (NULL != vrh->credential)
562 rmsg->cred_found = htonl (GNUNET_YES); 577 rmsg->cred_found = htonl (GNUNET_YES);
@@ -566,7 +581,8 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
566 GNUNET_assert (-1 != 581 GNUNET_assert (-1 !=
567 GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, 582 GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size,
568 dd, 583 dd,
569 &cred, 584 vrh->cred_chain_size,
585 cred,
570 size, 586 size,
571 (char*)&rmsg[1])); 587 (char*)&rmsg[1]));
572 588
@@ -605,7 +621,7 @@ backward_resolution (void* cls,
605 current_set->lookup_request = NULL; 621 current_set->lookup_request = NULL;
606 vrh = current_set->handle; 622 vrh = current_set->handle;
607 vrh->pending_lookups--; 623 vrh->pending_lookups--;
608 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 624 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
609 "Got %d attrs\n", rd_count); 625 "Got %d attrs\n", rd_count);
610 626
611 // Each OR 627 // Each OR
@@ -616,7 +632,7 @@ backward_resolution (void* cls,
616 632
617 sets = rd[i].data; 633 sets = rd[i].data;
618 struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets->set_count)]; 634 struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets->set_count)];
619 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
620 "Found new attribute delegation with %d sets. Creating new Job...\n", 636 "Found new attribute delegation with %d sets. Creating new Job...\n",
621 ntohl (sets->set_count)); 637 ntohl (sets->set_count));
622 638
@@ -653,13 +669,13 @@ backward_resolution (void* cls,
653 set[j].subject_attribute, 669 set[j].subject_attribute,
654 current_set->attr_trailer); 670 current_set->attr_trailer);
655 } 671 }
656 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
657 "Expanded to %s\n", expanded_attr); 673 "Expanded to %s\n", expanded_attr);
658 ds_entry->unresolved_attribute_delegation = expanded_attr; 674 ds_entry->unresolved_attribute_delegation = expanded_attr;
659 } else { 675 } else {
660 if (0 != set[j].subject_attribute_len) 676 if (0 != set[j].subject_attribute_len)
661 { 677 {
662 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 678 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
663 "Not Expanding %s\n", set[j].subject_attribute); 679 "Not Expanding %s\n", set[j].subject_attribute);
664 ds_entry->unresolved_attribute_delegation = GNUNET_strdup (set[j].subject_attribute); 680 ds_entry->unresolved_attribute_delegation = GNUNET_strdup (set[j].subject_attribute);
665 } 681 }
@@ -682,7 +698,7 @@ backward_resolution (void* cls,
682 dq_entry->set_entries_tail, 698 dq_entry->set_entries_tail,
683 ds_entry); 699 ds_entry);
684 700
685 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
686 "Checking for cred match\n"); 702 "Checking for cred match\n");
687 /** 703 /**
688 * Check if this delegation already matches one of our credentials 704 * Check if this delegation already matches one of our credentials
@@ -695,14 +711,14 @@ backward_resolution (void* cls,
695 &cred_pointer->data->issuer_key, 711 &cred_pointer->data->issuer_key,
696 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) 712 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
697 continue; 713 continue;
698 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
699 "Checking if %s matches %s\n", 715 "Checking if %s matches %s\n",
700 ds_entry->unresolved_attribute_delegation, (char*)&cred[1]); 716 ds_entry->unresolved_attribute_delegation, (char*)&cred[1]);
701 717
702 if (0 != strcmp (ds_entry->unresolved_attribute_delegation, (char*)&cred[1])) 718 if (0 != strcmp (ds_entry->unresolved_attribute_delegation, (char*)&cred[1]))
703 continue; 719 continue;
704 720
705 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
706 "Found issuer\n"); 722 "Found issuer\n");
707 723
708 //Backtrack 724 //Backtrack
@@ -724,7 +740,7 @@ backward_resolution (void* cls,
724 740
725 if (NULL == tmp_set->parent_queue_entry) 741 if (NULL == tmp_set->parent_queue_entry)
726 { 742 {
727 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
728 "All solutions found\n"); 744 "All solutions found\n");
729 vrh->credential = GNUNET_malloc (cred_pointer->data_size); 745 vrh->credential = GNUNET_malloc (cred_pointer->data_size);
730 memcpy (vrh->credential, 746 memcpy (vrh->credential,
@@ -735,9 +751,12 @@ backward_resolution (void* cls,
735 send_lookup_response (vrh); 751 send_lookup_response (vrh);
736 return; 752 return;
737 } 753 }
754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
755 "Not all solutions found yet.\n");
756 continue;
738 757
739 } 758 }
740 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
741 "Building new lookup request from %s\n", 760 "Building new lookup request from %s\n",
742 ds_entry->unresolved_attribute_delegation); 761 ds_entry->unresolved_attribute_delegation);
743 //Continue with backward resolution 762 //Continue with backward resolution
@@ -759,10 +778,10 @@ backward_resolution (void* cls,
759 ds_entry->attr_trailer = GNUNET_strdup (next_attr); 778 ds_entry->attr_trailer = GNUNET_strdup (next_attr);
760 } 779 }
761 780
762 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 781 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
763 "Looking up %s\n", ds_entry->lookup_attribute); 782 "Looking up %s\n", ds_entry->lookup_attribute);
764 if (NULL != ds_entry->attr_trailer) 783 if (NULL != ds_entry->attr_trailer)
765 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 784 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
766 "%s still to go...\n", ds_entry->attr_trailer); 785 "%s still to go...\n", ds_entry->attr_trailer);
767 786
768 vrh->pending_lookups++; 787 vrh->pending_lookups++;
@@ -781,7 +800,7 @@ backward_resolution (void* cls,
781 800
782 if(0 == vrh->pending_lookups) 801 if(0 == vrh->pending_lookups)
783 { 802 {
784 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
785 "We are all out of attributes...\n"); 804 "We are all out of attributes...\n");
786 send_lookup_response (vrh); 805 send_lookup_response (vrh);
787 return; 806 return;
@@ -835,6 +854,7 @@ handle_credential_query (void* cls,
835 GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head, 854 GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head,
836 vrh->cred_chain_tail, 855 vrh->cred_chain_tail,
837 cr_entry); 856 cr_entry);
857 vrh->cred_chain_size++;
838 858
839 if (0 != memcmp (&crd->issuer_key, 859 if (0 != memcmp (&crd->issuer_key,
840 &vrh->issuer_key, 860 &vrh->issuer_key,
@@ -862,7 +882,7 @@ handle_credential_query (void* cls,
862 vrh->issuer_attribute); 882 vrh->issuer_attribute);
863 strcpy (issuer_attribute_name + strlen (vrh->issuer_attribute), 883 strcpy (issuer_attribute_name + strlen (vrh->issuer_attribute),
864 ".gnu"); 884 ".gnu");
865 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 885 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
866 "Looking up %s\n", issuer_attribute_name); 886 "Looking up %s\n", issuer_attribute_name);
867 ds_entry = GNUNET_new (struct DelegationSetEntry); 887 ds_entry = GNUNET_new (struct DelegationSetEntry);
868 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); 888 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
@@ -905,7 +925,7 @@ handle_verify (void *cls,
905 char *attrptr = attrs; 925 char *attrptr = attrs;
906 const char *utf_in; 926 const char *utf_in;
907 927
908 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 928 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
909 "Received VERIFY message\n"); 929 "Received VERIFY message\n");
910 930
911 utf_in = (const char *) &v_msg[1]; 931 utf_in = (const char *) &v_msg[1];
@@ -939,7 +959,7 @@ handle_verify (void *cls,
939 send_lookup_response (vrh); 959 send_lookup_response (vrh);
940 return; 960 return;
941 } 961 }
942 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 962 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
943 "Looking up %s\n", 963 "Looking up %s\n",
944 subject_attribute); 964 subject_attribute);
945 /** 965 /**
@@ -967,7 +987,7 @@ client_disconnect_cb (void *cls,
967 struct GNUNET_SERVICE_Client *client, 987 struct GNUNET_SERVICE_Client *client,
968 void *app_ctx) 988 void *app_ctx)
969{ 989{
970 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 990 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
971 "Client %p disconnected\n", 991 "Client %p disconnected\n",
972 client); 992 client);
973} 993}
@@ -985,7 +1005,7 @@ client_connect_cb (void *cls,
985 struct GNUNET_SERVICE_Client *client, 1005 struct GNUNET_SERVICE_Client *client,
986 struct GNUNET_MQ_Handle *mq) 1006 struct GNUNET_MQ_Handle *mq)
987{ 1007{
988 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1008 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
989 "Client %p connected\n", 1009 "Client %p connected\n",
990 client); 1010 client);
991 return client; 1011 return client;