gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated: working on keys path, cleanup in js


From: gnunet
Subject: [taler-donau] branch master updated: working on keys path, cleanup in json helper
Date: Sat, 16 Mar 2024 16:37:01 +0100

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

johannes-casaburi pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new 6985bfa  working on keys path, cleanup in json helper
6985bfa is described below

commit 6985bfa6274d138258edac2d0625082560678b68
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Sat Mar 16 16:36:16 2024 +0100

    working on keys path, cleanup in json helper
---
 src/donau/donau-httpd_keys.c |  54 ++-
 src/json/json_helper.c       | 956 -------------------------------------------
 2 files changed, 33 insertions(+), 977 deletions(-)

diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c
index 2d218d2..a75b9c7 100644
--- a/src/donau/donau-httpd_keys.c
+++ b/src/donau/donau-httpd_keys.c
@@ -623,11 +623,21 @@ insert_donation_unit_cb (void *cls,
   du = GNUNET_CONTAINER_multihashmap_get (
     kbc->ksh->donation_unit_map,
     h_du_pub);
+
   if (NULL != du)
     return GNUNET_OK; /* skip: this key is already active! */
+
   // if (GNUNET_TIME_relative_is_zero (hd->validity_duration))
   // return GNUNET_OK; /* this key already expired! */
 
+  // if (GNUNET_OK !=
+  //     load_extension_data (hd->section_name,
+  //                          &meta))
+  // {
+  //   /* Woops, couldn't determine fee structure!? */
+  //   return GNUNET_OK;
+  // }
+
   GNUNET_assert (
     0 == json_array_append_new (
       kbc->donation_units,
@@ -652,7 +662,7 @@ insert_donation_unit_cb (void *cls,
  * and @a denoms.
  *
  * @param[in,out] ksh key state handle we build @a krd for
- * @param[in] h_donation_unit_pub hash over all the denomination keys in @a 
denoms
+ * @param[in] du_keys_hash hash over all the denomination keys in @a denoms
  * @param last_cherry_pick_date timestamp to use
  * @param[in,out] signkeys list of sign keys to return
  * @param[in,out] grouped_donation_units list of grouped denominations to 
return
@@ -660,7 +670,7 @@ insert_donation_unit_cb (void *cls,
  */
 static enum GNUNET_GenericReturnValue
 create_krd (struct DH_KeyStateHandle *ksh,
-            const struct GNUNET_HashCode *h_du_pub,
+            const struct GNUNET_HashCode *du_keys_hash,
             struct GNUNET_TIME_Timestamp last_cherry_pick_date,
             json_t *signkeys,
             json_t *grouped_donation_units)
@@ -680,18 +690,18 @@ create_krd (struct DH_KeyStateHandle *ksh,
               "Creating /keys at cherry pick date %s\n",
               GNUNET_TIME_timestamp2s (last_cherry_pick_date));
 
-  // /* Sign hash over master signatures of all denomination keys until this 
time
-  //    (in reverse order). */
+  /* Sign hash over master signatures of all denomination keys until this time
+     (in reverse order). */
   // {
-  //  enum TALER_ErrorCode ec;
+  // enum TALER_ErrorCode ec;
   //
   //  if (TALER_EC_NONE !=
   //      (ec =
-  //         TALER_donau_online_key_set_sign (
+  //         DONAU_donau_online_key_set_sign (
   //           &TEH_keys_donau_sign2_,
   //           ksh,
   //           last_cherry_pick_date,
-  //           h_donation_unit_pub,
+  //           du_keys_hash,
   //           &donau_pub,
   //           &donau_sig)))
   //  {
@@ -701,17 +711,17 @@ create_krd (struct DH_KeyStateHandle *ksh,
   //    return GNUNET_SYSERR;
   //  }
   // }
-
-  {
-    const struct SigningKey *sk;
-
-    sk = GNUNET_CONTAINER_multipeermap_get (ksh->signkey_map,
-                                            (const struct GNUNET_PeerIdentity 
*)
-                                            &donau_pub);
-
-    ksh->signature_expires = GNUNET_TIME_timestamp_min (sk->meta.expire_sign,
-                                                        
ksh->signature_expires);
-  }
+  //
+  // {
+  //  const struct SigningKey *sk;
+  //
+  //  sk = GNUNET_CONTAINER_multipeermap_get (ksh->signkey_map,
+  //                                          (const struct 
GNUNET_PeerIdentity *)
+  //                                          &donau_pub);
+  //
+  //  ksh->signature_expires = GNUNET_TIME_timestamp_min (sk->meta.expire_sign,
+  //                                                      
ksh->signature_expires);
+  // }
 
   keys = GNUNET_JSON_PACK (
     GNUNET_JSON_pack_string ("version",
@@ -1083,6 +1093,7 @@ finish_keys_response (struct DH_KeyStateHandle *ksh)
         //                  group->group_off,
         //                  (unsigned int) json_array_size (group->list),
         //                  &dk->master_sig);
+
         /* Finally, add the denomination to the list of donation_units in this
            group */
         GNUNET_assert (json_is_array (group->list));
@@ -1324,14 +1335,13 @@ check_esign_sm_pub (const struct 
TALER_SecurityModulePublicKeyP *sm_pub)
  */
 static enum GNUNET_GenericReturnValue
 free_donation_unit_cb (void *cls,
-                       const struct DONAU_DonationUnitHashP 
*h_donation_unit_pub
-                       ,
+                       const struct GNUNET_HashCode *h_du_pub,
                        void *value)
 {
   struct HelperDonationUnit *hd = value;
 
   (void) cls;
-  (void) h_donation_unit_pub;
+  (void) h_du_pub;
   DONAU_donation_unit_pub_free (&hd->donation_unit_pub);
   GNUNET_free (hd->section_name);
   GNUNET_free (hd);
@@ -1518,6 +1528,7 @@ helper_rsa_cb (
     &value);
   if (qs < 0)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to insert donation units");
     // FIXME: error, probably should not proceed...
   }
   hd->section_name = GNUNET_strdup (section_name);
@@ -1619,6 +1630,7 @@ helper_cs_cb (
     &value);
   if (qs < 0)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to insert donation units");
     // FIXME: error, probably should not proceed...
   }
 
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 8848430..c5bd98c 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -270,77 +270,6 @@ TALER_JSON_spec_currency_specification (
 }
 
 
-static enum GNUNET_GenericReturnValue
-parse_denomination_group (void *cls,
-                          json_t *root,
-                          struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_DenominationGroup *group = spec->ptr;
-  const char *cipher;
-  const char *currency = cls;
-  bool age_mask_missing = false;
-  bool has_age_restricted_suffix = false;
-  struct GNUNET_JSON_Specification gspec[] = {
-    GNUNET_JSON_spec_string ("cipher",
-                             &cipher),
-    TALER_JSON_spec_amount ("value",
-                            currency,
-                            &group->value),
-    TALER_JSON_SPEC_DENOM_FEES ("fee",
-                                currency,
-                                &group->fees),
-    GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_uint32 ("age_mask",
-                               &group->age_mask.bits),
-      &age_mask_missing),
-    GNUNET_JSON_spec_end ()
-  };
-  const char *emsg;
-  unsigned int eline;
-
-  if (GNUNET_OK !=
-      GNUNET_JSON_parse (root,
-                         gspec,
-                         &emsg,
-                         &eline))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Failed to parse %s at %u: %s\n",
-                spec[eline].field,
-                eline,
-                emsg);
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-
-  group->cipher = string_to_cipher (cipher);
-  if (GNUNET_CRYPTO_BSA_INVALID == group->cipher)
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-
-  return GNUNET_OK;
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_denomination_group (const char *name,
-                                    const char *currency,
-                                    struct TALER_DenominationGroup *group)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .cls = (void *) currency,
-    .parser = &parse_denomination_group,
-    .field = name,
-    .ptr = group,
-    .ptr_size = sizeof(*group)
-  };
-
-  return ret;
-}
-
-
 /**
  * Parse given JSON object to an encrypted contract.
  *
@@ -414,841 +343,6 @@ TALER_JSON_spec_econtract (const char *name,
 }
 
 
-/**
- * Parse given JSON object to an age commitmnet
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_age_commitment (void *cls,
-                      json_t *root,
-                      struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_AgeCommitment *age_commitment = spec->ptr;
-  json_t *pk;
-  unsigned int idx;
-  size_t num;
-
-  (void) cls;
-  if ( (NULL == root) ||
-       (! json_is_array (root)))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-
-  num = json_array_size (root);
-  if (32 <= num || 0 == num)
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-
-  age_commitment->num = num;
-  age_commitment->keys =
-    GNUNET_new_array (num,
-                      struct TALER_AgeCommitmentPublicKeyP);
-
-  json_array_foreach (root, idx, pk) {
-    const char *emsg;
-    unsigned int eline;
-    struct GNUNET_JSON_Specification pkspec[] = {
-      GNUNET_JSON_spec_fixed_auto (
-        NULL,
-        &age_commitment->keys[idx].pub),
-      GNUNET_JSON_spec_end ()
-    };
-
-    if (GNUNET_OK !=
-        GNUNET_JSON_parse (pk,
-                           pkspec,
-                           &emsg,
-                           &eline))
-    {
-      GNUNET_break_op (0);
-      GNUNET_JSON_parse_free (spec);
-      return GNUNET_SYSERR;
-    }
-  };
-
-  return GNUNET_OK;
-}
-
-
-/**
- * Cleanup data left from parsing age commitment
- *
- * @param cls closure, NULL
- * @param[out] spec where to free the data
- */
-static void
-clean_age_commitment (void *cls,
-                      struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_AgeCommitment *age_commitment = spec->ptr;
-
-  (void) cls;
-
-  if (NULL == age_commitment ||
-      NULL == age_commitment->keys)
-    return;
-
-  age_commitment->num = 0;
-  GNUNET_free (age_commitment->keys);
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_age_commitment (const char *name,
-                                struct TALER_AgeCommitment *age_commitment)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_age_commitment,
-    .cleaner = &clean_age_commitment,
-    .field = name,
-    .ptr = age_commitment
-  };
-
-  return ret;
-}
-
-
-/**
- * Parse given JSON object to denomination public key.
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_denom_pub (void *cls,
-                 json_t *root,
-                 struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_DenominationPublicKey *denom_pub = spec->ptr;
-  struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub;
-  const char *cipher;
-  bool age_mask_missing = false;
-  struct GNUNET_JSON_Specification dspec[] = {
-    GNUNET_JSON_spec_string ("cipher",
-                             &cipher),
-    GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_uint32 ("age_mask",
-                               &denom_pub->age_mask.bits),
-      &age_mask_missing),
-    GNUNET_JSON_spec_end ()
-  };
-  const char *emsg;
-  unsigned int eline;
-
-  (void) cls;
-  if (GNUNET_OK !=
-      GNUNET_JSON_parse (root,
-                         dspec,
-                         &emsg,
-                         &eline))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-
-  if (age_mask_missing)
-    denom_pub->age_mask.bits = 0;
-  bsign_pub = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey);
-  bsign_pub->rc = 1;
-  bsign_pub->cipher = string_to_cipher (cipher);
-  switch (bsign_pub->cipher)
-  {
-  case GNUNET_CRYPTO_BSA_INVALID:
-    break;
-  case GNUNET_CRYPTO_BSA_RSA:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_rsa_public_key (
-          "rsa_public_key",
-          &bsign_pub->details.rsa_public_key),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (bsign_pub);
-        return GNUNET_SYSERR;
-      }
-      denom_pub->bsign_pub_key = bsign_pub;
-      return GNUNET_OK;
-    }
-  case GNUNET_CRYPTO_BSA_CS:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_fixed ("cs_public_key",
-                                &bsign_pub->details.cs_public_key,
-                                sizeof (bsign_pub->details.cs_public_key)),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (bsign_pub);
-        return GNUNET_SYSERR;
-      }
-      denom_pub->bsign_pub_key = bsign_pub;
-      return GNUNET_OK;
-    }
-  }
-  GNUNET_break_op (0);
-  GNUNET_free (bsign_pub);
-  return GNUNET_SYSERR;
-}
-
-
-/**
- * Cleanup data left from parsing denomination public key.
- *
- * @param cls closure, NULL
- * @param[out] spec where to free the data
- */
-static void
-clean_denom_pub (void *cls,
-                 struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_DenominationPublicKey *denom_pub = spec->ptr;
-
-  (void) cls;
-  TALER_denom_pub_free (denom_pub);
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_denom_pub (const char *field,
-                           struct TALER_DenominationPublicKey *pk)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_denom_pub,
-    .cleaner = &clean_denom_pub,
-    .field = field,
-    .ptr = pk
-  };
-
-  pk->bsign_pub_key = NULL;
-  return ret;
-}
-
-
-/**
- * Parse given JSON object partially into a denomination public key.
- *
- * Depending on the cipher in cls, it parses the corresponding public key type.
- *
- * @param cls closure, enum GNUNET_CRYPTO_BlindSignatureAlgorithm
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_denom_pub_cipher (void *cls,
-                        json_t *root,
-                        struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_DenominationPublicKey *denom_pub = spec->ptr;
-  enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher =
-    (enum GNUNET_CRYPTO_BlindSignatureAlgorithm) (long) cls;
-  struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub;
-  const char *emsg;
-  unsigned int eline;
-
-  bsign_pub = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey);
-  bsign_pub->cipher = cipher;
-  bsign_pub->rc = 1;
-  switch (cipher)
-  {
-  case GNUNET_CRYPTO_BSA_INVALID:
-    break;
-  case GNUNET_CRYPTO_BSA_RSA:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_rsa_public_key (
-          "rsa_pub",
-          &bsign_pub->details.rsa_public_key),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (bsign_pub);
-        return GNUNET_SYSERR;
-      }
-      denom_pub->bsign_pub_key = bsign_pub;
-      return GNUNET_OK;
-    }
-  case GNUNET_CRYPTO_BSA_CS:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_fixed ("cs_pub",
-                                &bsign_pub->details.cs_public_key,
-                                sizeof (bsign_pub->details.cs_public_key)),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (bsign_pub);
-        return GNUNET_SYSERR;
-      }
-      denom_pub->bsign_pub_key = bsign_pub;
-      return GNUNET_OK;
-    }
-  }
-  GNUNET_break_op (0);
-  GNUNET_free (bsign_pub);
-  return GNUNET_SYSERR;
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_denom_pub_cipher (const char *field,
-                                  enum GNUNET_CRYPTO_BlindSignatureAlgorithm
-                                  cipher,
-                                  struct TALER_DenominationPublicKey *pk)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_denom_pub_cipher,
-    .cleaner = &clean_denom_pub,
-    .field = field,
-    .cls = (void *) cipher,
-    .ptr = pk
-  };
-
-  return ret;
-}
-
-
-/**
- * Parse given JSON object to denomination signature.
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_denom_sig (void *cls,
-                 json_t *root,
-                 struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_DenominationSignature *denom_sig = spec->ptr;
-  struct GNUNET_CRYPTO_UnblindedSignature *unblinded_sig;
-  const char *cipher;
-  struct GNUNET_JSON_Specification dspec[] = {
-    GNUNET_JSON_spec_string ("cipher",
-                             &cipher),
-    GNUNET_JSON_spec_end ()
-  };
-  const char *emsg;
-  unsigned int eline;
-
-  (void) cls;
-  if (GNUNET_OK !=
-      GNUNET_JSON_parse (root,
-                         dspec,
-                         &emsg,
-                         &eline))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  unblinded_sig = GNUNET_new (struct GNUNET_CRYPTO_UnblindedSignature);
-  unblinded_sig->cipher = string_to_cipher (cipher);
-  unblinded_sig->rc = 1;
-  switch (unblinded_sig->cipher)
-  {
-  case GNUNET_CRYPTO_BSA_INVALID:
-    break;
-  case GNUNET_CRYPTO_BSA_RSA:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_rsa_signature (
-          "rsa_signature",
-          &unblinded_sig->details.rsa_signature),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (unblinded_sig);
-        return GNUNET_SYSERR;
-      }
-      denom_sig->unblinded_sig = unblinded_sig;
-      return GNUNET_OK;
-    }
-  case GNUNET_CRYPTO_BSA_CS:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_fixed_auto ("cs_signature_r",
-                                     &unblinded_sig->details.cs_signature.
-                                     r_point),
-        GNUNET_JSON_spec_fixed_auto ("cs_signature_s",
-                                     &unblinded_sig->details.cs_signature.
-                                     s_scalar),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (unblinded_sig);
-        return GNUNET_SYSERR;
-      }
-      denom_sig->unblinded_sig = unblinded_sig;
-      return GNUNET_OK;
-    }
-  }
-  GNUNET_break_op (0);
-  GNUNET_free (unblinded_sig);
-  return GNUNET_SYSERR;
-}
-
-
-/**
- * Cleanup data left from parsing denomination public key.
- *
- * @param cls closure, NULL
- * @param[out] spec where to free the data
- */
-static void
-clean_denom_sig (void *cls,
-                 struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_DenominationSignature *denom_sig = spec->ptr;
-
-  (void) cls;
-  TALER_denom_sig_free (denom_sig);
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_denom_sig (const char *field,
-                           struct TALER_DenominationSignature *sig)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_denom_sig,
-    .cleaner = &clean_denom_sig,
-    .field = field,
-    .ptr = sig
-  };
-
-  sig->unblinded_sig = NULL;
-  return ret;
-}
-
-
-/**
- * Parse given JSON object to blinded denomination signature.
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_blinded_denom_sig (void *cls,
-                         json_t *root,
-                         struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_BlindedDenominationSignature *denom_sig = spec->ptr;
-  struct GNUNET_CRYPTO_BlindedSignature *blinded_sig;
-  const char *cipher;
-  struct GNUNET_JSON_Specification dspec[] = {
-    GNUNET_JSON_spec_string ("cipher",
-                             &cipher),
-    GNUNET_JSON_spec_end ()
-  };
-  const char *emsg;
-  unsigned int eline;
-
-  (void) cls;
-  if (GNUNET_OK !=
-      GNUNET_JSON_parse (root,
-                         dspec,
-                         &emsg,
-                         &eline))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  blinded_sig = GNUNET_new (struct GNUNET_CRYPTO_BlindedSignature);
-  blinded_sig->cipher = string_to_cipher (cipher);
-  blinded_sig->rc = 1;
-  switch (blinded_sig->cipher)
-  {
-  case GNUNET_CRYPTO_BSA_INVALID:
-    break;
-  case GNUNET_CRYPTO_BSA_RSA:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_rsa_signature (
-          "blinded_rsa_signature",
-          &blinded_sig->details.blinded_rsa_signature),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (blinded_sig);
-        return GNUNET_SYSERR;
-      }
-      denom_sig->blinded_sig = blinded_sig;
-      return GNUNET_OK;
-    }
-  case GNUNET_CRYPTO_BSA_CS:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_uint32 ("b",
-                                 &blinded_sig->details.blinded_cs_answer.b),
-        GNUNET_JSON_spec_fixed_auto ("s",
-                                     &blinded_sig->details.blinded_cs_answer.
-                                     s_scalar),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (blinded_sig);
-        return GNUNET_SYSERR;
-      }
-      denom_sig->blinded_sig = blinded_sig;
-      return GNUNET_OK;
-    }
-  }
-  GNUNET_break_op (0);
-  GNUNET_free (blinded_sig);
-  return GNUNET_SYSERR;
-}
-
-
-/**
- * Cleanup data left from parsing denomination public key.
- *
- * @param cls closure, NULL
- * @param[out] spec where to free the data
- */
-static void
-clean_blinded_denom_sig (void *cls,
-                         struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_BlindedDenominationSignature *denom_sig = spec->ptr;
-
-  (void) cls;
-  TALER_blinded_denom_sig_free (denom_sig);
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_blinded_denom_sig (
-  const char *field,
-  struct TALER_BlindedDenominationSignature *sig)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_blinded_denom_sig,
-    .cleaner = &clean_blinded_denom_sig,
-    .field = field,
-    .ptr = sig
-  };
-
-  sig->blinded_sig = NULL;
-  return ret;
-}
-
-
-/**
- * Parse given JSON object to blinded planchet.
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_blinded_planchet (void *cls,
-                        json_t *root,
-                        struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_BlindedPlanchet *blinded_planchet = spec->ptr;
-  struct GNUNET_CRYPTO_BlindedMessage *blinded_message;
-  const char *cipher;
-  struct GNUNET_JSON_Specification dspec[] = {
-    GNUNET_JSON_spec_string ("cipher",
-                             &cipher),
-    GNUNET_JSON_spec_end ()
-  };
-  const char *emsg;
-  unsigned int eline;
-
-  (void) cls;
-  if (GNUNET_OK !=
-      GNUNET_JSON_parse (root,
-                         dspec,
-                         &emsg,
-                         &eline))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  blinded_message = GNUNET_new (struct GNUNET_CRYPTO_BlindedMessage);
-  blinded_message->rc = 1;
-  blinded_message->cipher = string_to_cipher (cipher);
-  switch (blinded_message->cipher)
-  {
-  case GNUNET_CRYPTO_BSA_INVALID:
-    break;
-  case GNUNET_CRYPTO_BSA_RSA:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_varsize (
-          "rsa_blinded_planchet",
-          &blinded_message->details.rsa_blinded_message.blinded_msg,
-          &blinded_message->details.rsa_blinded_message.blinded_msg_size),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (blinded_message);
-        return GNUNET_SYSERR;
-      }
-      blinded_planchet->blinded_message = blinded_message;
-      return GNUNET_OK;
-    }
-  case GNUNET_CRYPTO_BSA_CS:
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_fixed_auto (
-          "cs_nonce",
-          &blinded_message->details.cs_blinded_message.nonce),
-        GNUNET_JSON_spec_fixed_auto (
-          "cs_blinded_c0",
-          &blinded_message->details.cs_blinded_message.c[0]),
-        GNUNET_JSON_spec_fixed_auto (
-          "cs_blinded_c1",
-          &blinded_message->details.cs_blinded_message.c[1]),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (blinded_message);
-        return GNUNET_SYSERR;
-      }
-      blinded_planchet->blinded_message = blinded_message;
-      return GNUNET_OK;
-    }
-  }
-  GNUNET_break_op (0);
-  GNUNET_free (blinded_message);
-  return GNUNET_SYSERR;
-}
-
-
-/**
- * Cleanup data left from parsing blinded planchet.
- *
- * @param cls closure, NULL
- * @param[out] spec where to free the data
- */
-static void
-clean_blinded_planchet (void *cls,
-                        struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_BlindedPlanchet *blinded_planchet = spec->ptr;
-
-  (void) cls;
-  TALER_blinded_planchet_free (blinded_planchet);
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_blinded_planchet (const char *field,
-                                  struct TALER_BlindedPlanchet 
*blinded_planchet)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_blinded_planchet,
-    .cleaner = &clean_blinded_planchet,
-    .field = field,
-    .ptr = blinded_planchet
-  };
-
-  blinded_planchet->blinded_message = NULL;
-  return ret;
-}
-
-
-/**
- * Parse given JSON object to exchange withdraw values (/csr).
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_exchange_withdraw_values (void *cls,
-                                json_t *root,
-                                struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_ExchangeWithdrawValues *ewv = spec->ptr;
-  struct GNUNET_CRYPTO_BlindingInputValues *bi;
-  const char *cipher;
-  struct GNUNET_JSON_Specification dspec[] = {
-    GNUNET_JSON_spec_string ("cipher",
-                             &cipher),
-    GNUNET_JSON_spec_end ()
-  };
-  const char *emsg;
-  unsigned int eline;
-  enum GNUNET_CRYPTO_BlindSignatureAlgorithm ci;
-
-  (void) cls;
-  if (GNUNET_OK !=
-      GNUNET_JSON_parse (root,
-                         dspec,
-                         &emsg,
-                         &eline))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  ci = string_to_cipher (cipher);
-  switch (ci)
-  {
-  case GNUNET_CRYPTO_BSA_INVALID:
-    break;
-  case GNUNET_CRYPTO_BSA_RSA:
-    ewv->blinding_inputs = TALER_denom_ewv_rsa_singleton ()->blinding_inputs;
-    return GNUNET_OK;
-  case GNUNET_CRYPTO_BSA_CS:
-    bi = GNUNET_new (struct GNUNET_CRYPTO_BlindingInputValues);
-    bi->cipher = GNUNET_CRYPTO_BSA_CS;
-    bi->rc = 1;
-    {
-      struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_fixed (
-          "r_pub_0",
-          &bi->details.cs_values.r_pub[0],
-          sizeof (struct GNUNET_CRYPTO_CsRPublic)),
-        GNUNET_JSON_spec_fixed (
-          "r_pub_1",
-          &bi->details.cs_values.r_pub[1],
-          sizeof (struct GNUNET_CRYPTO_CsRPublic)),
-        GNUNET_JSON_spec_end ()
-      };
-
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (root,
-                             ispec,
-                             &emsg,
-                             &eline))
-      {
-        GNUNET_break_op (0);
-        GNUNET_free (bi);
-        return GNUNET_SYSERR;
-      }
-      ewv->blinding_inputs = bi;
-      return GNUNET_OK;
-    }
-  }
-  GNUNET_break_op (0);
-  return GNUNET_SYSERR;
-}
-
-
-/**
- * Cleanup data left from parsing withdraw values
- *
- * @param cls closure, NULL
- * @param[out] spec where to free the data
- */
-static void
-clean_exchange_withdraw_values (
-  void *cls,
-  struct GNUNET_JSON_Specification *spec)
-{
-  struct TALER_ExchangeWithdrawValues *ewv = spec->ptr;
-
-  (void) cls;
-  TALER_denom_ewv_free (ewv);
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_exchange_withdraw_values (
-  const char *field,
-  struct TALER_ExchangeWithdrawValues *ewv)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_exchange_withdraw_values,
-    .cleaner = &clean_exchange_withdraw_values,
-    .field = field,
-    .ptr = ewv
-  };
-
-  ewv->blinding_inputs = NULL;
-  return ret;
-}
-
-
 /**
  * Closure for #parse_i18n_string.
  */
