[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 16/30: add attestation API to CLI
From: |
gnunet |
Subject: |
[gnunet] 16/30: add attestation API to CLI |
Date: |
Thu, 13 Feb 2020 22:31:16 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 73de82ef85076f0421af025887f0053e6c652b09
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Tue Feb 4 21:53:47 2020 +0100
add attestation API to CLI
---
src/reclaim/gnunet-reclaim.c | 169 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 150 insertions(+), 19 deletions(-)
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 93d9ee3df..35c1258f5 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -42,6 +42,31 @@ static int ret;
*/
static int list;
+/**
+ * List attestations flag
+ */
+static int list_attestations;
+
+/**
+ * Attestation ID string
+ */
+static char *attestation_id;
+
+/**
+ * Attestation ID
+ */
+static struct GNUNET_RECLAIM_Identifier attestation;
+
+/**
+ * Attestation name
+ */
+static char *attestation_name;
+
+/**
+ * Attestation exists
+ */
+static int attestation_exists;
+
/**
* Relying party
*/
@@ -107,6 +132,12 @@ static struct GNUNET_RECLAIM_Operation *reclaim_op;
*/
static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator;
+/**
+ * Attestation iterator
+ */
+static struct GNUNET_RECLAIM_AttestationIterator *attest_iterator;
+
+
/**
* Ticket iterator
*/
@@ -212,7 +243,7 @@ ticket_issue_cb (void *cls, const struct
GNUNET_RECLAIM_Ticket *ticket)
static void
-store_attr_cont (void *cls, int32_t success, const char *emsg)
+store_cont (void *cls, int32_t success, const char *emsg)
{
reclaim_op = NULL;
if (GNUNET_SYSERR == success)
@@ -305,7 +336,9 @@ static void
iter_error (void *cls)
{
attr_iterator = NULL;
- fprintf (stderr, "Failed to iterate over attributes\n");
+ attest_iterator = NULL;
+ fprintf (stderr, "Failed\n");
+
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
@@ -430,11 +463,16 @@ iter_finished (void *cls)
claim =
GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size);
}
+ if (NULL != attestation_id)
+ {
+ claim->attestation = attestation;
+ }
+ else
reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
pkey,
claim,
&exp_interval,
- &store_attr_cont,
+ &store_cont,
NULL);
GNUNET_free (data);
GNUNET_free (claim);
@@ -527,6 +565,76 @@ iter_cb (void *cls,
}
+static void
+attest_iter_finished (void *cls)
+{
+ attest_iterator = NULL;
+ //Add new attestation
+ if ((NULL != attestation_name) &&
+ (NULL != attr_value))
+ {
+ struct GNUNET_RECLAIM_Attestation *attestation =
+ GNUNET_RECLAIM_attestation_new (attestation_name,
+ GNUNET_RECLAIM_ATTESTATION_TYPE_JWT,
//FIXME hardcoded
+ attr_value,
+ strlen (attr_value));
+ reclaim_op = GNUNET_RECLAIM_attestation_store (reclaim_handle,
+ pkey,
+ attestation,
+ &exp_interval,
+ store_cont,
+ NULL);
+ return;
+
+ }
+ if (! list_attestations)
+ {
+ attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
+ pkey,
+ &iter_error,
+ NULL,
+ &iter_cb,
+ NULL,
+ &iter_finished,
+ NULL);
+
+ }
+ cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
+}
+
+
+static void
+attest_iter_cb (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
+ const struct GNUNET_RECLAIM_Attestation *attest)
+{
+ char *attest_str;
+ char *id;
+ const char *attest_type;
+
+ if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attestation,
+ &attest->id))
+ attestation_exists = GNUNET_YES;
+ if (list_attestations)
+ {
+ attest_str = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
+ attest->data,
+
attest->data_size);
+ attest_type = GNUNET_RECLAIM_attribute_number_to_typename (attest->type);
+ id = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id));
+ fprintf (stdout,
+ "Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
+ attest->name,
+ attest_str,
+ attest_type,
+ attest->flag,
+ id);
+ GNUNET_free (id);
+ }
+ GNUNET_RECLAIM_get_attestations_next (attest_iterator);
+}
+
+
static void
start_process ()
{
@@ -536,7 +644,12 @@ start_process ()
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
return;
}
-
+ attestation = GNUNET_RECLAIM_ID_ZERO;
+ if (NULL != attestation_id)
+ GNUNET_STRINGS_string_to_data (attestation_id,
+ strlen (attestation_id),
+ &attestation, sizeof(attestation));
+ attestation_exists = GNUNET_NO;
if (list_tickets)
{
ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
@@ -549,6 +662,19 @@ start_process ()
NULL);
return;
}
+ if (list_attestations)
+ {
+ attest_iterator = GNUNET_RECLAIM_get_attestations_start (reclaim_handle,
+ pkey,
+ &iter_error,
+ NULL,
+ &attest_iter_cb,
+ NULL,
+ &
+
attest_iter_finished,
+ NULL);
+ return;
+ }
if ((NULL != rp) &&
(GNUNET_OK !=
@@ -571,14 +697,6 @@ start_process ()
attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
claim = NULL;
- attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
- pkey,
- &iter_error,
- NULL,
- &iter_cb,
- NULL,
- &iter_finished,
- NULL);
}
@@ -674,13 +792,26 @@ main (int argc, char *const argv[])
"dump",
gettext_noop ("List attributes for EGO"),
&list),
- GNUNET_GETOPT_option_string (
- 'i',
- "issue",
- "A1,A2,...",
- gettext_noop (
- "Issue a ticket for a set of attributes separated by comma"),
- &issue_attrs),
+ GNUNET_GETOPT_option_flag ('A',
+ "attestations",
+ gettext_noop ("List attestations for EGO"),
+ &list_attestations),
+ GNUNET_GETOPT_option_string ('I',
+ "Attestation ID",
+ "ATTESTATION_ID",
+ gettext_noop ("Attestation to use for
attribute"),
+ &attestation_id),
+ GNUNET_GETOPT_option_string ('N',
+ "attestation-name",
+ "NAME",
+ gettext_noop ("Attestation name"),
+ &attestation_name),
+ GNUNET_GETOPT_option_string ('i',
+ "issue",
+ "A1,A2,...",
+ gettext_noop (
+ "Issue a ticket for a set of attributes
separated by comma"),
+ &issue_attrs),
GNUNET_GETOPT_option_string ('C',
"consume",
"TICKET",
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnunet] branch master updated (79243b3d2 -> 007bba133), gnunet, 2020/02/13
- [gnunet] 04/30: add attestation API to CLI, gnunet, 2020/02/13
- [gnunet] 05/30: bugfixes, gnunet, 2020/02/13
- [gnunet] 06/30: towards better API, gnunet, 2020/02/13
- [gnunet] 08/30: more bugfixes and REST API change, gnunet, 2020/02/13
- [gnunet] 03/30: add attestation API, gnunet, 2020/02/13
- [gnunet] 01/30: move to 256-bit identifier; some cleanups, gnunet, 2020/02/13
- [gnunet] 10/30: bugfixes; CLI improvements, gnunet, 2020/02/13
- [gnunet] 09/30: add base64url encoding to util (RFC7515), gnunet, 2020/02/13
- [gnunet] 07/30: bugfixes, gnunet, 2020/02/13
- [gnunet] 16/30: add attestation API to CLI,
gnunet <=
- [gnunet] 11/30: consolidate reclaim attribute lib, gnunet, 2020/02/13
- [gnunet] 27/30: Merge branch 'master' into schanzen/reclaim_256bit, gnunet, 2020/02/13
- [gnunet] 21/30: add base64url encoding to util (RFC7515), gnunet, 2020/02/13
- [gnunet] 12/30: add expiration, gnunet, 2020/02/13
- [gnunet] 29/30: Merge branch 'master' into schanzen/reclaim_256bit, gnunet, 2020/02/13
- [gnunet] 19/30: bugfixes, gnunet, 2020/02/13
- [gnunet] 17/30: bugfixes, gnunet, 2020/02/13
- [gnunet] 15/30: add attestation API, gnunet, 2020/02/13
- [gnunet] 13/30: move to 256-bit identifier; some cleanups, gnunet, 2020/02/13
- [gnunet] 18/30: towards better API, gnunet, 2020/02/13