gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 52/171: -fixes, prettify


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 52/171: -fixes, prettify
Date: Thu, 04 Jan 2018 16:09:20 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 745f0dc8f07ef5275f829b13524d6afcc251e58a
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Wed Dec 14 17:35:49 2016 +0100

    -fixes, prettify
---
 src/credential/credential.h                  |  7 ++-
 src/credential/credential_api.c              | 10 +++-
 src/credential/credential_serialization.c    | 75 +++++++++++++++----------
 src/credential/credential_serialization.h    |  6 ++
 src/credential/gnunet-credential.c           | 29 ++++++----
 src/credential/gnunet-service-credential.c   | 82 +++++++++++++++++-----------
 src/credential/plugin_gnsrecord_credential.c | 15 +----
 src/credential/plugin_rest_credential.c      | 26 ++++++---
 src/credential/test_credential_verify.sh     |  4 +-
 src/include/gnunet_credential_service.h      | 24 ++------
 10 files changed, 160 insertions(+), 118 deletions(-)

diff --git a/src/credential/credential.h b/src/credential/credential.h
index 209fcdcaa..3ba8e9c9e 100644
--- a/src/credential/credential.h
+++ b/src/credential/credential.h
@@ -90,10 +90,15 @@ struct VerifyResultMessage
   uint32_t cred_found GNUNET_PACKED;
 
   /**
-   * The number of credentials in the response
+   * The number of delegations in the response
    */
   uint32_t d_count GNUNET_PACKED;
 
+  /**
+   * The number of credentials in the response
+   */
+  uint32_t c_count GNUNET_PACKED;
+
   /* followed by ad_count GNUNET_CREDENTIAL_RecordData structs*/
 
 };
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c
index cae670206..860504e61 100644
--- a/src/credential/credential_api.c
+++ b/src/credential/credential_api.c
@@ -216,8 +216,9 @@ handle_result (void *cls,
   struct GNUNET_CREDENTIAL_Request *vr;
   size_t mlen = ntohs (vr_msg->header.size) - sizeof (*vr_msg);
   uint32_t d_count = ntohl (vr_msg->d_count);
+  uint32_t c_count = ntohl (vr_msg->c_count);
   struct GNUNET_CREDENTIAL_Delegation d_chain[d_count];
-  struct GNUNET_CREDENTIAL_Credential cred;
+  struct GNUNET_CREDENTIAL_Credential creds[c_count];
   GNUNET_CREDENTIAL_VerifyResultProcessor proc;
   void *proc_cls;
 
@@ -239,18 +240,21 @@ handle_result (void *cls,
                                                        (const char*) 
&vr_msg[1],
                                                        d_count,
                                                        d_chain,
-                                                       &cred));
+                                                       c_count,
+                                                       creds));
   if (GNUNET_NO == ntohl (vr_msg->cred_found))
   {
     proc (proc_cls,
           0,
           NULL,
+          0,
           NULL); // TODO
   } else {
     proc (proc_cls,
           d_count,
           d_chain,
-          &cred);
+          c_count,
+          creds);
   }
 }
 
diff --git a/src/credential/credential_serialization.c 
b/src/credential/credential_serialization.c
index 99138441e..b08920d96 100644
--- a/src/credential/credential_serialization.c
+++ b/src/credential/credential_serialization.c
@@ -184,18 +184,21 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
  *
  * @param d_count number of delegation chain entries
  * @param dd array of #GNUNET_CREDENTIAL_Delegation
+ * @param c_count number of credential entries
  * @param cd a #GNUNET_CREDENTIAL_Credential
  * @return the required size to serialize
  */
 size_t
 GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
                                              const struct 
GNUNET_CREDENTIAL_Delegation *dd,
+                                             unsigned int c_count,
                                              const struct 
GNUNET_CREDENTIAL_Credential *cd)
 {
   unsigned int i;
   size_t ret;
 
-  ret = sizeof (struct ChainEntry) * (d_count + 1);
+  ret = sizeof (struct ChainEntry) * (d_count);
+  ret += sizeof (struct ChainEntry) * (c_count);
 
   for (i=0; i<d_count;i++)
   {
@@ -204,8 +207,11 @@ GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int 
d_count,
                     dd[i].subject_attribute_len) >= ret);
     ret += dd[i].issuer_attribute_len + dd[i].subject_attribute_len;
   }
