gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (2a0f180 -> b759cff)


From: gnunet
Subject: [taler-anastasis] branch master updated (2a0f180 -> b759cff)
Date: Thu, 07 May 2020 19:10:05 +0200

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

dennis-neufeld pushed a change to branch master
in repository anastasis.

    from 2a0f180  Merge branch 'master' of ssh://git.taler.net/anastasis
     new c9cfd8b  fix truths in policy struct
     new 8ece31b  fix uuids in policy struct
     new b759cff  core secret trait

The 3 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_testing_lib.h                | 26 ++++++++++++++
 src/lib/Makefile.am                                |  1 +
 src/lib/anastasis.c                                | 34 ++++++++++--------
 src/lib/test_anastasis.c                           | 12 +++----
 src/lib/testing_cmd_secret_share.c                 |  3 +-
 ...pi_trait_uuid.c => testing_trait_core_secret.c} | 42 +++++++++++-----------
 6 files changed, 76 insertions(+), 42 deletions(-)
 copy src/lib/{testing_api_trait_uuid.c => testing_trait_core_secret.c} (53%)

diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index d91e662..acc4d05 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -567,6 +567,32 @@ ANASTASIS_TESTING_cmd_policy_create (const char *label,
 
 /* ********************* test secret share ********************* */
 
+/**
+ * Obtain the core secret from @a cmd.
+ *
+ * @param cmd command to extract the core secret from.
+ * @param index the index of the core secret (usually 0)
+ * @param s[out] set to the core secret coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_core_secret (const struct
+                                         TALER_TESTING_Command *cmd,
+                                         unsigned int index,
+                                         const void **s);
+
+
+/**
+ * Offer the core secret.
+ *
+ * @param index the core secret's index number (usually 0).
+ * @param s the core secret to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_core_secret (unsigned int index,
+                                          const void *s);
+
 /**
  * Types of options for performing the secret sharing. Used as a bitmask.
  */
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index adccffd..a800bfb 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -75,6 +75,7 @@ libanastasistesting_la_SOURCES = \
   testing_cmd_challenge_answer.c \
   testing_trait_truth.c \
   testing_trait_policy.c \
+  testing_trait_core_secret.c \
   testing_trait_recovery.c \
   testing_trait_challenge.c
 libanastasistesting_la_LIBADD = \
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index eb08c45..6b67fdd 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -1009,7 +1009,7 @@ struct ANASTASIS_Policy
   /**
    * length of methods used
    */
-  unsigned int uuid_length;
+  unsigned int uuids_length;
 
   /**
    * array of truths
@@ -1030,7 +1030,7 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
   struct ANASTASIS_Policy *p;
   struct ANASTASIS_Truth *truth;
   struct ANASTASIS_CRYPTO_KeyShareP key_shares[truths_len];
-  uuid_t uuids[truths_len];
+  uuid_t *uuids[truths_len];
 
   p = GNUNET_new (struct ANASTASIS_Policy);
 
@@ -1075,12 +1075,18 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth 
*truths[],
               "At %s:%d policy key is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (&p->policy_key),
               (unsigned long long) sizeof (p->policy_key));
-  p->uuids = uuids;
-  p->uuid_length = truths_len;
-  p->truths = truths;
+  p->truths = GNUNET_malloc (truths_len * sizeof (struct ANASTASIS_Truth *));
+  GNUNET_memcpy (p->truths,
+                 truths,
+                 truths_len * sizeof (struct ANASTASIS_Truth *));
+  p->uuids = GNUNET_malloc (truths_len * sizeof (uuid_t *));
+  GNUNET_memcpy (p->uuids,
+                 uuids,
+                 truths_len * sizeof (uuid_t *));
+  p->uuids_length = truths_len;
 
   GNUNET_assert (NULL != p->uuids);
-  GNUNET_assert (p->uuid_length == truths_len);
+  GNUNET_assert (p->uuids_length == truths_len);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (p),
@@ -1333,7 +1339,7 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
   {
     policy = policies[i];
 
-    len += policy->uuid_length;
+    len += policy->uuids_length;
   }
 
   {
@@ -1349,9 +1355,9 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
       policy = policies[l];
       struct ANASTASIS_Truth *truth;
 
-      for (unsigned int j = 0; j < policy->uuid_length; j++)
+      for (unsigned int j = 0; j < policy->uuids_length; j++)
       {
-        truth = policy->truths[0];
+        truth = policy->truths[j];
 
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
@@ -1475,12 +1481,10 @@ ANASTASIS_secret_share (const json_t *id_data,
 
   dec_policies = json_array ();
   esc_methods = json_array ();
-  unsigned int all_uuids_length = 0;
   int index_pss = 0;
   for (unsigned int k = 0; k < policies_len; k++ )
   {
     policy = policies[k];
-    all_uuids_length += policy->uuid_length;
     json_t *dec_policy = json_pack ("{s:o," /* encrypted master key */
                                     " s:o," /* policy uuids  */
                                     " s:i}",/* policy uuids length */
@@ -1490,9 +1494,9 @@ ANASTASIS_secret_share (const json_t *id_data,
                                     "uuids",
                                     GNUNET_JSON_from_data (policy->uuids,
                                                            policy->
-                                                           uuid_length
+                                                           uuids_length
                                                            * sizeof(uuid_t)),
-                                    "uuid_length", &policy->uuid_length);
+                                    "uuid_length", policy->uuids_length);
     GNUNET_assert (NULL != dec_policy);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "dec policy json before upload 0: %s\n",
@@ -1505,7 +1509,7 @@ ANASTASIS_secret_share (const json_t *id_data,
                 json_dumps (dec_policies, JSON_COMPACT));
 
     // FIXME CHALLENGE
