-add issue test
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 5 Dec 2016 18:26:27 +0000 (19:26 +0100)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 5 Dec 2016 18:26:27 +0000 (19:26 +0100)
src/credential/credential_api.c
src/credential/gnunet-credential.c
src/credential/plugin_gnsrecord_credential.c

index 8d3c96ca8916d6e0770f981b61b44aa14b79f981..88f5f4e178d614ea1743a4bf67dd3ee714a241a4 100644 (file)
@@ -433,7 +433,7 @@ GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
   crd->purpose.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));
index eaad6d5cf3c4b8571b264dbc1b1155f96e4d881e..874aa29cba69f9de1d9d0f53b2347a25931590a6 100644 (file)
@@ -180,6 +180,7 @@ identity_cb (void *cls,
 {
   const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
   struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
+  char *res;
 
   el = NULL;
   if (NULL == ego)
@@ -200,10 +201,11 @@ identity_cb (void *cls,
                                  privkey,
                                  &subject_pkey,
                                  issuer_attr);
-  printf ("Success.\n");
-  printf (GNUNET_GNSRECORD_value_to_string (GNUNET_GNSRECORD_TYPE_CREDENTIAL,
-                                            crd,
-                                            sizeof (crd) + strlen (issuer_attr) + 1));
+  res =  GNUNET_GNSRECORD_value_to_string (GNUNET_GNSRECORD_TYPE_CREDENTIAL,
+                                           crd,
+                                           sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (issuer_attr) + 1);
+  printf ("%s\n", res);
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -225,15 +227,6 @@ run (void *cls,
 {
 
   cfg = c;
-  credential = GNUNET_CREDENTIAL_connect (cfg);
-
-  if (NULL == credential)
-  {
-    fprintf (stderr,
-             _("Failed to connect to CREDENTIAL\n"));
-    return;
-  }
-
 
 
   tt = GNUNET_SCHEDULER_add_delayed (timeout,
@@ -281,6 +274,15 @@ run (void *cls,
                issuer_key);
       GNUNET_SCHEDULER_shutdown ();
     }
+    credential = GNUNET_CREDENTIAL_connect (cfg);
+
+    if (NULL == credential)
+    {
+      fprintf (stderr,
+               _("Failed to connect to CREDENTIAL\n"));
+      return;
+    }
+
 
     verify_request = GNUNET_CREDENTIAL_verify(credential,
                                               &issuer_pkey,
index c7cbb8bdd15e7d3e2affb361f866f8eaad398634..67fd32e4967c9f20e0f3a6acddbdef64f9de0c98 100644 (file)
@@ -73,33 +73,31 @@ credential_value_to_string (void *cls,
    }
    case GNUNET_GNSRECORD_TYPE_CREDENTIAL:
    {
-    struct GNUNET_CREDENTIAL_CredentialRecordData cred;
-    char *cred_str;
-    char *subject_pkey;
-    char *issuer_pkey;
-    if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData))
-        return NULL; /* malformed */
-    memcpy (&cred,
-              data,
-              sizeof (cred));
-    cdata = data;  
-    subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key);
-    issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key);
+     struct GNUNET_CREDENTIAL_CredentialRecordData cred;
+     char *cred_str;
+     char *subject_pkey;
+     char *issuer_pkey;
+     if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData))
+       return NULL; /* malformed */
+     memcpy (&cred,
+             data,
+             sizeof (cred));
+     cdata = data;  
+     subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key);
+     issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key);
 
      GNUNET_asprintf (&cred_str,
-                     "%s %s %s",
-                     subject_pkey,
-                     issuer_pkey,
-                     &cdata[sizeof (cred)]);
-      GNUNET_free (subject_pkey);
-      GNUNET_free (issuer_pkey);
-
-
-
-    return cred_str;
-    }
-  default:
-    return NULL;
+                      "%s %s %s",
+                      subject_pkey,
+                      issuer_pkey,
+                      &cdata[sizeof (cred)]);
+     GNUNET_free (subject_pkey);
+     GNUNET_free (issuer_pkey);
+
+     return cred_str;
+   }
+   default:
+   return NULL;
   }
 }
 
@@ -117,10 +115,10 @@ credential_value_to_string (void *cls,
  */
 static int
 credential_string_to_value (void *cls,
-                     uint32_t type,
-                     const char *s,
-                     void **data,
-                     size_t *data_size)
+                            uint32_t type,
+                            const char *s,
+                            void **data,
+                            size_t *data_size)
 {
   if (NULL == s)
     return GNUNET_SYSERR;