-  GNUNET_assert ((ret + cd->issuer_attribute_len) >= ret);
-  ret += cd->issuer_attribute_len;
+  for (i=0; i<c_count;i++)
+  {
+    GNUNET_assert ((ret + cd[i].issuer_attribute_len) >= ret);
+    ret += cd[i].issuer_attribute_len;
+  }
   return ret;
 }
 
@@ -214,6 +220,7 @@ GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int 
d_count,
  *
  * @param d_count number of delegation chain entries
  * @param dd array of #GNUNET_CREDENTIAL_Delegation
+ * @param c_count number of credential entries
  * @param cd a #GNUNET_CREDENTIAL_Credential
  * @param dest_size size of the destination
  * @param dest where to store the result
@@ -222,6 +229,7 @@ GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int 
d_count,
 ssize_t
 GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
                                               const struct 
GNUNET_CREDENTIAL_Delegation *dd,
+                                              unsigned int c_count,
                                               const struct 
GNUNET_CREDENTIAL_Credential *cd,
                                               size_t dest_size,
                                               char *dest)
@@ -258,21 +266,25 @@ GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned 
int d_count,
                    dd[i].subject_attribute_len);
     off += dd[i].subject_attribute_len;
   }
-  rec.issuer_attribute_len = htonl ((uint32_t) cd->issuer_attribute_len);
-  rec.subject_attribute_len = htonl (0);
-  rec.issuer_key = cd->issuer_key;
-  if (off + sizeof (rec) > dest_size)
-    return -1;
-  GNUNET_memcpy (&dest[off],
-                 &rec,
-                 sizeof (rec));
-  off += sizeof (rec);
-  if (off + cd->issuer_attribute_len > dest_size)
-    return -1;
-  GNUNET_memcpy (&dest[off],
-                 cd->issuer_attribute,
-                 cd->issuer_attribute_len);
-  off += cd->issuer_attribute_len;
+  for (i=0;i<c_count;i++)
+  {
+    rec.issuer_attribute_len = htonl ((uint32_t) cd[i].issuer_attribute_len);
+    rec.subject_attribute_len = htonl (0);
+    rec.issuer_key = cd[i].issuer_key;
+    rec.subject_key = cd[i].subject_key;
+    if (off + sizeof (rec) > dest_size)
+      return -1;
+    GNUNET_memcpy (&dest[off],
+                   &rec,
+                   sizeof (rec));
+    off += sizeof (rec);
+    if (off + cd[i].issuer_attribute_len > dest_size)
+      return -1;
+    GNUNET_memcpy (&dest[off],
+                   cd[i].issuer_attribute,
+                   cd[i].issuer_attribute_len);
+    off += cd[i].issuer_attribute_len;
+  }
 
   return off;
 }
@@ -285,6 +297,7 @@ GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int 
d_count,
  * @param src the serialized data
  * @param d_count the number of delegation chain entries
  * @param dd where to put the delegation chain entries
+ * @param c_count the number of credential entries
  * @param cd where to put the credential data
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
@@ -293,6 +306,7 @@ GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len,
                                                 const char *src,
                                                 unsigned int d_count,
                                                 struct 
GNUNET_CREDENTIAL_Delegation *dd,
+                                                unsigned int c_count,
                                                 struct 
GNUNET_CREDENTIAL_Credential *cd)
 {
   struct ChainEntry rec;
@@ -319,17 +333,20 @@ GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t 
len,
     dd[i].subject_attribute = &src[off];
     off += dd[i].subject_attribute_len;
   }
