summaryrefslogtreecommitdiff
path: root/src/credential
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-14 08:35:22 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-14 08:35:22 +0100
commita80e5610fe689631da94242e05f5ad85b21b6b4d (patch)
tree4217defc298ad87c791ccf6b1d5dac04cf03aad4 /src/credential
parent8052eb6445f29eec791e7c473a15334a66c91141 (diff)
-fix
Diffstat (limited to 'src/credential')
-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,
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;i<d_count;i++)
{
- char* iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key);
- char* sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key);
+ iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key);
+ sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key);
if (0 != dc[i].subject_attribute_len)
{
- printf ("%s.%s <- %s.%s\n",
+ printf ("(%d) %s.%s <- %s.%s\n", i+1,
iss_key, dc[i].issuer_attribute,
sub_key, dc[i].subject_attribute);
} else {
- printf ("%s.%s <- %s\n",
+ printf ("(%d) %s.%s <- %s\n", i+1,
iss_key, dc[i].issuer_attribute,
sub_key);
}
+ GNUNET_free (iss_key);
+ GNUNET_free (sub_key);
}
printf ("Successful.\n");
}
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)
* Append at the end of rmsg
*/
cred.issuer_key = vrh->credential->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."