GNUnet 0.22.2
gnunet-service-abd.c File Reference

GNUnet Credential Service (main service) More...

Include dependency graph for gnunet-service-abd.c:

Go to the source code of this file.

Data Structures

struct  DelegationChainEntry
 
struct  DelegateRecordEntry
 DLL for record. More...
 
struct  DelegationQueueEntry
 DLL used for delegations Used for OR delegations. More...
 
struct  DelegationSetQueueEntry
 DLL for delegation sets Used for AND delegation set. More...
 
struct  VerifyRequestHandle
 Handle to a lookup operation from api. More...
 

Macros

#define GNUNET_ABD_MAX_LENGTH   255
 

Functions

static void print_deleset (struct DelegationSetQueueEntry *dsentry, const char *text)
 
static void cleanup_dsq_entry (struct DelegationSetQueueEntry *ds_entry)
 
static void cleanup_handle (struct VerifyRequestHandle *vrh)
 
static void shutdown_task (void *cls)
 
static void send_intermediate_response (struct VerifyRequestHandle *vrh, struct DelegationChainEntry *ch_entry, bool is_bw)
 
static void send_lookup_response (struct VerifyRequestHandle *vrh)
 
static char * partial_match (char *tmp_trail, char *tmp_subattr, char *parent_trail, char *issuer_attribute)
 
static int handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry, struct DelegationSetQueueEntry *match_entry, struct VerifyRequestHandle *vrh)
 
static void forward_resolution (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 
static void backward_resolution (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 
static int delegation_chain_bw_resolution_start (void *cls)
 Result from GNS lookup. More...
 
static int delegation_chain_fw_resolution_start (void *cls)
 
static int check_verify (void *cls, const struct VerifyMessage *v_msg)
 
static void handle_verify (void *cls, const struct VerifyMessage *v_msg)
 
static void handle_delegate_collection_error_cb (void *cls)
 
static void delegate_collection_finished (void *cls)
 
static void handle_delegate_collection_cb (void *cls, const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 
static void handle_collect (void *cls, const struct CollectMessage *c_msg)
 
static int check_collect (void *cls, const struct CollectMessage *c_msg)
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *handle)
 Process Credential requests. More...
 
 GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "abd", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(verify, GNUNET_MESSAGE_TYPE_ABD_VERIFY, struct VerifyMessage, NULL), GNUNET_MQ_hd_var_size(collect, GNUNET_MESSAGE_TYPE_ABD_COLLECT, struct CollectMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct VerifyRequestHandlevrh_head = NULL
 Head of the DLL. More...
 
static struct VerifyRequestHandlevrh_tail = NULL
 Tail of the DLL. More...
 
static struct GNUNET_STATISTICS_Handlestatistics
 Handle to the statistics service. More...
 
static struct GNUNET_GNS_Handlegns
 Handle to GNS service. More...
 
static struct GNUNET_NAMESTORE_Handlenamestore
 Handle to namestore service. More...
 

Detailed Description

GNUnet Credential Service (main service)

Author
Martin Schanzenbach

Definition in file gnunet-service-abd.c.

Macro Definition Documentation

◆ GNUNET_ABD_MAX_LENGTH

#define GNUNET_ABD_MAX_LENGTH   255

Definition at line 40 of file gnunet-service-abd.c.

Function Documentation

◆ print_deleset()

static void print_deleset ( struct DelegationSetQueueEntry dsentry,
const char *  text 
)
static

Definition at line 348 of file gnunet-service-abd.c.

349{
351 "%s %s.%s <- %s.%s\n",
352 text,
359}
#define GNUNET_log(kind,...)
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: crypto_pkey.c:379
@ GNUNET_ERROR_TYPE_DEBUG
char * subject_attribute
The delegated attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer.
struct GNUNET_CRYPTO_PublicKey subject_key
The subject.
char * issuer_attribute
The issued attribute.
struct DelegationChainEntry * delegation_chain_entry
The delegation chain entry.

References DelegationSetQueueEntry::delegation_chain_entry, GNUNET_CRYPTO_public_key_to_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, DelegationChainEntry::issuer_attribute, DelegationChainEntry::issuer_key, DelegationChainEntry::subject_attribute, and DelegationChainEntry::subject_key.

Referenced by backward_resolution(), and forward_resolution().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_dsq_entry()

static void cleanup_dsq_entry ( struct DelegationSetQueueEntry ds_entry)
static

Definition at line 363 of file gnunet-service-abd.c.

364{
365 GNUNET_free (ds_entry->issuer_key);
366 GNUNET_free (ds_entry->issuer_attribute);
367 GNUNET_free (ds_entry->attr_trailer);
368 // those fields are only set/used in bw search
369 if (ds_entry->from_bw)
370 {
371 GNUNET_free (ds_entry->lookup_attribute);
373 }
374 if (NULL != ds_entry->lookup_request)
375 {
377 ds_entry->lookup_request = NULL;
378 }
379 if (NULL != ds_entry->delegation_chain_entry)
380 {
385 }
386 // Free DQ entries
387 for (struct DelegationQueueEntry *dq_entry = ds_entry->queue_entries_head;
388 NULL != ds_entry->queue_entries_head;
389 dq_entry = ds_entry->queue_entries_head)
390 {
392 ds_entry->queue_entries_tail,
393 dq_entry);
394 GNUNET_free (dq_entry);
395 }
396 GNUNET_free (ds_entry);
397}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
Definition: gns_api.c:313
#define GNUNET_free(ptr)
Wrapper around free.
DLL used for delegations Used for OR delegations.
char * lookup_attribute
The current attribute to look up.
char * attr_trailer
Trailing attribute context.
char * issuer_attribute
Issuer attribute delegated to.
char * unresolved_attribute_delegation
Still to resolve delegation as string.
struct DelegationQueueEntry * queue_entries_head
Queue entries of this set.
struct GNUNET_CRYPTO_PublicKey * issuer_key
Issuer key.
struct DelegationQueueEntry * queue_entries_tail
Queue entries of this set.
bool from_bw
True if added by backward resolution.
struct GNUNET_GNS_LookupRequest * lookup_request
GNS handle.

References DelegationSetQueueEntry::attr_trailer, DelegationSetQueueEntry::delegation_chain_entry, DelegationSetQueueEntry::from_bw, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_GNS_lookup_cancel(), DelegationChainEntry::issuer_attribute, DelegationSetQueueEntry::issuer_attribute, DelegationSetQueueEntry::issuer_key, DelegationSetQueueEntry::lookup_attribute, DelegationSetQueueEntry::lookup_request, DelegationSetQueueEntry::queue_entries_head, DelegationSetQueueEntry::queue_entries_tail, DelegationChainEntry::subject_attribute, and DelegationSetQueueEntry::unresolved_attribute_delegation.

Referenced by cleanup_handle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_handle()

static void cleanup_handle ( struct VerifyRequestHandle vrh)
static

Definition at line 401 of file gnunet-service-abd.c.

402{
403 struct DelegateRecordEntry *del_entry;
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n");
405
406 if (NULL != vrh->dsq_head)
407 {
408 for (struct DelegationSetQueueEntry *ds_entry = vrh->dsq_head; NULL !=
409 vrh->dsq_head;
410 ds_entry = vrh->dsq_head)
411 {
412 GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry);
413 cleanup_dsq_entry (ds_entry);
414 }
415 }
416 if (NULL != vrh->del_chain_head)
417 {
418 for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
419 del_entry = vrh->del_chain_head)
420 {
422 vrh->del_chain_tail,
423 del_entry);
424 GNUNET_free (del_entry->delegate);
425 GNUNET_free (del_entry);
426 }
427 }
429 GNUNET_free (vrh);
430}
static void cleanup_dsq_entry(struct DelegationSetQueueEntry *ds_entry)
struct GNUNET_ABD_Delegate * delegate
Payload.
DLL for delegation sets Used for AND delegation set.
struct DelegationSetQueueEntry * dsq_head
List for bidirectional matching.
struct DelegationSetQueueEntry * dsq_tail
List for bidirectional matching.
struct DelegateRecordEntry * del_chain_head
Delegate DLL.
struct DelegateRecordEntry * del_chain_tail
Delegate DLL.
char * issuer_attribute
Issuer attribute.

References cleanup_dsq_entry(), VerifyRequestHandle::del_chain_head, VerifyRequestHandle::del_chain_tail, DelegateRecordEntry::delegate, VerifyRequestHandle::dsq_head, VerifyRequestHandle::dsq_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and VerifyRequestHandle::issuer_attribute.