-  if (off + sizeof (rec) > len)
-    return GNUNET_SYSERR;
-  GNUNET_memcpy (&rec, &src[off], sizeof (rec));
-  cd->issuer_attribute_len = ntohl ((uint32_t) rec.issuer_attribute_len);
-  cd->issuer_key = rec.issuer_key;
-  cd->subject_key = rec.subject_key;
-  off += sizeof (rec);
-  if (off + cd->issuer_attribute_len > len)
-    return GNUNET_SYSERR;
-  cd->issuer_attribute = &src[off];
-  off += cd->issuer_attribute_len;
+  for (i=0;i<c_count;i++)
+  {
+    if (off + sizeof (rec) > len)
+      return GNUNET_SYSERR;
+    GNUNET_memcpy (&rec, &src[off], sizeof (rec));
+    cd[i].issuer_attribute_len = ntohl ((uint32_t) rec.issuer_attribute_len);
+    cd[i].issuer_key = rec.issuer_key;
+    cd[i].subject_key = rec.subject_key;
+    off += sizeof (rec);
+    if (off + cd[i].issuer_attribute_len > len)
+      return GNUNET_SYSERR;
+    cd[i].issuer_attribute = &src[off];
+    off += cd[i].issuer_attribute_len;
+  }
   return GNUNET_OK;
 }
 
diff --git a/src/credential/credential_serialization.h 
b/src/credential/credential_serialization.h
index 7f6d0dda9..39ac0103b 100644
--- a/src/credential/credential_serialization.h
+++ b/src/credential/credential_serialization.h
@@ -79,12 +79,14 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
    *
    * @param d_count number of delegation chain entries
    * @param dd array of #GNUNET_CREDENTIAL_Delegation
+   * @param c_count number of credential entries
    * @param cd a #GNUNET_CREDENTIAL_Credential
    * @return the required size to serialize
    */
   size_t
     GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
                                                  const struct 
GNUNET_CREDENTIAL_Delegation *dd,
+                                                 unsigned int c_count,
                                                  const struct 
GNUNET_CREDENTIAL_Credential *cd);
 
   /**
@@ -92,6 +94,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
    *
    * @param d_count number of delegation chain entries
    * @param dd array of #GNUNET_CREDENTIAL_Delegation
+   * @param c_count number of credential entries
    * @param cd a #GNUNET_CREDENTIAL_Credential
    * @param dest_size size of the destination
    * @param dest where to store the result
@@ -100,6 +103,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
   ssize_t
     GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
                                                   const struct 
GNUNET_CREDENTIAL_Delegation *dd,
+                                                  unsigned int c_count,
                                                   const struct 
GNUNET_CREDENTIAL_Credential *cd,
                                                   size_t dest_size,
                                                   char *dest);
@@ -112,6 +116,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
    * @param src the serialized data
    * @param d_count the number of delegation chain entries
    * @param dd where to put the delegation chain entries
+   * @param c_count number of credential entries
    * @param cd where to put the credential data
    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    */
@@ -120,5 +125,6 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
                                                     const char *src,
                                                     unsigned int d_count,
                                                     struct 
GNUNET_CREDENTIAL_Delegation *dd,
+                                                    unsigned int c_count,
                                                     struct 
GNUNET_CREDENTIAL_Credential *cd);
   /* end of credential_serialization.h */
diff --git a/src/credential/gnunet-credential.c 
b/src/credential/gnunet-credential.c
index 41b17ef66..a743458d5 100644
--- a/src/credential/gnunet-credential.c
+++ b/src/credential/gnunet-credential.c
@@ -159,6 +159,7 @@ static void
 handle_verify_result (void *cls,
                       unsigned int d_count,
                       struct GNUNET_CREDENTIAL_Delegation *dc,
+                      unsigned int c_count,
                       struct GNUNET_CREDENTIAL_Credential *cred)
 {
   int i;
@@ -170,30 +171,36 @@ handle_verify_result (void *cls,
     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);
+    printf("Delegation Chain:\n");
     for (i=0;i<d_count;i++)
     {
       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 ("(%d) %s.%s <- %s.%s\n", i+1,
+        printf ("(%d) %s.%s <- %s.%s\n", i,
                 iss_key, dc[i].issuer_attribute,
                 sub_key, dc[i].subject_attribute);
       } else {
-        printf ("(%d) %s.%s <- %s\n", i+1,
+        printf ("(%d) %s.%s <- %s\n", i,
                 iss_key, dc[i].issuer_attribute,
                 sub_key);
       }
       GNUNET_free (iss_key);
       GNUNET_free (sub_key);
     }
+    printf("\nCredentials:\n");
+    for (i=0;i<c_count;i++)
+    {
+      iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred[i].issuer_key);
+      sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string 
(&cred[i].subject_key);
+      printf ("%s.%s <- %s\n",
+              iss_key, cred[i].issuer_attribute,
+              sub_key);
+      GNUNET_free (iss_key);
+      GNUNET_free (sub_key);
+
+    }
     printf ("Successful.\n");
   }
 
