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 errors


From: gnunet
Subject: [taler-anastasis] branch master updated: worked on anastasis errors
Date: Tue, 12 May 2020 17:51:24 +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 347228e  worked on anastasis errors
347228e is described below

commit 347228ed5a3a1f002afc66df74d0416be6fa2892
Author: Dominik Meister <address@hidden>
AuthorDate: Tue May 12 17:51:14 2020 +0200

    worked on anastasis errors
---
 src/include/anastasis.h                |   2 +-
 src/lib/anastasis.c                    | 159 ++++++++++++++++++++++++---------
 src/lib/testing_cmd_challenge_answer.c |   4 +-
 3 files changed, 118 insertions(+), 47 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 7824c0a..248466d 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -58,7 +58,7 @@ struct ANASTASIS_RecoveryInformation
 
   unsigned int dps_len;
 
-  const struct ANASTASIS_Challenge **cs;
+  struct ANASTASIS_Challenge **cs;
 
   unsigned int cs_len;
 
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 69a81cc..ed8827d 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -178,14 +178,6 @@ struct ANASTASIS_Recovery
    * size of the core secret
    */
   size_t enc_core_secret_size;
-  /**
-   * Available decryption policies, iterated after each successfull challenge
-   */
-  struct ANASTASIS_DecryptionPolicy *dps;
-  /**
-   * Length of available decryption policies
-   */
-  unsigned int dps_len;
   /**
    * Length of available decryption policies
    */
@@ -198,6 +190,10 @@ struct ANASTASIS_Recovery
    * Length of available decryption policies
    */
   unsigned int solved_challenge_pos;
+  /**
+   * Recovery information which is sent to the user
+   */
+  struct ANASTASIS_RecoveryInformation *ri;
 };
 
 /**
@@ -300,10 +296,14 @@ keyshare_lookup_cb (void *cls,
     return;
   }
 
-
   ANASTASIS_CRYPTO_keyshare_decrypt (dd->encrypted_key_share,
                                      &c->recovery->id,
                                      &c->key_share);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d decrypted keyshare is %s-%llu b\n", __FILE__, __LINE__,
+              TALER_B2S (&c->key_share),
+              (unsigned long long) sizeof (c->key_share));
+
   c->recovery->solved_challenges[c->recovery->solved_challenge_pos] = *c;
   c->recovery->solved_challenge_pos++;
   c->af (c->af_cls,
@@ -318,14 +318,14 @@ keyshare_lookup_cb (void *cls,
    */
   unsigned int success = UINT_MAX;
 