Referenced by send_lookup_response(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Definition at line 434 of file gnunet-service-abd.c.

435{
436 struct VerifyRequestHandle *vrh;
437
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down!\n");
439
440 while (NULL != (vrh = vrh_head))
441 {
442 // ABD_resolver_lookup_cancel (clh->lookup);
444 cleanup_handle (vrh);
445 }
446
447 if (NULL != gns)
448 {
450 gns = NULL;
451 }
452 if (NULL != namestore)
453 {
455 namestore = NULL;
456 }
457 if (NULL != statistics)
458 {
460 statistics = NULL;
461 }
462}
static struct GNUNET_GNS_Handle * gns
Handle to GNS service.
static struct VerifyRequestHandle * vrh_tail
Tail of the DLL.
static void cleanup_handle(struct VerifyRequestHandle *vrh)
static struct VerifyRequestHandle * vrh_head
Head of the DLL.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_NAMESTORE_Handle * namestore
Handle to namestore service.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:289
@ GNUNET_NO
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
Handle to a lookup operation from api.

References cleanup_handle(), gns, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNS_disconnect(), GNUNET_log, GNUNET_NAMESTORE_disconnect(), GNUNET_NO, GNUNET_STATISTICS_destroy(), namestore, statistics, vrh_head, and vrh_tail.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_intermediate_response()

static void send_intermediate_response ( struct VerifyRequestHandle vrh,
struct DelegationChainEntry ch_entry,
bool  is_bw 
)
static

Definition at line 466 of file gnunet-service-abd.c.

468{
470 struct GNUNET_MQ_Envelope *env;
471 struct GNUNET_ABD_Delegation *dd;
472 size_t size;
473
474 // Don't report immediate results during collect
475 if (vrh->is_collect)
476 return;
477
478 dd = GNUNET_new (struct GNUNET_ABD_Delegation);
479 dd->issuer_key = ch_entry->issuer_key;
480 dd->subject_key = ch_entry->subject_key;
481 dd->issuer_attribute = ch_entry->issuer_attribute;
482 dd->issuer_attribute_len = strlen (ch_entry->issuer_attribute) + 1;
483 dd->subject_attribute_len = 0;
484 dd->subject_attribute = NULL;
485 if (NULL != ch_entry->subject_attribute)
486 {
487 dd->subject_attribute = ch_entry->subject_attribute;
488 dd->subject_attribute_len = strlen (ch_entry->subject_attribute) + 1;
489 }
490
491
493 dd,
494 0,
495 NULL);
496
497 env = GNUNET_MQ_msg_extra (rmsg,
498 size,
500 // Assign id so that client can find associated request
501 rmsg->id = vrh->request_id;
502 rmsg->is_bw = htons (is_bw);
503 rmsg->size = htonl (size);
504
507 dd,
508 0,
509 NULL,
510 size,
511 (char *) &rmsg[1]));
513
514 GNUNET_free (dd);
515}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
ssize_t GNUNET_ABD_delegation_chain_serialize(unsigned int d_count, const struct GNUNET_ABD_Delegation *dd, unsigned int c_count, const struct GNUNET_ABD_Delegate *cd, size_t dest_size, char *dest)
Serizalize the given delegation chain entries and abd.
size_t GNUNET_ABD_delegation_chain_get_size(unsigned int d_count, const struct GNUNET_ABD_Delegation *dd, unsigned int c_count, const struct GNUNET_ABD_Delegate *cd)
Calculate how many bytes we will need to serialize the given delegation chain and abd.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:61
#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2500
static unsigned int size
Size of the "table".
Definition: peer.c:68
Message from ABD service to client: new results.
Definition: abd.h:152
uint32_t id
Unique identifier for this request (for key collisions).
Definition: abd.h:161
uint32_t issuer_attribute_len
Length of the attribute.
uint32_t subject_attribute_len
Length of the attribute.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this attribute was delegated to.
const char * issuer_attribute
The attribute.
const char * subject_attribute
The attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer of the delegation.
struct GNUNET_SERVICE_Client * client
Handle to the requesting client.
uint32_t request_id
request id
bool is_collect
True if created by a collect request.

References VerifyRequestHandle::client, env, GNUNET_ABD_delegation_chain_get_size(), GNUNET_ABD_delegation_chain_serialize(), GNUNET_assert, GNUNET_free, GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_SERVICE_client_get_mq(), DelegationChainIntermediateMessage::id, DelegationChainIntermediateMessage::is_bw, VerifyRequestHandle::is_collect, DelegationChainEntry::issuer_attribute, GNUNET_ABD_Delegation::issuer_attribute, GNUNET_ABD_Delegation::issuer_attribute_len, DelegationChainEntry::issuer_key, GNUNET_ABD_Delegation::issuer_key, VerifyRequestHandle::request_id, DelegationChainIntermediateMessage::size, size, DelegationChainEntry::subject_attribute, GNUNET_ABD_Delegation::subject_attribute, GNUNET_ABD_Delegation::subject_attribute_len, DelegationChainEntry::subject_key, and GNUNET_ABD_Delegation::subject_key.

Referenced by backward_resolution(), and forward_resolution().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_lookup_response()

static void send_lookup_response ( struct VerifyRequestHandle vrh)
static

Definition at line 519 of file gnunet-service-abd.c.

520{
521 struct GNUNET_MQ_Envelope *env;
522 struct DelegationChainResultMessage *rmsg;
523 struct DelegationChainEntry *dce;
524 struct GNUNET_ABD_Delegation dd[vrh->delegation_chain_size];
525 struct GNUNET_ABD_Delegate dele[vrh->del_chain_size];
526 struct DelegateRecordEntry *del;
527 struct DelegateRecordEntry *tmp;
528 size_t size;
529
530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending response\n");
531 dce = vrh->delegation_chain_head;
532 for (uint32_t i = 0; i < vrh->delegation_chain_size; i++)
533 {
534 dd[i].issuer_key = dce->issuer_key;
535 dd[i].subject_key = dce->subject_key;
536 dd[i].issuer_attribute = dce->issuer_attribute;
537 dd[i].issuer_attribute_len = strlen (dce->issuer_attribute) + 1;
538 dd[i].subject_attribute_len = 0;
539 dd[i].subject_attribute = NULL;
540 if (NULL != dce->subject_attribute)
541 {
542 dd[i].subject_attribute = dce->subject_attribute;
543 dd[i].subject_attribute_len = strlen (dce->subject_attribute) + 1;
544 }
545 dce = dce->next;
546 }
547
548 // Remove all not needed credentials
549 for (del = vrh->del_chain_head; NULL != del;)
550 {
551 if (del->refcount > 0)
552 {
553 del = del->next;
554 continue;
555 }
556 tmp = del;
557 del = del->next;
559 GNUNET_free (tmp->delegate);
560 GNUNET_free (tmp);
561 vrh->del_chain_size--;
562 }
563
564 // Get serialized record data
565 // Append at the end of rmsg
566 del = vrh->del_chain_head;
567 for (uint32_t i = 0; i < vrh->del_chain_size; i++)
568 {
569 dele[i].issuer_key = del->delegate->issuer_key;
570 dele[i].subject_key = del->delegate->subject_key;
571 dele[i].issuer_attribute_len = strlen (del->delegate->issuer_attribute) + 1;
572 dele[i].issuer_attribute = del->delegate->issuer_attribute;
573 dele[i].subject_attribute_len = del->delegate->subject_attribute_len;
574 dele[i].subject_attribute = del->delegate->subject_attribute;
575 dele[i].expiration = del->delegate->expiration;
576 dele[i].signature = del->delegate->signature;
577 del = del->next;
578 }
579 size =
581 dd,
582 vrh->del_chain_size,
583 dele);
584 env = GNUNET_MQ_msg_extra (rmsg,
585 size,
587 // Assign id so that client can find associated request
588 rmsg->id = vrh->request_id;
589 rmsg->d_count = htonl (vrh->delegation_chain_size);
590 rmsg->c_count = htonl (vrh->del_chain_size);
591
592 if (0 < vrh->del_chain_size)
593 rmsg->del_found = htonl (GNUNET_YES);
594 else
595 rmsg->del_found = htonl (GNUNET_NO);
596
598 -1 !=
600 dd,
601 vrh->del_chain_size,
602 dele,
603 size,
604 (char *) &rmsg[1]));
605
608 cleanup_handle (vrh);
610 "Completed verifications",
611 1,
612 GNUNET_NO);
613}
static int del
Desired action is to remove a record.
@ GNUNET_YES
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct DelegationChainEntry * next
DLL.
Message from ABD service to client: new results.
Definition: abd.h:119
uint32_t del_found
Indicates if credential has been found at all.
Definition: abd.h:133
uint32_t d_count
The number of delegations in the response.
Definition: abd.h:138
uint32_t id
Unique identifier for this request (for key collisions).
Definition: abd.h:128
uint32_t c_count
The number of credentials in the response.
Definition: abd.h:143
uint32_t del_chain_size
Delegate DLL size.
uint32_t delegation_chain_size
Size of delegation tree.
struct DelegationChainEntry * delegation_chain_head
Children of this attribute.

