GNUnet debian-0.26.1
 
Loading...
Searching...
No Matches
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.
 
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_BlindablePrivateKey *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.
 
 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.
 

Variables

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

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_blindable_public_key_to_string(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Creates a (Base32) string representation of the public key.
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
The issuer.
char * subject_attribute
The delegated attribute.
struct GNUNET_CRYPTO_BlindablePublicKey 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_blindable_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.
struct GNUNET_CRYPTO_BlindablePublicKey * issuer_key
Issuer key.
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 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.

Here is the call 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.
#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:2544
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.
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Public key of the subject this attribute was delegated to.
uint32_t subject_attribute_len
Length of the attribute.
const char * issuer_attribute
The attribute.
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
The issuer of the delegation.
const char * subject_attribute
The attribute.
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 DelegateRecordEntry * next
DLL.
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
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
The issuer of the credential.
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, DelegateRecordEntry::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_BlindablePublicKey)))
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 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, 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)
856 GNUNET_memcpy (ds_entry->issuer_key,
857 &del->subject_key,
858 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey));
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_BlindablePublicKey)))
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_BlindablePublicKey)))
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_BlindablePublicKey)))
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
973 ds_entry->lookup_request =
976 &del->issuer_key,
980 ds_entry);
982 }
983
984 if (0 == vrh->pending_lookups)
985 {
986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
988 return;
989 }
990}
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_deserialize(const char *data, size_t data_size)
#define GNUNET_GNSRECORD_TYPE_DELEGATE
For ABD policies.
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_BlindablePublicKey *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_.
uint32_t required_solutions
Required solutions.
struct VerifyRequestHandle * handle
Verify handle.
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
Issuer public key.
uint64_t pending_lookups
Pending lookups.

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_blindable_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, 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 994 of file gnunet-service-abd.c.

