gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 04/12: fixed compiling errors


From: gnunet
Subject: [taler-anastasis] 04/12: fixed compiling errors
Date: Mon, 20 Apr 2020 09:45:59 +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 9f62d6c8288fa217f85a69f11f244595ac419053
Author: Dennis Neufeld <address@hidden>
AuthorDate: Sat Apr 18 14:32:48 2020 +0000

    fixed compiling errors
---
 src/backend/anastasis-httpd_truth.c       | 16 +++---------
 src/include/anastasis_testing_lib.h       | 28 ++++++++++++++++++---
 src/lib/anastasis_api_keyshare_lookup.c   | 21 ++++++++--------
 src/lib/test_anastasis_api.c              | 10 +++++++-
 src/lib/testing_api_cmd_keyshare_lookup.c | 42 +++++++++++++++++++++++++++++--
 src/lib/testing_api_cmd_truth_store.c     | 21 ++++++++++++----
 src/lib/testing_api_trait_uuid.c          |  4 +--
 7 files changed, 105 insertions(+), 37 deletions(-)

diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 6704b68..8784266 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -22,8 +22,8 @@
  */
 #include "platform.h"
 #include "anastasis-httpd.h"
+#include "anastasis_service.h"
 #include "anastasis-httpd_truth.h"
-#include "anastasis_crypto_lib.h"
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet/gnunet_rest_lib.h>
 
@@ -49,7 +49,6 @@ AH_handler_truth_get (struct MHD_Connection *connection,
   void *decrypted_truth;
   size_t decrypted_truth_size;
   void *encrypted_keyshare;
-  char result[GNUNET_CRYPTO_AES_KEY_LENGTH];
   char *truth_mime;
   char *method;
   int ret;
@@ -108,17 +107,12 @@ AH_handler_truth_get (struct MHD_Connection *connection,
     {
       return qs;
     }
-
-    if (NULL == challenge_response_s)
-    {
-      // FIXME: Return escrow challenge
-    }
   }
   {
     // decrypt encrypted_truth
     ANASTASIS_CRYPTO_truth_decrypt (&truth_key,
                                     encrypted_truth,
-                                    &encrypted_truth_size,
+                                    encrypted_truth_size,
                                     &decrypted_truth,
                                     &decrypted_truth_size);
   }
@@ -172,10 +166,6 @@ AH_handler_truth_get (struct MHD_Connection *connection,
 
     }
   }
-
-  return MHD_NO;
-
-error:
   GNUNET_free_non_null (decrypted_truth);
-  return ret;
+  return MHD_NO;
 }
\ No newline at end of file
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index d54c276..a06b33f 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -340,16 +340,32 @@ enum ANASTASIS_TESTING_TruthStoreOption
 
 };
 
+/**
+ * Creates hash of an answer
+ *
+ * @param answer the answer to a challenge (e.g. a secure question)
+ * @param size_answer size of the answer
+ * @return hash of the answer
+ */
+struct GNUNET_HashCode *
+ANASTASIS_TESTING_make_hashed_answer (void *answer,
+                                      size_t size_answer);
+
 /**
  * Creates a sample of truth.
  *
  * @param method the challenge method
  * @param mime_type mime type of the truth
+ * @param answer the hashed answer (part of truth) to a challenge
+ * @param key the key to encrypt the truth
  * @return truth in json format
  */
 json_t*
-ANASTASIS_TESTING_make_truth_example (char *method,
-                                      char *mime_type);
+ANASTASIS_TESTING_make_truth_example (const char *method,
+                                      const char *mime_type,
+                                      const struct GNUNET_HashCode *answer,
+                                      const struct
+                                      ANASTASIS_CRYPTO_TruthKey *key);
 
 /**
  * Make the "truth store" command.
@@ -366,8 +382,7 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
                                    const char *anastasis_url,
                                    const char *prev_upload,
                                    unsigned int http_status,
-                                   enum
-                                   ANASTASIS_TESTING_TruthStoreOption tso,
+                                   enum ANASTASIS_TESTING_TruthStoreOption tso,
                                    json_t *truth_data);
 
 /**
@@ -377,6 +392,8 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
  * @param anastasis_url base URL of the ANASTASIS serving
  *        the keyshare lookup request.
  * @param http_status expected HTTP status.
+ * @param answer hashed answer (response to challenge)
+ * @param key key to decrypt truth
  * @param upload_ref reference to upload command
  * @return the command
  */
@@ -384,6 +401,9 @@ struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        const char *anastasis_url,
                                        unsigned int http_status,
