gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated (b727c2f -> bdf42ed)


From: gnunet
Subject: [taler-anastasis] branch master updated (b727c2f -> bdf42ed)
Date: Sun, 17 May 2020 19:51:53 +0200

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a change to branch master
in repository anastasis.

    from b727c2f  added /terms rest api
     new df8ad9d  added truthstorestate
     new bdf42ed  worked on splitter

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/cli/anastasis-cli-splitter.c | 325 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 310 insertions(+), 15 deletions(-)

diff --git a/src/cli/anastasis-cli-splitter.c b/src/cli/anastasis-cli-splitter.c
index d7413a7..a738f21 100644
--- a/src/cli/anastasis-cli-splitter.c
+++ b/src/cli/anastasis-cli-splitter.c
@@ -22,12 +22,156 @@
  */
 #include "platform.h"
 #include <gnunet/gnunet_util_lib.h>
+#include <taler/taler_util.h>
 #include "anastasis_service.h"
 #include "anastasis.h"
 
 /* Constant, max size of keyboard input buffer */
 #define MAX_SIZE_INPUT_BUFFER 256
 
+/**
+ * State for a "truth upload" CMD.
+ */
+struct TruthUploadState
+{
+  /**
+   * URL of the anastasis backend.
+   */
+  const char *backend_url;
+
+  /**
+   * label of the anastasis backend.
+   */
+  const char *backend_label;
+
+  /**
+   * supported methods of the anastasis backend.
+   */
+  const char *backend_methods;
+
+  /**
+   * server salt of the anastasis backend.
+   */
+  const struct ANASTASIS_CRYPTO_SaltP *backend_salt;
+
+  /**
+   * insurance of the anastasis backend.
+   */
+  const struct TALER_Amount *backend_insurance;
+
+  /**
+   * cost of using the anastasis backend.
+   */
+  const struct TALER_Amount *backend_cost;
+
+  /**
+   * Label of this command.
+   */
+  const char *label;
+
+  /**
+   * The ID data to generate user identifier
+   */
+  const json_t *id_data;
+
+  /**
+   * The escrow method
+   */
+  const char *method;
+
+  /**
+   * A secret question
+   */
+  const char *secret_question;
+
+  /**
+   * Answer to secret question
+   */
+  const char *secret_answer;
+
+  /**
+   * Phonenumber for method SMS
+   */
+  const char *phone;
+
+  /**
+   * E-Mail address
+   */
+  const char *mail;
+
+  /**
+   * Instructions to be returned to client/user
+   * (e.g. "Look at your smartphone. SMS was sent to you")
+   */
+  const char *instructions;
+
+  /**
+   * Mime type of truth_data (eg. jpeg, string etc.)
+   */
+  const char *mime_type;
+
+  /**
+   * The truth_data (e.g. hash of answer to a secure question)
+   */
+  const void *truth_data;
+
+  /**
+   * Size of truth_data
+   */
+  size_t truth_data_size;
+
+  /**
+   * Expected status code.
+   */
+  unsigned int http_status;
+
+  /**
+   * The /truth POST operation handle.
+   */
+  struct ANASTASIS_TruthUpload *tuo;
+
+  /**
+   * closure for the payment callback
+   */
+  void *tpc_cls;
+
+  /**
+   * Reference to upload command of previous truth upload.
+   */
+  const char *upload_reference;
+
+  /**
+   * Truth object
+   */
+  const struct ANASTASIS_Truth *truth;
+};
+
+/**
+ * State for a "salt" CMD.
+ */
+struct SaltState
+{
+  /**
+   * URL of the anastasis backend.
+   */
+  const char *anastasis_url;
+
+  /**
+   * Expected status code.
+   */
+  unsigned int http_status;
+
+  /**
+   * The /salt GET operation handle.
+   */
+  struct ANASTASIS_SaltOperation *so;
+
+  /**
+   * The salt value from server.
+   */
+  struct ANASTASIS_CRYPTO_SaltP salt;
+};
+
 /**
  * Global option '--me' to import json containing details of user.
  */
@@ -53,6 +197,52 @@ static struct GNUNET_CURL_Context *ctx;
  */
 static struct GNUNET_CURL_RescheduleContext *rc;
 
