gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: add mime to core secret (#6825)


From: gnunet
Subject: [taler-anastasis] branch master updated: add mime to core secret (#6825)
Date: Sun, 04 Apr 2021 15:50:19 +0200

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 9c925c2  add mime to core secret (#6825)
9c925c2 is described below

commit 9c925c2e372c31ebd9da3fed9d2b0f9169bbda3a
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Apr 4 15:49:18 2021 +0200

    add mime to core secret (#6825)
---
 contrib/gana                                           |  2 +-
 src/cli/test_anastasis_reducer_enter_secret.sh         |  2 +-
 ...anastasis_reducer_recovery_enter_user_attributes.sh | 10 ++++++++--
 src/include/anastasis_database_plugin.h                |  4 ++--
 src/lib/anastasis_backup.c                             |  2 --
 src/reducer/anastasis_api_backup_redux.c               | 11 ++++++++---
 src/reducer/anastasis_api_recovery_redux.c             | 18 ++++++++++++++++--
 src/stasis/plugin_anastasis_postgres.c                 |  4 +++-
 8 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 65b3235..962d417 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 65b32359b300f5369eff62fceb5001e609c2f339
+Subproject commit 962d417a99000b79a29994cd445db3c5251ac3bc
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh 
b/src/cli/test_anastasis_reducer_enter_secret.sh
index da5ac68..5236281 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -272,7 +272,7 @@ echo " DONE"
 echo -en $COLOR$BOLD"Test enter secret in a backup state ..."$NORM$NOCOLOR
 
 $PREFIX anastasis-reducer -a \
-  '{"secret": "veryhardtoguesssecret" }' \
+  '{"secret": { "value" : "veryhardtoguesssecret", "mime" : "text/plain" } }' \
   enter_secret resources/06-backup.json $TFILE
 
 STATE=`jq -r -e .backup_state < $TFILE`
diff --git a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh 
b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
index 1a7ba7b..796acd9 100755
--- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
@@ -325,7 +325,7 @@ echo -n "."
 
 # Note: 'secret' must here be a Crockford base32-encoded value
 anastasis-reducer -a \
-  '{"secret": "VERYHARDT0GVESSSECRET"}' \
+  '{"secret": { "value" : "VERYHARDT0GVESSSECRET", "mime" : "text/plain" }}' \
   enter_secret < $B1FILE > $B2FILE
 echo " OK"
 echo -n "Preparing wallet"
@@ -452,12 +452,18 @@ then
     exit_fail "Expected new state to be 'RECOVERY_FINISHED', got '$STATE'"
 fi
 
-SECRET=`jq -r -e .core_secret < $R2FILE`
+SECRET=`jq -r -e .core_secret.value < $R2FILE`
 if test "$SECRET" != "VERYHARDT0GVESSSECRET"
 then
     exit_fail "Expected recovered secret to be 'VERYHARDT0GVESSSECRET', got 
'$SECRET'"
 fi
 
+MIME=`jq -r -e .core_secret.mime < $R2FILE`
+if test "$MIME" != "text/plain"
+then
+    exit_fail "Expected recovered mime to be 'text/plain', got '$MIME'"
+fi
+
 echo " OK"
 
 exit 0
diff --git a/src/include/anastasis_database_plugin.h 
b/src/include/anastasis_database_plugin.h
index b63fefa..1d1420f 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -539,8 +539,8 @@ struct ANASTASIS_DatabasePlugin
    * @param[out] retransmission_date when to next retransmit
    * @param[out] code set to the code which will be checked for later
    * @return transaction status,
-   *        #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a code was already in the 
DB
-   *        #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if this @a code is now in the 
DB
+   *        #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if we are out of valid tries,
+   *        #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if @a code is now in the DB
    */
   enum GNUNET_DB_QueryStatus
   (*create_challenge_code)(
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index 879e5bd..17363c6 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -404,8 +404,6 @@ ANASTASIS_truth_upload (
   struct ANASTASIS_CRYPTO_KeyShareP key_share;
   struct ANASTASIS_CRYPTO_NonceP nonce;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Creating fresh truth object\n");
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                               &nonce,
                               sizeof (nonce));
diff --git a/src/reducer/anastasis_api_backup_redux.c 
b/src/reducer/anastasis_api_backup_redux.c
index ec80434..b8f98f5 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -2457,12 +2457,12 @@ enter_secret (json_t *state,
               ANASTASIS_ActionCallback cb,
               void *cb_cls)
 {
+  json_t *jsecret;
   void *secret;
   size_t secret_size;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_varsize ("secret",
-                              &secret,
-                              &secret_size),
+    GNUNET_JSON_spec_json ("secret",
+                           &jsecret),
     GNUNET_JSON_spec_end ()
   };
 
@@ -2485,11 +2485,16 @@ enter_secret (json_t *state,
                            "'secret' argument required");
     return NULL;
   }
+  secret = json_dumps (jsecret,
+                       JSON_COMPACT | JSON_SORT_KEYS);
+  GNUNET_assert (NULL != secret);
+  secret_size = strlen (secret);
   GNUNET_assert (0 ==
                  json_object_set_new (state,
                                       "core_secret",
                                       GNUNET_JSON_from_data (secret,
                                                              secret_size)));
+  GNUNET_free (secret);
   GNUNET_JSON_parse_free (spec);
   return upload (state,
                  cb,
diff --git a/src/reducer/anastasis_api_recovery_redux.c 
b/src/reducer/anastasis_api_recovery_redux.c
index 5ab977d..e58ee55 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -271,11 +271,25 @@ core_secret_cb (void *cls,
   sctx->r = NULL;
   if (ANASTASIS_RS_SUCCESS == rc)
   {
+    json_t *jsecret;
+
+    jsecret = json_loadb (secret,
+                          secret_size,
+                          JSON_REJECT_DUPLICATES,
+                          NULL);
+    if (NULL == jsecret)
+    {
+      ANASTASIS_redux_fail_ (sctx->cb,
+                             sctx->cb_cls,
+                             TALER_EC_ANASTASIS_REDUCER_SECRET_MALFORMED,
+                             NULL);
+      sctx_free (sctx);
+      return;
+    }
     GNUNET_assert (0 ==
                    json_object_set_new (sctx->state,
                                         "core_secret",
-                                        GNUNET_JSON_from_data (secret,
-                                                               secret_size)));
+                                        jsecret));
     set_state (sctx->state,
                ANASTASIS_RECOVERY_STATE_RECOVERY_FINISHED);
     sctx->cb (sctx->cb_cls,
diff --git a/src/stasis/plugin_anastasis_postgres.c 
b/src/stasis/plugin_anastasis_postgres.c
index 4a759ce..725e7fd 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -1563,7 +1563,9 @@ postgres_update_challenge_payment (
  * @param retry_counter amount of retries allowed
  * @param[out] retransmission_date when to next retransmit
  * @param[out] code set to the code which will be checked for later
- * @return transaction status
+ * @return transaction status,
+ *        #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if we are out of valid tries,
+ *        #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if @a code is now in the DB
  */
 enum GNUNET_DB_QueryStatus
 postgres_create_challenge_code (

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