gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/02: corrected truth key creation in api test


From: gnunet
Subject: [taler-anastasis] 01/02: corrected truth key creation in api test
Date: Wed, 22 Apr 2020 16:28:34 +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 451fa425760692cf7f00926800727fb7acd4c5c7
Author: Dennis Neufeld <address@hidden>
AuthorDate: Tue Apr 21 17:18:05 2020 +0000

    corrected truth key creation in api test
---
 src/backend/anastasis-httpd_truth.c       |  3 +++
 src/include/anastasis_testing_lib.h       |  6 +++---
 src/lib/testing_api_cmd_keyshare_lookup.c |  8 ++++----
 src/lib/testing_api_cmd_truth_store.c     | 24 ++++++++++++++++--------
 src/util/test_anastasis_crypto.c          |  2 +-
 5 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 6805ab1..4c2059d 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -123,6 +123,9 @@ AH_handler_truth_get (struct MHD_Connection *connection,
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Encrypted truth from db: %s\n",
                 TALER_b2s (encrypted_truth, encrypted_truth_size));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Encrypted truth size from db: %lu\n",
+                encrypted_truth_size);
   }
   {
     // decrypt encrypted_truth
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 386eadf..f4f8bd7 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -346,7 +346,7 @@ enum ANASTASIS_TESTING_TruthStoreOption
  * @param key_str a str you want to be a truth key
  * @return truthkey
  */
-struct ANASTASIS_CRYPTO_TruthKey *
+struct ANASTASIS_CRYPTO_TruthKey
 ANASTASIS_TESTING_make_truthkey (const char *key_str);
 
 /**
@@ -374,7 +374,7 @@ ANASTASIS_TESTING_make_truth_example (const char *method,
                                       const char *mime_type,
                                       const struct GNUNET_HashCode answer,
                                       const struct
-                                      ANASTASIS_CRYPTO_TruthKey *key);
+                                      ANASTASIS_CRYPTO_TruthKey key);
 
 /**
  * Make the "truth store" command.
@@ -412,7 +412,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        unsigned int http_status,
                                        const struct GNUNET_HashCode answer,
                                        const struct
-                                       ANASTASIS_CRYPTO_TruthKey *key,
+                                       ANASTASIS_CRYPTO_TruthKey key,
                                        const char *upload_ref);
 
 /**
diff --git a/src/lib/testing_api_cmd_keyshare_lookup.c 
b/src/lib/testing_api_cmd_keyshare_lookup.c
index 4807f01..8aafc81 100644
--- a/src/lib/testing_api_cmd_keyshare_lookup.c
+++ b/src/lib/testing_api_cmd_keyshare_lookup.c
@@ -60,7 +60,7 @@ struct KeyShareLookupState
   /**
    * Key to decrypt truth
    */
-  const struct ANASTASIS_CRYPTO_TruthKey *truth_key;
+  struct ANASTASIS_CRYPTO_TruthKey truth_key;
 
   /**
    * Identification of the Truth Object
@@ -167,7 +167,7 @@ keyshare_lookup_run (void *cls,
   ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
                                           ksls->anastasis_url,
                                           ksls->truth_uuid,
-                                          ksls->truth_key,
+                                          &ksls->truth_key,
                                           &ksls->hashed_answer,
                                           &keyshare_lookup_cb,
                                           ksls);
@@ -245,7 +245,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        unsigned int http_status,
                                        const struct GNUNET_HashCode answer,
                                        const struct
-                                       ANASTASIS_CRYPTO_TruthKey *key,
+                                       ANASTASIS_CRYPTO_TruthKey key,
                                        const char *upload_ref)
 {
   struct KeyShareLookupState *ksls;
@@ -255,7 +255,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
               TALER_B2S (&answer));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "TruthKey in keyshare lookup cmd: %s\n",
-              TALER_B2S (key));
+              TALER_B2S (&key));
 
   GNUNET_assert (NULL != upload_ref);
   ksls = GNUNET_new (struct KeyShareLookupState);
diff --git a/src/lib/testing_api_cmd_truth_store.c 
b/src/lib/testing_api_cmd_truth_store.c
index 6117aee..432a5d0 100644
--- a/src/lib/testing_api_cmd_truth_store.c
+++ b/src/lib/testing_api_cmd_truth_store.c
@@ -356,15 +356,17 @@ truth_store_traits (void *cls,
  * @param key_str a str you want to be a truth key
  * @return truthkey (must be freed)
  */
-struct ANASTASIS_CRYPTO_TruthKey *
+struct ANASTASIS_CRYPTO_TruthKey
 ANASTASIS_TESTING_make_truthkey (const char *key_str)
 {
-  struct ANASTASIS_CRYPTO_TruthKey *key;
+  struct ANASTASIS_CRYPTO_TruthKey key;
 
-  key = GNUNET_new (struct ANASTASIS_CRYPTO_TruthKey);
   GNUNET_CRYPTO_hash (key_str,
                       strlen (key_str),
-                      &key->key);
+                      &key.key);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "TruthKey created: %s\n",
+              TALER_B2S (&key));
   return key;
 }
 
