gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (4529f7a -> 1f40b7e)


From: gnunet
Subject: [taler-anastasis] branch master updated (4529f7a -> 1f40b7e)
Date: Wed, 13 May 2020 20:56:25 +0200

This is an automated email from the git hooks/post-receive script.

ds-meister pushed a change to branch master
in repository anastasis.

    from 4529f7a  minor edits to business presentation
     new b4cc740  recovery test
     new 1f40b7e  recovery test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/anastasis.h                |   7 +-
 src/lib/anastasis.c                    | 161 ++++++++++++++++++++++++---------
 src/lib/test_anastasis.c               |   9 +-
 src/lib/testing_cmd_challenge_answer.c |   7 +-
 4 files changed, 134 insertions(+), 50 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 4b37bae..5037575 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -63,7 +63,7 @@ struct ANASTASIS_DecryptionPolicy
   /**
    * encrypted masterkey ( encrypted with the policy key)
    */
-  struct ANASTASIS_CRYPTO_EncryptedMasterKeyP *emk;
+  struct ANASTASIS_CRYPTO_EncryptedMasterKeyP emk;
   /**
    * salt used to decrypt master key
    */
@@ -84,6 +84,8 @@ struct ANASTASIS_RecoveryInformation
 
   unsigned int cs_len;
 
+  struct ANASTASIS_CRYPTO_SaltP salt;
+
   unsigned int version;     // actual version obtained
 
 };
@@ -127,7 +129,8 @@ typedef void
  * @param af_cls handle for the challenge answer struct
  */
 void
-ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
+ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
+                            struct ANASTASIS_Challenge *c,
                             const void *answer,
                             size_t answer_size,
                             ANASTASIS_AnswerFeedback af,
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index bd77dfb..7d9a1a6 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -227,15 +227,15 @@ struct ANASTASIS_Challenge
   /**
    * uuid which defines this challenge
    */
-  const uuid_t *challenge_uuid;
+  uuid_t challenge_uuid;
   /**
    * Key used to encrypt the truth passed to the server
    */
-  const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key;
+  struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
   /**
    * Salt used to encrypt the truth
    */
-  const struct ANASTASIS_CRYPTO_SaltP *truth_salt;
+  struct ANASTASIS_CRYPTO_SaltP truth_salt;
   /**
    * plaintext challenge which is sent to the client
    */
@@ -362,7 +362,8 @@ keyshare_lookup_cb (void *cls,
       }
     }
     ANASTASIS_CRYPTO_policy_key_derive (key_shares,
-                                        
c->recovery->ri->dps[success].uuids_length,
+                                        c->recovery->ri->dps[success].
+                                        uuids_length,
                                         &c->recovery->ri->dps[success].salt,
                                         &policy_key);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -370,7 +371,7 @@ keyshare_lookup_cb (void *cls,
                 TALER_B2S (&policy_key),
                 (unsigned long long) sizeof (policy_key));
 
-    ANASTASIS_CRYPTO_core_secret_recover (c->recovery->ri->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,
@@ -392,20 +393,29 @@ keyshare_lookup_cb (void *cls,
  * @param af_cls handle for the challenge answer struct
  */
 void
-ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
+ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
+                            struct ANASTASIS_Challenge *c,
                             const void *answer,
                             size_t answer_size,
                             ANASTASIS_AnswerFeedback af,
                             void *af_cls)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d we are here 2  \n", __FILE__, __LINE__);
+
+
   c->af = af;
+  c->ctx = ctx;
   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,
@@ -565,36 +575,53 @@ policy_lookup_cb (void *cls,
 
   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++)
   {
+    const char *uuid;
+    const char *truth_key;
+    const char *truth_salt;
     GNUNET_assert (0 ==
                    json_unpack (json_array_get (esc_methods, i),
-                                "{s:o,"       /* truth uuid */
+                                "{s:s,"       /* truth uuid */
                                 " s:s,"       /* provider url */
-                                " s:o,"       /* truth key */
-                                " s:o,"       /* truth salt */
+                                " s:s,"       /* truth key */
+                                " s:s,"       /* truth salt */
                                 " s:s}",       /* escrow method */
-                                "uuid", &cs[i].challenge_uuid,
+                                "uuid", &uuid,
                                 "url", &cs[i].url,
-                                "truth_key", &cs[i].truth_key,
-                                "salt", &cs[i].truth_salt,
+                                "truth_key", &truth_key,
+                                "salt", &truth_salt,
                                 "escrow_method", &cs[i].escrow_method));
     cs[i].recovery = r;
+    GNUNET_assert (0 ==
+                   uuid_parse (uuid,
+                               cs[i].challenge_uuid));
+    GNUNET_STRINGS_string_to_data (truth_key,
+                                   strlen (truth_key),
+                                   &cs[i].truth_key,
+                                   sizeof(struct ANASTASIS_CRYPTO_TruthKeyP));
+    GNUNET_STRINGS_string_to_data (truth_salt,
+                                   strlen (truth_salt),
+                                   &cs[i].truth_salt,
+                                   sizeof(struct ANASTASIS_CRYPTO_SaltP));
+
     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));
