[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: truthupload and other fixes
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: truthupload and other fixes |
Date: |
Wed, 15 Apr 2020 17:44:40 +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 674888a truthupload and other fixes
674888a is described below
commit 674888a0baac5041594e12ea32a781020bb500cf
Author: Dominik Meister <address@hidden>
AuthorDate: Wed Apr 15 17:44:28 2020 +0200
truthupload and other fixes
---
src/include/anastasis.h | 4 +-
src/lib/anastasis.c | 180 ++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 154 insertions(+), 30 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index cf7e18a..2334a98 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -282,8 +282,8 @@ ANASTASIS_truth_upload (const json_t *id_data,
const char *method,
const char *instructions,
const char *mime_type,
- const void *data,
- size_t data_size,
+ const void *truth_data,
+ size_t truth_data_size,
ANASTASIS_TruthPaymentCallback tpc,
void *tpc_cls,
ANASTASIS_TruthCallback tc,
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 109478f..575ebee 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -27,8 +27,6 @@
-
-
/**
* Challenge struct contains the UUID's needed for the recovery process and a
reference to
* ANASTASIS_Recovery.
@@ -68,11 +66,11 @@ struct ANASTASIS_Challenge
* @param af_cls handle for the challenge answer struct
*/
void
-ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *challenge,
- const void *answer,
- size_t answer_size,
- ANASTASIS_AnswerFeedback af,
- void *af_cls)
+ANASTASIS_challenge_aynswer (struct ANASTASIS_Challenge *challenge,
+ const void *answer,
+ size_t answer_size,
+ ANASTASIS_AnswerFeedback af,
+ void *af_cls)
{
}
@@ -303,7 +301,7 @@ struct ANASTASIS_Truth
/**
* url to the server
*/
- char *url;
+ const char *url;
/**
* identification of the truth
*/
@@ -311,7 +309,15 @@ struct ANASTASIS_Truth
/**
* method used for this truth
*/
- char *method;
+ const char *method;
+ /**
+ * method used for this truth
+ */
+ const char *instructions;
+ /**
+ * mime type of the truth
+ */
+ const char *mime_type;
/**
* keyshare of this truth, used to generate policy keys
*/
@@ -324,19 +330,57 @@ struct ANASTASIS_Truth
* salt used to encrypt the truth
*/
struct ANASTASIS_CRYPTO_Salt *salt;
+};
+/**
+* Truth Upload struct
+*/
+struct ANASTASIS_TruthUpload
+{
+ /**
+ * CURL Context for the Post Request
+ */
+ struct GNUNET_CURL_Context *ctx;
+ /**
+ * User identifier used for the keyshare encryption
+ */
+ struct ANASTASIS_CRYPTO_UserIdentifier id;
+ /**
+ * Callback which tells the user the payment details for the upload
+ */
+ ANASTASIS_TruthPaymentCallback tpc;
+ /**
+ * Closure for the payment callback
+ */
+ void *tpc_cls;
+ /**
+ * Callback which sends back the generated truth object later used to build
the policy
+ */
+ ANASTASIS_TruthCallback tc;
/**
- * challenge for this truth
+ * Closure for the Callback
*/
- void *challenge;
+ void *tc_cls;
/**
- * size of the challenge
+ * Reference to the Truthstore Operation
*/
- size_t challenge_size;
+ struct ANASTASIS_TruthStoreOperation *tso;
+
+ // FIXME not sure how to do payment
+ int payment_requested;
+ const char *paid_order_id;
};
-/**
-* Truth Upload struct
-*/
-struct ANASTASIS_TruthUpload;
+
+static void
+truth_store_callback (void *cls,
+ enum ANASTASIS_ErrorCode ec,
+ unsigned int http_status,
+ const struct ANASTASIS_UploadDetails *up)
+{
+ struct ANASTASIS_TruthUpload *tu = cls;
+ tu->tso = NULL;
+ // FIXME CALLBACK
+}
+
/**
* Uploads a truth object onto a escrow provider
@@ -345,8 +389,8 @@ struct ANASTASIS_TruthUpload;
* @param method defines the method of the challenge (secure question, sms,
email)
* @param instructions depending on method! usually only for security
question/answer!
* @param mime_type format of the challenge
-* @param data contains the keyshare for this truth
-* @param data_size size of the data
+* @param truth_data contains the truth for this challenge i.e. phone number,
email address
+* @param truth_data_size size of the data
* @param tpc opens a truth payment callback to pay the upload
* @param tpc_cls closure for the payment callback
* @param tc opens the truth callback which contains the status of the upload
@@ -358,14 +402,76 @@ ANASTASIS_truth_upload (const json_t *id_data,
const char *method,
const char *instructions,
const char *mime_type,
- const void *data,
- size_t data_size,
+ const void *truth_data,
+ size_t truth_data_size,
ANASTASIS_TruthPaymentCallback tpc,
void *tpc_cls,
ANASTASIS_TruthCallback tc,
void *tc_cls)
{
-
+ // FIXME Challenge
+ struct ANASTASIS_TruthUpload *tu;
+ tu = GNUNET_new (struct ANASTASIS_TruthUpload);
+ struct ANASTASIS_Truth *t;
+ t = GNUNET_new (struct ANASTASIS_Truth);
+ struct ANASTASIS_CRYPTO_EncryptedKeyShare *encrypted_key_share;
+ void *encrypted_truth;
+ size_t *encrypted_truth_size;
+
+ t->url = provider_url;
+ t->method = method;
+ t->instructions = instructions;
+ t->mime_type = mime_type;
+ uuid_generate (t->uuid);
+
+ ANASTASIS_CRYPTO_key_share_create (&t->key_share);
+ ANASTASIS_CRYPTO_user_identifier_derive (id_data, &tu->id);
+
+ ANASTASIS_CRYPTO_key_share_encrypt (&t->key_share,
+ &tu->id,
+ &encrypted_key_share);
+
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
+ &t->truth_key,
+ sizeof (struct ANASTASIS_CRYPTO_TruthKey));
+
+ ANASTASIS_CRYPTO_truth_encrypt (&t->truth_key,
+ truth_data,
+ truth_data_size,
+ &encrypted_truth,
+ encrypted_truth_size);
+
+ truth_data = json_pack ("{s:o," /* encrypted KeyShare */
+ " s:s," /* method */
+ " s:o," /* nonce */
+ " s:s}", /* truth_mime */
+ "keyshare_data", GNUNET_JSON_from_data_auto (
+ encrypted_key_share),
+ "method", method,
+ "encrypted_truth", GNUNET_JSON_from_data (
+ encrypted_truth, *encrypted_truth_size),
+ "truth_mime", mime_type);
+
+ tu->tso = ANASTASIS_truth_store (tu->ctx,
+ t->url,
+ t->uuid,
+ &truth_data,
+ tu->payment_requested,
+ tu->paid_order_id,
+ &truth_store_callback,
+ tu);
+
+ // SETUP TRUTH CALLBACK
+ tu->tc = tc;
+ tu->tc_cls = tc_cls;
+ if (NULL != tu->tc)
+ {
+ tu->tc (tu->tc_cls,
+ t);
+ tu->tc = NULL;
+ }
+ // FIXME PAYMENT CALLBACK
+ return tu;
}
/**
* Cancels a upload process
@@ -374,7 +480,14 @@ ANASTASIS_truth_upload (const json_t *id_data,
void
ANASTASIS_truth_upload_cancel (struct ANASTASIS_TruthUpload *tu)
{
-
+ if (NULL != tu->tso)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "policy lookup aborted");
+ ANASTASIS_truth_store_cancel (tu->tso);
+ tu->tso = NULL;
+ }
+ GNUNET_free (tu);
}
/**
@@ -384,7 +497,7 @@ ANASTASIS_truth_upload_cancel (struct ANASTASIS_TruthUpload
*tu)
void
ANASTASIS_truth_free (struct ANASTASIS_Truth *t)
{
-
+ GNUNET_free (t);
}
/**
@@ -424,15 +537,16 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
p = GNUNET_new (struct ANASTASIS_Policy);
struct ANASTASIS_CRYPTO_PolicyKey policy_key;
struct ANASTASIS_CRYPTO_KeyShare key_shares[truths_len];
+ // FIXME
// p->truths = truths;
- // p->truths_len = truths_len;
+ p->truths_len = truths_len;
for (unsigned int i = 0; i < truths_len; i++)
{
key_shares[i] = truths[i]->key_share;
}
// FIXME SALT
- ANASTASIS_CRYPTO_policy_key_derive (&key_shares,
+ ANASTASIS_CRYPTO_policy_key_derive (key_shares,
truths_len,
&p->salt,
&p->policy_key);
@@ -453,7 +567,14 @@ ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p)
/**
* Defines a recovery document upload process (recovery document consists of
multiple policies)
*/
-struct ANASTASIS_SecretShare;
+struct ANASTASIS_SecretShare
+{
+ ANASTASIS_SharePaymentCallback spc;
+ void *spc_cls;
+ ANASTASIS_ShareResultCallback src;
+ void *src_cls;
+
+};
/**
* Creates a recovery document with the created policies.
@@ -482,7 +603,10 @@ ANASTASIS_secret_share (const json_t *id_data,
size_t core_secret_size)
{
-
+ // coresecret encrypt
+ // build recovery document in json
+ // policy document encrypt
+ // policy upload
}
/**
--
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: truthupload and other fixes,
gnunet <=