[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 64/70: - didlib; use expire value
From: |
gnunet |
Subject: |
[gnunet] 64/70: - didlib; use expire value |
Date: |
Wed, 31 Aug 2022 18:00:58 +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 9c008dbed86125e74286f4a9c7da0f586fc7e04d
Author: Tristan Schwieren <tristan.schwieren@tum.de>
AuthorDate: Wed Jul 6 15:10:33 2022 +0200
- didlib; use expire value
---
src/reclaim/did_core.c | 31 +++++++++----------------------
src/reclaim/did_core.h | 6 ++++++
src/reclaim/gnunet-did.c | 46 +++++++++++++++++++++++++++++++---------------
3 files changed, 46 insertions(+), 37 deletions(-)
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c
index 16bdb0bdb..f43b7e7eb 100644
--- a/src/reclaim/did_core.c
+++ b/src/reclaim/did_core.c
@@ -24,17 +24,15 @@
* @author Tristan Schwieren
*/
+// DO: Expiration time missing in create
+// Add Expiration TIME to json DID document
-// TODO: Expiration time missing in create
// TODO: Check if ego already has a DID document in create
-// TODO: Store DID document with empty label and own type (maybe DID-Document
or Json??)
// TODO: Store DID document as compact JSON in GNS but resolve it with newlines
-#include "did_core.h"
+// TODO: Store DID document with empty label and own type (maybe DID-Document
or JSON??)
-// #define DID_DOCUMENT_LABEL GNUNET_GNS_EMPTY_LABEL_AT
-#define DID_DOCUMENT_LABEL "didd"
-#define DID_DOCUMENT_DEFAULT_EXPIRATION_TIME "1d"
+#include "did_core.h"
struct DID_resolve_return
{
@@ -89,10 +87,7 @@ DID_resolve_gns_lookup_cb (
* 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 DID that is resolved
- * @param gns_handle pointer to gns handle.
- * @param cont callback function
- * @param cls closure
+ * @param did DID that is
resolved000G055PGJ4RJSS4G8HWCP86AWF1C6TF2DW2K3BW05HHRKSJG38NT2Z3JGe
*/
enum GNUNET_GenericReturnValue
DID_resolve (const char *did,
@@ -109,7 +104,7 @@ DID_resolve (const char *did,
if (GNUNET_OK != DID_did_to_pkey (did, &pkey))
return GNUNET_NO;
- // Create closure for lockup callback
+ // Create closure for lookup callback
struct DID_resolve_return *cls2 = malloc (sizeof(struct DID_resolve_return));
cls2->cb = cont;
cls2->cls = cls;
@@ -161,12 +156,13 @@ DID_create_did_store_cb (void *cls,
enum GNUNET_GenericReturnValue
DID_create (const struct GNUNET_IDENTITY_Ego *ego,
const char *did_document,
+ const struct GNUNET_TIME_Relative *expire_time,
struct GNUNET_NAMESTORE_Handle *namestore_handle,
DID_action_callback *cont,
void *cls)
{
struct GNUNET_IDENTITY_PublicKey pkey;
- struct GNUNET_TIME_Relative expire_time;
+ // struct GNUNET_TIME_Relative expire_time;
struct GNUNET_GNSRECORD_Data record_data;
// Ego, namestore_handle and cont must be set
@@ -176,7 +172,6 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego,
// Check if ego has EdDSA key
GNUNET_IDENTITY_ego_get_public_key ((struct GNUNET_IDENTITY_Ego *) ego,
&pkey);
-
if (ntohl (pkey.type) != GNUNET_GNSRECORD_TYPE_EDKEY)
{
printf ("The EGO has to have an EdDSA key pair\n");
@@ -190,17 +185,9 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego,
else
did_document = DID_pkey_to_did_document (&pkey);
- // TODO: Get the expiration time as argument
- if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (
- DID_DOCUMENT_DEFAULT_EXPIRATION_TIME, &expire_time))
- {
- printf ("Failed to read given expiration time\n");
- return GNUNET_NO;
- }
-
// Create record
record_data.data = did_document;
- record_data.expiration_time = expire_time.rel_value_us;
+ record_data.expiration_time = expire_time->rel_value_us;
record_data.data_size = strlen (did_document) + 1;
record_data.record_type = GNUNET_GNSRECORD_typename_to_number ("TXT"),
record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
diff --git a/src/reclaim/did_core.h b/src/reclaim/did_core.h
index 6cde18342..842424e14 100644
--- a/src/reclaim/did_core.h
+++ b/src/reclaim/did_core.h
@@ -33,6 +33,10 @@
#include "did_helper.h"
#include "jansson.h"
+// #define DID_DOCUMENT_LABEL GNUNET_GNS_EMPTY_LABEL_AT
+#define DID_DOCUMENT_LABEL "didd"
+#define DID_DOCUMENT_DEFAULT_EXPIRATION_TIME "365d"
+
/**
* @brief Signature of a callback function that is called after a did has been
resolved.
* did_document contains an Error message if DID can not be resolved.
@@ -99,6 +103,7 @@ DID_remove (const struct GNUNET_IDENTITY_Ego *ego,
* @param ego ego for which the DID should be created.
* @param did_document did_document that should be saved in namestore.
* If did_document==NULL -> Default DID document is created.
+ * @param expire_time
* @param namestore_handle
* @param cont callback function
* @param cls closure
@@ -106,6 +111,7 @@ DID_remove (const struct GNUNET_IDENTITY_Ego *ego,
enum GNUNET_GenericReturnValue
DID_create (const struct GNUNET_IDENTITY_Ego *ego,
const char *did_document,
+ const struct GNUNET_TIME_Relative *expire_time,
struct GNUNET_NAMESTORE_Handle *namestore_handle,
DID_action_callback *cont,
void *cls);
diff --git a/src/reclaim/gnunet-did.c b/src/reclaim/gnunet-did.c
index 55eedfbd7..fb9a8e9a1 100644
--- a/src/reclaim/gnunet-did.c
+++ b/src/reclaim/gnunet-did.c
@@ -36,6 +36,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_namestore_service.h"
+#include "gnunet_identity_service.h"
#include "gnunet_gns_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "did_helper.h"
@@ -157,7 +158,7 @@ cleanup (void *cls)
// get_did_for_ego_lookup_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
// {
// char *did_str;
-//
+//
// if (ego == NULL)
// {
// printf ("EGO not found\n");
@@ -166,9 +167,9 @@ cleanup (void *cls)
// return;
// }
// did_str = DID_identity_to_did (ego);
-//
+//
// printf ("%s\n", did_str);
-//
+//
// GNUNET_SCHEDULER_add_now (&cleanup, NULL);
// ret = 0;
// return;
@@ -426,9 +427,34 @@ create_did_ego_lockup_cb (void *cls, struct
GNUNET_IDENTITY_Ego *ego)
{
char *did = DID_identity_to_did (ego);
void *cls = malloc (strlen (did) + 1);
+ struct GNUNET_TIME_Relative expire_relative;
+
+ if (expire == NULL)
+ {
+ GNUNET_STRINGS_fancy_time_to_relative (
+ DID_DOCUMENT_DEFAULT_EXPIRATION_TIME, &expire_relative);
+ }
+ else if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (expire,
+ &
+
expire_relative))
+ {
+ printf ("Failed to read given expiration time\n");
+ GNUNET_SCHEDULER_add_now (cleanup, NULL);
+ ret = 1;
+ return;
+ }
+
strcpy (cls, did);
// TODO: Add DID_document argument
- DID_create (ego, NULL, namestore_handle, create_did_cb, cls);
+ if (GNUNET_OK != DID_create (ego, NULL, &expire_relative, namestore_handle,
+ create_did_cb,
+ cls))
+ {
+ printf ("An error occured while creating the DID.\n");
+ ret = 1;
+ GNUNET_SCHEDULER_add_now (&cleanup, NULL);
+ return;
+ }
}
}
@@ -439,16 +465,6 @@ create_did_ego_lockup_cb (void *cls, struct
GNUNET_IDENTITY_Ego *ego)
static void
create_did ()
{
- // Expire has to be set
- if (expire == NULL)
- {
- printf (
- "Set the Expiration-time argument to create a new DID(-Document)\n");
- GNUNET_SCHEDULER_add_now (&cleanup, NULL);
- ret = 1;
- return;
- }
-
// Ego name to be set
if (egoname == NULL)
{
@@ -515,7 +531,7 @@ static void
post_ego_iteration (void *cls)
{
// TODO: Check that only one argument is set
-
+
if (1 == replace)
{
replace_did_document ();
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 68/70: - DID lib; simplify closure, (continued)
- [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, 2022/08/31
- [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 <=
- [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