997{
998 struct VerifyRequestHandle *vrh;
999 const struct GNUNET_ABD_DelegationRecord *sets;
1000 struct DelegateRecordEntry *del_pointer;
1001 struct DelegationSetQueueEntry *current_set;
1002 struct DelegationSetQueueEntry *ds_entry;
1003 struct DelegationSetQueueEntry *tmp_set;
1004 struct DelegationQueueEntry *dq_entry;
1005 char *expanded_attr;
1006 char *lookup_attribute;
1007
1008 current_set = cls;
1009 current_set->lookup_request = NULL;
1010 vrh = current_set->handle;
1011 vrh->pending_lookups--;
1012
1013 // Each OR
1014 for (uint32_t i = 0; i < rd_count; i++)
1015 {
1016 if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type)
1017 continue;
1018
1019 sets = rd[i].data;
1020 struct GNUNET_ABD_DelegationSet set[ntohl (sets->set_count)];
1022 "Found new attribute delegation with %d sets. Creating new Job...\n",
1023 ntohl (sets->set_count));
1024
1025 if (GNUNET_OK !=
1027 sets->data_size),
1028 (const char *) &sets[1],
1029 ntohl (sets->set_count),
1030 set))
1031 {
1032 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to deserialize!\n");
1033 continue;
1034 }
1035 dq_entry = GNUNET_new (struct DelegationQueueEntry);
1036 dq_entry->required_solutions = ntohl (sets->set_count);
1037 dq_entry->parent_set = current_set;
1038
1040 current_set->queue_entries_tail,
1041 dq_entry);
1042 // Each AND
1043 for (uint32_t j = 0; j < ntohl (sets->set_count); j++)
1044 {
1045 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1046 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1047 ds_entry->from_bw = true;
1048
1049 if (NULL != current_set->attr_trailer)
1050 {
1051 if (0 == set[j].subject_attribute_len)
1052 {
1053 GNUNET_asprintf (&expanded_attr, "%s", current_set->attr_trailer);
1054 }
1055 else
1056 {
1057 GNUNET_asprintf (&expanded_attr,
1058 "%s.%s",
1059 set[j].subject_attribute,
1060 current_set->attr_trailer);
1061 }
1062 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expanded to %s\n", expanded_attr);
1063 ds_entry->unresolved_attribute_delegation = expanded_attr;
1064 }
1065 else
1066 {
1067 if (0 != set[j].subject_attribute_len)
1068 {
1070 "Not Expanding %s\n",
1071 set[j].subject_attribute);
1074 }
1075 }
1076
1077 // Add a credential chain entry
1078 ds_entry->delegation_chain_entry =
1080 ds_entry->delegation_chain_entry->subject_key = set[j].subject_key;
1081 ds_entry->issuer_key = GNUNET_new (struct
1083 GNUNET_memcpy (ds_entry->issuer_key,
1084 &set[j].subject_key,
1085 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey));
1086 if (0 < set[j].subject_attribute_len)
1089 ds_entry->delegation_chain_entry->issuer_key = *current_set->issuer_key;
1091 GNUNET_strdup (current_set->lookup_attribute);
1092
1093 // Found new entry, repoting intermediate result
1095
1096 ds_entry->parent_queue_entry = dq_entry; // current_delegation;
1097
1101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking for cred match\n");
1102
1103 for (del_pointer = vrh->del_chain_head; del_pointer != NULL;
1104 del_pointer = del_pointer->next)
1105 {
1106 // If key and attribute match credential: continue and backtrack
1107 if (0 != memcmp (&set[j].subject_key,
1108 &del_pointer->delegate->issuer_key,
1109 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
1110 continue;
1112 "Checking if %s matches %s\n",
1114 del_pointer->delegate->issuer_attribute);
1115
1116 if (0 != strcmp (ds_entry->unresolved_attribute_delegation,
1117 del_pointer->delegate->issuer_attribute))
1118 continue;
1119
1120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found issuer\n");
1121 // increase refcount of the start delegation
1122 del_pointer->refcount++;
1123
1124 // Backtrack
1125 for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
1126 tmp_set = tmp_set->parent_queue_entry->parent_set)
1127 {
1129 if (NULL != tmp_set->delegation_chain_entry)
1130 {
1131 vrh->delegation_chain_size++;
1134 tmp_set->delegation_chain_entry);
1135 }
1136 if (0 < tmp_set->parent_queue_entry->required_solutions)
1137 break;
1138 }
1139
1140 // if the break above is not called the condition of the for is met
1141 if (NULL == tmp_set->parent_queue_entry)
1142 {
1143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n");
1144 // Found match
1146 return;
1147 }
1148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not all solutions found yet.\n");
1149 continue;
1150 }
1151
1153 "Building new lookup request from %s\n",
1155 // Continue with next/new backward resolution
1156 char issuer_attribute_name[strlen (
1158 + 1];
1159 strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation);
1160 char *next_attr = strtok (issuer_attribute_name, ".");
1161 if (NULL == next_attr)
1162 {
1164 "Failed to parse next attribute\n");
1165 continue;
1166 }
1167 GNUNET_asprintf (&lookup_attribute, "%s", next_attr);
1168 GNUNET_asprintf (&ds_entry->lookup_attribute, "%s", next_attr);
1169 if (strlen (next_attr) ==
1170 strlen (ds_entry->unresolved_attribute_delegation))
1171 {
1172 ds_entry->attr_trailer = NULL;
1173 }
1174 else
1175 {
1176 next_attr += strlen (next_attr) + 1;
1177 ds_entry->attr_trailer = GNUNET_strdup (next_attr);
1178 }
1179
1180 // Check for bidirectional crossmatch
1181 for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head;
1182 del_entry != NULL;
1183 del_entry = del_entry->next)
1184 {
1185 // only check entries added by forward algorithm
1186 if (! del_entry->from_bw)
1187 {
1188 // key of list entry matches actual key
1189 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
1191 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
1192 {
1193 // compare entry subject attributes to this trailer (iss attr + old trailer)
1194 if (0 == strcmp (del_entry->attr_trailer,
1196 {
1197 print_deleset (del_entry, "Backward:");
1199 "Backward: Found match with above!\n");
1200
1201 // if one node on the path still needs solutions: return
1202 if (GNUNET_NO ==
1203 handle_bidirectional_match (del_entry, ds_entry, vrh))
1204 break;
1205
1206 // Send lookup response
1208 return;
1209 }
1210 }
1211 }
1212 }
1213
1214 // Starting a new GNS lookup
1216 "Looking up %s\n",
1217 ds_entry->lookup_attribute);
1218 if (NULL != ds_entry->attr_trailer)
1220 "%s still to go...\n",
1221 ds_entry->attr_trailer);
1222
1223 vrh->pending_lookups++;
1224 ds_entry->handle = vrh;
1225 ds_entry->lookup_request =
1227 lookup_attribute,
1228 ds_entry->issuer_key, // issuer_key,
1232 ds_entry);
1233
1234 GNUNET_free (lookup_attribute);
1235 }
1236 }
1237
1238 if (0 == vrh->pending_lookups)
1239 {
1240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We are all out of attributes...\n");
1242 return;
1243 }
1244}
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.
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
For ABD reverse lookups.
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.
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_ERROR
uint32_t refcount
Number of references in delegation chains.
const char * issuer_attribute
The issuer attribute.
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_BlindablePublicKey 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::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 1253 of file gnunet-service-abd.c.

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

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 1333 of file gnunet-service-abd.c.

