gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (75e2deb -> 2a0f180)


From: gnunet
Subject: [taler-anastasis] branch master updated (75e2deb -> 2a0f180)
Date: Thu, 07 May 2020 03:26: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 75e2deb  testing anastasis recovery
     new dfd6e2a  worked on anastasis.c secret share
     new 0138994  playing with pointers...
     new 9057dde  worked on secret share
     new 2a0f180  Merge branch 'master' of ssh://git.taler.net/anastasis

The 4 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/include/anastasis.h             |   4 +-
 src/include/anastasis_testing_lib.h |   8 +-
 src/lib/anastasis.c                 | 333 +++++++++++++++++++++++++-----------
 src/lib/test_anastasis.c            |   9 +-
 src/lib/testing_cmd_policy_create.c |  69 +-------
 src/lib/testing_cmd_secret_share.c  | 139 +++++++++------
 6 files changed, 348 insertions(+), 214 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index e92c4d9..29e4da6 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -380,10 +380,8 @@ struct ANASTASIS_SecretShare;
 struct ANASTASIS_SecretShare *
 ANASTASIS_secret_share (const json_t *id_data,
                         const struct GNUNET_HashCode *last_etag,
-                        struct ANASTASIS_Policy *policies[],
+                        const struct ANASTASIS_Policy *policies[],
                         unsigned int policies_len,
-                        struct ANASTASIS_Truth *truths[],
-                        unsigned int truths_len,
                         ANASTASIS_SharePaymentCallback spc,
                         void *spc_cls,
                         ANASTASIS_ShareResultCallback src,
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 1dc46f7..d91e662 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -475,7 +475,7 @@ ANASTASIS_TESTING_get_trait_truth (const struct 
TALER_TESTING_Command *cmd,
 
 
 /**
- * Offer an truth.
+ * Offer a truth.
  *
  * @param index the truth's index number.
  * @param t the truth to offer.
@@ -595,6 +595,8 @@ enum ANASTASIS_TESTING_SecretShareOption
  * @param label command label
  * @param anastasis_url base URL of the anastasis serving our requests.
  * @param id_data ID data to generate user identifier
+ * @param core_secret core secret to backup/recover
+ * @param core_secret_size size of core_secret
  * @param http_status expected HTTP status.
  * @param sso secret share options
  * @param ... NULL-terminated list of policy create commands
@@ -603,7 +605,9 @@ enum ANASTASIS_TESTING_SecretShareOption
 struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_secret_share (const char *label,
                                     const char *anastasis_url,
-                                    json_t *id_data,
+                                    const json_t *id_data,
+                                    const void *core_secret,
+                                    size_t core_secret_size,
                                     unsigned int http_status,
                                     enum
                                     ANASTASIS_TESTING_SecretShareOption sso,
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 6460e9b..eb08c45 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -24,6 +24,7 @@
 #include <taler/taler_json_lib.h>
 #include <gnunet/gnunet_util_lib.h>
 
+#define SIZE_URL 50
 
 /**
  * FIXME: Needed? -> maybe needed in ANASTASIS_secret_share()
@@ -660,34 +661,41 @@ struct ANASTASIS_Truth
    * url to the server
    */
   const char *url;
+
   /**
    * identification of the truth
    */
   uuid_t uuid;
+
   /**
    * method used for this truth
    */
   const char *method;
+
   /**
    * method used for this truth
    */
   const char *instructions;
+
   /**
    * mime type of the truth
    */
   const char *mime_type;
+
   /**
    * keyshare of this truth, used to generate policy keys
    */
   struct ANASTASIS_CRYPTO_KeyShareP key_share;
+
   /**
    * key used to encrypt this truth
    */
   struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
+
   /**
-   * salt used to encrypt the truth
+   * server salt used to derive user identifier
    */
-  struct ANASTASIS_CRYPTO_SaltP *salt;
+  const struct ANASTASIS_CRYPTO_SaltP *salt;
 };
 
 /**
@@ -868,6 +876,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
   t->method = method;
   t->instructions = instructions;
   t->mime_type = mime_type;
+  t->salt = salt;
 
   uuid_generate (t->uuid);
   GNUNET_assert (NULL != &t->uuid);
@@ -986,18 +995,26 @@ struct ANASTASIS_Policy
   * Encrypted policy master key
   */
   struct ANASTASIS_CRYPTO_PolicyKeyP policy_key;
+
   /**
    * salt used to encrypt the master key
    */
   struct ANASTASIS_CRYPTO_SaltP salt;
+
   /**
    * set of truths inside this policy
    */
   uuid_t *uuids;
+
   /**
    * length of methods used
    */
   unsigned int uuid_length;
+
+  /**
+   * array of truths
+   */
+  struct ANASTASIS_Truth **truths;
 };
 
 /**
@@ -1016,24 +1033,17 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth 
*truths[],
   uuid_t uuids[truths_len];
 
   p = GNUNET_new (struct ANASTASIS_Policy);
-  truth = truths;
 
   GNUNET_assert (NULL != *truths);
   GNUNET_assert (truths_len > 0);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d truth array is %s\n", __FILE__, __LINE__,
-              TALER_b2s (truths,
-                         truths_len
-                         * sizeof (struct ANASTASIS_Truth)));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d truth array length is %i\n", __FILE__, __LINE__,
               truths_len);
 
   for (unsigned int i = 0; i < truths_len; i++)
   {
-    if (i > 0)
-      truth = &truth[1];
+    truth = truths[i];
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (truth),
@@ -1067,6 +1077,7 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
               (unsigned long long) sizeof (p->policy_key));
   p->uuids = uuids;
   p->uuid_length = truths_len;
+  p->truths = truths;
 
   GNUNET_assert (NULL != p->uuids);
   GNUNET_assert (p->uuid_length == truths_len);
@@ -1088,41 +1099,6 @@ ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p)
 }
 
 
-/**
-* Defines a recovery document upload process (recovery document consists of 
multiple policies)
-*/
-struct ANASTASIS_SecretShare
-{
-  /**
-   * Callback which gives back the payment details
-   */
-  ANASTASIS_SharePaymentCallback spc;
-  /**
-   * Closure for the payment callback
-   */
-  void *spc_cls;
-  /**
-   * Callback which gives back the result of the POST Request
-   */
-  ANASTASIS_ShareResultCallback src;
-  /**
-   * Closure for the Result Callback
-   */
-  void *src_cls;
-  /**
-   * Closure for the Result Callback
-   */
-  struct GNUNET_CURL_Context *ctx;
-  /**
-   * References for the upload states and operations (size of truths passed)
-   */
-  struct PolicyStoreState **pss;
-  /**
-   * Closure for the Result Callback
-   */
-  unsigned int pss_length;
-};
-
 /**
  * State for a "policy store" CMD.
  */
