gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (72e3029 -> dcefd8e)


From: gnunet
Subject: [taler-anastasis] branch master updated (72e3029 -> dcefd8e)
Date: Mon, 20 Apr 2020 23:18:20 +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 72e3029  modified salt request again :D
     new 584f35c  fixed uuid issue
     new 5e23bd3  worked on keyshare api
     new dcefd8e  worked on keyshare api, currently failing on decryption of 
encrypted truth from db (checktag fails)

The 3 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/backend/anastasis-httpd_truth.c       |  37 +++---
 src/lib/anastasis_api_keyshare_lookup.c   |  65 ++++++---
 src/lib/anastasis_api_truth_store.c       |   4 +-
 src/lib/test_anastasis_api.c              |   2 +-
 src/lib/testing_api_cmd_keyshare_lookup.c | 213 +++++++++++++++---------------
 src/lib/testing_api_cmd_truth_store.c     |  26 ++--
 src/util/anastasis_crypto.c               |  39 ++++--
 7 files changed, 216 insertions(+), 170 deletions(-)

diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 25de255..6805ab1 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -64,15 +64,15 @@ AH_handler_truth_get (struct MHD_Connection *connection,
     uuid_parse (uuid_str, uuid);
 
     GNUNET_assert (NULL != uuid_str);
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Uuid from Url (keyshare lookup): %s\n",
-                uuid_str);
+                TALER_B2S (&uuid));
 
     challenge_response_s = MHD_lookup_connection_value (connection,
                                                         MHD_GET_ARGUMENT_KIND,
                                                         "response");
     GNUNET_assert (NULL != challenge_response_s);
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Challenge response from url (keyshare lookup): %s\n",
                 challenge_response_s);
   }
@@ -83,6 +83,8 @@ AH_handler_truth_get (struct MHD_Connection *connection,
     tdk = MHD_lookup_connection_value (connection,
                                        MHD_HEADER_KIND,
                                        "Truth-Decryption-Key");
+    if (NULL == tdk)
+      return MHD_HTTP_PRECONDITION_FAILED;
 
     if ( (NULL != tdk) &&
          (GNUNET_OK !=
@@ -99,8 +101,10 @@ AH_handler_truth_get (struct MHD_Connection *connection,
                                          TALER_EC_SYNC_BAD_IF_MATCH,
                                          "Truth-Decryption-Key does not 
include a base32-encoded decryption key");
     }
-    else
-      return MHD_HTTP_PRECONDITION_FAILED;
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "TruthKey from header: %s\n",
+                TALER_B2S (&truth_key));
   }
   {
     // load encrypted truth from db
@@ -108,14 +112,17 @@ AH_handler_truth_get (struct MHD_Connection *connection,
 
     qs = db->get_escrow_challenge (db->cls,
                                    &uuid,
-                                   encrypted_truth,
+                                   &encrypted_truth,
                                    &encrypted_truth_size,
                                    &truth_mime,
                                    &method);
     if (qs != ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT)
     {
-      return qs;
+      return MHD_HTTP_NOT_FOUND;
     }
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Encrypted truth from db: %s\n",
+                TALER_b2s (encrypted_truth, encrypted_truth_size));
   }
   {
     // decrypt encrypted_truth
@@ -127,7 +134,11 @@ AH_handler_truth_get (struct MHD_Connection *connection,
   }
   {
     // validate challenge response
-    if (strcmp (method, "Secure Question") == 0)
+    GNUNET_assert (strlen (method) == strlen ("Secure-Question"));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Method from db: %s\n",
+                method);
+    if (strncmp (method, "Secure-Question", strlen ("Secure-Question")) == 0)
     {
       GNUNET_CRYPTO_hash_from_string (challenge_response_s,
                                       &challenge_response);
@@ -155,24 +166,20 @@ AH_handler_truth_get (struct MHD_Connection *connection,
 
         if (qs != ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT)
         {
-          return qs;
+          return MHD_HTTP_NOT_FOUND;
         }
 
         struct MHD_Response *resp;
-        resp = MHD_create_response_from_buffer (sizeof (encrypted_keyshare),
+        resp = MHD_create_response_from_buffer (encrypted_keyshare_size,
                                                 encrypted_keyshare,
                                                 MHD_RESPMEM_MUST_FREE);
-        GNUNET_break (MHD_YES ==
-                      MHD_add_response_header (resp,
-                                               
MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
-                                               "*"));
+        TALER_MHD_add_global_headers (resp);
         ret = MHD_queue_response (connection,
                                   MHD_HTTP_OK,
                                   resp);
         MHD_destroy_response (resp);
         return ret;
       }
-
     }
   }
   GNUNET_free_non_null (decrypted_truth);
diff --git a/src/lib/anastasis_api_keyshare_lookup.c 
b/src/lib/anastasis_api_keyshare_lookup.c
index a70596a..653e858 100644
--- a/src/lib/anastasis_api_keyshare_lookup.c
+++ b/src/lib/anastasis_api_keyshare_lookup.c
@@ -31,6 +31,7 @@
 #include <taler/taler_util.h>
 #include <taler/taler_signatures.h>
 #include "anastasis_service.h"
+#include "anastasis_api_curl_defaults.h"
 
 
 /**
@@ -250,63 +251,83 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context 
*ctx,
 {
   struct ANASTASIS_KeyShareLookupOperation *kslo;
   CURL *eh;
-  char *uuid_str;
+  struct curl_slist *job_headers;
+  char uuid_str[37];
   char *hashed_answer_str;
   char *path;
 
+  job_headers = NULL;
+  {
+    struct curl_slist *ext;
+    char *val;
+    char *hdr;
+
+    /* Set Truth-Decryption-Key header */
+    val = GNUNET_STRINGS_data_to_string_alloc (truth_key,
+                                               sizeof (*truth_key));
+    GNUNET_asprintf (&hdr,
+                     "Truth-Decryption-Key: %s",
+                     val);
+    GNUNET_free (val);
+    ext = curl_slist_append (job_headers,
+                             hdr);
+    GNUNET_free (hdr);
+    if (NULL == ext)
+    {
+      GNUNET_break (0);
+      curl_slist_free_all (job_headers);
+      return NULL;
+    }
+    job_headers = ext;
+  }
   kslo = GNUNET_new (struct ANASTASIS_KeyShareLookupOperation);
   kslo->ctx = ctx;
   kslo->cb = cb;
   kslo->cb_cls = cb_cls;
   kslo->truth_key = truth_key;
-    << << << < HEAD
 
-    GNUNET_assert (NULL != truth_uuid);
-  uuid_str = GNUNET_STRINGS_data_to_string_alloc (truth_uuid,
-                                                  sizeof (*truth_uuid));
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+  GNUNET_assert (GNUNET_NO == uuid_is_null (*truth_uuid));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "UUID in keyshare lookup: %s\n",
+              TALER_B2S (truth_uuid));
+  uuid_unparse (*truth_uuid, uuid_str);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "UUID in keyshare lookup:  %s\n",
               uuid_str);
   GNUNET_assert (NULL != hashed_answer);
