[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: finish recovery deserialization
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: finish recovery deserialization logic |
Date: |
Wed, 10 Feb 2021 22:02:23 +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 4f54b13 finish recovery deserialization logic
4f54b13 is described below
commit 4f54b13ef024238a4437162863b72416f2b55e36
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Feb 10 22:02:21 2021 +0100
finish recovery deserialization logic
---
src/lib/anastasis_recovery.c | 91 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 83 insertions(+), 8 deletions(-)
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index 039ed91..94b9798 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -126,11 +126,6 @@ struct DecryptionPolicy
*/
struct ANASTASIS_CRYPTO_SaltP salt;
- /**
- * Array of challenges needed to solve for this decryption policy.
- */
- struct ANASTASIS_Challenge **challenges;
-
};
@@ -353,7 +348,7 @@ keyshare_lookup_cb (void *cls,
for (unsigned int k = 0; k < recovery->solved_challenge_pos; k++)
{
- if (dps->challenges[j] == recovery->solved_challenges[k])
+ if (dps->pub_details.challenges[j] == recovery->solved_challenges[k])
{
found = true;
break;
@@ -383,7 +378,7 @@ keyshare_lookup_cb (void *cls,
for (unsigned int l = 0; l < rdps->pub_details.challenges_length; l++)
for (unsigned int m = 0; m < recovery->solved_challenge_pos; m++)
- if (rdps->challenges[l] == recovery->solved_challenges[m])
+ if (rdps->pub_details.challenges[l] == recovery->solved_challenges[m])
key_shares[l] = recovery->solved_challenges[m]->key_share;
ANASTASIS_CRYPTO_policy_key_derive (key_shares,
rdps->pub_details.challenges_length,
@@ -787,7 +782,7 @@ policy_lookup_cb (void *cls,
&r->cs[i].uuid))
continue;
found = true;
- dp->challenges[n_index] = &r->cs[i];
+ dp->pub_details.challenges[n_index] = &r->cs[i];
break;
}
if (! found)
@@ -1047,11 +1042,90 @@ static int
parse_dps_array (struct ANASTASIS_Recovery *r,
json_t *dps_arr)
{
+ json_t *dps;
+ unsigned int n_index;
+
if (! json_is_array (dps_arr))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
+ r->ri.dps_len = json_array_size (dps_arr);
+ json_array_foreach (dps_arr, n_index, dps)
+ {
+ struct DecryptionPolicy *dp = &r->dps[n_index];
+ json_t *challenges;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("emk",
+ &dp->emk),
+ GNUNET_JSON_spec_fixed_auto ("salt",
+ &dp->salt),
+ GNUNET_JSON_spec_json ("challenges",
+ &challenges),
+ GNUNET_JSON_spec_end ()
+ };
+
+ r->ri.dps[n_index] = &dp->pub_details;
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (dps,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ if (! json_is_array (challenges))
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return GNUNET_SYSERR;
+ }
+ dp->pub_details.challenges_length = json_array_size (challenges);
+ dp->pub_details.challenges = GNUNET_new_array (
+ dp->pub_details.challenges_length,
+ struct ANASTASIS_Challenge *);
+
+ {
+ json_t *challenge;
+ unsigned int c_index;
+ json_array_foreach (challenges, c_index, challenge)
+ {
+ struct ANASTASIS_CRYPTO_TruthUUIDP uuid;
+ struct GNUNET_JSON_Specification ispec[] = {
+ GNUNET_JSON_spec_fixed_auto ("uuid",
+ &uuid),
+ GNUNET_JSON_spec_end ()
+ };
+ bool found = false;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (challenge,
+ ispec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return GNUNET_SYSERR;
+ }
+ for (unsigned int i = 0; i<r->ri.cs_len; i++)
+ {
+ if (0 !=
+ GNUNET_memcmp (&uuid,
+ &r->cs[i].uuid))
+ continue;
+ dp->pub_details.challenges[c_index] = &r->cs[i];
+ found = true;
+ }
+ if (! found)
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return GNUNET_SYSERR;
+ }
+ }
+ }
+ GNUNET_JSON_parse_free (spec);
+ }
return GNUNET_SYSERR;
}
@@ -1129,6 +1203,7 @@ ANASTASIS_recovery_deserialize (struct
GNUNET_CURL_Context *ctx,
ecs_size);
r->enc_core_secret_size = ecs_size;
}
+ GNUNET_JSON_parse_free (spec);
}
if (0 == r->ri.dps_len)
{
--
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: finish recovery deserialization logic,
gnunet <=