diff options
Diffstat (limited to 'src/credential/credential_api.c')
-rw-r--r-- | src/credential/credential_api.c | 354 |
1 files changed, 175 insertions, 179 deletions
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c index 84c32a724..dc1052484 100644 --- a/src/credential/credential_api.c +++ b/src/credential/credential_api.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file credential/credential_api.c | 21 | * @file credential/credential_api.c |
22 | * @brief library to access the CREDENTIAL service | 22 | * @brief library to access the CREDENTIAL service |
@@ -35,14 +35,12 @@ | |||
35 | #include "gnunet_identity_service.h" | 35 | #include "gnunet_identity_service.h" |
36 | 36 | ||
37 | 37 | ||
38 | #define LOG(kind,...) GNUNET_log_from (kind, "credential-api",__VA_ARGS__) | 38 | #define LOG(kind, ...) GNUNET_log_from(kind, "credential-api", __VA_ARGS__) |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Handle to a verify request | 41 | * Handle to a verify request |
42 | */ | 42 | */ |
43 | struct GNUNET_CREDENTIAL_Request | 43 | struct GNUNET_CREDENTIAL_Request { |
44 | { | ||
45 | |||
46 | /** | 44 | /** |
47 | * DLL | 45 | * DLL |
48 | */ | 46 | */ |
@@ -77,16 +75,13 @@ struct GNUNET_CREDENTIAL_Request | |||
77 | * request id | 75 | * request id |
78 | */ | 76 | */ |
79 | uint32_t r_id; | 77 | uint32_t r_id; |
80 | |||
81 | }; | 78 | }; |
82 | 79 | ||
83 | 80 | ||
84 | /** | 81 | /** |
85 | * Connection to the CREDENTIAL service. | 82 | * Connection to the CREDENTIAL service. |
86 | */ | 83 | */ |
87 | struct GNUNET_CREDENTIAL_Handle | 84 | struct GNUNET_CREDENTIAL_Handle { |
88 | { | ||
89 | |||
90 | /** | 85 | /** |
91 | * Configuration to use. | 86 | * Configuration to use. |
92 | */ | 87 | */ |
@@ -121,7 +116,6 @@ struct GNUNET_CREDENTIAL_Handle | |||
121 | * Request Id generator. Incremented by one for each request. | 116 | * Request Id generator. Incremented by one for each request. |
122 | */ | 117 | */ |
123 | uint32_t r_id_gen; | 118 | uint32_t r_id_gen; |
124 | |||
125 | }; | 119 | }; |
126 | 120 | ||
127 | 121 | ||
@@ -131,7 +125,7 @@ struct GNUNET_CREDENTIAL_Handle | |||
131 | * @param handle the handle to the CREDENTIAL service | 125 | * @param handle the handle to the CREDENTIAL service |
132 | */ | 126 | */ |
133 | static void | 127 | static void |
134 | reconnect (struct GNUNET_CREDENTIAL_Handle *handle); | 128 | reconnect(struct GNUNET_CREDENTIAL_Handle *handle); |
135 | 129 | ||
136 | 130 | ||
137 | /** | 131 | /** |
@@ -140,12 +134,12 @@ reconnect (struct GNUNET_CREDENTIAL_Handle *handle); | |||
140 | * @param cls the handle | 134 | * @param cls the handle |
141 | */ | 135 | */ |
142 | static void | 136 | static void |
143 | reconnect_task (void *cls) | 137 | reconnect_task(void *cls) |
144 | { | 138 | { |
145 | struct GNUNET_CREDENTIAL_Handle *handle = cls; | 139 | struct GNUNET_CREDENTIAL_Handle *handle = cls; |
146 | 140 | ||
147 | handle->reconnect_task = NULL; | 141 | handle->reconnect_task = NULL; |
148 | reconnect (handle); | 142 | reconnect(handle); |
149 | } | 143 | } |
150 | 144 | ||
151 | 145 | ||
@@ -155,16 +149,16 @@ reconnect_task (void *cls) | |||
155 | * @param handle our handle | 149 | * @param handle our handle |
156 | */ | 150 | */ |
157 | static void | 151 | static void |
158 | force_reconnect (struct GNUNET_CREDENTIAL_Handle *handle) | 152 | force_reconnect(struct GNUNET_CREDENTIAL_Handle *handle) |
159 | { | 153 | { |
160 | GNUNET_MQ_destroy (handle->mq); | 154 | GNUNET_MQ_destroy(handle->mq); |
161 | handle->mq = NULL; | 155 | handle->mq = NULL; |
162 | handle->reconnect_backoff | 156 | handle->reconnect_backoff |
163 | = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); | 157 | = GNUNET_TIME_STD_BACKOFF(handle->reconnect_backoff); |
164 | handle->reconnect_task | 158 | handle->reconnect_task |
165 | = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, | 159 | = GNUNET_SCHEDULER_add_delayed(handle->reconnect_backoff, |
166 | &reconnect_task, | 160 | &reconnect_task, |
167 | handle); | 161 | handle); |
168 | } | 162 | } |
169 | 163 | ||
170 | 164 | ||
@@ -177,12 +171,12 @@ force_reconnect (struct GNUNET_CREDENTIAL_Handle *handle) | |||
177 | * @param error error code | 171 | * @param error error code |
178 | */ | 172 | */ |
179 | static void | 173 | static void |
180 | mq_error_handler (void *cls, | 174 | mq_error_handler(void *cls, |
181 | enum GNUNET_MQ_Error error) | 175 | enum GNUNET_MQ_Error error) |
182 | { | 176 | { |
183 | struct GNUNET_CREDENTIAL_Handle *handle = cls; | 177 | struct GNUNET_CREDENTIAL_Handle *handle = cls; |
184 | 178 | ||
185 | force_reconnect (handle); | 179 | force_reconnect(handle); |
186 | } | 180 | } |
187 | 181 | ||
188 | /** | 182 | /** |
@@ -192,8 +186,8 @@ mq_error_handler (void *cls, | |||
192 | * @param vr_msg the incoming message | 186 | * @param vr_msg the incoming message |
193 | */ | 187 | */ |
194 | static int | 188 | static int |
195 | check_result (void *cls, | 189 | check_result(void *cls, |
196 | const struct DelegationChainResultMessage *vr_msg) | 190 | const struct DelegationChainResultMessage *vr_msg) |
197 | { | 191 | { |
198 | //TODO | 192 | //TODO |
199 | return GNUNET_OK; | 193 | return GNUNET_OK; |
@@ -207,22 +201,22 @@ check_result (void *cls, | |||
207 | * @param vr_msg the incoming message | 201 | * @param vr_msg the incoming message |
208 | */ | 202 | */ |
209 | static void | 203 | static void |
210 | handle_result (void *cls, | 204 | handle_result(void *cls, |
211 | const struct DelegationChainResultMessage *vr_msg) | 205 | const struct DelegationChainResultMessage *vr_msg) |
212 | { | 206 | { |
213 | struct GNUNET_CREDENTIAL_Handle *handle = cls; | 207 | struct GNUNET_CREDENTIAL_Handle *handle = cls; |
214 | uint32_t r_id = ntohl (vr_msg->id); | 208 | uint32_t r_id = ntohl(vr_msg->id); |
215 | struct GNUNET_CREDENTIAL_Request *vr; | 209 | struct GNUNET_CREDENTIAL_Request *vr; |
216 | size_t mlen = ntohs (vr_msg->header.size) - sizeof (*vr_msg); | 210 | size_t mlen = ntohs(vr_msg->header.size) - sizeof(*vr_msg); |
217 | uint32_t d_count = ntohl (vr_msg->d_count); | 211 | uint32_t d_count = ntohl(vr_msg->d_count); |
218 | uint32_t c_count = ntohl (vr_msg->c_count); | 212 | uint32_t c_count = ntohl(vr_msg->c_count); |
219 | struct GNUNET_CREDENTIAL_Delegation d_chain[d_count]; | 213 | struct GNUNET_CREDENTIAL_Delegation d_chain[d_count]; |
220 | struct GNUNET_CREDENTIAL_Credential creds[c_count]; | 214 | struct GNUNET_CREDENTIAL_Credential creds[c_count]; |
221 | GNUNET_CREDENTIAL_CredentialResultProcessor proc; | 215 | GNUNET_CREDENTIAL_CredentialResultProcessor proc; |
222 | void *proc_cls; | 216 | void *proc_cls; |
223 | 217 | ||
224 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 218 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
225 | "Received verify reply from CREDENTIAL service\n"); | 219 | "Received verify reply from CREDENTIAL service\n"); |
226 | for (vr = handle->request_head; NULL != vr; vr = vr->next) | 220 | for (vr = handle->request_head; NULL != vr; vr = vr->next) |
227 | if (vr->r_id == r_id) | 221 | if (vr->r_id == r_id) |
228 | break; | 222 | break; |
@@ -230,32 +224,34 @@ handle_result (void *cls, | |||
230 | return; | 224 | return; |
231 | proc = vr->verify_proc; | 225 | proc = vr->verify_proc; |
232 | proc_cls = vr->proc_cls; | 226 | proc_cls = vr->proc_cls; |
233 | GNUNET_CONTAINER_DLL_remove (handle->request_head, | 227 | GNUNET_CONTAINER_DLL_remove(handle->request_head, |
234 | handle->request_tail, | 228 | handle->request_tail, |
235 | vr); | 229 | vr); |
236 | GNUNET_MQ_discard (vr->env); | 230 | GNUNET_MQ_discard(vr->env); |
237 | GNUNET_free (vr); | 231 | GNUNET_free(vr); |
238 | GNUNET_assert (GNUNET_OK == | 232 | GNUNET_assert(GNUNET_OK == |
239 | GNUNET_CREDENTIAL_delegation_chain_deserialize (mlen, | 233 | GNUNET_CREDENTIAL_delegation_chain_deserialize(mlen, |
240 | (const char*) &vr_msg[1], | 234 | (const char*)&vr_msg[1], |
241 | d_count, | 235 | d_count, |
242 | d_chain, | 236 | d_chain, |
243 | c_count, | 237 | c_count, |
244 | creds)); | 238 | creds)); |
245 | if (GNUNET_NO == ntohl (vr_msg->cred_found)) | 239 | if (GNUNET_NO == ntohl(vr_msg->cred_found)) |
246 | { | 240 | { |
247 | proc (proc_cls, | 241 | proc(proc_cls, |
248 | 0, | 242 | 0, |
249 | NULL, | 243 | NULL, |
250 | 0, | 244 | 0, |
251 | NULL); // TODO | 245 | NULL); // TODO |
252 | } else { | 246 | } |
253 | proc (proc_cls, | 247 | else |
254 | d_count, | 248 | { |
255 | d_chain, | 249 | proc(proc_cls, |
256 | c_count, | 250 | d_count, |
257 | creds); | 251 | d_chain, |
258 | } | 252 | c_count, |
253 | creds); | ||
254 | } | ||
259 | } | 255 | } |
260 | 256 | ||
261 | 257 | ||
@@ -265,34 +261,34 @@ handle_result (void *cls, | |||
265 | * @param handle the handle to the CREDENTIAL service | 261 | * @param handle the handle to the CREDENTIAL service |
266 | */ | 262 | */ |
267 | static void | 263 | static void |
268 | reconnect (struct GNUNET_CREDENTIAL_Handle *handle) | 264 | reconnect(struct GNUNET_CREDENTIAL_Handle *handle) |
269 | { | 265 | { |
270 | struct GNUNET_MQ_MessageHandler handlers[] = { | 266 | struct GNUNET_MQ_MessageHandler handlers[] = { |
271 | GNUNET_MQ_hd_var_size (result, | 267 | GNUNET_MQ_hd_var_size(result, |
272 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT, | 268 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT, |
273 | struct DelegationChainResultMessage, | 269 | struct DelegationChainResultMessage, |
274 | handle), | 270 | handle), |
275 | GNUNET_MQ_hd_var_size (result, | 271 | GNUNET_MQ_hd_var_size(result, |
276 | GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT_RESULT, | 272 | GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT_RESULT, |
277 | struct DelegationChainResultMessage, | 273 | struct DelegationChainResultMessage, |
278 | handle), | 274 | handle), |
279 | GNUNET_MQ_handler_end () | 275 | GNUNET_MQ_handler_end() |
280 | }; | 276 | }; |
281 | struct GNUNET_CREDENTIAL_Request *vr; | 277 | struct GNUNET_CREDENTIAL_Request *vr; |
282 | 278 | ||
283 | GNUNET_assert (NULL == handle->mq); | 279 | GNUNET_assert(NULL == handle->mq); |
284 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 280 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
285 | "Trying to connect to CREDENTIAL\n"); | 281 | "Trying to connect to CREDENTIAL\n"); |
286 | handle->mq = GNUNET_CLIENT_connect (handle->cfg, | 282 | handle->mq = GNUNET_CLIENT_connect(handle->cfg, |
287 | "credential", | 283 | "credential", |
288 | handlers, | 284 | handlers, |
289 | &mq_error_handler, | 285 | &mq_error_handler, |
290 | handle); | 286 | handle); |
291 | if (NULL == handle->mq) | 287 | if (NULL == handle->mq) |
292 | return; | 288 | return; |
293 | for (vr = handle->request_head; NULL != vr; vr = vr->next) | 289 | for (vr = handle->request_head; NULL != vr; vr = vr->next) |
294 | GNUNET_MQ_send_copy (handle->mq, | 290 | GNUNET_MQ_send_copy(handle->mq, |
295 | vr->env); | 291 | vr->env); |
296 | } | 292 | } |
297 | 293 | ||
298 | 294 | ||
@@ -303,18 +299,18 @@ reconnect (struct GNUNET_CREDENTIAL_Handle *handle) | |||
303 | * @return handle to the CREDENTIAL service, or NULL on error | 299 | * @return handle to the CREDENTIAL service, or NULL on error |
304 | */ | 300 | */ |
305 | struct GNUNET_CREDENTIAL_Handle * | 301 | struct GNUNET_CREDENTIAL_Handle * |
306 | GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | 302 | GNUNET_CREDENTIAL_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) |
307 | { | 303 | { |
308 | struct GNUNET_CREDENTIAL_Handle *handle; | 304 | struct GNUNET_CREDENTIAL_Handle *handle; |
309 | 305 | ||
310 | handle = GNUNET_new (struct GNUNET_CREDENTIAL_Handle); | 306 | handle = GNUNET_new(struct GNUNET_CREDENTIAL_Handle); |
311 | handle->cfg = cfg; | 307 | handle->cfg = cfg; |
312 | reconnect (handle); | 308 | reconnect(handle); |
313 | if (NULL == handle->mq) | 309 | if (NULL == handle->mq) |
314 | { | 310 | { |
315 | GNUNET_free (handle); | 311 | GNUNET_free(handle); |
316 | return NULL; | 312 | return NULL; |
317 | } | 313 | } |
318 | return handle; | 314 | return handle; |
319 | } | 315 | } |
320 | 316 | ||
@@ -325,20 +321,20 @@ GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
325 | * @param handle handle of the CREDENTIAL connection to stop | 321 | * @param handle handle of the CREDENTIAL connection to stop |
326 | */ | 322 | */ |
327 | void | 323 | void |
328 | GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle) | 324 | GNUNET_CREDENTIAL_disconnect(struct GNUNET_CREDENTIAL_Handle *handle) |
329 | { | 325 | { |
330 | if (NULL != handle->mq) | 326 | if (NULL != handle->mq) |
331 | { | 327 | { |
332 | GNUNET_MQ_destroy (handle->mq); | 328 | GNUNET_MQ_destroy(handle->mq); |
333 | handle->mq = NULL; | 329 | handle->mq = NULL; |
334 | } | 330 | } |
335 | if (NULL != handle->reconnect_task) | 331 | if (NULL != handle->reconnect_task) |
336 | { | 332 | { |
337 | GNUNET_SCHEDULER_cancel (handle->reconnect_task); | 333 | GNUNET_SCHEDULER_cancel(handle->reconnect_task); |
338 | handle->reconnect_task = NULL; | 334 | handle->reconnect_task = NULL; |
339 | } | 335 | } |
340 | GNUNET_assert (NULL == handle->request_head); | 336 | GNUNET_assert(NULL == handle->request_head); |
341 | GNUNET_free (handle); | 337 | GNUNET_free(handle); |
342 | } | 338 | } |
343 | 339 | ||
344 | 340 | ||
@@ -348,21 +344,21 @@ GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle) | |||
348 | * @param lr the verify request to cancel | 344 | * @param lr the verify request to cancel |
349 | */ | 345 | */ |
350 | void | 346 | void |
351 | GNUNET_CREDENTIAL_request_cancel (struct GNUNET_CREDENTIAL_Request *lr) | 347 | GNUNET_CREDENTIAL_request_cancel(struct GNUNET_CREDENTIAL_Request *lr) |
352 | { | 348 | { |
353 | struct GNUNET_CREDENTIAL_Handle *handle = lr->credential_handle; | 349 | struct GNUNET_CREDENTIAL_Handle *handle = lr->credential_handle; |
354 | 350 | ||
355 | GNUNET_CONTAINER_DLL_remove (handle->request_head, | 351 | GNUNET_CONTAINER_DLL_remove(handle->request_head, |
356 | handle->request_tail, | 352 | handle->request_tail, |
357 | lr); | 353 | lr); |
358 | GNUNET_MQ_discard (lr->env); | 354 | GNUNET_MQ_discard(lr->env); |
359 | GNUNET_free (lr); | 355 | GNUNET_free(lr); |
360 | } | 356 | } |
361 | 357 | ||
362 | 358 | ||
363 | /** | 359 | /** |
364 | * Performs attribute collection. | 360 | * Performs attribute collection. |
365 | * Collects all credentials of subject to fulfill the | 361 | * Collects all credentials of subject to fulfill the |
366 | * attribute, if possible | 362 | * attribute, if possible |
367 | * | 363 | * |
368 | * @param handle handle to the Credential service | 364 | * @param handle handle to the Credential service |
@@ -374,12 +370,12 @@ GNUNET_CREDENTIAL_request_cancel (struct GNUNET_CREDENTIAL_Request *lr) | |||
374 | * @return handle to the queued request | 370 | * @return handle to the queued request |
375 | */ | 371 | */ |
376 | struct GNUNET_CREDENTIAL_Request* | 372 | struct GNUNET_CREDENTIAL_Request* |
377 | GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle, | 373 | GNUNET_CREDENTIAL_collect(struct GNUNET_CREDENTIAL_Handle *handle, |
378 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, | 374 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, |
379 | const char *issuer_attribute, | 375 | const char *issuer_attribute, |
380 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key, | 376 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key, |
381 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, | 377 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, |
382 | void *proc_cls) | 378 | void *proc_cls) |
383 | { | 379 | { |
384 | /* IPC to shorten credential names, return shorten_handle */ | 380 | /* IPC to shorten credential names, return shorten_handle */ |
385 | struct CollectMessage *c_msg; | 381 | struct CollectMessage *c_msg; |
@@ -387,42 +383,42 @@ GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle, | |||
387 | size_t nlen; | 383 | size_t nlen; |
388 | 384 | ||
389 | if (NULL == issuer_attribute) | 385 | if (NULL == issuer_attribute) |
390 | { | 386 | { |
391 | GNUNET_break (0); | 387 | GNUNET_break(0); |
392 | return NULL; | 388 | return NULL; |
393 | } | 389 | } |
394 | 390 | ||
395 | //DEBUG LOG | 391 | //DEBUG LOG |
396 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 392 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
397 | "Trying to collect `%s' in CREDENTIAL\n", | 393 | "Trying to collect `%s' in CREDENTIAL\n", |
398 | issuer_attribute); | 394 | issuer_attribute); |
399 | nlen = strlen (issuer_attribute) + 1; | 395 | nlen = strlen(issuer_attribute) + 1; |
400 | if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*vr)) | 396 | if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(*vr)) |
401 | { | 397 | { |
402 | GNUNET_break (0); | 398 | GNUNET_break(0); |
403 | return NULL; | 399 | return NULL; |
404 | } | 400 | } |
405 | vr = GNUNET_new (struct GNUNET_CREDENTIAL_Request); | 401 | vr = GNUNET_new(struct GNUNET_CREDENTIAL_Request); |
406 | vr->credential_handle = handle; | 402 | vr->credential_handle = handle; |
407 | vr->verify_proc = proc; | 403 | vr->verify_proc = proc; |
408 | vr->proc_cls = proc_cls; | 404 | vr->proc_cls = proc_cls; |
409 | vr->r_id = handle->r_id_gen++; | 405 | vr->r_id = handle->r_id_gen++; |
410 | vr->env = GNUNET_MQ_msg_extra (c_msg, | 406 | vr->env = GNUNET_MQ_msg_extra(c_msg, |
411 | nlen, | 407 | nlen, |
412 | GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT); | 408 | GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT); |
413 | c_msg->id = htonl (vr->r_id); | 409 | c_msg->id = htonl(vr->r_id); |
414 | c_msg->subject_key = *subject_key; | 410 | c_msg->subject_key = *subject_key; |
415 | c_msg->issuer_key = *issuer_key; | 411 | c_msg->issuer_key = *issuer_key; |
416 | c_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); | 412 | c_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); |
417 | GNUNET_memcpy (&c_msg[1], | 413 | GNUNET_memcpy(&c_msg[1], |
418 | issuer_attribute, | 414 | issuer_attribute, |
419 | strlen (issuer_attribute)); | 415 | strlen(issuer_attribute)); |
420 | GNUNET_CONTAINER_DLL_insert (handle->request_head, | 416 | GNUNET_CONTAINER_DLL_insert(handle->request_head, |
421 | handle->request_tail, | 417 | handle->request_tail, |
422 | vr); | 418 | vr); |
423 | if (NULL != handle->mq) | 419 | if (NULL != handle->mq) |
424 | GNUNET_MQ_send_copy (handle->mq, | 420 | GNUNET_MQ_send_copy(handle->mq, |
425 | vr->env); | 421 | vr->env); |
426 | return vr; | 422 | return vr; |
427 | } | 423 | } |
428 | /** | 424 | /** |
@@ -444,14 +440,14 @@ GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle, | |||
444 | * @return handle to the queued request | 440 | * @return handle to the queued request |
445 | */ | 441 | */ |
446 | struct GNUNET_CREDENTIAL_Request* | 442 | struct GNUNET_CREDENTIAL_Request* |
447 | GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, | 443 | GNUNET_CREDENTIAL_verify(struct GNUNET_CREDENTIAL_Handle *handle, |
448 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, | 444 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, |
449 | const char *issuer_attribute, | 445 | const char *issuer_attribute, |
450 | const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, | 446 | const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, |
451 | uint32_t credential_count, | 447 | uint32_t credential_count, |
452 | const struct GNUNET_CREDENTIAL_Credential *credentials, | 448 | const struct GNUNET_CREDENTIAL_Credential *credentials, |
453 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, | 449 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, |
454 | void *proc_cls) | 450 | void *proc_cls) |
455 | { | 451 | { |
456 | /* IPC to shorten credential names, return shorten_handle */ | 452 | /* IPC to shorten credential names, return shorten_handle */ |
457 | struct VerifyMessage *v_msg; | 453 | struct VerifyMessage *v_msg; |
@@ -460,51 +456,51 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, | |||
460 | size_t clen; | 456 | size_t clen; |
461 | 457 | ||
462 | if (NULL == issuer_attribute || NULL == credentials) | 458 | if (NULL == issuer_attribute || NULL == credentials) |
463 | { | 459 | { |
464 | GNUNET_break (0); | 460 | GNUNET_break(0); |
465 | return NULL; | 461 | return NULL; |
466 | } | 462 | } |
467 | 463 | ||
468 | clen = GNUNET_CREDENTIAL_credentials_get_size (credential_count, | 464 | clen = GNUNET_CREDENTIAL_credentials_get_size(credential_count, |
469 | credentials); | 465 | credentials); |
470 | 466 | ||
471 | //DEBUG LOG | 467 | //DEBUG LOG |
472 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 468 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
473 | "Trying to verify `%s' in CREDENTIAL\n", | 469 | "Trying to verify `%s' in CREDENTIAL\n", |
474 | issuer_attribute); | 470 | issuer_attribute); |
475 | nlen = strlen (issuer_attribute) + 1 + clen; | 471 | nlen = strlen(issuer_attribute) + 1 + clen; |
476 | if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*vr)) | 472 | if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(*vr)) |
477 | { | 473 | { |
478 | GNUNET_break (0); | 474 | GNUNET_break(0); |
479 | return NULL; | 475 | return NULL; |
480 | } | 476 | } |
481 | vr = GNUNET_new (struct GNUNET_CREDENTIAL_Request); | 477 | vr = GNUNET_new(struct GNUNET_CREDENTIAL_Request); |
482 | vr->credential_handle = handle; | 478 | vr->credential_handle = handle; |
483 | vr->verify_proc = proc; | 479 | vr->verify_proc = proc; |
484 | vr->proc_cls = proc_cls; | 480 | vr->proc_cls = proc_cls; |
485 | vr->r_id = handle->r_id_gen++; | 481 | vr->r_id = handle->r_id_gen++; |
486 | vr->env = GNUNET_MQ_msg_extra (v_msg, | 482 | vr->env = GNUNET_MQ_msg_extra(v_msg, |
487 | nlen, | 483 | nlen, |
488 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY); | 484 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY); |
489 | v_msg->id = htonl (vr->r_id); | 485 | v_msg->id = htonl(vr->r_id); |
490 | v_msg->subject_key = *subject_key; | 486 | v_msg->subject_key = *subject_key; |
491 | v_msg->c_count = htonl(credential_count); | 487 | v_msg->c_count = htonl(credential_count); |
492 | v_msg->issuer_key = *issuer_key; | 488 | v_msg->issuer_key = *issuer_key; |
493 | v_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); | 489 | v_msg->issuer_attribute_len = htons(strlen(issuer_attribute)); |
494 | GNUNET_memcpy (&v_msg[1], | 490 | GNUNET_memcpy(&v_msg[1], |
495 | issuer_attribute, | 491 | issuer_attribute, |
496 | strlen (issuer_attribute)); | 492 | strlen(issuer_attribute)); |
497 | GNUNET_CREDENTIAL_credentials_serialize (credential_count, | 493 | GNUNET_CREDENTIAL_credentials_serialize(credential_count, |
498 | credentials, | 494 | credentials, |
499 | clen, | 495 | clen, |
500 | ((char*)&v_msg[1]) | 496 | ((char*)&v_msg[1]) |
501 | + strlen (issuer_attribute) + 1); | 497 | + strlen(issuer_attribute) + 1); |
502 | GNUNET_CONTAINER_DLL_insert (handle->request_head, | 498 | GNUNET_CONTAINER_DLL_insert(handle->request_head, |
503 | handle->request_tail, | 499 | handle->request_tail, |
504 | vr); | 500 | vr); |
505 | if (NULL != handle->mq) | 501 | if (NULL != handle->mq) |
506 | GNUNET_MQ_send_copy (handle->mq, | 502 | GNUNET_MQ_send_copy(handle->mq, |
507 | vr->env); | 503 | vr->env); |
508 | return vr; | 504 | return vr; |
509 | } | 505 | } |
510 | 506 | ||