gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: work on payment


From: gnunet
Subject: [taler-anastasis] branch master updated: work on payment
Date: Mon, 16 Nov 2020 11:45:21 +0100

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 c46f696  work on payment
c46f696 is described below

commit c46f6963a265c1625ea56353fdefa2aab1aa9ca4
Author: Dominik Meister <dominik.meister@hotmail.ch>
AuthorDate: Mon Nov 16 11:45:13 2020 +0100

    work on payment
---
 src/include/anastasis_crypto_lib.h        |  4 +-
 src/include/anastasis_testing_lib.h       |  5 +-
 src/lib/test_anastasis_api.c              |  2 +
 src/lib/testing_api_cmd_keyshare_lookup.c | 90 ++++++++++++++-----------------
 4 files changed, 45 insertions(+), 56 deletions(-)

diff --git a/src/include/anastasis_crypto_lib.h 
b/src/include/anastasis_crypto_lib.h
index 491d71c..254528b 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -106,7 +106,7 @@ struct ANASTASIS_CRYPTO_EncryptedMasterKeyP
 
 
 /**
- * Specifies a Nonce used for the AES encryption, here defined as 32Byte large.
+   * Specifies a Nonce used for the AES encryption, here defined as 32Byte 
large.
 */
 struct ANASTASIS_CRYPTO_NonceP
 {
@@ -408,4 +408,4 @@ ANASTASIS_CRYPTO_core_secret_recover (
   const void *encrypted_core_secret,
   size_t encrypted_core_secret_size,
   void **core_secret,
-  size_t *core_secret_size);
\ No newline at end of file
+  size_t *core_secret_size);
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index f9cd892..0751e25 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -433,7 +433,7 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
  * @param http_status expected HTTP status.
  * @param answer (response to challenge)
  * @param key key to decrypt truth
- * @param payment secret secret used to pay
+ * @param payment_ref reference to the payment request
  * @param upload_ref reference to upload command
  * @param lookup_mode defines the mode (0= secure question, 1 code based)
  * @return the command
@@ -445,8 +445,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        char *answer,
                                        const struct
                                        ANASTASIS_CRYPTO_TruthKeyP key,
-                                       const struct
-                                       ANASTASIS_PaymentSecretP 
*payment_secret,
+                                       const char *payment_ref,
                                        int payment_requested,
                                        const char *upload_ref,
                                        int lookup_mode);
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 0e1549b..34f0146 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -318,6 +318,8 @@ run (void *cls,
                                            "challenge-run-2",
                                            ANASTASIS_TESTING_make_truthkey (
                                              "Truth-Key-2"),
+                                           "challenge-run-2",
+                                           1,
                                            "truth-store-2",
                                            1),
     TALER_TESTING_cmd_end ()
diff --git a/src/lib/testing_api_cmd_keyshare_lookup.c 
b/src/lib/testing_api_cmd_keyshare_lookup.c
index 7427925..5fb078a 100644
--- a/src/lib/testing_api_cmd_keyshare_lookup.c
+++ b/src/lib/testing_api_cmd_keyshare_lookup.c
@@ -55,7 +55,7 @@ struct KeyShareLookupState
   /**
    * answer to a challenge
    */
-  char *answer;
+  const char *answer;
 
   /**
    * Key to decrypt truth
@@ -72,6 +72,11 @@ struct KeyShareLookupState
    */
   const char *upload_reference;
 
+  /**
+   * Reference to upload command we expect to lookup.
+   */
+  const char *payment_reference;
+
   /**
    * Mode for the lookup(0 = question, 1 = code based)
    */
@@ -79,7 +84,7 @@ struct KeyShareLookupState
   /**
    * Payment secret used for the payment
    */
