gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: -fix


From: gnunet
Subject: [gnunet] branch master updated: -fix
Date: Fri, 14 Jan 2022 22:10:52 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new be0fee19c -fix
     new 3a50faa93 Merge branch 'master' of git+ssh://git.gnunet.org/gnunet
be0fee19c is described below

commit be0fee19cd01821dcb67cf2bca633b4e2b711bbf
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Jan 14 22:10:11 2022 +0100

    -fix
---
 contrib/gana             |  2 +-
 po/POTFILES.in           |  3 +++
 src/reclaim/Makefile.am  |  3 ++-
 src/reclaim/did.h        | 49 +++++++++++++++++++++++++++++++++
 src/reclaim/did_misc.c   | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/reclaim/gnunet-did.c | 44 +++++++-----------------------
 6 files changed, 134 insertions(+), 37 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 9b8a78758..c12314df0 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 9b8a787580307cea5a38359c485d521cd8ece820
+Subproject commit c12314df0f82e192c6829a9c6cf3e9663b586da1
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b456f2ad3..94b64e5b3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -296,6 +296,8 @@ src/pq/pq_prepare.c
 src/pq/pq_query_helper.c
 src/pq/pq_result_helper.c
 src/pt/gnunet-daemon-pt.c
+src/reclaim/did_misc.c
+src/reclaim/gnunet-did.c
 src/reclaim/gnunet-reclaim.c
 src/reclaim/gnunet-service-reclaim.c
 src/reclaim/gnunet-service-reclaim_tickets.c
@@ -312,6 +314,7 @@ src/reclaim/plugin_rest_reclaim.c
 src/reclaim/reclaim_api.c
 src/reclaim/reclaim_attribute.c
 src/reclaim/reclaim_credential.c
+src/reclaim/test.c
 src/regex/gnunet-daemon-regexprofiler.c
 src/regex/gnunet-regex-profiler.c
 src/regex/gnunet-regex-simulation-profiler.c
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am
index 6b5934a2f..a0150a3b9 100644
--- a/src/reclaim/Makefile.am
+++ b/src/reclaim/Makefile.am
@@ -189,7 +189,8 @@ test_reclaim_attribute_LDADD = \
   $(GN_LIBINTL)
 
 gnunet_did_SOURCES = \
-       gnunet-did.c
+       gnunet-did.c \
+  did_misc.c
 gnunet_did_LDADD = \
        $(top_builddir)/src/util/libgnunetutil.la \
        $(top_builddir)/src/gns/libgnunetgns.la \
