gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/03: fix truths in policy struct


From: gnunet
Subject: [taler-anastasis] 01/03: fix truths in policy struct
Date: Thu, 07 May 2020 19:10:06 +0200

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

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

commit c9cfd8b9ffa1c7a7c94495a92155a97efe63b3cb
Author: Dennis Neufeld <address@hidden>
AuthorDate: Thu May 7 16:40:10 2020 +0000

    fix truths in policy struct
---
 src/lib/anastasis.c      | 29 +++++++++++++++++------------
 src/lib/test_anastasis.c | 12 ++++++------
 2 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index eb08c45..7af886e 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,17 @@ 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->truths = GNUNET_malloc (truths_len * sizeof (struct ANASTASIS_Truth *));
+  GNUNET_memcpy (p->truths,
+                 truths,
+                 truths_len * sizeof (struct ANASTASIS_Truth *));
+
   p->uuids = uuids;
-  p->uuid_length = truths_len;
-  p->truths = truths;
+  p->uuids_length = truths_len;
+  // p->truths = truths;
 
   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 +1338,7 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
   {
     policy = policies[i];
 
-    len += policy->uuid_length;
+    len += policy->uuids_length;
   }
 
   {
@@ -1349,9 +1354,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__,
@@ -1480,7 +1485,7 @@ ANASTASIS_secret_share (const json_t *id_data,
   for (unsigned int k = 0; k < policies_len; k++ )
   {
     policy = policies[k];
-    all_uuids_length += policy->uuid_length;
+    all_uuids_length += policy->uuids_length;
     json_t *dec_policy = json_pack ("{s:o," /* encrypted master key */
                                     " s:o," /* policy uuids  */
                                     " s:i}",/* policy uuids length */
@@ -1490,9 +1495,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 +1510,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 */
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"),

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



reply via email to

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