-  struct ANASTASIS_PaymentSecretP *payment_secret;
+  const struct ANASTASIS_PaymentSecretP *payment_secret;
 
   /**
    * if payment is needed or free
@@ -88,13 +93,6 @@ struct KeyShareLookupState
 
 };
 
-/**
- * Function called with the results of a #ANASTASIS_keyshare_lookup().
- *
- * @param cls closure
- * @param http_status HTTP status of the request
- * @param ud details about the lookup operation
- */
 static void
 keyshare_lookup_cb (void *cls,
                     unsigned int http_status,
@@ -117,14 +115,6 @@ keyshare_lookup_cb (void *cls,
   TALER_TESTING_interpreter_next (ksls->is);
 }
 
-
-/**
- * Run a "keyshare lookup" CMD.
- *
- * @param cls closure.
- * @param cmd command currently being run.
- * @param is interpreter state.
- */
 static void
 keyshare_lookup_run (void *cls,
                      const struct TALER_TESTING_Command *cmd,
@@ -201,15 +191,43 @@ keyshare_lookup_run (void *cls,
                   "Answer from trait: %s\n",
                   ksls->answer);
     }
-
   }
 
+  if (ksls->payment_requested)
+  {
+
+    const char *order_id;
+
+
+    if (GNUNET_OK !=
+        TALER_TESTING_get_trait_order_id (ksls->payment_reference,
+                                          0,
+                                          &order_id))
+    {
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (ksls->is);
+      return;
+    }
+
+    if (GNUNET_OK !=
+        GNUNET_STRINGS_string_to_data (order_id,
+                                       strlen (order_id),
+                                       &ksls->payment_secret,
+                                       sizeof (struct
+                                               ANASTASIS_PaymentSecretP)))
+    {
+      GNUNET_break_op (0);
+      TALER_TESTING_interpreter_fail (ksls->is);
+      return;
+    }
+
+  }
   ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
                                           ksls->anastasis_url,
                                           ksls->truth_public_key,
                                           &ksls->truth_key,
                                           ksls->payment_requested,
-                                          &ksls->payment_secret,
+                                          ksls->payment_secret,
                                           ksls->answer,
                                           &keyshare_lookup_cb,
                                           ksls);
@@ -221,14 +239,6 @@ keyshare_lookup_run (void *cls,
   }
 }
 
-
-/**
- * Free the state of a "keyshare lookup" CMD, and possibly
- * cancel it if it did not complete.
- *
- * @param cls closure.
- * @param cmd command being freed.
- */
 static void
 keyshare_lookup_cleanup (void *cls,
                          const struct TALER_TESTING_Command *cmd)
@@ -246,14 +256,6 @@ keyshare_lookup_cleanup (void *cls,
   GNUNET_free (ksls);
 }
 
-
-/**
- * Creates hash of an answer
- *
- * @param answer the answer to a challenge (e.g. a secure question)
- * @param size_answer size of the answer
- * @return hash of the answer
- */
 struct GNUNET_HashCode
 ANASTASIS_TESTING_make_hashed_answer (const void *answer,
                                       size_t size_answer)
@@ -268,19 +270,6 @@ ANASTASIS_TESTING_make_hashed_answer (const void *answer,
   return hashed_answer;
 }
 
-
-/**
- * Make the "keyshare lookup" command.
- *
- * @param label command label
- * @param anastasis_url base URL of the ANASTASIS serving
- *        the keyshare lookup request.
- * @param http_status expected HTTP status.
- * @param answer hashed answer (response to challenge)
- * @param key key to decrypt truth
- * @param upload_ref reference to upload command
- * @return the command
- */
 struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        const char *anastasis_url,
@@ -288,8 +277,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        char *answer,
                                        const struct
                                        ANASTASIS_CRYPTO_TruthKeyP key,
-                                       const struct
-                                       ANASTASIS_PaymentSecretP 
*payment_secret,
+                                       const char *payment_ref,
                                        int payment_requested,
                                        const char *upload_ref,
                                        int lookup_mode)
@@ -308,7 +296,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
   ksls->http_status = http_status;
   ksls->anastasis_url = anastasis_url;
   ksls->upload_reference = upload_ref;
-  ksls->payment_secret = payment_secret;
+  ksls->payment_reference = payment_ref;
   ksls->payment_requested = payment_requested;
   ksls->answer = answer;
   ksls->truth_key = key;

-- 
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]