[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 06/15: fetch recovery information
From: |
gnunet |
Subject: |
[taler-anastasis] 06/15: fetch recovery information |
Date: |
Sun, 31 Jan 2021 17:06:12 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit e70b0c0e3e5c76f44fd7eb56f50843d2be8a824a
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Jan 18 19:26:21 2021 +0100
fetch recovery information
---
src/include/anastasis.h | 25 ++----------
src/lib/anastasis.c | 93 -------------------------------------------
src/lib/anastasis_api_redux.c | 76 +++++++++++++++++++++++++++++------
3 files changed, 68 insertions(+), 126 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 237d240..b2d9e73 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -53,16 +53,20 @@ struct ANASTASIS_DecryptionPolicy
{
/**
* Set of escrow methods identfied by unique public keys
+ * (FIXME: public keys? nonces?)
*/
struct ANASTASIS_CRYPTO_NonceP *nonces;
+
/**
* length of the methods in this policy
*/
uint32_t nonces_length;
+
/**
* encrypted masterkey ( encrypted with the policy key)
*/
struct ANASTASIS_CRYPTO_EncryptedMasterKeyP emk;
+
/**
* salt used to decrypt master key
*/
@@ -273,27 +277,6 @@ typedef void
struct ANASTASIS_Recovery;
-/**
- * Returns JSON-encoded recovery data.
- *
- * @param r object to return JSON encoding for
- * @return JSON encoding of @a r
- */
-json_t *
-ANASTASIS_recovery_to_json (const struct ANASTASIS_Recovery *r);
-
-
-/**
- * Extracts recovery data from JSON.
- *
- * @param json JSON encoding to decode; recovery returned ONLY valid as long
- * as the JSON remains valid (do not decref until the recovery
- * is truly finished)
- * @return decoded recovery object, NULL on error
- */
-struct ANASTASIS_Recovery *
-ANASTASIS_recovery_from_json (const json_t *json);
-
/**
* Starts the recovery process by opening callbacks for the coresecret and a
policy callback. A list of
* providers is checked for policies and passed back to the client.
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index a780ab1..79e3520 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -280,99 +280,6 @@ struct ANASTASIS_ChallengeAnswerOperation
};
-json_t *
-ANASTASIS_recovery_to_json (const struct ANASTASIS_Recovery *r)
-{
- return json_pack
("{s:o,s:s,s:o,s:s,s:o,s:o,s:o,s:I,s:I,s:o,s:o,s:o,s:I,s:o}",
- "pc",
- GNUNET_JSON_from_data_auto (&r->pc),
- "pc_cls",
- r->pc_cls,
- "csc",
- GNUNET_JSON_from_data_auto (&r->csc),
- "csc_cls",
- r->csc_cls,
- "id",
- GNUNET_JSON_from_data_auto (&r->id),
- "pub_key",
- GNUNET_JSON_from_data_auto (&r->pub_key),
- "encrypted_recovery_document",
- GNUNET_JSON_from_data (r->encrypted_recovery_document,
- r->enc_rec_doc_size),
- "http_status",
- r->http_status,
- "response_code",
- r->response_code,
- "enc_core_secret",
- GNUNET_JSON_from_data (r->enc_core_secret,
- r->enc_core_secret_size),
- "policy_salt",
- GNUNET_JSON_from_data_auto (&r->policy_salt),
- "solved_challenges",
- GNUNET_JSON_from_data_auto (r->solved_challenges),
- "solved_challenge_pos",
- r->solved_challenge_pos,
- "ri",
- GNUNET_JSON_from_data_auto (r->ri));
-}
-
-
-struct ANASTASIS_Recovery *
-ANASTASIS_recovery_from_json (const json_t *json)
-{
- struct ANASTASIS_Recovery *r = GNUNET_new (struct ANASTASIS_Recovery);
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("pc",
- &r->pc),
- // GNUNET_JSON_spec_string ("pc_cls",
- // &r->pc_cls),
- GNUNET_JSON_spec_fixed_auto ("csc",
- &r->csc),
- // GNUNET_JSON_spec_string ("csc_cls",
- // &r->csc_cls),
- GNUNET_JSON_spec_fixed_auto ("id",
- &r->id),
- GNUNET_JSON_spec_fixed_auto ("pub_key",
- &r->pub_key),
- GNUNET_JSON_spec_fixed ("encrypted_recovery_document",
- &r->encrypted_recovery_document,
- r->enc_rec_doc_size),
- GNUNET_JSON_spec_uint32 ("http_status",
- &r->http_status),
- GNUNET_JSON_spec_uint32 ("response_code",
- &r->response_code),
- GNUNET_JSON_spec_fixed ("enc_core_secret",
- &r->enc_core_secret,
- r->enc_core_secret_size),
- GNUNET_JSON_spec_fixed_auto ("policy_salt",
- &r->policy_salt),
- GNUNET_JSON_spec_fixed_auto ("solved_challenges",
- &r->solved_challenges),
- GNUNET_JSON_spec_uint32 ("solved_challenge_pos",
- &r->solved_challenge_pos),
- GNUNET_JSON_spec_fixed_auto ("ri",
- &r->ri),
- GNUNET_JSON_spec_end ()
- };
- const char *err_name;
- unsigned int err_line;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (json,
- spec,
- &err_name,
- &err_line))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse recovery in line %u (%s)\n",
- err_line,
- err_name);
- return NULL;
- }
- return r;
-}
-
-
/**
* Function called with the results of a #ANASTASIS_keyshare_lookup().
*
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index d00a31d..58f2da9 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -947,20 +947,32 @@ policy_lookup_cb (void *cls,
const struct ANASTASIS_RecoveryInformation *ri,
const enum TALER_ErrorCode ec)
{
- json_t *challenge_information;
+ json_t *policies;
+ json_t *challenges;
+ json_t *recovery_information;
struct RecoverSecretState *rss = cls;
- challenge_information = json_object_get (rss->state,
- "challenge_information");
- rss->recovery = NULL;
- if (NULL == challenge_information)
+ recovery_information = json_object_get (rss->state,
+ "recovery_information");
+ if (NULL == recovery_information)
{
- challenge_information = json_array ();
- GNUNET_assert (json_is_array (challenge_information));
+ recovery_information = json_object ();
+ GNUNET_assert (json_is_object (recovery_information));
+ policies = json_array ();
+ GNUNET_assert (json_is_array (policies));
+ challenges = json_array ();
+ GNUNET_assert (json_is_array (challenges));
}
else
{
- GNUNET_assert (json_is_array (challenge_information));
+ GNUNET_assert (
+ json_is_array (
+ json_object_get (recovery_information,
+ "policies")));
+ GNUNET_assert (
+ json_is_array (
+ json_object_get (recovery_information,
+ "challenges")));
return;
}
@@ -994,21 +1006,61 @@ policy_lookup_cb (void *cls,
*ci);
GNUNET_assert (
0 == json_array_append (
- challenge_information,
+ challenges,
ANASTASIS_challenge_information_to_json (ci)));
}
}
- if (0 < json_array_size (challenge_information))
+ for (unsigned int i = 0; i < rss->ri->dps_len; i++)
+ {
+ json_t *policy = json_array ();
+ GNUNET_assert (json_is_array (policy));
+ for (unsigned int j = 0; j < rss->ri->dps[i].nonces_length; j++)
+ {
+ for (unsigned int k = 0; k < rss->challenges_length; k++)
+ {
+ if (0 == memcmp (&rss->ri->dps[i].nonces[j],
+ rss->challenges[k].nonce,
+ sizeof (struct ANASTASIS_CRYPTO_NonceP)))
+ GNUNET_assert (
+ 0 == json_array_append (policy,
+ json_integer ((json_int_t) k)));
+ }
+ }
+ if (0 < json_array_size (policy))
+ GNUNET_assert (
+ 0 == json_array_append_new (policies,
+ policy));
+ }
+ if ((0 < json_array_size (challenges))
+ && (0 < json_array_size (policies)))
{
+ GNUNET_assert (
+ 0 == json_object_set_new (recovery_information,
+ "policies",
+ policies));
+ GNUNET_assert (
+ 0 == json_object_set_new (recovery_information,
+ "challenges",
+ challenges));
GNUNET_assert (
0 == json_object_set_new (rss->state,
- "challenge_information",
- challenge_information));
+ "recovery_information",
+ recovery_information));
rss->cb (NULL,
ANASTASIS_EC_NONE,
rss->state);
rss->cb = NULL;
}
+ else
+ {
+ // FIXME: Error message if operation above failed (policies, challenges
missing)
+ rss->cb (NULL,
+ ANASTASIS_EC_INVALID,
+ rss->state);
+ rss->cb = NULL;
+ }
+
+ rss->recovery = NULL;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis] branch master updated (529012a -> fea0fc4), gnunet, 2021/01/31
- [taler-anastasis] 03/15: visualization, gnunet, 2021/01/31
- [taler-anastasis] 05/15: fix curl fini error, gnunet, 2021/01/31
- [taler-anastasis] 07/15: handle fail of fetching recovery information, gnunet, 2021/01/31
- [taler-anastasis] 04/15: worked on reducer, gnunet, 2021/01/31
- [taler-anastasis] 14/15: import .sql files for testing reducer recovery, gnunet, 2021/01/31
- [taler-anastasis] 09/15: fix key share decryption, gnunet, 2021/01/31
- [taler-anastasis] 13/15: worked on recovery reducer, gnunet, 2021/01/31
- [taler-anastasis] 12/15: worked on recovery reducer, gnunet, 2021/01/31
- [taler-anastasis] 08/15: nonces use json array, gnunet, 2021/01/31
- [taler-anastasis] 06/15: fetch recovery information,
gnunet <=
- [taler-anastasis] 15/15: Merge branch 'master' of ssh://git.taler.net/anastasis, gnunet, 2021/01/31
- [taler-anastasis] 01/15: set state to CHALLENGE_SELECTING, gnunet, 2021/01/31
- [taler-anastasis] 02/15: worked on recovery redux, gnunet, 2021/01/31
- [taler-anastasis] 10/15: fix memory leak, gnunet, 2021/01/31
- [taler-anastasis] 11/15: worked on challenge select, gnunet, 2021/01/31