-  ====== =
-    uuid_str = GNUNET_STRINGS_data_to_string_alloc (truth_uuid,
-                                                    sizeof (*truth_uuid));
-  >> >> >> > f6a488c ... modified salt request
   hashed_answer_str = GNUNET_STRINGS_data_to_string_alloc (hashed_answer,
                                                            sizeof (struct
                                                                    
GNUNET_HashCode));
   GNUNET_asprintf (&path,
                    "truth/%s",
                    uuid_str);
+  // GNUNET_free (uuid_str);
   kslo->url = TALER_url_join (backend_url,
                               path,
                               "response",
                               hashed_answer_str,
                               NULL);
-  GNUNET_free (path);
-  GNUNET_free (uuid_str);
-  GNUNET_free (hashed_answer_str);
-    << << << < HEAD
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Url get request (keyshare lookup): %s\n",
-                kslo->url);
-  ====== =
-    >> >> >> > f6a488c ... modified salt request
-    eh = curl_easy_init ();
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Url get request (keyshare lookup): %s\n",
+              kslo->url);
+  eh = ANASTASIS_curl_easy_get_ (kslo->url);
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_HEADERFUNCTION,
                                    &handle_header));
   GNUNET_assert ((CURLE_OK == curl_easy_setopt (eh,
-                                                CURLOPT_URL,
+                                                CURLOPT_HEADERDATA,
                                                 kslo)));
   kslo->cb = cb;
   kslo->cb_cls = cb_cls;
   kslo->job = GNUNET_CURL_job_add_raw (ctx,
                                        eh,
-                                       GNUNET_NO,
+                                       job_headers,
                                        &handle_keyshare_lookup_finished,
                                        kslo);
+  GNUNET_free (path);
+  GNUNET_free (hashed_answer_str);
+  curl_slist_free_all (job_headers);
   return kslo;
 }
 
diff --git a/src/lib/anastasis_api_truth_store.c 
b/src/lib/anastasis_api_truth_store.c
index 7552364..f4c744d 100644
--- a/src/lib/anastasis_api_truth_store.c
+++ b/src/lib/anastasis_api_truth_store.c
@@ -316,8 +316,10 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
                   "No uuid set");
       return NULL;
     }
