gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] 26/171: - add signature to cred


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 26/171: - add signature to cred
Date: Thu, 04 Jan 2018 16:08:54 +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 6d96eb580bec0831222811f3841174c39e437709
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Mon Dec 5 21:55:23 2016 +0100

    - add signature to cred
---
 src/credential/plugin_gnsrecord_credential.c | 31 ++++++++++++++++++++--------
 src/credential/test_credential_issue.sh      | 13 +++---------
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/src/credential/plugin_gnsrecord_credential.c 
b/src/credential/plugin_gnsrecord_credential.c
index 721e19fdb..f6aec9bcc 100644
--- a/src/credential/plugin_gnsrecord_credential.c
+++ b/src/credential/plugin_gnsrecord_credential.c
@@ -77,6 +77,8 @@ credential_value_to_string (void *cls,
      char *cred_str;
      char *subject_pkey;
      char *issuer_pkey;
+     char *signature;
+     
      if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData))
        return NULL; /* malformed */
      memcpy (&cred,
@@ -85,15 +87,18 @@ credential_value_to_string (void *cls,
      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_STRINGS_base64_encode ((char*)&cred.sig,
+                                   sizeof (struct 
GNUNET_CRYPTO_EcdsaSignature),
+                                   &signature);
      GNUNET_asprintf (&cred_str,
-                      "%s %s %s",
-                      subject_pkey,
+                      "%s.%s -> %s sig:%s",
                       issuer_pkey,
-                      &cdata[sizeof (cred)]);
+                      &cdata[sizeof (cred)],
+                      subject_pkey,
+                      signature);
      GNUNET_free (subject_pkey);
      GNUNET_free (issuer_pkey);
-
+     GNUNET_free (signature);
      return cred_str;
    }
    default:
@@ -135,12 +140,15 @@ credential_string_to_value (void *cls,
         char subject_pkey[enclen + 1];
         char issuer_pkey[enclen + 1];
         char name[253 + 1];
+        char signature[128]; //TODO max payload size
+        struct GNUNET_CRYPTO_EcdsaSignature *sig;
 
-        if (3 != SSCANF (s,
-                         "%52s %52s %253s",
-                         subject_pkey,
+        if (4 != SSCANF (s,
+                         "%52s.%253s -> %52s sig:%s",
                          issuer_pkey,
-                         name))
+                         name,
+                         subject_pkey,
+                         signature))
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                       _("Unable to parse CRED record string `%s'\n"),
@@ -155,6 +163,11 @@ credential_string_to_value (void *cls,
         GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_pkey,
                                                     strlen (issuer_pkey),
                                                     &cred->issuer_key);
+        GNUNET_STRINGS_base64_decode (signature,
+                                      strlen (signature),
+                                      (char**)&sig);
+        cred->sig = *sig;
+        GNUNET_free (sig);
         GNUNET_memcpy (&cred[1],
                        name,
                        strlen (name));
diff --git a/src/credential/test_credential_issue.sh 
b/src/credential/test_credential_issue.sh
index a78bde6ed..95eac2957 100755
--- a/src/credential/test_credential_issue.sh
+++ b/src/credential/test_credential_issue.sh
@@ -28,16 +28,9 @@ gnunet-identity -C testissuer -c test_credential_lookup.conf
 gnunet-identity -C testsubject -c test_credential_lookup.conf
 SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep 
testsubject | awk '{print $3}')
 ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep 
testissuer | awk '{print $3}')
-EXPECTED="$SUBJECT_KEY $ISSUER_KEY $TEST_ATTR"
 #TODO1 Get credential and store it with subject (3)
-CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer 
--subject=$SUBJECT_KEY --attribute=$TEST_ATTR -c test_credential_lookup.conf`
+$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY 
--attribute=$TEST_ATTR -c test_credential_lookup.conf
+STATUS=$?
 
 gnunet-arm -e -c test_credential_lookup.conf
-
-if [ "$EXPECTED" == "$CRED" ]
-then
-  exit 0
-else
-  echo "FAIL: Failed to issue credential, got $CRED."
-  exit 1
-fi
+exit $STATUS

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



reply via email to

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