@@ -1132,60 +1108,79 @@ struct PolicyStoreState
    * User identifier used as entropy source for the account public key
    */
   struct ANASTASIS_CRYPTO_UserIdentifierP id;
+
   /**
    * Struct to obtain the salt from the server
    */
   struct SaltState *st;
+
   /**
    * The policy data.
    */
   void *recovery_data;
+
   /**
    * Number of bytes in @e recovery_data
    */
   size_t recovery_data_size;
+
   /**
    * Expected status code.
    */
   unsigned int http_status;
+
+  /**
+   * Server salt
+   */
+  const struct ANASTASIS_CRYPTO_SaltP *server_salt;
+
   /**
    * Status of the transaction
    */
   enum ANASTASIS_ErrorCode ec;
+
   /**
    * Eddsa Publickey.
    */
   struct ANASTASIS_CRYPTO_AccountPublicKeyP anastasis_pub;
+
   /**
    * Eddsa Privatekey.
    */
   struct GNUNET_CRYPTO_EddsaPrivateKey anastasis_priv;
+
   /**
    * Hash of the previous upload (maybe bogus if
    * #ANASTASIS_TESTING_UO_PREV_HASH_WRONG is set in @e uo).
    * Maybe all zeros if there was no previous upload.
    */
   struct GNUNET_HashCode prev_hash;
+
   /**
    * Hash of the current upload.
    */
   struct GNUNET_HashCode curr_hash;
+
   /**
    * The /policy POST operation handle.
    */
   struct ANASTASIS_PolicyStoreOperation *pso;
+
   /**
    * URL of the anastasis backend.
    */
   const char *anastasis_url;
+
   /**
    * Payment identifier.
    */
   struct ANASTASIS_PaymentSecretP payment_id;
+
   /**
    * Payment order ID we got back, if any. Otherwise NULL.
    */
   char *payment_order_id;
