[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: json_unpack -> GNUNET_JSON_pars
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: json_unpack -> GNUNET_JSON_parse |
Date: |
Thu, 18 Jun 2020 15:45:43 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new d200765 json_unpack -> GNUNET_JSON_parse
d200765 is described below
commit d2007657b042156eaf829293117fb3064200ef14
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Thu Jun 18 13:45:36 2020 +0000
json_unpack -> GNUNET_JSON_parse
---
src/backend/anastasis-httpd.c | 2 +-
src/include/anastasis.h | 2 +-
src/lib/anastasis.c | 159 ++++++++++++++++++++----------------------
3 files changed, 78 insertions(+), 85 deletions(-)
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 8b91971..d321a15 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -601,7 +601,7 @@ run (void *cls,
TALER_config_get_currency (config,
&AH_currency))
{
- return GNUNET_SYSERR;
+ return;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (config,
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 164f95f..f4f6038 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -59,7 +59,7 @@ struct ANASTASIS_DecryptionPolicy
/**
* length of the methods in this policy
*/
- unsigned int uuids_length;
+ uint32_t uuids_length;
/**
* encrypted masterkey ( encrypted with the policy key)
*/
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 094505a..3ee561c 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -596,18 +596,26 @@ policy_lookup_cb (void *cls,
"Recovery_document after json_loadb %s\n",
json_dumps (recovery_document, JSON_COMPACT));
- const char *enc_core_secret;
- GNUNET_assert (0 ==
- json_unpack ((json_t *) recovery_document,
- "{s:o," /* policies */
- " s:o," /* decryption policies */
- " s:s," /* encrypted core secret */
- " s:I}",/* core secret size */
- "policies", &dec_policies,
- "escrow_methods", &esc_methods,
- "core_secret", &enc_core_secret,
- "core_secret_size", &r->enc_core_secret_size));
-
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_json ("policies",
+ &dec_policies),
+ GNUNET_JSON_spec_json ("escrow_methods",
+ &esc_methods),
+ GNUNET_JSON_spec_varsize ("core_secret",
+ &r->enc_core_secret,
+ &r->enc_core_secret_size),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (recovery_document,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ ANASTASIS_recovery_abort (r);
+ return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decryption Policies after unpack %s\n",
@@ -620,18 +628,13 @@ policy_lookup_cb (void *cls,
r->ri->dps_len = json_array_size (dec_policies);
r->ri->dps = GNUNET_new_array (r->ri->dps_len, struct
ANASTASIS_DecryptionPolicy);
- r->enc_core_secret = GNUNET_malloc (r->enc_core_secret_size);
- GNUNET_STRINGS_string_to_data (enc_core_secret,
- strlen (enc_core_secret),
- r->enc_core_secret,
- r->enc_core_secret_size);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d encrypted core secret is %s-%llu b\n", __FILE__,
__LINE__,
TALER_b2s (r->enc_core_secret,
r->enc_core_secret_size),
(unsigned long long) r->enc_core_secret_size);
-
r->solved_challenges = GNUNET_new_array (r->ri->cs_len,
struct ANASTASIS_Challenge);
@@ -643,36 +646,38 @@ policy_lookup_cb (void *cls,
for (unsigned int i = 0; i < r->ri->cs_len; i++)
{
const char *uuid;
- const char *truth_key;
- const char *truth_salt;
-
cs[i] = GNUNET_new (struct ANASTASIS_Challenge);
- GNUNET_assert (0 ==
- json_unpack (json_array_get (esc_methods, i),
- "{s:s," /* truth uuid */
- " s:s," /* provider url */
- " s:s," /* instructions */
- " s:s," /* truth key */
- " s:s," /* truth salt */
- " s:s}", /* escrow method */
- "uuid", &uuid,
- "url", &cs[i]->url,
- "instructions", &cs[i]->instructions,
- "truth_key", &truth_key,
- "salt", &truth_salt,
- "escrow_method", &cs[i]->escrow_method));
- cs[i]->recovery = r;
+
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("uuid",
+ &uuid),
+ GNUNET_JSON_spec_string ("url",
+ &cs[i]->url),
+ GNUNET_JSON_spec_string ("instructions",
+ &cs[i]->instructions),
+ GNUNET_JSON_spec_fixed_auto ("truth_key",
+ &cs[i]->truth_key),
+ GNUNET_JSON_spec_fixed_auto ("salt",
+ &cs[i]->truth_salt),
+ GNUNET_JSON_spec_string ("escrow_method",
+ &cs[i]->escrow_method),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json_array_get (esc_methods, i),
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ ANASTASIS_recovery_abort (r);
+ return;
+ }
+
GNUNET_assert (0 ==
uuid_parse (uuid,
cs[i]->challenge_uuid));
- GNUNET_STRINGS_string_to_data (truth_key,
- strlen (truth_key),
- &cs[i]->truth_key,
- sizeof(struct ANASTASIS_CRYPTO_TruthKeyP));
- GNUNET_STRINGS_string_to_data (truth_salt,
- strlen (truth_salt),
- &cs[i]->truth_salt,
- sizeof(struct ANASTASIS_CRYPTO_SaltP));
+ cs[i]->recovery = r;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d challenge_uuid is %s-%llu b\n", __FILE__, __LINE__,
@@ -696,39 +701,29 @@ policy_lookup_cb (void *cls,
for (unsigned int j = 0; j < r->ri->dps_len; j++)
{
-
- const char *enc_master_key;
const char *uuids;
- const char *salt;
- GNUNET_assert (0 ==
- json_unpack (json_array_get (dec_policies, j),
- "{s:s," /* encrypted master key */
- " s:s," /* policy uuids */
- " s:s," /* policy salt */
- " s:i}", /* policy uuids length */
- "master_key", &enc_master_key,
- "uuids",&uuids,
- "salt", &salt,
- "uuids_length", &r->ri->dps[j].uuids_length));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d we have key: %s uuids: %s and salt: %s b\n",
__FILE__,
- __LINE__,
- enc_master_key,
- uuids,
- salt);
-
- GNUNET_STRINGS_string_to_data (enc_master_key,
- strlen (enc_master_key),
- &r->ri->dps[j].emk,
- sizeof(struct
-
ANASTASIS_CRYPTO_EncryptedMasterKeyP));
-
- GNUNET_STRINGS_string_to_data (salt,
- strlen (salt),
- &r->ri->dps[j].salt,
- sizeof(struct ANASTASIS_CRYPTO_SaltP));
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("master_key",
+ &r->ri->dps[j].emk),
+ GNUNET_JSON_spec_string ("uuids",
+ &uuids),
+ GNUNET_JSON_spec_fixed_auto ("salt",
+ &r->ri->dps[j].salt),
+ GNUNET_JSON_spec_uint32 ("uuids_length",
+ &r->ri->dps[j].uuids_length),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json_array_get (dec_policies, j),
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ ANASTASIS_recovery_abort (r);
+ return;
+ }
r->ri->dps[j].escrow_uuids = GNUNET_new_array (r->ri->dps[j].uuids_length,
uuid_t);
@@ -1233,7 +1228,7 @@ struct ANASTASIS_Policy
/**
* length of methods used
*/
- unsigned int uuids_length;
+ uint32_t uuids_length;
/**
* array of truths
@@ -1801,7 +1796,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
GNUNET_JSON_from_data_auto (
&policies[k]->salt),
"uuids_length",
- policies[k]->uuids_length)))
+ (int) policies[k]->uuids_length)))
{
GNUNET_break (0);
json_decref (dec_policies);
@@ -1924,15 +1919,13 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
}
recovery_document = json_pack (
- "{s:o," /* policies */
- " s:o," /* decryption policies */
- " s:o," /* encrypted core secret */
- " s:I}",/* core secret size */
+ "{s:o," /* decryption policie */
+ " 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),
- "core_secret_size", (json_int_t) core_secret_size);
+ core_secret_size));
GNUNET_assert (NULL != recovery_document);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"recovery document json before upload: %s\n",
--
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: json_unpack -> GNUNET_JSON_parse,
gnunet <=