gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: -preserve secret name


From: gnunet
Subject: [taler-anastasis] branch master updated: -preserve secret name
Date: Tue, 13 Jul 2021 22:10:37 +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 ab1423d  -preserve secret name
ab1423d is described below

commit ab1423d49e2a13d3e172458750cb67e8ebf88f32
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Jul 13 22:10:35 2021 +0200

    -preserve secret name
---
 src/include/anastasis.h                    |  5 +++++
 src/lib/anastasis_recovery.c               | 28 +++++++++++++++++++++++++++-
 src/reducer/anastasis_api_recovery_redux.c |  3 ++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 668bafe..7015df3 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -363,6 +363,11 @@ struct ANASTASIS_RecoveryInformation
    */
   struct ANASTASIS_Challenge **cs;
 
+  /**
+   * Name of the secret being recovered, possibly NULL.
+   */
+  const char *secret_name;
+
   /**
    * Length of the @e dps array.
    */
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index 2ed95ab..7129811 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -204,6 +204,11 @@ struct ANASTASIS_Recovery
    */
   char *provider_url;
 
+  /**
+   * Name of the secret, can be NULL.
+   */
+  char *secret_name;
+
   /**
    * Task to run @e pc asynchronously.
    */
@@ -681,11 +686,15 @@ policy_lookup_cb (void *cls,
     }
 
     {
+      const char *secret_name = NULL;
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_json ("policies",
                                &dec_policies),
         GNUNET_JSON_spec_json ("escrow_methods",
                                &esc_methods),
+        GNUNET_JSON_spec_mark_optional (
+          GNUNET_JSON_spec_string ("secret_name",
+                                   &secret_name)),
         GNUNET_JSON_spec_varsize ("core_secret",
                                   &r->enc_core_secret,
                                   &r->enc_core_secret_size),
@@ -706,6 +715,12 @@ policy_lookup_cb (void *cls,
         ANASTASIS_recovery_abort (r);
         return;
       }
+      if (NULL != secret_name)
+      {
+        GNUNET_break (NULL == r->secret_name);
+        r->secret_name = GNUNET_strdup (secret_name);
+        r->ri.secret_name = r->secret_name;
+      }
     }
     json_decref (recovery_document);
   }
@@ -998,7 +1013,8 @@ ANASTASIS_recovery_serialize (const struct 
ANASTASIS_Recovery *r)
                                           cs));
   }
 
-  return json_pack ("{s:o, s:o, s:o, s:I, s:O, s:s, s:o}",
+  return json_pack ("{s:o, s:o, s:o, s:I, s:O, "
+                    " s:s, s:s?, s:o}",
                     "id",
                     GNUNET_JSON_from_data_auto (&r->id),
                     "dps",
@@ -1011,6 +1027,8 @@ ANASTASIS_recovery_serialize (const struct 
ANASTASIS_Recovery *r)
                     r->id_data,
                     "provider_url",
                     r->provider_url,
+                    "secret_name",
+                    r->secret_name,
                     "core_secret",
                     GNUNET_JSON_from_data (r->enc_core_secret,
                                            r->enc_core_secret_size));
@@ -1256,6 +1274,7 @@ ANASTASIS_recovery_deserialize (struct 
GNUNET_CURL_Context *ctx,
     json_t *cs_arr;
     json_t *id_data;
     const char *provider_url;
+    const char *secret_name;
     void *ecs;
     size_t ecs_size;
     struct GNUNET_JSON_Specification spec[] = {
@@ -1263,6 +1282,9 @@ ANASTASIS_recovery_deserialize (struct 
GNUNET_CURL_Context *ctx,
                                    &r->id),
       GNUNET_JSON_spec_string ("provider_url",
                                &provider_url),
+      GNUNET_JSON_spec_mark_optional (
+        GNUNET_JSON_spec_string ("secret_name",
+                                 &secret_name)),
       GNUNET_JSON_spec_uint32 ("version",
                                &version),
       GNUNET_JSON_spec_json ("dps",
@@ -1306,6 +1328,9 @@ ANASTASIS_recovery_deserialize (struct 
GNUNET_CURL_Context *ctx,
     }
     r->id_data = json_incref (id_data);
     r->provider_url = GNUNET_strdup (provider_url);
+    if (NULL != secret_name)
+      r->secret_name = GNUNET_strdup (secret_name);
+    r->ri.secret_name = r->secret_name;
     if (0 != ecs_size)
     {
       r->enc_core_secret = GNUNET_memdup (ecs,
@@ -1389,6 +1414,7 @@ ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r)
   GNUNET_free (r->dps);
   json_decref (r->id_data);
   GNUNET_free (r->provider_url);
+  GNUNET_free (r->secret_name);
   GNUNET_free (r->enc_core_secret);
   GNUNET_free (r);
 }
diff --git a/src/reducer/anastasis_api_recovery_redux.c 
b/src/reducer/anastasis_api_recovery_redux.c
index d173a4c..d2d99f8 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -2220,9 +2220,10 @@ policy_lookup_cb (void *cls,
                    json_array_append_new (challenges,
                                           cj));
   } /* end for all challenges */
-  recovery_information = json_pack ("{s:o, s:o, s:s, s:I}",
+  recovery_information = json_pack ("{s:o, s:o, s:s?, s:s, s:I}",
                                     "challenges", challenges,
                                     "policies", policies,
+                                    "secret_name", ri->secret_name,
                                     "provider_url", pd->backend_url,
                                     "version", (json_int_t) ri->version);
   GNUNET_assert (NULL != recovery_information);

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