+
   /**
    * Payment order ID we are to provide in the request, may be NULL.
    */
@@ -1194,6 +1189,41 @@ struct PolicyStoreState
   int payment_requested;
 };
 
+/**
+* Defines a recovery document upload process (recovery document consists of 
multiple policies)
+*/
+struct ANASTASIS_SecretShare
+{
+  /**
+   * Callback which gives back the payment details
+   */
+  ANASTASIS_SharePaymentCallback spc;
+  /**
+   * Closure for the payment callback
+   */
+  void *spc_cls;
+  /**
+   * Callback which gives back the result of the POST Request
+   */
+  ANASTASIS_ShareResultCallback src;
+  /**
+   * Closure for the Result Callback
+   */
+  void *src_cls;
+  /**
+   * Closure for the Result Callback
+   */
+  struct GNUNET_CURL_Context *ctx;
+  /**
+   * References for the upload states and operations (size of truths passed)
+   */
+  struct PolicyStoreState **pss;
+  /**
+   * Closure for the Result Callback
+   */
+  unsigned int pss_length;
+};
+
 static void
 policy_store_cb (void *cls,
                  enum ANASTASIS_ErrorCode ec,
@@ -1284,6 +1314,91 @@ policy_store_cb (void *cls,
 }
 
 
+/**
+ * Counts the number of different providers
+ *
+ * @param policies Array of policies
+ * @param policies_len Length of array
+ * @return number of different providers
+ */
+static unsigned int
+ANASTASIS_get_num_urls (const struct ANASTASIS_Policy *policies[],
+                        unsigned int policies_len)
+{
+  struct ANASTASIS_Policy *policy;
+  unsigned int len = 0;
+  unsigned int unique_urls_len = 0;
+
+  for (unsigned int i = 0; i < policies_len; i++)
+  {
+    policy = policies[i];
+
+    len += policy->uuid_length;
+  }
+
+  {
+    char *provider[len];
+    for (unsigned int i = 0; i < len; i++)
+    {
+      // allocate space for each url
+      provider[i] = GNUNET_malloc (SIZE_URL * sizeof (char));
+    }
+
+    for (unsigned int l = 0; l < policies_len; l++)
+    {
+      policy = policies[l];
+      struct ANASTASIS_Truth *truth;
+
+      for (unsigned int j = 0; j < policy->uuid_length; j++)
+      {
+        truth = policy->truths[0];
+
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
+                    TALER_B2S (truth),
+                    (unsigned long long) sizeof (struct ANASTASIS_Truth));
+
+        int contains_url = 0;
+        for (unsigned int k = 0; k < len; k++)
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "At %s:%d provider url from truth is %s\n", __FILE__,
+                      __LINE__,
+                      truth->url);
+          if (NULL != provider[k])
+          {
+            if (0 ==
+                strcmp (truth->url, provider[k]))
+            {
+              contains_url = 1;
+              break;
+            }
+          }
+        }
+
+        if (0 == contains_url)
+        {
+          provider[unique_urls_len] = truth->url;
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "At %s:%d provider url is %s\n", __FILE__, __LINE__,
+                      provider[unique_urls_len]);
+          unique_urls_len++;
+        }
+      }
+    }
+    for (unsigned int i = 0; i < len; i++)
+    {
+      // free space for each url
+      GNUNET_free (provider[i]);
+    }
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d unique_urls_len is %d\n", __FILE__, __LINE__,
+              unique_urls_len);
+  return unique_urls_len;
+}
+
+
 /**
 * Creates a recovery document with the created policies.
 *
@@ -1301,10 +1416,8 @@ policy_store_cb (void *cls,
 struct ANASTASIS_SecretShare *
 ANASTASIS_secret_share (const json_t *id_data,
                         const struct GNUNET_HashCode *last_etag,
-                        struct ANASTASIS_Policy *policies[],
+                        const struct ANASTASIS_Policy *policies[],
                         unsigned int policies_len,
-                        struct ANASTASIS_Truth *truths[],
-                        unsigned int truths_len,
                         ANASTASIS_SharePaymentCallback spc,
                         void *spc_cls,
                         ANASTASIS_ShareResultCallback src,
@@ -1314,12 +1427,17 @@ ANASTASIS_secret_share (const json_t *id_data,
 {
 
   struct ANASTASIS_SecretShare *ss;
+  struct ANASTASIS_Policy *policy;
+
+  unsigned int pss_length = ANASTASIS_get_num_urls (policies,
+                                                    policies_len);
+  struct PolicyStoreState pss[pss_length];
+  struct GNUNET_HashCode current_etags[pss_length];
+  enum TALER_ErrorCode ecs[pss_length];
+
   ss = GNUNET_new (struct ANASTASIS_SecretShare);
-  struct PolicyStoreState pss[truths_len];
-  struct GNUNET_HashCode current_etags[truths_len];
-  enum TALER_ErrorCode ecs[truths_len];
   ss->pss = &pss;
-  ss->pss_length = truths_len;
+  ss->pss_length = pss_length;
   ss->spc = spc;
   ss->spc_cls = spc_cls;
   ss->src = src;
@@ -1340,7 +1458,12 @@ ANASTASIS_secret_share (const json_t *id_data,
 
   for (unsigned int i = 0; i < policies_len; i++)
   {
-    policy_keys[i] = policies[i]->policy_key;
+    policy = policies[i];
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (policy),
+                (unsigned long long) sizeof (struct ANASTASIS_Policy));
+    policy_keys[i] = policy->policy_key;
   }
 
   ANASTASIS_CRYPTO_core_secret_encrypt (policy_keys,
@@ -1351,8 +1474,13 @@ ANASTASIS_secret_share (const json_t *id_data,
                                         encrypted_master_keys);
 
   dec_policies = json_array ();
+  esc_methods = json_array ();
+  unsigned int all_uuids_length = 0;
+  int index_pss = 0;
   for (unsigned int k = 0; k < policies_len; k++ )
   {
+    policy = policies[k];
+    all_uuids_length += policy->uuid_length;
     json_t *dec_policy = json_pack ("{s:o," /* encrypted master key */
                                     " s:o," /* policy uuids  */
                                     " s:i}",/* policy uuids length */