References DelegationChainResultMessage::c_count, cleanup_handle(), VerifyRequestHandle::client, DelegationChainResultMessage::d_count, del, VerifyRequestHandle::del_chain_head, VerifyRequestHandle::del_chain_size, VerifyRequestHandle::del_chain_tail, DelegationChainResultMessage::del_found, DelegateRecordEntry::delegate, VerifyRequestHandle::delegation_chain_head, VerifyRequestHandle::delegation_chain_size, env, GNUNET_ABD_Delegate::expiration, GNUNET_ABD_delegation_chain_get_size(), GNUNET_ABD_delegation_chain_serialize(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_get_mq(), GNUNET_STATISTICS_update(), GNUNET_YES, DelegationChainResultMessage::id, DelegationChainEntry::issuer_attribute, GNUNET_ABD_Delegation::issuer_attribute, GNUNET_ABD_Delegate::issuer_attribute, GNUNET_ABD_Delegation::issuer_attribute_len, GNUNET_ABD_Delegate::issuer_attribute_len, DelegationChainEntry::issuer_key, GNUNET_ABD_Delegation::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegationChainEntry::next, VerifyRequestHandle::request_id, GNUNET_ABD_Delegate::signature, size, statistics, DelegationChainEntry::subject_attribute, GNUNET_ABD_Delegation::subject_attribute, GNUNET_ABD_Delegate::subject_attribute, GNUNET_ABD_Delegation::subject_attribute_len, GNUNET_ABD_Delegate::subject_attribute_len, DelegationChainEntry::subject_key, GNUNET_ABD_Delegation::subject_key, GNUNET_ABD_Delegate::subject_key, vrh_head, and vrh_tail.

Referenced by backward_resolution(), delegation_chain_bw_resolution_start(), delegation_chain_fw_resolution_start(), forward_resolution(), handle_collect(), handle_delegate_collection_error_cb(), and handle_verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ partial_match()

static char * partial_match ( char *  tmp_trail,
char *  tmp_subattr,
char *  parent_trail,
char *  issuer_attribute 
)
static

Definition at line 617 of file gnunet-service-abd.c.

621{
622 char *saveptr1, *saveptr2;
623 char *trail_token;
624 char *sub_token;
625 char *attr_trailer;
626
627 // tok both, parent->attr_trailer and del->sub_attr to see how far they match,
628 // take rest of parent trailer (only when del->sub_attr token is null), and
629 // create new/actual trailer with del->iss_attr
630 trail_token = strtok_r (tmp_trail, ".", &saveptr1);
631 sub_token = strtok_r (tmp_subattr, ".", &saveptr2);
632 while (NULL != trail_token && NULL != sub_token)
633 {
634 if (0 == strcmp (trail_token, sub_token))
635 {
636 // good, matches, remove
637 }
638 else
639 {
640 // not relevant for solving the chain, end for iteration here
641 return NULL;
642 }
643
644 trail_token = strtok_r (NULL, ".", &saveptr1);
645 sub_token = strtok_r (NULL, ".", &saveptr2);
646 }
647 // skip this entry and go to next for if:
648 // 1. at some point the attr of the trailer and the subject dont match
649 // 2. the trailer is NULL, but the subject has more attributes
650 // Reason: This will lead to "startzone.attribute" but we're looking for a solution
651 // for "<- startzone"
652 if (NULL == trail_token)
653 {
654 return NULL;
655 }
656
657 // do not have to check sub_token == NULL, if both would be NULL
658 // at the same time, the complete match part above should have triggered already
659
660 // otherwise, above while only ends when sub_token == NULL
661 GNUNET_asprintf (&attr_trailer, "%s", trail_token);
662 trail_token = strtok_r (NULL, ".", &saveptr1);
663 while (NULL != trail_token)
664 {
665 GNUNET_asprintf (&attr_trailer, "%s.%s", parent_trail, trail_token);
666 trail_token = strtok_r (NULL, ".", &saveptr1);
667 }
668 GNUNET_asprintf (&attr_trailer, "%s.%s", issuer_attribute, attr_trailer);
669 return attr_trailer;
670}
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.

References GNUNET_asprintf().

Referenced by forward_resolution().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_bidirectional_match()

static int handle_bidirectional_match ( struct DelegationSetQueueEntry actual_entry,
struct DelegationSetQueueEntry match_entry,
struct VerifyRequestHandle vrh 
)
static

Definition at line 674 of file gnunet-service-abd.c.

677{
678 struct DelegationSetQueueEntry *old_fw_parent;
679 struct DelegationSetQueueEntry *fw_entry = actual_entry;
680 struct DelegationSetQueueEntry *last_entry = match_entry;
681 // parent fixing, combine backward and forward chain parts
682 while (NULL != fw_entry->parent_queue_entry)
683 {
684 old_fw_parent = fw_entry->parent_queue_entry->parent_set;
685 // set parent
686 fw_entry->parent_queue_entry->parent_set = last_entry;
687
688 last_entry = fw_entry;
689 fw_entry = old_fw_parent;
690 }
691 // set last entry of chain as actual_entry
692 // actual_entry = last_entry;
693 // set refcount, loop all delegations
694 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head;
695 del_entry != NULL;
696 del_entry = del_entry->next)
697 {
698 if (0 != memcmp (&last_entry->delegation_chain_entry->subject_key,
699 &del_entry->delegate->issuer_key,
700 sizeof (struct GNUNET_CRYPTO_PublicKey)))
701 continue;
702 if (0 != strcmp (last_entry->delegation_chain_entry->subject_attribute,
703 del_entry->delegate->issuer_attribute))
704 continue;
705
706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found delegate.\n");
707 // increase refcount of the start delegation
708 del_entry->refcount++;
709 }
710 // backtrack
711 for (struct DelegationSetQueueEntry *tmp_set = last_entry;
712 NULL != tmp_set->parent_queue_entry;
713 tmp_set = tmp_set->parent_queue_entry->parent_set)
714 {
715 tmp_set->parent_queue_entry->required_solutions--;
716
717 // add new found entry to vrh
721 tmp_set->delegation_chain_entry);
722
723 // if one node on the path still needs solutions, this current
724 // patch cannot fulfill the conditions and therefore stops here
725 // however, it is in the vrh and can be used by the other paths
726 // related to this path/collection/verification
727 if (0 < tmp_set->parent_queue_entry->required_solutions)
728 {
730 "Chain requires more solutions, waiting...\n");
731 return GNUNET_NO;
732 }
733 }
734 return GNUNET_YES;
735}
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct DelegateRecordEntry * next
DLL.
struct DelegationSetQueueEntry * parent_set
Parent set.
struct DelegationQueueEntry * parent_queue_entry
Parent QueueEntry.
An identity key as per LSD0001.
struct DelegationChainEntry * delegation_chain_tail
Children of this attribute.

References VerifyRequestHandle::del_chain_head, DelegationSetQueueEntry::delegation_chain_entry, VerifyRequestHandle::delegation_chain_head, VerifyRequestHandle::delegation_chain_size, VerifyRequestHandle::delegation_chain_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, DelegateRecordEntry::next, DelegationSetQueueEntry::parent_queue_entry, DelegationQueueEntry::parent_set, DelegationChainEntry::subject_attribute, and DelegationChainEntry::subject_key.

Referenced by backward_resolution(), and forward_resolution().

Here is the caller graph for this function:

◆ forward_resolution()

