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

index 88f5f4e178d614ea1743a4bf67dd3ee714a241a4..344bb6e632880ef9b60000714100d610ff08d0e7 100644 (file)
@@ -369,7 +369,7 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
   struct GNUNET_CREDENTIAL_Request *vr;
   size_t nlen;
 
-  if (NULL == issuer_attribute)
+  if (NULL == issuer_attribute || NULL == subject_attribute)
   {
     GNUNET_break (0);
     return NULL;
@@ -378,7 +378,7 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Trying to verify `%s' in CREDENTIAL\n",
        issuer_attribute);
-  nlen = strlen (issuer_attribute) + 1;
+  nlen = strlen (issuer_attribute) + 1 + strlen (subject_attribute) + 1;
   if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*vr))
   {
     GNUNET_break (0);
@@ -396,8 +396,11 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
   v_msg->subject_key = *subject_key;
   v_msg->issuer_key =  *issuer_key;
   GNUNET_memcpy (&v_msg[1],
+                 issuer_attribute,
+                 strlen (issuer_attribute));
+  GNUNET_memcpy (((char*)&v_msg[1]) + strlen (issuer_attribute) + 1,
                  subject_attribute,
-                 nlen);
+                 strlen (subject_attribute));
   GNUNET_CONTAINER_DLL_insert (handle->verify_head,
                                handle->verify_tail,
                                vr);
index 874aa29cba69f9de1d9d0f53b2347a25931590a6..a7b92447b153445eaf44e214d852d71b3c57bf5e 100644 (file)
@@ -280,7 +280,14 @@ run (void *cls,
     {
       fprintf (stderr,
                _("Failed to connect to CREDENTIAL\n"));
-      return;
+      GNUNET_SCHEDULER_shutdown ();
+    }
+
+    if (NULL == issuer_attr || NULL == subject_credential)
+    {
+      fprintf (stderr,
+               _("You must provide issuer and subject attributes\n"));
+      GNUNET_SCHEDULER_shutdown ();
     }
 
 
@@ -334,7 +341,7 @@ main (int argc, char *const *argv)
     {'s', "subject", "PKEY",
       gettext_noop ("The public key of the subject to lookup the credential for"), 1,
       &GNUNET_GETOPT_set_string, &subject_key},
-    {'c', "credential", "CRED",
+    {'b', "credential", "CRED",
       gettext_noop ("The name of the credential presented by the subject"), 1,
       &GNUNET_GETOPT_set_string, &subject_credential},
     {'i', "issuer", "PKEY",
index 67fd32e4967c9f20e0f3a6acddbdef64f9de0c98..721e19fdb65a5b09ae22a3c56e37da9b26946776 100644 (file)
@@ -136,7 +136,7 @@ credential_string_to_value (void *cls,
         char issuer_pkey[enclen + 1];
         char name[253 + 1];
 
-        if (5 != SSCANF (s,
+        if (3 != SSCANF (s,
                          "%52s %52s %253s",
                          subject_pkey,
                          issuer_pkey,