gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (162afbe -> 989ce2c)


From: gnunet
Subject: [taler-anastasis] branch master updated (162afbe -> 989ce2c)
Date: Mon, 11 May 2020 10:20:45 +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 162afbe  prepared recover test
     new bb727bf  fixed uuid issue
     new 989ce2c  merge

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


Summary of changes:
 src/backend/anastasis-httpd_policy_upload.c |   8 +
 src/include/anastasis.h                     |   4 +-
 src/lib/anastasis.c                         | 279 ++++++++++++++++++----------
 src/lib/anastasis_api_policy_store.c        |   7 +
 src/lib/test_anastasis.c                    |   4 +-
 src/lib/testing_cmd_secret_share.c          |  32 +---
 6 files changed, 206 insertions(+), 128 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index cb665e2..b6a0691 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -660,6 +660,9 @@ AH_handler_policy_post (struct MHD_Connection *connection,
     puc->hc.cc = &cleanup_ctx;
     puc->con = connection;
 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d handler is policy_post\n", __FILE__, __LINE__);
+
     /* extract publickey from url */
     GNUNET_assert (0 == strncmp (url,
                                  "/policy/",
@@ -680,6 +683,11 @@ AH_handler_policy_post (struct MHD_Connection *connection,
       }
     }
     puc->account = accountPubP;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d public key is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&puc->account),
+                (unsigned long long) sizeof (struct
+                                             
ANASTASIS_CRYPTO_AccountPublicKeyP));
     *con_cls = puc;
 
     /* now setup 'puc' */
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 29e4da6..7ebb98d 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -366,6 +366,7 @@ struct ANASTASIS_SecretShare;
 /**
 * Creates a recovery document with the created policies.
 *
+* @param ctx the CURL context used to connect to the backend
 * @param id_data used to create a account identifier on the escrow provider
 * @param last_etag NULL on 'first' use, otherwise 'current_etag' from previous 
ShareResultCallback
 * @param policies list of policies which are included in this recovery document
@@ -378,7 +379,8 @@ struct ANASTASIS_SecretShare;
 * @param core_secret_size size of the core secret
 */
 struct ANASTASIS_SecretShare *
-ANASTASIS_secret_share (const json_t *id_data,
+ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
+                        const json_t *id_data,
                         const struct GNUNET_HashCode *last_etag,
                         const struct ANASTASIS_Policy *policies[],
                         unsigned int policies_len,
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 6b67fdd..2a6f823 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -556,7 +556,7 @@ policy_lookup_cb (void *cls,
                                 " s:i}",        /* policy uuids length */
                                 "master_key",r->dps[j].emk,
                                 "uuids",r->dps[j].escrow_uuids,
-                                "uuid_length", r->dps[j].uuids_length));
+                                "uuids_length", r->dps[j].uuids_length));
   }
   r->solved_challenge_pos = 0;
   // SETUP POLICY CALLBACK
@@ -685,12 +685,12 @@ struct ANASTASIS_Truth
   /**
    * keyshare of this truth, used to generate policy keys
    */
-  struct ANASTASIS_CRYPTO_KeyShareP key_share;
+  const struct ANASTASIS_CRYPTO_KeyShareP *key_share;
 
   /**
    * key used to encrypt this truth
    */
