[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 02/03: worked on keyshare api
From: |
gnunet |
Subject: |
[taler-anastasis] 02/03: worked on keyshare api |
Date: |
Mon, 20 Apr 2020 23:18:22 +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 5e23bd319190f7014e0194400e9a5d4225f212d5
Author: Dennis Neufeld <address@hidden>
AuthorDate: Mon Apr 20 13:55:59 2020 +0000
worked on keyshare api
---
src/backend/anastasis-httpd_truth.c | 31 +++++++++++++++++--------------
src/lib/anastasis_api_keyshare_lookup.c | 16 +++++++++-------
src/lib/test_anastasis_api.c | 2 +-
3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index 755cd78..ed3fbbd 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -64,10 +64,7 @@ AH_handler_truth_get (struct MHD_Connection *connection,
uuid_parse (uuid_str, uuid);
GNUNET_assert (NULL != uuid_str);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Uuid from Url (keyshare lookup): %s\n",
- uuid_str);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Uuid from Url (keyshare lookup): %s\n",
TALER_B2S (&uuid));
@@ -75,7 +72,7 @@ AH_handler_truth_get (struct MHD_Connection *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);
}
@@ -104,6 +101,10 @@ AH_handler_truth_get (struct MHD_Connection *connection,
}
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
@@ -117,8 +118,10 @@ AH_handler_truth_get (struct MHD_Connection *connection,
&method);
if (qs != ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT)
{
- return qs;
+ return MHD_HTTP_NOT_FOUND;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Success, found truth information in db\n");
}
{
// decrypt encrypted_truth
@@ -130,7 +133,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 truth information: %s\n",
+ method);
+ if (strncmp (method, "Secure-Question", strlen ("Secure-Question")) == 0)
{
GNUNET_CRYPTO_hash_from_string (challenge_response_s,
&challenge_response);
@@ -158,24 +165,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 c7e47ab..1e4e805 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"
/**
@@ -265,7 +266,7 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
"UUID in keyshare lookup: %s\n",
TALER_B2S (truth_uuid));
uuid_unparse (*truth_uuid, uuid_str);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"UUID in keyshare lookup: %s\n",
uuid_str);
GNUNET_assert (NULL != hashed_answer);
@@ -275,24 +276,23 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context
*ctx,
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);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Url get request (keyshare lookup): %s\n",
kslo->url);
- eh = curl_easy_init ();
+ // eh = curl_easy_init ();
+ 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;
@@ -301,6 +301,8 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
GNUNET_NO,
&handle_keyshare_lookup_finished,
kslo);
+ GNUNET_free (path);
+ GNUNET_free (hashed_answer_str);
return kslo;
}
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",
--
To stop receiving notification emails like this one, please contact
address@hidden.