gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: kill obsolete CLI tools


From: gnunet
Subject: [taler-anastasis] branch master updated: kill obsolete CLI tools
Date: Tue, 20 Oct 2020 15:32:46 +0200

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 15c935e  kill obsolete CLI tools
15c935e is described below

commit 15c935e8afcad609ab3facb43686c4ea78606b0c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Oct 20 15:32:44 2020 +0200

    kill obsolete CLI tools
---
 src/cli/Makefile.am               |   46 --
 src/cli/anastasis-cli-assembler.c |  854 --------------------
 src/cli/anastasis-cli-splitter.c  | 1562 -------------------------------------
 3 files changed, 2462 deletions(-)

diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index b401a11..096bdc9 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -2,8 +2,6 @@
 AM_CPPFLAGS = -I$(top_srcdir)/src/include
 
 bin_PROGRAMS = \
-  anastasis-splitter \
-  anastasis-assembler \
   anastasis-reducer
 
 if USE_COVERAGE
@@ -11,40 +9,6 @@ if USE_COVERAGE
   XLIB = -lgcov
 endif
 
-anastasis_splitter_SOURCES = \
-  anastasis-cli-splitter.c
-anastasis_splitter_LDADD = \
-  $(top_builddir)/src/util/libanastasisutil.la \
-  $(top_builddir)/src/lib/libanastasisrest.la \
-  $(top_builddir)/src/lib/libanastasis.la \
-  -ltalermerchant \
-  -ltalerjson \
-  -ltalerutil \
-  -lgnunetjson \
-  -lgnunetcurl \
-  -lgnunetutil \
-  -ljansson \
-  -luuid \
-  -lreadline \
-  $(XLIB)
-
-anastasis_assembler_SOURCES = \
-  anastasis-cli-assembler.c
-anastasis_assembler_LDADD = \
-  $(top_builddir)/src/util/libanastasisutil.la \
-  $(top_builddir)/src/lib/libanastasisrest.la \
-  $(top_builddir)/src/lib/libanastasis.la \
-  -ltalermerchant \
-  -ltalerjson \
-  -ltalerutil \
-  -lgnunetjson \
-  -lgnunetcurl \
-  -lgnunetutil \
-  -ljansson \
-  -luuid \
-  -lreadline \
-  $(XLIB)
-
 anastasis_reducer_SOURCES = \
   anastasis-cli-redux.c
 anastasis_reducer_LDADD = \
@@ -56,13 +20,3 @@ anastasis_reducer_LDADD = \
   -lgnunetutil \
   -ljansson \
   $(XLIB)
