aboutsummaryrefslogtreecommitdiff
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.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
192 /** 192 /**
193 * Number of entries in @e metas. 193 * Number of entries in @e metas.
194 */ 194 */
195 unsigned int metas_length; 195 size_t metas_length;
196 196
197}; 197};
198 198
@@ -473,6 +473,8 @@ typedef void
473 * @param anastasis_priv private key of the user's account 473 * @param anastasis_priv private key of the user's account
474 * @param recovery_data policy data to be stored 474 * @param recovery_data policy data to be stored
475 * @param recovery_data_size number of bytes in @a recovery_data 475 * @param recovery_data_size number of bytes in @a recovery_data
476 * @param recovery_meta_data policy meta data to be stored, can be NULL
477 * @param recovery_meta_data_size number of bytes in @a recovery_meta_data
476 * @param payment_years_requested for how many years would the client like the service to store the truth? 478 * @param payment_years_requested for how many years would the client like the service to store the truth?
477 * @param payment_secret payment identifier of last payment 479 * @param payment_secret payment identifier of last payment
478 * @param payment_timeout how long to wait for the payment, use 480 * @param payment_timeout how long to wait for the payment, use
@@ -488,6 +490,8 @@ ANASTASIS_policy_store (
488 const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv, 490 const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
489 const void *recovery_data, 491 const void *recovery_data,
490 size_t recovery_data_size, 492 size_t recovery_data_size,
493 const void *recovery_meta_data,
494 size_t recovery_meta_data_size,
491 uint32_t payment_years_requested, 495 uint32_t payment_years_requested,
492 const struct ANASTASIS_PaymentSecretP *payment_secret, 496 const struct ANASTASIS_PaymentSecretP *payment_secret,
493 struct GNUNET_TIME_Relative payment_timeout, 497 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,
919 &anastasis_priv, 919 &anastasis_priv,
920 recovery_data, 920 recovery_data,
921 recovery_data_size, 921 recovery_data_size,
922 NULL, 0, /* FIXME: meta-data! */
922 payment_years_requested, 923 payment_years_requested,
923 (! GNUNET_is_zero (&pss->payment_secret)) 924 (! GNUNET_is_zero (&pss->payment_secret))
924 ? &pss->payment_secret 925 ? &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 @@
1/* 1/*
2 This file is part of ANASTASIS 2 This file is part of ANASTASIS
3 Copyright (C) 2014-2021 Anastasis SARL 3 Copyright (C) 2014-2022 Anastasis SARL
4 4
5 ANASTASIS is free software; you can redistribute it and/or modify 5 ANASTASIS is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as 6 it under the terms of the GNU General Public License as
@@ -356,6 +356,8 @@ ANASTASIS_policy_store (
356 const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv, 356 const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
357 const void *recovery_data, 357 const void *recovery_data,
358 size_t recovery_data_size, 358 size_t recovery_data_size,
359 const void *recovery_meta_data,
360 size_t recovery_meta_data_size,
359 uint32_t payment_years_requested, 361 uint32_t payment_years_requested,
360 const struct ANASTASIS_PaymentSecretP *payment_secret, 362 const struct ANASTASIS_PaymentSecretP *payment_secret,
361 struct GNUNET_TIME_Relative payment_timeout, 363 struct GNUNET_TIME_Relative payment_timeout,
@@ -425,6 +427,31 @@ ANASTASIS_policy_store (
425 } 427 }
426 job_headers = ext; 428 job_headers = ext;
427 429
430 /* Setup meta-data header */
431 if (NULL != recovery_meta_data)
432 {
433 char *meta_val;
434
435 meta_val = GNUNET_STRINGS_data_to_string_alloc (
436 recovery_meta_data,
437 recovery_meta_data_size);
438 GNUNET_asprintf (&hdr,
439 "%s: %s",
440 ANASTASIS_HTTP_HEADER_POLICY_META_DATA,
441 meta_val);
442 GNUNET_free (meta_val);
443 ext = curl_slist_append (job_headers,
444 hdr);
445 GNUNET_free (hdr);
446 if (NULL == ext)
447 {
448 GNUNET_break (0);
449 curl_slist_free_all (job_headers);
450 return NULL;
451 }
452 job_headers = ext;
453 }
454
428 /* Setup Payment-Identifier header */ 455 /* Setup Payment-Identifier header */
429 if (NULL != payment_secret) 456 if (NULL != payment_secret)
430 { 457 {
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,
281 &pss->anastasis_priv, 281 &pss->anastasis_priv,
282 pss->recovery_data, 282 pss->recovery_data,
283 pss->recovery_data_size, 283 pss->recovery_data_size,
284 NULL, 0, /* meta-data */
284 (0 != (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT & pss->psopt)), 285 (0 != (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT & pss->psopt)),
285 pss->payment_secret_set ? &pss->payment_secret_request : NULL, 286 pss->payment_secret_set ? &pss->payment_secret_request : NULL,
286 GNUNET_TIME_UNIT_ZERO, 287 GNUNET_TIME_UNIT_ZERO,