[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: short work on anstasis recovery
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: short work on anstasis recovery |
Date: |
Fri, 24 Apr 2020 16:50:43 +0200 |
This is an automated email from the git hooks/post-receive script.
ds-meister pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new e6893e7 short work on anstasis recovery
e6893e7 is described below
commit e6893e7a8c94bce308375ce0e3b5ada57f041320
Author: Dominik Meister <address@hidden>
AuthorDate: Fri Apr 24 16:50:34 2020 +0200
short work on anstasis recovery
---
src/include/anastasis.h | 1 -
src/lib/anastasis.c | 138 ++++++++++++++++++++++++++++++------------------
2 files changed, 87 insertions(+), 52 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 2eaaf38..458c947 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -225,7 +225,6 @@ struct ANASTASIS_Recovery *
ANASTASIS_recovery_begin (const json_t *id_data,
unsigned int version,
const char *anastasis_provider_url,
- unsigned int provider_candidates_length,
ANASTASIS_PolicyCallback pc,
void *pc_cls,
ANASTASIS_CoreSecretCallback csc,
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 22d3cab..aca4e78 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -231,6 +231,22 @@ struct ANASTASIS_Recovery
* size of the ecrypted recovery document
*/
size_t enc_rec_doc_size;
+ /**
+ * expected http status
+ */
+ unsigned int http_status;
+ /**
+ * expected http status
+ */
+ unsigned int response_code;
+ /**
+ * retrieved encrypted core secret from policy
+ */
+ void *enc_core_secret;
+ /**
+ * size of the core secret
+ */
+ size_t enc_core_secret_size;
};
/**
@@ -245,17 +261,30 @@ policy_lookup_cb (void *cls,
unsigned int http_status,
const struct ANASTASIS_DownloadDetails *dd)
{
- // FIXME
struct ANASTASIS_Recovery *r = cls;
+
r->plo = NULL;
- if (MHD_HTTP_OK == http_status)
+ if (http_status != r->http_status)
{
- r->enc_rec_doc_size = dd->policy_size;
- r->encrypted_recovery_document = GNUNET_malloc (
- r->enc_rec_doc_size);
- memcpy (r->encrypted_recovery_document, dd->policy,
- r->enc_rec_doc_size);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u to command %s in %u\n",
+ http_status,
+ __FILE__,
+ __LINE__);
+ GNUNET_break (0);
+ return;
}
+ if (dd->policy == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No recovery data available");
+ GNUNET_break (0);
+ return;
+ }
+ r->enc_rec_doc_size = dd->policy_size;
+ r->encrypted_recovery_document = GNUNET_malloc (r->enc_rec_doc_size);
+ memcpy (r->encrypted_recovery_document, dd->policy, r->enc_rec_doc_size);
+ r->response_code = http_status;
return;
}
@@ -278,7 +307,6 @@ struct ANASTASIS_Recovery *
ANASTASIS_recovery_begin (const json_t *id_data,
unsigned int version,
const char *anastasis_provider_url,
- unsigned int provider_candidates_length,
ANASTASIS_PolicyCallback pc,
void *pc_cls,
ANASTASIS_CoreSecretCallback csc,
@@ -286,13 +314,16 @@ ANASTASIS_recovery_begin (const json_t *id_data,
{
struct ANASTASIS_Recovery *r;
r = GNUNET_new (struct ANASTASIS_Recovery);
- // unsigned int i = 0;
+ struct ANASTASIS_RecoveryInformation *ri;
+ ri = GNUNET_new (struct ANASTASIS_RecoveryInformation);
void *plaintext;
size_t size_plaintext;
json_t *recovery_document;
json_error_t json_error;
+ json_t *dec_policies = json_array ();
+ json_t *esc_methods = json_array ();
struct SaltState *ss = pc_cls;
-
+ r->http_status = MHD_HTTP_OK;
ss->http_status = MHD_HTTP_OK;
ss->so = ANASTASIS_salt (r->ctx,
anastasis_provider_url,
@@ -304,44 +335,26 @@ ANASTASIS_recovery_begin (const json_t *id_data,
salt_cleanup (ss);
ANASTASIS_CRYPTO_account_public_key_derive (&r->id,
&r->pub_key);
- /*
if (version != 0)
{
- while (i < provider_candidates_length || r->encrypted_recovery_document !=
- NULL)
- {
- r->plo = ANASTASIS_policy_lookup_version (r->ctx,
-
anastasis_provider_url_candidates
- [i],
- &r->pub_key,
- &policy_lookup_cb,
- r,
- &version);
- i++;
- }
-
+ r->plo = ANASTASIS_policy_lookup_version (r->ctx,
+ anastasis_provider_url,
+ &r->pub_key,
+ &policy_lookup_cb,
+ r,
+ &version);
}
else
{
- while (i < provider_candidates_length || r->encrypted_recovery_document !=
- NULL)
- {
- r->plo = ANASTASIS_policy_lookup (r->ctx,
- anastasis_provider_url_candidates[i],
- &r->pub_key,
- &policy_lookup_cb,
- r);
- i++;
- }
- }
- */
- if (r->encrypted_recovery_document == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No recovery documents found");
- GNUNET_break (0);
+ r->plo = ANASTASIS_policy_lookup (r->ctx,
+ anastasis_provider_url,
+ &r->pub_key,
+ &policy_lookup_cb,
+ r);
}
+
+
ANASTASIS_CRYPTO_recovery_document_decrypt (&r->id,
r->encrypted_recovery_document,
r->enc_rec_doc_size,
@@ -353,11 +366,25 @@ ANASTASIS_recovery_begin (const json_t *id_data,
recovery_document = json_loadb ((char *) plaintext,size_plaintext,
JSON_DECODE_ANY,&json_error);
- // FIXME CALLBACK
+ GNUNET_assert (0 ==
+ json_unpack (recovery_document,
+ "{s:o," /* policies */
+ " s:i," /* policies length */
+ " s:o," /* decryption policies */
+ " s:i," /* decryption policies length */
+ " s:o," /* encrypted core secret */
+ " s:i}",/* encrypted core secret size */
+ "policies", dec_policies,
+ "policies_length", &ri->dps_len,
+ "escrow_methods", esc_methods,
+ "escrow_methods_length", &ri->ems_len,
+ "core_secret", r->enc_core_secret,
+ "core_secret_size", &r->enc_core_secret_size));
+ // FIXME CALLBACK
return r;
}
@@ -419,6 +446,7 @@ struct ANASTASIS_Truth
*/
struct ANASTASIS_CRYPTO_Salt *salt;
};
+
/**
* Truth Upload struct
*/
@@ -974,6 +1002,7 @@ ANASTASIS_secret_share (const json_t *id_data,
// Recovery document contains the array decryption policies and the array
escrow methods
json_t *recovery_document;
+ size_t recovery_document_size;
// json array
json_t *dec_policies;
// json array
@@ -996,7 +1025,8 @@ ANASTASIS_secret_share (const json_t *id_data,
for (unsigned int k = 0; k < policies_len; k++ )
{
json_t *dec_policy = json_pack ("{s:o," /* encrypted master key */
- " s:o}", /* policy uuids */
+ " s:o," /* policy uuids */
+ " s:i}",/* policy uuids length */
"master_key",
GNUNET_JSON_from_data_auto (
&encrypted_master_keys[k]),
@@ -1004,7 +1034,8 @@ ANASTASIS_secret_share (const json_t *id_data,
GNUNET_JSON_from_data (policies[k]->uuids,
policies[k]->
uuid_length
- * sizeof(uuid_t)));
+ * sizeof(uuid_t)),
+ "uuid_length", &policies[k]->uuid_length);
json_array_append_new (dec_policies, dec_policy);
}
@@ -1033,16 +1064,21 @@ ANASTASIS_secret_share (const json_t *id_data,
}
recovery_document = json_pack (
- "{s:o," /* policies */
- " s:o," /* decryption policies */
- " s:o}", /* encrypted core secret */
+ "{s:o," /* policies */
+ " s:i," /* policies length */
+ " s:o," /* decryption policies */
+ " s:i," /* decryption policies length */
+ " s:o," /* encrypted core secret */
+ " s:i}",/* encrypted core secret size */
"policies", dec_policies,
+ "policies_length", &policies_len,
"escrow_methods", esc_methods,
+ "escrow_methods_length", &truths_len,
"core_secret", GNUNET_JSON_from_data (&encrypted_core_secret,
- core_secret_size));
-
- // FIXME COMPRESSION
+ core_secret_size),
+ "core_secret_size", &core_secret_size);
+ // FIXME COMPRESSION AND SIZE
for (unsigned int l = 0; l < truths_len; l++)
{
@@ -1063,7 +1099,7 @@ ANASTASIS_secret_share (const json_t *id_data,
ANASTASIS_CRYPTO_recovery_document_encrypt (&ss->pss[l]->id,
recovery_document,
- sizeof(recovery_document), //
FIXME
+ sizeof(recovery_document), //
FIXME!!!
&ss->pss[l]->recovery_data,
&ss->pss[l]->recovery_data_size);
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: short work on anstasis recovery,
gnunet <=