gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: worked on policy creation


From: gnunet
Subject: [taler-anastasis] branch master updated: worked on policy creation
Date: Mon, 13 Apr 2020 01:16:27 +0200

This is an automated email from the git hooks/post-receive script.

ds-meister pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 8b13d9c  worked on policy creation
8b13d9c is described below

commit 8b13d9c021d5dfd703f701ef04ce4efae5b199ca
Author: Dominik Meister <address@hidden>
AuthorDate: Mon Apr 13 01:16:15 2020 +0200

    worked on policy creation
---
 src/lib/anastasis.c | 172 +++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 124 insertions(+), 48 deletions(-)

diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index b9988d4..5518e3a 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -47,9 +47,14 @@ struct ANASTASIS_Challenge
    * Reference to the recovery proccess which is ongoing
    */
   struct ANASTASIS_Recovery *recovery;
-
-
-
+  /**
+   * url to the escrow provider for this challenge
+   */
+  char *url;
+  /**
+   * uuid which defines this challenge
+   */
+  uuid_t challenge_uuid;
 };
 
 /**
@@ -164,15 +169,16 @@ policy_lookup_cb (void *cls,
                   unsigned int http_status,
                   const struct ANASTASIS_DownloadDetails *dd)
 {
-  struct ANASTASIS_Recovery *recovery = cls;
-  recovery->plo = NULL;
+  //FIXME
+  struct ANASTASIS_Recovery *r = cls;
+  r->plo = NULL;
   if (MHD_HTTP_OK == http_status)
   {
-    recovery->enc_rec_doc_size = dd->policy_size;
-    recovery->encrypted_recovery_document = GNUNET_malloc (
-      recovery->enc_rec_doc_size);
-    memcpy (recovery->encrypted_recovery_document, dd->policy,
-            recovery->enc_rec_doc_size);
+    r->enc_rec_doc_size = dd->policy_size;
+    r->encrypted_recovery_document = GNUNET_malloc (
+      r->enc_rec_doc_size);
+    memcpy (r->encrypted_recovery_document, dd->policy,
+            r->enc_rec_doc_size);
   }
   return;
 }
@@ -202,63 +208,67 @@ ANASTASIS_recovery_begin (const json_t *id_data,
                           ANASTASIS_CoreSecretCallback csc,
                           void *csc_cls)
 {
-  struct ANASTASIS_Recovery *recovery;
-  recovery = GNUNET_new (struct ANASTASIS_Recovery);
+  struct ANASTASIS_Recovery *r;
+  r = GNUNET_new (struct ANASTASIS_Recovery);
   unsigned int i = 0;
   void *plaintext;
   size_t size_plaintext;
+  json_t *recovery_document;
+  json_error_t json_error;
   // needs to be inside while and take a salt
-  ANASTASIS_CRYPTO_user_identifier_derive (id_data, &recovery->id);
-  ANASTASIS_CRYPTO_account_public_key_derive (&recovery->id,
-                                              &recovery->pub_key);
+  ANASTASIS_CRYPTO_user_identifier_derive (id_data, &r->id);
+  ANASTASIS_CRYPTO_account_public_key_derive (&r->id,
+                                              &r->pub_key);
 
   if (version != 0)
   {
-    while (i < provider_candidates_length ||
-           recovery->encrypted_recovery_document != NULL)
+    while (i < provider_candidates_length || r->encrypted_recovery_document != 
NULL)
     {
-      recovery->plo = ANASTASIS_policy_lookup_version (recovery->ctx,
-                                                       
anastasis_provider_url_candidates
-                                                       [i],
-                                                       &recovery->pub_key,
-                                                       &policy_lookup_cb,
-                                                       recovery,
-                                                       &version);
+      r->plo = ANASTASIS_policy_lookup_version (r->ctx,
+                                                
anastasis_provider_url_candidates[i],
+                                                &r->pub_key,
+                                                &policy_lookup_cb,
+                                                r,
+                                                &version);
       i++;
     }
 
   }
   else
   {
-    while (i < provider_candidates_length ||
-           recovery->encrypted_recovery_document != NULL)
+    while (i < provider_candidates_length || r->encrypted_recovery_document != 
NULL)
     {
-      recovery->plo = ANASTASIS_policy_lookup (recovery->ctx,
-                                               
anastasis_provider_url_candidates
-                                               [i],
-                                               &recovery->pub_key,
-                                               &policy_lookup_cb,
-                                               recovery);
+      r->plo = ANASTASIS_policy_lookup (r->ctx,
+                                        anastasis_provider_url_candidates[i],
+                                        &r->pub_key,
+                                        &policy_lookup_cb,
+                                        r);
       i++;
     }
   }
 
-  if (recovery->encrypted_recovery_document == NULL)
+  if (r->encrypted_recovery_document == NULL)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "No recovery documents found");
     GNUNET_break (0);
   }
 
-  ANASTASIS_CRYPTO_recovery_document_decrypt (&recovery->id,
-                                              recovery->
-                                              encrypted_recovery_document,
-                                              recovery->enc_rec_doc_size,
+  ANASTASIS_CRYPTO_recovery_document_decrypt (&r->id,
+                                              r->encrypted_recovery_document,
+                                              r->enc_rec_doc_size,
                                               &plaintext,
                                               &size_plaintext);
-  // FIXME CALLBACK AND BUILD OF REC DOC ?
 
-  return recovery;
+
+  recovery_document = json_loadb((char 
*)plaintext,size_plaintext,JSON_DECODE_ANY,&json_error);
+
+  //FIXME CALLBACK AND RECOVERY DOCUMENT BUILD
+
+
+
+
+  return r;
 }
 
 /**
@@ -281,16 +291,48 @@ ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r)
 
 /* Upload api
 ----------------------------------------------------------------- */