@@ -347,7 +354,9 @@ run (void *cls,
                _("You must provide issuer and subject attributes\n"));
       GNUNET_SCHEDULER_shutdown ();
     }
-
+    
+    printf ("Trying to find a chain from a credential under %s of %s to the 
attribute %s issued by %s\n",
+            subject_credential, subject_key, issuer_attr, issuer_key);
 
     verify_request = GNUNET_CREDENTIAL_verify(credential,
                                               &issuer_pkey,
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
   struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
 
   /**
-   * Credential Chain
+   * Credential DLL
    */
   struct CredentialRecordEntry *cred_chain_head;
 
   /**
-   * Credential Chain
+   * Credential DLL
    */
   struct CredentialRecordEntry *cred_chain_tail;
 
   /**
+   * Credential DLL size
+   */
+  uint32_t cred_chain_size;
+
+  /**
    * Root Delegation Set
    */
   struct DelegationSetEntry *root_set;
@@ -402,7 +407,7 @@ static void
 cleanup_handle (struct VerifyRequestHandle *vrh)
 {
   struct CredentialRecordEntry *cr_entry;
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Cleaning up...\n");
   if (NULL != vrh->lookup_request)
   {
@@ -439,7 +444,7 @@ shutdown_task (void *cls)
 {
   struct VerifyRequestHandle *vrh;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Shutting down!\n");
 
   while (NULL != (vrh = vrh_head))
@@ -515,10 +520,12 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
   struct DelegationChainEntry *dce;
   size_t size = vrh->credential_size;
   struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size];
-  struct GNUNET_CREDENTIAL_Credential cred;
+  struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size];
+  struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
+  struct CredentialRecordEntry *cd;
   int i;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending response\n");
   i = 0;
   for (dce = vrh->delegation_chain_head;
@@ -542,21 +549,29 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
    * Get serialized record data
    * Append at the end of rmsg
    */
-  cred.issuer_key = vrh->credential->issuer_key;
-  cred.subject_key = vrh->credential->subject_key;
-  cred.issuer_attribute_len = strlen((char*)&vrh->credential[1])+1;
-  cred.issuer_attribute = (char*)&vrh->credential[1];
+  i = 0;
+  for (cd = vrh->cred_chain_head;
+       NULL != cd;
+       cd = cd->next)
+  {
+    crd = cd->data;
+    cred[i].issuer_key = crd->issuer_key;
+    cred[i].subject_key = crd->subject_key;
+    cred[i].issuer_attribute_len = strlen((char*)&crd[1])+1;
+    cred[i].issuer_attribute = (char*)&crd[1];
+    i++;
+  }
   size = GNUNET_CREDENTIAL_delegation_chain_get_size 
(vrh->delegation_chain_size,
                                                       dd,
-                                                      &cred);
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "SIZE; %llu count: %d\n",size,vrh->delegation_chain_size);
+                                                      vrh->cred_chain_size,
+                                                      cred);
   env = GNUNET_MQ_msg_extra (rmsg,
                              size,
                              GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT);
   //Assign id so that client can find associated request
   rmsg->id = vrh->request_id;
   rmsg->d_count = htonl (vrh->delegation_chain_size);
+  rmsg->c_count = htonl (vrh->cred_chain_size);
 
   if (NULL != vrh->credential)
     rmsg->cred_found = htonl (GNUNET_YES);
@@ -566,7 +581,8 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
   GNUNET_assert (-1 != 
                GNUNET_CREDENTIAL_delegation_chain_serialize 
(vrh->delegation_chain_size,
                                                              dd,
-                                                             &cred,
+                                                             
vrh->cred_chain_size,
+                                                             cred,
                                                              size,
                                                              (char*)&rmsg[1]));
 
@@ -605,7 +621,7 @@ backward_resolution (void* cls,
   current_set->lookup_request = NULL;
   vrh = current_set->handle;
   vrh->pending_lookups--;
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Got %d attrs\n", rd_count);
 
   // Each OR
@@ -616,7 +632,7 @@ backward_resolution (void* cls,
 
     sets = rd[i].data;
     struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets->set_count)];
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Found new attribute delegation with %d sets. Creating new 
Job...\n",
                ntohl (sets->set_count));
 
