aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/did_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/did_core.c')
-rw-r--r--src/reclaim/did_core.c31
1 files changed, 9 insertions, 22 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 @@
24 * @author Tristan Schwieren 24 * @author Tristan Schwieren
25 */ 25 */
26 26
27// DO: Expiration time missing in create
28// Add Expiration TIME to json DID document
27 29
28// TODO: Expiration time missing in create
29// TODO: Check if ego already has a DID document in create 30// TODO: Check if ego already has a DID document in create
30// TODO: Store DID document with empty label and own type (maybe DID-Document or Json??)
31// TODO: Store DID document as compact JSON in GNS but resolve it with newlines 31// TODO: Store DID document as compact JSON in GNS but resolve it with newlines
32 32
33#include "did_core.h" 33// TODO: Store DID document with empty label and own type (maybe DID-Document or JSON??)
34 34
35// #define DID_DOCUMENT_LABEL GNUNET_GNS_EMPTY_LABEL_AT 35#include "did_core.h"
36#define DID_DOCUMENT_LABEL "didd"
37#define DID_DOCUMENT_DEFAULT_EXPIRATION_TIME "1d"
38 36
39struct DID_resolve_return 37struct DID_resolve_return
40{ 38{
@@ -89,10 +87,7 @@ DID_resolve_gns_lookup_cb (
89 * Calls the given callback function with the resolved DID Document and the given closure. 87 * Calls the given callback function with the resolved DID Document and the given closure.
90 * If the did can not be resolved did_document is NULL. 88 * If the did can not be resolved did_document is NULL.
91 * 89 *
92 * @param did DID that is resolved 90 * @param did DID that is resolved000G055PGJ4RJSS4G8HWCP86AWF1C6TF2DW2K3BW05HHRKSJG38NT2Z3JGe
93 * @param gns_handle pointer to gns handle.
94 * @param cont callback function
95 * @param cls closure
96 */ 91 */
97enum GNUNET_GenericReturnValue 92enum GNUNET_GenericReturnValue
98DID_resolve (const char *did, 93DID_resolve (const char *did,
@@ -109,7 +104,7 @@ DID_resolve (const char *did,
109 if (GNUNET_OK != DID_did_to_pkey (did, &pkey)) 104 if (GNUNET_OK != DID_did_to_pkey (did, &pkey))
110 return GNUNET_NO; 105 return GNUNET_NO;
111 106
112 // Create closure for lockup callback 107 // Create closure for lookup callback
113 struct DID_resolve_return *cls2 = malloc (sizeof(struct DID_resolve_return)); 108 struct DID_resolve_return *cls2 = malloc (sizeof(struct DID_resolve_return));
114 cls2->cb = cont; 109 cls2->cb = cont;
115 cls2->cls = cls; 110 cls2->cls = cls;
@@ -161,12 +156,13 @@ DID_create_did_store_cb (void *cls,
161enum GNUNET_GenericReturnValue 156enum GNUNET_GenericReturnValue
162DID_create (const struct GNUNET_IDENTITY_Ego *ego, 157DID_create (const struct GNUNET_IDENTITY_Ego *ego,
163 const char *did_document, 158 const char *did_document,
159 const struct GNUNET_TIME_Relative *expire_time,
164 struct GNUNET_NAMESTORE_Handle *namestore_handle, 160 struct GNUNET_NAMESTORE_Handle *namestore_handle,
165 DID_action_callback *cont, 161 DID_action_callback *cont,
166 void *cls) 162 void *cls)
167{ 163{
168 struct GNUNET_IDENTITY_PublicKey pkey; 164 struct GNUNET_IDENTITY_PublicKey pkey;
169 struct GNUNET_TIME_Relative expire_time; 165 // struct GNUNET_TIME_Relative expire_time;
170 struct GNUNET_GNSRECORD_Data record_data; 166 struct GNUNET_GNSRECORD_Data record_data;
171 167
172 // Ego, namestore_handle and cont must be set 168 // Ego, namestore_handle and cont must be set
@@ -176,7 +172,6 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego,
176 // Check if ego has EdDSA key 172 // Check if ego has EdDSA key
177 GNUNET_IDENTITY_ego_get_public_key ((struct GNUNET_IDENTITY_Ego *) ego, 173 GNUNET_IDENTITY_ego_get_public_key ((struct GNUNET_IDENTITY_Ego *) ego,
178 &pkey); 174 &pkey);
179
180 if (ntohl (pkey.type) != GNUNET_GNSRECORD_TYPE_EDKEY) 175 if (ntohl (pkey.type) != GNUNET_GNSRECORD_TYPE_EDKEY)
181 { 176 {
182 printf ("The EGO has to have an EdDSA key pair\n"); 177 printf ("The EGO has to have an EdDSA key pair\n");
@@ -190,17 +185,9 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego,
190 else 185 else
191 did_document = DID_pkey_to_did_document (&pkey); 186 did_document = DID_pkey_to_did_document (&pkey);
192 187
193 // TODO: Get the expiration time as argument
194 if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (
195 DID_DOCUMENT_DEFAULT_EXPIRATION_TIME, &expire_time))
196 {
197 printf ("Failed to read given expiration time\n");
198 return GNUNET_NO;
199 }
200
201 // Create record 188 // Create record
202 record_data.data = did_document; 189 record_data.data = did_document;
203 record_data.expiration_time = expire_time.rel_value_us; 190 record_data.expiration_time = expire_time->rel_value_us;
204 record_data.data_size = strlen (did_document) + 1; 191 record_data.data_size = strlen (did_document) + 1;
205 record_data.record_type = GNUNET_GNSRECORD_typename_to_number ("TXT"), 192 record_data.record_type = GNUNET_GNSRECORD_typename_to_number ("TXT"),
206 record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 193 record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;