aboutsummaryrefslogtreecommitdiff
path: root/src/escrow/plugin_escrow_plaintext.c
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-07-22 17:23:53 +0200
committerjospaeth <spaethj@in.tum.de>2020-07-22 17:23:53 +0200
commit7694804564e41a04e9d6e0909a59ee7ec3b7e627 (patch)
treee4d0a539e0eec95677f94dba281f5d071d0ff292 /src/escrow/plugin_escrow_plaintext.c
parent0c87a350df02b1dcaffe615f31a63e92be63aef1 (diff)
downloadgnunet-7694804564e41a04e9d6e0909a59ee7ec3b7e627.tar.gz
gnunet-7694804564e41a04e9d6e0909a59ee7ec3b7e627.zip
handle escrow operations as dll, clean them up
(not yet finished)
Diffstat (limited to 'src/escrow/plugin_escrow_plaintext.c')
-rw-r--r--src/escrow/plugin_escrow_plaintext.c67
1 files changed, 43 insertions, 24 deletions
diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c
index d6f224330..63ffe7720 100644
--- a/src/escrow/plugin_escrow_plaintext.c
+++ b/src/escrow/plugin_escrow_plaintext.c
@@ -47,12 +47,14 @@ struct EscrowPluginHandle ph;
47/** 47/**
48 * Start the plaintext escrow of the key, i.e. simply hand out the key 48 * Start the plaintext escrow of the key, i.e. simply hand out the key
49 * 49 *
50 * @param op the escrow operation 50 * @param h the handle for the escrow component
51 * @param ego the identity ego containing the private key 51 * @param ego the identity ego containing the private key
52 * @param cb the function called upon completion
52 */ 53 */
53void 54void
54start_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op, 55start_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
55 const struct GNUNET_IDENTITY_Ego *ego) 56 const struct GNUNET_IDENTITY_Ego *ego,
57 GNUNET_ESCROW_AnchorContinuation cb)
56{ 58{
57 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; 59 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
58 struct GNUNET_ESCROW_Anchor *anchor; 60 struct GNUNET_ESCROW_Anchor *anchor;
@@ -61,7 +63,7 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op,
61 63
62 if (NULL == ego) 64 if (NULL == ego)
63 { 65 {
64 op->cb_put (op->cb_cls, NULL); 66 cb (h, NULL);
65 return; 67 return;
66 } 68 }
67 pk = GNUNET_IDENTITY_ego_get_private_key (ego); 69 pk = GNUNET_IDENTITY_ego_get_private_key (ego);
@@ -73,7 +75,7 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op,
73 anchor->size = anchorDataSize; 75 anchor->size = anchorDataSize;
74 GNUNET_memcpy (&anchor[1], pkString, anchorDataSize); 76 GNUNET_memcpy (&anchor[1], pkString, anchorDataSize);
75 77
76 op->cb_put (op->cb_cls, anchor); 78 cb (h, anchor);
77} 79}
78 80
79 81
@@ -94,14 +96,16 @@ renew_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op,
94/** 96/**
95 * Verify the plaintext escrow of the key 97 * Verify the plaintext escrow of the key
96 * 98 *
97 * @param op the escrow operation 99 * @param h the handle for the escrow component
98 * @param ego the identity ego containing the private key 100 * @param ego the identity ego containing the private key
99 * @param escrowAnchor the escrow anchor needed to restore the key 101 * @param escrowAnchor the escrow anchor needed to restore the key
102 * @param cb the function called upon completion
100 */ 103 */
101void 104void
102verify_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op, 105verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
103 const struct GNUNET_IDENTITY_Ego *ego, 106 const struct GNUNET_IDENTITY_Ego *ego,
104 struct GNUNET_ESCROW_Anchor *escrowAnchor) 107 struct GNUNET_ESCROW_Anchor *escrowAnchor,
108 GNUNET_ESCROW_VerifyContinuation cb)
105{ 109{
106 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; 110 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
107 char *pkString; 111 char *pkString;
@@ -109,7 +113,7 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op,
109 113
110 if (NULL == ego) 114 if (NULL == ego)
111 { 115 {
112 op->cb_verify (op->cb_cls, GNUNET_ESCROW_INVALID); 116 cb (h, GNUNET_ESCROW_INVALID);
113 return; 117 return;
114 } 118 }
115 pk = GNUNET_IDENTITY_ego_get_private_key (ego); 119 pk = GNUNET_IDENTITY_ego_get_private_key (ego);
@@ -118,7 +122,7 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op,
118 (char *)&escrowAnchor[1], 122 (char *)&escrowAnchor[1],
119 strlen (pkString)) == 0 ? 123 strlen (pkString)) == 0 ?
120 GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID; 124 GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID;
121 op->cb_verify (op->cb_cls, verificationResult); 125 cb (h, verificationResult);
122} 126}
123 127
124 128
@@ -126,14 +130,14 @@ void
126ego_created (const struct GNUNET_IDENTITY_Ego *ego) 130ego_created (const struct GNUNET_IDENTITY_Ego *ego)
127{ 131{
128 ph.ego_create_cont = NULL; 132 ph.ego_create_cont = NULL;
129 ph.curr_op->cb_get (ph.curr_op->cb_cls, ego); 133 ph.curr_restore_cb (ph.escrow_handle, ego);
130 ph.curr_op = NULL; 134 ph.curr_restore_cb = NULL;
131} 135}
132 136
133 137
134/** 138/**
135 * Creation operation finished. 139 * Creation operation finished.
136 * This method only handles errors that may have occured. On success, 140 * This method only handles errors that may have occurred. On success,
137 * the callback is executed by the ESCROW_list_ego function, as the 141 * the callback is executed by the ESCROW_list_ego function, as the
138 * new ego is in our ego list only after ESCROW_list_ego has added it. 142 * new ego is in our ego list only after ESCROW_list_ego has added it.
139 * 143 *
@@ -146,7 +150,7 @@ create_finished (void *cls,
146 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 150 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
147 const char *emsg) 151 const char *emsg)
148{ 152{
149 struct GNUNET_ESCROW_Operation *op = cls; 153 GNUNET_ESCROW_EgoContinuation cb = cls;
150 154
151 if (NULL == pk) 155 if (NULL == pk)
152 { 156 {
@@ -156,35 +160,40 @@ create_finished (void *cls,
156 emsg); 160 emsg);
157 else 161 else
158 fprintf (stderr, "Failed to create ego!"); 162 fprintf (stderr, "Failed to create ego!");
159 op->cb_get (op->cb_cls, NULL); 163 cb (ph.escrow_handle, NULL);
160 return; 164 return;
161 } 165 }
162 166
163 /* no error occured, op->cb_get will be called from ESCROW_list_ego after 167 /* no error occurred, op->cb_get will be called from ESCROW_list_ego after
164 adding the new ego to our list */ 168 adding the new ego to our list */
165 ph.ego_create_cont = &ego_created; 169 ph.ego_create_cont = &ego_created;
166 ph.curr_op = op; 170 ph.curr_restore_cb = cb;
167} 171}
168 172
169 173
170/** 174/**
171 * Restore the key from plaintext escrow 175 * Restore the key from plaintext escrow
172 * 176 *
173 * @param op the escrow operation 177 * @param h the handle for the escrow component
174 * @param escrowAnchor the escrow anchor needed to restore the key 178 * @param escrowAnchor the escrow anchor needed to restore the key
175 * @param egoName the name of the ego to restore 179 * @param egoName the name of the ego to restore
180 * @param cb the function called upon completion
176 */ 181 */
177void 182void
178restore_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op, 183restore_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
179 struct GNUNET_ESCROW_Anchor *escrowAnchor, 184 struct GNUNET_ESCROW_Anchor *escrowAnchor,
180 char *egoName) 185 char *egoName,
186 GNUNET_ESCROW_EgoContinuation cb)
181{ 187{
182 struct GNUNET_CRYPTO_EcdsaPrivateKey pk; 188 struct GNUNET_CRYPTO_EcdsaPrivateKey pk;
183 struct GNUNET_IDENTITY_Operation *id_op; 189 struct GNUNET_IDENTITY_Operation *id_op;
184 190
191 // TODO: is this the right place for that?
192 ph.escrow_handle = h;
193
185 if (NULL == escrowAnchor) 194 if (NULL == escrowAnchor)
186 { 195 {
187 op->cb_get (op->cb_cls, NULL); 196 cb (h, NULL);
188 return; 197 return;
189 } 198 }
190 if (GNUNET_OK != 199 if (GNUNET_OK !=
@@ -192,7 +201,7 @@ restore_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op,
192 strlen ((char *)&escrowAnchor[1]), 201 strlen ((char *)&escrowAnchor[1]),
193 &pk)) 202 &pk))
194 { 203 {
195 op->cb_get (op->cb_cls, NULL); 204 cb (h, NULL);
196 return; 205 return;
197 } 206 }
198 207
@@ -200,9 +209,9 @@ restore_plaintext_key_escrow (struct GNUNET_ESCROW_Operation *op,
200 egoName, 209 egoName,
201 &pk, 210 &pk,
202 &create_finished, 211 &create_finished,
203 op); 212 cb);
204 213
205 op->id_op = id_op; 214 // TODO: return id_op?
206} 215}
207 216
208 217
@@ -254,6 +263,16 @@ plaintext_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h,
254 263
255 264
256/** 265/**
266 * Cancel ... TODO
267 */
268void
269cancel_plaintext_ ()
270{
271 return;
272}
273
274
275/**
257 * IdentityInitContinuation for the plaintext plugin 276 * IdentityInitContinuation for the plaintext plugin
258 */ 277 */
259void 278void