40#define GNUNET_ABD_MAX_LENGTH 255
351 "%s %s.%s <- %s.%s\n",
502 rmsg->
is_bw = htons (is_bw);
551 if (
del->refcount > 0)
610 "Completed verifications",
620 char *issuer_attribute)
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");
754 vrh = current_set->
handle;
758 for (uint32_t i = 0; i <
rd_count; i++)
803 if (0 ==
del->subject_attribute_len)
810 del->issuer_attribute,
813 else if (0 == strcmp (
del->subject_attribute, current_set->
attr_trailer))
834 "Entry not relevant, discarding: %s.%s <- %s.%s\n",
837 del->issuer_attribute,
840 del->subject_attribute);
862 if (0 <
del->subject_attribute_len)
877 if (0 == memcmp (&
del->issuer_key,
908 del_entry = del_entry->
next)
910 if (0 == memcmp (&del_entry->delegate->issuer_key,
914 if (0 == strcmp (del_entry->delegate->issuer_attribute,
917 del_entry->refcount++;
932 del_entry = del_entry->
next)
935 if (del_entry->from_bw)
938 if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key,
943 if (0 == strcmp (del_entry->unresolved_attribute_delegation,
948 "Forward: Found match with above!\n");
968 "Starting to look up trailer %s in zone %s\n",
1004 char *expanded_attr;
1005 char *lookup_attribute;
1009 vrh = current_set->
handle;
1013 for (uint32_t i = 0; i <
rd_count; i++)
1021 "Found new attribute delegation with %d sets. Creating new Job...\n",
1022 ntohl (sets->set_count));
1027 (
const char *) &sets[1],
1028 ntohl (sets->set_count),
1042 for (uint32_t j = 0; j < ntohl (sets->set_count); j++)
1069 "Not Expanding %s\n",
1102 del_pointer = del_pointer->
next)
1110 "Checking if %s matches %s\n",
1151 "Building new lookup request from %s\n",
1154 char issuer_attribute_name[strlen (
1158 char *next_attr = strtok (issuer_attribute_name,
".");
1159 if (NULL == next_attr)
1162 "Failed to parse next attribute\n");
1167 if (strlen (next_attr) ==
1174 next_attr += strlen (next_attr) + 1;
1181 del_entry = del_entry->
next)
1184 if (! del_entry->from_bw)
1187 if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
1192 if (0 == strcmp (del_entry->attr_trailer,
1197 "Backward: Found match with above!\n");
1218 "%s still to go...\n",
1274 del_entry = del_entry->
next)
1296 issuer_attribute_name);
1320 issuer_attribute_name,
1356 del_entry = del_entry->
next)
1377 del_entry = del_entry->
next)
1381 "Looking for %s.%s\n",
1441 attr = (
const char *) &v_msg[1];
1458 uint32_t delegate_count;
1459 uint32_t delegate_data_size;
1462 char *attrptr = attr;
1463 char *delegate_data;
1467 utf_in = (
const char *) &v_msg[1];
1489 if (0 == strlen (issuer_attribute))
1497 delegate_count = ntohl (v_msg->
d_count);
1498 delegate_data_size = ntohs (v_msg->
header.
size)
1517 for (uint32_t i = 0; i < delegate_count; i++)
1562 "Got disconnected from namestore database.\n");
1605 for (uint32_t i = 0; i <
rd_count; i++)
1639 char *attrptr = attr;
1644 utf_in = (
const char *) &c_msg[1];
1666 if (0 == strlen (issuer_attribute))
1704 attr = (
const char *) &c_msg[1];
1706 if ((
'\0' != attr[msg_size -
sizeof (
struct CollectMessage) - 1]) ||
1751 fprintf (stderr,
_ (
"Failed to connect to GNS\n"));
1756 fprintf (stderr,
_ (
"Failed to connect to namestore\n"));
struct GNUNET_MQ_Handle * mq
struct GNUNET_MQ_Envelope * env
IPC messages between ABD API and ABD service.
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_deserialize(const char *data, size_t data_size)
int GNUNET_ABD_delegates_deserialize(size_t len, const char *src, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
Deserialize the given destination.
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.
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.
API to serialize and deserialize delegation chains and abds.
static int collect
Collect mode.
static int verify
Verify mode.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in 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 int del
Desired action is to remove a record.
static size_t data_size
Number of bytes in data.
static void handle_collect(void *cls, const struct CollectMessage *c_msg)
static struct GNUNET_GNS_Handle * gns
Handle to GNS service.
static struct VerifyRequestHandle * vrh_tail
Tail of the DLL.
static void forward_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 void cleanup_handle(struct VerifyRequestHandle *vrh)
static int check_verify(void *cls, const struct VerifyMessage *v_msg)
static struct VerifyRequestHandle * vrh_head
Head of the DLL.
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.
static void handle_delegate_collection_error_cb(void *cls)
static void shutdown_task(void *cls)
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
static int handle_bidirectional_match(struct DelegationSetQueueEntry *actual_entry, struct DelegationSetQueueEntry *match_entry, struct VerifyRequestHandle *vrh)
static int delegation_chain_fw_resolution_start(void *cls)
static void cleanup_dsq_entry(struct DelegationSetQueueEntry *ds_entry)
static struct GNUNET_NAMESTORE_Handle * namestore
Handle to namestore service.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *handle)
Process Credential requests.
static void delegate_collection_finished(void *cls)
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 backward_resolution(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
static void handle_verify(void *cls, const struct VerifyMessage *v_msg)
static int check_collect(void *cls, const struct CollectMessage *c_msg)
static void send_lookup_response(struct VerifyRequestHandle *vrh)
#define GNUNET_ABD_MAX_LENGTH
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 struct GNUNET_VPN_Handle * handle
Handle to vpn service.
API to the Credential service.
API that can be used to manipulate GNS record data.
Identity service; implements identity management for GNUnet.
API that can be used to store naming information on a GNUnet node;.
Constants for network protocols.
API to create, modify and access statistics.
GNUNET_ABD_AlgoDirectionFlags
@ GNUNET_ABD_FLAG_BACKWARD
@ GNUNET_ABD_FLAG_FORWARD
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
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.
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
@ 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).
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
#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.
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.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#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_MQ_hd_var_size(name, code, str, ctx)
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.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT
#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT
#define GNUNET_MESSAGE_TYPE_ABD_COLLECT
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY
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,...
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
static unsigned int size
Size of the "table".
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
For ABD reverse lookups.
#define GNUNET_GNSRECORD_TYPE_DELEGATE
For ABD policies.
Message from client to Credential service to collect credentials.
struct GNUNET_CRYPTO_PublicKey issuer_key
Trust anchor.
uint16_t resolution_algo
Direction of the resolution algo.
uint16_t issuer_attribute_len
Length of the issuer attribute.
struct GNUNET_CRYPTO_PrivateKey subject_key
Subject public key.
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
uint32_t id
Unique identifier for this request (for key collisions).
uint32_t refcount
Number of references in delegation chains.
struct DelegateRecordEntry * prev
DLL.
struct GNUNET_ABD_Delegate * delegate
Payload.
struct DelegateRecordEntry * next
DLL.
struct DelegationChainEntry * prev
DLL.
char * subject_attribute
The delegated attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer.
struct DelegationChainEntry * next
DLL.
struct GNUNET_CRYPTO_PublicKey subject_key
The subject.
char * issuer_attribute
The issued attribute.
Message from ABD service to client: new results.
uint32_t del_found
Indicates if credential has been found at all.
uint32_t d_count
The number of delegations in the response.
uint32_t id
Unique identifier for this request (for key collisions).
uint32_t c_count
The number of credentials in the response.
DLL used for delegations Used for OR delegations.
struct DelegationQueueEntry * next
DLL.
struct DelegationQueueEntry * prev
DLL.
uint32_t required_solutions
Required solutions.
struct DelegationSetQueueEntry * parent_set
Parent set.
DLL for delegation sets Used for AND delegation set.
char * lookup_attribute
The current attribute to look up.
struct DelegationQueueEntry * parent_queue_entry
Parent QueueEntry.
char * attr_trailer
Trailing attribute context.
struct DelegationSetQueueEntry * prev
DLL.
char * issuer_attribute
Issuer attribute delegated to.
struct DelegationChainEntry * delegation_chain_entry
The delegation chain entry.
struct VerifyRequestHandle * handle
Verify handle.
struct DelegationQueueEntry * parent
Parent attribute delegation.
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 DelegationSetQueueEntry * next
DLL.
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.
const char * subject_attribute
The subject attribute.
const char * issuer_attribute
The issuer attribute.
uint32_t issuer_attribute_len
Length of the issuer attribute.
uint32_t subject_attribute_len
Length of the subject attribute.
struct GNUNET_CRYPTO_Signature signature
Signature of this credential.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer of the credential.
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this credential was issued to.
The attribute delegation 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.
uint32_t subject_attribute_len
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.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
const void * data
Binary value stored in the DNS record.
Connection to the GNS service.
Handle to a lookup request.
Handle to a message queue.
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Handle to a client that is connected to a service.
Message from client to Credential service to verify attributes.
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY.
uint16_t resolution_algo
Direction of the resolution algo.
struct GNUNET_CRYPTO_PublicKey subject_key
Subject public key.
uint32_t id
Unique identifier for this request (for key collisions).
uint32_t d_count
Number of delegates.
uint16_t issuer_attribute_len
Length of the issuer attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
Trust anchor.
Handle to a lookup operation from api.
struct VerifyRequestHandle * prev
We keep these in a DLL.
struct GNUNET_NAMESTORE_QueueEntry * dele_qe
Delegate iterator for lookup.
struct GNUNET_SERVICE_Client * client
Handle to the requesting client.
struct GNUNET_CRYPTO_PublicKey subject_key
Subject public key.
uint32_t request_id
request id
struct DelegationQueueEntry * current_delegation
Current Delegation Pointer.
struct VerifyRequestHandle * next
We keep these in a DLL.
enum GNUNET_ABD_AlgoDirectionFlags resolution_algo
Direction of the resolution algo.
uint32_t del_chain_size
Delegate DLL size.
uint64_t pending_lookups
Pending lookups.
struct DelegationSetQueueEntry * dsq_head
List for bidirectional matching.
uint32_t delegation_chain_size
Size of delegation tree.
struct DelegationSetQueueEntry * dsq_tail
List for bidirectional matching.
struct GNUNET_CRYPTO_PublicKey issuer_key
Issuer public key.
struct DelegationChainEntry * delegation_chain_tail
Children of this attribute.
struct DelegateRecordEntry * del_chain_head
Delegate DLL.
bool is_collect
True if created by a collect request.
struct DelegateRecordEntry * del_chain_tail
Delegate DLL.
char * issuer_attribute
Issuer attribute.
struct DelegationChainEntry * delegation_chain_head
Children of this attribute.