@@ -1500,56 +594,6 @@ TALER_JSON_spec_web_url (const char *field,
 }
 
 
-/**
- * Parse given JSON object to payto:// URI.
- *
- * @param cls closure, NULL
- * @param root the json object representing data
- * @param[out] spec where to write the data
- * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
- */
-static enum GNUNET_GenericReturnValue
-parse_payto_uri (void *cls,
-                 json_t *root,
-                 struct GNUNET_JSON_Specification *spec)
-{
-  const char *str;
-  char *err;
-
-  (void) cls;
-  str = json_string_value (root);
-  if (NULL == str)
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  err = TALER_payto_validate (str);
-  if (NULL != err)
-  {
-    GNUNET_break_op (0);
-    GNUNET_free (err);
-    return GNUNET_SYSERR;
-  }
-  *(const char **) spec->ptr = str;
-  return GNUNET_OK;
-}
-
-
-struct GNUNET_JSON_Specification
-TALER_JSON_spec_payto_uri (const char *field,
-                           const char **payto_uri)
-{
-  struct GNUNET_JSON_Specification ret = {
-    .parser = &parse_payto_uri,
-    .field = field,
-    .ptr = payto_uri
-  };
-
-  *payto_uri = NULL;
-  return ret;
-}
-
-
 /**
  * Parse given JSON object with protocol version.
  *

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