- remove purpose from cred
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 5 Dec 2016 21:09:11 +0000 (22:09 +0100)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 5 Dec 2016 21:09:11 +0000 (22:09 +0100)
src/credential/credential_api.c
src/credential/gnunet-service-credential.c
src/include/gnunet_credential_service.h

index b6c585c72883fc45348d633bab29458f5f353fd6..3be2d8bbb06c4786fdba003dbad5ddd4662cd902 100644 (file)
@@ -428,23 +428,32 @@ GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
                          const char *attribute)
 {
   struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
+  struct GNUNET_CRYPTO_EccSignaturePurpose *purp;
 
   crd = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (attribute) + 1);
 
-  crd->purpose.size = htonl (strlen (attribute) + 1 +
-                             sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
-                                              sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
-                                              sizeof (struct GNUNET_TIME_AbsoluteNBO));
-  crd->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
+  purp = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
+                        strlen (attribute) + 1);
+  purp->size = htonl (strlen (attribute) + 1 +
+                      sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
+                                       sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose));
+  
+  purp->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
   GNUNET_CRYPTO_ecdsa_key_get_public (issuer,
                                       &crd->issuer_key);
   crd->subject_key = *subject;
   GNUNET_memcpy (&crd[1],
                  attribute,
                  strlen (attribute));
+  GNUNET_memcpy (&purp[1],
+                 subject,
+                 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
+  GNUNET_memcpy (&purp[1] + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
+                 attribute,
+                 strlen (attribute));
   if (GNUNET_OK !=
       GNUNET_CRYPTO_ecdsa_sign (issuer,
-                                &crd->purpose,
+                                purp,
                                 &crd->sig))
   {
     GNUNET_break (0);
index 1171563790fb224ed0a1be55483ffd4536f48ce4..20f6fe4e03f21b3ee58bbc7c30e11c551504b28f 100644 (file)
@@ -262,6 +262,7 @@ send_lookup_response (void* cls,
   struct GNUNET_MQ_Envelope *env;
   struct VerifyResultMessage *rmsg;
   const struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
+  struct GNUNET_CRYPTO_EccSignaturePurpose *purp;
   struct CredentialRecordEntry *cr_entry;
 
   cred_record_count = 0;
@@ -284,16 +285,26 @@ send_lookup_response (void* cls,
     GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head,
                                       vrh->cred_chain_tail,
                                       cr_entry);
-
+    purp = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
+                          sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
+                          strlen ((char*)&crd[1]) +1 );
+    purp->size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
+                        sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
+                        strlen ((char*)&crd[1]) +1 );
+
+    purp->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
     if(GNUNET_OK == GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_CREDENTIAL, 
-                                               &crd->purpose,
-                                               &crd->sig, &crd->issuer_key))
-    {   
+                                               purp,
+                                               &crd->sig,
+                                               &crd->issuer_key))
+    {
+      GNUNET_free (purp);
       break;
     }
+    GNUNET_free (purp);
 
   }
-  
+
 
 
   /**
index 088d0c75e8c799ad393839c152681dcf3c17aa5b..1515877685b2e6050a650ff3fd9d1159fef528ed 100644 (file)
@@ -89,11 +89,6 @@ struct GNUNET_CREDENTIAL_CredentialRecordData {
    */
   struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
   
-  /**
-   * Signature purpose (data to sign, kind of signature)
-   */
-  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
   /**
    * Public key of the subject this credential was issued to
    */