1334{
1335
1336 struct VerifyRequestHandle *vrh = cls;
1337 struct DelegationSetQueueEntry *ds_entry;
1338 struct DelegateRecordEntry *del_entry;
1339
1340 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Forward Resolution...\n");
1341 // set to 0 and increase on each lookup: for fw multiple lookups (may be) started
1342 vrh->pending_lookups = 0;
1343
1344 if (0 == vrh->del_chain_size)
1345 {
1346 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n");
1348 return 1;
1349 }
1350
1351 // Pre-check with vrh->dele_chain_.. if match issuer_key
1352 // otherwise FW: start multiple lookups for each vrh->dele_chain
1353 // A.a <- ...
1354 // X.x <- C
1355 // Y.y <- C
1356 // if not X.x or Y.y == A.a start at X and at Y
1357 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1358 del_entry = del_entry->next)
1359 {
1360 if (0 != memcmp (&del_entry->delegate->issuer_key,
1361 &vrh->issuer_key,
1362 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey)))
1363 continue;
1364 if (0 !=
1365 strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
1366 continue;
1367 del_entry->refcount++;
1368 // Found match prematurely
1370 return 1;
1371 }
1372
1373 // None match, therefore start for every delegation found a lookup chain
1374 // Return and end collect process on first chain iss <-> sub found
1375
1376 // ds_entry created belongs to the first lookup, vrh still has the
1377 // issuer+attr we look for
1378 for (del_entry = vrh->del_chain_head; del_entry != NULL;
1379 del_entry = del_entry->next)
1380 {
1381
1383 "Looking for %s.%s\n",
1385 &del_entry->delegate->issuer_key),
1386 del_entry->delegate->issuer_attribute);
1387
1388 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
1389 GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
1390 ds_entry->from_bw = false;
1392 GNUNET_memcpy (ds_entry->issuer_key,
1393 &del_entry->delegate->subject_key,
1394 sizeof (struct GNUNET_CRYPTO_BlindablePublicKey));
1395
1398 del_entry->delegate->subject_key;
1399 ds_entry->delegation_chain_entry->subject_attribute = NULL;
1401 del_entry->delegate->issuer_key;
1404
1405 ds_entry->attr_trailer =
1407 ds_entry->handle = vrh;
1408
1409 vrh->pending_lookups++;
1410 // Start with forward resolution
1411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Forward Resolution\n");
1412
1413 ds_entry->lookup_request =
1416 &del_entry->delegate->issuer_key, // issuer_key,
1420 ds_entry);
1421 }
1422 return 0;
1423}
struct GNUNET_CRYPTO_BlindablePublicKey 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_blindable_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 1427 of file gnunet-service-abd.c.