static void forward_resolution ( void *  cls,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Definition at line 739 of file gnunet-service-abd.c.

742{
743 struct VerifyRequestHandle *vrh;
744 struct DelegationSetQueueEntry *current_set;
745 struct DelegationSetQueueEntry *ds_entry;
746 struct DelegationQueueEntry *dq_entry;
747 struct GNUNET_ABD_Delegate *del;
748
749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d entries.\n", rd_count);
750
751 current_set = cls;
752 // set handle to NULL (as el = NULL)
753 current_set->lookup_request = NULL;
754 vrh = current_set->handle;
755 vrh->pending_lookups--;
756
757 // Loop record entries
758 for (uint32_t i = 0; i < rd_count; i++)
759 {
760 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
761 continue;
762
763 // Start deserialize into Delegate
765
766 if (NULL == del)
767 continue;
768
769 // Start: Create DQ Entry
770 dq_entry = GNUNET_new (struct DelegationQueueEntry);
771 // AND delegations are not possible, only 1 solution
772 dq_entry->required_solutions = 1;
773 dq_entry->parent_set = current_set;
774
775 // Insert it into the current set
777 current_set->queue_entries_tail,
778 dq_entry);
779
780 // Start: Create DS Entry
781 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
782 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
783 ds_entry->from_bw = false;
784
785 // (1) A.a <- A.b.c
786 // (2) A.b <- D.d
787 // (3) D.d <- E
788 // (4) E.c <- F.c
789 // (5) F.c <- G
790 // Possibilities:
791 // 1. complete match: trailer = 0, validate
792 // 2. partial match: replace
793 // 3. new solution: replace, add trailer
794
795 // At resolution chain start trailer of parent is NULL
796 if (NULL == current_set->attr_trailer)
797 {
798 // for (5) F.c <- G, remember .c when going upwards
799 ds_entry->attr_trailer = GNUNET_strdup (del->issuer_attribute);
800 }
801 else
802 {
803 if (0 == del->subject_attribute_len)
804 {
805 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: New solution\n");
806 // new solution
807 // create new trailer del->issuer_attribute, ds_entry->attr_trailer
808 GNUNET_asprintf (&ds_entry->attr_trailer,
809 "%s.%s",
810 del->issuer_attribute,
811 current_set->attr_trailer);
812 }
813 else if (0 == strcmp (del->subject_attribute, current_set->attr_trailer))
814 {
815 // complete match
816 // new trailer == issuer attribute (e.g. (5) to (4))
817 ds_entry->attr_trailer = GNUNET_strdup (del->issuer_attribute);
818 }
819 else
820 {
821 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: Partial match\n");
822 // partial match
823 {
824 char *trail = partial_match (GNUNET_strdup (current_set->attr_trailer)
825 ,
826 GNUNET_strdup (del->subject_attribute),
827 current_set->attr_trailer,
828 GNUNET_strdup (del->issuer_attribute));
829
830 // if null: skip this record entry (reasons: mismatch or overmatch, both not relevant)
831 if (NULL == trail)
832 {
834 "Entry not relevant, discarding: %s.%s <- %s.%s\n",
836 &del->issuer_key),
837 del->issuer_attribute,
839 &del->subject_key),
840 del->subject_attribute);
842 continue;
843 }
844 else
845 {
846 ds_entry->attr_trailer = trail;
847 }
848 }
849 }
850 }
851
852
853 // Start: Credential Chain Entry
854 // issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject)
855 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_PublicKey);
856 GNUNET_memcpy (ds_entry->issuer_key,
857 &del->subject_key,
858 sizeof (struct GNUNET_CRYPTO_PublicKey));
859
861 ds_entry->delegation_chain_entry->subject_key = del->subject_key;
862 if (0 < del->subject_attribute_len)
864 GNUNET_strdup (del->subject_attribute);
865 ds_entry->delegation_chain_entry->issuer_key = del->issuer_key;
867 GNUNET_strdup (del->issuer_attribute);
868
869 // Found new entry, repoting intermediate result
871
872 // current delegation as parent
873 ds_entry->parent_queue_entry = dq_entry;
874
875 // Check for solution
876 // if: issuer key we looking for
877 if (0 == memcmp (&del->issuer_key,
878 &vrh->issuer_key,
879 sizeof (struct GNUNET_CRYPTO_PublicKey)))
880 {
881 // if: issuer attr we looking for
882 if (0 == strcmp (del->issuer_attribute, vrh->issuer_attribute))
883 {
884 // if: complete match, meaning new trailer == issuer attr
885 if (0 == strcmp (vrh->issuer_attribute, ds_entry->attr_trailer))
886 {
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found: Solution\n");
888
889 // Add found solution into delegation_chain
890 {
891 struct DelegationSetQueueEntry *tmp_set;
892 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
893 tmp_set = tmp_set->parent_queue_entry->parent_set)
894 {
895 if (NULL != tmp_set->delegation_chain_entry)
896 {
900 tmp_set->delegation_chain_entry);
901 }
902 }
903 }
904
905 // Increase refcount for this delegate
906 for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head;
907 del_entry != NULL;
908 del_entry = del_entry->next)
909 {
910 if (0 == memcmp (&del_entry->delegate->issuer_key,
912 sizeof (struct GNUNET_CRYPTO_PublicKey)))
913 {
914 if (0 == strcmp (del_entry->delegate->issuer_attribute,
916 {
917 del_entry->refcount++;
918 }
919 }
920 }
921
924 return;
925 }
926 }
927 }
928
929 // Check for bidirectional crossmatch
930 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
931 del_entry != NULL;
932 del_entry = del_entry->next)
933 {
934 // only check entries not by backward algorithm
935 if (del_entry->from_bw)
936 {
937 // key of list entry matches actual key
938 if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key,
940 sizeof (struct GNUNET_CRYPTO_PublicKey)))
941 {
942 // compare entry subject attributes to this trailer (iss attr + old trailer)
943 if (0 == strcmp (del_entry->unresolved_attribute_delegation,
944 ds_entry->attr_trailer))
945 {
946 print_deleset (del_entry, "Forward:");
948 "Forward: Found match with above!\n");
949
951 // one node on the path still needs solutions: return
952 if (GNUNET_NO ==
953 handle_bidirectional_match (ds_entry, del_entry, vrh))
954 return;
955
957 return;
958 }
959 }
960 }
961 }
962
963 // Starting a new GNS lookup
964 vrh->pending_lookups++;
965 ds_entry->handle = vrh;
966
968 "Starting to look up trailer %s in zone %s\n",
969 ds_entry->attr_trailer,
971
972 ds_entry->lookup_request =
975 &del->issuer_key,
979 ds_entry);
981 }
982
983 if (0 == vrh->pending_lookups)
984 {
985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
987 return;
988 }
989}
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_deserialize(const char *data, size_t data_size)
static char * data
The data to insert into the dht.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static size_t data_size
Number of bytes in data.
static void forward_resolution(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
static int handle_bidirectional_match(struct DelegationSetQueueEntry *actual_entry, struct DelegationSetQueueEntry *match_entry, struct VerifyRequestHandle *vrh)
static char * partial_match(char *tmp_trail, char *tmp_subattr, char *parent_trail, char *issuer_attribute)
static void send_intermediate_response(struct VerifyRequestHandle *vrh, struct DelegationChainEntry *ch_entry, bool is_bw)
static void print_deleset(struct DelegationSetQueueEntry *dsentry, const char *text)
static void send_lookup_response(struct VerifyRequestHandle *vrh)
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_CRYPTO_PublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS.
Definition: gns_api.c:421
@ GNUNET_GNS_LO_DEFAULT
Defaults, look in cache, then in DHT.
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_GNSRECORD_TYPE_DELEGATE
For ABD policies.
uint32_t required_solutions
Required solutions.
struct VerifyRequestHandle * handle
Verify handle.
struct DelegationSetQueueEntry * next
DLL.
uint64_t pending_lookups
Pending lookups.
struct GNUNET_CRYPTO_PublicKey issuer_key
Issuer public key.

References DelegationSetQueueEntry::attr_trailer, data, data_size, del, VerifyRequestHandle::del_chain_head, DelegationSetQueueEntry::delegation_chain_entry, VerifyRequestHandle::delegation_chain_head, VerifyRequestHandle::delegation_chain_size, VerifyRequestHandle::delegation_chain_tail, VerifyRequestHandle::dsq_head, VerifyRequestHandle::dsq_tail, forward_resolution(), DelegationSetQueueEntry::from_bw, gns, GNUNET_ABD_delegate_deserialize(), GNUNET_asprintf(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_public_key_to_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_DELEGATE, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_strdup, DelegationSetQueueEntry::handle, handle_bidirectional_match(), DelegationChainEntry::issuer_attribute, VerifyRequestHandle::issuer_attribute, DelegationChainEntry::issuer_key, DelegationSetQueueEntry::issuer_key, VerifyRequestHandle::issuer_key, DelegationSetQueueEntry::lookup_request, DelegateRecordEntry::next, DelegationSetQueueEntry::next, DelegationSetQueueEntry::parent_queue_entry, DelegationQueueEntry::parent_set, partial_match(), VerifyRequestHandle::pending_lookups, print_deleset(), DelegationSetQueueEntry::queue_entries_head, DelegationSetQueueEntry::queue_entries_tail, rd, rd_count, DelegationQueueEntry::required_solutions, send_intermediate_response(), send_lookup_response(), DelegationChainEntry::subject_attribute, and DelegationChainEntry::subject_key.

Referenced by delegation_chain_fw_resolution_start(), and forward_resolution().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ backward_resolution()

static void backward_resolution ( void *  cls,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Check if this delegation already matches one of our credentials

Definition at line 993 of file gnunet-service-abd.c.

996{
997 struct VerifyRequestHandle *vrh;
998 const struct GNUNET_ABD_DelegationRecord *sets;
999 struct DelegateRecordEntry *del_pointer;
1000 struct DelegationSetQueueEntry *current_set;
1001 struct DelegationSetQueueEntry *ds_entry;
1002 struct DelegationSetQueueEntry *tmp_set;
1003 struct DelegationQueueEntry *dq_entry;
1004 char *expanded_attr;
1005 char *lookup_attribute;
1006
1007 current_set = cls;
1008 current_set->lookup_request = NULL;
1009 vrh = current_set->handle;
1010 vrh->pending_lookups--;
1011
1012 // Each OR
1013 for (uint32_t i = 0; i < rd_count; i++)
1014 {
1015 if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type)
1016 continue;
1017
1018 sets = rd[i].data;
1019 struct GNUNET_ABD_DelegationSet set[ntohl (sets->set_count)];
1021 "Found new attribute delegation with %d sets. Creating new Job...\n",
1022 ntohl (sets->set_count));
1023
1024 if (GNUNET_OK !=
1026 sets->data_size),
1027 (const char *) &sets[1],
1028 ntohl (sets->set_count),
1029 set))
1030 {
1031 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to deserialize!\n");
1032 continue;
1033 }
1034 dq_entry = GNUNET_new (struct DelegationQueueEntry);
1035 dq_entry->required_solutions = ntohl (sets->set_count);
1036 dq_entry->parent_set = current_set;
1037
1039 current_set->queue_entries_tail,
1040 dq_entry);
1041 // Each AND
1042 for (uint32_t j = 0; j < ntohl (sets->set_count); j++)
1043 {
1044 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1045 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1046 ds_entry->from_bw = true;
1047
1048 if (NULL != current_set->attr_trailer)
1049 {
1050 if (0 == set[j].subject_attribute_len)
1051 {
1052 GNUNET_asprintf (&expanded_attr, "%s", current_set->attr_trailer);
1053 }
1054 else
1055 {
1056 GNUNET_asprintf (&expanded_attr,
1057 "%s.%s",
1058 set[j].subject_attribute,
1059 current_set->attr_trailer);
1060 }
1061 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expanded to %s\n", expanded_attr);
1062 ds_entry->unresolved_attribute_delegation = expanded_attr;
1063 }
1064 else
1065 {
1066 if (0 != set[j].subject_attribute_len)
1067 {
1069 "Not Expanding %s\n",
1070 set[j].subject_attribute);
1073 }
1074 }
1075
1076 // Add a credential chain entry
1077 ds_entry->delegation_chain_entry =
1079 ds_entry->delegation_chain_entry->subject_key = set[j].subject_key;
1080 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_PublicKey);
1081 GNUNET_memcpy (ds_entry->issuer_key,
1082 &set[j].subject_key,
1083 sizeof (struct GNUNET_CRYPTO_PublicKey));
1084 if (0 < set[j].subject_attribute_len)
1087 ds_entry->delegation_chain_entry->issuer_key = *current_set->issuer_key;
1089 GNUNET_strdup (current_set->lookup_attribute);
1090
1091 // Found new entry, repoting intermediate result
1093
1094 ds_entry->parent_queue_entry = dq_entry; // current_delegation;
1095
1099 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking for cred match\n");
1100
1101 for (del_pointer = vrh->del_chain_head; del_pointer != NULL;
1102 del_pointer = del_pointer->next)
1103 {
1104 // If key and attribute match credential: continue and backtrack
1105 if (0 != memcmp (&set[j].subject_key,
1106 &del_pointer->delegate->issuer_key,
1107 sizeof (struct GNUNET_CRYPTO_PublicKey)))
1108 continue;
1110 "Checking if %s matches %s\n",
1112 del_pointer->delegate->issuer_attribute);
1113
1114 if (0 != strcmp (ds_entry->unresolved_attribute_delegation,
1115 del_pointer->delegate->issuer_attribute))
1116 continue;
1117
1118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found issuer\n");
1119 // increase refcount of the start delegation
1120 del_pointer->refcount++;
1121
1122 // Backtrack
1123 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
1124 tmp_set = tmp_set->parent_queue_entry->parent_set)
1125 {
1127 if (NULL != tmp_set->delegation_chain_entry)
1128 {
1129 vrh->delegation_chain_size++;
1132 tmp_set->delegation_chain_entry);
1133 }
1134 if (0 < tmp_set->parent_queue_entry->required_solutions)
1135 break;
1136 }
1137
1138 // if the break above is not called the condition of the for is met
1139 if (NULL == tmp_set->parent_queue_entry)
1140 {
1141 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n");
1142 // Found match
1144 return;
1145 }
1146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not all solutions found yet.\n");
1147 continue;
1148 }
1149
1151 "Building new lookup request from %s\n",
1153 // Continue with next/new backward resolution
1154 char issuer_attribute_name[strlen (
1156 + 1];
1157 strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation);
1158 char *next_attr = strtok (issuer_attribute_name, ".");
1159 if (NULL == next_attr)
1160 {
1162 "Failed to parse next attribute\n");
1163 continue;
1164 }
1165 GNUNET_asprintf (&lookup_attribute, "%s", next_attr);
1166 GNUNET_asprintf (&ds_entry->lookup_attribute, "%s", next_attr);
1167 if (strlen (next_attr) ==
1168 strlen (ds_entry->unresolved_attribute_delegation))
1169 {
1170 ds_entry->attr_trailer = NULL;
1171 }
1172 else
1173 {
1174 next_attr += strlen (next_attr) + 1;
1175 ds_entry->attr_trailer = GNUNET_strdup (next_attr);
1176 }
1177
1178 // Check for bidirectional crossmatch
1179 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
1180 del_entry != NULL;
1181 del_entry = del_entry->next)
1182 {
1183 // only check entries added by forward algorithm
1184 if (! del_entry->from_bw)
1185 {
1186 // key of list entry matches actual key
1187 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
1189 sizeof (struct GNUNET_CRYPTO_PublicKey)))
1190 {
1191 // compare entry subject attributes to this trailer (iss attr + old trailer)
1192 if (0 == strcmp (del_entry->attr_trailer,
1194 {
1195 print_deleset (del_entry, "Backward:");
1197 "Backward: Found match with above!\n");
1198
1199 // if one node on the path still needs solutions: return
1200 if (GNUNET_NO ==
1201 handle_bidirectional_match (del_entry, ds_entry, vrh))
1202 break;
1203
1204 // Send lookup response
1206 return;
1207 }
1208 }
1209 }
1210 }
1211
1212 // Starting a new GNS lookup
1214 "Looking up %s\n",
1215 ds_entry->lookup_attribute);
1216 if (NULL != ds_entry->attr_trailer)
1218 "%s still to go...\n",
1219 ds_entry->attr_trailer);
1220
1221 vrh->pending_lookups++;
1222 ds_entry->handle = vrh;
1223 ds_entry->lookup_request =
1225 lookup_attribute,
1226 ds_entry->issuer_key, // issuer_key,
1230 ds_entry);
1231
1232 GNUNET_free (lookup_attribute);
1233 }
1234 }
1235
1236 if (0 == vrh->pending_lookups)
1237 {
1238 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
1240 return;
1241 }
1242}
int GNUNET_ABD_delegation_set_deserialize(size_t len, const char *src, unsigned int d_count, struct GNUNET_ABD_DelegationSet *dsr)
Deserialize the given destination.
static void backward_resolution(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
For ABD reverse lookups.
uint32_t refcount
Number of references in delegation chains.
const char * issuer_attribute
The issuer attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer of the credential.
The attribute delegation record.
uint64_t data_size
Length of delegation sets.
uint32_t set_count
Number of delegation sets in this record.
The attribute delegation record.
const char * subject_attribute
The subject attribute.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this attribute was delegated to.
const void * data
Binary value stored in the DNS record.

References DelegationSetQueueEntry::attr_trailer, backward_resolution(), GNUNET_GNSRECORD_Data::data, VerifyRequestHandle::del_chain_head, DelegateRecordEntry::delegate, DelegationSetQueueEntry::delegation_chain_entry, VerifyRequestHandle::delegation_chain_head, VerifyRequestHandle::delegation_chain_size, VerifyRequestHandle::delegation_chain_tail, VerifyRequestHandle::dsq_head, VerifyRequestHandle::dsq_tail, DelegationSetQueueEntry::from_bw, gns, GNUNET_ABD_delegation_set_deserialize(), GNUNET_asprintf(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_ATTRIBUTE, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_strdup, DelegationSetQueueEntry::handle, handle_bidirectional_match(), DelegationChainEntry::issuer_attribute, GNUNET_ABD_Delegate::issuer_attribute, DelegationChainEntry::issuer_key, DelegationSetQueueEntry::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegationSetQueueEntry::lookup_attribute, DelegationSetQueueEntry::lookup_request, DelegateRecordEntry::next, DelegationSetQueueEntry::next, DelegationSetQueueEntry::parent_queue_entry, DelegationQueueEntry::parent_set, VerifyRequestHandle::pending_lookups, print_deleset(), DelegationSetQueueEntry::queue_entries_head, DelegationSetQueueEntry::queue_entries_tail, rd, rd_count, DelegateRecordEntry::refcount, DelegationQueueEntry::required_solutions, send_intermediate_response(), send_lookup_response(), DelegationChainEntry::subject_attribute, GNUNET_ABD_DelegationSet::subject_attribute, GNUNET_ABD_DelegationSet::subject_attribute_len, DelegationChainEntry::subject_key, GNUNET_ABD_DelegationSet::subject_key, and DelegationSetQueueEntry::unresolved_attribute_delegation.

Referenced by backward_resolution(), and delegation_chain_bw_resolution_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delegation_chain_bw_resolution_start()

static int delegation_chain_bw_resolution_start ( void *  cls)
static

Result from GNS lookup.

Parameters
clsthe closure (our client lookup handle)

Definition at line 1251 of file gnunet-service-abd.c.

1252{
1253
1254 struct VerifyRequestHandle *vrh = cls;
1255 struct DelegationSetQueueEntry *ds_entry;
1256 struct DelegateRecordEntry *del_entry;
1257
1258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Backward Resolution...\n");
1259 if (0 == vrh->del_chain_size)
1260 {
1261 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegates found\n");
1263 return 1;
1264 }
1265
1266 // Pre-check with vrh->dele_chain_.. if match issuer_key
1267 // Backward: check every cred entry if match issuer key
1268 // otherwise: start at issuer and go down till match
1269 // A.a <- ...
1270 // X.x <- C
1271 // Y.y <- C
1272 // if not X.x or Y.y == A.a start at A
1273 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1274 del_entry = del_entry->next)
1275 {
1276 if (0 != memcmp (&del_entry->delegate->issuer_key,
1277 &vrh->issuer_key,
1278 sizeof (struct GNUNET_CRYPTO_PublicKey)))
1279 continue;
1280 if (0 !=
1281 strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
1282 continue;
1283 del_entry->refcount++;
1284 // Found match prematurely
1286 return 1;
1287 }
1288
1289
1290 // Check for attributes from the issuer and follow the chain
1291 // till you get the required subject's attributes
1292 char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1];
1293 strcpy (issuer_attribute_name, vrh->issuer_attribute);
1295 "Looking up %s\n",
1296 issuer_attribute_name);
1297 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1298 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1299 ds_entry->from_bw = true;
1300 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_PublicKey);
1301 GNUNET_memcpy (ds_entry->issuer_key,
1302 &vrh->issuer_key,
1303 sizeof (struct GNUNET_CRYPTO_PublicKey));
1305
1310
1311 ds_entry->handle = vrh;
1313 ds_entry->unresolved_attribute_delegation = NULL;
1314 vrh->pending_lookups = 1;
1315
1316 // Start with backward resolution
1317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Backward Resolution\n");
1318
1320 issuer_attribute_name,
1321 &vrh->issuer_key, // issuer_key,
1325 ds_entry);
1326 return 0;
1327}

