[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 02/02: worked on truth upload
From: |
gnunet |
Subject: |
[taler-anastasis] 02/02: worked on truth upload |
Date: |
Wed, 08 Apr 2020 23:19:17 +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 5fafda8f3b6fc4d6fd1e760e349ad8d9e8316ea8
Merge: 59129aa 009658d
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Apr 8 21:19:06 2020 +0000
worked on truth upload
src/backend/anastasis-httpd_policy_upload.c | 14 +++----
src/backend/anastasis-httpd_truth_upload.c | 21 +++++++----
src/include/anastasis_database_plugin.h | 14 ++++---
src/include/anastasis_service.h | 2 +-
src/include/anastasis_testing_lib.h | 2 +-
src/lib/anastasis_api_policy_lookup.c | 11 +++---
src/lib/anastasis_api_policy_store.c | 24 ++++--------
src/lib/anastasis_api_truth_store.c | 8 ++--
src/lib/test_anastasis_api.c | 58 ++++++++++++++++++++++++-----
src/lib/testing_api_cmd_truth_store.c | 11 +-----
src/stasis/plugin_anastasis_postgres.c | 4 +-
src/stasis/test_anastasis_db.c | 9 +++--
12 files changed, 107 insertions(+), 71 deletions(-)
diff --cc src/backend/anastasis-httpd_policy_upload.c
index bb08a87,1a8ec67..9b28af0
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@@ -791,15 -791,16 +791,15 @@@ AH_handler_policy_post (struct MHD_Conn
}
/* validate signature */
{
- struct ANASTASIS_UploadSignaturePS usp;
-
- usp.purpose.size = htonl (sizeof (struct ANASTASIS_UploadSignaturePS));
- usp.purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD);
- // usp.old_recovery_data_hash = puc->old_policy_upload_hash;
- usp.new_recovery_data_hash = puc->new_policy_upload_hash;
+ struct ANASTASIS_UploadSignaturePS usp = {
+ .purpose.size = htonl (sizeof (usp)),
+ .purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD),
- .old_recovery_data_hash = puc->old_policy_upload_hash,
++ // .old_recovery_data_hash = puc->old_policy_upload_hash,
+ .new_recovery_data_hash = puc->new_policy_upload_hash
+ };
-
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD,
- &usp.purpose,
+ &usp,
&puc->account_sig.eddsa_sig,
&accountPubP.pub))
{
diff --cc src/backend/anastasis-httpd_truth_upload.c
index 6bfb8d9,e1282e0..4a48517
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@@ -42,7 -42,7 +42,6 @@@ verify_and_execute_truth (struct MHD_Co
const uuid_t *uuid)
{
enum ANASTASIS_DB_QueryStatus qs;
--
qs = db->store_truth (db->cls,
uuid,
truth->keyshare_data,
@@@ -50,8 -50,8 +49,8 @@@
truth->truth_mime,
truth->encrypted_truth,
sizeof (&truth->encrypted_truth),
-- truth->truth_hash,
-- truth->aes_gcm_tag,
++ &truth->truth_hash,
++ &truth->aes_gcm_tag,
&truth->nonce,
truth->method,
AH_truth_expiration);
@@@ -91,25 -88,22 +90,28 @@@ AH_handler_truth_post (struct MHD_Conne
uuid_str = &url[strlen ("/truth/")];
uuid_parse (uuid_str, uuid);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Uuid from Url: %s\n",
+ uuid_str);
}
{
++ const char *encrypted_truth_str;
+
- }
- {
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("keyshare_data", &truth.keyshare_data),
GNUNET_JSON_spec_string ("method", &truth.method),
-- GNUNET_JSON_spec_uint32 ("nonce", &truth.nonce),
++ GNUNET_JSON_spec_fixed_auto ("nonce", &truth.nonce),
GNUNET_JSON_spec_fixed_auto ("aes_gcm_tag", &truth.aes_gcm_tag),
GNUNET_JSON_spec_fixed_auto ("truth_hash", &truth.truth_hash),
-- GNUNET_JSON_spec_fixed_auto ("encrypted_truth", &truth.encrypted_truth),
++ GNUNET_JSON_spec_string ("encrypted_truth", &encrypted_truth_str),
GNUNET_JSON_spec_string ("truth_mime", &truth.truth_mime),
GNUNET_JSON_spec_end ()
};
+
+ (void) con_cls;
+ (void) truth_data;
+ (void) truth_data_size;
+
res = TALER_MHD_parse_post_json (connection,
con_cls,
truth_data,
@@@ -123,9 -116,6 +125,14 @@@
res = TALER_MHD_parse_json_data (connection,
json,
spec);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Truth json from upload: %s\n",
- TALER_b2s (json, sizeof (json)));
++ "Truth json from upload: %s\nResult: %i\n",
++ json_dumps (json, JSON_COMPACT),
++ res);
++ GNUNET_STRINGS_string_to_data (encrypted_truth_str,
++ strlen (encrypted_truth_str),
++ truth.encrypted_truth,
++ truth.encrypted_truth_size);
json_decref (json);
if (GNUNET_SYSERR == res)
return MHD_NO; /* hard failure */
diff --cc src/include/anastasis_database_plugin.h
index dd9df56,dd9df56..163d284
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@@ -33,17 -33,17 +33,19 @@@
*/
struct ANASTASIS_DB_Truth
{
-- const void *keyshare_data;
++ const struct ANASTASIS_CRYPTO_EncryptedKeyShare *keyshare_data;
-- uint32_t nonce;
++ struct ANASTASIS_CRYPTO_Nonce nonce;
// AES_GCM_Tag
-- unsigned char aes_gcm_tag[16];
++ struct ANASTASIS_CRYPTO_AesTag aes_gcm_tag;
-- struct GNUNET_HashCode *truth_hash;
++ struct GNUNET_HashCode truth_hash;
void *encrypted_truth;
++ size_t encrypted_truth_size;
++
const char *truth_mime;
const char *method;
@@@ -264,8 -264,8 +266,8 @@@ struct ANASTASIS_DatabasePlugi
size_t encrypted_truth_size,
const struct
GNUNET_HashCode *truth_data_hash,
-- const unsigned char aes_gcm_tag[16],
-- const uint32_t *nonce,
++ const struct ANASTASIS_CRYPTO_AesTag *aes_gcm_tag,
++ const struct ANASTASIS_CRYPTO_Nonce *nonce,
const char *method,
struct
GNUNET_TIME_Relative truth_expiration);
diff --cc src/include/anastasis_service.h
index 95c82f3,f94fae4..7916ed8
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@@ -483,7 -483,7 +483,7 @@@ ANASTASIS_truth_store (struct GNUNET_CU
const uuid_t truth_uuid,
const struct
GNUNET_HashCode *prev_truth_data_hash,
-- const json_t *truth_data,
++ json_t *truth_data,
int payment_requested,
const char *paid_order_id,
ANASTASIS_TruthStoreCallback cb,
diff --cc src/include/anastasis_testing_lib.h
index e0c9c3e,bb994c6..5bdb601
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@@ -338,7 -338,7 +338,7 @@@ ANASTASIS_TESTING_cmd_truth_store (cons
unsigned int http_status,
enum
ANASTASIS_TESTING_TruthStoreOption tso,
- const json_t *truth_data,
- const void *truth_data,
++ json_t *truth_data,
size_t truth_data_size);
/**
diff --cc src/lib/anastasis_api_policy_lookup.c
index 8ca660d,48c5dd5..1654637
--- a/src/lib/anastasis_api_policy_lookup.c
+++ b/src/lib/anastasis_api_policy_lookup.c
@@@ -131,17 -131,25 +131,18 @@@ handle_policy_lookup_finished (void *cl
case MHD_HTTP_OK:
{
struct ANASTASIS_DownloadDetails dd;
- struct ANASTASIS_UploadSignaturePS usp;
+ struct ANASTASIS_UploadSignaturePS usp = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD),
+ .purpose.size = htonl (sizeof (usp)),
- .old_recovery_data_hash = plo->anastasis_previous
++ // .old_recovery_data_hash = plo->anastasis_previous
+ };
- usp.purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD);
- usp.purpose.size = htonl (sizeof (struct ANASTASIS_UploadSignaturePS));
- // usp.old_recovery_data_hash = plo->anastasis_previous;
GNUNET_CRYPTO_hash (data,
data_size,
&usp.new_recovery_data_hash);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Account Signature to verify download: %s\n",
- TALER_B2S (&plo->account_sig));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Account Public Key for verification of signature: %s\n",
- TALER_B2S (&plo->account_pub));
-
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD,
- &usp.purpose,
+ &usp,
&plo->account_sig.eddsa_sig,
&plo->account_pub.pub))
{
diff --cc src/lib/anastasis_api_policy_store.c
index be3615f,fb1738a..df6e1ec
--- a/src/lib/anastasis_api_policy_store.c
+++ b/src/lib/anastasis_api_policy_store.c
@@@ -285,17 -286,15 +285,17 @@@ ANASTASIS_policy_store (struct GNUNET_C
{
struct ANASTASIS_PolicyStoreOperation *pso;
struct ANASTASIS_AccountSignatureP account_sig;
- struct ANASTASIS_UploadSignaturePS usp;
CURL *eh;
struct curl_slist *job_headers;
+ struct ANASTASIS_UploadSignaturePS usp = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD),
+ .purpose.size = htonl (sizeof (usp))
+ };
- memset (&usp, 0, sizeof (usp));
- usp.purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD);
- usp.purpose.size = htonl (sizeof (usp));
- /* FIXME: delete
++ /*
if (NULL != prev_recovery_data_hash)
usp.old_recovery_data_hash = *prev_recovery_data_hash;
+ */
GNUNET_CRYPTO_hash (recovery_data,
recovery_data_size,
diff --cc src/lib/anastasis_api_truth_store.c
index efd2a83,12bc30c..dc9abf6
--- a/src/lib/anastasis_api_truth_store.c
+++ b/src/lib/anastasis_api_truth_store.c
@@@ -274,7 -259,7 +274,7 @@@ ANASTASIS_truth_store (struct GNUNET_CU
const uuid_t truth_uuid,
const struct
GNUNET_HashCode *prev_truth_data_hash,
-- const json_t *truth_data,
++ json_t *truth_data,
int payment_requested,
const char *paid_order_id,
ANASTASIS_TruthStoreCallback cb,
@@@ -283,10 -268,8 +283,11 @@@
struct ANASTASIS_TruthStoreOperation *tso;
CURL *eh;
struct curl_slist *job_headers;
- struct GNUNET_HashCode old_truth_data_hash;
struct GNUNET_HashCode new_truth_data_hash;
+ char *json_str;
+
- json_str = json_dumps (truth_data, 0);
++ json_str = json_dumps (truth_data,
++ JSON_COMPACT);
/* setup our HTTP headers */
job_headers = NULL;
@@@ -386,6 -371,6 +387,7 @@@
tso->cb = cb;
tso->cb_cls = cb_cls;
eh = ANASTASIS_curl_easy_get_ (tso->url);
++
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_POSTFIELDS,
@@@ -393,7 -378,7 +395,7 @@@
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_POSTFIELDSIZE,
- (long) strlen (json_str)));
- sizeof(truth_data)));
++ strlen (json_str)));
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_HEADERFUNCTION,
diff --cc src/lib/test_anastasis_api.c
index ce1aca9,62c5a58..25d415b
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@@ -234,17 -234,6 +234,55 @@@ run (void *cls
TALER_TESTING_cmd_end ()
};
- json_t *truth_data = json_object ();
-
- json_object_set_new (truth_data, "keyshare_data", json_string ("Truth
test"));
- json_object_set_new (truth_data, "method", json_string ("Truth test"));
- json_object_set_new (truth_data, "nonce", json_integer (1234));
- json_object_set_new (truth_data, "aes_gcm_tag", json_string ("Truth test"));
- json_object_set_new (truth_data, "truth_hash", json_string ("Truth test"));
- json_object_set_new (truth_data, "encrypted_truth", json_string (
- "Truth test"));
- json_object_set_new (truth_data, "truth_mime", json_string ("Truth test"));
++ json_t *truth_data;
++ struct ANASTASIS_CRYPTO_EncryptedKeyShare keyshare_data;
++ struct ANASTASIS_CRYPTO_Nonce nonce;
++ struct ANASTASIS_CRYPTO_AesTag aes_gcm_tag;
++ struct GNUNET_HashCode truth_hash;
++ const char *encrypted_truth;
++
++ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
++ &nonce,
++ sizeof (struct ANASTASIS_CRYPTO_Nonce));
++ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
++ &aes_gcm_tag,
++ sizeof (struct ANASTASIS_CRYPTO_AesTag));
++ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
++ &keyshare_data,
++ sizeof (struct
++ ANASTASIS_CRYPTO_EncryptedKeyShare));
++ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
++ &truth_hash,
++ sizeof (struct GNUNET_HashCode));
++ encrypted_truth = "Truth test (et)";
++
++ truth_data = json_pack ("{s:o," /* keyshare_data */
++ " s:s," /* method */
++ " s:o," /* nonce */
++ " s:o," /* aes_gcm_tag */
++ " s:o," /* truth_hash */
++ " s:o," /* encrypted_truth */
++ " s:s}", /* truth_mime */
++ "keyshare_data", GNUNET_JSON_from_data_auto (
++ &keyshare_data),
++ "method", "Truth test (method)",
++ "nonce", GNUNET_JSON_from_data_auto (&nonce),
++ "aes_gcm_tag", GNUNET_JSON_from_data_auto (
++ &aes_gcm_tag),
++ "truth_hash", GNUNET_JSON_from_data_auto (
++ &truth_hash),
++ "encrypted_truth", GNUNET_JSON_from_data (
++ encrypted_truth, strlen (encrypted_truth)),
++ "truth_mime", "Truth test (mime)"
++ );
++ if (NULL == truth_data)
++ {
++ GNUNET_break (0);
++ }
++ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
++ "Truth json before upload: %s\n",
++ json_dumps (truth_data, JSON_COMPACT));
+
struct TALER_TESTING_Command truth[] = {
// FIXME: Code for truth handling
diff --cc src/lib/testing_api_cmd_truth_store.c
index 2826e28,c7e6b2a..2f3286f
--- a/src/lib/testing_api_cmd_truth_store.c
+++ b/src/lib/testing_api_cmd_truth_store.c
@@@ -38,7 -38,7 +38,7 @@@ struct TruthStoreStat
/**
* The policy data.
*/
-- const json_t *truth_data;
++ json_t *truth_data;
/**
* Expected status code.
@@@ -293,13 -293,13 +293,6 @@@ truth_store_run (void *cls
}
}
}
-- {
-- // create json
-- // FIXME: create an example TruthUploadRequest-Json-Object
-- json_t *truth_json;
-- truth_json = json_pack ("");
-- tss->truth_data = truth_json;
-- }
// Create an uuid
uuid_t truth_uuid;
uuid_generate (truth_uuid);
@@@ -407,7 -407,7 +400,7 @@@ ANASTASIS_TESTING_cmd_truth_store (cons
unsigned int http_status,
enum
ANASTASIS_TESTING_TruthStoreOption tso,
- const json_t *truth_data,
- const void *truth_data,
++ json_t *truth_data,
size_t truth_data_size)
{
struct TruthStoreState *tss;
diff --cc src/stasis/plugin_anastasis_postgres.c
index 1884619,1884619..fc8319b
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@@ -986,8 -986,8 +986,8 @@@ postgres_store_truth (void *cls
size_t encrypted_truth_size,
const struct
GNUNET_HashCode *truth_data_hash,
-- const unsigned char aes_gcm_tag[16],
-- const uint32_t *nonce,
++ const struct ANASTASIS_CRYPTO_AesTag *aes_gcm_tag,
++ const struct ANASTASIS_CRYPTO_Nonce *nonce,
const char *method,
struct
GNUNET_TIME_Relative truth_expiration)
diff --cc src/stasis/test_anastasis_db.c
index 5b2f535,5b2f535..1e6f959
--- a/src/stasis/test_anastasis_db.c
+++ b/src/stasis/test_anastasis_db.c
@@@ -192,8 -192,8 +192,11 @@@ run (void *cls
size_t recoverydatasize;
size_t keysharesize;
const char *str = "AHV123456789";
-- struct GNUNET_CRYPTO_EccSignaturePurpose purp;
struct GNUNET_HashCode r;
++ struct ANASTASIS_UploadSignaturePS usp = {
++ .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST),
++ .purpose.size = htonl (sizeof (usp))
++ };
GNUNET_CRYPTO_eddsa_private_key_from_string (str,
sizeof (str),
@@@ -214,10 -214,10 +217,8 @@@
sizeof ("key_share_data"),
&truthDataHash);
-- purp.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose));
-- purp.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
GNUNET_CRYPTO_eddsa_sign (&accountPrivP.priv,
-- &purp,
++ &usp,
&accountSig.eddsa_sig);
RND_BLK (&paymentSecretP);
--
To stop receiving notification emails like this one, please contact
address@hidden.