diff --git a/src/reclaim/did.h b/src/reclaim/did.h
new file mode 100644
index 000000000..054bd29e4
--- /dev/null
+++ b/src/reclaim/did.h
@@ -0,0 +1,49 @@
+/*
+   This file is part of GNUnet.
+   Copyright (C) 2012-2022 GNUnet e.V.
+
+   GNUnet is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Affero General Public License as published
+   by the Free Software Foundation, either version 3 of the License,
+   or (at your option) any later version.
+
+   GNUnet is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Affero General Public License for more details.
+
+   You should have received a copy of the GNU Affero General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+#ifndef RECLAIM_DID_H
+#define RECLAIM_DID_H
+
+#define GNUNET_RECLAIM_DID_METHOD_PREFIX "did:reclaim:"
+
+/**
+ * Create a DID string from an ego in the format
+ * did:reclaim:<pubkey>
+ *
+ * @param ego the Ego to use
+ * @return the DID string
+ */
+char*
+DID_ego_to_did (struct GNUNET_IDENTITY_Ego *ego);
+
+
+/**
+ * Extract the public key from a DID
+ * in the format did:reclaim:<pubkey>
+ *
+ * @param did the DID parse
+ * @param pk where to store the public key
+ * @return GNUNET_OK if successful
+ */
+enum GNUNET_GenericReturnValue
+DID_public_key_from_did (const char* did,
+                         struct GNUNET_IDENTITY_PublicKey *pk);
+
+#endif
diff --git a/src/reclaim/did_misc.c b/src/reclaim/did_misc.c
new file mode 100644
index 000000000..44b72a69f
--- /dev/null
+++ b/src/reclaim/did_misc.c
@@ -0,0 +1,70 @@
+/*
+   This file is part of GNUnet.
+   Copyright (C) 2012-2022 GNUnet e.V.
+
+   GNUnet is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Affero General Public License as published
+   by the Free Software Foundation, either version 3 of the License,
+   or (at your option) any later version.
+
+   GNUnet is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Affero General Public License for more details.
+
+   You should have received a copy of the GNU Affero General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @author Martin Schanzenbach
+ * @file src/reclaim/did_misc.c
+ * @brief Helper functions for DIDs
+ *
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_identity_service.h"
+#include "jansson.h"
+#include "did.h"
+
+char*
+DID_ego_to_did (struct GNUNET_IDENTITY_Ego *ego)
+{
+  struct GNUNET_IDENTITY_PublicKey pkey; // Get Public key
+  char *pkey_str;
+  char *did_str;
+  size_t pkey_len;
+
+  GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
+
+  pkey_str = GNUNET_IDENTITY_public_key_to_string (&pkey);
+  GNUNET_asprintf (&did_str, "%s%s",
+                   GNUNET_RECLAIM_DID_METHOD_PREFIX,
+                   pkey_str);
+
+  GNUNET_free (pkey_str);
+  return did_str;
+}
+
+enum GNUNET_GenericReturnValue
+DID_public_key_from_did (const char* did,
+                         struct GNUNET_IDENTITY_PublicKey *pk)
+{
+  /* FIXME-MSC: I suggest introducing a
+   * #define MAX_DID_LENGTH <something>
+   * here and use it for parsing
+   */
+  char pkey_str[59];
+
+  if ((1 != (sscanf (did, GNUNET_RECLAIM_DID_METHOD_PREFIX"%58s", pkey_str))) 
||
+      (GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (pkey_str, pk)))
+  {
+    return GNUNET_SYSERR;
+  }
+  return GNUNET_OK;
+}
+
+
diff --git a/src/reclaim/gnunet-did.c b/src/reclaim/gnunet-did.c
index 2ebef7601..4c5704d44 100644
--- a/src/reclaim/gnunet-did.c
+++ b/src/reclaim/gnunet-did.c
@@ -1,6 +1,6 @@
 /*
    This file is part of GNUnet.
-   Copyright (C) 2012-2021 GNUnet e.V.
+   Copyright (C) 2012-2022 GNUnet e.V.
 
    GNUnet is free software: you can redistribute it and/or modify it
    under the terms of the GNU Affero General Public License as published
@@ -39,8 +39,8 @@
 #include "gnunet_gns_service.h"
 #include "gnunet_gnsrecord_lib.h"
 #include "jansson.h"
+#include "did.h"
 
-#define GNUNET_DID_METHOD_RECLAIM_PREFIX "did:reclaim:"
 #define GNUNET_DID_DEFAULT_DID_DOCUMENT_EXPIRATION_TIME "1d"
 
 /**
@@ -146,25 +146,6 @@ cleanup (void *cls)
   GNUNET_SCHEDULER_shutdown ();
 }
 
-char*
-ego_to_did (struct GNUNET_IDENTITY_Ego *ego)
-{
-  struct GNUNET_IDENTITY_PublicKey pkey; // Get Public key
-  char *pkey_str;
-  char *did_str;
-  size_t pkey_len;
-
-  GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
-
-  pkey_str = GNUNET_IDENTITY_public_key_to_string (&pkey);
-  GNUNET_asprintf (&did_str, "%s%s",
-                   GNUNET_DID_METHOD_RECLAIM_PREFIX,
-                   pkey_str);
-
-  free (pkey_str);
-  return did_str;
-}
-
 /**
  * @brief Callback for ego loockup of get_did_for_ego()
  *
@@ -183,7 +164,7 @@ get_did_for_ego_lookup_cb (void *cls, struct 
GNUNET_IDENTITY_Ego *ego)
     ret = 1;
     return;
   }
-  did_str = ego_to_did (ego);
+  did_str = DID_ego_to_did (ego);
 
   printf ("%s\n", did_str);
 
@@ -223,16 +204,9 @@ get_did_for_ego ()
 static void
 get_pkey_from_attr_did (struct GNUNET_IDENTITY_PublicKey *pkey)
 {
-  /* FIXME-MSC: I suggest introducing a
-   * #define MAX_DID_LENGTH <something>
-   * here and use it for parsing
-   */
-  char pkey_str[59];
-
-  if ((1 != (sscanf (did, GNUNET_DID_METHOD_RECLAIM_PREFIX"%58s", pkey_str))) 
||
-      (GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (pkey_str, pkey)))
+  if (GNUNET_OK != DID_public_key_from_did (did, pkey))
   {
-    fprintf (stderr, _("Invalid DID `%s'\n"), pkey_str);
+    fprintf (stderr, _("Invalid DID `%s'\n"), did);
     GNUNET_SCHEDULER_add_now (cleanup, NULL);
     ret = 1;
     return;
@@ -274,7 +248,7 @@ print_did_document (
     printf ("DID Document is not a TXT record\n");
   }
 
-  GNUNET_SCHEDULER_add_now (cleanup, NULL);
+  GNUNET_SCHEDULER_add_now (&cleanup, NULL);
   ret = 0;
   return;
 }
@@ -354,7 +328,7 @@ remove_did_document_namestore_cb (void *cls, int32_t 
success, const char *emgs)
       printf ("%s\n", emgs);
     }
 
-    GNUNET_SCHEDULER_add_now (cleanup, NULL);
+    GNUNET_SCHEDULER_add_now (&cleanup, NULL);
     ret = 0;
     return;
   }
@@ -798,7 +772,7 @@ process_dids (void *cls, struct GNUNET_IDENTITY_Ego *ego,
   }
   if (1 == show_all)
   {
-    did_str = ego_to_did (ego);
+    did_str = DID_ego_to_did (ego);
     printf ("%s\n", did_str);
     GNUNET_free (did_str);
     return;
@@ -807,7 +781,7 @@ process_dids (void *cls, struct GNUNET_IDENTITY_Ego *ego,
   {
     if (0 == strncmp (name, egoname, strlen (egoname)))
     {
-      did_str = ego_to_did (ego);
+      did_str = DID_ego_to_did (ego);
       printf ("%s\n", did_str);
       GNUNET_free (did_str);
       return;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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