gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (f7c3eac -> d87884d)


From: gnunet
Subject: [taler-anastasis] branch master updated (f7c3eac -> d87884d)
Date: Wed, 29 Apr 2020 23:23:56 +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 f7c3eac  fixed json
     new a5ca68b  worked on salt trait
     new d87884d  solved salt request timing issue

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                            |  4 +-
 src/include/anastasis_testing_lib.h                | 27 +++++++++++
 src/lib/Makefile.am                                |  1 +
 src/lib/anastasis.c                                | 53 +++++++++++++++++-----
 src/lib/test_anastasis.c                           | 12 +++++
 src/lib/testing_api_cmd_salt.c                     | 39 +++++++++++++++-
 ...g_api_trait_uuid.c => testing_api_trait_salt.c} | 36 +++++++--------
 src/lib/testing_cmd_truth_upload.c                 | 36 ++++++++++++---
 8 files changed, 169 insertions(+), 39 deletions(-)
 copy src/lib/{testing_api_trait_uuid.c => testing_api_trait_salt.c} (63%)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 5d3bc0d..1cf362a 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -24,7 +24,7 @@
 #include <taler/taler_json_lib.h>
 #include <gnunet/gnunet_util_lib.h>
 #include <uuid/uuid.h>
-
+#include "anastasis_service.h"
 
 /*Download api*/
 
@@ -272,6 +272,7 @@ typedef void
 * @param method defines the method of the challenge (secure question, sms, 
email)
 * @param instructions depending on method! usually only for security 
question/answer!
 * @param mime_type format of the challenge
+* @param salt the server salt
 * @param truth_data contains the truth for this challenge i.e. phone number, 
email address
 * @param truth_data_size size of the data
 * @param tpc opens a truth payment callback to pay the upload
@@ -286,6 +287,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                         const char *method,
                         const char *instructions,
                         const char *mime_type,
+                        const struct ANASTASIS_CRYPTO_SaltP *salt,
                         const void *truth_data,
                         size_t truth_data_size,
                         ANASTASIS_TruthPaymentCallback tpc,
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index f7406a5..60ccef8 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -417,6 +417,33 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        ANASTASIS_CRYPTO_TruthKeyP key,
                                        const char *upload_ref);
 
+
+/**
+ * Obtain a salt from @a cmd.
+ *
+ * @param cmd command to extract the salt from.
+ * @param index the salt's index number.
+ * @param s[out] set to the salt coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_salt (const struct TALER_TESTING_Command *cmd,
+                                  unsigned int index,
+                                  const struct ANASTASIS_CRYPTO_SaltP **s);
+
+
+/**
+ * Offer an salt.
+ *
+ * @param index the salt's index number.
+ * @param u the salt to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_salt (unsigned int index,
+                                   const struct ANASTASIS_CRYPTO_SaltP *s);
+
+
 /**
  * Make the "salt" command.
  *
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 32bcd5c..e3c837d 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -67,6 +67,7 @@ libanastasistesting_la_SOURCES = \
   testing_api_trait_payment_identifier.c \
   testing_api_trait_uuid.c \
   testing_api_trait_hash.c \
+  testing_api_trait_salt.c \
   testing_cmd_truth_upload.c \
   testing_cmd_secret_share.c \
   testing_cmd_recover_secret.c \
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 0a42a92..3339f24 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -23,7 +23,6 @@
 #include "anastasis.h"
 #include <taler/taler_json_lib.h>
 #include <gnunet/gnunet_util_lib.h>
-#include "anastasis_service.h"
 
 
 /**
@@ -45,6 +44,11 @@ struct SaltState
    * The /salt GET operation handle.
    */
   struct ANASTASIS_SaltOperation *so;
+
+  /**
+   * Server Salt
+   */
+  const struct ANASTASIS_CRYPTO_SaltP *salt;
 };
 
 