@@ -383,7 +385,7 @@ ANASTASIS_TESTING_make_truth_example (const char *method,
                                       const char *mime_type,
                                       const struct GNUNET_HashCode answer,
                                       const struct
-                                      ANASTASIS_CRYPTO_TruthKey *key)
+                                      ANASTASIS_CRYPTO_TruthKey key)
 {
 
   json_t *truth_data;
@@ -391,28 +393,34 @@ ANASTASIS_TESTING_make_truth_example (const char *method,
   void *encrypted_truth;
   size_t size_encrypted_truth;
 
+  GNUNET_assert (NULL != &answer);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Hashed answer in truth example: %s\n",
               TALER_B2S (&answer));
+  GNUNET_assert (NULL != &key);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "TruthKey in truth example: %s\n",
-              TALER_B2S (key));
+              TALER_B2S (&key));
 
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
                               &keyshare_data,
                               sizeof (struct
                                       ANASTASIS_CRYPTO_EncryptedKeyShare));
-  ANASTASIS_CRYPTO_truth_encrypt (key,
+  GNUNET_assert (NULL != &keyshare_data);
+
+  ANASTASIS_CRYPTO_truth_encrypt (&key,
                                   &answer,
                                   sizeof (answer),
                                   &encrypted_truth,
                                   &size_encrypted_truth);
+  GNUNET_assert (NULL != encrypted_truth);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Encrypted truth in json: %s\n",
               TALER_b2s (encrypted_truth, size_encrypted_truth));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Encrypted truth size: %lu\n",
               size_encrypted_truth);
+
   truth_data = json_pack ("{s:o," /* keyshare_data */
                           " s:s," /* method */
                           " s:o," /* encrypted_truth */
@@ -425,10 +433,10 @@ ANASTASIS_TESTING_make_truth_example (const char *method,
                             size_encrypted_truth),
                           "truth_mime", mime_type
                           );
+  GNUNET_assert (NULL != truth_data);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Truth json before upload 0: %s\n",
               json_dumps (truth_data, JSON_COMPACT));
-  GNUNET_assert (NULL != truth_data);
   GNUNET_free (encrypted_truth);
   return truth_data;
 }
diff --git a/src/util/test_anastasis_crypto.c b/src/util/test_anastasis_crypto.c
index 07a0712..dc6eeff 100644
--- a/src/util/test_anastasis_crypto.c
+++ b/src/util/test_anastasis_crypto.c
@@ -208,8 +208,8 @@ test_truth (void)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "TRUTH_AFTER:   %s\n",
               TALER_b2s (plaintext, size_plaintext));
-  ret = strncmp (plaintext, test, strlen (test));
   GNUNET_assert (strlen (test) == size_plaintext);
+  ret = strncmp (plaintext, test, strlen (test));
   GNUNET_free (ciphertext);
   GNUNET_free (plaintext);
   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]