@@ -653,13 +669,13 @@ backward_resolution (void* cls,
                            set[j].subject_attribute,
                            current_set->attr_trailer);
         }
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "Expanded to %s\n", expanded_attr);
         ds_entry->unresolved_attribute_delegation = expanded_attr;
       } else {
         if (0 != set[j].subject_attribute_len)
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Not Expanding %s\n", set[j].subject_attribute);
           ds_entry->unresolved_attribute_delegation = GNUNET_strdup 
(set[j].subject_attribute);
         }
@@ -682,7 +698,7 @@ backward_resolution (void* cls,
                                    dq_entry->set_entries_tail,
                                    ds_entry);
 
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Checking for cred match\n");
       /**
        * Check if this delegation already matches one of our credentials
@@ -695,14 +711,14 @@ backward_resolution (void* cls,
                         &cred_pointer->data->issuer_key,
                         sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
           continue;
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "Checking if %s matches %s\n",
                     ds_entry->unresolved_attribute_delegation, 
(char*)&cred[1]);
 
         if (0 != strcmp (ds_entry->unresolved_attribute_delegation, 
(char*)&cred[1]))
           continue;
 
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "Found issuer\n");
 
         //Backtrack
@@ -724,7 +740,7 @@ backward_resolution (void* cls,
 
         if (NULL == tmp_set->parent_queue_entry)
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "All solutions found\n");
           vrh->credential = GNUNET_malloc (cred_pointer->data_size);
           memcpy (vrh->credential,
@@ -735,9 +751,12 @@ backward_resolution (void* cls,
           send_lookup_response (vrh);
           return;
         }
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Not all solutions found yet.\n");
+        continue;
 
       }
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Building new lookup request from %s\n",
                   ds_entry->unresolved_attribute_delegation);
       //Continue with backward resolution
@@ -759,10 +778,10 @@ backward_resolution (void* cls,
         ds_entry->attr_trailer = GNUNET_strdup (next_attr);
       }
 
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Looking up %s\n", ds_entry->lookup_attribute);
       if (NULL != ds_entry->attr_trailer)
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "%s still to go...\n", ds_entry->attr_trailer);
 
       vrh->pending_lookups++;
@@ -781,7 +800,7 @@ backward_resolution (void* cls,
 
   if(0 == vrh->pending_lookups)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "We are all out of attributes...\n");
     send_lookup_response (vrh);
     return;
@@ -835,6 +854,7 @@ handle_credential_query (void* cls,
     GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head,
                                       vrh->cred_chain_tail,
                                       cr_entry);
+    vrh->cred_chain_size++;
 
     if (0 != memcmp (&crd->issuer_key,
                      &vrh->issuer_key,
@@ -862,7 +882,7 @@ handle_credential_query (void* cls,
           vrh->issuer_attribute);
   strcpy (issuer_attribute_name + strlen (vrh->issuer_attribute),
           ".gnu");
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Looking up %s\n", issuer_attribute_name);
   ds_entry = GNUNET_new (struct DelegationSetEntry);
   ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
@@ -905,7 +925,7 @@ handle_verify (void *cls,
   char *attrptr = attrs;
   const char *utf_in;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received VERIFY message\n");
 
   utf_in = (const char *) &v_msg[1];
@@ -939,7 +959,7 @@ handle_verify (void *cls,
     send_lookup_response (vrh);
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Looking up %s\n",
               subject_attribute);
   /**
@@ -967,7 +987,7 @@ client_disconnect_cb (void *cls,
                       struct GNUNET_SERVICE_Client *client,
                       void *app_ctx)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Client %p disconnected\n",
               client);
 }
@@ -985,7 +1005,7 @@ client_connect_cb (void *cls,
                    struct GNUNET_SERVICE_Client *client,
                    struct GNUNET_MQ_Handle *mq)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Client %p connected\n",
               client);
   return client;
diff --git a/src/credential/plugin_gnsrecord_credential.c 
b/src/credential/plugin_gnsrecord_credential.c
index d21185981..1358afdb1 100644
--- a/src/credential/plugin_gnsrecord_credential.c
+++ b/src/credential/plugin_gnsrecord_credential.c
@@ -65,12 +65,6 @@ credential_value_to_string (void *cls,
     memcpy (&sets,
             data,
             sizeof (sets));
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "SIZE %llu needed: %llu + %llu\n", 
-                data_size,
-                GNUNET_ntohll (sets.data_size),
-                sizeof (sets));
-
     cdata = data;
     struct GNUNET_CREDENTIAL_DelegationSetRecord set[ntohl(sets.set_count)];
     if (GNUNET_OK != GNUNET_CREDENTIAL_delegation_set_deserialize 
(GNUNET_ntohll (sets.data_size),
@@ -238,15 +232,8 @@ credential_string_to_value (void *cls,
                                                       strlen (subject_pkey),
                                                       &set[i].subject_key);
           if (2 == matches) {
-            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                        "Adding %s (data size %llu)\n",
-                        attr_str,
-                        tmp_data_size);
-            /*GNUNET_memcpy (&set[1],
-                           attr_str,
-                           strlen (attr_str)+1);*/
             set[i].subject_attribute_len = strlen (attr_str) + 1;