-
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "URL before curl:  %s\n",
+              tso->url);
   tso->ctx = ctx;
   tso->cb = cb;
   tso->cb_cls = cb_cls;
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 317f7af..2ecfd21 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -238,7 +238,7 @@ run (void *cls,
                                        MHD_HTTP_NO_CONTENT,
                                        ANASTASIS_TESTING_TSO_NONE,
                                        ANASTASIS_TESTING_make_truth_example (
-                                         "Truth method",
+                                         "Secure-Question",
                                          "Truth mime",
                                          ANASTASIS_TESTING_make_hashed_answer (
                                            "Hashed-Answer",
diff --git a/src/lib/testing_api_cmd_keyshare_lookup.c 
b/src/lib/testing_api_cmd_keyshare_lookup.c
index ec2f491..4807f01 100644
--- a/src/lib/testing_api_cmd_keyshare_lookup.c
+++ b/src/lib/testing_api_cmd_keyshare_lookup.c
@@ -131,56 +131,53 @@ keyshare_lookup_run (void *cls,
       TALER_TESTING_interpreter_fail (ksls->is);
       return;
     }
-      << << << < HEAD
-        {
-        const uuid_t *uuid;
-
-        if (GNUNET_OK !=
-            ANASTASIS_TESTING_get_trait_uuid (upload_cmd,
-                                              0,
-                                              &uuid))
-        {
-          GNUNET_break (0);
-          TALER_TESTING_interpreter_fail (ksls->is);
-          return;
-        }
-        ksls->truth_uuid = uuid;
-        if (NULL == ksls->truth_uuid)
-        {
-          GNUNET_break (0);
-          TALER_TESTING_interpreter_fail (ksls->is);
-          return;
-        }
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "Uuid from trait: %s\n",
-                    TALER_B2S (ksls->truth_uuid));
-
-        ====== =
-          if (GNUNET_OK !=
-              ANASTASIS_TESTING_get_trait_uuid (upload_cmd,
-                                                0,
-                                                &ksls->truth_uuid))
-        {
-          GNUNET_break (0);
-          TALER_TESTING_interpreter_fail (ksls->is);
-          return;
-          >> >> >> > f6a488c ... modified salt request
-        }
-      }
-      ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
-                                              ksls->anastasis_url,
-                                              ksls->truth_uuid,
-                                              ksls->truth_key,
-                                              &ksls->hashed_answer,
-                                              &keyshare_lookup_cb,
-                                              ksls);
-    if (NULL == ksls->kslo)
     {
-      GNUNET_break (0);
-      TALER_TESTING_interpreter_fail (ksls->is);
-      return;
+      const uuid_t *uuid;
+
+      if (GNUNET_OK !=
+          ANASTASIS_TESTING_get_trait_uuid (upload_cmd,
+                                            0,
+                                            &uuid))
+      {
+        GNUNET_break (0);
+        TALER_TESTING_interpreter_fail (ksls->is);
+        return;
+      }
+      ksls->truth_uuid = uuid;
+      if (NULL == ksls->truth_uuid)
+      {
+        GNUNET_break (0);
+        TALER_TESTING_interpreter_fail (ksls->is);
+        return;
+      }
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Uuid from trait: %s\n",
+                  TALER_B2S (ksls->truth_uuid));
+      if (GNUNET_OK !=
+          ANASTASIS_TESTING_get_trait_uuid (upload_cmd,
+                                            0,
+                                            &ksls->truth_uuid))
+      {
+        GNUNET_break (0);
+        TALER_TESTING_interpreter_fail (ksls->is);
+        return;
+      }
     }
   }
+  ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
+                                          ksls->anastasis_url,
+                                          ksls->truth_uuid,
+                                          ksls->truth_key,
+                                          &ksls->hashed_answer,
+                                          &keyshare_lookup_cb,
+                                          ksls);
+  if (NULL == ksls->kslo)
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (ksls->is);
+    return;
+  }
+}
 
 
 /**
@@ -190,22 +187,22 @@ keyshare_lookup_run (void *cls,
  * @param cls closure.
  * @param cmd command being freed.
  */