References backward_resolution(), VerifyRequestHandle::del_chain_head, VerifyRequestHandle::del_chain_size, DelegateRecordEntry::delegate, DelegationSetQueueEntry::delegation_chain_entry, VerifyRequestHandle::dsq_head, VerifyRequestHandle::dsq_tail, DelegationSetQueueEntry::from_bw, gns, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_ATTRIBUTE, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_strdup, DelegationSetQueueEntry::handle, DelegationChainEntry::issuer_attribute, DelegationSetQueueEntry::issuer_attribute, VerifyRequestHandle::issuer_attribute, GNUNET_ABD_Delegate::issuer_attribute, DelegationChainEntry::issuer_key, DelegationSetQueueEntry::issuer_key, VerifyRequestHandle::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegationSetQueueEntry::lookup_attribute, DelegationSetQueueEntry::lookup_request, DelegateRecordEntry::next, VerifyRequestHandle::pending_lookups, DelegateRecordEntry::refcount, send_lookup_response(), and DelegationSetQueueEntry::unresolved_attribute_delegation.

Referenced by delegate_collection_finished(), and handle_verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delegation_chain_fw_resolution_start()

static int delegation_chain_fw_resolution_start ( void *  cls)
static

Definition at line 1331 of file gnunet-service-abd.c.

