summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-19 13:29:47 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-19 13:29:47 +0100
commitb973491c643a5e86e3df3acb9fc62a62d9401438 (patch)
treeee582ffe52f403cc450a0cb7d2f87bc4c1ecdcea
parent16bb30ce4b424fa5ada004c53721a6f3f202b538 (diff)
downloadanastasis-b973491c643a5e86e3df3acb9fc62a62d9401438.tar.gz
anastasis-b973491c643a5e86e3df3acb9fc62a62d9401438.tar.bz2
anastasis-b973491c643a5e86e3df3acb9fc62a62d9401438.zip
enable meta-data upload in REST client logic
-rw-r--r--src/include/anastasis_service.h6
-rw-r--r--src/lib/anastasis_backup.c1
-rw-r--r--src/restclient/anastasis_api_policy_store.c29
-rw-r--r--src/testing/testing_api_cmd_policy_store.c1
4 files changed, 35 insertions, 2 deletions
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 5a8ca21..ee24b7a 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -192,7 +192,7 @@ struct ANASTASIS_MetaDownloadDetails
/**
* Number of entries in @e metas.
*/
- unsigned int metas_length;
+ size_t metas_length;
};
@@ -473,6 +473,8 @@ typedef void
* @param anastasis_priv private key of the user's account
* @param recovery_data policy data to be stored
* @param recovery_data_size number of bytes in @a recovery_data
+ * @param recovery_meta_data policy meta data to be stored, can be NULL
+ * @param recovery_meta_data_size number of bytes in @a recovery_meta_data
* @param payment_years_requested for how many years would the client like the service to store the truth?
* @param payment_secret payment identifier of last payment
* @param payment_timeout how long to wait for the payment, use
@@ -488,6 +490,8 @@ ANASTASIS_policy_store (
const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
const void *recovery_data,
size_t recovery_data_size,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size,
uint32_t payment_years_requested,
const struct ANASTASIS_PaymentSecretP *payment_secret,
struct GNUNET_TIME_Relative payment_timeout,
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index 21dd291..f5b91fb 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -919,6 +919,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
&anastasis_priv,
recovery_data,
recovery_data_size,
+ NULL, 0, /* FIXME: meta-data! */
payment_years_requested,
(! GNUNET_is_zero (&pss->payment_secret))
? &pss->payment_secret
diff --git a/src/restclient/anastasis_api_policy_store.c b/src/restclient/anastasis_api_policy_store.c
index b709472..2432079 100644
--- a/src/restclient/anastasis_api_policy_store.c
+++ b/src/restclient/anastasis_api_policy_store.c
@@ -1,6 +1,6 @@
/*
This file is part of ANASTASIS
- Copyright (C) 2014-2021 Anastasis SARL
+ Copyright (C) 2014-2022 Anastasis SARL
ANASTASIS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -356,6 +356,8 @@ ANASTASIS_policy_store (
const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
const void *recovery_data,
size_t recovery_data_size,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size,
uint32_t payment_years_requested,
const struct ANASTASIS_PaymentSecretP *payment_secret,
struct GNUNET_TIME_Relative payment_timeout,
@@ -425,6 +427,31 @@ ANASTASIS_policy_store (
}
job_headers = ext;
+ /* Setup meta-data header */
+ if (NULL != recovery_meta_data)
+ {
+ char *meta_val;
+
+ meta_val = GNUNET_STRINGS_data_to_string_alloc (
+ recovery_meta_data,
+ recovery_meta_data_size);
+ GNUNET_asprintf (&hdr,
+ "%s: %s",
+ ANASTASIS_HTTP_HEADER_POLICY_META_DATA,
+ meta_val);
+ GNUNET_free (meta_val);
+ ext = curl_slist_append (job_headers,
+ hdr);
+ GNUNET_free (hdr);
+ if (NULL == ext)
+ {
+ GNUNET_break (0);
+ curl_slist_free_all (job_headers);
+ return NULL;
+ }
+ job_headers = ext;
+ }
+
/* Setup Payment-Identifier header */
if (NULL != payment_secret)
{
diff --git a/src/testing/testing_api_cmd_policy_store.c b/src/testing/testing_api_cmd_policy_store.c
index d1ee3c0..08e567c 100644
--- a/src/testing/testing_api_cmd_policy_store.c
+++ b/src/testing/testing_api_cmd_policy_store.c
@@ -281,6 +281,7 @@ policy_store_run (void *cls,
&pss->anastasis_priv,
pss->recovery_data,
pss->recovery_data_size,
+ NULL, 0, /* meta-data */
(0 != (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT & pss->psopt)),
pss->payment_secret_set ? &pss->payment_secret_request : NULL,
GNUNET_TIME_UNIT_ZERO,