+                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\n", __FILE__, __LINE__,
                 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));
+                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));
+                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\n", __FILE__, __LINE__,
                 cs[i].escrow_method);
@@ -602,31 +629,71 @@ policy_lookup_cb (void *cls,
 
   for (unsigned int j = 0; j < r->ri->dps_len; j++ )
   {
+
+    const char *enc_master_key;
+    const char *uuids;
+    const char *salt;
     GNUNET_assert (0 ==
                    json_unpack (json_array_get (dec_policies, j),
-                                "{s:o,"         /* encrypted master key */
-                                " s:o,"         /* policy uuids  */
-                                " s:o,"         /* policy salt */
+                                "{s:s,"         /* encrypted master key */
+                                " s:s,"         /* policy uuids  */
+                                " s:s,"         /* policy salt */
                                 " s:i}",        /* policy uuids length */
-                                "master_key",r->ri->dps[j].emk,
-                                "uuids",r->ri->dps[j].escrow_uuids,
-                                "salt", r->ri->dps[j].salt,
-                                "uuids_length", r->ri->dps[j].uuids_length));
+                                "master_key",&enc_master_key,
+                                "uuids",&uuids,
+                                "salt", &salt,
+                                "uuids_length", &r->ri->dps[j].uuids_length));
+
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d we have key: %s uuids: %s and salt: %s b\n", 
__FILE__,
+                __LINE__,
+                enc_master_key,
+                uuids,
+                salt);
+
+    GNUNET_STRINGS_string_to_data (enc_master_key,
+                                   strlen (enc_master_key),
+                                   &r->ri->dps[j].emk,
+                                   sizeof(struct
+                                          
ANASTASIS_CRYPTO_EncryptedMasterKeyP));
+
+    GNUNET_STRINGS_string_to_data (salt,
+                                   strlen (salt),
+                                   &r->ri->dps[j].salt,
+                                   sizeof(struct ANASTASIS_CRYPTO_SaltP));
+
+    r->ri->dps[j].escrow_uuids = GNUNET_new_array (r->ri->dps[j].uuids_length,
+                                                   uuid_t);
+
+    for (int a = 0; a < r->ri->dps[j].uuids_length; a++)
+    {
+      char buf[37];
+      strncpy (buf,uuids + a * 36,36);
+      buf[36] = '\0';
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "At %s:%d buf is %s\n", __FILE__, __LINE__,
+                  &buf);
+      GNUNET_assert (0 ==
+                     uuid_parse (buf,
+                                 r->ri->dps[j].escrow_uuids[a]));
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "At %s:%d escrow uuid is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (&r->ri->dps[j].escrow_uuids[a]),
+                  (unsigned long long) sizeof (r->ri->dps[j].escrow_uuids[a]));
+    }
 
     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));
+
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "At %s:%d policy salt is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (&r->ri->dps[j].salt),
                 (unsigned long long) sizeof (r->ri->dps[j].salt));
-
   }
   r->solved_challenge_pos = 0;
   r->ri->cs = &cs;
@@ -1616,24 +1683,33 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                 "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (policies[k]),
                 (unsigned long long) sizeof (struct ANASTASIS_Policy));