1332{
1333
1334 struct VerifyRequestHandle *vrh = cls;
1335 struct DelegationSetQueueEntry *ds_entry;
1336 struct DelegateRecordEntry *del_entry;
1337
1338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Forward Resolution...\n");
1339 // set to 0 and increase on each lookup: for fw multiple lookups (may be) started
1340 vrh->pending_lookups = 0;
1341
1342 if (0 == vrh->del_chain_size)
1343 {
1344 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n");
1346 return 1;
1347 }
1348
1349 // Pre-check with vrh->dele_chain_.. if match issuer_key
1350 // otherwise FW: start multiple lookups for each vrh->dele_chain
1351 // A.a <- ...
1352 // X.x <- C
1353 // Y.y <- C
1354 // if not X.x or Y.y == A.a start at X and at Y
1355 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1356 del_entry = del_entry->next)
1357 {
1358 if (0 != memcmp (&del_entry->delegate->issuer_key,
1359 &vrh->issuer_key,
1360 sizeof (struct GNUNET_CRYPTO_PublicKey)))
1361 continue;
1362 if (0 !=
1363 strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
1364 continue;
1365 del_entry->refcount++;
1366 // Found match prematurely
1368 return 1;
1369 }
1370
1371 // None match, therefore start for every delegation found a lookup chain
1372 // Return and end collect process on first chain iss <-> sub found
1373
1374 // ds_entry created belongs to the first lookup, vrh still has the
1375 // issuer+attr we look for
1376 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1377 del_entry = del_entry->next)
1378 {
1379
1381 "Looking for %s.%s\n",
1383 &del_entry->delegate->issuer_key),
1384 del_entry->delegate->issuer_attribute);
1385
1386 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1387 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1388 ds_entry->from_bw = false;
1389 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_PublicKey);
1390 GNUNET_memcpy (ds_entry->issuer_key,
1391 &del_entry->delegate->subject_key,
1392 sizeof (struct GNUNET_CRYPTO_PublicKey));
1393
1396 del_entry->delegate->subject_key;
1397 ds_entry->delegation_chain_entry->subject_attribute = NULL;
1399 del_entry->delegate->issuer_key;
1402
1403 ds_entry->attr_trailer =
1405 ds_entry->handle = vrh;
1406
1407 vrh->pending_lookups++;
1408 // Start with forward resolution
1409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Forward Resolution\n");
1410
1411 ds_entry->lookup_request =
1414 &del_entry->delegate->issuer_key, // issuer_key,
1418 ds_entry);
1419 }
1420 return 0;
1421}
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this credential was issued to.

