gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: keyshare lookup


From: gnunet
Subject: [taler-anastasis] branch master updated: keyshare lookup
Date: Thu, 30 Apr 2020 09:41:10 +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 7737a00  keyshare lookup
7737a00 is described below

commit 7737a0048c2840ae6002ccba787b11ec80796ad1
Author: Dominik Meister <address@hidden>
AuthorDate: Thu Apr 30 09:41:03 2020 +0200

    keyshare lookup
---
 src/include/anastasis.h |   6 +--
 src/lib/anastasis.c     | 138 ++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 118 insertions(+), 26 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 1cf362a..2eae470 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -104,7 +104,7 @@ typedef void
  * @param af_cls handle for the challenge answer struct
  */
 void
-ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *challenge,
+ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
                             const void *answer,
                             size_t answer_size,
                             ANASTASIS_AnswerFeedback af,
@@ -341,8 +341,8 @@ ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p);
 */
 typedef void
 (*ANASTASIS_ShareResultCallback)(void *cls,
-                                 const struct GNUNET_HashCode *current_etag,
-                                 enum TALER_ErrorCode ec);
+                                 struct GNUNET_HashCode *current_etag[],
+                                 enum TALER_ErrorCode *ec[]);
 /**
 * Callback for a payment process for uploading a policy
 *
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 3339f24..df62d8c 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -127,10 +127,18 @@ struct ANASTASIS_Challenge
    * Closure for the challenge callback
    */
   void *cc_cls;
+  /**
+   * Callback which gives back the instructions and a status code of the 
request to the user
+   */
+  ANASTASIS_AnswerFeedback af;
+  /**
+   * Closure for the challenge callback
+   */
+  void *af_cls;
   /**
    * Reference to the recovery proccess which is ongoing
    */
-  struct ANASTASIS_Recovery *recovery;
+  struct ANASTASIS_Recovery *r;
   /**
    * url to the escrow provider for this challenge
    */
@@ -159,8 +167,36 @@ struct ANASTASIS_Challenge
    * method of the challenge
    */
   char *escrow_method;
+  /**
+   * keyshare lookup operation
+   */
+  struct ANASTASIS_KeyShareLookupOperation *kslo;
+  /**
+   * Curl context
+   */
+  struct GNUNET_CURL_Context *ctx;
+  /**
+   * Encrypted key share
+   */
+  struct ANASTASIS_CRYPTO_EncryptedKeyShareP enc_key_share;
 };
-
+/**
+ * Function called with the results of a #ANASTASIS_keyshare_lookup().
+ *
+ * @param cls closure
+ * @param http_status HTTP status of the request
+ * @param ud details about the lookup operation
+ */
+static void
+keyshare_lookup_cb (void *cls,
+                    unsigned int http_status,
+                    const struct ANASTASIS_KeyShareDownloadDetails *dd)
+{
+  struct ANASTASIS_Challenge *c = cls;
+  c->kslo = NULL;
+  memcpy (&c->enc_key_share, dd->encrypted_key_share, sizeof(struct
+                                                             
ANASTASIS_CRYPTO_EncryptedKeyShareP));
+}
 /**
  * Challenge answer from the user like input SMS pin. Is referenced to a 
challenge and
  * sends back an AnswerFeedback.
@@ -172,13 +208,36 @@ struct ANASTASIS_Challenge
  * @param af_cls handle for the challenge answer struct
  */
 void
-ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *challenge,
+ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
                             const void *answer,
                             size_t answer_size,
                             ANASTASIS_AnswerFeedback af,
                             void *af_cls)
 {
-
+  c->af = af;
+  c->af_cls = af_cls;
+//  struct ANASTASIS_Recovery *r = c->r;
+  struct GNUNET_HashCode hashed_answer;
+  GNUNET_CRYPTO_hash (answer,
+                      answer_size,
+                      &hashed_answer);
+
+  struct ANASTASIS_CRYPTO_KeyShareP *key_share;
+  c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
+                                       c->url,
+                                       c->challenge_uuid,
+                                       &c->truth_key,
+                                       &hashed_answer,
+                                       &keyshare_lookup_cb,
+                                       c);
+
+//  ANASTASIS_CRYPTO_keyshare_decrypt (&c->enc_key_share,
+//                                     r->id,
+//                                     &key_share);
+
+  // r->key_shares[r->key_share_pos] = key_share;
+//  r->key_share_pos++;
+  return;
 }
 
 /**
@@ -197,6 +256,17 @@ ANASTASIS_challenge_run (struct ANASTASIS_Challenge 
*challenge,
 
 }
 
+void
+ANASTASIS_policy_select (struct ANASTASIS_DecryptionPolicy *dp,
+                         struct ANASTASIS_Recovery *r)
+{
+  // r->dp = dp;
+  struct ANASTASIS_CRYPTO_KeyShareP key_shares[dp->uuids_length];
+//  r->key_shares = key_shares;
+  return;
+}
+
+
 /**
  * User decides which method is to be used, and wants to pay for the 
authentication
  * this is only needed if the cost for the authentication is not zero. Opens a 
Challenge Payment Callback
@@ -275,6 +345,18 @@ struct ANASTASIS_Recovery
    * size of the core secret
    */
   size_t enc_core_secret_size;
