diff options
Diffstat (limited to 'src/credential/credential_api.c')
-rw-r--r-- | src/credential/credential_api.c | 153 |
1 files changed, 76 insertions, 77 deletions
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c index 1efe2d089..4864d54d0 100644 --- a/src/credential/credential_api.c +++ b/src/credential/credential_api.c | |||
@@ -36,20 +36,20 @@ | |||
36 | #define LOG(kind,...) GNUNET_log_from (kind, "credential-api",__VA_ARGS__) | 36 | #define LOG(kind,...) GNUNET_log_from (kind, "credential-api",__VA_ARGS__) |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * Handle to a lookup request | 39 | * Handle to a verify request |
40 | */ | 40 | */ |
41 | struct GNUNET_CREDENTIAL_LookupRequest | 41 | struct GNUNET_CREDENTIAL_VerifyRequest |
42 | { | 42 | { |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * DLL | 45 | * DLL |
46 | */ | 46 | */ |
47 | struct GNUNET_CREDENTIAL_LookupRequest *next; | 47 | struct GNUNET_CREDENTIAL_VerifyRequest *next; |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * DLL | 50 | * DLL |
51 | */ | 51 | */ |
52 | struct GNUNET_CREDENTIAL_LookupRequest *prev; | 52 | struct GNUNET_CREDENTIAL_VerifyRequest *prev; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * handle to credential service | 55 | * handle to credential service |
@@ -57,12 +57,12 @@ struct GNUNET_CREDENTIAL_LookupRequest | |||
57 | struct GNUNET_CREDENTIAL_Handle *credential_handle; | 57 | struct GNUNET_CREDENTIAL_Handle *credential_handle; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * processor to call on lookup result | 60 | * processor to call on verify result |
61 | */ | 61 | */ |
62 | GNUNET_CREDENTIAL_LookupResultProcessor lookup_proc; | 62 | GNUNET_CREDENTIAL_VerifyResultProcessor verify_proc; |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * @e lookup_proc closure | 65 | * @e verify_proc closure |
66 | */ | 66 | */ |
67 | void *proc_cls; | 67 | void *proc_cls; |
68 | 68 | ||
@@ -96,14 +96,14 @@ struct GNUNET_CREDENTIAL_Handle | |||
96 | struct GNUNET_MQ_Handle *mq; | 96 | struct GNUNET_MQ_Handle *mq; |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Head of linked list of active lookup requests. | 99 | * Head of linked list of active verify requests. |
100 | */ | 100 | */ |
101 | struct GNUNET_CREDENTIAL_LookupRequest *lookup_head; | 101 | struct GNUNET_CREDENTIAL_VerifyRequest *verify_head; |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Tail of linked list of active lookup requests. | 104 | * Tail of linked list of active verify requests. |
105 | */ | 105 | */ |
106 | struct GNUNET_CREDENTIAL_LookupRequest *lookup_tail; | 106 | struct GNUNET_CREDENTIAL_VerifyRequest *verify_tail; |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Reconnect task | 109 | * Reconnect task |
@@ -192,7 +192,7 @@ mq_error_handler (void *cls, | |||
192 | */ | 192 | */ |
193 | static int | 193 | static int |
194 | check_result (void *cls, | 194 | check_result (void *cls, |
195 | const struct LookupResultMessage *lookup_msg) | 195 | const struct VerifyResultMessage *vr_msg) |
196 | { | 196 | { |
197 | //TODO | 197 | //TODO |
198 | return GNUNET_OK; | 198 | return GNUNET_OK; |
@@ -207,30 +207,30 @@ check_result (void *cls, | |||
207 | */ | 207 | */ |
208 | static void | 208 | static void |
209 | handle_result (void *cls, | 209 | handle_result (void *cls, |
210 | const struct LookupResultMessage *lookup_msg) | 210 | const struct VerifyResultMessage *vr_msg) |
211 | { | 211 | { |
212 | struct GNUNET_CREDENTIAL_Handle *handle = cls; | 212 | struct GNUNET_CREDENTIAL_Handle *handle = cls; |
213 | uint32_t cd_count = ntohl (lookup_msg->cd_count); | 213 | uint32_t ad_count = ntohl (vr_msg->ad_count); |
214 | struct GNUNET_CREDENTIAL_RecordData cd[cd_count]; | 214 | struct GNUNET_CREDENTIAL_RecordData ad[ad_count]; |
215 | uint32_t r_id = ntohl (lookup_msg->id); | 215 | uint32_t r_id = ntohl (vr_msg->id); |
216 | struct GNUNET_CREDENTIAL_LookupRequest *lr; | 216 | struct GNUNET_CREDENTIAL_VerifyRequest *vr; |
217 | GNUNET_CREDENTIAL_LookupResultProcessor proc; | 217 | GNUNET_CREDENTIAL_VerifyResultProcessor proc; |
218 | void *proc_cls; | 218 | void *proc_cls; |
219 | 219 | ||
220 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 220 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
221 | "Received lookup reply from CREDENTIAL service (%u credentials)\n", | 221 | "Received verify reply from CREDENTIAL service (%u credentials)\n", |
222 | (unsigned int) cd_count); | 222 | (unsigned int) ad_count); |
223 | for (lr = handle->lookup_head; NULL != lr; lr = lr->next) | 223 | for (vr = handle->verify_head; NULL != vr; vr = vr->next) |
224 | if (lr->r_id == r_id) | 224 | if (vr->r_id == r_id) |
225 | break; | 225 | break; |
226 | if (NULL == lr) | 226 | if (NULL == vr) |
227 | return; | 227 | return; |
228 | proc = lr->lookup_proc; | 228 | proc = vr->verify_proc; |
229 | proc_cls = lr->proc_cls; | 229 | proc_cls = vr->proc_cls; |
230 | GNUNET_CONTAINER_DLL_remove (handle->lookup_head, | 230 | GNUNET_CONTAINER_DLL_remove (handle->verify_head, |
231 | handle->lookup_tail, | 231 | handle->verify_tail, |
232 | lr); | 232 | vr); |
233 | GNUNET_free (lr); | 233 | GNUNET_free (vr); |
234 | /** | 234 | /** |
235 | GNUNET_assert (GNUNET_OK == | 235 | GNUNET_assert (GNUNET_OK == |
236 | GNUNET_CREDENTIAL_records_deserialize (mlen, | 236 | GNUNET_CREDENTIAL_records_deserialize (mlen, |
@@ -240,8 +240,8 @@ handle_result (void *cls, | |||
240 | */ | 240 | */ |
241 | proc (proc_cls, | 241 | proc (proc_cls, |
242 | NULL, | 242 | NULL, |
243 | cd_count, | 243 | ad_count, |
244 | cd); // TODO | 244 | ad); // TODO |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
@@ -255,12 +255,12 @@ reconnect (struct GNUNET_CREDENTIAL_Handle *handle) | |||
255 | { | 255 | { |
256 | struct GNUNET_MQ_MessageHandler handlers[] = { | 256 | struct GNUNET_MQ_MessageHandler handlers[] = { |
257 | GNUNET_MQ_hd_var_size (result, | 257 | GNUNET_MQ_hd_var_size (result, |
258 | GNUNET_MESSAGE_TYPE_CREDENTIAL_LOOKUP_RESULT, | 258 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT, |
259 | struct LookupResultMessage, | 259 | struct VerifyResultMessage, |
260 | NULL), | 260 | NULL), |
261 | GNUNET_MQ_handler_end () | 261 | GNUNET_MQ_handler_end () |
262 | }; | 262 | }; |
263 | struct GNUNET_CREDENTIAL_LookupRequest *lh; | 263 | struct GNUNET_CREDENTIAL_VerifyRequest *vr; |
264 | 264 | ||
265 | GNUNET_assert (NULL == handle->mq); | 265 | GNUNET_assert (NULL == handle->mq); |
266 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 266 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -272,9 +272,9 @@ reconnect (struct GNUNET_CREDENTIAL_Handle *handle) | |||
272 | handle); | 272 | handle); |
273 | if (NULL == handle->mq) | 273 | if (NULL == handle->mq) |
274 | return; | 274 | return; |
275 | for (lh = handle->lookup_head; NULL != lh; lh = lh->next) | 275 | for (vr = handle->verify_head; NULL != vr; vr = vr->next) |
276 | GNUNET_MQ_send_copy (handle->mq, | 276 | GNUNET_MQ_send_copy (handle->mq, |
277 | lh->env); | 277 | vr->env); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
@@ -319,31 +319,31 @@ GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle) | |||
319 | GNUNET_SCHEDULER_cancel (handle->reconnect_task); | 319 | GNUNET_SCHEDULER_cancel (handle->reconnect_task); |
320 | handle->reconnect_task = NULL; | 320 | handle->reconnect_task = NULL; |
321 | } | 321 | } |
322 | GNUNET_assert (NULL == handle->lookup_head); | 322 | GNUNET_assert (NULL == handle->verify_head); |
323 | GNUNET_free (handle); | 323 | GNUNET_free (handle); |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | /** | 327 | /** |
328 | * Cancel pending lookup request | 328 | * Cancel pending verify request |
329 | * | 329 | * |
330 | * @param lr the lookup request to cancel | 330 | * @param lr the verify request to cancel |
331 | */ | 331 | */ |
332 | void | 332 | void |
333 | GNUNET_CREDENTIAL_lookup_cancel (struct GNUNET_CREDENTIAL_LookupRequest *lr) | 333 | GNUNET_CREDENTIAL_verify_cancel (struct GNUNET_CREDENTIAL_VerifyRequest *vr) |
334 | { | 334 | { |
335 | struct GNUNET_CREDENTIAL_Handle *handle = lr->credential_handle; | 335 | struct GNUNET_CREDENTIAL_Handle *handle = vr->credential_handle; |
336 | 336 | ||
337 | GNUNET_CONTAINER_DLL_remove (handle->lookup_head, | 337 | GNUNET_CONTAINER_DLL_remove (handle->verify_head, |
338 | handle->lookup_tail, | 338 | handle->verify_tail, |
339 | lr); | 339 | vr); |
340 | GNUNET_MQ_discard (lr->env); | 340 | GNUNET_MQ_discard (vr->env); |
341 | GNUNET_free (lr); | 341 | GNUNET_free (vr); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | /** | 345 | /** |
346 | * Perform an asynchronous lookup operation for a credential. | 346 | * Perform an asynchronous verify operation for a credential. |
347 | * | 347 | * |
348 | * @param handle handle to the Credential service | 348 | * @param handle handle to the Credential service |
349 | * @param credential the credential to look up | 349 | * @param credential the credential to look up |
@@ -352,58 +352,57 @@ GNUNET_CREDENTIAL_lookup_cancel (struct GNUNET_CREDENTIAL_LookupRequest *lr) | |||
352 | * @param proc_cls closure for processor | 352 | * @param proc_cls closure for processor |
353 | * @return handle to the queued request | 353 | * @return handle to the queued request |
354 | */ | 354 | */ |
355 | struct GNUNET_CREDENTIAL_LookupRequest* | 355 | struct GNUNET_CREDENTIAL_VerifyRequest* |
356 | GNUNET_CREDENTIAL_lookup (struct GNUNET_CREDENTIAL_Handle *handle, | 356 | GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, |
357 | const char *credential, | 357 | const char *issuer_attribute, |
358 | const struct GNUNET_IDENTITY_Ego *subject, | 358 | const char *subject_attribute, |
359 | const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, | 359 | const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, |
360 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, | 360 | const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, |
361 | uint32_t credential_flags, | 361 | uint32_t credential_flags, |
362 | uint32_t max_delegation_depth, | 362 | GNUNET_CREDENTIAL_VerifyResultProcessor proc, |
363 | GNUNET_CREDENTIAL_LookupResultProcessor proc, | ||
364 | void *proc_cls) | 363 | void *proc_cls) |
365 | { | 364 | { |
366 | /* IPC to shorten credential names, return shorten_handle */ | 365 | /* IPC to shorten credential names, return shorten_handle */ |
367 | struct LookupMessage *lookup_msg; | 366 | struct VerifyMessage *v_msg; |
368 | struct GNUNET_CREDENTIAL_LookupRequest *lr; | 367 | struct GNUNET_CREDENTIAL_VerifyRequest *vr; |
369 | size_t nlen; | 368 | size_t nlen; |
370 | 369 | ||
371 | if (NULL == credential) | 370 | if (NULL == issuer_attribute) |
372 | { | 371 | { |
373 | GNUNET_break (0); | 372 | GNUNET_break (0); |
374 | return NULL; | 373 | return NULL; |
375 | } | 374 | } |
376 | //DEBUG LOG | 375 | //DEBUG LOG |
377 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 376 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
378 | "Trying to lookup `%s' in CREDENTIAL\n", | 377 | "Trying to verify `%s' in CREDENTIAL\n", |
379 | credential); | 378 | issuer_attribute); |
380 | nlen = strlen (credential) + 1; | 379 | nlen = strlen (issuer_attribute) + 1; |
381 | if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*lr)) | 380 | if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*vr)) |
382 | { | 381 | { |
383 | GNUNET_break (0); | 382 | GNUNET_break (0); |
384 | return NULL; | 383 | return NULL; |
385 | } | 384 | } |
386 | lr = GNUNET_new (struct GNUNET_CREDENTIAL_LookupRequest); | 385 | vr = GNUNET_new (struct GNUNET_CREDENTIAL_VerifyRequest); |
387 | lr->credential_handle = handle; | 386 | vr->credential_handle = handle; |
388 | lr->lookup_proc = proc; | 387 | vr->verify_proc = proc; |
389 | lr->proc_cls = proc_cls; | 388 | vr->proc_cls = proc_cls; |
390 | lr->r_id = handle->r_id_gen++; | 389 | vr->r_id = handle->r_id_gen++; |
391 | lr->env = GNUNET_MQ_msg_extra (lookup_msg, | 390 | vr->env = GNUNET_MQ_msg_extra (v_msg, |
392 | nlen, | 391 | nlen, |
393 | GNUNET_MESSAGE_TYPE_CREDENTIAL_LOOKUP); | 392 | GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY); |
394 | lookup_msg->id = htonl (lr->r_id); | 393 | v_msg->id = htonl (vr->r_id); |
395 | lookup_msg->subject_key = *subject_key; | 394 | v_msg->subject_key = *subject_key; |
396 | lookup_msg->issuer_key = *issuer_key; | 395 | v_msg->issuer_key = *issuer_key; |
397 | GNUNET_memcpy (&lookup_msg[1], | 396 | GNUNET_memcpy (&v_msg[1], |
398 | credential, | 397 | subject_attribute, |
399 | nlen); | 398 | nlen); |
400 | GNUNET_CONTAINER_DLL_insert (handle->lookup_head, | 399 | GNUNET_CONTAINER_DLL_insert (handle->verify_head, |
401 | handle->lookup_tail, | 400 | handle->verify_tail, |
402 | lr); | 401 | vr); |
403 | if (NULL != handle->mq) | 402 | if (NULL != handle->mq) |
404 | GNUNET_MQ_send_copy (handle->mq, | 403 | GNUNET_MQ_send_copy (handle->mq, |
405 | lr->env); | 404 | vr->env); |
406 | return lr; | 405 | return vr; |
407 | } | 406 | } |
408 | 407 | ||
409 | 408 | ||