@@ -63,8 +67,28 @@ salt_cb (void *cls,
   struct SaltState *ss = cls;
 
   ss->so = NULL;
-  GNUNET_assert (http_status == ss->http_status);
-  GNUNET_assert (NULL != salt);
+
+  if (http_status != ss->http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected response code %u in %s:%u\n",
+                http_status,
+                __FILE__,
+                __LINE__);
+    GNUNET_break (0);
+    return;
+  }
+  if (NULL == salt)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Salt is NULL in %s:%u\n",
+                __FILE__,
+                __LINE__);
+    GNUNET_break (0);
+    return;
+  }
+
+  ss->salt = salt;
 }
 
 
@@ -624,6 +648,7 @@ truth_store_callback (void *cls,
 * @param method defines the method of the challenge (secure question, sms, 
email)
 * @param instructions depending on method! usually only for security 
question/answer!
 * @param mime_type format of the challenge
+* @param salt the server salt
 * @param truth_data contains the truth for this challenge i.e. phone number, 
email address
 * @param truth_data_size size of the data
 * @param tpc opens a truth payment callback to pay the upload
@@ -638,6 +663,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                         const char *method,
                         const char *instructions,
                         const char *mime_type,
+                        const struct ANASTASIS_CRYPTO_SaltP *salt,
                         const void *truth_data,
                         size_t truth_data_size,
                         ANASTASIS_TruthPaymentCallback tpc,
@@ -656,7 +682,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
 
   tu = GNUNET_new (struct ANASTASIS_TruthUpload);
   t = GNUNET_new (struct ANASTASIS_Truth);
-  ss = GNUNET_new (struct ANASTASIS_CRYPTO_SaltP);
+  // ss = GNUNET_new (struct SaltState);
   tu->tc_cls = tc_cls;
   tu->tpc_cls = tpc_cls;
   tu->tpc = tpc;
@@ -668,32 +694,35 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
   t->mime_type = mime_type;
   uuid_generate (t->uuid);
 
+  /*
   ss->http_status = MHD_HTTP_OK;
   ss->so = ANASTASIS_salt (tu->ctx,
                            provider_url,
                            &salt_cb,
                            ss);
-  if (NULL == &ss->so->salt)
+  */
+
+  if (NULL == id_data)
   {
     GNUNET_break (0);
     return;
   }
-  if (NULL == id_data)
+
+  if (NULL == ss->salt)
   {
-    GNUNET_break (0);
-    return;
+
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
-              TALER_B2S (&ss->so->salt),
-              (unsigned long long) sizeof (ss->so->salt));
+              TALER_B2S (salt),
+              (unsigned long long) sizeof (*salt));
   ANASTASIS_CRYPTO_keyshare_create (&t->key_share);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d keyshare is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (&t->key_share),
               (unsigned long long) sizeof (t->key_share));
   ANASTASIS_CRYPTO_user_identifier_derive (id_data,
-                                           &ss->so->salt,
+                                           salt,
                                            &tu->id);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d user identifier is %s-%llu b\n", __FILE__, __LINE__,
@@ -743,7 +772,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                                    tu->paid_order_id,
                                    &truth_store_callback,
                                    tu);
