[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: work on assembler
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: work on assembler |
Date: |
Tue, 19 May 2020 17:20:39 +0200 |
This is an automated email from the git hooks/post-receive script.
ds-meister pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new f6eeec7 work on assembler
f6eeec7 is described below
commit f6eeec76679714187fd3a29a3e2d654a1e223e95
Author: Dominik Meister <address@hidden>
AuthorDate: Tue May 19 17:20:33 2020 +0200
work on assembler
---
src/cli/anastasis-cli-assembler.c | 233 +++++++++++++++++++++++++++++++++-----
1 file changed, 204 insertions(+), 29 deletions(-)
diff --git a/src/cli/anastasis-cli-assembler.c
b/src/cli/anastasis-cli-assembler.c
index 2a79898..95bcc12 100644
--- a/src/cli/anastasis-cli-assembler.c
+++ b/src/cli/anastasis-cli-assembler.c
@@ -27,16 +27,23 @@
#include "anastasis_service.h"
#include "anastasis.h"
+
+
+
/**
* Global option '--me' to import json containing details of user.
*/
-static int import_id;
+static char *import_id;
/**
* Global option '--import' to import json containing recovery document.
*/
-static int import_recovery_document;
+static char *import_recovery_document;
+/**
+ * Global option '--version' to import the version of the recovery document.
+ */
+static unsigned int import_recovery_version;
/**
* Reference to the keyboard task
*/
@@ -52,11 +59,55 @@ static struct GNUNET_CURL_Context *ctx;
*/
static struct GNUNET_CURL_RescheduleContext *rc;
-
static void
start_read_keyboard (void);
+/**
+ * State for a "recover secret" CMD.
+ */
+struct RecoverSecretState
+{
+/**
+ * URL of the anastasis backend.
+ */
+ const char *anastasis_url;
+ /**
+ * Expected status code.
+ */
+ unsigned int http_status_salt;
+ /**
+ * Expected status code.
+ */
+ unsigned int http_status_policy;
+ /**
+ * The /policy GET operation handle.
+ */
+ struct ANASTASIS_Recovery *recovery;
+ /**
+ * Identification data from the user
+ */
+ json_t *id_data;
+ /**
+ * version of the recovery document
+ */
+ unsigned int version;
+ /**
+ * Salt to be used to derive the id
+ */
+ struct ANASTASIS_CRYPTO_SaltP *salt;
+ /**
+ * Recovery information from the lookup
+ */
+ const struct ANASTASIS_RecoveryInformation *ri;
+ /**
+ * The /salt GET operation handle.
+ */
+ struct ANASTASIS_SaltOperation *so;
+
+};
+
+
/**
* @brief Read the character from stdin and activate the selected task
*
@@ -66,7 +117,7 @@ static void
read_keyboard_command (void *cls)
{
(void) cls;
- char *buffer = readline ("anastasis-splitter> ");
+ char *buffer = readline ("anastasis-assembler> ");
size_t characters = strlen (buffer);
// Check for EOF.
@@ -93,8 +144,7 @@ read_keyboard_command (void *cls)
"\nOPTIONS:\n"
"'x' to quit\n"
"'o' to show these options\n"
- "'truth' to show all truths\n" // FIXME
- "'truth --all' to show all truths" // FIXME
+ "'truth' to show all truths\n"
"'policy' to show all policies\n"
"'try' to check whether you have to pay for truth\n"
"'answer' to solve a challenge\n"
@@ -125,16 +175,6 @@ read_keyboard_command (void *cls)
buffer = NULL;
return;
}
- if (0 == strncmp ("truth --all",
- buffer,
- strlen ("truth --all")))
- {
- // FIXME "truth --secrets" logic here
- start_read_keyboard ();
- GNUNET_free (buffer);
- buffer = NULL;
- return;
- }
if (0 == strncmp ("policy",
buffer,
@@ -171,13 +211,11 @@ read_keyboard_command (void *cls)
fprintf (stderr,
"Unknown command '%s'\n",
- (char*) buffer);
+ (char *) buffer);
GNUNET_free (buffer);
buffer = NULL;
start_read_keyboard ();
}
-
-
/**
* @brief Wait for a keyboard input
*/
@@ -207,6 +245,124 @@ start_read_keyboard ()
}
+static void
+policy_lookup_cb (void *cls,
+ const struct ANASTASIS_RecoveryInformation *ri,
+ const enum TALER_ErrorCode ec)
+{
+ struct RecoverSecretState *rss = cls;
+ rss->ri = ri;
+ if (NULL == ri)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ start_read_keyboard ();
+ return;
+}
+
+static void
+core_secret_cb (void *cls,
+ const void *secret,
+ size_t secret_size)
+{
+ // FIXME
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d arrived at core secret cb \n", __FILE__, __LINE__);
+ struct RecoverSecretState *rss = cls;
+ return;
+}
+
+/**
+ * State for a "challenge answer" CMD.
+ */
+struct ChallengeState
+{
+ /**
+ * The interpreter state.
+ */
+ struct TALER_TESTING_Interpreter *is;
+ /**
+ * Reference to the challenge we are solving
+ */
+ struct ANASTASIS_Challenge *c;
+ /**
+ * Expected status code.
+ */
+ unsigned int http_status;
+ /**
+ * Answer to the challenge we are solving
+ */
+ const void *answer;
+ /**
+ * Size of the answer we are solving
+ */
+ size_t answer_size;
+ /**
+ * Referenece to the recovery process
+ */
+ const char *challenge_ref;
+ /**
+ * Index of the challenge we are solving
+ */
+ unsigned int challenge_index;
+};
+
+static void
+challenge_answer_cb (void *af_cls,
+ enum TALER_ErrorCode ec)
+{
+ struct ChallengeState *cs = af_cls;
+ if (ec != MHD_HTTP_OK)
+ {
+ GNUNET_break (0);
+ }
+}
+
+/**
+ * Function called with the results of a #ANASTASIS_salt().
+ *
+ * @param cls closure
+ * @param http_status HTTP status of the request
+ * @param salt salt from the server
+ */
+static void
+salt_cb (void *cls,
+ unsigned int http_status,
+ const struct ANASTASIS_CRYPTO_SaltP *salt)
+{
+ struct RecoverSecretState *rss = cls;
+
+ rss->so = NULL;
+ if (http_status != rss->http_status_salt)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u in %s:%u\n",
+ http_status,
+ __FILE__,
+ __LINE__);
+ return;
+ }
+ if (NULL == salt)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Salt is NULL in %s:%u\n",
+ __FILE__,
+ __LINE__);
+ return;
+ }
+ rss->recovery = ANASTASIS_recovery_begin (ctx,
+ rss->id_data,
+ rss->version,
+ rss->anastasis_url,
+ salt,
+ &policy_lookup_cb,
+ rss,
+ &core_secret_cb,
+ rss);
+}
+
+
/**
* @brief Shutdown the application.
*
@@ -249,6 +405,9 @@ run (void *cls,
(void) args;
(void) cfgfile;
+ struct RecoverSecretState *rss;
+ rss = GNUNET_new (struct RecoverSecretState);
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Starting anastasis-assembler\n");
@@ -264,8 +423,16 @@ run (void *cls,
ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
&rc);
rc = GNUNET_CURL_gnunet_rc_create (ctx);
-
- start_read_keyboard ();
+ // FIXME
+ json_error_t error;
+ rss->id_data = json_load_file (import_id, JSON_DECODE_ANY,&error);
+ rss->version = import_recovery_version;
+ rss->anastasis_url = import_recovery_document;
+ rss->http_status_salt = MHD_HTTP_OK;
+ rss->so = ANASTASIS_salt (ctx,
+ rss->anastasis_url,
+ &salt_cb,
+ rss);
}
int
@@ -276,14 +443,22 @@ main (int argc,
/* the available command line options */
struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_flag ('m',
- "me",
- "import json file containing details to create
user identifier",
- &import_id),
- GNUNET_GETOPT_option_flag ('i',
- "import",
- "import json file containing a recovery
document",
- &import_recovery_document),
+ GNUNET_GETOPT_option_filename ('m',
+ "me",
+ "import json file containing details to
create user identifier",
+ "import json file containing details to
create user identifier",
+ &import_id),
+ GNUNET_GETOPT_option_string ('i',
+ "import",
+ "import url for downloading recovery
document",
+ "import url for downloading recovery
document",
+ &import_recovery_document),
+ GNUNET_GETOPT_option_uint ('p',
+ "policy-version",
+ "version of the recovery document to lookup",
+ "version of the recovery document to lookup",
+ &import_recovery_version),
+
GNUNET_GETOPT_OPTION_END
};
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: work on assembler,
gnunet <=