References DelegationSetQueueEntry::attr_trailer, VerifyRequestHandle::del_chain_head, VerifyRequestHandle::del_chain_size, DelegateRecordEntry::delegate, DelegationSetQueueEntry::delegation_chain_entry, VerifyRequestHandle::dsq_head, VerifyRequestHandle::dsq_tail, forward_resolution(), DelegationSetQueueEntry::from_bw, gns, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_public_key_to_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup(), GNUNET_GNSRECORD_TYPE_DELEGATE, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_strdup, DelegationSetQueueEntry::handle, DelegationChainEntry::issuer_attribute, VerifyRequestHandle::issuer_attribute, GNUNET_ABD_Delegate::issuer_attribute, DelegationChainEntry::issuer_key, DelegationSetQueueEntry::issuer_key, VerifyRequestHandle::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegationSetQueueEntry::lookup_request, DelegateRecordEntry::next, VerifyRequestHandle::pending_lookups, DelegateRecordEntry::refcount, send_lookup_response(), DelegationChainEntry::subject_attribute, DelegationChainEntry::subject_key, and GNUNET_ABD_Delegate::subject_key.

Referenced by delegate_collection_finished(), and handle_verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_verify()

static int check_verify ( void *  cls,
const struct VerifyMessage v_msg 
)
static

Definition at line 1425 of file gnunet-service-abd.c.

1426{
1427 size_t msg_size;
1428 const char *attr;
1429
1430 msg_size = ntohs (v_msg->header.size);
1431 if (msg_size < sizeof (struct VerifyMessage))
1432 {
1433 GNUNET_break (0);
1434 return GNUNET_SYSERR;
1435 }
1436 if (ntohs (v_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1437 {
1438 GNUNET_break (0);
1439 return GNUNET_SYSERR;
1440 }
1441 attr = (const char *) &v_msg[1];
1442
1443 if (strlen (attr) > GNUNET_ABD_MAX_LENGTH)
1444 {
1445 GNUNET_break (0);
1446 return GNUNET_SYSERR;
1447 }
1448 return GNUNET_OK;
1449}
#define GNUNET_ABD_MAX_LENGTH
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
Message from client to Credential service to verify attributes.
Definition: abd.h:75
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
Definition: abd.h:79
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition: abd.h:99

References GNUNET_ABD_MAX_LENGTH, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, VerifyMessage::header, VerifyMessage::issuer_attribute_len, and GNUNET_MessageHeader::size.

◆ handle_verify()

static void handle_verify ( void *  cls,
const struct VerifyMessage v_msg 
)
static

Definition at line 1453 of file gnunet-service-abd.c.

1454{
1455 struct VerifyRequestHandle *vrh;
1456 struct GNUNET_SERVICE_Client *client = cls;
1457 struct DelegateRecordEntry *del_entry;
1458 uint32_t delegate_count;
1459 uint32_t delegate_data_size;
1460 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1461 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1462 char *attrptr = attr;
1463 char *delegate_data;
1464 const char *utf_in;
1465
1466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n");
1467 utf_in = (const char *) &v_msg[1];
1468 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1469 GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len));
1470 issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
1471 vrh = GNUNET_new (struct VerifyRequestHandle);
1472 vrh->is_collect = false;
1474 vrh->client = client;
1475 vrh->request_id = v_msg->id;
1476 vrh->issuer_key = v_msg->issuer_key;
1477 vrh->subject_key = v_msg->subject_key;
1478 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1479 vrh->resolution_algo = ntohs (v_msg->resolution_algo);
1480
1481 vrh->del_chain_head = NULL;
1482 vrh->del_chain_tail = NULL;
1483 vrh->dsq_head = NULL;
1484 vrh->dsq_tail = NULL;
1485 vrh->del_chain_head = NULL;
1486 vrh->del_chain_tail = NULL;
1487
1489 if (0 == strlen (issuer_attribute))
1490 {
1491 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1493 return;
1494 }
1495
1496 // Parse delegates from verifaction message
1497 delegate_count = ntohl (v_msg->d_count);
1498 delegate_data_size = ntohs (v_msg->header.size)
1499 - sizeof (struct VerifyMessage)
1500 - ntohs (v_msg->issuer_attribute_len) - 1;
1501 struct GNUNET_ABD_Delegate delegates[delegate_count];
1502 memset (delegates,
1503 0,
1504 sizeof (struct GNUNET_ABD_Delegate) * delegate_count);
1505 delegate_data = (char *) &v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1;
1506 if (GNUNET_OK != GNUNET_ABD_delegates_deserialize (delegate_data_size,
1507 delegate_data,
1508 delegate_count,
1509 delegates))
1510 {
1511 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n");
1513 return;
1514 }
1515
1516 // Prepare vrh delegation chain for later validation
1517 for (uint32_t i = 0; i < delegate_count; i++)
1518 {
1519 del_entry = GNUNET_new (struct DelegateRecordEntry);
1520 del_entry->delegate =
1521 GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate)
1522 + delegates[i].issuer_attribute_len + 1);
1523 GNUNET_memcpy (del_entry->delegate,
1524 &delegates[i],
1525 sizeof (struct GNUNET_ABD_Delegate));
1526 GNUNET_memcpy (&del_entry->delegate[1],
1527 delegates[i].issuer_attribute,
1528 delegates[i].issuer_attribute_len);
1529 del_entry->delegate->issuer_attribute_len =
1530 delegates[i].issuer_attribute_len;
1531 del_entry->delegate->issuer_attribute = (char *) &del_entry->delegate[1];
1533 vrh->del_chain_tail,
1534 del_entry);
1535 vrh->del_chain_size++;
1536 }
1537
1538 // Switch resolution algo
1541 {
1543 return;
1545 }
1547 {
1549 }
1551 {
1553 }
1554}
int GNUNET_ABD_delegates_deserialize(size_t len, const char *src, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
Deserialize the given destination.
static int delegation_chain_bw_resolution_start(void *cls)
Result from GNS lookup.
static int delegation_chain_fw_resolution_start(void *cls)
@ GNUNET_ABD_FLAG_BACKWARD
@ GNUNET_ABD_FLAG_FORWARD
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_malloc(size)
Wrapper around malloc.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2389
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:459
uint32_t issuer_attribute_len
Length of the issuer attribute.
Handle to a client that is connected to a service.
Definition: service.c:249
uint16_t resolution_algo
Direction of the resolution algo.
Definition: abd.h:104
struct GNUNET_CRYPTO_PublicKey subject_key
Subject public key.
Definition: abd.h:84
uint32_t id
Unique identifier for this request (for key collisions).
Definition: abd.h:109
uint32_t d_count
Number of delegates.
Definition: abd.h:94
struct GNUNET_CRYPTO_PublicKey issuer_key
Trust anchor.
Definition: abd.h:89
struct GNUNET_CRYPTO_PublicKey subject_key
Subject public key.
enum GNUNET_ABD_AlgoDirectionFlags resolution_algo
Direction of the resolution algo.

References VerifyRequestHandle::client, VerifyMessage::d_count, VerifyRequestHandle::del_chain_head, VerifyRequestHandle::del_chain_size, VerifyRequestHandle::del_chain_tail, DelegateRecordEntry::delegate, delegation_chain_bw_resolution_start(), delegation_chain_fw_resolution_start(), VerifyRequestHandle::dsq_head, VerifyRequestHandle::dsq_tail, GNUNET_ABD_delegates_deserialize(), GNUNET_ABD_FLAG_BACKWARD, GNUNET_ABD_FLAG_FORWARD, GNUNET_ABD_MAX_LENGTH, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), VerifyMessage::header, VerifyMessage::id, VerifyRequestHandle::is_collect, VerifyRequestHandle::issuer_attribute, GNUNET_ABD_Delegate::issuer_attribute, VerifyMessage::issuer_attribute_len, GNUNET_ABD_Delegate::issuer_attribute_len, VerifyMessage::issuer_key, VerifyRequestHandle::issuer_key, VerifyRequestHandle::request_id, VerifyMessage::resolution_algo, VerifyRequestHandle::resolution_algo, send_lookup_response(), GNUNET_MessageHeader::size, VerifyMessage::subject_key, VerifyRequestHandle::subject_key, vrh_head, and vrh_tail.

Here is the call graph for this function:

◆ handle_delegate_collection_error_cb()

static void handle_delegate_collection_error_cb ( void *  cls)
static

Definition at line 1558 of file gnunet-service-abd.c.

1559{
1560 struct VerifyRequestHandle *vrh = cls;
1562 "Got disconnected from namestore database.\n");
1563 vrh->dele_qe = NULL;
1565}
struct GNUNET_NAMESTORE_QueueEntry * dele_qe
Delegate iterator for lookup.

References VerifyRequestHandle::dele_qe, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and send_lookup_response().

Referenced by handle_collect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delegate_collection_finished()

static void delegate_collection_finished ( void *  cls)
static

Definition at line 1569 of file gnunet-service-abd.c.