-  struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
+  const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key;
 
   /**
    * server salt used to derive user identifier
@@ -867,6 +867,8 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
 
   tu = GNUNET_new (struct ANASTASIS_TruthUpload);
   t = GNUNET_new (struct ANASTASIS_Truth);
+  t->key_share = GNUNET_new (struct ANASTASIS_CRYPTO_KeyShareP);
+  t->truth_key = GNUNET_new (struct ANASTASIS_CRYPTO_TruthKeyP);
   tu->tc_cls = tc_cls;
   tu->tpc_cls = tpc_cls;
   tu->tpc = tpc;
@@ -879,7 +881,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
   t->salt = salt;
 
   uuid_generate (t->uuid);
-  GNUNET_assert (NULL != &t->uuid);
+  GNUNET_assert (0 == uuid_is_null (t->uuid));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d uuid is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (&t->uuid),
@@ -890,11 +892,11 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
               "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (salt),
               (unsigned long long) sizeof (*salt));
-  ANASTASIS_CRYPTO_keyshare_create (&t->key_share);
+  ANASTASIS_CRYPTO_keyshare_create (t->key_share);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d keyshare is %s-%llu b\n", __FILE__, __LINE__,
-              TALER_B2S (&t->key_share),
-              (unsigned long long) sizeof (t->key_share));
+              TALER_B2S (t->key_share),
+              (unsigned long long) sizeof (*t->key_share));
   ANASTASIS_CRYPTO_user_identifier_derive (id_data,
                                            salt,
                                            &tu->id);
@@ -902,7 +904,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
               "At %s:%d user identifier is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (&tu->id),
               (unsigned long long) sizeof (tu->id));
-  ANASTASIS_CRYPTO_keyshare_encrypt (&t->key_share,
+  ANASTASIS_CRYPTO_keyshare_encrypt (t->key_share,
                                      &tu->id,
                                      &encrypted_key_share);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -911,13 +913,13 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
               (unsigned long long) sizeof (*encrypted_key_share));
 
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
-                              &t->truth_key,
+                              t->truth_key,
                               sizeof (struct ANASTASIS_CRYPTO_TruthKeyP));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d truth key is %s-%llu b\n", __FILE__, __LINE__,
-              TALER_B2S (&t->truth_key),
-              (unsigned long long) sizeof (t->truth_key));
-  ANASTASIS_CRYPTO_truth_encrypt (&t->truth_key,
+              TALER_B2S (t->truth_key),
+              (unsigned long long) sizeof (*t->truth_key));
+  ANASTASIS_CRYPTO_truth_encrypt (t->truth_key,
                                   truth_data,
                                   truth_data_size,
                                   &encrypted_truth,
@@ -1030,7 +1032,7 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
   struct ANASTASIS_Policy *p;
   struct ANASTASIS_Truth *truth;
   struct ANASTASIS_CRYPTO_KeyShareP key_shares[truths_len];
-  uuid_t *uuids[truths_len];
+  uuid_t uuids[truths_len];
 
   p = GNUNET_new (struct ANASTASIS_Policy);
 
@@ -1048,14 +1050,18 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth 
*truths[],
                 "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (truth),
                 (unsigned long long) sizeof (struct ANASTASIS_Truth));
-    key_shares[i] = truth->key_share;
+    GNUNET_memcpy (&key_shares[i],
+                   truth->key_share,
+                   sizeof (struct ANASTASIS_CRYPTO_KeyShareP));
+    // key_shares[i] = truth->key_share;
     GNUNET_assert (NULL != &key_shares[i]);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d key share is %s-%llu b\n", __FILE__, __LINE__,
+                "At %s:%d keyshare is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (&key_shares[i]),
                 (unsigned long long) sizeof (key_shares[i]));
-    uuid_copy (&uuids[i], &truth->uuid);
-    GNUNET_assert (NULL != &uuids[i]);
+    // uuids[i] = truth->uuid;
+    uuid_copy (uuids[i], truth->uuid);
+    GNUNET_assert (0 == uuid_is_null (uuids[i]));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "At %s:%d uuid is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (&uuids[i]),
@@ -1079,10 +1085,10 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth 
*truths[],
   GNUNET_memcpy (p->truths,
                  truths,
                  truths_len * sizeof (struct ANASTASIS_Truth *));
-  p->uuids = GNUNET_malloc (truths_len * sizeof (uuid_t *));
+  p->uuids = GNUNET_malloc (truths_len * sizeof (uuid_t));
   GNUNET_memcpy (p->uuids,
                  uuids,
-                 truths_len * sizeof (uuid_t *));
+                 truths_len * sizeof (uuid_t));
   p->uuids_length = truths_len;
 
   GNUNET_assert (NULL != p->uuids);
@@ -1193,6 +1199,12 @@ struct PolicyStoreState
   const char *payment_order_req;
 
   int payment_requested;
+
+  /**
+   * Previous upload, or NULL for none. Used to calculate what THIS
+   * upload is based on.
+   */
+  const char *prev_upload;
 };
 
 /**
@@ -1293,7 +1305,8 @@ policy_store_cb (void *cls,
         }
         pss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "Order ID from Anastasis service is `%s'\n",
+                    "At %s:%d Order ID from Anastasis service is %s\n",
+                    __FILE__, __LINE__,
                     pss->payment_order_id);
 
         memset (&pss->curr_hash,
@@ -1352,9 +1365,10 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
 
     for (unsigned int l = 0; l < policies_len; l++)
     {
-      policy = policies[l];
       struct ANASTASIS_Truth *truth;
 
+      policy = policies[l];
+
       for (unsigned int j = 0; j < policy->uuids_length; j++)
       {
         truth = policy->truths[j];
@@ -1386,17 +1400,13 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
         {
           provider[unique_urls_len] = truth->url;
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      "At %s:%d provider url is %s\n", __FILE__, __LINE__,
+                      "At %s:%d unique 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__,
@@ -1408,6 +1418,7 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
 /**
 * Creates a recovery document with the created policies.
 *
+* @param ctx the CURL context used to connect to the backend
 * @param id_data used to create a account identifier on the escrow provider
 * @param last_etag NULL on 'first' use, otherwise 'current_etag' from previous 
ShareResultCallback
 * @param policies list of policies which are included in this recovery document
@@ -1420,7 +1431,8 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
 * @param core_secret_size size of the core secret
 */
 struct ANASTASIS_SecretShare *
