[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 01/02: Learned something about json_t and sizeof()...
From: |
gnunet |
Subject: |
[taler-anastasis] 01/02: Learned something about json_t and sizeof()... |
Date: |
Sun, 29 Mar 2020 18:21:43 +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 5ab9ede8f1a1398a64e0afb5ba97107f84b40a2e
Author: Dennis Neufeld <address@hidden>
AuthorDate: Sun Mar 29 16:19:12 2020 +0000
Learned something about json_t and sizeof()...
---
src/util/anastasis_crypto.c | 11 +++++++----
src/util/test_anastasis_crypto.c | 18 +++++++++---------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index 2e01e92..94c6612 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -88,7 +88,7 @@ get_iv_key (const void *msec,
* @param res ciphertext output
* @param res_size size of the ciphertext
*/
-void
+static void
encrypt (const void *msec,
const void *data,
size_t data_size,
@@ -149,7 +149,7 @@ encrypt (const void *msec,
* @param res plaintext output
* @param res_size size of the plaintext
*/
-void
+static void
decrypt (const void *msec,
const void *data,
size_t data_size,
@@ -206,8 +206,10 @@ ANASTASIS_CRYPTO_user_identifier_derive (
const json_t *id_data,
struct ANASTASIS_CRYPTO_UserIdentifier *id)
{
- GNUNET_assert (0 == gcry_kdf_derive (id_data,
- sizeof (*id_data),
+ char *json_enc;
+ json_enc = json_dumps (id_data, 0);
+ GNUNET_assert (0 == gcry_kdf_derive (json_enc,
+ strlen (json_enc),
GCRY_KDF_SCRYPT,
1, // subalgo
"SERVER_SALT", // FIXME: Set real salt
value!!!
@@ -216,6 +218,7 @@ ANASTASIS_CRYPTO_user_identifier_derive (
sizeof (struct
ANASTASIS_CRYPTO_UserIdentifier),
id));
+ GNUNET_free (json_enc);
}
/**
diff --git a/src/util/test_anastasis_crypto.c b/src/util/test_anastasis_crypto.c
index 3f477c6..34cb442 100644
--- a/src/util/test_anastasis_crypto.c
+++ b/src/util/test_anastasis_crypto.c
@@ -43,14 +43,14 @@ test_user_identifier_derive ()
struct ANASTASIS_CRYPTO_UserIdentifier id_3;
// sample data 1
- id_data_1 = json_array ();
- json_array_append (id_data_1, json_string ("Hallo"));
+ id_data_1 = json_object ();
+ json_object_set_new (id_data_1, "arg1", json_string ("Hallo"));
// sample data 2, equal to sample data 1
- id_data_2 = json_array ();
- json_array_append (id_data_2, json_string ("Hallo"));
+ id_data_2 = json_object ();
+ json_object_set_new (id_data_2, "arg1", json_string ("Hallo"));
// sample data 3, differs
- id_data_3 = json_array ();
- json_array_append (id_data_3, json_string ("Hallo2"));
+ id_data_3 = json_object ();
+ json_object_set_new (id_data_3, "arg1", json_string ("Hallo2"));
ANASTASIS_CRYPTO_user_identifier_derive (id_data_1, &id_1);
ANASTASIS_CRYPTO_user_identifier_derive (id_data_2, &id_2);
@@ -81,11 +81,11 @@ test_recovery_document ()
void *plaintext;
size_t size_plaintext;
struct ANASTASIS_CRYPTO_UserIdentifier id;
+ json_t *id_data = json_object ();
const char *test = "TEST_ERD";
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
- &id,
- sizeof (struct ANASTASIS_CRYPTO_UserIdentifier));
+ json_object_set_new (id_data, "arg1", json_string ("ID_DATA"));
+ ANASTASIS_CRYPTO_user_identifier_derive (id_data, &id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ERD_BEFORE: %s\n",
--
To stop receiving notification emails like this one, please contact
address@hidden.