-
 /**
-* Truth Upload struct
+* provider_url + UUID
 */
-struct ANASTASIS_TruthUpload;
-
+struct ANASTASIS_Truth
+{
+  /**
+   * url to the server
+   */
+  char *url;
+  /**
+   * identification of the truth
+   */
+  uuid_t uuid;
+  /**
+   * method used for this truth
+   */
+  char *method;
+  /**
+   * keyshare of this truth, used to generate policy keys
+   */
+  struct ANASTASIS_CRYPTO_KeyShare key_share;
+  /**
+   * key used to encrypt this truth
+   */
+  struct ANASTASIS_CRYPTO_TruthKey truth_key;
+  /**
+   * salt used to encrypt the truth
+   */
+  struct ANASTASIS_CRYPTO_Salt *salt;
+  /**
+   * challenge for this truth
+   */
+  void *challenge;
+  /**
+   * size of the challenge
+   */
+  size_t challenge_size;
+};
 /**
-* provider_url + UUID
+* Truth Upload struct
 */
-struct ANASTASIS_Truth;
+struct ANASTASIS_TruthUpload;
 
 /**
 * Uploads a truth object onto a escrow provider
@@ -344,7 +386,25 @@ ANASTASIS_truth_free (struct ANASTASIS_Truth *t)
 /**
 * Policy object to upload
 */
-struct ANASTASIS_Policy;
+struct ANASTASIS_Policy
+{
+  /**
+  * Encrypted policy master key
+  */
+  struct ANASTASIS_CRYPTO_PolicyKey policy_key;
+  /**
+   * salt used to encrypt the master key
+   */
+  struct ANASTASIS_CRYPTO_Salt salt;
+   /**
+   * size of the truths
+   */
+  unsigned int truths_len;
+   /**
+   * set of truths inside this policy
+   */
+   struct ANASTASIS_Truth *truths[];
+};
 
 /**
 * Creates a policy with a set of trutht's
@@ -356,7 +416,23 @@ struct ANASTASIS_Policy *
 ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
                          unsigned int truths_len)
 {
-
+  struct ANASTASIS_Policy *p;
+  p = GNUNET_new (struct ANASTASIS_Policy);
+  struct ANASTASIS_CRYPTO_PolicyKey policy_key;
+  struct ANASTASIS_CRYPTO_KeyShare key_shares[truths_len];
+  //p->truths = truths;
+  //p->truths_len = truths_len;
+
+  for (unsigned int i = 0; i < truths_len; i++)
+  {
+    key_shares[i] = truths[i]->key_share;
+  }
+  //FIXME SALT
+  ANASTASIS_CRYPTO_policy_key_derive (&key_shares,
+                                      truths_len,
+                                      &p->salt,
+                                      &p->policy_key);
+  return p;
 }
 
 /**
@@ -366,7 +442,7 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
 void
 ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p)
 {
-
+  GNUNET_free (p);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]