-ANASTASIS_secret_share (const json_t *id_data,
+ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
+                        const json_t *id_data,
                         const struct GNUNET_HashCode *last_etag,
                         const struct ANASTASIS_Policy *policies[],
                         unsigned int policies_len,
@@ -1433,21 +1445,12 @@ 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 PolicyStoreState *pss[pss_length];
   struct GNUNET_HashCode current_etags[pss_length];
   enum TALER_ErrorCode ecs[pss_length];
-
-  ss = GNUNET_new (struct ANASTASIS_SecretShare);
-  ss->pss = &pss;
-  ss->pss_length = pss_length;
-  ss->spc = spc;
-  ss->spc_cls = spc_cls;
-  ss->src = src;
-  ss->src_cls = src_cls;
   struct ANASTASIS_CRYPTO_EncryptedMasterKeyP
     encrypted_master_keys[policies_len];
   struct ANASTASIS_CRYPTO_PolicyKeyP policy_keys[policies_len];
@@ -1462,13 +1465,25 @@ ANASTASIS_secret_share (const json_t *id_data,
   // json array
   json_t *esc_methods;
 
+  for (unsigned int i = 0; i < pss_length; i++)
+  {
+    pss[i] = GNUNET_new (struct PolicyStoreState);
+  }
+
+  ss = GNUNET_new (struct ANASTASIS_SecretShare);
+  ss->pss = pss;
+  ss->pss_length = pss_length;
+  ss->spc = spc;
+  ss->spc_cls = spc_cls;
+  ss->src = src;
+  ss->src_cls = src_cls;
+  ss->ctx = ctx;
+
   for (unsigned int i = 0; i < policies_len; i++)
   {
+    struct ANASTASIS_Policy *policy;
+
     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;
   }
 
@@ -1484,82 +1499,128 @@ ANASTASIS_secret_share (const json_t *id_data,
   int index_pss = 0;
   for (unsigned int k = 0; k < policies_len; k++ )
   {
+    struct ANASTASIS_Policy *policy;
+
     policy = policies[k];
-    json_t *dec_policy = json_pack ("{s:o," /* encrypted master key */
-                                    " s:o," /* policy uuids  */
-                                    " s:i}",/* policy uuids length */
-                                    "master_key",
-                                    GNUNET_JSON_from_data_auto (
-                                      &encrypted_master_keys[k]),
-                                    "uuids",
-                                    GNUNET_JSON_from_data (policy->uuids,
-                                                           policy->
-                                                           uuids_length
-                                                           * sizeof(uuid_t)),
-                                    "uuid_length", policy->uuids_length);
-    GNUNET_assert (NULL != dec_policy);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "dec policy json before upload 0: %s\n",
-                json_dumps (dec_policy, JSON_COMPACT));
+                "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (policy),
+                (unsigned long long) sizeof (struct ANASTASIS_Policy));
+    if (0 !=
+        json_array_append_new (
+          dec_policies,
+          json_pack ("{s:o,"   /* encrypted master key */
+                     " s:o,"   /* policy uuids  */
+                     " s:i}",  /* policy uuids length */
+                     "master_key",
+                     GNUNET_JSON_from_data_auto (
+                       &encrypted_master_keys[k]),
+                     "uuids",
+                     GNUNET_JSON_from_data (policy->uuids,
+                                            policy->
+                                            uuids_length
+                                            * sizeof(uuid_t)),
+                     "uuids_length",
+                     policy->uuids_length)))
+    {
+      GNUNET_break (0);
+      json_decref (dec_policies);
+      return NULL;
+    }
 
-    GNUNET_assert (0 ==
-                   json_array_append_new (dec_policies, dec_policy));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Dec policies json append before upload 0: %s\n",
+                "Dec policies json append before upload %d: %s\n",
+                k,
                 json_dumps (dec_policies, JSON_COMPACT));
 
     // FIXME CHALLENGE
     for (unsigned int l = 0; l < policy->uuids_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);
+      struct ANASTASIS_Truth *truth;
+
+      truth = policy->truths[l];
+      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));
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "At %s:%d keyshare is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (truth->key_share),
+                  (unsigned long long) sizeof (*truth->key_share));
+
       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));