+/**
+ * State for a "truth upload" CMD.
+ */
+static struct TruthUploadState *tu_states;
+
+/**
+ * Amount of truth upload states
+ */
+static unsigned int tu_states_length;
+
+
+/**
+ * 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 SaltState *ss = cls;
+
+  ss->so = NULL;
+  if (http_status != ss->http_status)
+  {
+    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;
+  }
+  ss->salt = *salt;
+}
+
 
 static void
 start_read_keyboard (void);
@@ -122,11 +312,28 @@ read_keyboard_command (void *cls)
     return;
   }
 
-  if (0 == strncmp ("server",
-                    buffer,
-                    strlen ("server")))
+  if ((0 == strncmp ("server",
+                     buffer,
+                     strlen ("server")))
+      && (characters == strlen ("server") + sizeof (char)))
   {
     // FIXME "server" logic here
+    if (NULL != tu_states)
+    {
+      for (unsigned int i = 0; i < tu_states_length; i++)
+      {
+        if (NULL != tu_states[i].backend_url)
+          printf ("server#%u: %s, %s, insured up to: %s, cost: %s\n",
+                  i,
+                  tu_states[i].backend_url,
+                  tu_states[i].backend_methods,
+                  TALER_amount_to_string (tu_states[i].backend_insurance),
+                  TALER_amount_to_string (tu_states[i].backend_cost));
+      }
+    }
+    else
+      printf ("Please add a server before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
@@ -137,17 +344,66 @@ read_keyboard_command (void *cls)
                     strlen ("server add")))
   {
     // FIXME "server add" logic here
+    struct TruthUploadState tus;
+    struct SaltState *ss;
+
+    ss = GNUNET_new (struct SaltState);
+    const char *url = &buffer[strlen ("server add ")];
+    tus.backend_url = url;
+    ss->anastasis_url = tus.backend_url;
+    ss->http_status = MHD_HTTP_OK;
+    ss->so = ANASTASIS_salt (ctx,
+                             tus.backend_url,
+                             salt_cb,
+                             ss);
+    if (NULL == ss->so)
+    {
+      GNUNET_break (0);
+      return;
+    }
+    tus.backend_salt = &ss->salt;
+
+    // FIXME /terms request here, DELETE next 3 lines!
+    tus.backend_methods = "Secure-Question";
+    // TALER_amount_get_zero ("KUDOS", tus.backend_insurance);
+    // TALER_amount_get_zero ("KUDOS", tus.backend_cost);
+
+    GNUNET_array_append (tu_states,
+                         tu_states_length,
+                         tus);
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
     return;
   }
 
-  if (0 == strncmp ("truth",
-                    buffer,
-                    strlen ("truth")))
+  if ((0 == strncmp ("truth",
+                     buffer,
+                     strlen ("truth")))
+      && (characters == strlen ("truth") + sizeof (char)))
   {
     // FIXME "truth" logic here
+    if (NULL != tu_states)
+    {
+      for (unsigned int i = 0; i < tu_states_length; i++)
+      {
+        if (0 == strcmp ("SMS", tu_states[i].method))
+          printf ("truth#%u: %s %s\n",
+                  i,
+                  tu_states[i].method,
+                  tu_states[i].phone);
+        if (0 == strcmp ("Secure-Question", tu_states[i].method))
+        {
+          printf ("truth#%u: %s \"%s\" <OMITTED>\n",
+                  i,
+                  tu_states[i].method,
+                  tu_states[i].secret_question);
+        }
+      }
+    }
+    else
+      printf ("Please add a truth before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
@@ -158,16 +414,31 @@ read_keyboard_command (void *cls)
                     strlen ("truth add")))
   {
     // FIXME "truth add" logic here
+    if (NULL != tu_states)
+    {
+      // FIXME
+    }
+    else
+      printf ("Please add a server before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
     return;
   }
-  if (0 == strncmp ("truth add question",
-                    buffer,
-                    strlen ("truth add question")))
+  if ((0 == strncmp ("truth add question",
+                     buffer,
+                     strlen ("truth add question")))
+      && (characters == strlen ("truth add question") + sizeof (char)))
   {
     // FIXME "truth add question" logic here
+    if (NULL != tu_states)
+    {
+      // FIXME
+    }
+    else
+      printf ("Please add a server before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
@@ -178,15 +449,38 @@ read_keyboard_command (void *cls)
                     strlen ("truth --secrets")))
   {
     // FIXME "truth --secrets" logic here
+    if (NULL != tu_states)
+    {
+      for (unsigned int i = 0; i < tu_states_length; i++)
+      {
+        if (0 == strcmp ("SMS", tu_states[i].method))
+          printf ("truth#%u: %s %s\n",
+                  i,
+                  tu_states[i].method,
+                  tu_states[i].phone);
+        if (0 == strcmp ("Secure-Question", tu_states[i].method))
+        {
+          printf ("truth#%u: %s \"%s\" \"%s\"\n",
+                  i,
+                  tu_states[i].method,
+                  tu_states[i].secret_question,
+                  tu_states[i].secret_answer);
+        }
+      }
+    }
+    else
+      printf ("Please add a truth before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
     return;
   }
 
-  if (0 == strncmp ("policy",
-                    buffer,
-                    strlen ("policy")))
+  if ((0 == strncmp ("policy",
+                     buffer,
+                     strlen ("policy")))
+      && (characters == strlen ("policy") + sizeof (char)))
   {
     // FIXME "policy" logic here
     start_read_keyboard ();
@@ -205,9 +499,10 @@ read_keyboard_command (void *cls)
     return;
   }
 
-  if (0 == strncmp ("publish",
-                    buffer,
-                    strlen ("publish")))
+  if ((0 == strncmp ("publish",
+                     buffer,
+                     strlen ("publish")))
+      && (characters == strlen ("publish") + sizeof (char)))
   {
     // FIXME "publish" logic here
     start_read_keyboard ();

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]