-  static void
-  keyshare_lookup_cleanup (void *cls,
-                           const struct TALER_TESTING_Command *cmd)
-  {
-    struct KeyShareLookupState *ksls = cls;
+static void
+keyshare_lookup_cleanup (void *cls,
+                         const struct TALER_TESTING_Command *cmd)
+{
+  struct KeyShareLookupState *ksls = cls;
 
-    if (NULL != ksls->kslo)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Command '%s' did not complete (keyshare lookup)\n",
-                  cmd->label);
-      ANASTASIS_keyshare_lookup_cancel (ksls->kslo);
-      ksls->kslo = NULL;
-    }
-    GNUNET_free (ksls);
+  if (NULL != ksls->kslo)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Command '%s' did not complete (keyshare lookup)\n",
+                cmd->label);
+    ANASTASIS_keyshare_lookup_cancel (ksls->kslo);
+    ksls->kslo = NULL;
   }
+  GNUNET_free (ksls);
+}
 
 
 /**
@@ -215,19 +212,19 @@ keyshare_lookup_run (void *cls,
  * @param size_answer size of the answer
  * @return hash of the answer
  */
-  struct GNUNET_HashCode
-  ANASTASIS_TESTING_make_hashed_answer (const void *answer,
-                                        size_t size_answer)
-  {
-    struct GNUNET_HashCode hashed_answer;
-    GNUNET_CRYPTO_hash (answer,
-                        size_answer,
-                        &hashed_answer);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Hashed answer: %s\n",
-                TALER_B2S (&hashed_answer));
-    return hashed_answer;
-  }
+struct GNUNET_HashCode
+ANASTASIS_TESTING_make_hashed_answer (const void *answer,
+                                      size_t size_answer)
+{
+  struct GNUNET_HashCode hashed_answer;
+  GNUNET_CRYPTO_hash (answer,
+                      size_answer,
+                      &hashed_answer);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hashed answer: %s\n",
+              TALER_B2S (&hashed_answer));
+  return hashed_answer;
+}
 
 
 /**
@@ -242,42 +239,42 @@ keyshare_lookup_run (void *cls,
  * @param upload_ref reference to upload command
  * @return the command
  */
-  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 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;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hashed answer in keyshare lookup cmd: %s\n",
+              TALER_B2S (&answer));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "TruthKey in keyshare lookup cmd: %s\n",
+              TALER_B2S (key));
+
+  GNUNET_assert (NULL != upload_ref);
+  ksls = GNUNET_new (struct KeyShareLookupState);
+  ksls->http_status = http_status;
+  ksls->anastasis_url = anastasis_url;
+  ksls->upload_reference = upload_ref;
+  ksls->hashed_answer = answer;
+  ksls->truth_key = key;
   {
-    struct KeyShareLookupState *ksls;
-
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Hashed answer in keyshare lookup cmd: %s\n",
-                TALER_B2S (&answer));
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "TruthKey in keyshare lookup cmd: %s\n",
-                TALER_B2S (key));
-
-    GNUNET_assert (NULL != upload_ref);
-    ksls = GNUNET_new (struct KeyShareLookupState);
-    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,
-        .label = label,
-        .run = &keyshare_lookup_run,
-        .cleanup = &keyshare_lookup_cleanup
-      };
-
-      return cmd;
-    }
+    struct TALER_TESTING_Command cmd = {
+      .cls = ksls,
+      .label = label,
+      .run = &keyshare_lookup_run,
+      .cleanup = &keyshare_lookup_cleanup
+    };
+
+    return cmd;
   }
+}
 
 
 /* end of testing_api_cmd_keyshare_lookup.c */
\ No newline at end of file
diff --git a/src/lib/testing_api_cmd_truth_store.c 
b/src/lib/testing_api_cmd_truth_store.c
index bb52a4c..6117aee 100644
--- a/src/lib/testing_api_cmd_truth_store.c
+++ b/src/lib/testing_api_cmd_truth_store.c
@@ -51,7 +51,7 @@ struct TruthStoreState
   /**
    * Uuid of truth
    */
