[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 10/37: remove varargs in cs crypto implementation
From: |
gnunet |
Subject: |
[taler-exchange] 10/37: remove varargs in cs crypto implementation |
Date: |
Fri, 04 Feb 2022 16:53:40 +0100 |
This is an automated email from the git hooks/post-receive script.
gian-demarmels pushed a commit to branch master
in repository exchange.
commit cf4fd36cc481d3af369a059df213ef00212046d5
Author: Lucien Heuzeveldt <lucienclaude.heuzeveldt@students.bfh.ch>
AuthorDate: Fri Dec 31 15:24:41 2021 +0100
remove varargs in cs crypto implementation
---
src/include/taler_crypto_lib.h | 64 ++++++++++++++++++++++++------------------
src/util/crypto.c | 42 ++++++++-------------------
src/util/denom.c | 19 +++++--------
src/util/test_crypto.c | 27 ++++++++----------
4 files changed, 68 insertions(+), 84 deletions(-)
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 850d259a..bf82b8f0 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -752,6 +752,18 @@ struct TALER_BlindedRsaPlanchet
};
+/**
+ * Withdraw nonce for CS denominations
+ */
+struct TALER_WithdrawNonce
+{
+ /**
+ * 32 bit nonce to include in withdrawals
+ */
+ struct GNUNET_CRYPTO_CsNonce nonce;
+};
+
+
/**
* @brief CS Parameters to create blinded signature
*
@@ -762,6 +774,11 @@ struct TALER_BlindedCsPlanchet
* The Clause Schnorr c_0 and c_1 containing the blinded message
*/
struct GNUNET_CRYPTO_CsC c[2];
+
+ /**
+ * Public Nonce
+ */
+ struct TALER_WithdrawNonce nonce;
};
/**
@@ -793,17 +810,6 @@ struct TALER_BlindedPlanchet
} details;
};
-/**
- * Withdraw nonce for CS denominations
- */
-struct TALER_WithdrawNonce
-{
- /**
- * 32 bit nonce to include in withdrawals
- */
- struct GNUNET_CRYPTO_CsNonce nonce;
-};
-
/**
* Withdraw nonce for CS denominations
*/
@@ -1016,8 +1022,7 @@ TALER_denom_blind (const struct
TALER_DenominationPublicKey *dk,
enum GNUNET_GenericReturnValue
TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
const struct TALER_DenominationPrivateKey
*denom_priv,
- const struct TALER_BlindedPlanchet *blinded_planchet,
- ...);
+ const struct TALER_BlindedPlanchet
*blinded_planchet);
/**
@@ -1235,6 +1240,17 @@ struct TALER_PlanchetSecretsP
*/
union TALER_DenominationBlindingKeyP blinding_key;
+ // only used in case of CS:
+
+ /**
+ * (non-blinded) r_pub
+ */
+ struct TALER_DenominationCsPublicR cs_r_pub;
+
+ /**
+ * blinded r_pub
+ */
+ struct TALER_DenominationCsPublicR cs_r_pub_blinded;
};
@@ -1406,16 +1422,13 @@ TALER_planchet_setup_random (struct
TALER_PlanchetSecretsP *ps,
* @param[out] c_hash set to the hash of the public key of the coin (needed
later)
* @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup()
and
* other withdraw operations
- * @param ... if CS algorithm, r_pub (TALER_DenominationCsPublicR) is needed
to blind and
- * r_pub_blind (TALER_DenominationCsPublicR) is an additional out parameter.
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
- const struct TALER_PlanchetSecretsP *ps,
+ struct TALER_PlanchetSecretsP *ps,
struct TALER_CoinPubHash *c_hash,
- struct TALER_PlanchetDetail *pd,
- ...);
+ struct TALER_PlanchetDetail *pd);
/**
@@ -1427,18 +1440,15 @@ TALER_planchet_prepare (const struct
TALER_DenominationPublicKey *dk,
* @param ps secrets from #TALER_planchet_prepare()
* @param c_hash hash of the coin's public key for verification of the
signature
* @param[out] coin set to the details of the fresh coin
- * @param ... If CS algorithm, r_pub_blind (TALER_DenominationCsPublicR) is an
additional param
-
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
-TALER_planchet_to_coin (
- const struct TALER_DenominationPublicKey *dk,
- const struct TALER_BlindedDenominationSignature *blind_sig,
- const struct TALER_PlanchetSecretsP *ps,
- const struct TALER_CoinPubHash *c_hash,
- struct TALER_FreshCoin *coin,
- ...);
+TALER_planchet_to_coin (const struct TALER_DenominationPublicKey *dk,
+ const struct
+ TALER_BlindedDenominationSignature *blind_sig,
+ const struct TALER_PlanchetSecretsP *ps,
+ const struct TALER_CoinPubHash *c_hash,
+ struct TALER_FreshCoin *coin);
/* ****************** Refresh crypto primitives ************* */
diff --git a/src/util/crypto.c b/src/util/crypto.c
index 1e5033a0..2d3099a4 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -262,6 +262,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP
*ps,
GNUNET_break (0);
return;
case TALER_DENOMINATION_RSA:
+ // TODO: replace with call to TALER_blinding_secret_create
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
&ps->blinding_key.rsa_bks,
sizeof (struct
@@ -278,10 +279,9 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP
*ps,
enum GNUNET_GenericReturnValue
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
- const struct TALER_PlanchetSecretsP *ps,
+ struct TALER_PlanchetSecretsP *ps,
struct TALER_CoinPubHash *c_hash,
- struct TALER_PlanchetDetail *pd,
- ...)
+ struct TALER_PlanchetDetail *pd)
{
struct TALER_CoinSpendPublicKeyP coin_pub;
@@ -305,14 +305,6 @@ TALER_planchet_prepare (const struct
TALER_DenominationPublicKey *dk,
break;
case TALER_DENOMINATION_CS:
{
- va_list ap;
- va_start (ap, pd);
- struct TALER_DenominationCsPublicR *r_pub;
- struct TALER_DenominationCsPublicR *blinded_r_pub;
-
- r_pub = va_arg (ap, struct TALER_DenominationCsPublicR *);
- blinded_r_pub = va_arg (ap, struct TALER_DenominationCsPublicR *);
-
if (GNUNET_OK !=
TALER_denom_blind (dk,
&ps->blinding_key,
@@ -320,14 +312,12 @@ TALER_planchet_prepare (const struct
TALER_DenominationPublicKey *dk,
&coin_pub,
c_hash,
&pd->blinded_planchet,
- r_pub,
- blinded_r_pub))
+ &ps->cs_r_pub,
+ &ps->cs_r_pub_blinded))
{
- va_end (ap);
GNUNET_break (0);
return GNUNET_SYSERR;
}
- va_end (ap);
break;
}
default:
@@ -342,13 +332,12 @@ TALER_planchet_prepare (const struct
TALER_DenominationPublicKey *dk,
enum GNUNET_GenericReturnValue
-TALER_planchet_to_coin (
- const struct TALER_DenominationPublicKey *dk,
- const struct TALER_BlindedDenominationSignature *blind_sig,
- const struct TALER_PlanchetSecretsP *ps,
- const struct TALER_CoinPubHash *c_hash,
- struct TALER_FreshCoin *coin,
- ...)
+TALER_planchet_to_coin (const struct TALER_DenominationPublicKey *dk,
+ const struct
+ TALER_BlindedDenominationSignature *blind_sig,
+ const struct TALER_PlanchetSecretsP *ps,
+ const struct TALER_CoinPubHash *c_hash,
+ struct TALER_FreshCoin *coin)
{
struct TALER_DenominationSignature sig;
@@ -367,23 +356,16 @@ TALER_planchet_to_coin (
break;
case TALER_DENOMINATION_CS:
{
- va_list ap;
- va_start (ap, coin);
-
- struct TALER_DenominationCsPublicR *r_pub_blind;
- r_pub_blind = va_arg (ap, struct TALER_DenominationCsPublicR *);
if (GNUNET_OK !=
TALER_denom_sig_unblind (&sig,
blind_sig,
&ps->blinding_key,
dk,
- r_pub_blind))
+ &ps->cs_r_pub_blinded))
{
GNUNET_break_op (0);
- va_end (ap);
return GNUNET_SYSERR;
}
- va_end (ap);
}
break;
default:
diff --git a/src/util/denom.c b/src/util/denom.c
index 4b62f4cc..9d8acfca 100644
--- a/src/util/denom.c
+++ b/src/util/denom.c
@@ -107,8 +107,7 @@ TALER_denom_cs_derive_r_public (const struct
TALER_WithdrawNonce *nonce,
enum GNUNET_GenericReturnValue
TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
const struct TALER_DenominationPrivateKey
*denom_priv,
- const struct TALER_BlindedPlanchet *blinded_planchet,
- ...)
+ const struct TALER_BlindedPlanchet *blinded_planchet)
{
memset (denom_sig,
0,
@@ -133,27 +132,23 @@ TALER_denom_sign_blinded (struct
TALER_BlindedDenominationSignature *denom_sig,
return GNUNET_OK;
case TALER_DENOMINATION_CS:
{
- va_list ap;
- va_start (ap, blinded_planchet);
- struct TALER_WithdrawNonce *nonce;
- nonce = va_arg (ap, struct TALER_WithdrawNonce *);
-
struct GNUNET_CRYPTO_CsRSecret r[2];
- GNUNET_CRYPTO_cs_r_derive (&nonce->nonce,
- &denom_priv->details.cs_private_key,
- r);
+ GNUNET_CRYPTO_cs_r_derive (
+ &blinded_planchet->details.cs_blinded_planchet.nonce.nonce,
+ &denom_priv->details.cs_private_key,
+ r);
denom_sig->details.blinded_cs_answer.b =
GNUNET_CRYPTO_cs_sign_derive (&denom_priv->details.cs_private_key,
r,
blinded_planchet->details.
cs_blinded_planchet.c,
- &nonce->nonce,
+ &blinded_planchet->details.
+ cs_blinded_planchet.nonce.nonce,
&denom_sig->details.blinded_cs_answer.
s_scalar);
denom_sig->cipher = TALER_DENOMINATION_CS;
- va_end (ap);
}
return GNUNET_OK;
default:
diff --git a/src/util/test_crypto.c b/src/util/test_crypto.c
index 760ec0fa..513fbbad 100644
--- a/src/util/test_crypto.c
+++ b/src/util/test_crypto.c
@@ -146,9 +146,6 @@ test_planchets_cs (void)
struct TALER_DenominationPublicKey dk_pub;
struct TALER_PlanchetDetail pd;
struct TALER_CoinPubHash c_hash;
- struct TALER_WithdrawNonce nonce;
- struct TALER_DenominationCsPublicR r_pub;
- struct TALER_DenominationCsPublicR r_pub_blind;
struct TALER_BlindedDenominationSignature blind_sig;
struct TALER_FreshCoin coin;
@@ -158,37 +155,37 @@ test_planchets_cs (void)
TALER_DENOMINATION_CS));
TALER_planchet_setup_random (&ps, TALER_DENOMINATION_CS);
- TALER_cs_withdraw_nonce_derive (&ps.coin_priv, &nonce);
+ TALER_cs_withdraw_nonce_derive (&ps.coin_priv,
+ &pd.blinded_planchet.details.
+ cs_blinded_planchet.nonce);
GNUNET_assert (GNUNET_OK ==
- TALER_denom_cs_derive_r_public (&nonce,
- &dk_priv,
- &r_pub));
+ TALER_denom_cs_derive_r_public (
+ &pd.blinded_planchet.details.cs_blinded_planchet.nonce,
+ &dk_priv,
+ &ps.cs_r_pub));
+ // TODO: eliminate r_pubs parameter
TALER_blinding_secret_create (&ps.blinding_key,
TALER_DENOMINATION_CS,
&ps.coin_priv,
- &r_pub);
+ &ps.cs_r_pub);
GNUNET_assert (GNUNET_OK ==
TALER_planchet_prepare (&dk_pub,
&ps,
&c_hash,
- &pd,
- &r_pub,
- &r_pub_blind));
+ &pd));
GNUNET_assert (GNUNET_OK ==
TALER_denom_sign_blinded (&blind_sig,
&dk_priv,
- &pd.blinded_planchet,
- &nonce));
+ &pd.blinded_planchet));
GNUNET_assert (GNUNET_OK ==
TALER_planchet_to_coin (&dk_pub,
&blind_sig,
&ps,
&c_hash,
- &coin,
- &r_pub_blind));
+ &coin));
TALER_blinded_denom_sig_free (&blind_sig);
TALER_denom_sig_free (&coin.sig);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] 16/37: revocation, (continued)
- [taler-exchange] 16/37: revocation, gnunet, 2022/02/04
- [taler-exchange] 17/37: implement secmod cs derive R, gnunet, 2022/02/04
- [taler-exchange] 08/37: fixed CS signatures and cleanup/refactoring, gnunet, 2022/02/04
- [taler-exchange] 14/37: initial cs_secmod implementation, gnunet, 2022/02/04
- [taler-exchange] 15/37: setup_key for cs secmod helper, gnunet, 2022/02/04
- [taler-exchange] 34/37: include denom_pub into coin_ev_hash, gnunet, 2022/02/04
- [taler-exchange] 36/37: denomination CIPHER field per denom, gnunet, 2022/02/04
- [taler-exchange] 21/37: secmod CS sign implementation, gnunet, 2022/02/04
- [taler-exchange] 22/37: cleanup, gnunet, 2022/02/04
- [taler-exchange] 23/37: implement withdraw (nonce reuse check missing), gnunet, 2022/02/04
- [taler-exchange] 10/37: remove varargs in cs crypto implementation,
gnunet <=
- [taler-exchange] 31/37: introduce new type for security module pubkeys, gnunet, 2022/02/04
- [taler-exchange] 25/37: implement spend, gnunet, 2022/02/04
- [taler-exchange] 27/37: change TEH_keys_denomination_sign message parameter, gnunet, 2022/02/04
- [taler-exchange] 35/37: refactor TALER_coin_ev_hash, gnunet, 2022/02/04
- [taler-exchange] 28/37: -scope needed, gnunet, 2022/02/04
- [taler-exchange] 33/37: fixed nonce check, renamed WithdrawNonce, gnunet, 2022/02/04
- [taler-exchange] 26/37: refactoring, gnunet, 2022/02/04
- [taler-exchange] 19/37: set planchet detail cipher, add cipher checks, gnunet, 2022/02/04
- [taler-exchange] 30/37: -make picky gcc happy, gnunet, 2022/02/04
- [taler-exchange] 37/37: resolves merge conflicts, gnunet, 2022/02/04