aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/credential/gnunet-credential.c19
-rw-r--r--src/credential/gnunet-service-credential.c14
-rwxr-xr-xsrc/credential/test_credential_verify.sh3
3 files changed, 28 insertions, 8 deletions
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c
index a728939dc..41b17ef66 100644
--- a/src/credential/gnunet-credential.c
+++ b/src/credential/gnunet-credential.c
@@ -162,26 +162,37 @@ handle_verify_result (void *cls,
162 struct GNUNET_CREDENTIAL_Credential *cred) 162 struct GNUNET_CREDENTIAL_Credential *cred)
163{ 163{
164 int i; 164 int i;
165 char* iss_key;
166 char* sub_key;
165 167
166 verify_request = NULL; 168 verify_request = NULL;
167 if (NULL == cred) 169 if (NULL == cred)
168 printf ("Failed.\n"); 170 printf ("Failed.\n");
169 else 171 else
170 { 172 {
173 iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->issuer_key);
174 sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key);
175 printf ("(0) %s.%s <- %s (Subject)\n",
176 iss_key, cred->issuer_attribute,
177 sub_key);
178 GNUNET_free (iss_key);
179 GNUNET_free (sub_key);
171 for (i=0;i<d_count;i++) 180 for (i=0;i<d_count;i++)
172 { 181 {
173 char* iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key); 182 iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key);
174 char* sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key); 183 sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key);
175 if (0 != dc[i].subject_attribute_len) 184 if (0 != dc[i].subject_attribute_len)
176 { 185 {
177 printf ("%s.%s <- %s.%s\n", 186 printf ("(%d) %s.%s <- %s.%s\n", i+1,
178 iss_key, dc[i].issuer_attribute, 187 iss_key, dc[i].issuer_attribute,
179 sub_key, dc[i].subject_attribute); 188 sub_key, dc[i].subject_attribute);
180 } else { 189 } else {
181 printf ("%s.%s <- %s\n", 190 printf ("(%d) %s.%s <- %s\n", i+1,
182 iss_key, dc[i].issuer_attribute, 191 iss_key, dc[i].issuer_attribute,
183 sub_key); 192 sub_key);
184 } 193 }
194 GNUNET_free (iss_key);
195 GNUNET_free (sub_key);
185 } 196 }
186 printf ("Successful.\n"); 197 printf ("Successful.\n");
187 } 198 }
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 01b955726..8f7d71b28 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -472,7 +472,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
472 * Append at the end of rmsg 472 * Append at the end of rmsg
473 */ 473 */
474 cred.issuer_key = vrh->credential->issuer_key; 474 cred.issuer_key = vrh->credential->issuer_key;
475 cred.subject_key = vrh->credential->issuer_key; 475 cred.subject_key = vrh->credential->subject_key;
476 cred.issuer_attribute_len = strlen((char*)&vrh->credential[1]); 476 cred.issuer_attribute_len = strlen((char*)&vrh->credential[1]);
477 cred.issuer_attribute = (char*)&vrh->credential[1]; 477 cred.issuer_attribute = (char*)&vrh->credential[1];
478 size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->d_count, 478 size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->d_count,
@@ -520,6 +520,7 @@ backward_resolution (void* cls,
520 struct DelegationQueueEntry *current_delegation; 520 struct DelegationQueueEntry *current_delegation;
521 struct DelegationQueueEntry *dq_entry; 521 struct DelegationQueueEntry *dq_entry;
522 char *expanded_attr; 522 char *expanded_attr;
523 char *lookup_attribute;
523 int i; 524 int i;
524 525
525 526
@@ -605,6 +606,9 @@ backward_resolution (void* cls,
605 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 606 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
606 "Found issuer\n"); 607 "Found issuer\n");
607 vrh->credential = GNUNET_malloc (cred_pointer->data_size); 608 vrh->credential = GNUNET_malloc (cred_pointer->data_size);
609 memcpy (vrh->credential,
610 cred,
611 cred_pointer->data_size);
608 vrh->credential_size = cred_pointer->data_size; 612 vrh->credential_size = cred_pointer->data_size;
609 vrh->chain_end = dq_entry; 613 vrh->chain_end = dq_entry;
610 vrh->d_count = dq_entry->d_count; 614 vrh->d_count = dq_entry->d_count;
@@ -620,9 +624,12 @@ backward_resolution (void* cls,
620 strcpy (issuer_attribute_name, 624 strcpy (issuer_attribute_name,
621 dq_entry->unresolved_attribute_delegation); 625 dq_entry->unresolved_attribute_delegation);
622 char *next_attr = strtok (issuer_attribute_name, "."); 626 char *next_attr = strtok (issuer_attribute_name, ".");
623 GNUNET_asprintf (&dq_entry->lookup_attribute, 627 GNUNET_asprintf (&lookup_attribute,
624 "%s.gnu", 628 "%s.gnu",
625 next_attr); 629 next_attr);
630 GNUNET_asprintf (&dq_entry->lookup_attribute,
631 "%s",
632 next_attr);
626 if (strlen (next_attr) == strlen (dq_entry->unresolved_attribute_delegation)) 633 if (strlen (next_attr) == strlen (dq_entry->unresolved_attribute_delegation))
627 { 634 {
628 dq_entry->attr_trailer = NULL; 635 dq_entry->attr_trailer = NULL;
@@ -640,13 +647,14 @@ backward_resolution (void* cls,
640 vrh->pending_lookups++; 647 vrh->pending_lookups++;
641 dq_entry->handle = vrh; 648 dq_entry->handle = vrh;
642 dq_entry->lookup_request = GNUNET_GNS_lookup (gns, 649 dq_entry->lookup_request = GNUNET_GNS_lookup (gns,
643 dq_entry->lookup_attribute, 650 lookup_attribute,
644 dq_entry->issuer_key, //issuer_key, 651 dq_entry->issuer_key, //issuer_key,
645 GNUNET_GNSRECORD_TYPE_ATTRIBUTE, 652 GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
646 GNUNET_GNS_LO_DEFAULT, 653 GNUNET_GNS_LO_DEFAULT,
647 NULL, //shorten_key, always NULL 654 NULL, //shorten_key, always NULL
648 &backward_resolution, 655 &backward_resolution,
649 dq_entry); 656 dq_entry);
657 GNUNET_free (lookup_attribute);
650 } 658 }
651 659
652 if(0 == vrh->pending_lookups) 660 if(0 == vrh->pending_lookups)
diff --git a/src/credential/test_credential_verify.sh b/src/credential/test_credential_verify.sh
index 012341f5f..6d69e337b 100755
--- a/src/credential/test_credential_verify.sh
+++ b/src/credential/test_credential_verify.sh
@@ -60,6 +60,7 @@ gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c
60#TODO2 Add -z swich like in gnunet-gns 60#TODO2 Add -z swich like in gnunet-gns
61RES_CRED=`gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf` 61RES_CRED=`gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf`
62 62
63
63#TODO cleanup properly 64#TODO cleanup properly
64gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf 65gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf
65gnunet-namestore -z gnu -d -n $GNU_PROJECT_ATTR -t ATTR -c test_credential_lookup.conf 66gnunet-namestore -z gnu -d -n $GNU_PROJECT_ATTR -t ATTR -c test_credential_lookup.conf
@@ -69,7 +70,7 @@ gnunet-arm -e -c test_credential_lookup.conf
69 70
70if [ "$RES_CRED" != "Failed." ] 71if [ "$RES_CRED" != "Failed." ]
71then 72then
72 echo $RES_CRED 73 echo -e "${RES_CRED}"
73 exit 0 74 exit 0
74else 75else
75 echo "FAIL: Failed to verify credential $RES_CRED." 76 echo "FAIL: Failed to verify credential $RES_CRED."