+                  "At %s:%d truthkey is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (truth->truth_key),
+                  (unsigned long long) sizeof (*truth->truth_key));
+
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Esc methods json append before upload 0: %s\n",
+                  "At %s:%d uuid is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (&truth->uuid),
+                  (unsigned long long) sizeof (truth->uuid));
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (truth->salt),
+                  (unsigned long long) sizeof (*truth->salt));
+
+      // creates a json array for saving
+      if (0 !=
+          json_array_append_new (
+            esc_methods,
+            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_auto (&truth->uuid),
+                       "url",
+                       truth->url,
+                       "truth_key", GNUNET_JSON_from_data_auto (
+                         truth->truth_key),
+                       "salt", GNUNET_JSON_from_data_auto (
+                         truth->salt),
+                       "escrow_method",
+                       truth->method)))
+      {
+        GNUNET_break (0);
+        json_decref (esc_methods);
+        return NULL;
+      }
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Esc methods json append before upload %d: %s\n",
+                  l,
                   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))
+        if (NULL != ss->pss[j]->anastasis_url)
         {
-          contains_url = 1;
-          break;
+          if (0 == strcmp (ss->pss[j]->anastasis_url,
+                           truth->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;
+        ss->pss[index_pss]->anastasis_url = truth->url;
+        if (NULL != last_etag)
+          ss->pss[index_pss]->prev_hash = *last_etag;
+        ss->pss[index_pss]->server_salt = truth->salt;
         index_pss++;
       }
     }
+    /* FIXME free uuids and truths
     GNUNET_free (policy->uuids);
     GNUNET_free (policy->truths);
+    */
   }
 
   recovery_document = json_pack (
@@ -1568,23 +1629,26 @@ ANASTASIS_secret_share (const json_t *id_data,
     " s:o}", /* encrypted core secret */
     "policies", dec_policies,
     "escrow_methods", esc_methods,
-    "core_secret", GNUNET_JSON_from_data (&encrypted_core_secret,
+    "core_secret", GNUNET_JSON_from_data (encrypted_core_secret,
                                           core_secret_size));
   GNUNET_assert (NULL != recovery_document);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "recovery document json before upload 0: %s\n",
-              json_dumps (recovery_document, JSON_COMPACT));
+              "recovery document json before upload: %s\n",
+              json_dumps (recovery_document,
+                          JSON_COMPACT | JSON_SORT_KEYS));
 
   // FIXME COMPRESSION
-  recovery_document_str = json_dumps (recovery_document, JSON_COMPACT);
+  recovery_document_str = json_dumps (recovery_document,
+                                      JSON_COMPACT | JSON_SORT_KEYS);
   recovery_document_size = strlen (recovery_document_str);