-            set[i].subject_attribute = GNUNET_strdup (attr_str);//(const 
char*)&set[1];
+            set[i].subject_attribute = GNUNET_strdup (attr_str);
           }
           token = strtok (NULL , ",");
         }
diff --git a/src/credential/plugin_rest_credential.c 
b/src/credential/plugin_rest_credential.c
index cdd0e86e9..f6e4fc5a8 100644
--- a/src/credential/plugin_rest_credential.c
+++ b/src/credential/plugin_rest_credential.c
@@ -41,7 +41,7 @@
 
 #define GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO "credential"
 
-#define GNUNET_REST_JSONAPI_CREDENTIAL_CHAIN "chain"
+#define GNUNET_REST_JSONAPI_DELEGATIONS "delegations"
 
 #define GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR "attribute"
 
@@ -273,6 +273,7 @@ static void
 handle_verify_response (void *cls,
                         unsigned int d_count,
                         struct GNUNET_CREDENTIAL_Delegation *delegation_chain,
+                        unsigned int c_count,
                         struct GNUNET_CREDENTIAL_Credential *cred)
 {
 
@@ -282,7 +283,8 @@ handle_verify_response (void *cls,
   struct GNUNET_JSONAPI_Resource *json_resource;
   json_t *cred_obj;
   json_t *attr_obj;
-  json_t *result_array;
+  json_t *cred_array;
+  json_t *attr_array;
   char *result;
   uint32_t i;
 
@@ -298,25 +300,33 @@ handle_verify_response (void *cls,
   json_resource = GNUNET_JSONAPI_resource_new 
(GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO,
                                                handle->issuer_attr);
   cred_obj = credential_to_json (cred);
-  result_array = json_array ();
+  attr_array = json_array ();
   for (i = 0; i < d_count; i++)
   {
     attr_obj = attribute_delegation_to_json (&delegation_chain[i]);
-    json_array_append (result_array, attr_obj);
+    json_array_append (attr_array, attr_obj);
     json_decref (attr_obj);
   }
+  cred_array = json_array ();
+  for (i=0;i<c_count;i++)
+  {
+    cred_obj = credential_to_json (&cred[i]);
+    json_array_append (cred_array, cred_obj);
+    json_decref (cred_obj);
+  }
   GNUNET_JSONAPI_resource_add_attr (json_resource,
                                     GNUNET_REST_JSONAPI_CREDENTIAL,
-                                    cred_obj);
+                                    cred_array);
   GNUNET_JSONAPI_resource_add_attr (json_resource,
-                                    GNUNET_REST_JSONAPI_CREDENTIAL_CHAIN,
-                                    result_array);
+                                    GNUNET_REST_JSONAPI_DELEGATIONS,
+                                    attr_array);
   GNUNET_JSONAPI_document_resource_add (json_document, json_resource);
   GNUNET_JSONAPI_document_serialize (json_document, &result);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Result %s\n",
               result);
