[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 01/02: worked on salt trait
From: |
gnunet |
Subject: |
[taler-anastasis] 01/02: worked on salt trait |
Date: |
Wed, 29 Apr 2020 23:23:57 +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 a5ca68b54394cf68f3d007237bcf5c634a1baa99
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Apr 29 19:55:53 2020 +0000
worked on salt trait
---
src/include/anastasis_testing_lib.h | 27 ++++++++++++++
src/lib/anastasis.c | 45 +++++++++++++++++-----
src/lib/testing_api_trait_salt.c | 74 +++++++++++++++++++++++++++++++++++++
src/lib/testing_cmd_truth_upload.c | 7 +---
4 files changed, 137 insertions(+), 16 deletions(-)
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index f7406a5..60ccef8 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -417,6 +417,33 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
ANASTASIS_CRYPTO_TruthKeyP key,
const char *upload_ref);
+
+/**
+ * Obtain a salt from @a cmd.
+ *
+ * @param cmd command to extract the salt from.
+ * @param index the salt's index number.
+ * @param s[out] set to the salt coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_salt (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_SaltP **s);
+
+
+/**
+ * Offer an salt.
+ *
+ * @param index the salt's index number.
+ * @param u the salt to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_salt (unsigned int index,
+ const struct ANASTASIS_CRYPTO_SaltP *s);
+
+
/**
* Make the "salt" command.
*
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 0a42a92..4d57a43 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -45,6 +45,11 @@ struct SaltState
* The /salt GET operation handle.
*/
struct ANASTASIS_SaltOperation *so;
+
+ /**
+ * Server Salt
+ */
+ const struct ANASTASIS_CRYPTO_SaltP *salt;
};
@@ -63,8 +68,28 @@ salt_cb (void *cls,
struct SaltState *ss = cls;
ss->so = NULL;
- GNUNET_assert (http_status == ss->http_status);
- GNUNET_assert (NULL != salt);
+
+ if (http_status != ss->http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u in %s:%u\n",
+ http_status,
+ __FILE__,
+ __LINE__);
+ GNUNET_break (0);
+ return;
+ }
+ if (NULL == salt)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Salt is NULL in %s:%u\n",
+ __FILE__,
+ __LINE__);
+ GNUNET_break (0);
+ return;
+ }
+
+ ss->salt = salt;
}
@@ -656,7 +681,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
tu = GNUNET_new (struct ANASTASIS_TruthUpload);
t = GNUNET_new (struct ANASTASIS_Truth);
- ss = GNUNET_new (struct ANASTASIS_CRYPTO_SaltP);
+ ss = GNUNET_new (struct SaltState);
tu->tc_cls = tc_cls;
tu->tpc_cls = tpc_cls;
tu->tpc = tpc;
@@ -673,27 +698,27 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
provider_url,
&salt_cb,
ss);
- if (NULL == &ss->so->salt)
+
+ if (NULL == id_data)
{
GNUNET_break (0);
return;
}
- if (NULL == id_data)
+ if (NULL == ss->salt)
{
- GNUNET_break (0);
- return;
+
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (&ss->so->salt),
- (unsigned long long) sizeof (ss->so->salt));
+ TALER_B2S (ss->salt),
+ (unsigned long long) sizeof (*ss->salt));
ANASTASIS_CRYPTO_keyshare_create (&t->key_share);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d keyshare is %s-%llu b\n", __FILE__, __LINE__,
TALER_B2S (&t->key_share),
(unsigned long long) sizeof (t->key_share));
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
- &ss->so->salt,
+ ss->salt,
&tu->id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d user identifier is %s-%llu b\n", __FILE__, __LINE__,
diff --git a/src/lib/testing_api_trait_salt.c b/src/lib/testing_api_trait_salt.c
new file mode 100644
index 0000000..0bf5f3a
--- /dev/null
+++ b/src/lib/testing_api_trait_salt.c
@@ -0,0 +1,74 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2020 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with TALER; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file lib/testing_api_trait_salt.c
+ * @brief traits to offer a hash
+ * @author Christian Grothoff
+ * @author Dominik Meister
+ * @author Dennis Neufeld
+ */
+#include "platform.h"
+#include "anastasis_testing_lib.h"
+
+#define ANASTASIS_TESTING_TRAIT_SALT "anastasis-salt"
+
+
+/**
+ * Obtain a salt from @a cmd.
+ *
+ * @param cmd command to extract the salt from.
+ * @param index the salt's index number.
+ * @param s[out] set to the salt coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_salt
+ (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_SaltP **s)
+{
+ return cmd->traits (cmd->cls,
+ (const void **) s,
+ ANASTASIS_TESTING_TRAIT_SALT,
+ index);
+}
+
+
+/**
+ * Offer an salt.
+ *
+ * @param index the salt's index number.
+ * @param u the salt to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_salt
+ (unsigned int index,
+ const struct ANASTASIS_CRYPTO_SaltP *s)
+{
+ struct TALER_TESTING_Trait ret = {
+ .index = index,
+ .trait_name = ANASTASIS_TESTING_TRAIT_SALT,
+ .ptr = (const void *) s
+ };
+ return ret;
+}
+
+
+/* end of testing_api_trait_salt.c */
diff --git a/src/lib/testing_cmd_truth_upload.c
b/src/lib/testing_cmd_truth_upload.c
index bdcd206..3f60aad 100644
--- a/src/lib/testing_cmd_truth_upload.c
+++ b/src/lib/testing_cmd_truth_upload.c
@@ -293,11 +293,6 @@ ANASTASIS_TESTING_make_id_data_example (const char
*id_data)
{
json_t *id;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d id data string is %s-%llu b\n", __FILE__, __LINE__,
- id_data,
- (unsigned long long) strlen (id_data));
-
id = json_pack ("{s:s}",
"id_data", id_data);
GNUNET_assert (NULL != id);
@@ -325,7 +320,7 @@ ANASTASIS_TESTING_make_id_data_example (const char *id_data)
struct TALER_TESTING_Command
ANASTASIS_TESTING_cmd_truth_upload (const char *label,
const char *anastasis_url,
- json_t *id_data,
+ const json_t *id_data,
const char *method,
const char *instructions,
const char *mime_type,
--
To stop receiving notification emails like this one, please contact
address@hidden.