remove varargs in cs crypto implementation
This commit is contained in:
parent
4bcbd704df
commit
cf4fd36cc4
@ -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
|
* @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
|
* The Clause Schnorr c_0 and c_1 containing the blinded message
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_CsC c[2];
|
struct GNUNET_CRYPTO_CsC c[2];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public Nonce
|
||||||
|
*/
|
||||||
|
struct TALER_WithdrawNonce nonce;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -793,17 +810,6 @@ struct TALER_BlindedPlanchet
|
|||||||
} details;
|
} 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
|
* Withdraw nonce for CS denominations
|
||||||
*/
|
*/
|
||||||
@ -1016,8 +1022,7 @@ TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
|
|||||||
enum GNUNET_GenericReturnValue
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
|
TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
|
||||||
const struct TALER_DenominationPrivateKey *denom_priv,
|
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;
|
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] 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
|
* @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup() and
|
||||||
* other withdraw operations
|
* 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
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
enum GNUNET_GenericReturnValue
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
||||||
const struct TALER_PlanchetSecretsP *ps,
|
struct TALER_PlanchetSecretsP *ps,
|
||||||
struct TALER_CoinPubHash *c_hash,
|
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 ps secrets from #TALER_planchet_prepare()
|
||||||
* @param c_hash hash of the coin's public key for verification of the signature
|
* @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[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
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
enum GNUNET_GenericReturnValue
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_planchet_to_coin (
|
TALER_planchet_to_coin (const struct TALER_DenominationPublicKey *dk,
|
||||||
const struct TALER_DenominationPublicKey *dk,
|
const struct
|
||||||
const struct TALER_BlindedDenominationSignature *blind_sig,
|
TALER_BlindedDenominationSignature *blind_sig,
|
||||||
const struct TALER_PlanchetSecretsP *ps,
|
const struct TALER_PlanchetSecretsP *ps,
|
||||||
const struct TALER_CoinPubHash *c_hash,
|
const struct TALER_CoinPubHash *c_hash,
|
||||||
struct TALER_FreshCoin *coin,
|
struct TALER_FreshCoin *coin);
|
||||||
...);
|
|
||||||
|
|
||||||
|
|
||||||
/* ****************** Refresh crypto primitives ************* */
|
/* ****************** Refresh crypto primitives ************* */
|
||||||
|
@ -262,6 +262,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return;
|
return;
|
||||||
case TALER_DENOMINATION_RSA:
|
case TALER_DENOMINATION_RSA:
|
||||||
|
// TODO: replace with call to TALER_blinding_secret_create
|
||||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
|
||||||
&ps->blinding_key.rsa_bks,
|
&ps->blinding_key.rsa_bks,
|
||||||
sizeof (struct
|
sizeof (struct
|
||||||
@ -278,10 +279,9 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps,
|
|||||||
|
|
||||||
enum GNUNET_GenericReturnValue
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
||||||
const struct TALER_PlanchetSecretsP *ps,
|
struct TALER_PlanchetSecretsP *ps,
|
||||||
struct TALER_CoinPubHash *c_hash,
|
struct TALER_CoinPubHash *c_hash,
|
||||||
struct TALER_PlanchetDetail *pd,
|
struct TALER_PlanchetDetail *pd)
|
||||||
...)
|
|
||||||
{
|
{
|
||||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
|
|
||||||
@ -305,14 +305,6 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
|||||||
break;
|
break;
|
||||||
case TALER_DENOMINATION_CS:
|
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 !=
|
if (GNUNET_OK !=
|
||||||
TALER_denom_blind (dk,
|
TALER_denom_blind (dk,
|
||||||
&ps->blinding_key,
|
&ps->blinding_key,
|
||||||
@ -320,14 +312,12 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
|||||||
&coin_pub,
|
&coin_pub,
|
||||||
c_hash,
|
c_hash,
|
||||||
&pd->blinded_planchet,
|
&pd->blinded_planchet,
|
||||||
r_pub,
|
&ps->cs_r_pub,
|
||||||
blinded_r_pub))
|
&ps->cs_r_pub_blinded))
|
||||||
{
|
{
|
||||||
va_end (ap);
|
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
va_end (ap);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -342,13 +332,12 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
|||||||
|
|
||||||
|
|
||||||
enum GNUNET_GenericReturnValue
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_planchet_to_coin (
|
TALER_planchet_to_coin (const struct TALER_DenominationPublicKey *dk,
|
||||||
const struct TALER_DenominationPublicKey *dk,
|
const struct
|
||||||
const struct TALER_BlindedDenominationSignature *blind_sig,
|
TALER_BlindedDenominationSignature *blind_sig,
|
||||||
const struct TALER_PlanchetSecretsP *ps,
|
const struct TALER_PlanchetSecretsP *ps,
|
||||||
const struct TALER_CoinPubHash *c_hash,
|
const struct TALER_CoinPubHash *c_hash,
|
||||||
struct TALER_FreshCoin *coin,
|
struct TALER_FreshCoin *coin)
|
||||||
...)
|
|
||||||
{
|
{
|
||||||
struct TALER_DenominationSignature sig;
|
struct TALER_DenominationSignature sig;
|
||||||
|
|
||||||
@ -367,23 +356,16 @@ TALER_planchet_to_coin (
|
|||||||
break;
|
break;
|
||||||
case TALER_DENOMINATION_CS:
|
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 !=
|
if (GNUNET_OK !=
|
||||||
TALER_denom_sig_unblind (&sig,
|
TALER_denom_sig_unblind (&sig,
|
||||||
blind_sig,
|
blind_sig,
|
||||||
&ps->blinding_key,
|
&ps->blinding_key,
|
||||||
dk,
|
dk,
|
||||||
r_pub_blind))
|
&ps->cs_r_pub_blinded))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
va_end (ap);
|
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
va_end (ap);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -107,8 +107,7 @@ TALER_denom_cs_derive_r_public (const struct TALER_WithdrawNonce *nonce,
|
|||||||
enum GNUNET_GenericReturnValue
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
|
TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
|
||||||
const struct TALER_DenominationPrivateKey *denom_priv,
|
const struct TALER_DenominationPrivateKey *denom_priv,
|
||||||
const struct TALER_BlindedPlanchet *blinded_planchet,
|
const struct TALER_BlindedPlanchet *blinded_planchet)
|
||||||
...)
|
|
||||||
{
|
{
|
||||||
memset (denom_sig,
|
memset (denom_sig,
|
||||||
0,
|
0,
|
||||||
@ -133,27 +132,23 @@ TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
|
|||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
case TALER_DENOMINATION_CS:
|
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];
|
struct GNUNET_CRYPTO_CsRSecret r[2];
|
||||||
GNUNET_CRYPTO_cs_r_derive (&nonce->nonce,
|
GNUNET_CRYPTO_cs_r_derive (
|
||||||
&denom_priv->details.cs_private_key,
|
&blinded_planchet->details.cs_blinded_planchet.nonce.nonce,
|
||||||
r);
|
&denom_priv->details.cs_private_key,
|
||||||
|
r);
|
||||||
|
|
||||||
denom_sig->details.blinded_cs_answer.b =
|
denom_sig->details.blinded_cs_answer.b =
|
||||||
GNUNET_CRYPTO_cs_sign_derive (&denom_priv->details.cs_private_key,
|
GNUNET_CRYPTO_cs_sign_derive (&denom_priv->details.cs_private_key,
|
||||||
r,
|
r,
|
||||||
blinded_planchet->details.
|
blinded_planchet->details.
|
||||||
cs_blinded_planchet.c,
|
cs_blinded_planchet.c,
|
||||||
&nonce->nonce,
|
&blinded_planchet->details.
|
||||||
|
cs_blinded_planchet.nonce.nonce,
|
||||||
&denom_sig->details.blinded_cs_answer.
|
&denom_sig->details.blinded_cs_answer.
|
||||||
s_scalar);
|
s_scalar);
|
||||||
|
|
||||||
denom_sig->cipher = TALER_DENOMINATION_CS;
|
denom_sig->cipher = TALER_DENOMINATION_CS;
|
||||||
va_end (ap);
|
|
||||||
}
|
}
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
default:
|
default:
|
||||||
|
@ -146,9 +146,6 @@ test_planchets_cs (void)
|
|||||||
struct TALER_DenominationPublicKey dk_pub;
|
struct TALER_DenominationPublicKey dk_pub;
|
||||||
struct TALER_PlanchetDetail pd;
|
struct TALER_PlanchetDetail pd;
|
||||||
struct TALER_CoinPubHash c_hash;
|
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_BlindedDenominationSignature blind_sig;
|
||||||
struct TALER_FreshCoin coin;
|
struct TALER_FreshCoin coin;
|
||||||
|
|
||||||
@ -158,37 +155,37 @@ test_planchets_cs (void)
|
|||||||
TALER_DENOMINATION_CS));
|
TALER_DENOMINATION_CS));
|
||||||
|
|
||||||
TALER_planchet_setup_random (&ps, 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 ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_denom_cs_derive_r_public (&nonce,
|
TALER_denom_cs_derive_r_public (
|
||||||
&dk_priv,
|
&pd.blinded_planchet.details.cs_blinded_planchet.nonce,
|
||||||
&r_pub));
|
&dk_priv,
|
||||||
|
&ps.cs_r_pub));
|
||||||
|
// TODO: eliminate r_pubs parameter
|
||||||
TALER_blinding_secret_create (&ps.blinding_key,
|
TALER_blinding_secret_create (&ps.blinding_key,
|
||||||
TALER_DENOMINATION_CS,
|
TALER_DENOMINATION_CS,
|
||||||
&ps.coin_priv,
|
&ps.coin_priv,
|
||||||
&r_pub);
|
&ps.cs_r_pub);
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_planchet_prepare (&dk_pub,
|
TALER_planchet_prepare (&dk_pub,
|
||||||
&ps,
|
&ps,
|
||||||
&c_hash,
|
&c_hash,
|
||||||
&pd,
|
&pd));
|
||||||
&r_pub,
|
|
||||||
&r_pub_blind));
|
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_denom_sign_blinded (&blind_sig,
|
TALER_denom_sign_blinded (&blind_sig,
|
||||||
&dk_priv,
|
&dk_priv,
|
||||||
&pd.blinded_planchet,
|
&pd.blinded_planchet));
|
||||||
&nonce));
|
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_planchet_to_coin (&dk_pub,
|
TALER_planchet_to_coin (&dk_pub,
|
||||||
&blind_sig,
|
&blind_sig,
|
||||||
&ps,
|
&ps,
|
||||||
&c_hash,
|
&c_hash,
|
||||||
&coin,
|
&coin));
|
||||||
&r_pub_blind));
|
|
||||||
|
|
||||||
TALER_blinded_denom_sig_free (&blind_sig);
|
TALER_blinded_denom_sig_free (&blind_sig);
|
||||||
TALER_denom_sig_free (&coin.sig);
|
TALER_denom_sig_free (&coin.sig);
|
||||||
|
Loading…
Reference in New Issue
Block a user