-  const uuid_t *truth_uuid;
+  uuid_t truth_uuid;
 
   /**
    * Hash of the current upload.
@@ -264,20 +264,16 @@ truth_store_run (void *cls,
   }
   {
     // Create an uuid
-    uuid_t truth_uuid;
-    uuid_generate (truth_uuid);
-    tss->truth_uuid = &truth_uuid;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Uuid created: %s\n",
-                TALER_B2S (&truth_uuid));
+    uuid_generate (tss->truth_uuid);
+    GNUNET_assert (GNUNET_NO == uuid_is_null (tss->truth_uuid));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Uuid stored in tss: %s\n",
-                TALER_B2S (tss->truth_uuid));
+                TALER_B2S (&tss->truth_uuid));
   }
 
   tss->tso = ANASTASIS_truth_store (is->ctx,
                                     tss->anastasis_url,
-                                    tss->truth_uuid,
+                                    &tss->truth_uuid,
                                     tss->truth_data,
                                     (0 !=
                                      (ANASTASIS_TESTING_TSO_REQUEST_PAYMENT
@@ -341,11 +337,7 @@ truth_store_traits (void *cls,
     ANASTASIS_TESTING_make_trait_hash (ANASTASIS_TESTING_TRAIT_HASH_CURRENT,
                                        &tss->curr_hash),
     ANASTASIS_TESTING_make_trait_uuid (0,
-                                       << << << < HEAD
-                                       tss->truth_uuid),
-    ====== =
-      &tss->truth_uuid),
-    >> >> >> > f6a488c ... modified salt request
+                                       &tss->truth_uuid),
     TALER_TESTING_make_trait_order_id (0,
                                        tss->payment_order_id),
     TALER_TESTING_trait_end ()
@@ -415,6 +407,12 @@ ANASTASIS_TESTING_make_truth_example (const char *method,
                                   sizeof (answer),
                                   &encrypted_truth,
                                   &size_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 */
diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index 5c3b62e..19cb076 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -87,6 +87,14 @@ anastasis_encrypt (const void *key,
                    void **res,
                    size_t *res_size)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "KEY_E:   %s\n",
+              TALER_b2s (key,
+                         key_len));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "PLAINTEXT_E:   %s\n",
+              TALER_b2s (data,
+                         data_size));
   struct ANASTASIS_CRYPTO_Nonce *nonce;
   gcry_cipher_hd_t cipher;
   struct ANASTASIS_CRYPTO_SymKey sym_key;
@@ -114,6 +122,9 @@ anastasis_encrypt (const void *key,
               salt,
               &sym_key,
               &iv);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "NONCE_E:   %s\n",
+              TALER_B2S (nonce));
   GNUNET_assert (0 ==
                  gcry_cipher_open (&cipher,
                                    GCRY_CIPHER_AES256,
@@ -134,21 +145,22 @@ anastasis_encrypt (const void *key,
                                       data_size,
                                       data,
                                       data_size));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "CIPHERTEXT_E:   %s\n",
+              TALER_b2s (ciphertext,
+                         strlen (ciphertext)));
   GNUNET_assert (0 ==
                  gcry_cipher_gettag (cipher,
                                      tag,
                                      sizeof (struct ANASTASIS_CRYPTO_AesTag)));
-  gcry_cipher_close (cipher);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "NONCE_E:   %s\n",
-              TALER_B2S (nonce));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "TAG_E:   %s\n",
               TALER_B2S (tag));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "CIPHERTEXT_E:   %s\n",
-              TALER_b2s (ciphertext,
-                         strlen (ciphertext)));
+              "RES_E:   %s\n",
+              TALER_b2s (*res,
+                         *res_size));
+  gcry_cipher_close (cipher);
 }
 
 
@@ -172,6 +184,10 @@ anastasis_decrypt (const void *key,
                    void **res,
                    size_t *res_size)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "KEY_D:   %s\n",
+              TALER_b2s (key,
+                         key_len));
   struct ANASTASIS_CRYPTO_Nonce *nonce;
   gcry_cipher_hd_t cipher;
   struct ANASTASIS_CRYPTO_SymKey sym_key;
@@ -188,18 +204,19 @@ anastasis_decrypt (const void *key,
                  - sizeof (struct ANASTASIS_CRYPTO_Nonce)
                  - sizeof (struct ANASTASIS_CRYPTO_AesTag));
   nonce = (struct ANASTASIS_CRYPTO_Nonce *) data;
-  tag = (struct ANASTASIS_CRYPTO_AesTag *) &nonce[1];
-  ciphertext = (char *) &tag[1];
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "NONCE_D:   %s\n",
               TALER_B2S (nonce));
+  tag = (struct ANASTASIS_CRYPTO_AesTag *) &nonce[1];
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "TAG_D:   %s\n",
               TALER_B2S (tag));
+  ciphertext = (char *) &tag[1];
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "CIPHERTEXT_D:   %s\n",
               TALER_b2s (ciphertext,
                          strlen (ciphertext)));
+
   get_iv_key (key,
               key_len,
               nonce,
@@ -225,6 +242,10 @@ anastasis_decrypt (const void *key,
                                            *res_size,
                                            ciphertext,
                                            *res_size));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "PLAINTEXT_D:   %s\n",
+              TALER_b2s (*res,
+                         *res_size));
   GNUNET_assert (0 ==
                  gcry_cipher_checktag (cipher,
                                        tag,

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



reply via email to

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