1428{
1429 size_t msg_size;
1430 const char *attr;
1431
1432 msg_size = ntohs (v_msg->header.size);
1433 if (msg_size < sizeof (struct VerifyMessage))
1434 {
1435 GNUNET_break (0);
1436 return GNUNET_SYSERR;
1437 }
1438 if (ntohs (v_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1439 {
1440 GNUNET_break (0);
1441 return GNUNET_SYSERR;
1442 }
1443 attr = (const char *) &v_msg[1];
1444
1445 if (strlen (attr) > GNUNET_ABD_MAX_LENGTH)
1446 {
1447 GNUNET_break (0);
1448 return GNUNET_SYSERR;
1449 }
1450 return GNUNET_OK;
1451}
#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 1455 of file gnunet-service-abd.c.

1456{
1457 struct VerifyRequestHandle *vrh;
1458 struct GNUNET_SERVICE_Client *client = cls;
1459 struct DelegateRecordEntry *del_entry;
1460 uint32_t delegate_count;
1461 uint32_t delegate_data_size;
1462 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1463 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1464 char *attrptr = attr;
1465 char *delegate_data;
1466 const char *utf_in;
1467
1468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n");
1469 utf_in = (const char *) &v_msg[1];
1470 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1471 GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len));
1472 issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
1473 vrh = GNUNET_new (struct VerifyRequestHandle);
1474 vrh->is_collect = false;
1476 vrh->client = client;
1477 vrh->request_id = v_msg->id;
1478 vrh->issuer_key = v_msg->issuer_key;
1479 vrh->subject_key = v_msg->subject_key;
1480 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1481 vrh->resolution_algo = ntohs (v_msg->resolution_algo);
1482
1483 vrh->del_chain_head = NULL;
1484 vrh->del_chain_tail = NULL;
1485 vrh->dsq_head = NULL;
1486 vrh->dsq_tail = NULL;
1487 vrh->del_chain_head = NULL;
1488 vrh->del_chain_tail = NULL;
1489
1491 if (0 == strlen (issuer_attribute))
1492 {
1493 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1495 return;
1496 }
1497
1498 // Parse delegates from verifaction message
1499 delegate_count = ntohl (v_msg->d_count);
1500 delegate_data_size = ntohs (v_msg->header.size)
1501 - sizeof (struct VerifyMessage)
1502 - ntohs (v_msg->issuer_attribute_len) - 1;
1503 struct GNUNET_ABD_Delegate delegates[delegate_count];
1504 memset (delegates,
1505 0,
1506 sizeof (struct GNUNET_ABD_Delegate) * delegate_count);
1507 delegate_data = (char *) &v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1;
1508 if (GNUNET_OK != GNUNET_ABD_delegates_deserialize (delegate_data_size,
1509 delegate_data,
1510 delegate_count,
1511 delegates))
1512 {
1513 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n");
1515 return;
1516 }
1517
1518 // Prepare vrh delegation chain for later validation
1519 for (uint32_t i = 0; i < delegate_count; i++)
1520 {
1521 del_entry = GNUNET_new (struct DelegateRecordEntry);
1522 del_entry->delegate =
1523 GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate)
1524 + delegates[i].issuer_attribute_len + 1);
1525 GNUNET_memcpy (del_entry->delegate,
1526 &delegates[i],
1527 sizeof (struct GNUNET_ABD_Delegate));
1528 GNUNET_memcpy (&del_entry->delegate[1],
1529 delegates[i].issuer_attribute,
1530 delegates[i].issuer_attribute_len);
1531 del_entry->delegate->issuer_attribute_len =
1532 delegates[i].issuer_attribute_len;
1533 del_entry->delegate->issuer_attribute = (char *) &del_entry->delegate[1];
1535 vrh->del_chain_tail,
1536 del_entry);
1537 vrh->del_chain_size++;
1538 }
1539
1540 // Switch resolution algo
1543 {
1545 return;
1547 }
1549 {
1551 }
1553 {
1555 }
1556}
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:2433
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition strings.c:475
uint32_t issuer_attribute_len
Length of the issuer attribute.
Handle to a client that is connected to a service.
Definition service.c:249
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
Trust anchor.
Definition abd.h:89
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Subject public key.
Definition abd.h:84
uint16_t resolution_algo
Direction of the resolution algo.
Definition abd.h:104
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
enum GNUNET_ABD_AlgoDirectionFlags resolution_algo
Direction of the resolution algo.
struct GNUNET_CRYPTO_BlindablePublicKey subject_key
Subject public key.

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 1560 of file gnunet-service-abd.c.

1561{
1562 struct VerifyRequestHandle *vrh = cls;
1564 "Got disconnected from namestore database.\n");
1565 vrh->dele_qe = NULL;
1567}
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 1571 of file gnunet-service-abd.c.

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

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_BlindablePrivateKey key,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

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

1603{
1604 struct VerifyRequestHandle *vrh = cls;
1605 struct DelegateRecordEntry *del_entry;
1606 vrh->dele_qe = NULL;
1607
1608 for (uint32_t i = 0; i < rd_count; i++)
1609 {
1610 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
1611 continue;
1612 // only add the entries that are explicitly marked as private
1613 // and therefore symbolize the end of a chain
1614 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
1615 continue;
1616 del_entry = GNUNET_new (struct DelegateRecordEntry);
1617 del_entry->delegate = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].
1618 data_size);
1619 if (NULL == del_entry->delegate)
1620 {
1621 GNUNET_free (del_entry);
1622 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
1623 continue;
1624 }
1626 vrh->del_chain_tail,
1627 del_entry);
1628 vrh->del_chain_size++;
1629 }
1630
1632}
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 1636 of file gnunet-service-abd.c.

1637{
1638 char attr[GNUNET_ABD_MAX_LENGTH + 1];
1639 char issuer_attribute[GNUNET_ABD_MAX_LENGTH + 1];
1640 struct VerifyRequestHandle *vrh;
1641 struct GNUNET_SERVICE_Client *client = cls;
1642 char *attrptr = attr;
1643 const char *utf_in;
1644
1645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received COLLECT message\n");
1646
1647 utf_in = (const char *) &c_msg[1];
1648 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1649
1650 GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len));
1651 issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0';
1652 vrh = GNUNET_new (struct VerifyRequestHandle);
1653 vrh->is_collect = true;
1655 vrh->client = client;
1656 vrh->request_id = c_msg->id;
1657 vrh->issuer_key = c_msg->issuer_key;
1659 );
1660 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
1661 vrh->resolution_algo = ntohs (c_msg->resolution_algo);
1662
1663 vrh->del_chain_head = NULL;
1664 vrh->del_chain_tail = NULL;
1665 vrh->dsq_head = NULL;
1666 vrh->dsq_tail = NULL;
1667 vrh->del_chain_head = NULL;
1668 vrh->del_chain_tail = NULL;
1669
1670 if (0 == strlen (issuer_attribute))
1671 {
1672 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n");
1674 return;
1675 }
1676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting delegates for subject\n");
1677
1678 // Get all delegates from subject
1679 vrh->dele_qe =
1681 &c_msg->subject_key,
1684 vrh,
1686 vrh);
1688}
static void handle_delegate_collection_error_cb(void *cls)
static void handle_delegate_collection_cb(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_key_get_public(const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Retrieves the public key representation of a private key.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *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_BlindablePrivateKey subject_key
Subject public key.
Definition abd.h:45
uint16_t resolution_algo
Direction of the resolution algo.
Definition abd.h:60
struct GNUNET_CRYPTO_BlindablePublicKey issuer_key
Trust anchor.
Definition abd.h:50
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition abd.h:55
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_blindable_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 1692 of file gnunet-service-abd.c.

1693{
1694 size_t msg_size;
1695 const char *attr;
1696
1697 msg_size = ntohs (c_msg->header.size);
1698 if (msg_size < sizeof (struct CollectMessage))
1699 {
1700 GNUNET_break (0);
1701 return GNUNET_SYSERR;
1702 }
1703 if (ntohs (c_msg->issuer_attribute_len) > GNUNET_ABD_MAX_LENGTH)
1704 {
1705 GNUNET_break (0);
1706 return GNUNET_SYSERR;
1707 }
1708 attr = (const char *) &c_msg[1];
1709
1710 if (('\0' != attr[msg_size - sizeof (struct CollectMessage) - 1]) ||
1711 (strlen (attr) > GNUNET_ABD_MAX_LENGTH))
1712 {
1713 GNUNET_break (0);
1714 return GNUNET_SYSERR;
1715 }
1716 return GNUNET_OK;
1717}
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 1721 of file gnunet-service-abd.c.

1724{
1725 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1726}

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 1730 of file gnunet-service-abd.c.

1733{
1734 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1735 return client;
1736}

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 1747 of file gnunet-service-abd.c.

1750{
1751
1752 gns = GNUNET_GNS_connect (c);
1753 if (NULL == gns)
1754 {
1755 fprintf (stderr, _ ("Failed to connect to GNS\n"));
1756 }
1758 if (NULL == namestore)
1759 {
1760 fprintf (stderr, _ ("Failed to connect to namestore\n"));
1761 }
1762
1765}
struct GNUNET_SCHEDULER_Task * shutdown_task
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:179

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().