-  for (unsigned int i = 0; i < c->recovery->dps_len; i++)
+  for (unsigned int i = 0; i < c->recovery->ri->dps_len; i++)
   {
-    for (unsigned int j = 0; j < c->recovery->dps[i].uuids_length; j++)
+    for (unsigned int j = 0; j < c->recovery->ri->dps[i].uuids_length; j++)
     {
       missing = true;
       for (unsigned int k = 0; k < c->recovery->solved_challenge_pos; k++)
       {
-        if (0 == uuid_compare (c->recovery->dps[i].escrow_uuids[j],
+        if (0 == uuid_compare (c->recovery->ri->dps[i].escrow_uuids[j],
                                
c->recovery->solved_challenges[k].challenge_uuid))
         {
           missing = false;
@@ -349,13 +349,13 @@ keyshare_lookup_cb (void *cls,
     void *core_secret;
     size_t core_secret_size;
     struct ANASTASIS_CRYPTO_KeyShareP
-      key_shares[c->recovery->dps[success].uuids_length];
+      key_shares[c->recovery->ri->dps[success].uuids_length];
     struct ANASTASIS_CRYPTO_PolicyKeyP policy_key;
-    for (unsigned int l = 0; l < c->recovery->dps[success].uuids_length; l++)
+    for (unsigned int l = 0; l < c->recovery->ri->dps[success].uuids_length; 
l++)
     {
       for (unsigned int m = 0; m < c->recovery->solved_challenge_pos; m++)
       {
-        if (0 == uuid_compare (c->recovery->dps[l].escrow_uuids[m],
+        if (0 == uuid_compare (c->recovery->ri->dps[l].escrow_uuids[m],
                                
c->recovery->solved_challenges[m].challenge_uuid))
         {
           key_shares[l] = *c->recovery->solved_challenges[m].key_share;
@@ -363,11 +363,15 @@ keyshare_lookup_cb (void *cls,
       }
     }
     ANASTASIS_CRYPTO_policy_key_derive (key_shares,
-                                        c->recovery->dps[success].uuids_length,
+                                        
c->recovery->ri->dps[success].uuids_length,
                                         &c->recovery->policy_salt,
                                         &policy_key);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d the policy key is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&policy_key),
+                (unsigned long long) sizeof (policy_key));
 
-    ANASTASIS_CRYPTO_core_secret_recover (c->recovery->dps[success].emk,
+    ANASTASIS_CRYPTO_core_secret_recover (c->recovery->ri->dps[success].emk,
                                           policy_key,
                                           c->recovery->enc_core_secret,
                                           c->recovery->enc_core_secret_size,
@@ -397,11 +401,20 @@ ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
 {
   c->af = af;
   c->af_cls = af_cls;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d challenge %s-%llu is solved with url %s \n", __FILE__, 
__LINE__,
+              TALER_B2S (&c->challenge_uuid),
+              (unsigned long long) sizeof (c->challenge_uuid),
+              c->url);
   struct GNUNET_HashCode hashed_answer;
   GNUNET_CRYPTO_hash (answer,
                       answer_size,
                       &hashed_answer);
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d challenge is answered with %s \n", __FILE__, __LINE__,
+              TALER_b2s (&hashed_answer, sizeof(struct GNUNET_HashCode)));
+
   c->http_status = MHD_HTTP_OK;
   c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
                                        c->url,
@@ -469,8 +482,8 @@ policy_lookup_cb (void *cls,
                   const struct ANASTASIS_DownloadDetails *dd)
 {
   struct ANASTASIS_Recovery *r = cls;
-  struct ANASTASIS_RecoveryInformation *ri;
-  ri = GNUNET_new (struct ANASTASIS_RecoveryInformation);
+  r->response_code = http_status;
+  r->ri = GNUNET_new (struct ANASTASIS_RecoveryInformation);
   r->plo = NULL;
 
   if (http_status != r->http_status)
@@ -482,9 +495,10 @@ policy_lookup_cb (void *cls,
                 __LINE__);
 
     r->pc (r->pc_cls,
-           ri,
+           r->ri,
            r->http_status);
     r->pc = NULL;
+    ANASTASIS_recovery_abort(r);
     return;
   }
   if (dd->policy == NULL)
@@ -492,9 +506,10 @@ policy_lookup_cb (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "No recovery data available");
     r->pc (r->pc_cls,
-           ri,
+           r->ri,
            r->http_status);
     r->pc = NULL;
+    ANASTASIS_recovery_abort(r);
     return;
   }
   void *plaintext;
@@ -503,17 +518,27 @@ policy_lookup_cb (void *cls,
   json_error_t json_error;
   json_t *dec_policies = json_array ();
   json_t *esc_methods = json_array ();
-  r->response_code = http_status;
 
   ANASTASIS_CRYPTO_recovery_document_decrypt (&r->id,
                                               dd->policy,
                                               dd->policy_size,
                                               &plaintext,
                                               &size_plaintext);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d rec doc after enc is %s \n", __FILE__, __LINE__,
+              TALER_b2s (plaintext, size_plaintext));
   // FIXME COMPRESSION
 
-  recovery_document = json_loadb ((char *) plaintext,size_plaintext,
-                                  JSON_DECODE_ANY,&json_error);
+  recovery_document = json_loadb ((char *) plaintext,
+                                 size_plaintext,
+                                 JSON_DECODE_ANY,
+                                 &json_error);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Recovery_document after json_loadb  %s\n",
+              json_dumps (recovery_document, JSON_COMPACT));
+
+
   GNUNET_assert (0 ==
                  json_unpack (recovery_document,
                               "{s:o,"   /* policies */
@@ -523,14 +548,23 @@ policy_lookup_cb (void *cls,
                               "escrow_methods", esc_methods,
                               "core_secret", r->enc_core_secret));
 
-  ri->cs_len = json_array_size (esc_methods);
-  ri->dps_len = json_array_size (dec_policies);
-  r->dps = GNUNET_new_array (ri->dps_len, struct ANASTASIS_DecryptionPolicy);
-  r->solved_challenges = GNUNET_new_array (ri->cs_len, struct
-                                           ANASTASIS_Challenge);
-  struct ANASTASIS_Challenge *cs[ri->cs_len];
 
-  for (unsigned int i = 0; i < ri->cs_len; i++)
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Decryption Policies after unpack  %s\n",
+              json_dumps (dec_policies, JSON_COMPACT));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Escrow Methods after unpack  %s\n",
+              json_dumps (esc_methods, JSON_COMPACT));
+
+  r->ri->cs_len = json_array_size (esc_methods);
+  r->ri->dps_len = json_array_size (dec_policies);
+  r->ri->dps = GNUNET_new_array (r->ri->dps_len, struct 
ANASTASIS_DecryptionPolicy);
+  r->solved_challenges = GNUNET_new_array (r->ri->cs_len,
+                                           struct ANASTASIS_Challenge);
+
+  struct ANASTASIS_Challenge *cs = GNUNET_new_array(r->ri->cs_len,
+                                                    struct 
ANASTASIS_Challenge);
+  for (unsigned int i = 0; i < r->ri->cs_len; i++)
   {
     GNUNET_assert (0 ==
                    json_unpack (json_array_get (esc_methods, i),
@@ -539,33 +573,61 @@ policy_lookup_cb (void *cls,
                                 " s:o,"       /* truth key */
                                 " s:o,"       /* truth salt */
                                 " s:s}",       /* escrow method */
-                                "uuid", cs[i]->challenge_uuid,
-                                "url", cs[i]->url,
-                                "truth_key",cs[i]->truth_key,
-                                "salt",cs[i]->truth_salt,
-                                "escrow_method", cs[i]->escrow_method));
-    cs[i]->recovery = r;
+                                "uuid", cs[i].challenge_uuid,
+                                "url", cs[i].url,
+                                "truth_key", cs[i].truth_key,
+                                "salt", cs[i].truth_salt,
+                                "escrow_method", cs[i].escrow_method));
+    cs[i].recovery = r;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d challenge_uuid is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&cs[i].challenge_uuid),
+                (unsigned long long) sizeof (cs[i].challenge_uuid));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d url is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&cs[i].url),
+                (unsigned long long) sizeof (cs[i].url));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d truth key is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&cs[i].truth_key),
+                (unsigned long long) sizeof (cs[i].truth_key));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d truth_salt is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&cs[i].truth_salt),
+                (unsigned long long) sizeof (cs[i].truth_salt));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d escrow method is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&cs[i].truth_salt),
+                (unsigned long long) sizeof (cs[i].truth_salt));
   }
 
