[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 11/13: worked on testing policy creation
From: |
gnunet |
Subject: |
[taler-anastasis] 11/13: worked on testing policy creation |
Date: |
Sun, 03 May 2020 18:02:35 +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 649e611b5d3774b786c147ed97142b1a5099c37b
Author: Dennis Neufeld <address@hidden>
AuthorDate: Sat May 2 15:50:07 2020 +0000
worked on testing policy creation
---
src/lib/anastasis.c | 42 ++++++++++-
src/lib/test_anastasis.c | 6 ++
src/lib/testing_cmd_policy_create.c | 134 +++++++++++++++++++++++++++++-------
3 files changed, 154 insertions(+), 28 deletions(-)
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 6cd0904..ed226e2 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -912,18 +912,56 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
p = GNUNET_new (struct ANASTASIS_Policy);
struct ANASTASIS_CRYPTO_KeyShareP key_shares[truths_len];
uuid_t uuids[truths_len];
+
+ GNUNET_assert (NULL != truths);
+ GNUNET_assert (truths_len > 0);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d truth array is %s\n", __FILE__, __LINE__,
+ TALER_b2s (*truths,
+ truths_len
+ * sizeof (struct ANASTASIS_Truth)));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d truth array length is %i\n", __FILE__, __LINE__,
+ truths_len);
+
for (unsigned int i = 0; i < truths_len; i++)
{
key_shares[i] = truths[i]->key_share;
- memcpy (uuids[i], truths[i]->uuid, sizeof(uuid_t));
+ GNUNET_assert (NULL != &key_shares[i]);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d key share is %s-%llu b\n", __FILE__, __LINE__,
+ TALER_B2S (&key_shares[i]),
+ (unsigned long long) sizeof (key_shares[i]));
+ GNUNET_memcpy (uuids[i], truths[i]->uuid, sizeof(uuids[i]));
+ GNUNET_assert (NULL != &uuids[i]);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d uuid is %lu\n", __FILE__, __LINE__,
+ uuids[i]);
}
- // FIXME SALT
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+ &p->salt,
+ sizeof (struct ANASTASIS_CRYPTO_SaltP));
+ GNUNET_assert (NULL != &p->salt);
+
ANASTASIS_CRYPTO_policy_key_derive (key_shares,
truths_len,
&p->salt,
&p->policy_key);
+ GNUNET_assert (NULL != &p->policy_key);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d policy key is %s-%llu b\n", __FILE__, __LINE__,
+ TALER_B2S (&p->policy_key),
+ (unsigned long long) sizeof (p->policy_key));
p->uuids = uuids;
p->uuid_length = truths_len;
+
+ GNUNET_assert (NULL != p->uuids);
+ GNUNET_assert (p->uuid_length == truths_len);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
+ TALER_B2S (p),
+ (unsigned long long) sizeof (*p));
return p;
}
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index b3cf89d..7348529 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -235,6 +235,12 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
ANASTASIS_TESTING_TSO_NONE,
"salt-request-3"),
+
+ ANASTASIS_TESTING_cmd_policy_create ("policy-create-1",
+ "truth-create-1",
+ "truth-create-2",
+ "truth-create-3",
+ NULL),
/*
ANASTASIS_TESTING_cmd_secret_share ("secret-share-1",
anastasis_url,
diff --git a/src/lib/testing_cmd_policy_create.c
b/src/lib/testing_cmd_policy_create.c
index ad88bf3..6454df1 100644
--- a/src/lib/testing_cmd_policy_create.c
+++ b/src/lib/testing_cmd_policy_create.c
@@ -47,11 +47,6 @@ struct PolicyCreateState
*/
const char **cmd_label_array;
- /**
- * References to upload commands of previous truth uploads.
- */
- const char **cmd_label_array;
-
/**
* Length of array of command labels (cmd_label_array).
*/
@@ -63,6 +58,48 @@ struct PolicyCreateState
const struct ANASTASIS_Policy *policy;
};
+/**
+ * Th Truth.
+ * FIXME: Is there a more elegant way to fix "incomplete type" error?
+ * see sizeof (*truth)
+ */
+struct Truth
+{
+ /**
+ * url to the server
+ */
+ const char *url;
+ /**
+ * identification of the truth
+ */
+ uuid_t uuid;
+ /**
+ * method used for this truth
+ */
+ const char *method;
+ /**
+ * method used for this truth
+ */
+ const char *instructions;
+ /**
+ * mime type of the truth
+ */
+ const char *mime_type;
+ /**
+ * keyshare of this truth, used to generate policy keys
+ */
+ struct ANASTASIS_CRYPTO_KeyShareP key_share;
+ /**
+ * key used to encrypt this truth
+ */
+ struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
+ /**
+ * salt used to encrypt the truth
+ */
+ struct ANASTASIS_CRYPTO_SaltP *salt;
+};
+
+
/**
* Run a "policy create" CMD.
@@ -77,32 +114,70 @@ policy_create_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct PolicyCreateState *pcs = cls;
- const struct TALER_TESTING_Command *ref;
- struct ANASTASIS_Truth truth;
+ struct Truth truths[pcs->cmd_label_array_length];
+
+ GNUNET_assert (pcs->cmd_label_array_length > 0);
+ GNUNET_assert (NULL != pcs->cmd_label_array);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d cmd label array length is %i\n", __FILE__, __LINE__,
+ pcs->cmd_label_array_length);
pcs->is = is;
- if (NULL != pcs->ap)
+ if (NULL != pcs->cmd_label_array)
{
- ref = TALER_TESTING_interpreter_lookup_command
- (is,
- tus->upload_reference);
- if (NULL == ref)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (tus->is);
- return;
- }
- if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_truth (ref,
- 0,
- &truth))
+ for (unsigned int i = 0; i < pcs->cmd_label_array_length; i++)
{
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pcs->is);
- return;
+ const struct TALER_TESTING_Command *ref;
+ struct Truth *truth;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d truth upload cmd is %s\n", __FILE__, __LINE__,
+ pcs->cmd_label_array[i]);
+
+ ref = TALER_TESTING_interpreter_lookup_command
+ (is,
+ pcs->cmd_label_array[i]);
+ if (NULL == ref)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pcs->is);
+ return;
+ }
+ if (GNUNET_OK !=
+ ANASTASIS_TESTING_get_trait_truth (ref,
+ 0,
+ &truth))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pcs->is);
+ return;
+ }
+ GNUNET_assert (NULL != truth);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
+ TALER_B2S (truth),
+ (unsigned long long) sizeof (*truth));
+ truths[i] = *truth;
+ GNUNET_assert (0 ==
+ GNUNET_memcmp (&truths[i],
+ truth));
}
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d truth array is %s\n", __FILE__, __LINE__,
+ TALER_b2s (truths,
+ pcs->cmd_label_array_length
+ * sizeof (struct Truth)));
+ pcs->policy = ANASTASIS_policy_create (&truths,
+ pcs->cmd_label_array_length);
+ if (NULL == &pcs->policy)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pcs->is);
+ return;
+ }
+ TALER_TESTING_interpreter_next (pcs->is);
}
@@ -170,16 +245,23 @@ ANASTASIS_TESTING_cmd_policy_create (const char *label,
pcs = GNUNET_new (struct PolicyCreateState);
pcs->label = label;
- va_start (label, ap);
+ va_start (ap, label);
char *truth_upload_cmd;
while (NULL != (truth_upload_cmd = va_arg (ap, const char *)))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d truth upload cmd is %s\n", __FILE__, __LINE__,
+ truth_upload_cmd);
GNUNET_array_append (pcs->cmd_label_array,
pcs->cmd_label_array_length,
truth_upload_cmd);
}
va_end (ap);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d cmd label array length is %i\n", __FILE__, __LINE__,
+ pcs->cmd_label_array_length);
+
struct TALER_TESTING_Command cmd = {
.cls = pcs,
.label = label,
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-anastasis] 06/13: big O to small o, json_pack, (continued)
- [taler-anastasis] 06/13: big O to small o, json_pack, gnunet, 2020/05/03
- [taler-anastasis] 04/13: changed user identifier derivation to use GNUNET_CRYPTO_hash_pow(), gnunet, 2020/05/03
- [taler-anastasis] 02/13: deleted salt cb etc. from anastasis.c, gnunet, 2020/05/03
- [taler-anastasis] 09/13: created policy trait, gnunet, 2020/05/03
- [taler-anastasis] 10/13: modified Makefile, gnunet, 2020/05/03
- [taler-anastasis] 08/13: Initial work on testing policy creation, gnunet, 2020/05/03
- [taler-anastasis] 03/13: changed user identifier derivation to use GNUNET_CRYPTO_hash_pow(), gnunet, 2020/05/03
- [taler-anastasis] 05/13: modified truth trait, gnunet, 2020/05/03
- [taler-anastasis] 07/13: fixed http server not shutting down, gnunet, 2020/05/03
- [taler-anastasis] 12/13: Some error fixes, gnunet, 2020/05/03
- [taler-anastasis] 11/13: worked on testing policy creation,
gnunet <=
- [taler-anastasis] 13/13: fixed truth array problems, gnunet, 2020/05/03