gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: fix refreshes_reveal FTBFS


From: gnunet
Subject: [taler-exchange] branch master updated: fix refreshes_reveal FTBFS
Date: Mon, 07 Feb 2022 13:41:57 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new b84fb618 fix refreshes_reveal FTBFS
b84fb618 is described below

commit b84fb618c3c0f7492f609949f5202c75882d7b68
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Feb 7 13:41:55 2022 +0100

    fix refreshes_reveal FTBFS
---
 .../taler-exchange-httpd_refreshes_reveal.c        | 29 ++++++++++++--------
 src/include/taler_crypto_lib.h                     | 21 +++++++++-----
 src/util/crypto.c                                  |  5 ++--
 src/util/denom.c                                   | 32 ++++++++++++++++++++++
 4 files changed, 66 insertions(+), 21 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c 
b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index 63a61159..f9330ebe 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -200,10 +200,7 @@ check_commitment (struct RevealContext *rctx,
                                                  &coin_priv,
                                                  &c_hash,
                                                  &pd));
-          rcd->coin_ev =
-            pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg;
-          rcd->coin_ev_size =
-            pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg_size;
+          rcd->blinded_planchet = pd.blinded_planchet;
         }
       }
     }
@@ -225,7 +222,7 @@ check_commitment (struct RevealContext *rctx,
       {
         struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
 
-        GNUNET_free (rcd->coin_ev);
+        TALER_blinded_planchet_free (&rcd->blinded_planchet);
       }
       GNUNET_free (rce->new_coins);
     }
@@ -493,9 +490,18 @@ resolve_refreshes_reveal_denominations (struct 
MHD_Connection *connection,
     const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
     struct TALER_RefreshCoinData *rcd = &rcds[i];
 
-    rcd->coin_ev = rrc->coin_ev;
-    rcd->coin_ev_size = rrc->coin_ev_size;
+    rcd->blinded_planchet = rrc->blinded_planchet;
     rcd->dk = &dks[i]->denom_pub;
+    if (rcd->blinded_planchet.cipher != rcd->dk->cipher)
+    {
+      GNUNET_break_op (0);
+      ret = TALER_MHD_REPLY_JSON_PACK (
+        connection,
+        MHD_HTTP_BAD_REQUEST,
+        TALER_JSON_pack_ec (
+          TALER_EC_EXCHANGE_GENERIC_CIPHER_MISMATCH));
+      goto cleanup;
+    }
   }
   rctx->dks = dks;
   rctx->rcds = rcds;
@@ -513,11 +519,13 @@ resolve_refreshes_reveal_denominations (struct 
MHD_Connection *connection,
   {
     enum TALER_ErrorCode ec = TALER_EC_NONE;
     struct TEH_SignDetails sign_details;
+    const struct TALER_BlindedRsaPlanchet *rp;
 
     // FIXME: implement cipher handling
+    rp = &rcds[i].blinded_planchet.details.rsa_blinded_planchet;
     sign_details.cipher = TALER_DENOMINATION_RSA;
-    sign_details.details.rsa_message.msg = rcds[i].coin_ev;
-    sign_details.details.rsa_message.msg_size = rcds[i].coin_ev_size;
+    sign_details.details.rsa_message.msg = rp->blinded_msg;
+    sign_details.details.rsa_message.msg_size = rp->blinded_msg_size;
     rrcs[i].coin_sig
       = TEH_keys_denomination_sign (
           &rrcs[i].h_denom_pub,
@@ -542,8 +550,7 @@ resolve_refreshes_reveal_denominations (struct 
MHD_Connection *connection,
     {
       struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
 
-      rrc->coin_ev = rcds[i].coin_ev;
-      rrc->coin_ev_size = rcds[i].coin_ev_size;
+      rrc->blinded_planchet = rcds[i].blinded_planchet;
     }
     qs = TEH_plugin->insert_refresh_reveal (TEH_plugin->cls,
                                             melt_serial_id,
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 189d4b06..dbf390ea 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1589,6 +1589,18 @@ TALER_planchet_to_coin (
   struct TALER_FreshCoin *coin);
 
 
+/**
+ * Add the hash of the @a bp (in some canonicalized form)
+ * to the @a hash_context.
+ *
+ * @param bp blinded planchet to hash
+ * @param[in,out] hash_context hash context to use
+ */
+void
+TALER_blinded_planchet_hash (const struct TALER_BlindedPlanchet *bp,
+                             struct GNUNET_HashContext *hash_context);
+
+
 /**
  * Given the coin and the transfer private keys, compute the
  * transfer secret.  (Technically, we only need one of the two
@@ -1649,14 +1661,9 @@ struct TALER_RefreshCoinData
   const struct TALER_DenominationPublicKey *dk;
 
   /**
-   * The envelope with the blinded coin.
+   * The blinded planchet (details depend on cipher).
    */
-  void *coin_ev;
-
-  /**
-   * Number of bytes in @a coin_ev
-   */
-  size_t coin_ev_size;
+  struct TALER_BlindedPlanchet blinded_planchet;
 
 };
 
diff --git a/src/util/crypto.c b/src/util/crypto.c
index c239f797..8e48b48d 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -519,9 +519,8 @@ TALER_refresh_get_commitment (struct 
TALER_RefreshCommitmentP *rc,
     {
       const struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
 
-      GNUNET_CRYPTO_hash_context_read (hash_context,
-                                       rcd->coin_ev,
-                                       rcd->coin_ev_size);
+      TALER_blinded_planchet_hash (&rcd->blinded_planchet,
+                                   hash_context);
     }
   }
 
diff --git a/src/util/denom.c b/src/util/denom.c
index caaa4f4e..0c1f9922 100644
--- a/src/util/denom.c
+++ b/src/util/denom.c
@@ -691,4 +691,36 @@ TALER_blinded_denom_sig_cmp (
 }
 
 
+void
+TALER_blinded_planchet_hash (const struct TALER_BlindedPlanchet *bp,
+                             struct GNUNET_HashContext *hash_context)
+{
+  uint32_t cipher = htonl (bp->cipher);
+
+  GNUNET_CRYPTO_hash_context_read (hash_context,
+                                   &cipher,
+                                   sizeof (cipher));
+  switch (bp->cipher)
+  {
+  case TALER_DENOMINATION_INVALID:
+    break;
+  case TALER_DENOMINATION_RSA:
+    GNUNET_CRYPTO_hash_context_read (
+      hash_context,
+      bp->details.rsa_blinded_planchet.blinded_msg,
+      bp->details.rsa_blinded_planchet.blinded_msg_size);
+    break;
+  case TALER_DENOMINATION_CS:
+    GNUNET_CRYPTO_hash_context_read (
+      hash_context,
+      &bp->details.cs_blinded_planchet,
+      sizeof (bp->details.cs_blinded_planchet));
+    break;
+  default:
+    GNUNET_assert (0);
+    break;
+  }
+}
+
+
 /* end of denom.c */

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