- add signatures to creds, add converter
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Fri, 2 Dec 2016 13:20:08 +0000 (14:20 +0100)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Fri, 2 Dec 2016 13:20:08 +0000 (14:20 +0100)
src/credential/plugin_gnsrecord_credential.c
src/include/gnunet_credential_service.h
src/include/gnunet_signatures.h

index 480dc4c62e52859c25b5dda9abafcbce563a9577..d321a43a495164dac189d045079289405edf3438 100644 (file)
@@ -51,6 +51,26 @@ credential_value_to_string (void *cls,
 
   switch (type)
   {
+   case GNUNET_GNSRECORD_TYPE_ATTRIBUTE:
+   {
+    struct GNUNET_CREDENTIAL_AttributeRecordData attr;
+    char *attr_str;
+    char *subject_pkey;
+    
+    if (data_size < sizeof (struct GNUNET_CREDENTIAL_AttributeRecordData))
+      return NULL; /* malformed */
+    memcpy (&attr,
+            data,
+            sizeof (attr));
+    cdata = data;
+    subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&attr.subject_key);
+    GNUNET_asprintf (&attr_str,
+                     "%s.%s",
+                     subject_pkey,
+                     &cdata[sizeof (attr)]);
+    GNUNET_free (subject_pkey);
+    return attr_str;
+   }
    case GNUNET_GNSRECORD_TYPE_CREDENTIAL:
    {
     struct GNUNET_CREDENTIAL_CredentialRecordData cred;
index 5675cd9905b93e1b994e3685b2f785c0231717be..b996b77db49d8daa0648838b2f335238163785d7 100644 (file)
@@ -79,16 +79,27 @@ GNUNET_NETWORK_STRUCT_BEGIN
 struct GNUNET_CREDENTIAL_CredentialRecordData {
   
   /**
-   * Public key of the subject this credential was issued to
+   * The signature for this credential by the issuer
    */
-  struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+  struct GNUNET_CRYPTO_EcdsaSignature sig;
   
+
   /**
    * Public key of the issuer
    */
   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
+   */
+  struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+  
+    /**
    * Flags for this credential
    */
   uint32_t credential_flags GNUNET_PACKED;
@@ -98,12 +109,7 @@ struct GNUNET_CREDENTIAL_CredentialRecordData {
    */
   uint64_t expiration GNUNET_PACKED;
   
-  /**
-   * The signature for this credential by the issuer
-   */
-  struct GNUNET_CRYPTO_EcdsaSignature sig;
-  
-  /**
+    /**
    * Followed by the attribute string
    */
 };
index 1e372bbeac5e8315c2f8ad4ef004e5f475c3c0c4..353287cbf37fceebbb99faf03d22a3103a7544d9 100644 (file)
@@ -190,6 +190,11 @@ extern "C"
  */
 #define GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET 27
 
+/**
+ * Signature for a GNUnet credential
+ */
+#define GNUNET_SIGNATURE_PURPOSE_CREDENTIAL 28
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif