aboutsummaryrefslogtreecommitdiff
path: root/src/lib/anastasis_backup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/anastasis_backup.c')
-rw-r--r--src/lib/anastasis_backup.c140
1 files changed, 61 insertions, 79 deletions
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index ea55e6a..d97bdae 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -134,29 +134,28 @@ ANASTASIS_truth_from_json (const json_t *json)
134json_t * 134json_t *
135ANASTASIS_truth_to_json (const struct ANASTASIS_Truth *t) 135ANASTASIS_truth_to_json (const struct ANASTASIS_Truth *t)
136{ 136{
137 return json_pack ( 137 return GNUNET_JSON_PACK (
138 "{s:o,s:o,s:o,s:o,s:o" 138 GNUNET_JSON_pack_data_auto ("uuid",
139 ",s:o,s:s,s:s,s:s,s:s?}", 139 &t->uuid),
140 "uuid", 140 GNUNET_JSON_pack_data_auto ("key_share",
141 GNUNET_JSON_from_data_auto (&t->uuid), 141 &t->key_share),
142 "key_share", 142 GNUNET_JSON_pack_data_auto ("truth_key",
143 GNUNET_JSON_from_data_auto (&t->key_share), 143 &t->truth_key),
144 "truth_key", 144 GNUNET_JSON_pack_data_auto ("salt",
145 GNUNET_JSON_from_data_auto (&t->truth_key), 145 &t->salt),
146 "salt", 146 GNUNET_JSON_pack_data_auto ("nonce",
147 GNUNET_JSON_from_data_auto (&t->salt), 147 &t->nonce),
148 "nonce", 148 GNUNET_JSON_pack_data_auto ("provider_salt",
149 GNUNET_JSON_from_data_auto (&t->nonce), 149 &t->provider_salt),
150 "provider_salt", 150 GNUNET_JSON_pack_string ("url",
151 GNUNET_JSON_from_data_auto (&t->provider_salt), 151 t->url),
152 "url", 152 GNUNET_JSON_pack_string ("type",
153 t->url, 153 t->type),
154 "type", 154 GNUNET_JSON_pack_string ("instructions",
155 t->type, 155 t->instructions),
156 "instructions", 156 GNUNET_JSON_pack_allow_null (
157 t->instructions, 157 GNUNET_JSON_pack_string ("mime_type",
158 "mime_type", 158 t->mime_type)));
159 t->mime_type);
160} 159}
161 160
162 161
@@ -778,23 +777,16 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
778 uuids, 777 uuids,
779 GNUNET_JSON_from_data_auto ( 778 GNUNET_JSON_from_data_auto (
780 &policy->truths[b]->uuid))); 779 &policy->truths[b]->uuid)));
781 if (0 != 780 GNUNET_assert (0 ==
782 json_array_append_new ( 781 json_array_append_new (
783 dec_policies, 782 dec_policies,
784 json_pack ("{s:o, s:o, s:o}", 783 GNUNET_JSON_PACK (
785 "master_key", 784 GNUNET_JSON_pack_data_auto ("master_key",
786 GNUNET_JSON_from_data_auto ( 785 &encrypted_master_keys[k]),
787 &encrypted_master_keys[k]), 786 GNUNET_JSON_pack_array_steal ("uuids",
788 "uuids", 787 uuids),
789 uuids, 788 GNUNET_JSON_pack_data_auto ("salt",
790 "salt", 789 &policy->salt))));
791 GNUNET_JSON_from_data_auto (&policy->salt))))
792 {
793 GNUNET_break (0);
794 json_decref (dec_policies);
795 ANASTASIS_secret_share_cancel (ss);
796 return NULL;
797 }
798 } 790 }
799 791
800 esc_methods = json_array (); 792 esc_methods = json_array ();
@@ -825,38 +817,24 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
825 if (! unique) 817 if (! unique)
826 continue; 818 continue;
827 819
828 if (0 != 820 GNUNET_assert (0 ==
829 json_array_append_new ( 821 json_array_append_new (
830 esc_methods, 822 esc_methods,
831 json_pack ("{s:o," /* truth uuid */ 823 GNUNET_JSON_PACK (
832 " s:s," /* provider url */ 824 GNUNET_JSON_pack_data_auto ("uuid",
833 " s:s," /* instructions */ 825 &pt->uuid),
834 " s:o," /* truth key */ 826 GNUNET_JSON_pack_string ("url",
835 " s:o," /* truth salt */ 827 pt->url),
836 " s:o," /* provider salt */ 828 GNUNET_JSON_pack_string ("instructions",
837 " s:s}", /* escrow method */ 829 pt->instructions),
838 "uuid", 830 GNUNET_JSON_pack_data_auto ("truth_key",
839 GNUNET_JSON_from_data_auto ( 831 &pt->truth_key),
840 &pt->uuid), 832 GNUNET_JSON_pack_data_auto ("salt",
841 "url", 833 &pt->salt),
842 pt->url, 834 GNUNET_JSON_pack_data_auto ("provider_salt",
843 "instructions", 835 &pt->provider_salt),
844 pt->instructions, 836 GNUNET_JSON_pack_string ("escrow_type",
845 "truth_key", GNUNET_JSON_from_data_auto ( 837 pt->type))));
846 &pt->truth_key),
847 "salt", GNUNET_JSON_from_data_auto (
848 &pt->salt),
849 "provider_salt", GNUNET_JSON_from_data_auto (
850 &pt->provider_salt),
851 "escrow_type",
852 pt->type)))
853 {
854 GNUNET_break (0);
855 json_decref (esc_methods);
856 json_decref (dec_policies);
857 ANASTASIS_secret_share_cancel (ss);
858 return NULL;
859 }
860 } 838 }
861 } 839 }
862 840
@@ -869,13 +847,17 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
869 int ret; 847 int ret;
870 uint32_t be_size; 848 uint32_t be_size;
871 849
872 recovery_document = json_pack ( 850 recovery_document = GNUNET_JSON_PACK (
873 "{s:s?, s:o, s:o, s:o}", 851 GNUNET_JSON_pack_allow_null (
874 "secret_name", secret_name, 852 GNUNET_JSON_pack_string ("secret_name",
875 "policies", dec_policies, 853 secret_name)),
876 "escrow_methods", esc_methods, 854 GNUNET_JSON_pack_array_steal ("policies",
877 "encrypted_core_secret", GNUNET_JSON_from_data (encrypted_core_secret, 855 dec_policies),
878 core_secret_size)); 856 GNUNET_JSON_pack_array_steal ("escrow_methods",
857 esc_methods),
858 GNUNET_JSON_pack_data_varsize ("encrypted_core_secret",
859 encrypted_core_secret,
860 core_secret_size));
879 GNUNET_assert (NULL != recovery_document); 861 GNUNET_assert (NULL != recovery_document);
880 GNUNET_free (encrypted_core_secret); 862 GNUNET_free (encrypted_core_secret);
881 863