diff options
author | jospaeth <spaethj@in.tum.de> | 2020-08-03 11:58:50 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-08-03 11:58:50 +0200 |
commit | 1c09fd9efa3ce06b980b8e493644a7d271c52747 (patch) | |
tree | b1c1dfaa305d0a9e8b8b6a1145df80e1538854db /src/escrow/plugin_escrow_gns.c | |
parent | 7694804564e41a04e9d6e0909a59ee7ec3b7e627 (diff) | |
download | gnunet-1c09fd9efa3ce06b980b8e493644a7d271c52747.tar.gz gnunet-1c09fd9efa3ce06b980b8e493644a7d271c52747.zip |
major restructuring of the escrow component
refine the several layers (CLI, API, plugins) and enable async execution
Diffstat (limited to 'src/escrow/plugin_escrow_gns.c')
-rw-r--r-- | src/escrow/plugin_escrow_gns.c | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c index f77ef30d6..278ceff5b 100644 --- a/src/escrow/plugin_escrow_gns.c +++ b/src/escrow/plugin_escrow_gns.c | |||
@@ -44,7 +44,7 @@ static struct GNUNET_IDENTITY_Handle *identity_handle; | |||
44 | /** | 44 | /** |
45 | * Handle for the plugin instance | 45 | * Handle for the plugin instance |
46 | */ | 46 | */ |
47 | struct EscrowPluginHandle ph; | 47 | struct ESCROW_PluginHandle ph; |
48 | 48 | ||
49 | 49 | ||
50 | /** | 50 | /** |
@@ -53,21 +53,28 @@ struct EscrowPluginHandle ph; | |||
53 | * @param h the handle for the escrow component | 53 | * @param h the handle for the escrow component |
54 | * @param ego the identity ego containing the private key | 54 | * @param ego the identity ego containing the private key |
55 | * @param cb the function called upon completion | 55 | * @param cb the function called upon completion |
56 | * | ||
57 | * @return plugin operation wrapper | ||
56 | */ | 58 | */ |
57 | void | 59 | struct ESCROW_PluginOperationWrapper * |
58 | start_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | 60 | start_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, |
59 | const struct GNUNET_IDENTITY_Ego *ego, | 61 | const struct GNUNET_IDENTITY_Ego *ego, |
60 | GNUNET_ESCROW_AnchorContinuation cb) | 62 | GNUNET_SCHEDULER_TaskCallback cb) |
61 | { | 63 | { |
62 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | 64 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; |
63 | sss_Keyshare keyshares; | 65 | sss_Keyshare keyshares; |
64 | struct GNUNET_ESCROW_Anchor *anchor; | 66 | struct GNUNET_ESCROW_Anchor *anchor; |
65 | int anchorDataSize; | 67 | int anchorDataSize; |
68 | struct GNUNET_ESCROW_Plugin_AnchorContinuationWrapper *w; | ||
69 | |||
70 | w = GNUNET_new (struct GNUNET_ESCROW_Plugin_AnchorContinuationWrapper); | ||
71 | w->h = h; | ||
66 | 72 | ||
67 | if (NULL == ego) | 73 | if (NULL == ego) |
68 | { | 74 | { |
69 | cb (h, NULL); | 75 | w->escrowAnchor = NULL; |
70 | return; | 76 | GNUNET_SCHEDULER_add_now (cb, w); |
77 | return NULL; // TODO! | ||
71 | } | 78 | } |
72 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); | 79 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); |
73 | 80 | ||
@@ -85,7 +92,9 @@ start_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
85 | // TODO: implement | 92 | // TODO: implement |
86 | anchorDataSize = 0; // TODO! | 93 | anchorDataSize = 0; // TODO! |
87 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize); | 94 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize); |
88 | cb (h, anchor); | 95 | w->escrowAnchor = anchor; |
96 | GNUNET_SCHEDULER_add_now (cb, w); | ||
97 | return NULL; // TODO! | ||
89 | } | 98 | } |
90 | 99 | ||
91 | 100 | ||
@@ -100,7 +109,7 @@ renew_gns_key_escrow (struct GNUNET_ESCROW_Operation *op, | |||
100 | struct GNUNET_ESCROW_Anchor *escrowAnchor) | 109 | struct GNUNET_ESCROW_Anchor *escrowAnchor) |
101 | { | 110 | { |
102 | // TODO: implement | 111 | // TODO: implement |
103 | op->cb_renew (op->cb_cls, NULL); | 112 | op->cb_renew (NULL); |
104 | } | 113 | } |
105 | 114 | ||
106 | 115 | ||
@@ -111,15 +120,24 @@ renew_gns_key_escrow (struct GNUNET_ESCROW_Operation *op, | |||
111 | * @param ego the identity ego containing the private key | 120 | * @param ego the identity ego containing the private key |
112 | * @param escrowAnchor the escrow anchor needed to restore the key | 121 | * @param escrowAnchor the escrow anchor needed to restore the key |
113 | * @param cb the function called upon completion | 122 | * @param cb the function called upon completion |
123 | * | ||
124 | * @return plugin operation wrapper | ||
114 | */ | 125 | */ |
115 | void | 126 | struct ESCROW_PluginOperationWrapper * |
116 | verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | 127 | verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, |
117 | const struct GNUNET_IDENTITY_Ego *ego, | 128 | const struct GNUNET_IDENTITY_Ego *ego, |
118 | struct GNUNET_ESCROW_Anchor *escrowAnchor, | 129 | struct GNUNET_ESCROW_Anchor *escrowAnchor, |
119 | GNUNET_ESCROW_VerifyContinuation cb) | 130 | GNUNET_SCHEDULER_TaskCallback cb) |
120 | { | 131 | { |
132 | struct GNUNET_ESCROW_Plugin_VerifyContinuationWrapper *w; | ||
133 | |||
134 | w = GNUNET_new (struct GNUNET_ESCROW_Plugin_VerifyContinuationWrapper); | ||
135 | w->h = h; | ||
136 | |||
121 | // TODO: implement | 137 | // TODO: implement |
122 | cb (h, GNUNET_ESCROW_INVALID); | 138 | w->verificationResult = GNUNET_ESCROW_INVALID; |
139 | GNUNET_SCHEDULER_add_now (cb, w); | ||
140 | return NULL; | ||
123 | } | 141 | } |
124 | 142 | ||
125 | 143 | ||
@@ -130,15 +148,24 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
130 | * @param escrowAnchor the escrow anchor needed to restore the key | 148 | * @param escrowAnchor the escrow anchor needed to restore the key |
131 | * @param egoName the name of the ego to restore | 149 | * @param egoName the name of the ego to restore |
132 | * @param cb the function called upon completion | 150 | * @param cb the function called upon completion |
151 | * | ||
152 | * @return plugin operation wrapper | ||
133 | */ | 153 | */ |
134 | void | 154 | struct ESCROW_PluginOperationWrapper * |
135 | restore_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | 155 | restore_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, |
136 | struct GNUNET_ESCROW_Anchor *escrowAnchor, | 156 | struct GNUNET_ESCROW_Anchor *escrowAnchor, |
137 | char *egoName, | 157 | char *egoName, |
138 | GNUNET_ESCROW_EgoContinuation cb) | 158 | GNUNET_SCHEDULER_TaskCallback cb) |
139 | { | 159 | { |
160 | struct GNUNET_ESCROW_Plugin_EgoContinuationWrapper *w; | ||
161 | |||
162 | w = GNUNET_new (struct GNUNET_ESCROW_Plugin_EgoContinuationWrapper); | ||
163 | w->h = h; | ||
164 | |||
140 | // TODO: implement | 165 | // TODO: implement |
141 | cb (h, NULL); | 166 | w->ego = NULL; |
167 | GNUNET_SCHEDULER_add_now (cb, w); | ||
168 | return NULL; | ||
142 | } | 169 | } |
143 | 170 | ||
144 | 171 | ||
@@ -185,6 +212,19 @@ gns_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h, | |||
185 | 212 | ||
186 | 213 | ||
187 | /** | 214 | /** |
215 | * Cancel a GNS plugin operation. | ||
216 | * | ||
217 | * @param plugin_op_wrap the plugin operation wrapper containing the operation | ||
218 | */ | ||
219 | void | ||
220 | cancel_gns_operation (struct ESCROW_PluginOperationWrapper *plugin_op_wrap) | ||
221 | { | ||
222 | // TODO: implement | ||
223 | return; | ||
224 | } | ||
225 | |||
226 | |||
227 | /** | ||
188 | * IdentityInitContinuation for the GNS plugin | 228 | * IdentityInitContinuation for the GNS plugin |
189 | */ | 229 | */ |
190 | void | 230 | void |
@@ -213,6 +253,7 @@ libgnunet_plugin_escrow_gns_init (void *cls) | |||
213 | api->verify_key_escrow = &verify_gns_key_escrow; | 253 | api->verify_key_escrow = &verify_gns_key_escrow; |
214 | api->restore_key = &restore_gns_key_escrow; | 254 | api->restore_key = &restore_gns_key_escrow; |
215 | api->anchor_string_to_data = &gns_anchor_string_to_data; | 255 | api->anchor_string_to_data = &gns_anchor_string_to_data; |
256 | api->cancel_plugin_operation = &cancel_gns_operation; | ||
216 | 257 | ||
217 | ph.id_init_cont = &gns_cont_init; | 258 | ph.id_init_cont = &gns_cont_init; |
218 | 259 | ||