[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 03/13: changed user identifier derivation to use GNUNE
From: |
gnunet |
Subject: |
[taler-anastasis] 03/13: changed user identifier derivation to use GNUNET_CRYPTO_hash_pow() |
Date: |
Sun, 03 May 2020 18:02:27 +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 ac3b9577fd6befeb96edbd9fad34f3a155193b0b
Author: Dennis Neufeld <address@hidden>
AuthorDate: Fri May 1 18:26:48 2020 +0000
changed user identifier derivation to use GNUNET_CRYPTO_hash_pow()
---
src/include/anastasis.h | 5 +-
src/include/anastasis_crypto_lib.h | 2 +-
src/lib/anastasis.c | 106 +++++++++++++++++++++++++++++++++----
src/util/anastasis_crypto.c | 14 ++++-
4 files changed, 113 insertions(+), 14 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 2eae470..aab80ed 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -204,8 +204,8 @@ struct ANASTASIS_Recovery;
*
* @param id_data contains the users identity, (user account on providers)
* @param version defines the version which will be downloaded NULL for latest
version
-* @param anastasis_provider_url_candidates NULL terminated list of possible
provider urls
-* @param provider_candidates_length length of the provider list
+* @param anastasis_provider_url NULL terminated list of possible provider urls
+* @param salt the server salt
* @param pc opens the policy call back which holds the downloaded version and
the policies
* @param pc_cls closure for callback
* @param csc core secret callback is opened, with this the core secert is
passed to the client after the authentication
@@ -215,6 +215,7 @@ struct ANASTASIS_Recovery *
ANASTASIS_recovery_begin (const json_t *id_data,
unsigned int version,
const char *anastasis_provider_url,
+ const struct ANASTASIS_CRYPTO_SaltP *salt,
ANASTASIS_PolicyCallback pc,
void *pc_cls,
ANASTASIS_CoreSecretCallback csc,
diff --git a/src/include/anastasis_crypto_lib.h
b/src/include/anastasis_crypto_lib.h
index a7e21f4..6fe6490 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -153,7 +153,7 @@ struct ANASTASIS_CRYPTO_EscrowMasterKeyP
*/
struct ANASTASIS_CRYPTO_UserIdentifierP
{
- uint32_t hash[8];
+ struct GNUNET_HashCode hash GNUNET_PACKED;
};
GNUNET_NETWORK_STRUCT_END
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 78a4d0e..b0fd01e 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -24,6 +24,98 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_util_lib.h>
+
+/**
+ * FIXME: Needed? -> maybe needed in ANASTASIS_secret_share()
+ * State for a "salt" CMD.
+ */
+struct SaltState
+{
+ /**
+ * URL of the anastasis backend.
+ */
+ const char *anastasis_url;
+
+ /**
+ * Expected status code.
+ */
+ unsigned int http_status;
+
+ /**
+ * The /salt GET operation handle.
+ */
+ struct ANASTASIS_SaltOperation *so;
+
+ /**
+ * Server Salt
+ */
+ const struct ANASTASIS_CRYPTO_SaltP *salt;
+};
+
+
+/**
+ * FIXME: Needed? -> maybe needed in ANASTASIS_secret_share()
+ * Function called with the results of a #ANASTASIS_salt().
+ *
+ * @param cls closure
+ * @param http_status HTTP status of the request
+ * @param salt salt from the server
+ */
+static void
+salt_cb (void *cls,
+ unsigned int http_status,
+ const struct ANASTASIS_CRYPTO_SaltP *salt)
+{
+ struct SaltState *ss = cls;
+
+ ss->so = NULL;
+
+ 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;
+}
+
+
+/**
+ * FIXME: Needed? -> maybe needed in ANASTASIS_secret_share()
+ * Free the state of a "salt" CMD, and possibly
+ * cancel it if it did not complete.
+ *
+ * @param cls closure.
+ * @param cmd command being freed.
+ */
+static void
+salt_cleanup (struct SaltState *ss)
+{
+ if (NULL != ss->so)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Salt request did not complete\n");
+ ANASTASIS_salt_cancel (ss->so);
+ ss->so = NULL;
+ }
+ GNUNET_free (ss);
+}
+
+
/**
* Challenge struct contains the UUID's needed for the recovery process and a
reference to
* ANASTASIS_Recovery.
@@ -317,8 +409,8 @@ policy_lookup_cb (void *cls,
*
* @param id_data contains the users identity, (user account on providers)
* @param version defines the version which will be downloaded NULL for latest
version
-* @param anastasis_provider_url_candidates NULL terminated list of possible
provider urls
-* @param provider_candidates_length length of the provider list
+* @param anastasis_provider_url NULL terminated list of possible provider urls
+* @param salt the server salt
* @param pc opens the policy call back which holds the downloaded version and
the policies
* @param pc_cls closure for callback
* @param csc core secret callback is opened, with this the core secert is
passed to the client after the authentication
@@ -328,6 +420,7 @@ struct ANASTASIS_Recovery *
ANASTASIS_recovery_begin (const json_t *id_data,
unsigned int version,
const char *anastasis_provider_url,
+ const struct ANASTASIS_CRYPTO_SaltP *salt,
ANASTASIS_PolicyCallback pc,
void *pc_cls,
ANASTASIS_CoreSecretCallback csc,
@@ -344,17 +437,10 @@ ANASTASIS_recovery_begin (const json_t *id_data,
json_t *dec_policies = json_array ();
json_t *esc_methods = json_array ();
r->key_share_pos = 0;
- struct SaltState *ss = pc_cls;
r->http_status = MHD_HTTP_OK;
- ss->http_status = MHD_HTTP_OK;
- ss->so = ANASTASIS_salt (r->ctx,
- anastasis_provider_url,
- &salt_cb,
- ss);
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
- &ss->so->salt,
+ salt,
&r->id);
- salt_cleanup (ss);
ANASTASIS_CRYPTO_account_public_key_derive (&r->id,
&r->pub_key);
if (version != 0)
diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index 74192cb..ba6d71c 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -323,9 +323,18 @@ ANASTASIS_CRYPTO_user_identifier_derive (
struct ANASTASIS_CRYPTO_UserIdentifierP *id)
{
char *json_enc;
+
+ GNUNET_assert (NULL != id_data);
+ GNUNET_assert (NULL != server_salt);
+
json_enc = json_dumps (id_data,
JSON_COMPACT | JSON_SORT_KEYS);
GNUNET_assert (NULL != json_enc);
+ GNUNET_CRYPTO_pow_hash (server_salt,
+ json_enc,
+ strlen (json_enc),
+ &id->hash);
+ /*
GNUNET_assert (0 ==
gcry_kdf_derive (json_enc,
strlen (json_enc),
@@ -333,11 +342,14 @@ ANASTASIS_CRYPTO_user_identifier_derive (
1, // subalgo
server_salt,
sizeof (*server_salt),
- SCRYPT_ITERATION, // iterations
+ 1, // iterations
sizeof (struct
ANASTASIS_CRYPTO_UserIdentifierP),
id));
+ */
free (json_enc);
+ json_decref (id_data);
+ GNUNET_assert (NULL != id);
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-anastasis] branch master updated (a5b4c84 -> d0a484e), gnunet, 2020/05/03
- [taler-anastasis] 01/13: json_dumps with JSON_COMPACT and JSON_SORT_KEYS, gnunet, 2020/05/03
- [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 <=
- [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, 2020/05/03
- [taler-anastasis] 13/13: fixed truth array problems, gnunet, 2020/05/03