gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: worked on anastasis.c


From: gnunet
Subject: [taler-anastasis] branch master updated: worked on anastasis.c
Date: Wed, 15 Apr 2020 23:12:17 +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 d59ff3f  worked on anastasis.c
d59ff3f is described below

commit d59ff3fd640a22a4b833d44062e7b672406c9664
Author: Dominik Meister <address@hidden>
AuthorDate: Wed Apr 15 23:12:00 2020 +0200

    worked on anastasis.c
---
 src/lib/anastasis.c | 169 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 149 insertions(+), 20 deletions(-)

diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 575ebee..18131cf 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -261,11 +261,12 @@ ANASTASIS_recovery_begin (const json_t *id_data,
                                               &plaintext,
                                               &size_plaintext);
 
+  // FIXME COMPRESSION
 
   recovery_document = json_loadb ((char *) plaintext,size_plaintext,
                                   JSON_DECODE_ANY,&json_error);
 
-  // FIXME CALLBACK AND RECOVERY DOCUMENT BUILD
+  // FIXME CALLBACK
 
 
 
@@ -336,6 +337,10 @@ struct ANASTASIS_Truth
 */
 struct ANASTASIS_TruthUpload
 {
+  /**
+   * Expected HTTP Status
+   */
+  unsigned int http_status;
   /**
    * CURL Context for the Post Request
    */
@@ -374,11 +379,76 @@ static void
 truth_store_callback (void *cls,
                       enum ANASTASIS_ErrorCode ec,
                       unsigned int http_status,
-                      const struct ANASTASIS_UploadDetails *up)
+                      const struct ANASTASIS_UploadDetails *ud)
 {
   struct ANASTASIS_TruthUpload *tu = cls;
   tu->tso = NULL;
-  // FIXME CALLBACK
+
+  // FIXME
+  if (NULL != ud)
+  {
+    switch (ud->us)
+    {
+    case ANASTASIS_US_SUCCESS:
+      break;
+    case ANASTASIS_US_PAYMENT_REQUIRED:
+      {
+        /* FIXME: Payment required handling */
+        const char *m;
+
+        if (0 != strncmp (ud->details.payment_request,
+                          "taler://pay/http",
+                          strlen ("taler://pay/http")))
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Did not find `%s' in `%s'\n",
+                      "/-/-/",
+                      ud->details.payment_request);
+          GNUNET_break (0);
+          return;
+        }
+        m = strstr (ud->details.payment_request, "/-/-/");
+        if (NULL == m)
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Did not find `%s' in `%s'\n",
+                      "/-/-/",
+                      ud->details.payment_request);
+          GNUNET_break (0);
+          /* NOTE: The above is a simplifying assumption for the
+             test-logic, hitting this code merely means that
+             the assumptions for the test (i.e. no instance) are
+             not satisfied, it is not inherently the case that
+             the above token must appear in the payment request!
+
+             So if you hit this, you might just want to modify
+             the code here to handle this better! */return;
+        }
+        tu->paid_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                    "Order ID from Anastasis service is `%s'\n",
+                    tu->paid_order_id);
+      }
+      break;
+    case ANASTASIS_US_CONFLICTING_TRUTH:
+      {
+        GNUNET_break (0);
+        return;
+      }
+    case ANASTASIS_US_HTTP_ERROR:
+      break;
+    case ANASTASIS_US_CLIENT_ERROR:
+      GNUNET_break (0);
+      return;
+    case ANASTASIS_US_SERVER_ERROR:
+      GNUNET_break (0);
+      return;
+    default:
+      GNUNET_break (0);
+      return;
+    }
+  }
+  return;
 }
 
 
@@ -416,8 +486,8 @@ ANASTASIS_truth_upload (const json_t *id_data,
   t = GNUNET_new (struct ANASTASIS_Truth);
   struct ANASTASIS_CRYPTO_EncryptedKeyShare *encrypted_key_share;
   void *encrypted_truth;
-  size_t *encrypted_truth_size;
-
+  size_t encrypted_truth_size;
+  json_t *truth;
   t->url = provider_url;
   t->method = method;
   t->instructions = instructions;
@@ -439,23 +509,23 @@ ANASTASIS_truth_upload (const json_t *id_data,
                                   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);
+                                  &encrypted_truth_size);
+
+  truth = 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,
+                                   truth,
                                    tu->payment_requested,
                                    tu->paid_order_id,
                                    &truth_store_callback,
@@ -569,13 +639,45 @@ ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p)
 */
 struct ANASTASIS_SecretShare
 {
+  /**
+   * Callback which gives back the payment details
+   */
   ANASTASIS_SharePaymentCallback spc;
+  /**
+   * Closure for the payment callback
+   */
   void *spc_cls;
+  /**
+   * Callback which gives back the result of the POST Request
+   */
   ANASTASIS_ShareResultCallback src;
+  /**
+   * Closure for the Result Callback
+   */
   void *src_cls;
-
+  /**
+   * The /policy POST operation handle.
+   */
+  struct ANASTASIS_PolicyStoreOperation *pso;
+  /**
+   * Hash of the current upload.
+   */
+  struct GNUNET_HashCode curr_hash;
 };
 
+
+
+static void
+policy_store_cb (void *cls,
+                 enum ANASTASIS_ErrorCode ec,
+                 unsigned int http_status,
+                 const struct ANASTASIS_UploadDetails *ud)
+{
+  // FIXME
+}
+
+
+
 /**
 * Creates a recovery document with the created policies.
 *
@@ -603,10 +705,37 @@ ANASTASIS_secret_share (const json_t *id_data,
                         size_t core_secret_size)
 {
 
-  // coresecret encrypt
+  struct ANASTASIS_SecretShare *ss;
+  ss = GNUNET_new (struct ANASTASIS_SecretShare);
+  void *encrypted_core_secret;
+  struct ANASTASIS_CRYPTO_EncryptedMasterKey
+    encrypted_master_keys[policies_len];
+  struct ANASTASIS_CRYPTO_PolicyKey policy_keys[policies_len];
+  json_t *recovery_document;
+
+  for (unsigned int i = 0; i < policies_len; i++)
+  {
+    policy_keys[i] = policies[i]->policy_key;
+  }
+
+  ANASTASIS_CRYPTO_core_secret_encrypt ((struct ANASTASIS_CRYPTO_PolicyKey *)
+                                        &policy_keys,
+                                        policies_len,
+                                        core_secret,
+                                        core_secret_size,
+                                        &encrypted_core_secret,
+                                        (struct
+                                         ANASTASIS_CRYPTO_EncryptedMasterKey *)
+                                        &encrypted_master_keys);
+
+
   // build recovery document in json
+  // Compress recovery document
   // policy document encrypt
   // policy upload
+  // Callback handle
+
+  return ss;
 }
 
 /**

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]