-  for (unsigned int j = 0; j < ri->dps_len; j++ )
+  for (unsigned int j = 0; j < r->ri->dps_len; j++ )
   {
     GNUNET_assert (0 ==
                    json_unpack (json_array_get (dec_policies, j),
                                 "{s:o,"         /* encrypted master key */
                                 " s:o,"         /* policy uuids  */
                                 " s:i}",        /* policy uuids length */
-                                "master_key",r->dps[j].emk,
-                                "uuids",r->dps[j].escrow_uuids,
-                                "uuids_length", r->dps[j].uuids_length));
+                                "master_key",r->ri->dps[j].emk,
+                                "uuids",r->ri->dps[j].escrow_uuids,
+                                "uuids_length", r->ri->dps[j].uuids_length));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d encrypted master key is %s-%llu b\n", __FILE__, 
__LINE__,
+                TALER_B2S (&r->ri->dps[j].emk),
+                (unsigned long long) sizeof (r->ri->dps[j].emk));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d escrow uuids are %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&r->ri->dps[j].escrow_uuids),
+                (unsigned long long) sizeof (r->ri->dps[j].escrow_uuids));
   }
   r->solved_challenge_pos = 0;
+  r->ri->cs = &cs;
   // SETUP POLICY CALLBACK
-  ri->dps = r->dps;
-  ri->cs = cs;
   if (NULL != r->pc)
   {
     r->pc (r->pc_cls,
-           ri,
+           r->ri,
            r->http_status);
     r->pc = NULL;
   }
@@ -610,8 +672,17 @@ ANASTASIS_recovery_begin (struct GNUNET_CURL_Context *ctx,
   ANASTASIS_CRYPTO_user_identifier_derive (id_data,
                                            salt,
                                            &r->id);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d user_identfier is %s-%llu b\n", __FILE__, __LINE__,
+              TALER_B2S (&r->id),
+              (unsigned long long) sizeof (r->id));
   ANASTASIS_CRYPTO_account_public_key_derive (&r->id,
                                               &r->pub_key);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d public key is %s-%llu b\n", __FILE__, __LINE__,
+              TALER_B2S (&r->pub_key),
+              (unsigned long long) sizeof (r->pub_key));
+
   if (version != 0)
   {
     r->plo = ANASTASIS_policy_lookup_version (r->ctx,
diff --git a/src/lib/testing_cmd_challenge_answer.c 
b/src/lib/testing_cmd_challenge_answer.c
index 97f8310..a2a863b 100644
--- a/src/lib/testing_cmd_challenge_answer.c
+++ b/src/lib/testing_cmd_challenge_answer.c
@@ -114,8 +114,8 @@ challenge_answer_run (void *cls,
       return;
     }
   }
-
-  ANASTASIS_challenge_answer (c,
+  //FIXME IS THIS ALLOWED ?
+  ANASTASIS_challenge_answer ((struct ANASTASIS_Challenge *)c,
                               cs->answer,
                               cs->answer_size,
                               &challenge_answer_cb,

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



reply via email to

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