more crypto refactoring
This commit is contained in:
parent
eaf9d728f5
commit
c3e244322b
@ -352,8 +352,6 @@ verify_and_execute_recoup (
|
||||
struct RecoupContext pc;
|
||||
const struct TEH_DenominationKey *dk;
|
||||
struct TALER_CoinPubHash c_hash;
|
||||
void *coin_ev;
|
||||
size_t coin_ev_size;
|
||||
MHD_RESULT mret;
|
||||
|
||||
/* check denomination exists and is in recoup mode */
|
||||
@ -442,28 +440,30 @@ verify_and_execute_recoup (
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
TALER_coin_pub_hash (&coin->coin_pub,
|
||||
&c_hash);
|
||||
GNUNET_assert (dk->denom_pub.cipher ==
|
||||
TALER_DENOMINATION_RSA);
|
||||
// FIXME-RSA migration...
|
||||
if (GNUNET_YES !=
|
||||
TALER_rsa_blind (&c_hash,
|
||||
&coin_bks->rsa_bks,
|
||||
dk->denom_pub.details.rsa_public_key,
|
||||
&coin_ev,
|
||||
&coin_ev_size))
|
||||
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return TALER_MHD_reply_with_error (connection,
|
||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||
TALER_EC_EXCHANGE_RECOUP_BLINDING_FAILED,
|
||||
NULL);
|
||||
void *coin_ev;
|
||||
size_t coin_ev_size;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_denom_blind (&dk->denom_pub,
|
||||
coin_bks,
|
||||
&coin->coin_pub,
|
||||
&c_hash,
|
||||
&coin_ev,
|
||||
&coin_ev_size))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return TALER_MHD_reply_with_error (connection,
|
||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||
TALER_EC_EXCHANGE_RECOUP_BLINDING_FAILED,
|
||||
NULL);
|
||||
}
|
||||
TALER_coin_ev_hash (coin_ev,
|
||||
coin_ev_size,
|
||||
&pc.h_blind);
|
||||
GNUNET_free (coin_ev);
|
||||
}
|
||||
TALER_coin_ev_hash (coin_ev,
|
||||
coin_ev_size,
|
||||
&pc.h_blind);
|
||||
GNUNET_free (coin_ev);
|
||||
|
||||
/* Perform actual recoup transaction */
|
||||
pc.coin_sig = coin_sig;
|
||||
|
@ -724,6 +724,26 @@ void
|
||||
TALER_denom_sig_free (struct TALER_DenominationSignature *denom_sig);
|
||||
|
||||
|
||||
/**
|
||||
* Blind coin for blind signing with @a dk using blinding secret @a coin_bks.
|
||||
*
|
||||
* @param dk denomination public key to blind for
|
||||
* @param coin_bks blinding secret to use
|
||||
* @param coin_pub public key of the coin to blind
|
||||
* @param[out] c_hash resulting hashed coin
|
||||
* @param[out] coin_ev blinded coin to submit
|
||||
* @param[out] coin_ev_size number of bytes in @a coin_ev
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
enum GNUNET_GenericReturnValue
|
||||
TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
|
||||
const union TALER_DenominationBlindingKeyP *coin_bks,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
struct TALER_CoinPubHash *c_hash,
|
||||
void **coin_ev,
|
||||
size_t *coin_ev_size);
|
||||
|
||||
|
||||
/**
|
||||
* Create blinded signature.
|
||||
*
|
||||
|
@ -185,21 +185,13 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
||||
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&ps->coin_priv.eddsa_priv,
|
||||
&coin_pub.eddsa_pub);
|
||||
// FIXME-Oec: replace with function that
|
||||
// also hashes the age vector if we have
|
||||
// one!
|
||||
TALER_coin_pub_hash (&coin_pub,
|
||||
c_hash);
|
||||
// FIXME-Gian/Lucien: this will be the bigger
|
||||
// change, as you have the extra round trip
|
||||
// => to be discussed!
|
||||
GNUNET_assert (TALER_DENOMINATION_RSA == dk->cipher);
|
||||
if (GNUNET_YES !=
|
||||
TALER_rsa_blind (c_hash,
|
||||
&ps->blinding_key.rsa_bks,
|
||||
dk->details.rsa_public_key,
|
||||
&pd->coin_ev,
|
||||
&pd->coin_ev_size))
|
||||
if (GNUNET_OK !=
|
||||
TALER_denom_blind (dk,
|
||||
&ps->blinding_key,
|
||||
&coin_pub,
|
||||
c_hash,
|
||||
&pd->coin_ev,
|
||||
&pd->coin_ev_size))
|
||||
{
|
||||
GNUNET_break_op (0);
|
||||
return GNUNET_SYSERR;
|
||||
|
@ -216,6 +216,38 @@ TALER_denom_priv_to_pub (const struct TALER_DenominationPrivateKey *denom_priv,
|
||||
}
|
||||
|
||||
|
||||
enum GNUNET_GenericReturnValue
|
||||
TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
|
||||
const union TALER_DenominationBlindingKeyP *coin_bks,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
struct TALER_CoinPubHash *c_hash,
|
||||
void **coin_ev,
|
||||
size_t *coin_ev_size)
|
||||
{
|
||||
switch (dk->cipher)
|
||||
{
|
||||
case TALER_DENOMINATION_RSA:
|
||||
TALER_coin_pub_hash (coin_pub,
|
||||
c_hash);
|
||||
if (GNUNET_YES !=
|
||||
TALER_rsa_blind (c_hash,
|
||||
&coin_bks->rsa_bks,
|
||||
dk->details.rsa_public_key,
|
||||
coin_ev,
|
||||
coin_ev_size))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
return GNUNET_OK;
|
||||
// TODO: add case for Clause-Schnorr
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum GNUNET_GenericReturnValue
|
||||
TALER_denom_pub_verify (const struct TALER_DenominationPublicKey *denom_pub,
|
||||
const struct TALER_DenominationSignature *denom_sig,
|
||||
|
Loading…
Reference in New Issue
Block a user