-  json_decref (result_array);
+  json_decref (attr_array);
+  json_decref (cred_array);
   GNUNET_JSONAPI_document_delete (json_document);
   resp = GNUNET_REST_create_response (result);
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
diff --git a/src/credential/test_credential_verify.sh 
b/src/credential/test_credential_verify.sh
index 52a4fd2fc..6d69e337b 100755
--- a/src/credential/test_credential_verify.sh
+++ b/src/credential/test_credential_verify.sh
@@ -23,7 +23,7 @@ rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS 
-o GNUNET_HOME -f`
 
 
 which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
-#gnunet-arm -s -c test_credential_lookup.conf
+gnunet-arm -s -c test_credential_lookup.conf
 gnunet-identity -C service -c test_credential_lookup.conf
 gnunet-identity -C alice -c test_credential_lookup.conf
 gnunet-identity -C gnu -c test_credential_lookup.conf
@@ -44,8 +44,6 @@ TEST_CREDENTIAL="mygnunetcreds"
 # (1) A service assigns the attribute "user" to all entities that have been 
assigned "member" by entities that werde assigned "project" from GNU
 gnunet-namestore -p -z service -a -n $USER_ATTR -t ATTR -V "$GNU_KEY 
$GNU_PROJECT_ATTR.$MEMBER_ATTR" -e 5m -c test_credential_lookup.conf
 
-valgrind gnunet-namestore -D -z service -c test_credential_lookup.conf
-
 # (2) GNU recognized GNUnet as a GNU project and delegates the "project" 
attribute
 gnunet-namestore -p -z gnu -a -n $GNU_PROJECT_ATTR -t ATTR -V "$GNUNET_KEY" -e 
5m -c test_credential_lookup.conf
 
diff --git a/src/include/gnunet_credential_service.h 
b/src/include/gnunet_credential_service.h
index b28d90140..7419407d3 100644
--- a/src/include/gnunet_credential_service.h
+++ b/src/include/gnunet_credential_service.h
@@ -112,22 +112,6 @@ struct GNUNET_CREDENTIAL_CredentialRecordData {
 /**
  * The attribute delegation record
 */
-struct GNUNET_CREDENTIAL_AttributeRecordData {
-  
-  /**
-   * Public key of the subject this attribute was delegated to
-   */
-  struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
-  
-  /**
-   * Followed by the attribute that was delegated to as string
-   * May be empty
-   */
-};
-
-/**
- * The attribute delegation record
-*/
 struct GNUNET_CREDENTIAL_DelegationRecordData {
   
   uint32_t set_count;
@@ -257,13 +241,15 @@ GNUNET_CREDENTIAL_disconnect (struct 
GNUNET_CREDENTIAL_Handle *handle);
  * Iterator called on obtained result for an attribute verification.
  *
  * @param cls closure
- * @param issuer the issuer of the attribute NULL if verification failed
- * @param result the result of the verification
- * @param rd the records in reply
+ * @param d_count the number of delegations processed
+ * @param delegation_chain the delegations processed
+ * @param c_count the number of credentials found
+ * @param credential the credentials
  */
 typedef void (*GNUNET_CREDENTIAL_VerifyResultProcessor) (void *cls,
                                                          unsigned int d_count,
                                                          struct 
GNUNET_CREDENTIAL_Delegation *delegation_chain,
+                                                         unsigned int c_count,
                                                          struct 
GNUNET_CREDENTIAL_Credential *credential);
 
 /**

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]