+
+    char uuids[36 * policies[k]->uuids_length + 1];
+    for (unsigned int a = 0; a < policies[k]->uuids_length; a++)
+    {
+      char buf[36];
+      uuid_unparse (policies[k]->uuids[a], buf);
+      strncpy (uuids + a * strlen (buf),buf, strlen (buf));
+    }
+    uuids[36 * policies[k]->uuids_length] = '\0';
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "At %s:%d uuids are %s b\n", __FILE__, __LINE__,
+                uuids);
     if (0 !=
         json_array_append_new (
           dec_policies,
           json_pack ("{s:o,"   /* encrypted master key */
-                     " s:o,"   /* policy uuids  */
+                     " s:s,"   /* policy uuids  */
                      " s:o,"   /* policy salt  */
                      " s:i}",  /* policy uuids length */
                      "master_key",
                      GNUNET_JSON_from_data_auto (
                        &encrypted_master_keys[k]),
                      "uuids",
+                     uuids,
+                     "salt",
                      GNUNET_JSON_from_data_auto (
                        &policies[k]->salt),
-                     "salt",
-                     GNUNET_JSON_from_data (policies[k]->uuids,
-                                            policies[k]->
-                                            uuids_length
-                                            * sizeof(uuid_t)),
                      "uuids_length",
                      policies[k]->uuids_length)))
     {
@@ -1667,10 +1743,12 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                   (unsigned long
                    long) sizeof (policies[k]->truths[l]->truth_key));
 
+      char uuid[37];
+      uuid_unparse (policies[k]->truths[l]->uuid, uuid);
+
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "At %s:%d uuid is %s-%llu b\n", __FILE__, __LINE__,
-                  TALER_B2S (&policies[k]->truths[l]->uuid),
-                  (unsigned long long) sizeof (policies[k]->truths[l]->uuid));
+                  "At %s:%d uuid is %s b\n", __FILE__, __LINE__,
+                  uuid);
 
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
@@ -1681,14 +1759,13 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
       if (0 !=
           json_array_append_new (
             esc_methods,
-            json_pack ("{s:o," /* truth uuid */
+            json_pack ("{s:s," /* truth uuid */
                        " s:s," /* provider url */
                        " s:o," /* truth key */
                        " s:o," /* truth salt */
                        " s:s}", /* escrow method */
                        "uuid",
-                       GNUNET_JSON_from_data_auto (
-                         &policies[k]->truths[l]->uuid),
+                       &uuid,
                        "url",
                        policies[k]->truths[l]->url,
                        "truth_key", GNUNET_JSON_from_data_auto (
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index 0bf89a7..839ee51 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -291,26 +291,25 @@ run (void *cls,
                                           ANASTASIS_TESTING_RSO_NONE,
                                           "salt-request-1",
                                           "secret-share-2"),
-    /**
     ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-1",
                                             MHD_HTTP_OK,
                                             "recover-secret-1",
                                             0,
                                             "HashOfSomeTruth1",
-                                            strlen("HashOfSomeTruth1")),
+                                            strlen ("HashOfSomeTruth1")),
     ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-2",
                                             MHD_HTTP_OK,
                                             "recover-secret-1",
                                             1,
                                             "HashOfSomeTruth2",
-                                            strlen("HashOfSomeTruth2")),
+                                            strlen ("HashOfSomeTruth2")),
     ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-3",
                                             MHD_HTTP_OK,
                                             "recover-secret-1",
                                             2,
                                             "HashOfSomeTruth3",
-                                            strlen("HashOfSomeTruth3")),
-    */
+                                            strlen ("HashOfSomeTruth3")),
+
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/lib/testing_cmd_challenge_answer.c 
b/src/lib/testing_cmd_challenge_answer.c
index 5877c6c..441e500 100644
--- a/src/lib/testing_cmd_challenge_answer.c
+++ b/src/lib/testing_cmd_challenge_answer.c
@@ -114,8 +114,13 @@ challenge_answer_run (void *cls,
       return;
     }
   }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "At %s:%d we are here 1  \n", __FILE__, __LINE__);
+
   // FIXME IS THIS ALLOWED ?
-  ANASTASIS_challenge_answer ((struct ANASTASIS_Challenge *) c,
+  ANASTASIS_challenge_answer (is->ctx,
+                              (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]