[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: backend work
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: backend work |
Date: |
Wed, 14 Oct 2020 00:24:38 +0200 |
This is an automated email from the git hooks/post-receive script.
ds-meister pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new d9dbf48 backend work
d9dbf48 is described below
commit d9dbf48d96d51d29faccc581b6c7148f18b92da8
Author: Dominik Meister <dominik.meister@hotmail.ch>
AuthorDate: Wed Oct 14 00:23:42 2020 +0200
backend work
---
src/backend/anastasis-httpd.c | 4 +--
src/backend/anastasis-httpd_policy_upload.c | 4 +--
src/backend/anastasis-httpd_truth.c | 9 ++++--
src/include/anastasis_service.h | 5 ++--
src/include/anastasis_testing_lib.h | 4 +--
src/lib/anastasis.c | 44 ++++++++++++++++++-----------
src/lib/anastasis_api_keyshare_lookup.c | 16 +++++------
src/lib/test_anastasis_api.c | 36 +++++++++++++++++++++--
src/lib/testing_api_cmd_keyshare_lookup.c | 12 ++++----
9 files changed, 88 insertions(+), 46 deletions(-)
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index f789a00..7e29ef3 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -353,7 +353,7 @@ url_handler (void *cls,
{
return AH_handler_truth_get (connection,
url,
- hc);
+ con_cls);
}
if (0 == strcmp (method,
MHD_HTTP_METHOD_POST))
@@ -579,7 +579,7 @@ run (void *cls,
NULL);
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("anastasis-httpd",
- "WARNING",
+ "DEBUG",
NULL));
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (config,
diff --git a/src/backend/anastasis-httpd_policy_upload.c
b/src/backend/anastasis-httpd_policy_upload.c
index ae7546a..2cd5b18 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -412,7 +412,7 @@ check_payment_cb (void *cls,
puc->cpo = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Payment status checked: %s\n",
- osr->paid ? "paid" : "unpaid");
+ osr->status ? "paid" : "unpaid");
GNUNET_CONTAINER_DLL_remove (puc_head,
puc_tail,
puc);
@@ -423,7 +423,7 @@ check_payment_cb (void *cls,
* FIXME: DELETE
GNUNET_break ( (GNUNET_NO == refunded) &&
(NULL == refund_amount) );
- */if (osr->paid)
+ */if (osr->status)
{
enum ANASTASIS_DB_QueryStatus qs;
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index b22a62c..6dfa245 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -26,7 +26,7 @@
#include "anastasis-httpd_truth.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_rest_lib.h>
-#include <anastasis_authorization_plugin.h>
+#include "anastasis_authorization_plugin.h"
#include <taler/taler_merchant_service.h>
/**
@@ -429,7 +429,7 @@ check_payment_cb (void *cls,
gc->cpo = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Payment status checked: %s\n",
- osr->paid ? "paid" : "unpaid");
+ osr->status ? "paid" : "unpaid");
GNUNET_CONTAINER_DLL_remove (gc_head,
gc_tail,
gc);
@@ -440,7 +440,7 @@ check_payment_cb (void *cls,
* FIXME: DELETE
GNUNET_break ( (GNUNET_NO == refunded) &&
(NULL == refund_amount) );
- */if (osr->paid)
+ */if (osr->status)
{
enum ANASTASIS_DB_QueryStatus qs;
@@ -594,6 +594,9 @@ AH_handler_truth_get (struct MHD_Connection *connection,
const char *url,
struct TM_HandlerContext *hc)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Handling truth get\n");
+
struct GetContext *gc = hc->ctx;
struct ANASTASIS_CRYPTO_TruthPublicKeyP truth_public_key;
struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index d192afc..17ba57b 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -520,7 +520,7 @@ typedef void
* @param backend_url base URL of the merchant backend
* @param truth_public_key identification of the Truth
* @param truth_key Key used to Decrypt the Truth on the Server
- * @param hashed_answer Hashed answer for the Securityquestion
+ * @param answer Answer for the different authentication methods(code, hash)
* @param cb callback which will work the response gotten from the backend
* @param cb_cls closure to pass to the callback
* @return handle for this operation, NULL upon errors
@@ -531,11 +531,10 @@ ANASTASIS_keyshare_lookup (
const char *backend_url,
const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
- const struct GNUNET_HashCode *hashed_answer,
+ const char *answer,
ANASTASIS_KeyShareLookupCallback cb,
void *cb_cls);
-
/**
* Cancel a GET /truth request.
*
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index 079dfc9..22634aa 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -408,7 +408,7 @@ 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 answer (response to challenge)
* @param key key to decrypt truth
* @param upload_ref reference to upload command
* @return the command
@@ -417,7 +417,7 @@ 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,
+ char *answer,
const struct
ANASTASIS_CRYPTO_TruthKeyP key,
const char *upload_ref);
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index e943284..42c8e6b 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -368,6 +368,7 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
c->af = af;
c->ctx = ctx;
c->af_cls = af_cls;
+ char *answer_str;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d challenge answer is %s\n", __FILE__, __LINE__,
(char *) answer);
@@ -379,23 +380,34 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context
*ctx,
(unsigned long long) sizeof (c->truth_public_key),
c->url);
- struct GNUNET_HashCode hashed_answer;
- GNUNET_CRYPTO_hash (answer,
- answer_size,
- &hashed_answer);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d challenge is answered with %s \n", __FILE__, __LINE__,
- TALER_b2s (&hashed_answer, sizeof(struct GNUNET_HashCode)));
-
c->http_status = MHD_HTTP_OK;
- c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
- c->url,
- &c->truth_public_key,
- &c->truth_key,
- &hashed_answer,
- &keyshare_lookup_cb,
- c);
+ if (0 == strcmp (c->escrow_method,"question"))
+ {
+
+ struct GNUNET_HashCode hashed_answer;
+ GNUNET_CRYPTO_hash (answer,
+ answer_size,
+ &hashed_answer);
+ c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
+ c->url,
+ &c->truth_public_key,
+ &c->truth_key,
+ answer_str,
+ &keyshare_lookup_cb,
+ c);
+ }
+ else
+ {
+ answer_str = GNUNET_STRINGS_data_to_string_alloc (answer,
+ answer_size);
+ c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
+ c->url,
+ &c->truth_public_key,
+ &c->truth_key,
+ answer_str,
+ &keyshare_lookup_cb,
+ c);
+ }
}
diff --git a/src/lib/anastasis_api_keyshare_lookup.c
b/src/lib/anastasis_api_keyshare_lookup.c
index a70e140..e1ec1a4 100644
--- a/src/lib/anastasis_api_keyshare_lookup.c
+++ b/src/lib/anastasis_api_keyshare_lookup.c
@@ -235,7 +235,8 @@ handle_header (char *buffer,
* @param backend_url base URL of the merchant backend
* @param truth_public_key identification of the Truth
* @param truth_key Key used to Decrypt the Truth on the Server
- * @param hashed_answer Hashed answer for the Securityquestion
+ * @param answer Answer for the different authentication methods(code, hash)
+ * @param answer_length size of the answer
* @param cb callback which will work the response gotten from the backend
* @param cb_cls closure to pass to the callback
* @return handle for this operation, NULL upon errors
@@ -246,14 +247,13 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context
*ctx,
const struct
ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
- const struct GNUNET_HashCode *hashed_answer,
+ const char *answer,
ANASTASIS_KeyShareLookupCallback cb,
void *cb_cls)
{
struct ANASTASIS_KeyShareLookupOperation *kslo;
CURL *eh;
struct curl_slist *job_headers;
- char *hashed_answer_str;
char *path;
job_headers = NULL;
@@ -294,11 +294,10 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context
*ctx,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"truth public key in keyshare lookup: %s\n",
pub_key_str);
+ /*FIXME */
- GNUNET_assert (NULL != hashed_answer);
- hashed_answer_str = GNUNET_STRINGS_data_to_string_alloc (hashed_answer,
- sizeof (struct
-
GNUNET_HashCode));
+
+ GNUNET_assert (NULL != answer);
GNUNET_asprintf (&path,
"truth/%s",
pub_key_str);
@@ -306,7 +305,7 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
kslo->url = TALER_url_join (backend_url,
path,
"response",
- hashed_answer_str,
+ answer,
NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Url get request (keyshare lookup): %s\n",
@@ -327,7 +326,6 @@ ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
&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/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 7d3513b..2562ab3 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -106,6 +106,10 @@ static struct GNUNET_OS_Process *merchantd;
* Anastasis process.
*/
static struct GNUNET_OS_Process *anastasisd;
+/**
+ * Code for answering challenge
+ */
+static char *answer_str;
/**
@@ -257,13 +261,32 @@ run (void *cls,
ANASTASIS_TESTING_cmd_keyshare_lookup ("keyshare-lookup-1",
anastasis_url,
MHD_HTTP_OK,
-
ANASTASIS_TESTING_make_hashed_answer (
- "Hashed-Answer",
- strlen ("Hashed-Answer")),
+ answer_str,
ANASTASIS_TESTING_make_truthkey (
"Truth-Key"),
"truth-store-1"),
+ ANASTASIS_TESTING_cmd_truth_store ("truth-store-2",
+ anastasis_url,
+ NULL,
+ MHD_HTTP_NO_CONTENT,
+ ANASTASIS_TESTING_TSO_NONE,
+ ANASTASIS_TESTING_make_truth_example (
+ "file",
+ "Truth mime",
+ ANASTASIS_TESTING_make_hashed_answer (
+ "Hashed-Answer",
+ strlen ("Hashed-Answer")),
+ ANASTASIS_TESTING_make_truthkey (
+ "Truth-Key"))),
+
+ ANASTASIS_TESTING_cmd_keyshare_lookup ("keyshare-lookup-2",
+ anastasis_url,
+ MHD_HTTP_OK,
+ "42",
+ ANASTASIS_TESTING_make_truthkey (
+ "Truth-Key"),
+ "truth-store-2"),
TALER_TESTING_cmd_end ()
};
@@ -306,6 +329,13 @@ int
main (int argc,
char *const *argv)
{
+ struct GNUNET_HashCode hash;
+ hash = ANASTASIS_TESTING_make_hashed_answer (
+ "Hashed-Answer",
+ strlen ("Hashed-Answer"));
+ answer_str = GNUNET_STRINGS_data_to_string_alloc (&hash,
+ sizeof(struct
+ GNUNET_HashCode));
unsigned int ret;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
diff --git a/src/lib/testing_api_cmd_keyshare_lookup.c
b/src/lib/testing_api_cmd_keyshare_lookup.c
index 7218d27..f1bb85f 100644
--- a/src/lib/testing_api_cmd_keyshare_lookup.c
+++ b/src/lib/testing_api_cmd_keyshare_lookup.c
@@ -53,9 +53,9 @@ struct KeyShareLookupState
struct ANASTASIS_KeyShareLookupOperation *kslo;
/**
- * Hashed answer to a challenge
+ * answer to a challenge
*/
- struct GNUNET_HashCode hashed_answer;
+ char *answer;
/**
* Key to decrypt truth
@@ -165,7 +165,7 @@ keyshare_lookup_run (void *cls,
ksls->anastasis_url,
ksls->truth_public_key,
&ksls->truth_key,
- &ksls->hashed_answer,
+ ksls->answer,
&keyshare_lookup_cb,
ksls);
if (NULL == ksls->kslo)
@@ -240,7 +240,7 @@ 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,
+ char *answer,
const struct
ANASTASIS_CRYPTO_TruthKeyP key,
const char *upload_ref)
@@ -259,7 +259,7 @@ 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->answer = answer;
ksls->truth_key = key;
{
struct TALER_TESTING_Command cmd = {
@@ -274,4 +274,4 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
}
-/* end of testing_api_cmd_keyshare_lookup.c */
\ No newline at end of file
+/* end of testing_api_cmd_keyshare_lookup.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.