@@ -1360,11 +1488,11 @@ ANASTASIS_secret_share (const json_t *id_data,
                                     GNUNET_JSON_from_data_auto (
                                       &encrypted_master_keys[k]),
                                     "uuids",
-                                    GNUNET_JSON_from_data (policies[k]->uuids,
-                                                           policies[k]->
+                                    GNUNET_JSON_from_data (policy->uuids,
+                                                           policy->
                                                            uuid_length
                                                            * sizeof(uuid_t)),
-                                    "uuid_length", &policies[k]->uuid_length);
+                                    "uuid_length", &policy->uuid_length);
     GNUNET_assert (NULL != dec_policy);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "dec policy json before upload 0: %s\n",
@@ -1375,39 +1503,57 @@ ANASTASIS_secret_share (const json_t *id_data,
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Dec policies json append before upload 0: %s\n",
                 json_dumps (dec_policies, JSON_COMPACT));
-  }
-  // FIXME CHALLENGE
-  esc_methods = json_array ();
-  for (unsigned int l = 0; l < truths_len; l++)
-  {
-    // creates a json array for saving
-    json_t *esc_method = json_pack ("{s:o," /* truth uuid */
-                                    " s:s," /* provider url */
-                                    " s:o," /* truth key */
-                                    " s:o," /* truth salt */
-                                    " s:s}", /* escrow method */
-                                    "uuid",
-                                    GNUNET_JSON_from_data (truths[l]->uuid,
-                                                           sizeof(uuid_t)),
-                                    "url", truths[l]->url,
-                                    "truth_key", GNUNET_JSON_from_data_auto (
-                                      &truths[l]->truth_key),
-                                    "salt", GNUNET_JSON_from_data_auto (
-                                      truths[l]->salt),
-                                    "escrow_method", truths[l]->method);
-
-    GNUNET_assert (NULL != esc_method);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "esc method json before upload 0: %s\n",
-                json_dumps (esc_method, JSON_COMPACT));
-    GNUNET_assert (0 ==
-                   json_array_append_new (esc_methods, esc_method));
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Esc methods json append before upload 0: %s\n",
-                json_dumps (esc_methods, JSON_COMPACT));
-    // prepares policy store operation
-    ss->pss[l]->anastasis_url = truths[l]->url;
-    ss->pss[l]->prev_hash = *last_etag;
+
+    // FIXME CHALLENGE
+    for (unsigned int l = 0; l < policy->uuid_length; l++)
+    {
+      // creates a json array for saving
+      json_t *esc_method = json_pack ("{s:o," /* truth uuid */
+                                      " s:s," /* provider url */
+                                      " s:o," /* truth key */
+                                      " s:o," /* truth salt */
+                                      " s:s}", /* escrow method */
+                                      "uuid",
+                                      GNUNET_JSON_from_data (
+                                        policy->truths[l]->uuid,
+                                        sizeof(uuid_t)),
+                                      "url", policy->truths[l]->url,
+                                      "truth_key", GNUNET_JSON_from_data_auto (
+                                        &policy->truths[l]->truth_key),
+                                      "salt", GNUNET_JSON_from_data_auto (
+                                        policy->truths[l]->salt),
+                                      "escrow_method",
+                                      policy->truths[l]->method);
+
+      GNUNET_assert (NULL != esc_method);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "esc method json before upload 0: %s\n",
+                  json_dumps (esc_method, JSON_COMPACT));
+      GNUNET_assert (0 ==
+                     json_array_append_new (esc_methods, esc_method));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Esc methods json append before upload 0: %s\n",
+                  json_dumps (esc_methods, JSON_COMPACT));
+
+      // prepares policy store operation
+      int contains_url = 0;
+      for (unsigned int j = 0; j < ss->pss_length; j++)
+      {
+        if (0 == strcmp (ss->pss[j]->anastasis_url,
+                         policy->truths[l]->url))
+        {
+          contains_url = 1;
+          break;
+        }
+      }
+      if (0 == contains_url)
+      {
+        ss->pss[index_pss]->anastasis_url = policy->truths[l]->url;
+        ss->pss[index_pss]->prev_hash = *last_etag;
+        ss->pss[index_pss]->server_salt = policy->truths[l]->salt;
+        index_pss++;
+      }
+    }
   }
 
   recovery_document = json_pack (
@@ -1426,19 +1572,14 @@ ANASTASIS_secret_share (const json_t *id_data,
   // FIXME COMPRESSION
   recovery_document_str = json_dumps (recovery_document, JSON_COMPACT);
   recovery_document_size = strlen (recovery_document_str);
-  for (unsigned int l = 0; l < truths_len; l++)
+  for (unsigned int l = 0; l < ss->pss_length; l++)
   {
     ss->pss[l]->http_status = MHD_HTTP_NO_CONTENT;
     ss->pss[l]->st->http_status = MHD_HTTP_OK;
-    ss->pss[l]->st->so = ANASTASIS_salt (ss->ctx,
-                                         ss->pss[l]->anastasis_url,
-                                         &salt_cb,
-                                         ss->pss[l]->st);
 
     ANASTASIS_CRYPTO_user_identifier_derive (id_data,
-                                             &ss->pss[l]->st->so->salt,
+                                             &ss->pss[l]->server_salt,
                                              &ss->pss[l]->id);
-    salt_cleanup (ss->pss[l]->st);
 
     ANASTASIS_CRYPTO_account_private_key_derive (&ss->pss[l]->id,
                                                  &ss->pss[l]->anastasis_priv);
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index e82c05f..7d1fd87 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -241,13 +241,18 @@ run (void *cls,
                                          "truth-create-2",
                                          "truth-create-3",
                                          NULL),
-    /*
+
     ANASTASIS_TESTING_cmd_secret_share ("secret-share-1",
                                         anastasis_url,
+                                        ANASTASIS_TESTING_make_id_data_example 
(
+                                          "MaxMuster123456789"),
+                                        "core secret",
+                                        strlen ("core secret"),
                                         MHD_HTTP_PAYMENT_REQUIRED,
                                         ANASTASIS_TESTING_SSO_NONE,
+                                        "policy-create-1",
                                         NULL),
-
+    /*
     ANASTASIS_TESTING_cmd_recover_secret ("recover-secret-1",
                                           anastasis_url,
                                           
ANASTASIS_TESTING_make_id_data_example (
diff --git a/src/lib/testing_cmd_policy_create.c 
b/src/lib/testing_cmd_policy_create.c
index cce0f25..dba47b4 100644
--- a/src/lib/testing_cmd_policy_create.c
+++ b/src/lib/testing_cmd_policy_create.c
@@ -58,48 +58,6 @@ struct PolicyCreateState
   const struct ANASTASIS_Policy *policy;
 };
 
-/**
- * Th Truth.
- * FIXME: Is there a more elegant way to fix "incomplete type" error?
- * see sizeof (*truth)
- */
-struct Truth
-{
-  /**
-   * url to the server
-   */
-  const char *url;
-  /**
-   * identification of the truth
-   */
-  uuid_t uuid;
-  /**
-   * method used for this truth
-   */
-  const char *method;
-  /**
-   * method used for this truth
-   */
-  const char *instructions;
-  /**
-   * mime type of the truth
-   */
-  const char *mime_type;
-  /**
-   * keyshare of this truth, used to generate policy keys
-   */
-  struct ANASTASIS_CRYPTO_KeyShareP key_share;
-  /**
-   * key used to encrypt this truth
-   */
-  struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
-  /**
-   * salt used to encrypt the truth
-   */
-  struct ANASTASIS_CRYPTO_SaltP *salt;
-};
-
-
 
 /**
  * Run a "policy create" CMD.
@@ -114,7 +72,7 @@ policy_create_run (void *cls,
                    struct TALER_TESTING_Interpreter *is)
 {
   struct PolicyCreateState *pcs = cls;
-  struct Truth truths[pcs->cmd_label_array_length];
+  struct Truth *truths[pcs->cmd_label_array_length];
 
   GNUNET_assert (pcs->cmd_label_array_length > 0);
   GNUNET_assert (NULL != pcs->cmd_label_array);
@@ -129,7 +87,7 @@ policy_create_run (void *cls,
     for (unsigned int i = 0; i < pcs->cmd_label_array_length; i++)
     {
       const struct TALER_TESTING_Command *ref;
-      struct Truth *truth;
+      const struct Truth *truth;
 
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "At %s:%d truth upload cmd is %s\n", __FILE__, __LINE__,
@@ -154,28 +112,13 @@ policy_create_run (void *cls,
         return;
       }
       GNUNET_assert (NULL != truth);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
-                  TALER_B2S (truth),
-                  (unsigned long long) sizeof (*truth));
-      truths[i] = *truth;
-      GNUNET_assert (0 ==
-                     GNUNET_memcmp (&truths[i],
-                                    truth));
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
-                  TALER_B2S (&truths[i]),
-                  (unsigned long long) sizeof (truths[i]));
+      truths[i] = truth;
     }
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d truth array is %s\n", __FILE__, __LINE__,
-              TALER_b2s (&truths,
-                         pcs->cmd_label_array_length
-                         * sizeof (struct Truth)));
-  pcs->policy = ANASTASIS_policy_create (&truths,
+
+  pcs->policy = ANASTASIS_policy_create (truths,
                                          pcs->cmd_label_array_length);
-  if (NULL == &pcs->policy)
+  if (NULL == pcs->policy)
   {
     GNUNET_break (0);
     TALER_TESTING_interpreter_fail (pcs->is);
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
index d2c0958..6a97520 100644
--- a/src/lib/testing_cmd_secret_share.c
+++ b/src/lib/testing_cmd_secret_share.c
@@ -27,30 +27,6 @@
 #include <taler/taler_testing_lib.h>
 
 
-/**
-* Policy object to upload
-*/
-struct Policy
-{
-  /**
-  * Encrypted policy master key
-  */
-  struct ANASTASIS_CRYPTO_PolicyKeyP policy_key;
-  /**
-   * salt used to encrypt the master key
-   */
-  struct ANASTASIS_CRYPTO_SaltP salt;
-  /**
-   * set of truths inside this policy
-   */
-  uuid_t *uuids;
-  /**
-   * length of methods used
-   */
-  unsigned int uuid_length;
-};
-
-
 /**
  * State for a "secret share" CMD.
  */
@@ -71,6 +47,21 @@ struct SecretShareState
    */
   const char **cmd_label_array;
 
+  /**
+   * Data to derive user identifier from.
+   */
+  const json_t *id_data;
+
+  /**
+   * The core secret to backup/recover.
+   */
+  const void *core_secret;
+
+  /**
+   * Size of core_secret.
+   */
+  size_t core_secret_size;
+
   /**
    * Length of array of command labels (cmd_label_array).
    */
@@ -100,9 +91,65 @@ struct SecretShareState
    * Options for how we are supposed to do the upload.
    */
   enum ANASTASIS_TESTING_SecretShareOption ssopt;
+
+  /**
+   * closure for the payment callback
+   */
+  void *spc_cls;
+
+  /**
+   * closure for the result callback
+   */
+  void *src_cls;
 };
 
 
+/**
+ * Function called for payment routine.
+ *
+ * @param cls closure
+ * @param ec ANASTASIS error code
+ * @param http_status HTTP status of the request
+ */
+static void
+secret_share_payment_cb (void *cls,
+                         enum ANASTASIS_ErrorCode ec,
+                         unsigned int http_status)
+{
+
+}
+
+
+/**
+ * Function called with the results of a #secret_share().
+ *
+ * @param cls closure
+ * @param ec ANASTASIS error code
+ * @param http_status HTTP status of the request
+ * @param ud details about the upload operation
+ */
+static void
+secret_share_result_cb (void *cls,
+                        enum ANASTASIS_ErrorCode ec,
+                        unsigned int http_status,
+                        const struct ANASTASIS_UploadDetails *ud)
+{
+  struct SecretShareState *sss = cls;
+  sss->sso = NULL;
+  if (http_status != sss->http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected response code %u/%d to command %s in %s:%u\n",
+                http_status,
+                (int) ec,
+                sss->is->commands[sss->is->ip].label,
+                __FILE__,
+                __LINE__);
+    TALER_TESTING_interpreter_fail (sss->is);
+    return;
+  }
+}
+
 /**
  * Run a "secret share" CMD.
  *
@@ -116,7 +163,7 @@ secret_share_run (void *cls,
                   struct TALER_TESTING_Interpreter *is)
 {
   struct SecretShareState *sss = cls;
-  struct Policy policies[sss->cmd_label_array_length];
+  struct Policy *policies[sss->cmd_label_array_length];
 
   GNUNET_assert (sss->cmd_label_array_length > 0);
   GNUNET_assert (NULL != sss->cmd_label_array);
@@ -156,31 +203,20 @@ secret_share_run (void *cls,
         return;
       }
       GNUNET_assert (NULL != policy);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
-                  TALER_B2S (policy),
-                  (unsigned long long) sizeof (*policy));
-      policies[i] = *policy;
-      GNUNET_assert (0 ==
-                     GNUNET_memcmp (&policies[i],
-                                    policy));
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
-                  TALER_B2S (&policies[i]),
-                  (unsigned long long) sizeof (policies[i]));
+      policies[i] = policy;
     }
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d policy array is %s\n", __FILE__, __LINE__,
-              TALER_b2s (&policies,
-                         sss->cmd_label_array_length
-                         * sizeof (struct Policy)));
 
-  // sss->sso = ANASTASIS_secret_share ();
-
-
-  sss->is = is;
-  // FIXME: Whole secret share procedure here
+  sss->sso = ANASTASIS_secret_share (sss->id_data,
+                                     NULL,
+                                     policies,
+                                     sss->cmd_label_array_length,
+                                     &secret_share_payment_cb,
+                                     sss->spc_cls,
+                                     &secret_share_result_cb,
+                                     sss->src_cls,
+                                     sss->core_secret,
+                                     sss->core_secret_size);
 
   if (NULL == sss->sso)
   {
@@ -243,6 +279,8 @@ secret_share_traits (void *cls,
  * @param label command label
  * @param anastasis_url base URL of the anastasis serving our requests.
  * @param id_data ID data to generate user identifier
+ * @param core_secret core secret to backup/recover
+ * @param core_secret_size size of core_secret
  * @param http_status expected HTTP status.
  * @param sso secret share options
  * @param ... NULL-terminated list of policy create commands
@@ -251,7 +289,9 @@ secret_share_traits (void *cls,
 struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_secret_share (const char *label,
                                     const char *anastasis_url,
-                                    json_t *id_data,
+                                    const json_t *id_data,
+                                    const void *core_secret,
+                                    size_t core_secret_size,
                                     unsigned int http_status,
                                     enum
                                     ANASTASIS_TESTING_SecretShareOption sso,
@@ -265,6 +305,9 @@ ANASTASIS_TESTING_cmd_secret_share (const char *label,
   sss->ssopt = sso;
   sss->anastasis_url = anastasis_url;
   sss->label = label;
+  sss->id_data = id_data;
+  sss->core_secret = core_secret;
+  sss->core_secret_size = core_secret_size;
 
   va_start (ap, sso);
   char *policy_create_cmd;

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



reply via email to

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