[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 57/70: - changed did_core header
From: |
gnunet |
Subject: |
[gnunet] 57/70: - changed did_core header |
Date: |
Wed, 31 Aug 2022 18:00:51 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit bc05f5201575ac97edbfedbc77d780fd6db558d6
Author: Tristan Schwieren <tristan.schwieren@tum.de>
AuthorDate: Fri Jun 24 15:03:11 2022 +0200
- changed did_core header
---
src/reclaim/.gitignore | 3 +++
src/reclaim/did_core.c | 28 +++++++++++++++++++
src/reclaim/did_core.h | 62 ++++++++++++++++++++++++++++---------------
src/reclaim/did_helper.c | 20 +++++++-------
src/reclaim/did_helper.h | 12 ++++-----
src/reclaim/test_did_helper.c | 9 +++----
6 files changed, 91 insertions(+), 43 deletions(-)
diff --git a/src/reclaim/.gitignore b/src/reclaim/.gitignore
index 46472101b..e22aa5011 100644
--- a/src/reclaim/.gitignore
+++ b/src/reclaim/.gitignore
@@ -1,2 +1,5 @@
gnunet-reclaim
gnunet-service-reclaim
+gnunet-did
+test_did_helper
+test_reclaim_attribute
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c
new file mode 100644
index 000000000..74c715651
--- /dev/null
+++ b/src/reclaim/did_core.c
@@ -0,0 +1,28 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2010-2015 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
+ */
+
+/**
+ * @file reclaim/did_core.c
+ * @brief Core functionality for DID
+ * @author Tristan Schwieren
+ */
+
+
+#include "did_core.h"
\ No newline at end of file
diff --git a/src/reclaim/did_core.h b/src/reclaim/did_core.h
index f53ae5400..6a1c23bc8 100644
--- a/src/reclaim/did_core.h
+++ b/src/reclaim/did_core.h
@@ -26,20 +26,22 @@
#include "platform.h"
#include "gnunet_util_lib.h"
+#include "gnunet_namestore_service.h"
#include "gnunet_gns_service.h"
+#include "gnunet_gnsrecord_lib.h"
#include "did_helper.h"
-
+#include "jansson.h"
/**
* @brief Signature of a callback function that is called after a did has been
resolved.
* did_document is NULL if DID can not be resolved.
- *Calls the given callback function with the resolved DID Document and the
given closure.
+ * Calls the given callback function with the resolved DID Document and the
given closure.
* If the did can not be resolved did_document is NULL.
* @param did_document resolved DID Document
* @param cls previsouly given closure
*/
typedef void
- did_resolve_callback (char *did_document, void *cls);
+ DID_resolve_callback (char *did_document, void *cls);
/**
* @brief Signature of a callback function that is called after a did has been
removed
@@ -50,7 +52,7 @@ typedef void
* @param cls previsouly given closure
*/
typedef void
- did_action_callback (int status, void *cls);
+ DID_action_callback (enum GNUNET_GenericReturnValue status, void *cls);
/**
@@ -59,13 +61,15 @@ typedef void
* If the did can not be resolved did_document is NULL.
*
* @param did DID that is resolved
+ * @param gns_handle pointer to gns handle.
* @param cont callback function
* @param cls closure
*/
-void
-GNUNET_DID_resolve (char *did,
- did_resolve_callback *cont,
- void *cls);
+enum GNUNET_GenericReturnValue
+DID_resolve (const char *did,
+ struct GNUNET_GNS_Handle *gns_handle,
+ DID_resolve_callback *cont,
+ void *cls);
/**
@@ -74,13 +78,17 @@ GNUNET_DID_resolve (char *did,
* Calls the callback function with status and the given closure.
*
* @param ego ego which controlls the DID
+ * @param cfg_handle pointer to configuration handle
+ * @param namestore_handle pointer to namestore handle
* @param cont callback function
* @param cls closure
*/
-void
-GNUNET_DID_remove (struct GNUNET_IDENTITY_Ego *ego,
- did_action_callback *cont,
- void *cls);
+enum GNUNET_GenericReturnValue
+DID_remove (const struct GNUNET_IDENTITY_Ego *ego,
+ struct GNUNET_CONFIGURATION_Handle *cfg_handle,
+ struct GNUNET_NAMESTORE_Handle *namestore_handle,
+ DID_action_callback *cont,
+ void *cls);
/**
@@ -91,14 +99,18 @@ GNUNET_DID_remove (struct GNUNET_IDENTITY_Ego *ego,
* @param did_document did_document that should be saved in namestore.
* If ego==NULL did_document can also be NULL.
* Default DID document is created.
+ * @param cfg_handle pointer to configuration handle
+ * @param identity_hanlde pointer to configuration handle. Can be NULL if
ego!=NULL
* @param cont callback function
* @param cls closure
*/
-void
-GNUNET_DID_create (struct GNUNET_IDENTITY_Ego *ego,
- char *did_document,
- did_action_callback *cont,
- void *cls);
+enum GNUNET_GenericReturnValue
+DID_create (const struct GNUNET_IDENTITY_Ego *ego,
+ const char *did_document,
+ struct GNUNET_CONFIGURATION_Handle *cfg_handle,
+ struct GNUNET_IDENTITY_Handle *identity_handle,
+ DID_action_callback *cont,
+ void *cls);
/**
@@ -106,11 +118,17 @@ GNUNET_DID_create (struct GNUNET_IDENTITY_Ego *ego,
*
* @param ego ego for which the DID Document should be replaced
* @param did_document new DID Document
+ * @param cfg_handle pointer to configuration handle
+ * @param identity_handle pointer to configuration handle
+ * @param namestore_handle pointer to namestore handle
* @param cont callback function
* @param cls closure
*/
-void
-GNUNET_DID_replace (struct GNUNET_IDENTITY_Ego *ego,
- char *did_document,
- did_action_callback *cont,
- void *cls);
+enum GNUNET_GenericReturnValue
+DID_replace (struct GNUNET_IDENTITY_Ego *ego,
+ char *did_document,
+ struct GNUNET_CONFIGURATION_Handle *cfg_handle,
+ struct GNUNET_IDENTITY_Handle *identity_handle,
+ struct GNUNET_NAMESTORE_Handle *namestore_handle,
+ DID_action_callback *cont,
+ void *cls);
diff --git a/src/reclaim/did_helper.c b/src/reclaim/did_helper.c
index c579a5cca..0cc400c09 100644
--- a/src/reclaim/did_helper.c
+++ b/src/reclaim/did_helper.c
@@ -42,7 +42,7 @@
* TODO: Check if EdDSA
*/
char*
-GNUNET_DID_pkey_to_did (struct GNUNET_IDENTITY_PublicKey *pkey)
+DID_pkey_to_did (struct GNUNET_IDENTITY_PublicKey *pkey)
{
char *pkey_str;
char *did_str;
@@ -64,19 +64,19 @@ GNUNET_DID_pkey_to_did (struct GNUNET_IDENTITY_PublicKey
*pkey)
* @return char* Returns the DID. Caller must free
*/
char*
-GNUNET_DID_identity_to_did (struct GNUNET_IDENTITY_Ego *ego)
+DID_identity_to_did (struct GNUNET_IDENTITY_Ego *ego)
{
struct GNUNET_IDENTITY_PublicKey pkey;
GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
- return GNUNET_DID_pkey_to_did (&pkey);
+ return DID_pkey_to_did (&pkey);
}
/**
* @brief Return the public key of a DID
*/
int
-GNUNET_DID_did_to_pkey (char *did, struct GNUNET_IDENTITY_PublicKey *pkey)
+DID_did_to_pkey (char *did, struct GNUNET_IDENTITY_PublicKey *pkey)
{
/* FIXME-MSC: I suggest introducing a
* #define MAX_DID_LENGTH <something>
@@ -111,7 +111,7 @@ GNUNET_DID_key_covert_multibase_base64_to_gnunet (char
*pkey_str)
* @brief Convert GNUNET key to a base 64 encoded public key
*/
char *
-GNUNET_DID_key_covert_gnunet_to_multibase_base64 (struct
+DID_key_covert_gnunet_to_multibase_base64 (struct
GNUNET_IDENTITY_PublicKey *
pkey)
{
@@ -139,7 +139,7 @@ GNUNET_DID_key_covert_gnunet_to_multibase_base64 (struct
* @return void* Return pointer to the DID Document
*/
char *
-GNUNET_DID_pkey_to_did_document (struct GNUNET_IDENTITY_PublicKey *pkey)
+DID_pkey_to_did_document (struct GNUNET_IDENTITY_PublicKey *pkey)
{
/* FIXME-MSC: This is effectively creating a DID Document default template
for
@@ -155,10 +155,10 @@ GNUNET_DID_pkey_to_did_document (struct
GNUNET_IDENTITY_PublicKey *pkey)
char *didd_str;
json_t *didd_json;
- did_str = GNUNET_DID_pkey_to_did (pkey);
+ did_str = DID_pkey_to_did (pkey);
GNUNET_asprintf (&verify_id_str, "%s#key-1", did_str);
- pkey_multibase_str = GNUNET_DID_key_covert_gnunet_to_multibase_base64 (pkey);
+ pkey_multibase_str = DID_key_covert_gnunet_to_multibase_base64 (pkey);
didd_json = json_pack (
"{s:[ss], s:s, s:[{s:s, s:s, s:s, s:s}], s:[s], s:[s]}",
@@ -198,10 +198,10 @@ GNUNET_DID_pkey_to_did_document (struct
GNUNET_IDENTITY_PublicKey *pkey)
* Wrapper around GNUNET_DID_pkey_to_did_document
*/
char *
-GNUNET_DID_identity_to_did_document (struct GNUNET_IDENTITY_Ego *ego)
+DID_identity_to_did_document (struct GNUNET_IDENTITY_Ego *ego)
{
struct GNUNET_IDENTITY_PublicKey pkey;
GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
- return GNUNET_DID_pkey_to_did (&pkey);
+ return DID_pkey_to_did (&pkey);
}
\ No newline at end of file
diff --git a/src/reclaim/did_helper.h b/src/reclaim/did_helper.h
index 11bab0354..729d0d835 100644
--- a/src/reclaim/did_helper.h
+++ b/src/reclaim/did_helper.h
@@ -31,7 +31,7 @@
* @brief Return a DID for a given GNUNET public key
*/
char *
-GNUNET_DID_pkey_to_did (struct GNUNET_IDENTITY_PublicKey *pkey);
+DID_pkey_to_did (struct GNUNET_IDENTITY_PublicKey *pkey);
/**
* @brief Generate a DID for a given gnunet EGO
@@ -40,13 +40,13 @@ GNUNET_DID_pkey_to_did (struct GNUNET_IDENTITY_PublicKey
*pkey);
* @return char * Returns the DID. Caller must free
*/
char *
-GNUNET_DID_identity_to_did (struct GNUNET_IDENTITY_Ego *ego);
+DID_identity_to_did (struct GNUNET_IDENTITY_Ego *ego);
/**
* @brief Return the public key of a DID
*/
int
-GNUNET_DID_did_to_pkey (char *did, struct GNUNET_IDENTITY_PublicKey *pkey);
+DID_did_to_pkey (char *did, struct GNUNET_IDENTITY_PublicKey *pkey);
// /**
// * @brief Convert a base 64 encoded public key to a GNUNET key
@@ -58,17 +58,17 @@ GNUNET_DID_did_to_pkey (char *did, struct
GNUNET_IDENTITY_PublicKey *pkey);
* @brief Convert GNUNET key to a base 64 encoded public key
*/
char *
-GNUNET_DID_key_covert_gnunet_to_multibase_base64 (struct
+DID_key_covert_gnunet_to_multibase_base64 (struct
GNUNET_IDENTITY_PublicKey *);
/**
* @brief Generate the default DID document for a GNUNET public key
*/
char *
-GNUNET_DID_pkey_to_did_document (struct GNUNET_IDENTITY_PublicKey *pkey);
+DID_pkey_to_did_document (struct GNUNET_IDENTITY_PublicKey *pkey);
/**
* @brief Generate the default DID document for a GNUNET ego
*/
char *
-GNUNET_DID_identity_to_did_document (struct GNUNET_IDENTITY_Ego *ego);
\ No newline at end of file
+DID_identity_to_did_document (struct GNUNET_IDENTITY_Ego *ego);
\ No newline at end of file
diff --git a/src/reclaim/test_did_helper.c b/src/reclaim/test_did_helper.c
index c514f17b2..2f72c3496 100644
--- a/src/reclaim/test_did_helper.c
+++ b/src/reclaim/test_did_helper.c
@@ -67,7 +67,7 @@ void
test_GNUNET_DID_pkey_to_did ()
{
char *str_did;
- str_did = GNUNET_DID_pkey_to_did (&test_pkey);
+ str_did = DID_pkey_to_did (&test_pkey);
GNUNET_assert (strcmp ((char *) test_did, str_did) == 0);
}
@@ -75,7 +75,7 @@ void
test_GNUNET_DID_did_to_pkey ()
{
struct GNUNET_IDENTITY_PublicKey pkey;
- GNUNET_DID_did_to_pkey ((char *) test_did, &pkey);
+ DID_did_to_pkey ((char *) test_did, &pkey);
GNUNET_assert (test_pkey.type = pkey.type);
GNUNET_assert (strcmp (pkey.eddsa_key.q_y,
@@ -89,8 +89,7 @@ void
test_GNUNET_DID_key_covert_gnunet_to_multibase_base64 ()
{
char *multibase_key;
- multibase_key = GNUNET_DID_key_covert_gnunet_to_multibase_base64
(&test_pkey);
- printf ("%s\n", multibase_key);
+ multibase_key = DID_key_covert_gnunet_to_multibase_base64 (&test_pkey);
GNUNET_assert (strcmp (test_multibase_key, multibase_key) == 0);
}
@@ -99,7 +98,7 @@ void
test_GNUNET_DID_pkey_to_did_document ()
{
struct json_t *did_document;
- char *did_document_str = GNUNET_DID_pkey_to_did_document (&test_pkey);
+ char *did_document_str = DID_pkey_to_did_document (&test_pkey);
did_document = json_loads (did_document_str, JSON_DECODE_ANY, NULL);
GNUNET_assert (json_equal (test_did_document, did_document) == 1);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 63/70: - remove static variable from did_core, (continued)
- [gnunet] 63/70: - remove static variable from did_core, gnunet, 2022/08/31
- [gnunet] 55/70: - finished DID helper with tests, gnunet, 2022/08/31
- [gnunet] 60/70: - started with DID lib create func, gnunet, 2022/08/31
- [gnunet] 54/70: - default did document test without multibase, gnunet, 2022/08/31
- [gnunet] 68/70: - DID lib; simplify closure, gnunet, 2022/08/31
- [gnunet] 30/70: -DID refactor, uncrustify, not working didd create, gnunet, 2022/08/31
- [gnunet] 31/70: - did not working create, gnunet, 2022/08/31
- [gnunet] 46/70: -code review, gnunet, 2022/08/31
- [gnunet] 53/70: - more tests, gnunet, 2022/08/31
- [gnunet] 61/70: - non working DID lib create func, gnunet, 2022/08/31
- [gnunet] 57/70: - changed did_core header,
gnunet <=
- [gnunet] 59/70: - DID resolve using DID lib, gnunet, 2022/08/31
- [gnunet] 67/70: - DID lib; formatting, gnunet, 2022/08/31
- [gnunet] 51/70: - trying to make did_helper a lib, gnunet, 2022/08/31
- [gnunet] 64/70: - didlib; use expire value, gnunet, 2022/08/31
- [gnunet] 69/70: - added gitignores, gnunet, 2022/08/31
- [gnunet] 65/70: -m DID lib; added check for existing DID document, gnunet, 2022/08/31
- [gnunet] 22/70: -did mulitbase key and assert method for VCs, gnunet, 2022/08/31
- [gnunet] 25/70: -forgot the .c..., gnunet, 2022/08/31