+                                       const struct GNUNET_HashCode *answer,
+                                       const struct
+                                       ANASTASIS_CRYPTO_TruthKey *key,
                                        const char *upload_ref);
 
 /**
diff --git a/src/lib/anastasis_api_keyshare_lookup.c 
b/src/lib/anastasis_api_keyshare_lookup.c
index 8675ae4..54bb25c 100644
--- a/src/lib/anastasis_api_keyshare_lookup.c
+++ b/src/lib/anastasis_api_keyshare_lookup.c
@@ -170,7 +170,7 @@ handle_key_share_lookup_finished (void *cls,
  * @param buffer one line of HTTP header data
  * @param size size of an item
  * @param nitems number of items passed
- * @param userdata our `struct ANASTASIS_PolicyLookupOperation *`
+ * @param userdata our `struct ANASTASIS_KeyShareLookupOperation *`
  * @return `size * nitems`
  */
 static size_t
@@ -184,18 +184,21 @@ handle_header (char *buffer,
   char *ndup;
   const char *hdr_type;
   char *hdr_val;
+  char *sp;
 
   ndup = GNUNET_strndup (buffer,
                          total);
-  hdr_type = strtok (ndup,
-                     ":");
+  hdr_type = strtok_r (ndup,
+                       ":",
+                       &sp);
   if (NULL == hdr_type)
   {
     GNUNET_free (ndup);
     return total;
   }
-  hdr_val = strtok (NULL,
-                    "\n\r");
+  hdr_val = strtok_r (NULL,
+                      "\n\r",
+                      &sp);
   if (NULL == hdr_val)
   {
     GNUNET_free (ndup);
@@ -203,13 +206,11 @@ handle_header (char *buffer,
   }
   if (' ' == *hdr_val)
     hdr_val++;
-
-  /* FIXME: reasonable?*/
   if (0 == strcasecmp (hdr_type,
                        "Truth-Decryption-Key"))
   {
     if (GNUNET_OK !=
-        GNUNET_STRINGS_data_to_string (hdr_val,
+        GNUNET_STRINGS_string_to_data (hdr_val,
                                        strlen (hdr_val),
                                        &kslo->truth_key,
                                        sizeof (struct
@@ -268,10 +269,10 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context 
*ctx,
   kslo->url = TALER_url_join (backend_url,
                               path,
                               "response",
-                              hashed_answer,
+                              hashed_answer_str,
                               NULL);
   GNUNET_free (path);
-  GNUNET_free (hashed_answer);
+  GNUNET_free (hashed_answer_str);
   eh = curl_easy_init ();
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 4b52a72..475ca41 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -239,10 +239,18 @@ run (void *cls,
                                        ANASTASIS_TESTING_TSO_NONE,
                                        ANASTASIS_TESTING_make_truth_example (
                                          "Truth method",
-                                         "Truth mime")),
+                                         "Truth mime",
+                                         ANASTASIS_TESTING_make_hashed_answer (
+                                           "Hashed-Answer",
+                                           strlen ("Hashed-Answer")),
+                                         "Truth-Key")),
     ANASTASIS_TESTING_cmd_keyshare_lookup ("keyshare-lookup-1",
                                            anastasis_url,
                                            MHD_HTTP_OK,
+                                           
ANASTASIS_TESTING_make_hashed_answer (
+                                             "Hashed-Answer",
+                                             strlen ("Hashed-Answer")),
+                                           "Truth-Key",
                                            "truth-store-1"),
 
     TALER_TESTING_cmd_end ()
diff --git a/src/lib/testing_api_cmd_keyshare_lookup.c 
b/src/lib/testing_api_cmd_keyshare_lookup.c
index 0758e30..f7b8c89 100644
--- a/src/lib/testing_api_cmd_keyshare_lookup.c
+++ b/src/lib/testing_api_cmd_keyshare_lookup.c
@@ -52,10 +52,20 @@ struct KeyshareLookupState
    */
   struct ANASTASIS_KeyshareLookupOperation *kslo;
 
+  /**
+   * Hashed answer to a challenge
+   */
+  const struct GNUNET_HashCode *hashed_answer;
+
+  /**
+   * Key to decrypt truth
+   */
+  const struct ANASTASIS_CRYPTO_TruthKey *truth_key;
+
   /**
    * Identification of the Truth Object
    */
-  const uuid_t truth_uuid;
+  const uuid_t *truth_uuid;
 
   /**
    * Reference to upload command we expect to lookup.
@@ -133,7 +143,9 @@ keyshare_lookup_run (void *cls,
   }
   ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
                                           ksls->anastasis_url,
-                                          &ksls->anastasis_pub,
+                                          ksls->truth_uuid,
+                                          ksls->truth_key,
+                                          ksls->hashed_answer,
                                           &keyshare_lookup_cb,
                                           ksls);
   if (NULL == ksls->kslo)
@@ -170,6 +182,25 @@ keyshare_lookup_cleanup (void *cls,
 }
 
 
+/**
+ * Creates hash of an answer
+ *
+ * @param answer the answer to a challenge (e.g. a secure question)
+ * @param size_answer size of the answer
+ * @return hash of the answer
+ */
+struct GNUNET_HashCode *
+ANASTASIS_TESTING_make_hashed_answer (void *answer,
+                                      size_t size_answer)
+{
+  struct GNUNET_HashCode *hashed_answer;
+  GNUNET_CRYPTO_hash (answer,
+                      size_answer,
+                      hashed_answer);
+  return hashed_answer;
+}
+
+
 /**
  * Make the "keyshare lookup" command.
  *
@@ -177,6 +208,8 @@ keyshare_lookup_cleanup (void *cls,
  * @param anastasis_url base URL of the ANASTASIS serving
  *        the keyshare lookup request.
  * @param http_status expected HTTP status.
+ * @param answer hashed answer (response to challenge)
+ * @param key key to decrypt truth
  * @param upload_ref reference to upload command
  * @return the command
  */
@@ -184,6 +217,9 @@ struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        const char *anastasis_url,
                                        unsigned int http_status,
+                                       const struct GNUNET_HashCode *answer,
+                                       const struct
+                                       ANASTASIS_CRYPTO_TruthKey *key,
                                        const char *upload_ref)
 {
   struct KeyshareLookupState *ksls;
@@ -193,6 +229,8 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
   ksls->http_status = http_status;
   ksls->anastasis_url = anastasis_url;
   ksls->upload_reference = upload_ref;
+  ksls->hashed_answer = answer;
+  ksls->truth_key = key;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ksls,
diff --git a/src/lib/testing_api_cmd_truth_store.c 
b/src/lib/testing_api_cmd_truth_store.c
index 3095ea6..0f16278 100644
--- a/src/lib/testing_api_cmd_truth_store.c
+++ b/src/lib/testing_api_cmd_truth_store.c
@@ -337,17 +337,23 @@ truth_store_traits (void *cls,
  *
  * @param method the challenge method
  * @param mime_type mime type of the truth
+ * @param answer the hashed answer (part of truth) to a challenge
+ * @param key the key to encrypt the truth
  * @return truth in json format
  */
 json_t*
-ANASTASIS_TESTING_make_truth_example (char *method,
-                                      char *mime_type)
+ANASTASIS_TESTING_make_truth_example (const char *method,
+                                      const char *mime_type,
+                                      const struct GNUNET_HashCode *answer,
+                                      const struct
+                                      ANASTASIS_CRYPTO_TruthKey *key)
 {
 
   json_t *truth_data;
   struct ANASTASIS_CRYPTO_EncryptedKeyShare keyshare_data;
   struct GNUNET_HashCode truth_hash;
-  const char *encrypted_truth;
+  void *encrypted_truth;
+  size_t size_encrypted_truth;
 
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
                               &keyshare_data,
@@ -356,7 +362,11 @@ ANASTASIS_TESTING_make_truth_example (char *method,
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
                               &truth_hash,
                               sizeof (struct GNUNET_HashCode));
-  encrypted_truth = "Truth test (et)";
+  ANASTASIS_CRYPTO_truth_encrypt (key,
+                                  &answer,
+                                  sizeof (struct GNUNET_HashCode *),
+                                  &encrypted_truth,
+                                  &size_encrypted_truth);
 
   truth_data = json_pack ("{s:o," /* keyshare_data */
                           " s:s," /* method */
@@ -366,7 +376,8 @@ ANASTASIS_TESTING_make_truth_example (char *method,
                             &keyshare_data),
                           "method", method,
                           "encrypted_truth", GNUNET_JSON_from_data (
-                            encrypted_truth, strlen (encrypted_truth)),
+                            encrypted_truth,
+                            size_encrypted_truth),
                           "truth_mime", mime_type
                           );
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/lib/testing_api_trait_uuid.c b/src/lib/testing_api_trait_uuid.c
index b62a5eb..4a61eeb 100644
--- a/src/lib/testing_api_trait_uuid.c
+++ b/src/lib/testing_api_trait_uuid.c
@@ -45,7 +45,7 @@ ANASTASIS_TESTING_get_trait_uuid
 {
   return cmd->traits (cmd->cls,
                       (const void **) u,
-                      ANASTASIS_TESTING_TRAIT_HASH,
+                      ANASTASIS_TESTING_TRAIT_UUID,
                       index);
 }
 
@@ -64,7 +64,7 @@ ANASTASIS_TESTING_make_trait_uuid
 {
   struct TALER_TESTING_Trait ret = {
     .index = index,
-    .trait_name = ANASTASIS_TESTING_TRAIT_HASH,
+    .trait_name = ANASTASIS_TESTING_TRAIT_UUID,
     .ptr = (const void *) u
   };
   return ret;

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



reply via email to

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