+  /**
+   * Selected decryption policy
+   */
+  struct ANASTASIS_DecryptionPolicy *dp;
+  /**
+   * Successfull downloaded keyshares
+   */
+  struct ANASTASIS_CRYPTO_KeyShareP **key_shares;
+  /**
+   * Current keyshare position
+   */
+  unsigned int key_share_pos;
 };
 
 /**
@@ -350,6 +432,7 @@ ANASTASIS_recovery_begin (const json_t *id_data,
   json_error_t json_error;
   json_t *dec_policies = json_array ();
   json_t *esc_methods = json_array ();
+  r->key_share_pos = 0;
   struct SaltState *ss = pc_cls;
   r->http_status = MHD_HTTP_OK;
   ss->http_status = MHD_HTTP_OK;
@@ -424,7 +507,7 @@ ANASTASIS_recovery_begin (const json_t *id_data,
                                 "truth_key",cs[i].truth_key,
                                 "salt",cs[i].truth_salt,
                                 "escrow_method", cs[i].escrow_method));
-    cs[i].recovery = r;
+    cs[i].r = r;
   }
 
   for (unsigned int j = 0; j < ri->dps_len; j++ )
@@ -936,6 +1019,10 @@ struct PolicyStoreState
    * Expected status code.
    */
   unsigned int http_status;
+  /**
+   * Status of the transaction
+   */
+  enum ANASTASIS_ErrorCode ec;
   /**
    * Eddsa Publickey.
    */
@@ -966,16 +1053,6 @@ struct PolicyStoreState
    * Payment identifier.
    */
   struct ANASTASIS_PaymentSecretP payment_id;
-  /**
-   * Previous upload, or NULL for none. Used to calculate what THIS
-   * upload is based on.
-   */
-  const char *prev_upload;
-  /**
-   * Last upload, or NULL for none, usually same as @e prev_upload.
-   * Used to check the response on #MHD_HTTP_CONFLICT.
-   */
-  const char *last_upload;
   /**
    * Payment order ID we got back, if any. Otherwise NULL.
    */
@@ -996,9 +1073,10 @@ policy_store_cb (void *cls,
 {
   struct PolicyStoreState *pss = cls;
   pss->pso = NULL;
+  pss->ec = ec;
   if (http_status != pss->http_status)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Unexpected response code %u/%d in %s:%u\n",
                 http_status,
                 (int) ec,
@@ -1012,12 +1090,9 @@ policy_store_cb (void *cls,
     switch (ud->us)
     {
     case ANASTASIS_US_SUCCESS:
-      if (0 != GNUNET_memcmp (&pss->curr_hash,
-                              ud->details.curr_backup_hash))
-      {
-        GNUNET_break (0);
-        return;
-      }
+      memcpy (&pss->curr_hash,
+              &ud->details.curr_backup_hash,
+              sizeof(struct GNUNET_HashCode));
       break;
     case ANASTASIS_US_PAYMENT_REQUIRED:
       {
@@ -1112,8 +1187,14 @@ ANASTASIS_secret_share (const json_t *id_data,
   struct ANASTASIS_SecretShare *ss;
   ss = GNUNET_new (struct ANASTASIS_SecretShare);
   struct PolicyStoreState pss[truths_len];
+  struct GNUNET_HashCode current_etags[truths_len];
+  enum TALER_ErrorCode ecs[truths_len];
   ss->pss = &pss;
   ss->pss_length = truths_len;
+  ss->spc = spc;
+  ss->spc_cls = spc_cls;
+  ss->src = src;
+  ss->src_cls = src_cls;
   struct ANASTASIS_CRYPTO_EncryptedMasterKeyP
     encrypted_master_keys[policies_len];
   struct ANASTASIS_CRYPTO_PolicyKeyP policy_keys[policies_len];
@@ -1249,8 +1330,19 @@ ANASTASIS_secret_share (const json_t *id_data,
                                               ss->pss[l]->payment_order_id,
                                               &policy_store_cb,
                                               ss->pss[l]);
+
+    current_etags[l] = pss[l].curr_hash;
+    ecs[l] = pss[l].ec;
+  }
+
+  // SETUP SHARE RESULT CALLBACK
+  if (NULL != ss->src)
+  {
+    ss->src (ss->src_cls,
+             current_etags,
+             ecs);
+    ss->src = NULL;
   }
-  // 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]