-
-if HAVE_LIBCURL
-anastasis_splitter_LDADD += -lcurl
-anastasis_assembler_LDADD += -lcurl
-else
-if HAVE_LIBGNURL
-anastasis_splitter_LDADD += -lgnurl
-anastasis_assembler_LDADD += -lgnurl
-endif
-endif
diff --git a/src/cli/anastasis-cli-assembler.c 
b/src/cli/anastasis-cli-assembler.c
deleted file mode 100644
index 2a9a2f4..0000000
--- a/src/cli/anastasis-cli-assembler.c
+++ /dev/null
@@ -1,854 +0,0 @@
-/*
-  This file is part of Anastasis
-  Copyright (C) 2020 Taler Systems SA
-
-  Anastasis is free software; you can redistribute it and/or modify it under 
the
-  terms of the GNU Lesser General Public License as published by the Free 
Software
-  Foundation; either version 3, or (at your option) any later version.
-
-  Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License along with
-  Anastasis; see the file COPYING.GPL.  If not, see 
<http://www.gnu.org/licenses/>
-*/
-/**
- * @file cli/anastasis-cli-assembler.c
- * @brief command line tool for anastasis
- * @author Christian Grothoff
- * @author Dennis Neufeld
- * @author Dominik Meister
- */
-#include "platform.h"
-#include <gnunet/gnunet_util_lib.h>
-#include <readline/readline.h>
-#include <readline/history.h>
-#include "anastasis_service.h"
-#include "anastasis.h"
-
-
-/**
- * Global option '--me' to import json containing details of user.
- */
-static char *import_id;
-
-/**
- * Global option '--import' to import json containing 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
- */
-static struct GNUNET_SCHEDULER_Task *keyboard_task;
-
-/**
- * Curl context for communication with anastasis backend
- */
-static struct GNUNET_CURL_Context *ctx;
-
-/**
- * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
- */
-static struct GNUNET_CURL_RescheduleContext *rc;
-
-/**
- * Information about the challenges.
- */
-static struct ANASTASIS_ChallengeInformation *challenges;
-
-/**
- * Amount of challenges.
- */
-static unsigned int challenges_length = 0;
-
-/**
- * Policies with information how to decrypt master key
- */
-static struct ANASTASIS_DecryptionPolicy *policies;
-
-/**
- * Amount of policies.
- */
-static unsigned int policies_length = 0;
-
-static void
-start_read_keyboard (void);
-
-/**
- * State for a "get config" CMD.
- */
-struct ConfigState
-{
-  /**
-   * Expected status code.
-   */
-  unsigned int http_status;
-
-  /**
-   * Challenge the ConfigState refers to.
-   */
-  struct ANASTASIS_ChallengeInformation *ci;
-
-  /**
-   * The /config GET operation handle.
-   */
-  struct ANASTASIS_ConfigOperation *co;
-
-  /**
-   * Reference to a ServerInfo.
-   */
-  struct ServerInfo *server;
-
-  /**
-   * Cost.
-   */
-  struct TALER_Amount cost;
-
-  /**
-   * Currency of the cost;
-   */
-  char *currency;
-
-  /**
-   * Supported methods.
-   */
-  char *methods;
-
-  // FIXME add configs
-};
-
-
-/**
- * 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_PowSalt *salt;
-
-  /**
-   * Recovery information from the lookup
-   */
-  const struct ANASTASIS_RecoveryInformation *ri;
-
-  /**
-   * The /salt GET operation handle.
-   */
-  struct ANASTASIS_SaltOperation *so;
-};
-
-/**
- * State for a "challenge answer" CMD.
- */
-struct ChallengeState
-{
-  /**
-   * 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 char *answer;
-
-  /**
-   * 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)
-  {
-    printf ("Failed truth#%u\n", cs->challenge_index);
-    return;
-  }
-  printf ("Success truth#%u\n", cs->challenge_index);
-  challenges[cs->challenge_index].solved = 1;
-}
-
-
-static void
-challenge_try_cb (void *af_cls,
-                  enum TALER_ErrorCode ec)
-{
-  /**
-   * FIXME: Implement mechanism to be able to try if payment is needed
-  struct ChallengeState *cs = af_cls;
-  */
-  return;
-}
-
-
-/**
- * @brief Read the character from stdin and activate the selected task
- *
- * @param cls closure
- */
-static void
-read_keyboard_command (void *cls)
-{
-  (void) cls;
-  char *buffer = readline ("anastasis-assembler> ");
-  size_t characters = strlen (buffer);
-
-  // Check for EOF.
-  if (! buffer)
-  {
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-  add_history (buffer);
-
-  keyboard_task = NULL;
-
-  if (characters == sizeof (char))
-  {
-    switch ((char) buffer[0])
-    {
-    case 'x':
-      GNUNET_SCHEDULER_shutdown ();
-      GNUNET_free (buffer);
-      buffer = NULL;
-      return;
-    case 'o':
-      printf (
-        "\nOPTIONS:\n"
-        "'x' to quit\n"
-        "'o' to show these options\n"
-        "'truth' to show all truths\n"
-        "'policies' to show all policies with missing challenges\n"
-        "'try' to check whether you have to pay for truth\n"
-        "'answer' to solve a challenge\n"
-        "\n"
-        );
-      GNUNET_free (buffer);
-      buffer = NULL;
-      break;
-    default:
-      fprintf (stderr,
-               "Unknown command '%c'\n",
-               buffer[0]);
-      GNUNET_free (buffer);
-      buffer = NULL;
-      break;
-    }
-    start_read_keyboard ();
-    return;
-  }
-
-  if ((0 == strncmp ("truth",
-                     buffer,
-                     strlen ("truth")))
-      && (characters == strlen ("truth")))
-  {
-    for (unsigned int i = 0; i < challenges_length; i++)
-    {
-      char solved_state = '-';
-      if (challenges[i].solved == 1)
-        solved_state = '+';
-      printf ("truth#%u(%c): %s %s ",
-              i,
-              solved_state,
-              TALER_amount_to_string (challenges[i].cost),
-              challenges[i].method);
-      if (0 == strcmp (challenges[i].method, "question"))
-        printf ("\"%s\"", challenges[i].instructions);
-      printf ("\n");
-    }
-    start_read_keyboard ();
-    GNUNET_free (buffer);
-    buffer = NULL;
-    return;
-  }
-
-  if ((0 == strncmp ("policies",
-                     buffer,
-                     strlen ("policies")))
-      && (characters == strlen ("policies")))
-  {
-    for (unsigned int i = 0; i < policies_length; i++)
-    {
-      // Calculate costs
-      struct TALER_Amount *costs; // different cost for different currencies
-      char **currencies;
-      unsigned int costs_len = 0;
-
-      for (unsigned int j = 0; j < policies[i].nonces_length; j++)
-      {
-        for (unsigned int k = 0; k < challenges_length; k++)
-        {
-          if (0 == memcmp (&policies[i].nonces[j],
-                           challenges[k].nonce,
-                           sizeof(struct ANASTASIS_CRYPTO_NonceP)))
-          {
-            unsigned int new_currency = 1;
-            unsigned int index = 0;
-            for (unsigned int l = 0; l < costs_len; l++)
-            {
-              if (0 == strcmp (challenges[k].currency, currencies[l]))
-              {
-                index = l;
-                new_currency = 0;
-                break;
-              }
-            }
-            if (0 == costs_len)
-            {
-              costs = GNUNET_new_array (1, struct TALER_Amount);
-              currencies = GNUNET_new_array (1, char *);
-
-              GNUNET_assert (GNUNET_OK ==
-                             TALER_amount_get_zero (challenges[k].currency,
-                                                    &costs[0]));
-              currencies[0] = GNUNET_malloc (strlen (challenges[k].currency)
-                                             + 1);
-              GNUNET_strlcpy (currencies[0],
-                              challenges[k].currency,
-                              strlen (challenges[k].currency) + 1);
-              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                          "At %s:%d cost is %s\n", __FILE__, __LINE__,
-                          TALER_amount_to_string (&costs[0]));
-              costs_len = 1;
-              new_currency = 0;
-            }
-            if (1 == new_currency)
-            {
-              struct TALER_Amount cost;
-              GNUNET_assert (GNUNET_OK ==
-                             TALER_amount_get_zero (challenges[k].currency,
-                                                    &cost));
-              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                          "At %s:%d cost is %s\n", __FILE__, __LINE__,
-                          TALER_amount_to_string (&cost));
-              GNUNET_array_append (costs,
-                                   costs_len,
-                                   cost);
-              GNUNET_array_append (currencies,
-                                   costs_len,
-                                   challenges[k].currency);
-              index = costs_len - 1;
-            }
-
-            TALER_amount_add (&costs[index],
-                              &costs[index],
-                              challenges[k].cost);
-          }
-        }
-      }
-      printf ("policy#%u: ", i);
-      for (unsigned int l = 0; l < costs_len; l++)
-      {
-        printf ("%s ", TALER_amount_to_string (&costs[l]));
-      }
-      for (unsigned int j = 0; j < policies[i].nonces_length; j++)
-      {
-        for (unsigned int k = 0; k < challenges_length; k++)
-        {
-          if (0 == memcmp (&policies[i].nonces[j],
-                           challenges[k].nonce,
-                           sizeof(struct ANASTASIS_CRYPTO_NonceP)))
-            if (1 != challenges[k].solved)
-              printf ("truth#%u ", k);
-        }
-      }
-      printf ("missing\n");
-    }
-    start_read_keyboard ();
-    GNUNET_free (buffer);
-    buffer = NULL;
-    return;
-  }
-
-  if (0 == strncmp ("try",
-                    buffer,
-                    strlen ("try")))
-  {
-    struct ChallengeState *cs = GNUNET_new (struct ChallengeState);
-    char *token_start = &buffer[strlen ("try ")];
-    char *token = strtok (token_start, " ");
-
-    unsigned int truth_index;
-    if (0 != strncmp ("truth#",
-                      token,
-                      strlen ("truth#")))
-    {
-      printf ("Wrong argument: %s!\n", token);
-      free (buffer);
-      start_read_keyboard ();
-      return;
-    }
-    truth_index = (int) token[strlen ("truth#")] - 48;
-
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d truth index is %u\n", __FILE__, __LINE__,
-                truth_index);
-
-    cs->http_status = MHD_HTTP_PAYMENT_REQUIRED;
-    cs->answer = "try";
-    cs->challenge_index = truth_index;
-
-    ANASTASIS_challenge_answer (ctx,
-                                challenges[truth_index].challenge,
-                                cs->answer,
-                                &challenge_try_cb,
-                                cs);
-    start_read_keyboard ();
-    GNUNET_free (buffer);
-    buffer = NULL;
-    return;
-  }
-
-  if (0 == strncmp ("answer",
-                    buffer,
-                    strlen ("answer")))
-  {
-    struct ChallengeState *cs = GNUNET_new (struct ChallengeState);
-    char *token_start = &buffer[strlen ("answer ")];
-    char *token = strtok (token_start, " ");
-
-    unsigned int truth_index;
-    if (0 != strncmp ("truth#",
-                      token,
-                      strlen ("truth#")))
-    {
-      printf ("Wrong argument: %s!\n", token);
-      free (buffer);
-      start_read_keyboard ();
-      return;
-    }
-    truth_index = (int) token[strlen ("truth#")] - 48;
-
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d truth index is %u\n", __FILE__, __LINE__,
-                truth_index);
-
-    if (0 == strcmp (challenges[truth_index].method, "question"))
-      token = strtok (NULL, "\"");
-
-    char *challenge_answer = GNUNET_malloc (strlen (token) + 1);
-    GNUNET_strlcpy (challenge_answer,
-                    token,
-                    strlen (token) + 1);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d challenge answer is %s\n", __FILE__, __LINE__,
-                challenge_answer);
-
-    cs->http_status = MHD_HTTP_OK;
-    cs->answer = challenge_answer;
-    cs->challenge_index = truth_index;
-
-    ANASTASIS_challenge_answer (ctx,
-                                challenges[truth_index].challenge,
-                                cs->answer,
-                                &challenge_answer_cb,
-                                cs);
-    start_read_keyboard ();
-    GNUNET_free (buffer);
-    return;
-  }
-
-  fprintf (stderr,
-           "Unknown command '%s'\n",
-           buffer);
-  GNUNET_free (buffer);
-  start_read_keyboard ();
-}
-
-
-/**
- * @brief Wait for a keyboard input
- */
-static void
-start_read_keyboard ()
-{
-  static struct GNUNET_DISK_FileHandle fh = { STDIN_FILENO };
-
-  GNUNET_assert (NULL == keyboard_task);
-
-  if (! import_id)
-  {
-    printf ("Please provide user details with option '--me file.json'!\n");
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-
-
-  printf ("'x' to quit\n");
-  printf ("'o' to show options\n");
-  printf ("Waiting for keyboard input\n");
-  keyboard_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                  &fh,
-                                                  &read_keyboard_command,
-                                                  NULL);
-}
-
-
-/**
- * Function called with the results of a #ANASTASIS_get_config().
- *
- * @param cls closure
- * @param http_status HTTP status of the request
- * @param methods supported methods by this provider
- * @param conf_currency
- * @param annual_fee Annual fee of this service
- */
-static void
-config_cb (void *cls,
-           unsigned int http_status,
-           const json_t *methods,
-           const char *conf_currency,
-           const struct TALER_Amount *annual_fee)
-{
-  struct ConfigState *cs = cls;
-  size_t index;
-  json_t *method;
-
-  cs->co = NULL;
-  if (http_status != cs->http_status)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Unexpected response code %u in %s:%u\n",
-                http_status,
-                __FILE__,
-                __LINE__);
-    return;
-  }
-
-  json_t *method_arr = json_object_get (methods,
-                                        "methods");
-  json_array_foreach (method_arr, index, method)
-  {
-    if (json_object_get (method, cs->ci->method))
-    {
-      struct TALER_Amount *amount;
-      TALER_string_to_amount (json_string_value (json_object_get (
-                                                   method, "method_cost")),
-                              amount);
-      cs->ci->cost = GNUNET_new (struct TALER_Amount);
-      GNUNET_memcpy (cs->ci->cost,
-                     amount,
-                     sizeof (*amount));
-      break;
-    }
-  }
-  cs->ci->currency = GNUNET_malloc (strlen (conf_currency) + 1);
-  GNUNET_strlcpy (cs->ci->currency,
-                  conf_currency,
-                  strlen (conf_currency) + 1);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d cost is %s\n", __FILE__, __LINE__,
-              TALER_amount_to_string (cs->ci->cost));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d currency is %s\n", __FILE__, __LINE__,
-              cs->ci->currency);
-
-  unsigned int contains = 0;
-  for (unsigned int i = 0; i < challenges_length; i++)
-  {
-    if (0 == memcmp (challenges[i].nonce,
-                     cs->ci->nonce,
-                     sizeof(struct ANASTASIS_CRYPTO_NonceP)))
-    {
-      contains = 1;
-      break;
-    }
-  }
-  if (0 == contains)
-    GNUNET_array_append (challenges,
-                         challenges_length,
-                         *cs->ci);
-}
-
-
-/**
- * Defines a Challenge Callback which is initially sent with the get 
challenge. It gives back the previously
- * defined Challenge Information and a Status Code, like "payment missing".
- *
- * @param cls handle for the callback
- * @param ec enum which defines the different status codes
- *
-*/
-static void
-challenge_cb (void *cls,
-              enum TALER_ErrorCode ec)
-{
-  // FIXME handle ec
-  struct ANASTASIS_ChallengeInformation *ci = cls;
-  struct ConfigState *cs = GNUNET_new (struct ConfigState);
-
-  cs->http_status = MHD_HTTP_OK;
-  cs->ci = ci;
-  cs->co = ANASTASIS_get_config (ctx,
-                                 ci->url,
-                                 config_cb,
-                                 cs);
-  if (NULL == cs->co)
-  {
-    GNUNET_break (0);
-    return;
-  }
-}
-
-
-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;
-  }
-  for (unsigned int i = 0; i < rss->ri->cs_len; i++)
-  {
-    ANASTASIS_get_challenge (rss->ri->cs[i],
-                             &challenge_cb);
-  }
-  policies = rss->ri->dps;
-  policies_length = rss->ri->dps_len;
-
-  start_read_keyboard ();
-  return;
-}
-
-
-static void
-core_secret_cb (void *cls,
-                const void *secret,
-                size_t secret_size)
-{
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d arrived at core secret cb \n", __FILE__, __LINE__);
-  printf ("Secret was: \"%s\" Size: %lu b\n",
-          (char *) secret,
-          secret_size);
-  return;
-}
-
-
-/**
- * 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_PowSalt *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.
- *
- * @param cls closure
- */
-static void
-shutdown_task (void *cls)
-{
-  (void) cls;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Shutdown initiated\n");
-
-  // FIXME shutdown routine here
-  if (NULL != keyboard_task)
-  {
-    GNUNET_SCHEDULER_cancel (keyboard_task);
-    keyboard_task = NULL;
-  }
-  if (NULL != ctx)
-  {
-    GNUNET_CURL_fini (ctx);
-    ctx = NULL;
-  }
-  if (NULL != rc)
-  {
-    GNUNET_CURL_gnunet_rc_destroy (rc);
-    rc = NULL;
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Shutdown complete\n");
-}
-
-
-/**
- * @brief Start the application
- *
- * @param cls closure
- * @param args arguments left
- * @param cfgfile config file name
- * @param cfg handle for the configuration file
- */
-static void
-run (void *cls,
-     char *const *args,
-     const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-  (void) cls;
-  (void) args;
-  (void) cfgfile;
-
-  struct RecoverSecretState *rss;
-  rss = GNUNET_new (struct RecoverSecretState);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Starting anastasis-assembler\n");
-
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                 NULL);
-
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_log_setup ("anastasis-assembler",
-                                   "WARNING",
-                                   NULL));
-
-  /* initialize HTTP client */
-  ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
-                          &rc);
-  rc = GNUNET_CURL_gnunet_rc_create (ctx);
-  // 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
-main (int argc,
-      char *const *argv)
-{
-  int ret;
-
-  /* the available command line options */
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    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
-  };
-
-  ret = GNUNET_PROGRAM_run (argc,
-                            argv,
-                            "anastasis-assembler",
-                            "This is an application for using Anastasis to 
assemble the core secret from recovery document.\n",
-                            options,
-                            &run,
-                            NULL);
-
-  return (GNUNET_OK == ret) ? 0 : 1;
-}
-
-
-/* end of anastasis-cli-assembler.c */
diff --git a/src/cli/anastasis-cli-splitter.c b/src/cli/anastasis-cli-splitter.c
deleted file mode 100644
index c790e90..0000000
--- a/src/cli/anastasis-cli-splitter.c
+++ /dev/null
@@ -1,1562 +0,0 @@
-/*
-  This file is part of Anastasis
-  Copyright (C) 2020 Taler Systems SA
-
-  Anastasis is free software; you can redistribute it and/or modify it under 
the
-  terms of the GNU Lesser General Public License as published by the Free 
Software
-  Foundation; either version 3, or (at your option) any later version.
-
-  Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License along with
-  Anastasis; see the file COPYING.GPL.  If not, see 
<http://www.gnu.org/licenses/>
-*/
-/**
- * @file cli/anastasis-cli-splitter.c
- * @brief command line tool for anastasis
- * @author Christian Grothoff
- * @author Dennis Neufeld
- * @author Dominik Meister
- */
-#include "platform.h"
-#include <gnunet/gnunet_util_lib.h>
-#include <readline/readline.h>
-#include <readline/history.h>
-#include <taler/taler_util.h>
-#include "anastasis.h"
-
-/**
- * State for a "truth upload" CMD.
- */
-struct TruthUploadState
-{
-  /**
-   * Index of the truth.
-   */
-  unsigned int index;
-
-  /**
-   * The ID data to generate user identifier
-   */
-  const json_t *id_data;
-
-  /**
-   * The escrow method
-   */
-  char *method;
-
-  /**
-   * A secret question
-   */
-  char *secret_question;
-
-  /**
-   * Answer to secret question
-   */
-  char *secret_answer;
-
-  /**
-   * Phonenumber for method SMS
-   */
-  char *phone;
-
-  /**
-   * E-Mail address
-   */
-  char *mail;
-
-  /**
-   * Instructions to be returned to client/user
-   * (e.g. "Look at your smartphone. SMS was sent to you")
-   */
-  char *instructions;
-
-  /**
-   * Mime type of truth_data (eg. jpeg, string etc.)
-   */
-  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
-   */
-  struct ANASTASIS_Truth *truth;
-};
-
-/**
- * Server information
- */
-struct ServerInfo
-{
-  /**
-   * URL of the anastasis backend.
-   */
-  char *backend_url;
-
-  /**
-   * label of the anastasis backend.
-   */
-  const char *backend_label;
-
-  /**
-   * supported methods of the anastasis backend.
-   */
-  json_t *backend_methods;
-
-  /**
-   * server salt of the anastasis backend.
-   */
-  const struct ANASTASIS_CRYPTO_PowSalt *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;
-
-  /**
-   * user identifier derived from user data and backend salt
-   */
-  struct ANASTASIS_CRYPTO_UserIdentifierP *user_id;
-};
-
-/**
- * State for a "salt" CMD.
- */
-struct SaltState
-{
-  /**
-   * Expected status code.
-   */
-  unsigned int http_status;
-
-  /**
-   * The /salt GET operation handle.
-   */
-  struct ANASTASIS_SaltOperation *so;
-
-  /**
-   * The salt value from server.
-   */
-  struct ANASTASIS_CRYPTO_PowSalt salt;
-
-  /**
-   * Reference to a ServerInfo.
-   */
-  struct ServerInfo *server;
-};
-
-/**
- * State for a "get config" CMD.
- */
-struct ConfigState
-{
-  /**
-   * Expected status code.
-   */
-  unsigned int http_status;
-
-  /**
-   * The /config GET operation handle.
-   */
-  struct ANASTASIS_ConfigOperation *co;
-
-  /**
-   * Reference to a ServerInfo.
-   */
-  struct ServerInfo *server;
-
-  /**
-   * Cost.
-   */
-  struct TALER_Amount cost;
-
-  /**
-   * Supported methods.
-   */
-  json_t *methods;
-
-  // FIXME add configs
-};
-
-/**
- * State for a "policy create" CMD.
- */
-struct PolicyCreateState
-{
-  /**
-   * Array of References to TruthUploadStates.
-   */
-  struct TruthUploadState **tu_states;
-
-  /**
-   * Lengths of truths.
-   */
-  unsigned int tu_states_len;
-
-  /**
-   * Policy object
-   */
-  const struct ANASTASIS_Policy *policy;
-};
-
-/**
- * State for a "secret share" CMD.
- */
-struct SecretShareState
-{
-  /**
-   * Data to derive user identifier from.
-   */
-  const json_t *id_data;
-
-  /**
-   * The core secret to backup/recover.
-   */
-  void *core_secret;
-
-  /**
-   * Size of core_secret.
-   */
-  size_t core_secret_size;
-
-  /**
-   * Expected status code.
-   */
-  unsigned int http_status;
-
-  /**
-   * The /truth GET operation handle.
-   */
-  struct ANASTASIS_SecretShare *sso;
-
-  /**
-   * closure for the payment callback
-   */
-  void *spc_cls;
-
-  /**
-   * closure for the result callback
-   */
-  void *src_cls;
-
-  /**
-   * Payment order ID we got back, if any. Otherwise NULL.
-   */
-  const char *payment_order_id;
-
-};
-
-
-/**
- * Global option '--me' to import json containing details of user.
- */
-static char *import_id;
-
-/**
- * Global option '--import' to import json containing recovery document.
- */
-static int import_recovery_document;
-
-/**
- * Reference to the keyboard task
- */
-static struct GNUNET_SCHEDULER_Task *keyboard_task;
-
-/**
- * Curl context for communication with taler backend
- */
-static struct GNUNET_CURL_Context *ctx;
-
-/**
- * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
- */
-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 = 0;
-
-/**
- * Information about the servers.
- */
-static struct ServerInfo *servers;
-
-/**
- * Amount of servers.
- */
-static unsigned int servers_length = 0;
-
-/**
- * State for a "policy create" CMD.
- */
-static struct PolicyCreateState *pc_states;
-
-/**
- * Amount of policy create states.
- */
-static unsigned int pc_states_length = 0;
-
-/**
- * PaymentDetails.
- */
-static struct ANASTASIS_PaymentDetails *pds;
-
-/**
- * Amount of pds.
- */
-static unsigned int pds_length = 0;
-
-
-static void
-start_read_keyboard (void);
-
-
-/**
- * Function called for payment routine.
- *
- * @param cls closure
- * @param taler_pay_url url for the payment (taler://pay/Foo)
- * @param server_url url of the server to pay for
- * @param ec status of the request
- */
-static void
-secret_share_payment_cb (void *cls,
-                         const char *taler_pay_url,
-                         const char *server_url,
-                         enum TALER_ErrorCode ec)
-{
-  const char *m;
-  struct SecretShareState *sss = cls;
-  sss->sso = NULL;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "At %s:%d we are in SPC\n",
-              __FILE__, __LINE__);
-  if (! ((sss->http_status == MHD_HTTP_PAYMENT_REQUIRED)
-         || (sss->http_status == MHD_HTTP_NO_CONTENT) ))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Unexpected response code %u/%d in %s:%u\n",
-                sss->http_status,
-                (int) ec,
-                __FILE__,
-                __LINE__);
-    GNUNET_break (0);
-    keyboard_task = NULL;
-    start_read_keyboard ();
-    return;
-  }
-
-  if (0 != strncmp (taler_pay_url,
-                    "taler://pay/http",
-                    strlen ("taler://pay/http")))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Did not find `%s' in `%s'\n",
-                "/-/-/",
-                taler_pay_url);
-    GNUNET_break (0);
-    keyboard_task = NULL;
-    start_read_keyboard ();
-    return;
-  }
-  m = strstr (taler_pay_url, "/-/-/");
-  if (NULL == m)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Did not find `%s' in `%s'\n",
-                "/-/-/",
-                taler_pay_url);
-    /* NOTE: The above is a simplifying assumption for the
-        test-logic, hitting this code merely means that
-        the assumptions for the test (i.e. no instance) are
-        not satisfied, it is not inherently the case that
-        the above token must appear in the payment request!
-
-        So if you hit this, you might just want to modify
-        the code here to handle this better! */return;
-  }
-  sss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "At %s:%d Order ID from Anastasis service is %s\n",
-              __FILE__, __LINE__,
-              sss->payment_order_id);
-  for (unsigned int i = 0; i < pds_length; i++)
-  {
-    if (0 == strcmp (pds[i].provider_url,
-                     server_url))
-    {
-      printf ("Server#%u failure: 402 payment required: %s %s\n",
-              i,
-              taler_pay_url,
-              TALER_amount_to_string (servers[i].backend_cost));
-    }
-  }
-  keyboard_task = NULL;
-  start_read_keyboard ();
-}
-
-
-/**
- * Function called with the results of a #secret_share().
- *
- * @param cls closure
- * @param @param current_etag sends back the etag of the upload (used to 
prevent redundant uploads)
- * @param ec status code of the request
- * @param http_status http status code
- */
-static void
-secret_share_result_cb (void *cls,
-                        const struct GNUNET_HashCode *current_etag,
-                        const enum TALER_ErrorCode ec,
-                        unsigned int http_status)
-{
-  struct SecretShareState *sss = cls;
-  sss->sso = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "At %s:%d we are in SRC\n",
-              __FILE__, __LINE__);
-  if (NULL != sss)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d etag is %s-%llu b\n", __FILE__, __LINE__,
-                TALER_B2S (&current_etag),
-                (unsigned long long) sizeof (struct GNUNET_HashCode));
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d error code is %d\n", __FILE__, __LINE__,
-                ec);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d http status is %u\n", __FILE__, __LINE__,
-                http_status);
-
-    if (http_status != sss->http_status)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Unexpected response code %u/%d in %s:%u\n",
-                  http_status,
-                  (int) ec,
-                  __FILE__,
-                  __LINE__);
-      GNUNET_break (0);
-      keyboard_task = NULL;
-      start_read_keyboard ();
-      return;
-    }
-  }
-  printf ("Thank you for using Anastasis\n");
-  GNUNET_free (sss->core_secret);
-  keyboard_task = NULL;
-  start_read_keyboard ();
-  return;
-}
-
-
-/**
- * Initiates a callback for the payment of the truth upload
- *
- * @param cls closure
- * @param taler_pay_url payment link for the transaction (taler://pay/Foo)
- * @param ec status code of the request
- */
-static void
-truth_payment_cb (void *cls,
-                  const char *taler_pay_url,
-                  enum TALER_ErrorCode ec)
-{
-  struct TruthUploadState *tus = cls;
-  tus->tuo = NULL;
-  // FIXME: Payment handling
-  keyboard_task = NULL;
-  start_read_keyboard ();
-  return;
-}
-
-
-/**
-* Upload information
-* caller MUST free 't' using ANASTASIS_truth_free()
-*
-* @param cls closure for callback
-* @param t Truth object (contains provider url and truth public key)
-* @param t_size size of t
-*/
-static void
-truth_upload_cb (void *cls,
-                 struct ANASTASIS_Truth *t)
-{
-  struct TruthUploadState *tus = cls;
-  tus->tuo = NULL;
-
-  if (NULL == t)
-  {
-    GNUNET_break (0);
-    keyboard_task = NULL;
-    start_read_keyboard ();
-    return;
-  }
-  tus->truth = t;
-  keyboard_task = NULL;
-  start_read_keyboard ();
-  return;
-}
-
-
-/**
- * Function called with the results of a #ANASTASIS_get_config().
- *
- * @param cls closure
- * @param http_status HTTP status of the request
- * @param methods supported methods by this provider
- * @param annual_fee Annual fee of this service
- */
-static void
-config_cb (void *cls,
-           unsigned int http_status,
-           const json_t *methods,
-           const char *conf_currency,
-           const struct TALER_Amount *annual_fee)
-{
-  struct ConfigState *cs = cls;
-  struct ANASTASIS_PaymentDetails pd;
-
-  cs->co = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d url is %s\n", __FILE__, __LINE__,
-              cs->server->backend_url);
-  if (http_status != cs->http_status)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Unexpected response code %u in %s:%u\n",
-                http_status,
-                __FILE__,
-                __LINE__);
-    printf ("Server #%u is not available!\n",
-            servers_length);
-    keyboard_task = NULL;
-    start_read_keyboard ();
-    return;
-  }
-
-  cs->cost = *annual_fee;
-  cs->methods = methods;
-  printf ("Server #%u is available\n",
-          servers_length);
-
-  cs->server->backend_methods = cs->methods;
-  cs->server->backend_cost = &cs->cost;
-  memset (&pd,
-          0,
-          sizeof (pd));
-  pd.provider_url = cs->server->backend_url;
-  GNUNET_array_append (pds,
-                       pds_length,
-                       pd);
-  // FIXME add config max insurance amount
-
-  GNUNET_array_append (servers,
-                       servers_length,
-                       *cs->server);
-  keyboard_task = NULL;
-  start_read_keyboard ();
-}
-
-
-/**
- * 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_PowSalt *salt)
-{
-  struct SaltState *ss = cls;
-  struct ConfigState *cs = GNUNET_new (struct ConfigState);
-
-  ss->so = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d url is %s\n", __FILE__, __LINE__,
-              ss->server->backend_url);
-  if (http_status != ss->http_status)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Unexpected response code %u in %s:%u\n",
-                http_status,
-                __FILE__,
-                __LINE__);
-    printf ("Server #%u is not available!\n",
-            servers_length);
-    keyboard_task = NULL;
-    start_read_keyboard ();
-    return;
-  }
-  ss->salt = *salt;
-  ss->server->backend_salt = &ss->salt;
-
-  cs->server = ss->server;
-  json_error_t error;
-  const json_t *id_data;
-  if (NULL == (id_data = json_load_file (import_id,
-                                         JSON_DECODE_ANY,
-                                         &error)))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Failed to parse `%s': %s at %d:%d (%d)\n",
-                import_id,
-                error.text,
-                error.line,
-                error.column,
-                error.position);
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-  cs->server->user_id = GNUNET_new (struct ANASTASIS_CRYPTO_UserIdentifierP);
-  ANASTASIS_CRYPTO_user_identifier_derive (id_data,
-                                           salt,
-                                           cs->server->user_id);
-  cs->http_status = MHD_HTTP_OK;
-  cs->co = ANASTASIS_get_config (ctx,
-                                 cs->server->backend_url,
-                                 config_cb,
-                                 cs);
-  if (NULL == cs->co)
-  {
-    GNUNET_break (0);
-    keyboard_task = NULL;
-    return;
-  }
-}
-
-
-/**
- * @brief Read the character from stdin and activate the selected task
- *
- * @param cls closure
- */
-static void
-read_keyboard_command (void *cls)
-{
-  (void) cls;
-
-  // Configure readline to auto-complete paths when the tab key is hit.
-  rl_bind_key ('\t', rl_complete);
-  char *buffer = readline ("anastasis-splitter> ");
-  size_t characters = strlen (buffer);
-
-  // Check for EOF.
-  if (! buffer)
-  {
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-  add_history (buffer);
-
-  keyboard_task = NULL;
-
-  if (characters == sizeof (char))
-  {
-    switch ((char) buffer[0])
-    {
-    case 'x':
-      GNUNET_SCHEDULER_shutdown ();
-      free (buffer);
-      buffer = NULL;
-      return;
-    case 'o':
-      printf (
-        "\nOPTIONS:\n"
-        "'x' to quit\n"
-        "'o' to show these options\n"
-        "'server' to show added server\n"
-        "'server add' to add a provider/server\n"
-        "'truth' to show created truths\n"
-        "'truth add' to add truth to a server\n"
-        "'truth add question' to create a truth with method 'secure 
question'\n"
-        "'truth --secrets' to show created truths with their secrets"
-        "'policy' to show created policies\n"
-        "'policy add' to add truths to a policy\n"
-        "'publish' to upload the recovery document\n"
-        "\n"
-        );
-      free (buffer);
-      break;
-    default:
-      fprintf (stderr,
-               "Unknown command '%c'\n",
-               buffer[0]);
-      free (buffer);
-      buffer = (char *) NULL;
-      break;
-    }
-    start_read_keyboard ();
-    return;
-  }
-
-  if ((0 == strncmp ("server",
-                     buffer,
-                     strlen ("server")))
-      && (characters == strlen ("server")))
-  {
-    if (NULL != servers)
-    {
-      for (unsigned int i = 0; i < servers_length; i++)
-      {
-        char *methods_str = "";
-        size_t index;
-        json_t *method;
-        json_t *method_arr = json_object_get (
-          servers[i].backend_methods, "methods");
-
-        json_array_foreach (method_arr,
-                            index,
-                            method)
-        {
-          char *buf = GNUNET_malloc (strlen (methods_str) + 1);
-          const char *method_str = json_string_value (
-            json_object_get (method, "method"));;
-          if (method_str)
-          {
-            if (strlen (methods_str) > 0)
-            {
-              GNUNET_strlcpy (buf,
-                              methods_str,
-                              strlen (methods_str));
-              GNUNET_free (methods_str);
-              GNUNET_asprintf (&methods_str,
-                               ", %s, %s",
-                               buf,
-                               method_str);
-            }
-            else
-              GNUNET_asprintf (&methods_str,
-                               "%s",
-                               method_str);
-            GNUNET_free (buf);
-          }
-        }
-        if (NULL != servers[i].backend_url)
-          printf ("server#%u: %s %s, insured up to: %s, cost: %s\n",
-                  i,
-                  servers[i].backend_url,
-                  methods_str,
-                  "test_insurance_amount", // FIXME
-                  TALER_amount_to_string (servers[i].backend_cost)
-                  );
-        GNUNET_free (methods_str);
-      }
-    }
-    else
-      printf ("Please add a server before!\n");
-
-    free (buffer);
-    buffer = (char *) NULL;
-    start_read_keyboard ();
-    return;
-  }
-  if (0 == strncmp ("server add",
-                    buffer,
-                    strlen ("server add")))
-  {
-    struct ServerInfo *server = GNUNET_new (struct ServerInfo);
-    struct SaltState *ss = GNUNET_new (struct SaltState);
-
-    size_t url_len = characters - strlen ("server add ");
-    if ((0 == url_len) ||
-        (characters < strlen ("server add ")))
-    {
-      printf (
-        "Sorry, something went wrong with your command: Server Url 
missing.\n");
-      free (buffer);
-      buffer = (char *) NULL;
-      keyboard_task = NULL;
-      start_read_keyboard ();
-      return;
-    }
-    char *url = &buffer[strlen ("server add ")];
-    server->backend_url = GNUNET_malloc (url_len + 1);
-    GNUNET_strlcpy (server->backend_url,
-                    url,
-                    url_len + 1);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d url is %s\n", __FILE__, __LINE__,
-                server->backend_url);
-
-    ss->http_status = MHD_HTTP_OK;
-    ss->server = server;
-    ss->so = ANASTASIS_salt (ctx,
-                             server->backend_url,
-                             salt_cb,
-                             ss);
-    if (NULL == ss->so)
-    {
-      GNUNET_break (0);
-      free (buffer);
-      buffer = (char *) NULL;
-      keyboard_task = NULL;
-      return;
-    }
-    free (buffer);
-    return;
-  }
-
-  if ((0 == strncmp ("truth",
-                     buffer,
-                     strlen ("truth")))
-      && (characters == strlen ("truth")))
-  {
-    if (NULL != tu_states)
-    {
-      for (unsigned int i = 0; i < tu_states_length; i++)
-      {
-        if ((NULL != tu_states[i].method) &&
-            (0 == strcmp ("sms", tu_states[i].method)))
-          printf ("truth#%u: %s %s\n",
-                  i,
-                  tu_states[i].method,
-                  tu_states[i].phone);
-        if ((NULL != tu_states[i].method) &&
-            (0 == strcmp ("question", tu_states[i].method)))
-        {
-          printf ("truth#%u: %s \"%s\" <OMITTED>\n",
-                  tu_states[i].index,
-                  tu_states[i].method,
-                  tu_states[i].secret_question);
-        }
-      }
-    }
-    else
-      printf ("Please add a truth before!\n");
-
-    free (buffer);
-    buffer = (char *) NULL;
-    keyboard_task = NULL;
-    start_read_keyboard ();
-    return;
-  }
-  if (0 == strncmp ("truth add",
-                    buffer,
-                    strlen ("truth add")))
-  {
-    if (NULL != servers)
-    {
-      struct TruthUploadState *tus = GNUNET_new (struct TruthUploadState);
-      char *truth_details = &buffer[strlen ("truth add ")];
-      char *token = strtok (truth_details, " ");
-      if (! token)
-      {
-        printf (
-          "Sorry, something went wrong with your command: Server is 
missing.\n");
-        printf (
-          "Example: truth add server#0 question \"question\" \"answer\"\n");
-        free (buffer);
-        buffer = (char *) NULL;
-        keyboard_task = NULL;
-        start_read_keyboard ();
-        return;
-      }
-      unsigned int server_num;
-      tus->secret_question = NULL;
-      tus->secret_answer = NULL;
-      tus->instructions = NULL;
-      if (0 == strncmp ("server#",
-                        token,
-                        strlen ("server#")))
-      {
-        server_num = (int) token[strlen ("server#")] - 48;
-        if (server_num > servers_length)
-        {
-          printf (
-            "Sorry, something went wrong with your command: Server number is 
missing.\n");
-          printf (
-            "Example: truth add server#0 question \"question\" \"answer\"\n");
-          free (buffer);
-          buffer = (char *) NULL;
-          keyboard_task = NULL;
-          start_read_keyboard ();
-          return;
-        }
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "At %s:%d server is %s\n", __FILE__, __LINE__,
-                    token);
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "At %s:%d server number is %u\n", __FILE__, __LINE__,
-                    server_num);
-        token = strtok (NULL, " ");
-        if (! token)
-        {
-          printf (
-            "Sorry, something went wrong with your command: Method is 
missing.\n");
-          free (buffer);
-          buffer = (char *) NULL;
-          keyboard_task = NULL;
-          start_read_keyboard ();
-          return;
-        }
-        tus->method = GNUNET_malloc (strlen (token) + 1);
-        GNUNET_strlcpy (tus->method,
-                        token,
-                        strlen (token) + 1);
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "At %s:%d method is %s\n", __FILE__, __LINE__,
-                    tus->method);
-        bool method_supported = false;
-        size_t index;
-        json_t *method;
-        json_t *methods = json_object_get (servers[server_num].backend_methods,
-                                           "methods");
-        json_array_foreach (methods, index, method)
-        {
-          if (json_object_get (method, tus->method))
-          {
-            method_supported = true;
-            break;
-          }
-        }
-        if (method_supported)
-        {
-          if (0 == strcmp ("question", tus->method))
-          {
-            token = strtok (NULL, "\"");
-            if (! token)
-            {
-              printf (
-                "Sorry, something went wrong with your command: Question is 
missing.\n");
-              printf (
-                "Example: truth add server#0 question \"question\" 
\"answer\"\n");
-              free (buffer);
-              buffer = (char *) NULL;
-              keyboard_task = NULL;
-              start_read_keyboard ();
-              return;
-            }
-            tus->secret_question = GNUNET_malloc (strlen (token) + 1);
-            GNUNET_strlcpy (tus->secret_question,
-                            token,
-                            strlen (token) + 1);
-            GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                        "At %s:%d question is %s\n", __FILE__, __LINE__,
-                        tus->secret_question);
-
-            token = strtok (NULL, "\"");
-            token = strtok (NULL, "\"");
-            if (! token)
-            {
-              printf (
-                "Sorry, something went wrong with your command: Answer is 
missing.\n");
-              printf (
-                "Example: truth add server#0 question \"question\" 
\"answer\"\n");
-              free (buffer);
-              buffer = (char *) NULL;
-              keyboard_task = NULL;
-              start_read_keyboard ();
-              return;
-            }
-            tus->secret_answer = GNUNET_malloc (strlen (token) + 1);
-            GNUNET_strlcpy (tus->secret_answer,
-                            token,
-                            strlen (token) + 1);
-            GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                        "At %s:%d answer is %s\n", __FILE__, __LINE__,
-                        tus->secret_answer);
-            tus->instructions = tus->secret_question;
-            tus->mime_type = "text/plain";
-            tus->truth_data = tus->secret_answer;
-            tus->truth_data_size = strlen (tus->secret_answer);
-          }
-          else if (0 == strcmp ("sms", tus->method))
-          {
-            token = strtok (NULL, " ");
-            tus->phone = GNUNET_malloc (strlen (token) + 1);
-            GNUNET_strlcpy (tus->phone,
-                            token,
-                            strlen (token) + 1);
-            tus->instructions = "SMS was sent to you. Please type in the 
Code.";
-            tus->mime_type = "text/plain";
-            tus->truth_data = tus->phone;
-            tus->truth_data_size = strlen (tus->phone);
-          }
-          else
-          {
-            printf ("Sorry, server#%u does not support '%s'\n",
-                    server_num,
-                    tus->method);
-            free (buffer);
-            buffer = (char *) NULL;
-            keyboard_task = NULL;
-            start_read_keyboard ();
-            return;
-          }
-
-          json_error_t error;
-          if (NULL == (tus->id_data = json_load_file (import_id,
-                                                      JSON_DECODE_ANY,
-                                                      &error)))
-          {
-            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                        "Failed to parse `%s': %s at %d:%d (%d)\n",
-                        import_id,
-                        error.text,
-                        error.line,
-                        error.column,
-                        error.position);
-            free (buffer);
-            buffer = (char *) NULL;
-            GNUNET_SCHEDULER_shutdown ();
-            return;
-          }
-          tus->index = tu_states_length;
-
-          // memorize tu_states of policies before appending tu_state
-          bool tu_mem[pc_states_length][tu_states_length];
-          if (pc_states_length > 0)
-          {
-            for (unsigned int i = 0; i < pc_states_length; i++)
-            {
-              for (unsigned int j = 0; j < tu_states_length; j++)
-              {
-                bool match = false;
-                for (unsigned int k = 0; k < pc_states[i].tu_states_len; k++)
-                {
-                  if (pc_states[i].tu_states[k]->index == j)
-                  {
-                    match = true;
-                    break;
-                  }
-                }
-                tu_mem[i][j] = match;
-              }
-            }
-          }
-          tus->tuo = ANASTASIS_truth_upload (ctx,
-                                             servers[server_num].user_id,
-                                             servers[server_num].backend_url,
-                                             tus->method,
-                                             tus->instructions,
-                                             tus->mime_type,
-                                             servers[server_num].backend_salt,
-                                             tus->truth_data,
-                                             tus->truth_data_size,
-                                             &truth_payment_cb,
-                                             tus->tpc_cls,
-                                             &truth_upload_cb,
-                                             tus);
-          GNUNET_array_append (tu_states,
-                               tu_states_length,
-                               *tus);
-          // fix policies after appending tu_state
-          if (pc_states_length > 0)
-          {
-            for (unsigned int i = 0; i < pc_states_length; i++)
-            {
-              unsigned int k = 0;
-              for (unsigned int j = 0; j < tu_states_length - 1; j++)
-              {
-                if (tu_mem[i][j] == true)
-                {
-                  pc_states[i].tu_states[k] = &tu_states[j];
-                  k++;
-                }
-              }
-              pc_states[i].tu_states_len = k;
-            }
-          }
-          if (NULL == tus->tuo)
-          {
-            GNUNET_break (0);
-            free (buffer);
-            buffer = (char *) NULL;
-            return;
-          }
-          printf ("Truth #%u added for server #%u\n",
-                  tus->index,
-                  server_num);
-          free (buffer);
-          buffer = (char *) NULL;
-          return;
-        }
-        else
-          printf ("Sorry, server#%u does not support '%s'\n",
-                  server_num,
-                  tus->method);
-      }
-      else
-      {
-        printf (
-          "Sorry, something went wrong with your command: Server is not 
correct.\n");
-        printf (
-          "Example: truth add server#0 question \"question\" \"answer\"\n");
-        free (buffer);
-        buffer = (char *) NULL;
-        keyboard_task = NULL;
-        start_read_keyboard ();
-        return;
-      }
-    }
-    else
-      printf ("Please add a server before!\n");
-
-    free (buffer);
-    buffer = (char *) NULL;
-    keyboard_task = NULL;
-    start_read_keyboard ();
-    return;
-  }
-  if (0 == strncmp ("truth --secrets",
-                    buffer,
-                    strlen ("truth --secrets")))
-  {
-    if (NULL != tu_states)
-    {
-      for (unsigned int i = 0; i < tu_states_length; i++)
-      {
-        if ((NULL != tu_states[i].method) &&
-            (0 == strcmp ("SMS", tu_states[i].method)))
-          printf ("truth#%u: %s %s\n",
-                  i,
-                  tu_states[i].method,
-                  tu_states[i].phone);
-        if ((NULL != tu_states[i].method) &&
-            (0 == strcmp ("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");
-
-    free (buffer);
-    buffer = (char *) NULL;
-    start_read_keyboard ();
-    return;
-  }
-
-  if ((0 == strncmp ("policy",
-                     buffer,
-                     strlen ("policy")))
-      && (characters == strlen ("policy")))
-  {
-    if (NULL != pc_states)
-    {
-      for (unsigned int i = 0; i < pc_states_length; i++)
-      {
-        if (NULL != pc_states[i].tu_states)
-        {
-          printf ("Policy#%u: ", i);
-          for (unsigned int j = 0; j < pc_states[i].tu_states_len; j++)
-            printf ("truth#%u ", pc_states[i].tu_states[j]->index);
-          printf ("\n");
-        }
-        else
-          printf ("Policy#%u: no truths added yet\n", i);
-      }
-    }
-    else
-      printf ("Please add a policy before!\n");
-    free (buffer);
-    buffer = (char *) NULL;
-    start_read_keyboard ();
-    return;
-  }
-  if (0 == strncmp ("policy add",
-                    buffer,
-                    strlen ("policy add")))
-  {
-    if (characters == strlen ("policy add"))
-    {
-      printf ("Wrong argument: No truth given!\n");
-      printf (
-        "Example: policy add truth#0 truth#2\n");
-      free (buffer);
-      buffer = (char *) NULL;
-      start_read_keyboard ();
-      return;
-    }
-    struct PolicyCreateState *pcs = GNUNET_new (struct PolicyCreateState);
-    pcs->tu_states_len = 0;
-    char *token_start = &buffer[strlen ("policy add ")];
-    char *token = strtok (token_start, " ");
-    while (token != NULL)
-    {
-      if (0 != strncmp ("truth#",
-                        token,
-                        strlen ("truth#")))
-      {
-        printf ("Wrong argument: %s!\n", token);
-        free (buffer);
-        buffer = (char *) NULL;
-        start_read_keyboard ();
-        return;
-      }
-      unsigned int tus_index = (int) token[strlen ("truth#")] - 48;
-      if (tus_index < tu_states_length)
-      {
-        GNUNET_array_append (pcs->tu_states,
-                             pcs->tu_states_len,
-                             &tu_states[tus_index]);
-        token = strtok (NULL, " ");
-      }
-      else
-      {
-        printf ("Wrong argument: truth#%i not existing!\n", tus_index);
-        free (buffer);
-        buffer = (char *) NULL;
-        start_read_keyboard ();
-        return;
-      }
-    }
-
-    GNUNET_array_append (pc_states,
-                         pc_states_length,
-                         *pcs);
-    printf ("Policy #%u defined\n",
-            (pc_states_length > 0) ? pc_states_length - 1 : 0);
-    free (buffer);
-    buffer = (char *) NULL;
-    start_read_keyboard ();
-    return;
-  }
-
-  if (0 == strncmp ("publish",
-                    buffer,
-                    strlen ("publish")))
-  {
-    if (NULL != pc_states)
-    {
-      struct SecretShareState *sss = GNUNET_new (struct SecretShareState);
-      const struct ANASTASIS_Policy *policies[pc_states_length];
-
-      for (unsigned int i = 0; i < pc_states_length; i++)
-      {
-        const struct ANASTASIS_Truth *truths[pc_states[i].tu_states_len];
-
-        for (unsigned int j = 0; j < pc_states[i].tu_states_len; j++)
-        {
-          GNUNET_assert (NULL != pc_states[i].tu_states[j]->truth);
-          truths[j] = pc_states[i].tu_states[j]->truth;
-        }
-
-        pc_states[i].policy = ANASTASIS_policy_create (truths,
-                                                       pc_states[i].
-                                                       tu_states_len);
-        policies[i] = pc_states[i].policy;
-      }
-
-      json_error_t error;
-      if (NULL == (sss->id_data = json_load_file (import_id,
-                                                  JSON_DECODE_ANY,
-                                                  &error)))
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    "Failed to parse `%s': %s at %d:%d (%d)\n",
-                    import_id,
-                    error.text,
-                    error.line,
-                    error.column,
-                    error.position);
-        free (buffer);
-        buffer = (char *) NULL;
-        GNUNET_SCHEDULER_shutdown ();
-        return;
-      }
-      if (characters > strlen ("publish"))
-      {
-        char *token_start = &buffer[strlen ("publish ")];
-        char *token = strtok (token_start, "\"");
-        sss->core_secret = GNUNET_malloc (strlen (token) + 1);
-        sss->core_secret_size = strlen (token) + 1;
-        GNUNET_strlcpy ((char *) sss->core_secret,
-                        token,
-                        sss->core_secret_size);
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "At %s:%d core secret is %s\n", __FILE__, __LINE__,
-                    (char *) sss->core_secret);
-        sss->http_status = MHD_HTTP_NO_CONTENT;
-      }
-      // core secret here is just for testing, if payment is needed
-      // FIXME: avoid uploading recovery document like this
-      if (characters == strlen ("publish"))
-      {
-        sss->core_secret = "test_payment";
-        sss->core_secret_size = strlen ("test_payment");
-        sss->http_status = MHD_HTTP_PAYMENT_REQUIRED;
-      }
-
-      for (unsigned int i = 0; i < servers_length; i++)
-      {
-        printf ("To skip following press enter\n");
-        printf ("Please type in PaymentSecret for Server#%u: ", i);
-        free (buffer);
-        buffer = readline ((char *) NULL);
-        characters = strlen (buffer);
-        if (characters > 1)
-        {
-          add_history (buffer);
-
-          if (GNUNET_OK !=
-              GNUNET_STRINGS_string_to_data (buffer,
-                                             strlen (buffer),
-                                             &pds[i].payment_secret,
-                                             sizeof (struct
-                                                     
ANASTASIS_PaymentSecretP)))
-          {
-            fprintf (stderr,
-                     "Invalid payment secret entered, please try again\n");
-            i--;
-            continue;
-          }
-          free (buffer);
-          buffer = (char *) NULL;
-        }
-        /** FIXME: Shall we delete order_id/payment secret if not given during 
second 'publish' command?
-         * Shall we even ask for payment secret, if given before? Or shall the 
user have the option
-         * to use a different payment secret for second/further 'publish' 
command/s?
-        */
-        printf ("\n");
-        GNUNET_free (pds[i].provider_url); // FIXME: better: shrink array!
-      }
-      // FIXME: pds not as global, setup ONLY here
-      sss->sso = ANASTASIS_secret_share (ctx,
-                                         sss->id_data,
-                                         NULL,
-                                         policies,
-                                         pc_states_length,
-                                         pds,
-                                         pds_length,
-                                         &secret_share_payment_cb,
-                                         sss,
-                                         &secret_share_result_cb,
-                                         sss,
-                                         sss->core_secret,
-                                         sss->core_secret_size);
-      if (NULL == sss->sso)
-      {
-        GNUNET_break (0);
-        free (buffer);
-        buffer = (char *) NULL;
-        return;
-      }
-      free (buffer);
-      buffer = (char *) NULL;
-      return;
-    }
-    free (buffer);
-    buffer = (char *) NULL;
-    return;
-  }
-
-  fprintf (stderr,
-           "Unknown command '%s'\n",
-           (char *) buffer);
-  free (buffer);
-  buffer = (char *) NULL;
-  keyboard_task = NULL;
-  start_read_keyboard ();
-}
-
-
-/**
- * @brief Wait for a keyboard input
- */
-static void
-start_read_keyboard ()
-{
-  static struct GNUNET_DISK_FileHandle fh = { STDIN_FILENO };
-
-  GNUNET_assert (NULL == keyboard_task);
-
-  if (! import_id)
-  {
-    printf ("Please provide user details with option '--me file.json'!\n");
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-
-  printf ("'x' to quit\n");
-  printf ("'o' to show options\n");
-  printf ("Waiting for keyboard input\n");
-  keyboard_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                  &fh,
-                                                  &read_keyboard_command,
-                                                  NULL);
-}
-
-
-/**
- * @brief Shutdown the application.
- *
- * @param cls closure
- */
-static void
-shutdown_task (void *cls)
-{
-  (void) cls;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Shutdown initiated\n");
-
-  // FIXME shutdown routine here
-  if (NULL != keyboard_task)
-  {
-    GNUNET_SCHEDULER_cancel (keyboard_task);
-    keyboard_task = NULL;
-  }
-  if (NULL != ctx)
-  {
-    GNUNET_CURL_fini (ctx);
-    ctx = NULL;
-  }
-  if (NULL != rc)
-  {
-    GNUNET_CURL_gnunet_rc_destroy (rc);
-    rc = NULL;
-  }
-
-  if (NULL != tu_states)
-  {
-    for (unsigned int i = 0; i < tu_states_length; i++)
-    {
-      GNUNET_free (tu_states[i].truth);
-      GNUNET_free (tu_states[i].method);
-      GNUNET_free (tu_states[i].secret_answer);
-    }
-  }
-
-  if (NULL != servers)
-  {
-    for (unsigned int i = 0; i < servers_length; i++)
-    {
-      GNUNET_free (servers[i].backend_url);
-      GNUNET_free (servers[i].backend_methods);
-    }
-  }
-  GNUNET_free (servers);
-
-  GNUNET_free (pds);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Shutdown complete\n");
-}
-
-
-/**
- * @brief Start the application
- *
- * @param cls closure
- * @param args arguments left
- * @param cfgfile config file name
- * @param cfg handle for the configuration file
- */
-static void
-run (void *cls,
-     char *const *args,
-     const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-  (void) cls;
-  (void) args;
-  (void) cfgfile;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Starting anastasis-splitter\n");
-
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                 NULL);
-
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_log_setup ("anastasis-splitter",
-                                   "WARNING",
-                                   NULL));
-
-  /* initialize HTTP client */
-  ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
-                          &rc);
-  rc = GNUNET_CURL_gnunet_rc_create (ctx);
-
-  start_read_keyboard ();
-}
-
-
-int
-main (int argc,
-      char *const *argv)
-{
-  int ret;
-
-  /* the available command line options */
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    // FIXME json is not an int...
-    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),
-    // FIXME recovery document also is not a int...
-    GNUNET_GETOPT_option_flag ('i',
-                               "import",
-                               "import json file containing a recovery 
document",
-                               &import_recovery_document),
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  ret = GNUNET_PROGRAM_run (argc,
-                            argv,
-                            "anastasis-splitter",
-                            "This is an application for using Anastasis to 
split and share a secret.\n",
-                            options,
-                            &run,
-                            NULL);
-
-  return (GNUNET_OK == ret) ? 0 : 1;
-}
-
-
-/* end of anastasis-cli-spliter.c */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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