+  GNUNET_assert (NULL != recovery_document_str);
+
   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]->http_status = MHD_HTTP_NO_CONTENT;
 
     ANASTASIS_CRYPTO_user_identifier_derive (id_data,
-                                             &ss->pss[l]->server_salt,
+                                             ss->pss[l]->server_salt,
                                              &ss->pss[l]->id);
 
     ANASTASIS_CRYPTO_account_private_key_derive (&ss->pss[l]->id,
@@ -1595,22 +1659,31 @@ ANASTASIS_secret_share (const json_t *id_data,
                                                 recovery_document_size,
                                                 &ss->pss[l]->recovery_data,
                                                 
&ss->pss[l]->recovery_data_size);
-
+    // hash recovery data
+    GNUNET_CRYPTO_hash (ss->pss[l]->recovery_data,
+                        ss->pss[l]->recovery_data_size,
+                        &ss->pss[l]->curr_hash);
     ss->pss[l]->pso = ANASTASIS_policy_store (ss->ctx,
                                               ss->pss[l]->anastasis_url,
                                               &ss->pss[l]->anastasis_priv,
-                                              last_etag,
+                                              ( ( (NULL !=
+                                                   ss->pss[l]->prev_upload) &&
+                                                  (0 != GNUNET_is_zero (
+                                                     last_etag)) ))
+                                              ? last_etag
+                                              : NULL,
                                               ss->pss[l]->recovery_data,
                                               ss->pss[l]->recovery_data_size,
                                               ss->pss[l]->payment_requested,
                                               ss->pss[l]->payment_order_id,
                                               &policy_store_cb,
                                               ss->pss[l]);
+    GNUNET_assert (NULL != ss->pss[l]->pso);
 
-    current_etags[l] = pss[l].curr_hash;
-    ecs[l] = pss[l].ec;
+    current_etags[l] = ss->pss[l]->curr_hash;
+    ecs[l] = ss->pss[l]->ec;
   }
-
+  // FIXME: clean up PSS, UUIDS, TRUTHS etc. !!!
   // SETUP SHARE RESULT CALLBACK
   if (NULL != ss->src)
   {
diff --git a/src/lib/anastasis_api_policy_store.c 
b/src/lib/anastasis_api_policy_store.c
index cb8e324..5d7e9a4 100644
--- a/src/lib/anastasis_api_policy_store.c
+++ b/src/lib/anastasis_api_policy_store.c
@@ -426,6 +426,13 @@ ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
                                  NULL);
     GNUNET_free (path);
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d url is %s\n", __FILE__, __LINE__,
+              pso->url);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d recovery data is %s-%llu b\n", __FILE__, __LINE__,
+              TALER_b2s (recovery_data, recovery_data_size),
+              (unsigned long long) recovery_data_size);
   pso->ctx = ctx;
   pso->cb = cb;
   pso->cb_cls = cb_cls;
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index fdd47f5..58c1a08 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -252,7 +252,7 @@ run (void *cls,
                                         ANASTASIS_TESTING_SSO_NONE,
                                         "policy-create-1",
                                         NULL),
-/**
+    /**
     ANASTASIS_TESTING_cmd_recover_secret ("recover-secret-1",
                                           anastasis_url,
                                           
ANASTASIS_TESTING_make_id_data_example (
@@ -281,7 +281,7 @@ run (void *cls,
                                             2,
                                             "HashOfSomeTruth3",
                                             strlen("HashOfSomeTruth3")),
-*//
+    */
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
index 4ec5f81..9e18d99 100644
--- a/src/lib/testing_cmd_secret_share.c
+++ b/src/lib/testing_cmd_secret_share.c
@@ -108,15 +108,16 @@ struct SecretShareState
  * Function called for payment routine.
  *
  * @param cls closure
+ * @param etag etag of upload
  * @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)
+                         struct GNUNET_HashCode *etags,
+                         enum ANASTASIS_ErrorCode *ec)
 {
-
+  struct SecretShareState *sss = cls;
+  sss->sso = NULL;
 }
 
 
@@ -124,30 +125,16 @@ secret_share_payment_cb (void *cls,
  * Function called with the results of a #secret_share().
  *
  * @param cls closure
+ * @param etag etag of upload
  * @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 GNUNET_HashCode *etag,
+                        enum ANASTASIS_ErrorCode *ec)
 {
   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;
-  }
 }
 
 /**
@@ -207,7 +194,8 @@ secret_share_run (void *cls,
     }
   }
 
-  sss->sso = ANASTASIS_secret_share (sss->id_data,
+  sss->sso = ANASTASIS_secret_share (is->ctx,
+                                     sss->id_data,
                                      NULL,
                                      policies,
                                      sss->cmd_label_array_length,

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



reply via email to

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