From a80e5610fe689631da94242e05f5ad85b21b6b4d Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Wed, 14 Dec 2016 08:35:22 +0100 Subject: [PATCH] -fix --- src/credential/gnunet-credential.c | 19 +++++++++++++++---- src/credential/gnunet-service-credential.c | 14 +++++++++++--- src/credential/test_credential_verify.sh | 3 ++- 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, struct GNUNET_CREDENTIAL_Credential *cred) { int i; + char* iss_key; + char* sub_key; verify_request = NULL; if (NULL == cred) printf ("Failed.\n"); else { + iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->issuer_key); + sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key); + printf ("(0) %s.%s <- %s (Subject)\n", + iss_key, cred->issuer_attribute, + sub_key); + GNUNET_free (iss_key); + GNUNET_free (sub_key); for (i=0;icredential->issuer_key; - cred.subject_key = vrh->credential->issuer_key; + cred.subject_key = vrh->credential->subject_key; cred.issuer_attribute_len = strlen((char*)&vrh->credential[1]); cred.issuer_attribute = (char*)&vrh->credential[1]; size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->d_count, @@ -520,6 +520,7 @@ backward_resolution (void* cls, struct DelegationQueueEntry *current_delegation; struct DelegationQueueEntry *dq_entry; char *expanded_attr; + char *lookup_attribute; int i; @@ -605,6 +606,9 @@ backward_resolution (void* cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found issuer\n"); vrh->credential = GNUNET_malloc (cred_pointer->data_size); + memcpy (vrh->credential, + cred, + cred_pointer->data_size); vrh->credential_size = cred_pointer->data_size; vrh->chain_end = dq_entry; vrh->d_count = dq_entry->d_count; @@ -620,9 +624,12 @@ backward_resolution (void* cls, strcpy (issuer_attribute_name, dq_entry->unresolved_attribute_delegation); char *next_attr = strtok (issuer_attribute_name, "."); - GNUNET_asprintf (&dq_entry->lookup_attribute, + GNUNET_asprintf (&lookup_attribute, "%s.gnu", next_attr); + GNUNET_asprintf (&dq_entry->lookup_attribute, + "%s", + next_attr); if (strlen (next_attr) == strlen (dq_entry->unresolved_attribute_delegation)) { dq_entry->attr_trailer = NULL; @@ -640,13 +647,14 @@ backward_resolution (void* cls, vrh->pending_lookups++; dq_entry->handle = vrh; dq_entry->lookup_request = GNUNET_GNS_lookup (gns, - dq_entry->lookup_attribute, + lookup_attribute, dq_entry->issuer_key, //issuer_key, GNUNET_GNSRECORD_TYPE_ATTRIBUTE, GNUNET_GNS_LO_DEFAULT, NULL, //shorten_key, always NULL &backward_resolution, dq_entry); + GNUNET_free (lookup_attribute); } 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 #TODO2 Add -z swich like in gnunet-gns RES_CRED=`gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf` + #TODO cleanup properly gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf gnunet-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 if [ "$RES_CRED" != "Failed." ] then - echo $RES_CRED + echo -e "${RES_CRED}" exit 0 else echo "FAIL: Failed to verify credential $RES_CRED." -- 2.25.1