-  salt_cleanup (ss);
+  // salt_cleanup (ss);
   // SETUP TRUTH CALLBACK
   tu->tc = tc;
   tu->tc_cls = tc_cls;
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index 8dfe491..7867d14 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -185,6 +185,10 @@ run (void *cls,
 
   struct TALER_TESTING_Command anastasis[] = {
     // FIXME: testing logic here
+    ANASTASIS_TESTING_cmd_salt ("truth-create-1",
+                                anastasis_url,
+                                MHD_HTTP_OK),
+
     ANASTASIS_TESTING_cmd_truth_upload ("truth-create-1",
                                         anastasis_url,
                                         ANASTASIS_TESTING_make_id_data_example 
(
@@ -198,6 +202,10 @@ run (void *cls,
                                         ANASTASIS_TESTING_TSO_NONE,
                                         NULL),
 
+    ANASTASIS_TESTING_cmd_salt ("truth-create-2",
+                                anastasis_url,
+                                MHD_HTTP_OK),
+
     ANASTASIS_TESTING_cmd_truth_upload ("truth-create-2",
                                         anastasis_url,
                                         ANASTASIS_TESTING_make_id_data_example 
(
@@ -211,6 +219,10 @@ run (void *cls,
                                         ANASTASIS_TESTING_TSO_NONE,
                                         "truth-create-1"),
 
+    ANASTASIS_TESTING_cmd_salt ("truth-create-3",
+                                anastasis_url,
+                                MHD_HTTP_OK),
+
     ANASTASIS_TESTING_cmd_truth_upload ("truth-create-3",
                                         anastasis_url,
                                         ANASTASIS_TESTING_make_id_data_example 
(
diff --git a/src/lib/testing_api_cmd_salt.c b/src/lib/testing_api_cmd_salt.c
index 6360408..c891215 100644
--- a/src/lib/testing_api_cmd_salt.c
+++ b/src/lib/testing_api_cmd_salt.c
@@ -50,6 +50,11 @@ struct SaltState
    * The /salt GET operation handle.
    */
   struct ANASTASIS_SaltOperation *so;
+
+  /**
+   * The salt value from server.
+   */
+  struct ANASTASIS_CRYPTO_SaltP salt;
 };
 
 
@@ -89,6 +94,7 @@ salt_cb (void *cls,
     TALER_TESTING_interpreter_fail (ss->is);
     return;
   }
+  ss->salt = *salt;
   TALER_TESTING_interpreter_next (ss->is);
 }
 
@@ -146,6 +152,36 @@ salt_cleanup (void *cls,
 }
 
 
+/**
+ * Offer internal data to other commands.
+ *
+ * @param cls closure
+ * @param ret[out] result (could be anything)
+ * @param trait name of the trait
+ * @param index index number of the object to extract.
+ * @return #GNUNET_OK on success
+ */
+static int
+salt_traits (void *cls,
+             const void **ret,
+             const char *trait,
+             unsigned int index)
+{
+  struct SaltState *ss = cls;
+
+  struct TALER_TESTING_Trait traits[] = {
+    ANASTASIS_TESTING_make_trait_salt (0,
+                                       &ss->salt),
+    TALER_TESTING_trait_end ()
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+}
+
+
 /**
  * Make the "salt" command.
  *
@@ -170,7 +206,8 @@ ANASTASIS_TESTING_cmd_salt (const char *label,
       .cls = ss,
       .label = label,
       .run = &salt_run,
-      .cleanup = &salt_cleanup
+      .cleanup = &salt_cleanup,
+      .traits = &salt_traits
     };
 
     return cmd;
diff --git a/src/lib/testing_api_trait_uuid.c b/src/lib/testing_api_trait_salt.c
similarity index 63%
copy from src/lib/testing_api_trait_uuid.c
copy to src/lib/testing_api_trait_salt.c
index 4a61eeb..0bf5f3a 100644
--- a/src/lib/testing_api_trait_uuid.c
+++ b/src/lib/testing_api_trait_salt.c
@@ -17,7 +17,7 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file lib/testing_api_trait_uuid.c
+ * @file lib/testing_api_trait_salt.c
  * @brief traits to offer a hash
  * @author Christian Grothoff
  * @author Dominik Meister
@@ -26,49 +26,49 @@
 #include "platform.h"
 #include "anastasis_testing_lib.h"
 
-#define ANASTASIS_TESTING_TRAIT_UUID "anastasis-uuid"
+#define ANASTASIS_TESTING_TRAIT_SALT "anastasis-salt"
 
 
 /**
- * Obtain an uuid from @a cmd.
+ * Obtain a salt 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 salt from.
+ * @param index the salt's index number.
+ * @param s[out] set to the salt coming from @a cmd.
  * @return #GNUNET_OK on success.
  */
 int
-ANASTASIS_TESTING_get_trait_uuid
+ANASTASIS_TESTING_get_trait_salt
   (const struct TALER_TESTING_Command *cmd,
   unsigned int index,
-  const uuid_t **u)
+  const struct ANASTASIS_CRYPTO_SaltP **s)
 {
   return cmd->traits (cmd->cls,
-                      (const void **) u,
-                      ANASTASIS_TESTING_TRAIT_UUID,
+                      (const void **) s,
+                      ANASTASIS_TESTING_TRAIT_SALT,
                       index);
 }
 
 
 /**
- * Offer an uuid.
+ * Offer an salt.
  *
- * @param index the number's index number.
- * @param u the uuid to offer.
+ * @param index the salt's index number.
+ * @param u the salt to offer.
  * @return #GNUNET_OK on success.
  */
 struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_uuid
+ANASTASIS_TESTING_make_trait_salt
   (unsigned int index,
-  const uuid_t *u)
+  const struct ANASTASIS_CRYPTO_SaltP *s)
 {
   struct TALER_TESTING_Trait ret = {
     .index = index,
-    .trait_name = ANASTASIS_TESTING_TRAIT_UUID,
-    .ptr = (const void *) u
+    .trait_name = ANASTASIS_TESTING_TRAIT_SALT,
+    .ptr = (const void *) s
   };
   return ret;
 }
 
 
-/* end of testing_api_trait_uuid.c */
+/* end of testing_api_trait_salt.c */
diff --git a/src/lib/testing_cmd_truth_upload.c 
b/src/lib/testing_cmd_truth_upload.c
index bdcd206..e6eb6a2 100644
--- a/src/lib/testing_cmd_truth_upload.c
+++ b/src/lib/testing_cmd_truth_upload.c
@@ -42,6 +42,11 @@ struct TruthUploadState
    */
   const char *anastasis_url;
 
+  /**
+   * Label of this command.
+   */
+  const char *label;
+
   /**
    * The ID data to generate user identifier
    */
@@ -168,12 +173,12 @@ truth_upload_run (void *cls,
                   struct TALER_TESTING_Interpreter *is)
 {
   struct TruthUploadState *tus = cls;
+  const struct TALER_TESTING_Command *ref;
+  const struct ANASTASIS_CRYPTO_SaltP *salt;
 
   tus->is = is;
   if (NULL != tus->upload_reference)
   {
-    const struct TALER_TESTING_Command *ref;
-
     ref = TALER_TESTING_interpreter_lookup_command
             (is,
             tus->upload_reference);
@@ -201,12 +206,33 @@ truth_upload_run (void *cls,
     tus->truth_number = 0;
   }
 
+  ref = TALER_TESTING_interpreter_lookup_command
+          (is,
+          tus->label);
+  if (NULL == ref)
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (tus->is);
+    return;
+  }
+
+  if (GNUNET_OK !=
+      ANASTASIS_TESTING_get_trait_salt (ref,
+                                        0,
+                                        &salt))
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (tus->is);
+    return;
+  }
+
   tus->tuo = ANASTASIS_truth_upload (is->ctx,
                                      tus->id_data,
                                      tus->anastasis_url,
                                      tus->method,
                                      tus->instructions,
                                      tus->mime_type,
+                                     salt,
                                      tus->truth_data,
                                      tus->truth_data_size,
                                      &truth_payment_cb,
@@ -293,11 +319,6 @@ ANASTASIS_TESTING_make_id_data_example (const char 
*id_data)
 {
   json_t *id;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d id data string is %s-%llu b\n", __FILE__, __LINE__,
-              id_data,
-              (unsigned long long) strlen (id_data));
-
   id = json_pack ("{s:s}",
                   "id_data", id_data);
   GNUNET_assert (NULL != id);
@@ -339,6 +360,7 @@ ANASTASIS_TESTING_cmd_truth_upload (const char *label,
   struct TruthUploadState *tus;
 
   tus = GNUNET_new (struct TruthUploadState);
+  tus->label = label;
   tus->http_status = http_status;
   tus->tsopt = tso;
   tus->anastasis_url = anastasis_url;

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



reply via email to

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