[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: clean up backup logic a bit mor
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: clean up backup logic a bit more |
Date: |
Fri, 05 Feb 2021 16:42:42 +0100 |
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 75304e6 clean up backup logic a bit more
75304e6 is described below
commit 75304e6b7aaf7427133929d6b075da4f47a7b6f5
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Feb 5 16:42:40 2021 +0100
clean up backup logic a bit more
---
src/include/anastasis.h | 37 +--
src/include/anastasis_service.h | 2 +-
src/lib/Makefile.am | 1 +
src/lib/anastasis_backup.c | 489 ++++++++++++-------------------
src/reducer/anastasis_api_backup_redux.c | 1 +
src/testing/testing_cmd_secret_share.c | 1 +
6 files changed, 218 insertions(+), 313 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 5a15a1d..5514ccd 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -30,23 +30,6 @@
#include <stdbool.h>
-/**
- * Details of a past payment
- */
-struct ANASTASIS_PaymentDetails
-{
- /**
- * URL of the provider backend.
- */
- const char *provider_url;
-
- /**
- * Payment order ID / secret of a past payment.
- */
- struct ANASTASIS_PaymentSecretP payment_secret;
-};
-
-
/* ********************* Recovery api *********************** */
@@ -544,6 +527,23 @@ typedef void
struct ANASTASIS_SecretShare;
+/**
+ * Details of a past payment
+ */
+struct ANASTASIS_PaymentDetails
+{
+ /**
+ * URL of the provider backend.
+ */
+ const char *provider_url;
+
+ /**
+ * Payment order ID / secret of a past payment.
+ */
+ struct ANASTASIS_PaymentSecretP payment_secret;
+};
+
+
/**
* Creates a recovery document with the created policies and uploads it to
* all servers. FIXME: how do we know the upload(s) are completed?
@@ -555,6 +555,8 @@ struct ANASTASIS_SecretShare;
* @param policies_length amount of policies in the document
* @param pds contains details of past payments
* @param pds_len length of @a pds array
+ * @param payment_requested the client insists on paying for the policy store,
even if not
+ * yet needed
* @param spc payment callback is opened to pay the upload
* @param spc_cls closure for the payment callback
* @param src callback for the upload process
@@ -570,6 +572,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
unsigned int policies_len,
const struct ANASTASIS_PaymentDetails *pds,
unsigned int pds_len,
+ bool payment_requested,
ANASTASIS_SharePaymentCallback spc,
void *spc_cls,
ANASTASIS_ShareResultCallback src,
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index e0cb416..9285029 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -402,7 +402,7 @@ struct ANASTASIS_PolicyStoreOperation;
* @param cls closure
* @param http_status HTTP status code for this request
* @param ec anastasis-specific error code
- * @param obj the response body
+ * @param obj the decoded response body
*/
typedef void
(*ANASTASIS_PolicyStoreCallback) (void *cls,
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 654f615..31dac24 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -22,4 +22,5 @@ libanastasis_la_LIBADD = \
-ljansson \
-ltalerutil \
-ltalermerchant \
+ -lz \
$(XLIB)
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index bebb58f..a88b9de 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -19,17 +19,17 @@
* @author Dominik Meister
* @author Dennis Neufeld
*/
-
#include "anastasis.h"
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_util_lib.h>
#include <taler/taler_merchant_service.h>
+#include <zlib.h>
struct ANASTASIS_Truth
{
/**
- * Identification of the truth
+ * Identification of the truth.
*/
struct ANASTASIS_CRYPTO_NonceP nonce;
@@ -448,24 +448,7 @@ struct PolicyStoreState
struct ANASTASIS_CRYPTO_UserIdentifierP id;
/**
- * Eddsa Publickey.
- */
- struct ANASTASIS_CRYPTO_AccountPublicKeyP anastasis_pub;
-
- /**
- * Eddsa Privatekey.
- */
- struct ANASTASIS_CRYPTO_AccountPrivateKeyP 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.
+ * Hash of the current upload. Used to check the server's response.
*/
struct GNUNET_HashCode curr_hash;
@@ -475,20 +458,11 @@ struct PolicyStoreState
struct ANASTASIS_PaymentSecretP payment_secret;
/**
- * Struct to obtain the salt from the server
- */
- struct SaltState *st;
-
- /**
- * Server salt
+ * Server salt. Points into a truth object from which we
+ * got the salt.
*/
const struct ANASTASIS_CRYPTO_PowSalt *server_salt;
- /**
- * The policy data.
- */
- void *recovery_data;
-
/**
* The /policy POST operation handle.
*/
@@ -499,22 +473,6 @@ struct PolicyStoreState
*/
const char *anastasis_url;
- /**
- * 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.
- */
- const char *payment_order_req;
-
- /**
- * Previous upload, or NULL for none. Used to calculate what THIS
- * upload is based on.
- */
- const char *prev_upload;
-
/**
* reference to SecretShare
*/
@@ -541,17 +499,10 @@ struct PolicyStoreState
void *src_cls;
/**
- * Number of bytes in @e recovery_data
- */
- size_t recovery_data_size;
-
- /**
- * Expected status code.
+ * Expected HTTP status code, usually #MHD_HTTP_NO_CONTENT.
*/
unsigned int http_status;
- bool payment_requested;
-
/**
* Status of the transaction
*/
@@ -572,7 +523,7 @@ struct ANASTASIS_SecretShare
/**
* References for the upload states and operations (size of truths passed)
*/
- struct PolicyStoreState **pss;
+ struct PolicyStoreState *pss;
/**
* Closure for the Result Callback
@@ -582,27 +533,13 @@ struct ANASTASIS_SecretShare
/**
- * Free the state of a "policy store" CMD, and possibly
- * cancel it if it did not complete.
+ * Callback to process a POST /policy request
*
- * @param cls closure.
+ * @param cls closure
+ * @param http_status HTTP status code for this request
+ * @param ec anastasis-specific error code
+ * @param obj the decoded response body
*/
-static void
-policy_store_cleanup (void *cls)
-{
- struct PolicyStoreState *pss = cls;
-
- if (NULL != pss->pso)
- {
- ANASTASIS_policy_store_cancel (pss->pso);
- pss->pso = NULL;
- }
- GNUNET_free (pss->recovery_data);
- GNUNET_free (pss->payment_order_id);
- GNUNET_free (pss);
-}
-
-
static void
policy_store_cb (void *cls,
enum ANASTASIS_ErrorCode ec,
@@ -661,12 +598,7 @@ policy_store_cb (void *cls,
GNUNET_break (0);
return;
}
- pss->payment_order_id = GNUNET_strdup (pd.order_id);
TALER_MERCHANT_parse_pay_uri_free (&pd);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d Order ID from Anastasis service is %s\n",
- __FILE__, __LINE__,
- pss->payment_order_id);
memset (&pss->curr_hash,
0,
sizeof (struct GNUNET_HashCode));
@@ -718,42 +650,28 @@ policy_store_cb (void *cls,
* @return number of different providers
*/
static unsigned int
-ANASTASIS_get_num_urls (const struct ANASTASIS_Policy *policies[],
- unsigned int policies_len)
+get_num_urls (const struct ANASTASIS_Policy *policies[],
+ unsigned int policies_len)
{
unsigned int len = 0;
unsigned int unique_urls_len = 0;
+ if (0 == policies_len)
+ return 0;
for (unsigned int i = 0; i < policies_len; i++)
len += policies[i]->truths_length;
-
{
char *provider[len];
for (unsigned int l = 0; l < policies_len; l++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (policies[l]),
- (unsigned long long) sizeof (struct ANASTASIS_Policy));
-
for (unsigned int j = 0; j < policies[l]->truths_length; j++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (policies[l]->truths[j]),
- (unsigned long long) sizeof (struct ANASTASIS_Truth));
-
int contains_url = 0;
if (0 < unique_urls_len)
{
for (unsigned int k = 0; k < unique_urls_len; k++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d provider url from truth is %s\n", __FILE__,
- __LINE__,
- policies[l]->truths[j]->url);
-
if (NULL != provider[k])
{
if (0 ==
@@ -770,10 +688,6 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy
*policies[],
{
provider[unique_urls_len]
= GNUNET_strdup (policies[l]->truths[j]->url);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d unique provider url is %s\n",
- __FILE__, __LINE__,
- provider[unique_urls_len]);
unique_urls_len++;
}
}
@@ -783,11 +697,6 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy
*policies[],
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;
}
@@ -800,6 +709,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
unsigned int policies_len,
const struct ANASTASIS_PaymentDetails *pds,
unsigned int pds_len,
+ bool payment_requested,
ANASTASIS_SharePaymentCallback spc,
void *spc_cls,
ANASTASIS_ShareResultCallback src,
@@ -808,139 +718,108 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
size_t core_secret_size)
{
struct ANASTASIS_SecretShare *ss;
-
- GNUNET_assert (policies_len > 0);
- unsigned int pss_length = ANASTASIS_get_num_urls (policies,
- policies_len);
- struct PolicyStoreState *pss[pss_length];
+ unsigned int pss_length = get_num_urls (policies,
+ policies_len);
struct ANASTASIS_CRYPTO_EncryptedMasterKeyP
- encrypted_master_keys[policies_len];
- struct ANASTASIS_CRYPTO_PolicyKeyP policy_keys[policies_len];
+ encrypted_master_keys[GNUNET_NZL (policies_len)];
void *encrypted_core_secret;
- // Recovery document contains the array decryption policies and the array
escrow methods
- json_t *recovery_document;
- size_t recovery_document_size;
- char *recovery_document_str;
- // json array
json_t *dec_policies;
- // json array
json_t *esc_methods;
+ unsigned int index_pss = 0;
+ size_t recovery_document_size;
+ char *recovery_document_str;
if (0 == pss_length)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "At %s:%d pss_length is %d!\n", __FILE__, __LINE__,
- pss_length);
GNUNET_break (0);
return NULL;
}
-
ss = GNUNET_new (struct ANASTASIS_SecretShare);
+ ss->pss = GNUNET_new_array (pss_length,
+ struct PolicyStoreState);
for (unsigned int i = 0; i < pss_length; i++)
{
- pss[i] = GNUNET_new (struct PolicyStoreState);
- pss[i]->ss = ss;
+ struct PolicyStoreState *pss = &ss->pss[i];
+
+ pss->ss = ss;
+ pss->http_status = MHD_HTTP_NO_CONTENT;
+ pss->spc = spc;
+ pss->spc_cls = spc_cls;
+ pss->src = src;
+ pss->src_cls = src_cls;
}
- ss->pss = pss;
ss->pss_length = pss_length;
ss->ctx = ctx;
- for (unsigned int i = 0; i < policies_len; i++)
- policy_keys[i] = policies[i]->policy_key;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d core secret is %s-%llu b\n", __FILE__, __LINE__,
- TALER_b2s (core_secret,
- core_secret_size),
- (unsigned long long) core_secret_size);
-
- ANASTASIS_CRYPTO_core_secret_encrypt (policy_keys,
- policies_len,
- core_secret,
- core_secret_size,
- &encrypted_core_secret,
- encrypted_master_keys);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d encrypted core secret is %s-%llu b\n", __FILE__,
- __LINE__,
- TALER_b2s (encrypted_core_secret,
- core_secret_size),
- (unsigned long long) core_secret_size);
-
+ {
+ struct ANASTASIS_CRYPTO_PolicyKeyP policy_keys[GNUNET_NZL (policies_len)];
+
+ for (unsigned int i = 0; i < policies_len; i++)
+ policy_keys[i] = policies[i]->policy_key;
+ ANASTASIS_CRYPTO_core_secret_encrypt (policy_keys,
+ policies_len,
+ core_secret,
+ core_secret_size,
+ &encrypted_core_secret,
+ encrypted_master_keys);
+ }
dec_policies = json_array ();
- esc_methods = json_array ();
- int index_pss = 0;
for (unsigned int k = 0; k < policies_len; k++)
{
const struct ANASTASIS_Policy *policy = policies[k];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d policy is %s\n",
- __FILE__,
- __LINE__,
- TALER_B2S (&policy->policy_key));
-
json_t *nonces = json_array ();
for (unsigned int b = 0; b < policy->truths_length; b++)
- {
json_array_append (nonces,
GNUNET_JSON_from_data_auto (
&policy->truths[b]->nonce));
- }
-
if (0 !=
json_array_append_new (
dec_policies,
- json_pack ("{s:o," /* encrypted master key */
- " s:o," /* policy nonces */
- " s:o," /* policy salt */
- " s:i}", /* policy nonces length */
+ json_pack ("{s:o, s:o, s:o}",
"master_key",
GNUNET_JSON_from_data_auto (
&encrypted_master_keys[k]),
"nonces",
nonces,
"salt",
- GNUNET_JSON_from_data_auto (&policy->salt),
- "nonces_length",
- (int) policy->truths_length)))
+ GNUNET_JSON_from_data_auto (&policy->salt))))
{
GNUNET_break (0);
json_decref (dec_policies);
+ ANASTASIS_secret_share_cancel (ss);
return NULL;
}
+ }
+
+ esc_methods = json_array ();
+ for (unsigned int k = 0; k < policies_len; k++)
+ {
+ const struct ANASTASIS_Policy *policy = policies[k];
- // FIXME CHALLENGE
for (unsigned int l = 0; l < policy->truths_length; l++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (policy->truths[l]),
- (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 (&policy->truths[l]->key_share),
- (unsigned long
- long) sizeof (policy->truths[l]->key_share));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d truthkey is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (&policy->truths[l]->truth_key),
- (unsigned long
- long) sizeof (policy->truths[l]->truth_key));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d nonce is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (&policy->truths[l]->nonce),
- (unsigned long long) sizeof (policy->truths[l]->nonce));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (&policy->truths[l]->salt),
- (unsigned long long) sizeof (policy->truths[l]->salt));
-
- // FIXME: JUST APPEND UNIQUE NONCES!!!
- // creates a json array for saving
+ struct ANASTASIS_Truth *pt = policy->truths[l];
+ bool unique = true;
+
+ /* Only append each truth once */
+ for (unsigned int k2 = 0; k2 < k; k2++)
+ {
+ const struct ANASTASIS_Policy *p2 = policies[k2];
+ for (unsigned int l2 = 0; l2 < p2->truths_length; l2++)
+ if (0 ==
+ GNUNET_memcmp (&pt->nonce,
+ &p2->truths[l2]->nonce))
+ {
+ unique = false;
+ break;
+ }
+ if (! unique)
+ break;
+ }
+ if (! unique)
+ continue;
+
if (0 !=
json_array_append_new (
esc_methods,
@@ -952,143 +831,154 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
" s:s}", /* escrow method */
"nonce",
GNUNET_JSON_from_data_auto (
- &policy->truths[l]->nonce),
+ &pt->nonce),
"url",
- policy->truths[l]->url,
+ pt->url,
"instructions",
- policy->truths[l]->instructions,
+ pt->instructions,
"truth_key", GNUNET_JSON_from_data_auto (
- &policy->truths[l]->truth_key),
+ &pt->truth_key),
"salt", GNUNET_JSON_from_data_auto (
- &policy->truths[l]->salt),
+ &pt->salt),
"escrow_method",
- policy->truths[l]->method)))
+ pt->method)))
{
GNUNET_break (0);
json_decref (esc_methods);
+ json_decref (dec_policies);
+ ANASTASIS_secret_share_cancel (ss);
return NULL;
}
- // prepares policy store operation
- bool contains_url = false;
- for (unsigned int j = 0; j < ss->pss_length; j++)
+ /* Check if this truth also specifies a new unique provider */
{
- if (NULL != ss->pss[j]->anastasis_url)
+ bool contains_url = false;
+ 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 = true;
- break;
+ if (0 == strcmp (ss->pss[j].anastasis_url,
+ pt->url))
+ {
+ contains_url = true;
+ break;
+ }
}
}
+ if (contains_url)
+ continue;
}
- if (! contains_url)
+
+ /* new provider, setup per-provider data structure */
{
- ss->pss[index_pss]->anastasis_url = policy->truths[l]->url;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d anastasis url is %s\n", __FILE__, __LINE__,
- ss->pss[index_pss]->anastasis_url);
- if (NULL != last_etag)
- ss->pss[index_pss]->prev_hash = *last_etag;
- ss->pss[index_pss]->server_salt = &policy->truths[l]->salt;
- if (pds_len > 0)
+ struct PolicyStoreState *pss;
+
+ GNUNET_assert (index_pss < pss_length);
+ pss = &ss->pss[index_pss++];
+ pss->anastasis_url = pt->url;
+ pss->server_salt = &pt->salt;
+ for (unsigned int m = 0; 0 < pds_len; m++)
{
- for (unsigned int m = 0; 0 < pds_len; m++)
+ if (NULL == pds[m].provider_url)
+ continue;
+ if (0 == strcmp (pds[m].provider_url,
+ pt->url))
{
- if (NULL == pds[m].provider_url)
- continue;
- if (0 == strcmp (pds[m].provider_url,
- policy->truths[l]->url))
- {
- ss->pss[index_pss]->payment_secret
- = pds[m].payment_secret;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d Payment-Identifier from PD is: %s\n",
- __FILE__,
- __LINE__,
- TALER_B2S (&pds[m].payment_secret));
- break;
- }
+ pss->payment_secret = pds[m].payment_secret;
+ break;
}
}
- index_pss++;
}
}
}
+ /* We must have setup the entire pss array at this point */
+ GNUNET_assert (index_pss == pss_length);
- recovery_document = json_pack (
- "{s:o," /* decryption policies */
- " s:o," /* escrow methods */
- " s:o}", /* encrypted core secret */
- "policies", dec_policies,
- "escrow_methods", esc_methods,
- "core_secret", GNUNET_JSON_from_data (encrypted_core_secret,
- core_secret_size));
- GNUNET_free (encrypted_core_secret);
- GNUNET_assert (NULL != recovery_document);
-
- // FIXME COMPRESSION
- 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);
- json_decref (recovery_document);
+ {
+ json_t *recovery_document;
+ size_t rd_size;
+ char *rd_str;
+ Bytef *cbuf;
+ uLongf cbuf_size;
+ int ret;
+
+ recovery_document = json_pack (
+ "{s:o, s:o, s:o}",
+ "policies", dec_policies,
+ "escrow_methods", esc_methods,
+ "core_secret", GNUNET_JSON_from_data (encrypted_core_secret,
+ core_secret_size));
+ GNUNET_assert (NULL != recovery_document);
+ GNUNET_free (encrypted_core_secret);
+
+ rd_str = json_dumps (recovery_document,
+ JSON_COMPACT | JSON_SORT_KEYS);
+ GNUNET_assert (NULL != rd_str);
+ json_decref (recovery_document);
+ rd_size = strlen (rd_str);
+ cbuf_size = compressBound (rd_size);
+ cbuf = GNUNET_malloc (cbuf_size);
+ ret = compress (cbuf,
+ &cbuf_size,
+ (const Bytef *) rd_str,
+ rd_size);
+ if (Z_OK != ret)
+ {
+ /* compression failed!? */
+ GNUNET_break (0);
+ free (rd_str);
+ GNUNET_free (cbuf);
+ ANASTASIS_secret_share_cancel (ss);
+ return NULL;
+ }
+ free (rd_str);
+ recovery_document_size = (size_t) cbuf_size;
+ recovery_document_str = (char *) cbuf;
+ }
for (unsigned int l = 0; l < ss->pss_length; l++)
{
- ss->pss[l]->http_status = MHD_HTTP_NO_CONTENT;
-
- ss->pss[l]->spc = spc;
- ss->pss[l]->spc_cls = spc_cls;
- ss->pss[l]->src = src;
- ss->pss[l]->src_cls = src_cls;
+ struct PolicyStoreState *pss = &ss->pss[l];
+ void *recovery_data;
+ size_t recovery_data_size;
+ struct ANASTASIS_CRYPTO_AccountPrivateKeyP anastasis_priv;
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
- ss->pss[l]->server_salt,
- &ss->pss[l]->id);
-
- ANASTASIS_CRYPTO_account_private_key_derive (&ss->pss[l]->id,
- &ss->pss[l]->anastasis_priv);
-
- ANASTASIS_CRYPTO_recovery_document_encrypt (&ss->pss[l]->id,
+ pss->server_salt,
+ &pss->id);
+ ANASTASIS_CRYPTO_account_private_key_derive (&pss->id,
+ &anastasis_priv);
+ ANASTASIS_CRYPTO_recovery_document_encrypt (&pss->id,
recovery_document_str,
recovery_document_size,
- &ss->pss[l]->recovery_data,
-
&ss->pss[l]->recovery_data_size);
- GNUNET_free (recovery_document_str);
- // hash recovery data
- GNUNET_CRYPTO_hash (ss->pss[l]->recovery_data,
- ss->pss[l]->recovery_data_size,
- &ss->pss[l]->curr_hash);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d current hash is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (&ss->pss[l]->curr_hash),
- (unsigned long long) sizeof (struct GNUNET_HashCode));
-
- ss->pss[l]->pso = ANASTASIS_policy_store (ss->ctx,
- ss->pss[l]->anastasis_url,
- &ss->pss[l]->anastasis_priv,
- ( ( (NULL !=
- ss->pss[l]->prev_upload) &&
- (GNUNET_NO == GNUNET_is_zero
(
- last_etag)) ))
- ? last_etag
- : NULL,
- ss->pss[l]->recovery_data,
- ss->pss[l]->recovery_data_size,
- ss->pss[l]->payment_requested,
- (pds_len > 0)
- ? &ss->pss[l]->payment_secret
- : NULL,
- &policy_store_cb,
- ss->pss[l]);
- if (NULL == ss->pss[l]->pso)
+ &recovery_data,
+ &recovery_data_size);
+ GNUNET_CRYPTO_hash (recovery_data,
+ recovery_data_size,
+ &pss->curr_hash);
+ pss->pso = ANASTASIS_policy_store (
+ ss->ctx,
+ pss->anastasis_url,
+ &anastasis_priv,
+ last_etag,
+ recovery_data,
+ recovery_data_size,
+ payment_requested,
+ (! GNUNET_is_zero (&pss->payment_secret))
+ ? &pss->payment_secret
+ : NULL,
+ &policy_store_cb,
+ pss);
+ GNUNET_free (recovery_data);
+ if (NULL == pss->pso)
{
GNUNET_break (0);
+ ANASTASIS_secret_share_cancel (ss);
+ GNUNET_free (recovery_document_str);
return NULL;
}
}
+ GNUNET_free (recovery_document_str);
return ss;
}
@@ -1096,5 +986,14 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
void
ANASTASIS_secret_share_cancel (struct ANASTASIS_SecretShare *ss)
{
+ for (unsigned int i = 0; i<ss->pss_length; i++)
+ {
+ if (NULL != ss->pss[i].pso)
+ {
+ ANASTASIS_policy_store_cancel (ss->pss[i].pso);
+ ss->pss[i].pso = NULL;
+ }
+ }
+ GNUNET_free (ss->pss);
GNUNET_free (ss);
}
diff --git a/src/reducer/anastasis_api_backup_redux.c
b/src/reducer/anastasis_api_backup_redux.c
index 5696af0..3f017b3 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -1690,6 +1690,7 @@ upload_rec_documents (json_t *state,
? pds
: NULL,
pds_len,
+ false, /* do not insist on payment */
&secret_share_payment_cb,
sss,
&secret_share_result_cb,
diff --git a/src/testing/testing_cmd_secret_share.c
b/src/testing/testing_cmd_secret_share.c
index 5a6b6c5..3259aa0 100644
--- a/src/testing/testing_cmd_secret_share.c
+++ b/src/testing/testing_cmd_secret_share.c
@@ -349,6 +349,7 @@ secret_share_run (void *cls,
sss->cmd_label_array_length,
pds,
pds_len,
+ false, /* we never insist on payment */
&secret_share_payment_cb,
sss,
&secret_share_result_cb,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: clean up backup logic a bit more,
gnunet <=