gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 02/04: worked on cli assembler


From: gnunet
Subject: [taler-anastasis] 02/04: worked on cli assembler
Date: Tue, 16 Jun 2020 15:25:46 +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 fe53e52fea4e493b10eedcb7e5f3a5e91b170914
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Tue Jun 16 08:29:53 2020 +0000

    worked on cli assembler
---
 src/cli/anastasis-cli-assembler.c | 36 ++++++++++++++++++++++++++++++++++++
 src/cli/anastasis-cli-splitter.c  |  1 -
 src/include/anastasis.h           | 10 ++++------
 src/lib/anastasis.c               | 35 +++++++++++++++++++++++++++--------
 4 files changed, 67 insertions(+), 15 deletions(-)

diff --git a/src/cli/anastasis-cli-assembler.c 
b/src/cli/anastasis-cli-assembler.c
index c3b4425..62e159a 100644
--- a/src/cli/anastasis-cli-assembler.c
+++ b/src/cli/anastasis-cli-assembler.c
@@ -59,6 +59,16 @@ static struct GNUNET_CURL_Context *ctx;
  */
 static struct GNUNET_CURL_RescheduleContext *rc;
 
+/**
+ * Information about the challenges.
+ */
+static struct ANASTASIS_ChallengeInformation *challenges;
+
+/**
+ * Amount of challenges.
+ */
+static unsigned int challenges_length = 0;
+
 static void
 start_read_keyboard (void);
 
@@ -245,6 +255,27 @@ start_read_keyboard ()
 }
 
 
+/**
+ * Defines a Challenge Callback which is initially sent with the get 
challenge. It gives back the previously
+ * defined Challenge Information and a Status Code, like "payment missing".
+ *
+ * @param cls handle for the callback
+ * @param ec enum which defines the different status codes
+ *
+*/
+static void
+challenge_cb (void *cls,
+              enum TALER_ErrorCode ec)
+{
+  // FIXME handle ec
+
+  struct ANASTASIS_ChallengeInformation *ci = cls;
+  GNUNET_array_append (challenges,
+                       challenges_length,
+                       *ci);
+}
+
+
 static void
 policy_lookup_cb (void *cls,
                   const struct ANASTASIS_RecoveryInformation *ri,
@@ -257,6 +288,11 @@ policy_lookup_cb (void *cls,
     GNUNET_break (0);
     return;
   }
+  for (unsigned int i = 0; i < rss->ri->cs_len; i++)
+  {
+    ANASTASIS_get_challenge (rss->ri->cs[i],
+                             &challenge_cb);
+  }
   start_read_keyboard ();
   return;
 }
diff --git a/src/cli/anastasis-cli-splitter.c b/src/cli/anastasis-cli-splitter.c
index 776dd51..5f12d24 100644
--- a/src/cli/anastasis-cli-splitter.c
+++ b/src/cli/anastasis-cli-splitter.c
@@ -489,7 +489,6 @@ secret_share_result_cb (void *cls,
     }
   }
   printf ("Thank you for using Anastasis");
-  GNUNET_break (0);
   keyboard_task = NULL;
   start_read_keyboard ();
   return;
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 2fe1e35..bc23c89 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -150,6 +150,8 @@ struct ANASTASIS_ChallengeInformation
   const char *method;
   const char *url;
   const char *instructions;
+  const struct TALER_Amount *cost;
+  const unsigned int *solved;
 };
 
 /**
@@ -157,13 +159,11 @@ struct ANASTASIS_ChallengeInformation
  * defined Challenge Information and a Status Code, like "payment missing".
  *
  * @param cls handle for the callback
- * @param ci reference to the challenge information struct
  * @param ec enum which defines the different status codes
  *
 */
 typedef void
 (*ANASTASIS_ChallengeCallback)(void *cls,
-                               const struct ANASTASIS_ChallengeInformation *ci,
                                enum TALER_ErrorCode ec); // i.e. payment 
missing
 
 /**
@@ -172,12 +172,10 @@ typedef void
  *
  * @param challenge reference to the escrow challenge which is started
  * @param cc opens a callback for the requested information
- * @param cc_cls handle for the request
  */
 void
-ANASTASIS_challenge_run (struct ANASTASIS_Challenge *challenge,
-                         ANASTASIS_ChallengeCallback cc,
-                         void *cc_cls);
+ANASTASIS_get_challenge (struct ANASTASIS_Challenge *challenge,
+                         ANASTASIS_ChallengeCallback cc);
 
 /**
  * Defines a Callback for the payment of an escrow challenge. Sends back a 
payment link
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 7f8626d..25b95fb 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -204,75 +204,98 @@ struct ANASTASIS_Challenge
    * Callback which gives back the instructions and a status code of the 
request to the user
    */
   ANASTASIS_ChallengeCallback cc;
+
   /**
    * Closure for the challenge callback
    */
   void *cc_cls;
+
   /**
    * Callback which gives back the instructions and a status code of the 
request to the user
    */
   ANASTASIS_AnswerFeedback af;
+
   /**
    * Closure for the challenge callback
    */
   void *af_cls;
+
   /**
    * Reference to the recovery proccess which is ongoing
    */
   struct ANASTASIS_Recovery *recovery;
+
   /**
    * url to the escrow provider for this challenge
    */
   const char *url;
+
   /**
    * uuid which defines this challenge
    */
   uuid_t challenge_uuid;
+
   /**
    * Key used to encrypt the truth passed to the server
    */
   struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
+
   /**
    * Salt used to encrypt the truth
    */
   struct ANASTASIS_CRYPTO_SaltP truth_salt;
+
   /**
    * plaintext challenge which is sent to the client
    */
   void *challenge;
+
   /**
    * size of the challenge
    */
   size_t challenge_size;
+
   /**
    * method of the challenge
    */
   const char *escrow_method;
+
   /**
    * keyshare lookup operation
    */
   struct ANASTASIS_KeyShareLookupOperation *kslo;
+
   /**
    * Curl context
    */
   struct GNUNET_CURL_Context *ctx;
+
   /**
    * Encrypted key share
    */
   struct ANASTASIS_CRYPTO_KeyShareP *key_share;
+
   /**
    * Status of the challenge 0 pending, 1 solved
    */
   unsigned int solved;
+
   /**
    * Expected http status
    */
   unsigned int http_status;
+
   /**
    * Challenge instructions
    */
   char *instructions;
+
+  /**
+   * Cost for authentication
+   */
+  struct TALER_Amount cost;
 };
+
 /**
  * Function called with the results of a #ANASTASIS_keyshare_lookup().
  *
@@ -449,24 +472,20 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context 
*ctx,
  *
  * @param challenge reference to the escrow challenge which is started
  * @param cc opens a callback for the requested information
- * @param cc_cls handle for the request
  */
 void
-ANASTASIS_challenge_run (struct ANASTASIS_Challenge *challenge,
-                         ANASTASIS_ChallengeCallback cc,
-                         void *cc_cls)
+ANASTASIS_get_challenge (struct ANASTASIS_Challenge *challenge,
+                         ANASTASIS_ChallengeCallback cc)
 {
-
   // FIXME
   struct ANASTASIS_ChallengeInformation *ci;
   ci = GNUNET_new (struct ANASTASIS_ChallengeInformation);
   challenge->cc = cc;
-  challenge->cc_cls = cc_cls;
   ci->method = challenge->escrow_method;
   ci->url = challenge->url;
   ci->instructions = challenge->instructions;
-  challenge->cc (challenge->cc_cls,
-                 ci,
+  ci->solved = &challenge->solved;
+  challenge->cc (ci,
                  200);
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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