-    for (unsigned int l = 0; l < policy->uuid_length; l++)
+    for (unsigned int l = 0; l < policy->uuids_length; l++)
     {
       // creates a json array for saving
       json_t *esc_method = json_pack ("{s:o," /* truth uuid */
@@ -1554,6 +1558,8 @@ ANASTASIS_secret_share (const json_t *id_data,
         index_pss++;
       }
     }
+    GNUNET_free (policy->uuids);
+    GNUNET_free (policy->truths);
   }
 
   recovery_document = json_pack (
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index 7d1fd87..fc98911 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -196,8 +196,8 @@ run (void *cls,
                                         "Secure-Question",
                                         "You have to answer the secure 
question.",
                                         "string",
-                                        "HashOfSomeTruth",
-                                        strlen ("HashOfSomeTruth"),
+                                        "HashOfSomeTruth1",
+                                        strlen ("HashOfSomeTruth1"),
                                         MHD_HTTP_NO_CONTENT,
                                         ANASTASIS_TESTING_TSO_NONE,
                                         "salt-request-1"),
@@ -213,8 +213,8 @@ run (void *cls,
                                         "Secure-Question",
                                         "You have to answer the secure 
question.",
                                         "string",
-                                        "HashOfSomeTruth",
-                                        strlen ("HashOfSomeTruth"),
+                                        "HashOfSomeTruth2",
+                                        strlen ("HashOfSomeTruth2"),
                                         MHD_HTTP_NO_CONTENT,
                                         ANASTASIS_TESTING_TSO_NONE,
                                         "salt-request-2"),
@@ -230,8 +230,8 @@ run (void *cls,
                                         "Secure-Question",
                                         "You have to answer the secure 
question.",
                                         "string",
-                                        "HashOfSomeTruth",
-                                        strlen ("HashOfSomeTruth"),
+                                        "HashOfSomeTruth3",
+                                        strlen ("HashOfSomeTruth3"),
                                         MHD_HTTP_NO_CONTENT,
                                         ANASTASIS_TESTING_TSO_NONE,
                                         "salt-request-3"),
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
index 6a97520..4ec5f81 100644
--- a/src/lib/testing_cmd_secret_share.c
+++ b/src/lib/testing_cmd_secret_share.c
@@ -262,7 +262,8 @@ secret_share_traits (void *cls,
 {
   struct SecretShareState *sss = cls;
   struct TALER_TESTING_Trait traits[] = {
-    // FIXME: What traits are usefull?
+    ANASTASIS_TESTING_make_trait_core_secret (0,
+                                              sss->core_secret),
     TALER_TESTING_trait_end ()
   };
 
diff --git a/src/lib/testing_api_trait_uuid.c 
b/src/lib/testing_trait_core_secret.c
similarity index 53%
copy from src/lib/testing_api_trait_uuid.c
copy to src/lib/testing_trait_core_secret.c
index 4a61eeb..100a249 100644
--- a/src/lib/testing_api_trait_uuid.c
+++ b/src/lib/testing_trait_core_secret.c
@@ -17,8 +17,8 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file lib/testing_api_trait_uuid.c
- * @brief traits to offer a hash
+ * @file lib/testing_trait_core_secret.c
+ * @brief traits to offer the core secret
  * @author Christian Grothoff
  * @author Dominik Meister
  * @author Dennis Neufeld
@@ -26,49 +26,49 @@
 #include "platform.h"
 #include "anastasis_testing_lib.h"
 
-#define ANASTASIS_TESTING_TRAIT_UUID "anastasis-uuid"
+#define ANASTASIS_TESTING_TRAIT_CORE_SECRET "anastasis-core-secret"
 
 
 /**
- * Obtain an uuid from @a cmd.
+ * Obtain the core secret from @a cmd.
  *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param u[out] set to the number coming from @a cmd.
+ * @param cmd command to extract the core secret from.
+ * @param index the index of the core secret (usually 0)
+ * @param s[out] set to the core secret coming from @a cmd.
  * @return #GNUNET_OK on success.
  */
 int
-ANASTASIS_TESTING_get_trait_uuid
-  (const struct TALER_TESTING_Command *cmd,
-  unsigned int index,
-  const uuid_t **u)
+ANASTASIS_TESTING_get_trait_core_secret (const struct
+                                         TALER_TESTING_Command *cmd,
+                                         unsigned int index,
+                                         const void **s)
 {
   return cmd->traits (cmd->cls,
-                      (const void **) u,
-                      ANASTASIS_TESTING_TRAIT_UUID,
+                      s,
+                      ANASTASIS_TESTING_TRAIT_CORE_SECRET,
                       index);
 }
 
 
 /**
- * Offer an uuid.
+ * Offer the core secret.
  *
- * @param index the number's index number.
- * @param u the uuid to offer.
+ * @param index the core secret's index number (usually 0).
+ * @param s the core secret to offer.
  * @return #GNUNET_OK on success.
  */
 struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_uuid
+ANASTASIS_TESTING_make_trait_core_secret
   (unsigned int index,
-  const uuid_t *u)
+  const void *s)
 {
   struct TALER_TESTING_Trait ret = {
     .index = index,
-    .trait_name = ANASTASIS_TESTING_TRAIT_UUID,
-    .ptr = (const void *) u
+    .trait_name = ANASTASIS_TESTING_TRAIT_CORE_SECRET,
+    .ptr = s
   };
   return ret;
 }
 
 
-/* end of testing_api_trait_uuid.c */
+/* end of testing_trait_core_secret.c */

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



reply via email to

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