[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: worked on client api
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: worked on client api |
Date: |
Wed, 08 Apr 2020 23:52:35 +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 f435cc3 worked on client api
f435cc3 is described below
commit f435cc3316a767c61058a3f23e90328c3b5a2acd
Author: Dominik Meister <address@hidden>
AuthorDate: Wed Apr 8 23:52:14 2020 +0200
worked on client api
---
src/include/anastasis.h | 8 +-
src/include/anastasis_crypto_lib.h | 2 +-
src/lib/anastasis.c | 187 +++++++++++++++++++++++++++++--------
3 files changed, 154 insertions(+), 43 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 9e05965..ba8af3a 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -82,7 +82,7 @@ typedef void
struct ANASTASIS_Challenge;
/**
- * The answer feedback defines the callback for an esrow challenge e.g. (wrong
SMS Pin)
+ * The answer feedback defines the callback for an escrow challenge e.g.
(wrong SMS Pin)
*
* @param af_cls handle for the callback
* @param ec enum with the different possible states like wrong pin, success
@@ -126,7 +126,7 @@ struct ANASTASIS_ChallengeInformation
/**
* Defines a Challenge Callback which is initially sent with the challenge
run. It gives back the previously
- * defined Challenge Information and a Status Code, cloud be payment missing.
+ * defined Challenge Information and a Status Code, like "payment missing".
*
* @param cls handle for the callback
* @param ci reference to the challenge information struct
@@ -194,7 +194,7 @@ typedef void
/**
* stores provider URIs, identity key material, decrypted recovery document
(internally!)
*/
-struct ANASTASIS_Recovery; //
+struct ANASTASIS_Recovery;
/**
* Starts the recovery process by opening callbacks for the coresecret and a
policy callback. A list of
@@ -309,7 +309,7 @@ ANASTASIS_truth_free (struct ANASTASIS_Truth *t);
struct ANASTASIS_Policy;
/**
-* Creates a policy with a set of trutht's
+* Creates a policy with a set of truth's
* Creates the policy key with the different key shares from the truths and
encrypts the escrow master key.
* @param truths array of truths which are stored on different providers
* @param truths_len amount of truths in this policy
diff --git a/src/include/anastasis_crypto_lib.h
b/src/include/anastasis_crypto_lib.h
index 6d9f7d3..25642df 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -14,7 +14,7 @@
Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
*/
/**
- * @file lib/anastasis_crypto.c
+ * @file lib/anastasis_cryto_lib.h
* @brief anastasis crypto api
* @author Christian Grothoff
* @author Dominik Meister
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 2a3fd55..b9988d4 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -33,7 +33,24 @@
* Challenge struct contains the UUID's needed for the recovery process and a
reference to
* ANASTASIS_Recovery.
*/
-struct ANASTASIS_Challenge;
+struct ANASTASIS_Challenge
+{
+ /**
+ * Callback which gives back the instructions and a status code of the
request to the user
+ */
+ ANASTASIS_ChallengeCallback cc;
+ /**
+ * Closure for the challenge callback
+ */
+ void *cc_cls;
+ /**
+ * Reference to the recovery proccess which is ongoing
+ */
+ struct ANASTASIS_Recovery *recovery;
+
+
+
+};
/**
* Challenge answer from the user like input SMS pin. Is referenced to a
challenge and
@@ -89,9 +106,78 @@ ANASTASIS_challenge_select_to_pay (struct
ANASTASIS_Challenge *challenge,
}
/**
- * stores provider URIs, identity key material, decrypted recovery document
(internally!)
+ * stores provider URLs, identity key material, decrypted recovery document
(internally!)
*/
-struct ANASTASIS_Recovery;
+struct ANASTASIS_Recovery
+{
+ /**
+ * Callback to send back a recovery document with the policies and the
version
+ */
+ ANASTASIS_PolicyCallback pc;
+ /**
+ * closure for the Policy callback
+ */
+ void *pc_cls;
+ /**
+ * Callback to send back the core secret which was saved by anastasis, after
all challenges are completed
+ */
+ ANASTASIS_CoreSecretCallback csc;
+ /**
+ * Closure for the core secret callback
+ */
+ void *csc_cls;
+ /**
+ * Identity key material used for the derivation of keys
+ */
+ struct ANASTASIS_CRYPTO_UserIdentifier id;
+ /**
+ * Public key for a request
+ */
+ struct ANASTASIS_CRYPTO_AccountPublicKey pub_key;
+ /**
+ * Curl context
+ */
+ struct GNUNET_CURL_Context *ctx;
+ /**
+ * Reference to the policy lookup operation which is executed
+ */
+ struct ANASTASIS_PolicyLookupOperation *plo;
+ /**
+ * encrypted recovery document, only used for the decription
+ */
+ void *encrypted_recovery_document;
+ /**
+ * size of the ecrypted recovery document
+ */
+ size_t enc_rec_doc_size;
+};
+
+/**
+ * Function called with the results of a ANASTASIS_policy_lookup
+ *
+ * @param cls closure
+ * @param http_status HTTP status of the request
+ * @param ud details about the lookup operation
+ */
+static void
+policy_lookup_cb (void *cls,
+ unsigned int http_status,
+ const struct ANASTASIS_DownloadDetails *dd)
+{
+ struct ANASTASIS_Recovery *recovery = cls;
+ recovery->plo = NULL;
+ if (MHD_HTTP_OK == http_status)
+ {
+ recovery->enc_rec_doc_size = dd->policy_size;
+ recovery->encrypted_recovery_document = GNUNET_malloc (
+ recovery->enc_rec_doc_size);
+ memcpy (recovery->encrypted_recovery_document, dd->policy,
+ recovery->enc_rec_doc_size);
+ }
+ return;
+}
+
+
/**
* Starts the recovery process by opening callbacks for the coresecret and a
policy callback. A list of
@@ -116,47 +202,65 @@ ANASTASIS_recovery_begin (const json_t *id_data,
ANASTASIS_CoreSecretCallback csc,
void *csc_cls)
{
- // Derivation of user input into the account public key and user identifier
for the encryption
- struct ANASTASIS_CRYPTO_UserIdentifier id;
- struct ANASTASIS_CRYPTO_AccountPublicKey pub_key;
- // Callbacks and context for lookup function
- ANASTASIS_PolicyLookupCallback plc;
- struct GNUNET_CURL_Context *ctx;
- // iterator used to process the url's
+ struct ANASTASIS_Recovery *recovery;
+ recovery = GNUNET_new (struct ANASTASIS_Recovery);
unsigned int i = 0;
- void *plc_cls;
-
- ANASTASIS_CRYPTO_user_identifier_derive (id_data, &id);
- ANASTASIS_CRYPTO_account_public_key_derive (&id, &pub_key);
+ void *plaintext;
+ size_t size_plaintext;
+ // needs to be inside while and take a salt
+ ANASTASIS_CRYPTO_user_identifier_derive (id_data, &recovery->id);
+ ANASTASIS_CRYPTO_account_public_key_derive (&recovery->id,
+ &recovery->pub_key);
+
+ if (version != 0)
+ {
+ while (i < provider_candidates_length ||
+ recovery->encrypted_recovery_document != NULL)
+ {
+ recovery->plo = ANASTASIS_policy_lookup_version (recovery->ctx,
+
anastasis_provider_url_candidates
+ [i],
+ &recovery->pub_key,
+ &policy_lookup_cb,
+ recovery,
+ &version);
+ i++;
+ }
-/*
- if (version == 0)
+ }
+ else
{
- while (pc.http_status != 200 || i < provider_candidates_length)
- {
- ANASTASIS_policy_lookup(ctx,
- anastasis_provider_url_candidates[i],
- &pub_key,
- plc,
- plc_cls);
- i++;
- }
- }else
+ while (i < provider_candidates_length ||
+ recovery->encrypted_recovery_document != NULL)
+ {
+ recovery->plo = ANASTASIS_policy_lookup (recovery->ctx,
+
anastasis_provider_url_candidates
+ [i],
+ &recovery->pub_key,
+ &policy_lookup_cb,
+ recovery);
+ i++;
+ }
+ }
+
+ if (recovery->encrypted_recovery_document == NULL)
{
- while (pc.http_status != 200 || i < provider_candidates_length)
- {
- ANASTASIS_policy_lookup_version(ctx,
- anastasis_provider_url_candidates[i],
- &pub_key,
- plc,
- plc_cls,
- &version);
- i++;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No recovery documents found");
+ GNUNET_break (0);
}
-*/
+ ANASTASIS_CRYPTO_recovery_document_decrypt (&recovery->id,
+ recovery->
+ encrypted_recovery_document,
+ recovery->enc_rec_doc_size,
+ &plaintext,
+ &size_plaintext);
+ // FIXME CALLBACK AND BUILD OF REC DOC ?
+
+ return recovery;
}
+
/**
* Cancels the recovery process
* @param r handle to the recovery struct
@@ -164,7 +268,14 @@ ANASTASIS_recovery_begin (const json_t *id_data,
void
ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r)
{
-
+ if (NULL != r->plo)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "policy lookup aborted");
+ ANASTASIS_policy_lookup_cancel (r->plo);
+ r->plo = NULL;
+ }
+ GNUNET_free (r);
}
--
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: worked on client api,
gnunet <=