gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 02/02: solved salt request timing issue


From: gnunet
Subject: [taler-anastasis] 02/02: solved salt request timing issue
Date: Wed, 29 Apr 2020 23:23:58 +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 d87884d2a0b69e4787018e9d06b7b3f0d046762b
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Apr 29 21:16:57 2020 +0000

    solved salt request timing issue
---
 src/include/anastasis.h            |  4 +++-
 src/lib/Makefile.am                |  1 +
 src/lib/anastasis.c                | 16 ++++++++++------
 src/lib/test_anastasis.c           | 12 ++++++++++++
 src/lib/testing_api_cmd_salt.c     | 39 +++++++++++++++++++++++++++++++++++++-
 src/lib/testing_cmd_truth_upload.c | 33 +++++++++++++++++++++++++++++---
 6 files changed, 94 insertions(+), 11 deletions(-)

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/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 4d57a43..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"
 
 
 /**
@@ -649,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
@@ -663,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,
@@ -681,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 SaltState);
+  // ss = GNUNET_new (struct SaltState);
   tu->tc_cls = tc_cls;
   tu->tpc_cls = tpc_cls;
   tu->tpc = tpc;
@@ -693,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 == id_data)
   {
     GNUNET_break (0);
     return;
   }
+
   if (NULL == ss->salt)
   {
 
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
-              TALER_B2S (ss->salt),
-              (unsigned long long) sizeof (*ss->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->salt,
+                                           salt,
                                            &tu->id);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d user identifier is %s-%llu b\n", __FILE__, __LINE__,
@@ -768,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_cmd_truth_upload.c 
b/src/lib/testing_cmd_truth_upload.c
index 3f60aad..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,
@@ -320,7 +346,7 @@ ANASTASIS_TESTING_make_id_data_example (const char *id_data)
 struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_truth_upload (const char *label,
                                     const char *anastasis_url,
-                                    const json_t *id_data,
+                                    json_t *id_data,
                                     const char *method,
                                     const char *instructions,
                                     const char *mime_type,
@@ -334,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]