1570{
1571 struct VerifyRequestHandle *vrh = cls;
1572 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n");
1573
1574 // if both are set: bidirectional search, meaning start both chain resolutions
1577 {
1578 // if premature match found don't start bw resolution
1580 return;
1582 }
1584 {
1586 }
1588 {
1590 }
1591}

References delegation_chain_bw_resolution_start(), delegation_chain_fw_resolution_start(), GNUNET_ABD_FLAG_BACKWARD, GNUNET_ABD_FLAG_FORWARD, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and VerifyRequestHandle::resolution_algo.

Referenced by handle_delegate_collection_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_delegate_collection_cb()

static void handle_delegate_collection_cb ( void *  cls,
const struct GNUNET_CRYPTO_PrivateKey key,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Definition at line 1595 of file gnunet-service-abd.c.

1600{
1601 struct VerifyRequestHandle *vrh = cls;
1602 struct DelegateRecordEntry *del_entry;
1603 vrh->dele_qe = NULL;
1604
1605 for (uint32_t i = 0; i < rd_count; i++)
1606 {
1607 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
1608 continue;
1609 // only add the entries that are explicitly marked as private
1610 // and therefore symbolize the end of a chain
1611 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
1612 continue;
1613 del_entry = GNUNET_new (struct DelegateRecordEntry);
1614 del_entry->delegate = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].
1615 data_size);
1616 if (NULL == del_entry->delegate)
1617 {
1618 GNUNET_free (del_entry);
1619 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
1620 continue;
1621 }
1623 vrh->del_chain_tail,
1624 del_entry);
1625 vrh->del_chain_size++;
1626 }
1627
1629}
static void delegate_collection_finished(void *cls)
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
@ GNUNET_ERROR_TYPE_WARNING

References data, data_size, VerifyRequestHandle::del_chain_head, VerifyRequestHandle::del_chain_size, VerifyRequestHandle::del_chain_tail, VerifyRequestHandle::dele_qe, DelegateRecordEntry::delegate, delegate_collection_finished(), GNUNET_ABD_delegate_deserialize(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_TYPE_DELEGATE, GNUNET_log, GNUNET_new, rd, and rd_count.

Referenced by handle_collect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_collect()

static void handle_collect ( void *  cls,
const struct CollectMessage c_msg 
)
static

Definition at line 1633 of file gnunet-service-abd.c.

1634{
1635 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1636 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1637 struct VerifyRequestHandle *vrh;
1638 struct GNUNET_SERVICE_Client *client = cls;
1639 char *attrptr = attr;
1640 const char *utf_in;
1641
1642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received COLLECT message\n");
1643
1644 utf_in = (const char *) &c_msg[1];
1645 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1646
1647 GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len));
1648 issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0';
1649 vrh = GNUNET_new (struct VerifyRequestHandle);
1650 vrh->is_collect = true;
1652 vrh->client = client;
1653 vrh->request_id = c_msg->id;
1654 vrh->issuer_key = c_msg->issuer_key;
1656 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1657 vrh->resolution_algo = ntohs (c_msg->resolution_algo);
1658
1659 vrh->del_chain_head = NULL;
1660 vrh->del_chain_tail = NULL;
1661 vrh->dsq_head = NULL;
1662 vrh->dsq_tail = NULL;
1663 vrh->del_chain_head = NULL;
1664 vrh->del_chain_tail = NULL;
1665
1666 if (0 == strlen (issuer_attribute))
1667 {
1668 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1670 return;
1671 }
1672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting delegates for subject\n");
1673
1674 // Get all delegates from subject
1675 vrh->dele_qe =
1677 &c_msg->subject_key,
1680 vrh,
1682 vrh);
1684}
static void handle_delegate_collection_error_cb(void *cls)
static void handle_delegate_collection_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:430
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
struct GNUNET_CRYPTO_PublicKey issuer_key
Trust anchor.
Definition: abd.h:50
uint16_t resolution_algo
Direction of the resolution algo.
Definition: abd.h:60
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition: abd.h:55
struct GNUNET_CRYPTO_PrivateKey subject_key
Subject public key.
Definition: abd.h:45
uint32_t id
Unique identifier for this request (for key collisions).
Definition: abd.h:65

References VerifyRequestHandle::client, VerifyRequestHandle::del_chain_head, VerifyRequestHandle::del_chain_tail, VerifyRequestHandle::dele_qe, VerifyRequestHandle::dsq_head, VerifyRequestHandle::dsq_tail, GNUNET_ABD_MAX_LENGTH, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_log, GNUNET_memcpy, GNUNET_NAMESTORE_records_lookup(), GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), handle_delegate_collection_cb(), handle_delegate_collection_error_cb(), CollectMessage::id, VerifyRequestHandle::is_collect, VerifyRequestHandle::issuer_attribute, CollectMessage::issuer_attribute_len, CollectMessage::issuer_key, VerifyRequestHandle::issuer_key, namestore, VerifyRequestHandle::request_id, CollectMessage::resolution_algo, VerifyRequestHandle::resolution_algo, send_lookup_response(), CollectMessage::subject_key, VerifyRequestHandle::subject_key, vrh_head, and vrh_tail.

Here is the call graph for this function:

◆ check_collect()

static int check_collect ( void *  cls,
const struct CollectMessage c_msg 
)
static

Definition at line 1688 of file gnunet-service-abd.c.

1689{
1690 size_t msg_size;
1691 const char *attr;
1692
1693 msg_size = ntohs (c_msg->header.size);
1694 if (msg_size < sizeof (struct CollectMessage))
1695 {
1696 GNUNET_break (0);
1697 return GNUNET_SYSERR;
1698 }
1699 if (ntohs (c_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1700 {
1701 GNUNET_break (0);
1702 return GNUNET_SYSERR;
1703 }
1704 attr = (const char *) &c_msg[1];
1705
1706 if (('\0' != attr[msg_size - sizeof (struct CollectMessage) - 1]) ||
1707 (strlen (attr) > GNUNET_ABD_MAX_LENGTH))
1708 {
1709 GNUNET_break (0);
1710 return GNUNET_SYSERR;
1711 }
1712 return GNUNET_OK;
1713}
Message from client to Credential service to collect credentials.
Definition: abd.h:36
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
Definition: abd.h:40

References GNUNET_ABD_MAX_LENGTH, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, CollectMessage::header, CollectMessage::issuer_attribute_len, and GNUNET_MessageHeader::size.

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Definition at line 1717 of file gnunet-service-abd.c.

1720{
1721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1722}

References GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Definition at line 1726 of file gnunet-service-abd.c.

1729{
1730 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1731 return client;
1732}

References GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle handle 
)
static

Process Credential requests.

Parameters
clsclosure
cconfiguration to use
handleservice handle

Definition at line 1743 of file gnunet-service-abd.c.

1746{
1747
1748 gns = GNUNET_GNS_connect (c);
1749 if (NULL == gns)
1750 {
1751 fprintf (stderr, _ ("Failed to connect to GNS\n"));
1752 }
1754 if (NULL == namestore)
1755 {
1756 fprintf (stderr, _ ("Failed to connect to namestore\n"));
1757 }
1758
1761}
static void shutdown_task(void *cls)
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:267
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1339
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, gns, GNUNET_GNS_connect(), GNUNET_NAMESTORE_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), namestore, shutdown_task(), and statistics.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( GNUNET_OS_project_data_gnunet()  ,
"abd"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_var_size(verify, GNUNET_MESSAGE_TYPE_ABD_VERIFY, struct VerifyMessage, NULL)  ,
GNUNET_MQ_hd_var_size(collect, GNUNET_MESSAGE_TYPE_ABD_COLLECT, struct CollectMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Variable Documentation

◆ vrh_head

struct VerifyRequestHandle* vrh_head = NULL
static

Head of the DLL.

Definition at line 325 of file gnunet-service-abd.c.

Referenced by handle_collect(), handle_verify(), send_lookup_response(), and shutdown_task().

◆ vrh_tail

struct VerifyRequestHandle* vrh_tail = NULL
static

Tail of the DLL.

Definition at line 330 of file gnunet-service-abd.c.

Referenced by handle_collect(), handle_verify(), send_lookup_response(), and shutdown_task().

◆ statistics

struct GNUNET_STATISTICS_Handle* statistics
static

Handle to the statistics service.

Definition at line 335 of file gnunet-service-abd.c.

Referenced by run(), send_lookup_response(), and shutdown_task().

◆ gns

◆ namestore

struct GNUNET_NAMESTORE_Handle* namestore
static

Handle to namestore service.

Definition at line 345 of file gnunet-service-abd.c.

Referenced by handle_collect(), run(), and shutdown_task().