summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Ebner <pansy007@googlemail.com>2019-08-04 13:52:03 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-07 12:16:50 +0200
commit15b0d71a635f02f5e0291a695d35a65698fdea05 (patch)
tree5afc234a0ce848019d1098f3852fde06f14dcd98
parent93cd93a1330fb38add615f797ac9a87fc252ff98 (diff)
Clean up and renaming
- renamed a lot of variables/functions that no longer serve credential but delegate - correct printouts likewise - cleaned up test_credential_own.sh to use credential service issuer side storage - removed credential related parameters from VerifyRequestHandle struct
-rw-r--r--src/credential/credential.h6
-rw-r--r--src/credential/credential_api.c37
-rw-r--r--src/credential/credential_serialization.c12
-rw-r--r--src/credential/credential_serialization.h6
-rw-r--r--src/credential/gnunet-credential.c20
-rw-r--r--src/credential/gnunet-service-credential.c217
-rw-r--r--src/credential/plugin_gnsrecord_credential.c4
-rwxr-xr-xsrc/credential/test_credential_own.sh58
8 files changed, 134 insertions, 226 deletions
diff --git a/src/credential/credential.h b/src/credential/credential.h
index 97fdfecbf..ca8fb78d7 100644
--- a/src/credential/credential.h
+++ b/src/credential/credential.h
@@ -91,9 +91,9 @@ struct VerifyMessage
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
/**
- * Number of credentials
+ * Number of delegates
*/
- uint32_t c_count;
+ uint32_t d_count;
/**
* Length of the issuer attribute
@@ -132,7 +132,7 @@ struct DelegationChainResultMessage
/**
* Indicates if credential has been found at all
*/
- uint32_t cred_found GNUNET_PACKED;
+ uint32_t del_found GNUNET_PACKED;
/**
* The number of delegations in the response
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c
index 7323d3b1c..4fe32465a 100644
--- a/src/credential/credential_api.c
+++ b/src/credential/credential_api.c
@@ -217,8 +217,7 @@ handle_result (void *cls,
uint32_t d_count = ntohl (vr_msg->d_count);
uint32_t c_count = ntohl (vr_msg->c_count);
struct GNUNET_CREDENTIAL_Delegation d_chain[d_count];
- //TODO rename creds
- struct GNUNET_CREDENTIAL_Delegate creds[c_count];
+ struct GNUNET_CREDENTIAL_Delegate dels[c_count];
GNUNET_CREDENTIAL_CredentialResultProcessor proc;
void *proc_cls;
@@ -242,8 +241,8 @@ handle_result (void *cls,
d_count,
d_chain,
c_count,
- creds));
- if (GNUNET_NO == ntohl (vr_msg->cred_found))
+ dels));
+ if (GNUNET_NO == ntohl (vr_msg->del_found))
{
proc (proc_cls,
0,
@@ -255,7 +254,7 @@ handle_result (void *cls,
d_count,
d_chain,
c_count,
- creds);
+ dels);
}
}
@@ -415,8 +414,8 @@ GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle,
c_msg->subject_key = *subject_key;
c_msg->issuer_key = *issuer_key;
c_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
- //c_msg->resolution_algo = htons(Backward);
- c_msg->resolution_algo = htons(Forward);
+ c_msg->resolution_algo = htons(Backward);
+ //c_msg->resolution_algo = htons(Forward);
GNUNET_memcpy (&c_msg[1],
issuer_attribute,
@@ -441,8 +440,8 @@ GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle,
* @param issuer_key the issuer public key
* @param issuer_attribute the issuer attribute
* @param subject_key the subject public key
- * @param credential_count number of credentials provided
- * @param credentials subject credentials
+ * @param delegate_count number of delegates provided
+ * @param delegates subject delegates
* @param proc function to call on result
* @param proc_cls closure for processor
* @return handle to the queued request
@@ -452,8 +451,8 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
const char *issuer_attribute,
const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
- uint32_t credential_count,
- const struct GNUNET_CREDENTIAL_Delegate *credentials,
+ uint32_t delegate_count,
+ const struct GNUNET_CREDENTIAL_Delegate *delegates,
GNUNET_CREDENTIAL_CredentialResultProcessor proc,
void *proc_cls)
{
@@ -463,14 +462,14 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
size_t nlen;
size_t clen;
- if (NULL == issuer_attribute || NULL == credentials)
+ if (NULL == issuer_attribute || NULL == delegates)
{
GNUNET_break (0);
return NULL;
}
- clen = GNUNET_CREDENTIAL_credentials_get_size (credential_count,
- credentials);
+ clen = GNUNET_CREDENTIAL_delegates_get_size (delegate_count,
+ delegates);
//DEBUG LOG
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -492,17 +491,17 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY);
v_msg->id = htonl (vr->r_id);
v_msg->subject_key = *subject_key;
- v_msg->c_count = htonl(credential_count);
+ v_msg->d_count = htonl(delegate_count);
v_msg->issuer_key = *issuer_key;
v_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
- //v_msg->resolution_algo = htons(Backward);
- v_msg->resolution_algo = htons(Forward);
+ v_msg->resolution_algo = htons(Backward);
+ //v_msg->resolution_algo = htons(Forward);
GNUNET_memcpy (&v_msg[1],
issuer_attribute,
strlen (issuer_attribute));
- GNUNET_CREDENTIAL_credentials_serialize (credential_count,
- credentials,
+ GNUNET_CREDENTIAL_delegates_serialize (delegate_count,
+ delegates,
clen,
((char*)&v_msg[1])
+ strlen (issuer_attribute) + 1);
diff --git a/src/credential/credential_serialization.c b/src/credential/credential_serialization.c
index 4f3b11450..65a85e37e 100644
--- a/src/credential/credential_serialization.c
+++ b/src/credential/credential_serialization.c
@@ -147,7 +147,7 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (
* @return the required size to serialize
*/
size_t
-GNUNET_CREDENTIAL_credentials_get_size (
+GNUNET_CREDENTIAL_delegates_get_size (
unsigned int c_count,
const struct GNUNET_CREDENTIAL_Delegate *cd)
{
@@ -173,7 +173,7 @@ GNUNET_CREDENTIAL_credentials_get_size (
* @return the size of the data, -1 on failure
*/
ssize_t
-GNUNET_CREDENTIAL_credentials_serialize (
+GNUNET_CREDENTIAL_delegates_serialize (
unsigned int c_count,
const struct GNUNET_CREDENTIAL_Delegate *cd,
size_t dest_size,
@@ -221,7 +221,7 @@ GNUNET_CREDENTIAL_credentials_serialize (
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
-GNUNET_CREDENTIAL_credentials_deserialize (
+GNUNET_CREDENTIAL_delegates_deserialize (
size_t len,
const char *src,
unsigned int c_count,
@@ -281,7 +281,7 @@ GNUNET_CREDENTIAL_delegation_chain_get_size (
(ret + dd[i].issuer_attribute_len + dd[i].subject_attribute_len) >= ret);
ret += dd[i].issuer_attribute_len + dd[i].subject_attribute_len;
}
- return ret + GNUNET_CREDENTIAL_credentials_get_size (c_count, cd);
+ return ret + GNUNET_CREDENTIAL_delegates_get_size (c_count, cd);
}
/**
@@ -334,7 +334,7 @@ GNUNET_CREDENTIAL_delegation_chain_serialize (
dd[i].subject_attribute_len);
off += dd[i].subject_attribute_len;
}
- return off + GNUNET_CREDENTIAL_credentials_serialize (c_count,
+ return off + GNUNET_CREDENTIAL_delegates_serialize (c_count,
cd,
dest_size - off,
&dest[off]);
@@ -385,7 +385,7 @@ GNUNET_CREDENTIAL_delegation_chain_deserialize (
dd[i].subject_attribute = &src[off];
off += dd[i].subject_attribute_len;
}
- return GNUNET_CREDENTIAL_credentials_deserialize (len - off,
+ return GNUNET_CREDENTIAL_delegates_deserialize (len - off,
&src[off],
c_count,
cd);
diff --git a/src/credential/credential_serialization.h b/src/credential/credential_serialization.h
index 072beb44e..12988354b 100644
--- a/src/credential/credential_serialization.h
+++ b/src/credential/credential_serialization.h
@@ -131,18 +131,18 @@ GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
unsigned int c_count,
struct GNUNET_CREDENTIAL_Delegate *cd);
size_t
- GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count,
+ GNUNET_CREDENTIAL_delegates_get_size (unsigned int c_count,
const struct GNUNET_CREDENTIAL_Delegate *cd);
ssize_t
-GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count,
+GNUNET_CREDENTIAL_delegates_serialize (unsigned int c_count,
const struct GNUNET_CREDENTIAL_Delegate *cd,
size_t dest_size,
char *dest);
int
-GNUNET_CREDENTIAL_credentials_deserialize (size_t len,
+GNUNET_CREDENTIAL_delegates_deserialize (size_t len,
const char *src,
unsigned int c_count,
struct GNUNET_CREDENTIAL_Delegate *cd);
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c
index 64f5c5a5f..07148a1b5 100644
--- a/src/credential/gnunet-credential.c
+++ b/src/credential/gnunet-credential.c
@@ -254,17 +254,17 @@ handle_collect_result (void *cls,
unsigned int d_count,
struct GNUNET_CREDENTIAL_Delegation *dc,
unsigned int c_count,
- struct GNUNET_CREDENTIAL_Delegate *cred)
+ struct GNUNET_CREDENTIAL_Delegate *dele)
{
int i;
char *line;
verify_request = NULL;
- if (NULL != cred)
+ if (NULL != dele)
{
for (i = 0; i < c_count; i++)
{
- line = GNUNET_CREDENTIAL_delegate_to_string (&cred[i]);
+ line = GNUNET_CREDENTIAL_delegate_to_string (&dele[i]);
printf ("%s\n", line);
GNUNET_free (line);
}
@@ -272,7 +272,6 @@ handle_collect_result (void *cls,
printf("Received NULL\n");
}
-
GNUNET_SCHEDULER_shutdown ();
}
@@ -282,14 +281,14 @@ handle_verify_result (void *cls,
unsigned int d_count,
struct GNUNET_CREDENTIAL_Delegation *dc,
unsigned int c_count,
- struct GNUNET_CREDENTIAL_Delegate *cred)
+ struct GNUNET_CREDENTIAL_Delegate *dele)
{
int i;
char *iss_key;
char *sub_key;
verify_request = NULL;
- if (NULL == cred)
+ if (NULL == dele)
printf ("Failed.\n");
else
{
@@ -319,19 +318,18 @@ handle_verify_result (void *cls,
GNUNET_free (iss_key);
GNUNET_free (sub_key);
}
- printf ("\nCredentials:\n");
+ printf ("\nDelegate(s):\n");
for (i = 0; i < c_count; i++)
{
- iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred[i].issuer_key);
- sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred[i].subject_key);
- printf ("%s.%s <- %s\n", iss_key, cred[i].issuer_attribute, sub_key);
+ iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].issuer_key);
+ sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].subject_key);
+ printf ("%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key);
GNUNET_free (iss_key);
GNUNET_free (sub_key);
}
printf ("Successful.\n");
}
-
GNUNET_SCHEDULER_shutdown ();
}
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index da43334df..2d954f823 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -303,32 +303,17 @@ struct VerifyRequestHandle
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
/**
- * Credential DLL
- */
- struct CredentialRecordEntry *cred_chain_head;
-
- /**
- * Credential DLL
- */
- struct CredentialRecordEntry *cred_chain_tail;
-
- /**
- * Credential DLL size
- */
- uint32_t cred_chain_size;
-
- /**
- * Credential DLL
+ * Delegate DLL
*/
struct DelegateRecordEntry *del_chain_head;
/**
- * Credential DLL
+ * Delegate DLL
*/
struct DelegateRecordEntry *del_chain_tail;
/**
- * Credential DLL size
+ * Delegate DLL size
*/
uint32_t del_chain_size;
@@ -358,19 +343,9 @@ struct VerifyRequestHandle
enum direction resolution_algo;
/**
- * Credential iterator
- */
- struct GNUNET_NAMESTORE_ZoneIterator *cred_collection_iter;
-
- /**
- * Credential iterator
+ * Delegate iterator for lookup
*/
struct GNUNET_NAMESTORE_QueueEntry *dele_qe;
-
- /**
- * Collect task
- */
- struct GNUNET_SCHEDULER_Task *collect_next_task;
};
@@ -443,7 +418,7 @@ cleanup_delegation_set (struct DelegationSetQueueEntry *ds_entry)
static void
cleanup_handle (struct VerifyRequestHandle *vrh)
{
- struct CredentialRecordEntry *cr_entry;
+ struct DelegateRecordEntry *del_entry;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n");
if (NULL != vrh->lookup_request) {
GNUNET_GNS_lookup_cancel (vrh->lookup_request);
@@ -451,13 +426,13 @@ cleanup_handle (struct VerifyRequestHandle *vrh)
}
cleanup_delegation_set (vrh->root_set);
GNUNET_free_non_null (vrh->issuer_attribute);
- for (cr_entry = vrh->cred_chain_head; NULL != vrh->cred_chain_head;
- cr_entry = vrh->cred_chain_head) {
- GNUNET_CONTAINER_DLL_remove (vrh->cred_chain_head,
- vrh->cred_chain_tail,
- cr_entry);
- GNUNET_free_non_null (cr_entry->credential);
- GNUNET_free (cr_entry);
+ for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
+ del_entry = vrh->del_chain_head) {
+ GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head,
+ vrh->del_chain_tail,
+ del_entry);
+ GNUNET_free_non_null (del_entry->delegate);
+ GNUNET_free (del_entry);
}
GNUNET_free (vrh);
}
@@ -497,10 +472,9 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
struct DelegationChainResultMessage *rmsg;
struct DelegationChainEntry *dce;
struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size];
- //TODO rename cred/cd
//TODO rename all methods using credential
- struct GNUNET_CREDENTIAL_Delegate cred[vrh->del_chain_size];
- struct DelegateRecordEntry *cd;
+ struct GNUNET_CREDENTIAL_Delegate dele[vrh->del_chain_size];
+ struct DelegateRecordEntry *del;
struct DelegateRecordEntry *tmp;
size_t size;
@@ -521,13 +495,13 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
}
// Remove all not needed credentials
- for (cd = vrh->del_chain_head; NULL != cd;) {
- if (cd->refcount > 0) {
- cd = cd->next;
+ for (del = vrh->del_chain_head; NULL != del;) {
+ if (del->refcount > 0) {
+ del = del->next;
continue;
}
- tmp = cd;
- cd = cd->next;
+ tmp = del;
+ del = del->next;
GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head,
vrh->del_chain_tail,
tmp);
@@ -536,25 +510,23 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
vrh->del_chain_size--;
}
- /**
- * Get serialized record data
- * Append at the end of rmsg
- */
- cd = vrh->del_chain_head;
+ // Get serialized record data
+ // Append at the end of rmsg
+ del = vrh->del_chain_head;
for (uint32_t i = 0; i < vrh->del_chain_size; i++) {
- cred[i].issuer_key = cd->delegate->issuer_key;
- cred[i].subject_key = cd->delegate->subject_key;
- cred[i].issuer_attribute_len
- = strlen (cd->delegate->issuer_attribute) + 1;
- cred[i].issuer_attribute = cd->delegate->issuer_attribute;
- cred[i].expiration = cd->delegate->expiration;
- cred[i].signature = cd->delegate->signature;
- cd = cd->next;
+ dele[i].issuer_key = del->delegate->issuer_key;
+ dele[i].subject_key = del->delegate->subject_key;
+ dele[i].issuer_attribute_len
+ = strlen (del->delegate->issuer_attribute) + 1;
+ dele[i].issuer_attribute = del->delegate->issuer_attribute;
+ dele[i].expiration = del->delegate->expiration;
+ dele[i].signature = del->delegate->signature;
+ del = del->next;
}
size = GNUNET_CREDENTIAL_delegation_chain_get_size (vrh->delegation_chain_size,
dd,
vrh->del_chain_size,
- cred);
+ dele);
env = GNUNET_MQ_msg_extra (rmsg,
size,
GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT);
@@ -564,16 +536,16 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
rmsg->c_count = htonl (vrh->del_chain_size);
if (0 < vrh->del_chain_size)
- rmsg->cred_found = htonl (GNUNET_YES);
+ rmsg->del_found = htonl (GNUNET_YES);
else
- rmsg->cred_found = htonl (GNUNET_NO);
+ rmsg->del_found = htonl (GNUNET_NO);
GNUNET_assert (
-1
!= GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size,
dd,
vrh->del_chain_size,
- cred,
+ dele,
size,
(char *)&rmsg[1]));
@@ -648,7 +620,7 @@ partial_match(char *tmp_trail, char *tmp_subattr, char *parent_trail, char *issu
}
static void
-test_resolution (void *cls,
+forward_resolution (void *cls,
uint32_t rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
@@ -773,7 +745,7 @@ test_resolution (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found: Solution\n");
- // Add to delegation_chain
+ // Add found solution into delegation_chain
struct DelegationSetQueueEntry *tmp_set;
for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
tmp_set = tmp_set->parent_queue_entry->parent_set) {
@@ -784,9 +756,6 @@ test_resolution (void *cls,
tmp_set->delegation_chain_entry);
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "tmpentrylast %s %s\n",
- GNUNET_CRYPTO_ecdsa_public_key_to_string(&vrh->delegation_chain_head->subject_key),
- vrh->delegation_chain_head->subject_attribute);
// Increase refcount for this delegate
for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) {
@@ -819,7 +788,7 @@ test_resolution (void *cls,
&del->issuer_key,
GNUNET_GNSRECORD_TYPE_DELEGATE,
GNUNET_GNS_LO_DEFAULT,
- &test_resolution,
+ &forward_resolution,
ds_entry);
}
@@ -875,8 +844,6 @@ backward_resolution (void *cls,
dq_entry->required_solutions = ntohl (sets->set_count);
dq_entry->parent_set = current_set;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# New OR entry into queue\n");
-
GNUNET_CONTAINER_DLL_insert (current_set->queue_entries_head,
current_set->queue_entries_tail,
dq_entry);
@@ -953,7 +920,6 @@ backward_resolution (void *cls,
// Backtrack
for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry;
tmp_set = tmp_set->parent_queue_entry->parent_set) {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# %s\n", tmp_set->unresolved_attribute_delegation);
tmp_set->parent_queue_entry->required_solutions--;
if (NULL != tmp_set->delegation_chain_entry) {
vrh->delegation_chain_size++;
@@ -982,7 +948,6 @@ backward_resolution (void *cls,
issuer_attribute_name[strlen (ds_entry->unresolved_attribute_delegation)
+ 1];
strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Issuer Att Name: %s\n", issuer_attribute_name);
char *next_attr = strtok (issuer_attribute_name, ".");
if (NULL == next_attr) {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1036,7 +1001,7 @@ backward_resolution (void *cls,
* @param cls the closure (our client lookup handle)
*/
static void
-delegation_chain_resolution_start (void *cls)
+delegation_chain_bw_resolution_start (void *cls)
{
struct VerifyRequestHandle *vrh = cls;
struct DelegationSetQueueEntry *ds_entry;
@@ -1064,10 +1029,9 @@ delegation_chain_resolution_start (void *cls)
return;
}
- /**
- * Check for attributes from the issuer and follow the chain
- * till you get the required subject's attributes
- */
+
+ //Check for attributes from the issuer and follow the chain
+ //till you get the required subject's attributes
char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1];
strcpy (issuer_attribute_name, vrh->issuer_attribute);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1083,8 +1047,9 @@ delegation_chain_resolution_start (void *cls)
ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute);
vrh->root_set = ds_entry;
vrh->pending_lookups = 1;
+
// Start with backward resolution
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Start Backward Resolution\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Backward Resolution\n");
ds_entry->lookup_request = GNUNET_GNS_lookup (gns,
issuer_attribute_name,
@@ -1146,8 +1111,6 @@ delegation_chain_fw_resolution_start (void *cls)
// ds_entry created belongs to the first lookup, vrh still has the
// issuer+attr we look for
for (del_entry = vrh->del_chain_head; del_entry != NULL; del_entry = del_entry->next) {
- //char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1];
- //strcpy (issuer_attribute_name, vrh->issuer_attribute);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Looking for %s.%s\n",
@@ -1159,23 +1122,20 @@ delegation_chain_fw_resolution_start (void *cls)
GNUNET_memcpy (ds_entry->issuer_key,
&del_entry->delegate->subject_key,
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
- //ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute);
ds_entry->attr_trailer = GNUNET_strdup(del_entry->delegate->issuer_attribute);
ds_entry->handle = vrh;
- // TODO: no lookup attribute for forward?
- //ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute);
vrh->root_set = ds_entry;
vrh->pending_lookups ++;
// Start with forward resolution
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "# Start Forward Resolution\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start Forward Resolution\n");
ds_entry->lookup_request = GNUNET_GNS_lookup (gns,
GNUNET_GNS_EMPTY_LABEL_AT,
&del_entry->delegate->issuer_key, // issuer_key,
GNUNET_GNSRECORD_TYPE_DELEGATE,
GNUNET_GNS_LO_DEFAULT,
- &test_resolution,
+ &forward_resolution,
ds_entry);
}
}
@@ -1210,12 +1170,12 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
struct VerifyRequestHandle *vrh;
struct GNUNET_SERVICE_Client *client = cls;
struct DelegateRecordEntry *del_entry;
- uint32_t credentials_count;
- uint32_t credential_data_size;
+ uint32_t delegate_count;
+ uint32_t delegate_data_size;
char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
char *attrptr = attr;
- char *credential_data;
+ char *delegate_data;
const char *utf_in;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received VERIFY message\n");
@@ -1240,39 +1200,39 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
}
// Parse delegates from verifaction message
- credentials_count = ntohl (v_msg->c_count);
- credential_data_size = ntohs (v_msg->header.size)
+ delegate_count = ntohl (v_msg->d_count);
+ delegate_data_size = ntohs (v_msg->header.size)
- sizeof (struct VerifyMessage)
- ntohs (v_msg->issuer_attribute_len) - 1;
- struct GNUNET_CREDENTIAL_Delegate credentials[credentials_count];
- memset (credentials,
+ struct GNUNET_CREDENTIAL_Delegate delegates[delegate_count];
+ memset (delegates,
0,
- sizeof (struct GNUNET_CREDENTIAL_Delegate) * credentials_count);
- credential_data = (char *)&v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1;
+ sizeof (struct GNUNET_CREDENTIAL_Delegate) * delegate_count);
+ delegate_data = (char *)&v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1;
if (GNUNET_OK
- != GNUNET_CREDENTIAL_credentials_deserialize (credential_data_size,
- credential_data,
- credentials_count,
- credentials)) {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize credentials!\n");
+ != GNUNET_CREDENTIAL_delegates_deserialize (delegate_data_size,
+ delegate_data,
+ delegate_count,
+ delegates)) {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n");
send_lookup_response (vrh);
return;
}
// Prepare vrh delegation chain for later validation
- for (uint32_t i = 0; i < credentials_count; i++) {
+ for (uint32_t i = 0; i < delegate_count; i++) {
del_entry = GNUNET_new (struct DelegateRecordEntry);
del_entry->delegate
= GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_Delegate)
- + credentials[i].issuer_attribute_len + 1);
+ + delegates[i].issuer_attribute_len + 1);
GNUNET_memcpy (del_entry->delegate,
- &credentials[i],
+ &delegates[i],
sizeof (struct GNUNET_CREDENTIAL_Delegate));
GNUNET_memcpy (&del_entry->delegate[1],
- credentials[i].issuer_attribute,
- credentials[i].issuer_attribute_len);
+ delegates[i].issuer_attribute,
+ delegates[i].issuer_attribute_len);
del_entry->delegate->issuer_attribute_len
- = credentials[i].issuer_attribute_len;
+ = delegates[i].issuer_attribute_len;
del_entry->delegate->issuer_attribute = (char *)&del_entry->delegate[1];
GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head,
vrh->del_chain_tail,
@@ -1282,10 +1242,8 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
// Switch resolution algo
if(Backward == vrh->resolution_algo){
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++backward\n");
- delegation_chain_resolution_start (vrh);
+ delegation_chain_bw_resolution_start (vrh);
} else if (Forward == vrh->resolution_algo){
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++forward\n");
delegation_chain_fw_resolution_start (vrh);
} else{
//TODO
@@ -1293,26 +1251,24 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
}
static void
-handle_cred_collection_error_cb (void *cls)
+handle_delegate_collection_error_cb (void *cls)
{
struct VerifyRequestHandle *vrh = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got disconnected from namestore database.\n");
- vrh->cred_collection_iter = NULL;
+ vrh->dele_qe = NULL;
send_lookup_response (vrh);
}
static void
-handle_cred_collection_finished_cb (void *cls)
+delegate_collection_finished (void *cls)
{
struct VerifyRequestHandle *vrh = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting credentials.\n");
- vrh->cred_collection_iter = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n");
+
if(Backward == vrh->resolution_algo){
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++backward\n");
- delegation_chain_resolution_start (vrh);
+ delegation_chain_bw_resolution_start (vrh);
} else if (Forward == vrh->resolution_algo){
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "+++++++++++++++++forward\n");
delegation_chain_fw_resolution_start (vrh);
} else{
//TODO
@@ -1320,7 +1276,7 @@ handle_cred_collection_finished_cb (void *cls)
}
static void
-tmp_handle_cred_collection_cb (void *cls,
+handle_delegate_collection_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
const char *label,
unsigned int rd_count,
@@ -1350,9 +1306,8 @@ tmp_handle_cred_collection_cb (void *cls,
del_entry);
vrh->del_chain_size++;
}
- // No need to collect next, should have all already
- //vrh->collect_next_task = GNUNET_SCHEDULER_add_now (&collect_next, vrh);
- handle_cred_collection_finished_cb(vrh);
+
+ delegate_collection_finished(vrh);
}
static void
@@ -1386,27 +1341,15 @@ handle_collect (void *cls, const struct CollectMessage *c_msg)
send_lookup_response (vrh);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting credentials for subject\n");
- /**
- * First, get attribute from subject
- */
- // TODO NAMESTORE_lookup auf empty label statt iteration, iteration genutzt da nicht wusste welches label
- /*vrh->cred_collection_iter = GNUNET_NAMESTORE_zone_iteration_start (
- namestore,
- &c_msg->subject_key,
- &handle_cred_collection_error_cb,
- vrh,
- &handle_cred_collection_cb,
- vrh,
- &handle_cred_collection_finished_cb,
- vrh);*/
- //TODO rename tmp_handle_... and test_resolution..
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting delegates for subject\n");
+
+ // Get all delegates from subject
vrh->dele_qe = GNUNET_NAMESTORE_records_lookup (namestore,
&c_msg->subject_key,
GNUNET_GNS_EMPTY_LABEL_AT,
- &handle_cred_collection_error_cb,
+ &handle_delegate_collection_error_cb,
vrh,
- &tmp_handle_cred_collection_cb,
+ &handle_delegate_collection_cb,
vrh);
GNUNET_SERVICE_client_continue (vrh->client);
}
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c
index 90cd2f46a..784c7def1 100644
--- a/src/credential/plugin_gnsrecord_credential.c
+++ b/src/credential/plugin_gnsrecord_credential.c
@@ -79,9 +79,7 @@ credential_value_to_string (void *cls,
{
subject_pkey =
GNUNET_CRYPTO_ecdsa_public_key_to_string (&set[i].subject_key);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%d len attr\n",
- set[i].subject_attribute_len);
+
if (0 == set[i].subject_attribute_len)
{
if (0 == i)
diff --git a/src/credential/test_credential_own.sh b/src/credential/test_credential_own.sh
index 19dd686a9..d2ed0b0ac 100755
--- a/src/credential/test_credential_own.sh
+++ b/src/credential/test_credential_own.sh
@@ -54,6 +54,7 @@ STATE_STUD_ATTR="student"
REG_STUD_ATTR="student"
END_ATTR="end"
+# FORWARD, subject side stored
SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=a --attribute="a" --subject="$AKEY b.c" --ttl="2019-12-12 10:00:00"`
gnunet-credential --createSubjectSide --ego=a --import "$SIGNED"
gnunet-namestore -D -z a
@@ -79,66 +80,35 @@ gnunet-credential --createSubjectSide --ego=g --import "$SIGNED"
gnunet-namestore -D -z g
-
-TEST_CREDENTIAL="mygnunetcreds"
-# Own issuer side storage:
-#gnunet-credential --createIssuerSide --ego=epub --attribute="issside" --subject="$EORG_KEY asd" --ttl=5m
-
-#gnunet-namestore -D -z epub
-
-# Own subject side storage:
-#SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd" --subject="$EORG_KEY" --ttl="2019-12-12 10:00:00"`
-#gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED"
-
-#SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd" --subject="$EORG_KEY efghijklmno" --ttl="2019-12-12 10:00:00"`
-#gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED"
-
-#SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd" --subject="$EORG_KEY efghijklmno.pqr" --ttl="2019-12-12 10:00:00"`
-#gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED"
-
-#SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="abcd.stu" --subject="$EORG_KEY efghijklmno.pqr" --ttl="2019-12-12 10:00:00"`
-#gnunet-credential --createSubjectSide --ego=eorg --import "$SIGNED"
-
-#SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=stateu --attribute="aaa" --subject="$EPUB_KEY bbbb" --ttl="2019-12-12 10:00:00"`
-#gnunet-credential --createSubjectSide --ego=epub --import "$SIGNED"
-
-#gnunet-namestore -D -z eorg
-
+# BACKWARD, issuer side stored
# (1) EPub assigns the attribute "discount" to all entities that have been assigned "preferred" by EOrg
-gnunet-namestore -p -z epub -a -n $DISC_ATTR -t ATTR -V "$EORG_KEY $PREF_ATTR" -e 5m -c test_credential_lookup.conf
-gnunet-namestore -p -z epub -a -n "random" -t ATTR -V "$GKEY random" -e 5m -c test_credential_lookup.conf
+gnunet-credential --createIssuerSide --ego=epub --attribute=$DISC_ATTR --subject="$EORG_KEY $PREF_ATTR" --ttl=5m -c test_credential_lookup.conf
# (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU
-gnunet-namestore -p -z eorg -a -n $PREF_ATTR -t ATTR -V "$STATEU_KEY $STATE_STUD_ATTR" -e 5m -c test_credential_lookup.conf
+gnunet-credential --createIssuerSide --ego=eorg --attribute=$PREF_ATTR --subject="$STATEU_KEY $STATE_STUD_ATTR" --ttl=5m -c test_credential_lookup.conf
# (3) StateU assigns the attribute "student" to all entities that have been asssigned "student" by RegistrarB
-gnunet-namestore -p -z stateu -a -n $STATE_STUD_ATTR -t ATTR -V "$REGISTRARB_KEY $REG_STUD_ATTR" -e 5m -c test_credential_lookup.conf
+gnunet-credential --createIssuerSide --ego=stateu --attribute=$STATE_STUD_ATTR --subject="$REGISTRARB_KEY $REG_STUD_ATTR" --ttl=5m -c test_credential_lookup.conf
# (4) RegistrarB issues Alice the credential "student"
-CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=registrarb --subject=$ALICE_KEY --attribute=$REG_STUD_ATTR --ttl=5m -c test_credential_lookup.conf`
-
-# Alice stores the credential under "mygnunetcreds"
-#gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf
-
SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=registrarb --attribute="$REG_STUD_ATTR" --subject="$ALICE_KEY" --ttl="2019-12-12 10:00:00"`
gnunet-credential --createSubjectSide --ego=alice --import "$SIGNED"
# Starting to resolve
-echo "+++++Starting Collect"
+echo "+++ Starting to Resolve +++"
-CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=g -c test_credential_lookup.conf | paste -d, -s`
-echo $CREDS
-echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential=\'$CREDS\' -c test_credential_lookup.conf
-RES_CRED=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential="$CREDS" -c test_credential_lookup.conf`
-
-#CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice -c test_credential_lookup.conf | paste -d, -s`
+#CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=g -c test_credential_lookup.conf | paste -d, -s`
#echo $CREDS
-#echo gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential=\'$CREDS\' -c test_credential_lookup.conf
-#RES_CRED=`gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential="$CREDS" -c test_credential_lookup.conf`
+#echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential=\'$CREDS\' -c test_credential_lookup.conf
+#RES_CRED=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --credential="$CREDS" -c test_credential_lookup.conf`
+
+CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice -c test_credential_lookup.conf | paste -d, -s`
+echo $CREDS
+echo gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential=\'$CREDS\' -c test_credential_lookup.conf
+RES_CRED=`gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential="$CREDS" -c test_credential_lookup.conf`
# Cleanup properly
-gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf
gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf
gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf
gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf