*/
uint32_t id GNUNET_PACKED;
+ uint16_t is_bw GNUNET_PACKED;
+
uint32_t size GNUNET_PACKED;
};
struct GNUNET_CREDENTIAL_Handle *handle = cls;
uint32_t r_id = ntohl (vr_msg->id);
uint32_t size = ntohl (vr_msg->size);
+ bool is_bw = ntohs(vr_msg->is_bw);
struct GNUNET_CREDENTIAL_Request *vr;
GNUNET_CREDENTIAL_IntermediateResultProcessor proc;
void *proc_cls;
struct GNUNET_CREDENTIAL_Delegation *dd;
+
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received intermediate reply from CREDENTIAL service\n");
+
for (vr = handle->request_head; NULL != vr; vr = vr->next)
if (vr->r_id == r_id)
break;
dd,
0,
NULL));
-
- proc (proc_cls, dd);
+ sleep(2);
+ proc (proc_cls, dd, is_bw);
}
off = 0;
for (i = 0; i < c_count; i++)
{
+ //c_rec.subject_attribute_len = htonl ((uint32_t) cd[i].subject_attribute_len);
c_rec.issuer_attribute_len = htonl ((uint32_t) cd[i].issuer_attribute_len);
c_rec.issuer_key = cd[i].issuer_key;
c_rec.subject_key = cd[i].subject_key;
GNUNET_assert (sizeof (struct GNUNET_CRYPTO_EcdsaSignature) ==
GNUNET_STRINGS_base64_decode (signature,
strlen (signature),
- (char **) &sig));
+ (void **) &sig));
dele->signature = *sig;
dele->expiration = etime_abs;
GNUNET_free (sig);
*/
static struct GNUNET_SCHEDULER_Task *tt;
+/**
+ * Return value of the commandline.
+ */
+static int ret = 0;
+
/**
* Subject pubkey string
*/
static void
handle_intermediate_result(void *cls,
-struct GNUNET_CREDENTIAL_Delegation *dd)
+ struct GNUNET_CREDENTIAL_Delegation *dd,
+ bool is_bw)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Intermediate result: %s.%s <- %s.%s\n",
+ char *prefix = "";
+ // TODO change to printf
+ if(is_bw)
+ prefix = "Backward -";
+ else
+ prefix = "Forward -";
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s Intermediate result: %s.%s <- %s.%s\n",
+ prefix,
GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->issuer_key),
dd->issuer_attribute,
GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->subject_key),
verify_request = NULL;
if (NULL == dele)
- printf ("Failed.\n");
+ ret = 1;
else
{
printf ("Delegation Chain:\n");
"Indicates that the collect/verify process is done via forward search."),
&backward),
GNUNET_GETOPT_OPTION_END};
- int ret;
+
timeout = GNUNET_TIME_UNIT_FOREVER_REL;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
GNUNET_log_setup ("gnunet-credential", "WARNING", NULL);
- ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc,
+ if (GNUNET_OK == GNUNET_PROGRAM_run (argc,
argv,
"gnunet-credential",
_ ("GNUnet credential resolver tool"),
options,
&run,
NULL))
- ? 0
- : 1;
+ ret = 1;
GNUNET_free ((void *) argv);
return ret;
}
*/
struct VerifyRequestHandle
{
+ /**
+ * True if created by a collect request.
+ */
+ bool is_collect;
/**
* We keep these in a DLL.
*/
}
static void
-send_intermediate_response(struct VerifyRequestHandle *vrh, struct DelegationChainEntry *ch_entry){
+send_intermediate_response(struct VerifyRequestHandle *vrh, struct DelegationChainEntry *ch_entry, bool is_bw){
struct DelegationChainIntermediateMessage *rmsg;
struct GNUNET_MQ_Envelope *env;
struct GNUNET_CREDENTIAL_Delegation *dd;
size_t size;
+ // Don't report immediate results during collect
+ if(vrh->is_collect)
+ return;
+
dd = GNUNET_new (struct GNUNET_CREDENTIAL_Delegation);
dd->issuer_key = ch_entry->issuer_key;
dd->subject_key = ch_entry->subject_key;
GNUNET_MESSAGE_TYPE_CREDENTIAL_INTERMEDIATE_RESULT);
// Assign id so that client can find associated request
rmsg->id = vrh->request_id;
+ rmsg->is_bw = htons(is_bw);
rmsg->size = htonl(size);
GNUNET_assert (
GNUNET_strdup (del->issuer_attribute);
// Found new entry, repoting intermediate result
- send_intermediate_response(vrh, ds_entry->delegation_chain_entry);
+ send_intermediate_response(vrh, ds_entry->delegation_chain_entry, false);
// current delegation as parent
ds_entry->parent_queue_entry = dq_entry;
GNUNET_strdup (current_set->lookup_attribute);
// Found new entry, repoting intermediate result
- send_intermediate_response(vrh, ds_entry->delegation_chain_entry);
+ send_intermediate_response(vrh, ds_entry->delegation_chain_entry, true);
ds_entry->parent_queue_entry = dq_entry; // current_delegation;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s still to go...\n",
ds_entry->attr_trailer);
-
+ // TODO remove
vrh->pending_lookups++;
ds_entry->handle = vrh;
ds_entry->lookup_request =
GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len));
issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
vrh = GNUNET_new (struct VerifyRequestHandle);
+ vrh->is_collect = false;
GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
vrh->client = client;
vrh->request_id = v_msg->id;
GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len));
issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0';
vrh = GNUNET_new (struct VerifyRequestHandle);
+ vrh->is_collect = true;
GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
vrh->client = client;
vrh->request_id = c_msg->id;
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_credential_lookup.conf | paste -d, -s - -`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f -c test_credential_lookup.conf | paste -d, -s - -`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f -c test_credential_lookup.conf | paste -d, -s - -`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
-
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_credential_lookup.conf | paste -d, -s - -`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
-
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_credential_lookup.conf | paste -d, -s - -`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_credential_lookup.conf | paste -d, -s - -`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=g --forward --backward -c test_credential_lookup.conf | paste -d, -s - -`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
-
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice --backward -c test_credential_lookup.conf | paste -d, -s`
echo $DELS
echo gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate=\'$DELS\' --backward -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_credential_lookup.conf`
-
+gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_credential_lookup.conf
+RES=$?
# Cleanup properly
gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private
-gnunet-namestore -D -z h
SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private
gnunet-namestore -D -z f
DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --backward -c test_credential_lookup.conf | paste -d, -s`
echo $DELS
echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --backward -c test_credential_lookup.conf
-RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --backward -c test_credential_lookup.conf`
+gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --backward -c test_credential_lookup.conf
+
+RES = $?
# Cleanup properly
-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
-#gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf
-#gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf
-#gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf
-#gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf
-#gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf
+gnunet-namestore -z a -d -n "a" -t ATTR -c test_credential_lookup.conf
+gnunet-namestore -z b -d -n "b" -t ATTR -c test_credential_lookup.conf
+gnunet-namestore -z f -d -n "@" -t DEL -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-if [ "$RES_DELS" != "Failed." ]
+if [ $RES == 0 ]
then
- # TODO: replace echo -e bashism
- echo -e "${RES_DELS}"
exit 0
else
- echo "FAIL: Failed to verify credential $RES_DELS."
+ echo "FAIL: Failed to verify credential."
exit 1
fi
struct GNUNET_CREDENTIAL_Delegate *delegte);
typedef void (*GNUNET_CREDENTIAL_IntermediateResultProcessor) (void *cls,
- struct GNUNET_CREDENTIAL_Delegation *delegation);
+ struct GNUNET_CREDENTIAL_Delegation *delegation,
+ bool is_bw);
/**
* Iterator called on obtained result for an attribute delegation.