42 #define GNUNET_ABD_MAX_LENGTH 255 353 "%s %s.%s <- %s.%s\n",
442 while (NULL != (vrh = vrh_head))
454 if (NULL != namestore)
459 if (NULL != statistics)
504 rmsg->
is_bw = htons (is_bw);
505 rmsg->
size = htonl (size);
531 dce = vrh->delegation_chain_head;
532 for (uint32_t i = 0; i < vrh->delegation_chain_size; i++)
549 for (del = vrh->del_chain_head; NULL != del;)
561 vrh->del_chain_size--;
566 del = vrh->del_chain_head;
567 for (uint32_t i = 0; i < vrh->del_chain_size; i++)
588 rmsg->
id = vrh->request_id;
589 rmsg->
d_count = htonl (vrh->delegation_chain_size);
590 rmsg->
c_count = htonl (vrh->del_chain_size);
592 if (0 < vrh->del_chain_size)
610 "Completed verifications",
622 char *saveptr1, *saveptr2;
630 trail_token = strtok_r (tmp_trail,
".", &saveptr1);
631 sub_token = strtok_r (tmp_subattr,
".", &saveptr2);
632 while (NULL != trail_token && NULL != sub_token)
634 if (0 == strcmp (trail_token, sub_token))
644 trail_token = strtok_r (NULL,
".", &saveptr1);
645 sub_token = strtok_r (NULL,
".", &saveptr2);
652 if (NULL == trail_token)
662 trail_token = strtok_r (NULL,
".", &saveptr1);
663 while (NULL != trail_token)
666 trail_token = strtok_r (NULL,
".", &saveptr1);
668 GNUNET_asprintf (&attr_trailer,
"%s.%s", issuer_attribute, attr_trailer);
688 last_entry = fw_entry;
689 fw_entry = old_fw_parent;
696 del_entry = del_entry->
next)
699 &del_entry->delegate->issuer_key,
703 del_entry->delegate->issuer_attribute))
708 del_entry->refcount++;
713 tmp_set = tmp_set->parent_queue_entry->
parent_set)
715 tmp_set->parent_queue_entry->required_solutions--;
721 tmp_set->delegation_chain_entry);
727 if (0 < tmp_set->parent_queue_entry->required_solutions)
730 "Chain requires more solutions, waiting...\n");
753 vrh = current_set->
handle;
757 for (uint32_t i = 0; i < rd_count; i++)
830 "Entry not relevant, discarding: %s.%s <- %s.%s\n",
898 del_entry = del_entry->
next)
900 if (0 == memcmp (&del_entry->delegate->issuer_key,
904 if (0 == strcmp (del_entry->delegate->issuer_attribute,
907 del_entry->refcount++;
921 del_entry = del_entry->
next)
924 if (del_entry->from_bw)
927 if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key,
932 if (0 == strcmp (del_entry->unresolved_attribute_delegation,
937 "Forward: Found match with above!\n");
956 "Starting to look up trailer %s in zone %s\n",
992 char *lookup_attribute;
996 vrh = current_set->
handle;
1000 for (uint32_t i = 0; i < rd_count; i++)
1008 "Found new attribute delegation with %d sets. Creating new Job...\n",
1009 ntohl (sets->set_count));
1014 (
const char *) &sets[1],
1015 ntohl (sets->set_count),
1029 for (uint32_t j = 0; j < ntohl (sets->set_count); j++)
1056 "Not Expanding %s\n",
1069 &
set[j].subject_key,
1089 del_pointer = del_pointer->
next)
1097 "Checking if %s matches %s\n",
1138 "Building new lookup request from %s\n",
1141 char issuer_attribute_name[strlen (
1145 char *next_attr = strtok (issuer_attribute_name,
".");
1146 if (NULL == next_attr)
1149 "Failed to parse next attribute\n");
1154 if (strlen (next_attr) ==
1161 next_attr += strlen (next_attr) + 1;
1168 del_entry = del_entry->
next)
1171 if (! del_entry->from_bw)
1174 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
1179 if (0 == strcmp (del_entry->attr_trailer,
1184 "Backward: Found match with above!\n");
1205 "%s still to go...\n",
1261 del_entry = del_entry->
next)
1283 issuer_attribute_name);
1307 issuer_attribute_name,
1343 del_entry = del_entry->
next)
1364 del_entry = del_entry->
next)
1368 "Looking for %s.%s\n",
1428 attr = (
const char *) &v_msg[1];
1445 uint32_t delegate_count;
1446 uint32_t delegate_data_size;
1449 char *attrptr = attr;
1450 char *delegate_data;
1454 utf_in = (
const char *) &v_msg[1];
1476 if (0 == strlen (issuer_attribute))
1484 delegate_count = ntohl (v_msg->
d_count);
1485 delegate_data_size = ntohs (v_msg->
header.
size)
1487 - ntohs (v_msg->issuer_attribute_len) - 1;
1504 for (uint32_t i = 0; i < delegate_count; i++)
1509 + delegates[i].issuer_attribute_len + 1);
1549 "Got disconnected from namestore database.\n");
1585 unsigned int rd_count,
1591 int cred_record_count;
1592 cred_record_count = 0;
1595 for (uint32_t i = 0; i < rd_count; i++)
1599 cred_record_count++;
1630 char *attrptr = attr;
1635 utf_in = (
const char *) &c_msg[1];
1657 if (0 == strlen (issuer_attribute))
1695 attr = (
const char *) &c_msg[1];
1697 if ((
'\0' != attr[msg_size -
sizeof (
struct CollectMessage) - 1]) ||
1742 fprintf (stderr,
_ (
"Failed to connect to GNS\n"));
1745 if (NULL == namestore)
1747 fprintf (stderr,
_ (
"Failed to connect to namestore\n"));
uint64_t pending_lookups
Pending lookups.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct VerifyRequestHandle * next
We keep these in a DLL.
Connection to the GNS service.
Message from client to Credential service to verify attributes.
#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT
static void cleanup_handle(struct VerifyRequestHandle *vrh)
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
uint32_t id
Unique identifier for this request (for key collisions).
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Public key of the subject this credential was issued to.
struct DelegationQueueEntry * parent
Parent attribute delegation.
struct DelegationChainEntry * prev
DLL.
struct DelegationChainEntry * delegation_chain_tail
Children of this attribute.
static void handle_verify(void *cls, const struct VerifyMessage *v_msg)
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_IDENTITY_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.
IPC messages between ABD API and ABD service.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
uint32_t issuer_attribute_len
Length of the attribute.
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
The subject.
struct VerifyRequestHandle * prev
We keep these in a DLL.
uint16_t issuer_attribute_len
Length of the issuer attribute.
int GNUNET_ABD_delegates_deserialize(size_t len, const char *src, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
Deserialize the given destination.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
struct DelegationSetQueueEntry * dsq_tail
List for bidirectional matching.
uint16_t resolution_algo
Direction of the resolution algo.
uint32_t id
Unique identifier for this request (for key collisions).
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Message from ABD service to client: new results.
struct DelegateRecordEntry * prev
DLL.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
char * issuer_attribute
Issuer attribute.
static size_t data_size
Number of bytes in data.
struct GNUNET_ABD_Delegate * delegate
Payload.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct DelegationChainEntry * delegation_chain_entry
The delegation chain entry.
Handle to a lookup request.
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
Trust anchor.
static struct VerifyRequestHandle * vrh_head
Head of the DLL.
GNUNET_ABD_AlgoDirectionFlags
static void send_lookup_response(struct VerifyRequestHandle *vrh)
The attribute delegation record.
char * issuer_attribute
Issuer attribute delegated to.
Message from client to Credential service to collect credentials.
static void handle_delegate_collection_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
char * issuer_attribute
The issued attribute.
DLL for delegation sets Used for AND delegation set.
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Subject public key.
bool is_collect
True if created by a collect request.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
static int check_verify(void *cls, const struct VerifyMessage *v_msg)
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
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 DelegationSetQueueEntry * next
DLL.
struct DelegateRecordEntry * del_chain_tail
Delegate DLL.
struct GNUNET_CRYPTO_EcdsaSignature signature
Signature of this credential.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
bool from_bw
True if added by backward resolution.
struct GNUNET_GNS_LookupRequest * lookup_request
GNS handle.
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
The issuer of the credential.
static char * partial_match(char *tmp_trail, char *tmp_subattr, char *parent_trail, char *issuer_attribute)
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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum GNUNET_ABD_AlgoDirectionFlags resolution_algo
Direction of the resolution algo.
struct DelegationQueueEntry * queue_entries_head
Queue entries of this set.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *handle)
Process Credential requests.
Handle to a client that is connected to a service.
struct DelegationChainEntry * next
DLL.
uint32_t request_id
request id
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
Issuer public key.
struct DelegationQueueEntry * current_delegation
Current Delegation Pointer.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
static int delegation_chain_fw_resolution_start(void *cls)
#define GNUNET_GNSRECORD_TYPE_DELEGATE
65546 reserved
static int delegation_chain_bw_resolution_start(void *cls)
Result from GNS lookup.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_deserialize(const char *data, size_t data_size)
uint32_t del_chain_size
Delegate DLL size.
const void * data
Binary value stored in the DNS record.
static int del
Desired action is to remove a record.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static void backward_resolution(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Connection to the NAMESTORE service.
struct DelegationSetQueueEntry * prev
DLL.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
uint32_t subject_attribute_len
Length of the subject attribute.
uint16_t resolution_algo
Direction of the resolution algo.
static void handle_delegate_collection_error_cb(void *cls)
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct VerifyRequestHandle * handle
Verify handle.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
This is a private record of this peer and it should thus not be handed out to other peers...
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
The issuer of the delegation.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
char * GNUNET_CRYPTO_ecdsa_public_key_to_string(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a public key to a string.
struct DelegationChainEntry * delegation_chain_head
Children of this attribute.
static void forward_resolution(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
static int collect
Collect mode.
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY
uint32_t issuer_attribute_len
Length of the issuer attribute.
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...
struct GNUNET_HashCode key
The key used in the DHT.
uint32_t refcount
Number of references in delegation chains.
static unsigned int size
Size of the "table".
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
struct DelegateRecordEntry * del_chain_head
Delegate DLL.
static void handle_collect(void *cls, const struct CollectMessage *c_msg)
Handle to a lookup operation from api.
uint32_t delegation_chain_size
Size of delegation tree.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct GNUNET_MQ_Envelope * env
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint32_t id
Unique identifier for this request (for key collisions).
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
struct DelegationQueueEntry * queue_entries_tail
Queue entries of this set.
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT
const char * subject_attribute
The attribute.
char * attr_trailer
Trailing attribute context.
const char * subject_attribute
The subject attribute.
static void delegate_collection_finished(void *cls)
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.
uint32_t d_count
Number of delegates.
struct GNUNET_CRYPTO_EcdsaPrivateKey subject_key
Subject public key.
Handle to a message queue.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_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.
uint32_t subject_attribute_len
GNUNET_SERVICE_MAIN("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.
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Public key of the subject this attribute was delegated to.
The attribute delegation record.
#define GNUNET_MESSAGE_TYPE_ABD_COLLECT
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static int check_collect(void *cls, const struct CollectMessage *c_msg)
struct DelegationQueueEntry * next
DLL.
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
Record type for reverse lookups.
struct GNUNET_MQ_Handle * mq
#define GNUNET_log(kind,...)
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Subject public key.
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
struct GNUNET_NAMESTORE_QueueEntry * dele_qe
Delegate iterator for lookup.
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
struct GNUNET_CRYPTO_EcdsaPublicKey * issuer_key
Issuer key.
struct DelegationSetQueueEntry * dsq_head
List for bidirectional matching.
struct GNUNET_SERVICE_Client * client
Handle to the requesting client.
uint16_t issuer_attribute_len
Length of the issuer attribute.
uint32_t del_found
Indicates if credential has been found at all.
char * subject_attribute
The delegated attribute.
Defaults, look in cache, then in DHT.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
#define GNUNET_ABD_MAX_LENGTH
uint32_t required_solutions
Required solutions.
static struct VerifyRequestHandle * vrh_tail
Tail of the DLL.
static struct GNUNET_GNS_Handle * gns
Handle to GNS service.
const char * issuer_attribute
The attribute.
const char * issuer_attribute
The issuer attribute.
static void shutdown_task(void *cls)
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
Trust anchor.
static void send_intermediate_response(struct VerifyRequestHandle *vrh, struct DelegationChainEntry *ch_entry, bool is_bw)
static void cleanup_dsq_entry(struct DelegationSetQueueEntry *ds_entry)
static int verify
Verify mode.
uint32_t data
The data value.
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
The issuer.
static void print_deleset(struct DelegationSetQueueEntry *dsentry, char *text)
API to serialize and deserialize delegation chains and abds.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
struct DelegationQueueEntry * parent_queue_entry
Parent QueueEntry.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
uint32_t subject_attribute_len
Length of the attribute.
uint32_t d_count
The number of delegations in the response.
#define GNUNET_malloc(size)
Wrapper around malloc.
static struct GNUNET_NAMESTORE_Handle * namestore
Handle to namestore service.
static int handle_bidirectional_match(struct DelegationSetQueueEntry *actual_entry, struct DelegationSetQueueEntry *match_entry, struct VerifyRequestHandle *vrh)
char * unresolved_attribute_delegation
Still to resolve delegation as string.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
uint32_t c_count
The number of credentials in the response.
#define GNUNET_free(ptr)
Wrapper around free.
struct DelegationQueueEntry * prev
DLL.
DLL used for delegations Used for OR delegations.
struct DelegationSetQueueEntry * parent_set
Parent set.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
struct DelegateRecordEntry * next
DLL.
char * lookup_attribute
The current attribute to look up.