gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] 17/171: - added DLL and some checks


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 17/171: - added DLL and some checks
Date: Thu, 04 Jan 2018 16:08:45 +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 6fb6ddb3cb9b4153033747ac42cbad66f9bc3268
Author: Adnan H <address@hidden>
AuthorDate: Fri Dec 2 15:38:10 2016 +0100

    - added DLL and some checks
---
 src/credential/gnunet-service-credential.c | 108 +++++++++++++++++++++--------
 1 file changed, 81 insertions(+), 27 deletions(-)

diff --git a/src/credential/gnunet-service-credential.c 
b/src/credential/gnunet-service-credential.c
index 58be7853b..620256cd9 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -45,26 +45,48 @@
 /**
  * DLL for record
  */
-struct AttributeRecordEntry
+struct CredentialRecordEntry
 {
   /**
    * DLL
    */
-  struct AttributeRecordEntry *next;
+  struct CredentialRecordEntry *next;
 
   /**
    * DLL
    */
-  struct AttributeRecordEntry *prev;
+  struct CredentialRecordEntry *prev;
 
 
   /**
    * Payload
    */
-  struct GNUNET_CREDENTIAL_AttributeRecordData record_data;
+  struct GNUNET_CREDENTIAL_CredentialRecordData record_data;
 };
 
 /**
+ * DLL for attributes - Used as a queue
+ * Insert tail - Pop head
+ */
+struct AttributeRecordEntry
+{
+  /**
+   * DLL
+   */
+  struct AttributeRecordEntry *next;
+
+  /**
+   * DLL
+   */
+  struct AttributeRecordEntry *prev;
+
+  /**
+   *
+   */
+  struct GNUNET_CREDENTIAL_AttributeDelegationRecordData;
+}
+
+/**
  * Handle to a lookup operation from api
  */
 struct VerifyRequestHandle
@@ -101,14 +123,24 @@ struct VerifyRequestHandle
   struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
 
   /**
-   * Attribute Chain
+   * Credential Chain
    */
-  struct AttributeRecordEntry *attr_chain_head;
+  struct CredentialRecordEntry *cred_chain_head;
 
   /**
-   * Attribute Chain
+   * Credential Chain
+   */
+  struct CredentialRecordEntry *cred_chain_tail;
+
+  /**
+   * Attribute Queue
+   */
+  struct AttributeRecordEntry *attr_queue_head;
+  
+  /**
+   * Attribute Queue
    */
-  struct AttributeRecordEntry *attr_chain_tail;
+  struct AttributeRecordEntry *attr_queue_tail;
 
   /**
    * request id
@@ -228,19 +260,26 @@ send_lookup_response (void* cls,
   struct VerifyRequestHandle *vrh = cls;
   size_t len;
   int i;
-  int attr_record_count;
+  int cred_record_count;
   struct GNUNET_MQ_Envelope *env;
   struct VerifyResultMessage *rmsg;
-  const struct GNUNET_CREDENTIAL_AttributeRecordData *ard;
-  struct AttributeRecordEntry *ar_entry;
-
-  attr_record_count = 0;
+  const struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
+  struct GNUNET_CREDENTIAL_AttributeDelegationRecordData *adrd;
+  struct CredentialRecordEntry *cr_entry;
+  struct AttributeRecordEntry *attr_entry;
+  bool cred_verified;
+
+  cred_record_count = 0;
+  adrd = GNUNET_CREDENTIAL_AttributeDelegationRecordData   
+  GNUNET_CONTAINER_DLL_insert_tail (vrh->attr_queue_head,
+                                    vrh->attr_queue_tail,
+                                    attr_entry);
   for (i=0; i < rd_count; i++)
   {
-    if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type)
+    if (GNUNET_GNSRECORD_TYPE_CREDENTIAL != rd[i].record_type)
       continue;
-    attr_record_count++;
-    ard = rd[i].data;
+    cred_record_count++;
+    crd = rd[i].data;
     /**
      * TODO:
      * Check if we have already found our credential here
@@ -249,18 +288,33 @@ send_lookup_response (void* cls,
      *  Save all found attributes/issues and prepare forward
      *  resolution of issuer attribute
      */
-    ar_entry = GNUNET_new (struct AttributeRecordEntry);
-    ar_entry->record_data = *ard;
-    GNUNET_CONTAINER_DLL_insert_tail (vrh->attr_chain_head,
-                                      vrh->attr_chain_tail,
-                                      ar_entry);
+    cr_entry = GNUNET_new (struct CredentialRecordEntry);
+    cr_entry->record_data = *crd;
+    GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head,
+                                      vrh->cred_chain_tail,
+                                      cr_entry);
+
+    if(GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_CREDENTIAL, 
purpose, sig, issuer_key))
+    {   
+      cred_verified = true;
+      break;
+    }
 
   }
+  
+
+  /**
+   * Check for attributes from the issuer and follow the chain 
+   * till you get the required subject's attributes
+   */
+  if(cred_verified != true){
+    for(i=0 ; i < rd_count ; i++){
+
 
   /**
    * Get serialized record data size
    */
-  len = attr_record_count * sizeof (struct 
GNUNET_CREDENTIAL_AttributeRecordData);
+  len = cred_record_count * sizeof (struct 
GNUNET_CREDENTIAL_CredentialRecordData);
 
   /**
    * Prepare a lookup result response message for the client
@@ -277,12 +331,12 @@ send_lookup_response (void* cls,
    * Append at the end of rmsg
    */
   i = 0;
-  struct GNUNET_CREDENTIAL_AttributeRecordData *tmp_record = (struct 
GNUNET_CREDENTIAL_AttributeRecordData*) &rmsg[1];
+  struct GNUNET_CREDENTIAL_CredentialRecordData *tmp_record = (struct 
GNUNET_CREDENTIAL_CredentialRecordData*) &rmsg[1];
   for (ar_entry = vrh->attr_chain_head; NULL != ar_entry; ar_entry = 
ar_entry->next)
   {
     memcpy (tmp_record,
             &ar_entry->record_data,
-            sizeof (struct GNUNET_CREDENTIAL_AttributeRecordData));
+            sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData));
     tmp_record++;
   }
   GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client),
@@ -301,13 +355,13 @@ send_lookup_response (void* cls,
                             "Completed verifications", 1,
                             GNUNET_NO);
   GNUNET_STATISTICS_update (statistics,
-                            "Attributes resolved",
+                            "Credentials resolved",
                             rd_count,
                             GNUNET_NO);
 }
 
 /**
- * Handle attribute verification requests from client
+ * Handle Credential verification requests from client
  *
  * @param cls the closure
  * @param client the client
@@ -361,7 +415,7 @@ handle_verify (void *cls,
   vrh->lookup_request = GNUNET_GNS_lookup (gns,
                                            subject_attribute,
                                            &v_msg->subject_key, //subject_pkey,
-                                           GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
+                                           GNUNET_GNSRECORD_TYPE_CREDENTIAL,
                                            GNUNET_GNS_LO_DEFAULT,
                                            NULL, //shorten_key, always NULL
                                            &send_lookup_response,

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



reply via email to

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