aboutsummaryrefslogtreecommitdiff
path: root/src/escrow/plugin_escrow_plaintext.c
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-07-15 16:28:26 +0200
committerjospaeth <spaethj@in.tum.de>2020-07-15 16:28:26 +0200
commit3192c1c84a8cf6aa81e55ac647adf125cbd88904 (patch)
treecf8c0505b36ac3a5c7d86d6a683b6651c1917dce /src/escrow/plugin_escrow_plaintext.c
parent122f2979146c6068cbaf189560f196e4a3323801 (diff)
downloadgnunet-3192c1c84a8cf6aa81e55ac647adf125cbd88904.tar.gz
gnunet-3192c1c84a8cf6aa81e55ac647adf125cbd88904.zip
changes to the escrow api [not compiling]
Diffstat (limited to 'src/escrow/plugin_escrow_plaintext.c')
-rw-r--r--src/escrow/plugin_escrow_plaintext.c66
1 files changed, 61 insertions, 5 deletions
diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c
index 347ab56e5..2213b334c 100644
--- a/src/escrow/plugin_escrow_plaintext.c
+++ b/src/escrow/plugin_escrow_plaintext.c
@@ -27,11 +27,23 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_escrow_plugin.h" 29#include "gnunet_escrow_plugin.h"
30#include "escrow_plugin_helper.h"
30#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
31#include <inttypes.h> 32#include <inttypes.h>
32 33
33 34
34/** 35/**
36 * Identity handle
37 */
38static struct GNUNET_IDENTITY_Handle *identity_handle;
39
40/**
41 * Handle for the plugin instance
42 */
43struct EscrowPluginHandle ph;
44
45
46/**
35 * Start the plaintext escrow of the key, i.e. simply hand out the key 47 * Start the plaintext escrow of the key, i.e. simply hand out the key
36 * 48 *
37 * @param ego the identity ego containing the private key 49 * @param ego the identity ego containing the private key
@@ -58,9 +70,9 @@ start_plaintext_key_escrow (const struct GNUNET_IDENTITY_Ego *ego)
58 * @return the escrow anchor needed to restore the key 70 * @return the escrow anchor needed to restore the key
59 */ 71 */
60void * 72void *
61renew_plaintext_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) 73renew_plaintext_key_escrow (void *escrowAnchor)
62{ 74{
63 return start_plaintext_key_escrow (ego); 75 return escrowAnchor;
64} 76}
65 77
66 78
@@ -102,14 +114,13 @@ const struct GNUNET_IDENTITY_Ego *
102restore_plaintext_key_escrow (void *escrowAnchor, 114restore_plaintext_key_escrow (void *escrowAnchor,
103 char *egoName) 115 char *egoName)
104{ 116{
105 const struct GNUNET_CRYPTO_EcdsaPrivateKey pk; 117 struct GNUNET_CRYPTO_EcdsaPrivateKey pk;
106 struct GNUNET_IDENTITY_Operation *op; 118 struct GNUNET_IDENTITY_Operation *op;
107 119
108 if (NULL == escrowAnchor) 120 if (NULL == escrowAnchor)
109 { 121 {
110 return NULL; 122 return NULL;
111 } 123 }
112 // TODO: ecdsa method for string -> privkey
113 if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_private_key_from_string ((char *)escrowAnchor, 124 if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_private_key_from_string ((char *)escrowAnchor,
114 strlen ((char *)escrowAnchor), 125 strlen ((char *)escrowAnchor),
115 &pk)) 126 &pk))
@@ -128,21 +139,63 @@ restore_plaintext_key_escrow (void *escrowAnchor,
128 139
129 140
130/** 141/**
142 * Deserialize an escrow anchor string into a GNUNET_ESCROW_Anchor struct
143 *
144 * @param anchorString the encoded escrow anchor string
145 * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct
146 */
147const struct GNUNET_ESCROW_Anchor *
148plaintext_anchor_string_to_data (char *anchorString)
149{
150 struct GNUNET_ESCROW_Anchor *anchor;
151 uint32_t data_size;
152
153 data_size = strlen (anchorString) + 1;
154
155 anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + data_size);
156 anchor->size = data_size;
157 // TODO: deserialize?
158 GNUNET_memcpy (&anchor[1], anchorString, data_size);
159
160 return anchor;
161}
162
163
164/**
165 * ContinueIdentityInitFunction for the plaintext plugin
166 */
167void
168plaintext_cont_init ()
169{
170 return;
171}
172
173
174/**
131 * Entry point for the plugin. 175 * Entry point for the plugin.
132 * 176 *
133 * @param cls NULL 177 * @param cls Config info
134 * @return the exported block API 178 * @return the exported block API
135 */ 179 */
136void * 180void *
137libgnunet_plugin_escrow_plaintext_init (void *cls) 181libgnunet_plugin_escrow_plaintext_init (void *cls)
138{ 182{
139 struct GNUNET_ESCROW_KeyPluginFunctions *api; 183 struct GNUNET_ESCROW_KeyPluginFunctions *api;
184 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
140 185
141 api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions); 186 api = GNUNET_new (struct GNUNET_ESCROW_KeyPluginFunctions);
142 api->start_key_escrow = &start_plaintext_key_escrow; 187 api->start_key_escrow = &start_plaintext_key_escrow;
143 api->renew_key_escrow = &renew_plaintext_key_escrow; 188 api->renew_key_escrow = &renew_plaintext_key_escrow;
144 api->verify_key_escrow = &verify_plaintext_key_escrow; 189 api->verify_key_escrow = &verify_plaintext_key_escrow;
145 api->restore_key = &restore_plaintext_key_escrow; 190 api->restore_key = &restore_plaintext_key_escrow;
191 api->anchor_string_to_data = &plaintext_anchor_string_to_data;
192
193 ph.cont = &plaintext_cont_init;
194
195 identity_handle = GNUNET_IDENTITY_connect (cfg,
196 &GNUNET_ESCROW_list_ego,
197 &ph);
198
146 return api; 199 return api;
147} 200}
148 201
@@ -159,6 +212,9 @@ libgnunet_plugin_escrow_plaintext_done (void *cls)
159 struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls; 212 struct GNUNET_RECLAIM_EscrowKeyPluginFunctions *api = cls;
160 213
161 GNUNET_free (api); 214 GNUNET_free (api);
215 GNUNET_IDENTITY_disconnect (identity_handle);
216 GNUNET_ESCROW_cleanup_ego_list (&ph);
217
162 return NULL; 218 return NULL;
163} 219}
164 220