diff options
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd_purses_create.c | 47 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_purses_deposit.c | 46 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 7 |
3 files changed, 73 insertions, 27 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_create.c b/src/exchange/taler-exchange-httpd_purses_create.c index 2c803234..b016aeee 100644 --- a/src/exchange/taler-exchange-httpd_purses_create.c +++ b/src/exchange/taler-exchange-httpd_purses_create.c @@ -335,6 +335,8 @@ create_transaction (void *cls, struct TALER_Amount amount; struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendSignatureP coin_sig; + struct TALER_DenominationHashP h_denom_pub; + struct TALER_AgeCommitmentHash phac; char *partner_url = NULL; TEH_plugin->rollback (TEH_plugin->cls); @@ -342,6 +344,8 @@ create_transaction (void *cls, pcc->purse_pub, &coin->cpi.coin_pub, &amount, + &h_denom_pub, + &phac, &coin_sig, &partner_url); if (qs < 0) @@ -366,6 +370,10 @@ create_transaction (void *cls, &coin_pub), GNUNET_JSON_pack_data_auto ("coin_sig", &coin_sig), + GNUNET_JSON_pack_data_auto ("h_denom_pub", + &h_denom_pub), + GNUNET_JSON_pack_data_auto ("h_age_restrictions", + &phac), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("partner_url", partner_url)), @@ -493,22 +501,33 @@ parse_coin (struct MHD_Connection *connection, return res; } - if (GNUNET_OK != - TALER_wallet_purse_deposit_verify (TEH_base_url, - pcc->purse_pub, - &coin->amount, - &coin->cpi.coin_pub, - &coin->coin_sig)) { - TALER_LOG_WARNING ( - "Invalid coin signature on /purses/$PID/create request\n"); - GNUNET_JSON_parse_free (spec); - return (MHD_YES == - TALER_MHD_reply_with_error (connection, - MHD_HTTP_FORBIDDEN, - TALER_EC_EXCHANGE_PURSE_CREATE_COIN_SIGNATURE_INVALID, - TEH_base_url)) + struct TALER_AgeCommitmentHash h_age; + + if (no_age_commitment) + memset (&h_age, 0, sizeof (h_age)); + else + TALER_age_commitment_hash (&age_commitment, + &h_age); + if (GNUNET_OK != + TALER_wallet_purse_deposit_verify (TEH_base_url, + pcc->purse_pub, + &coin->amount, + &coin->cpi.denom_pub_hash, + &h_age, + &coin->cpi.coin_pub, + &coin->coin_sig)) + { + TALER_LOG_WARNING ( + "Invalid coin signature on /purses/$PID/create request\n"); + GNUNET_JSON_parse_free (spec); + return (MHD_YES == + TALER_MHD_reply_with_error (connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_EXCHANGE_PURSE_CREATE_COIN_SIGNATURE_INVALID, + TEH_base_url)) ? GNUNET_NO : GNUNET_SYSERR; + } } /* check denomination exists and is valid */ { diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c b/src/exchange/taler-exchange-httpd_purses_deposit.c index af7200f1..4158b293 100644 --- a/src/exchange/taler-exchange-httpd_purses_deposit.c +++ b/src/exchange/taler-exchange-httpd_purses_deposit.c @@ -239,6 +239,8 @@ deposit_transaction (void *cls, struct TALER_Amount amount; struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendSignatureP coin_sig; + struct TALER_DenominationHashP h_denom_pub; + struct TALER_AgeCommitmentHash phac; char *partner_url = NULL; TEH_plugin->rollback (TEH_plugin->cls); @@ -246,6 +248,8 @@ deposit_transaction (void *cls, pcc->purse_pub, &coin->cpi.coin_pub, &amount, + &h_denom_pub, + &phac, &coin_sig, &partner_url); if (qs < 0) @@ -268,6 +272,10 @@ deposit_transaction (void *cls, TALER_EC_EXCHANGE_PURSE_DEPOSIT_CONFLICTING_META_DATA), GNUNET_JSON_pack_data_auto ("coin_pub", &coin_pub), + GNUNET_JSON_pack_data_auto ("h_denom_pub", + &h_denom_pub), + GNUNET_JSON_pack_data_auto ("h_age_commitment", + &phac), GNUNET_JSON_pack_data_auto ("coin_sig", &coin_sig), GNUNET_JSON_pack_allow_null ( @@ -336,21 +344,33 @@ parse_coin (struct MHD_Connection *connection, if (GNUNET_OK != res) return res; } - if (GNUNET_OK != - TALER_wallet_purse_deposit_verify (TEH_base_url, - pcc->purse_pub, - &coin->amount, - &coin->cpi.coin_pub, - &coin->coin_sig)) { - TALER_LOG_WARNING ("Invalid signature on /purses/$PID/deposit request\n"); - GNUNET_JSON_parse_free (spec); - return (MHD_YES == - TALER_MHD_reply_with_error (connection, - MHD_HTTP_FORBIDDEN, - TALER_EC_EXCHANGE_PURSE_DEPOSIT_COIN_SIGNATURE_INVALID, - TEH_base_url)) + struct TALER_AgeCommitmentHash h_age; + + if (no_age_commitment) + memset (&h_age, 0, sizeof (h_age)); + else + TALER_age_commitment_hash (&age_commitment, + &h_age); + + if (GNUNET_OK != + TALER_wallet_purse_deposit_verify (TEH_base_url, + pcc->purse_pub, + &coin->amount, + &coin->cpi.denom_pub_hash, + &h_age, + &coin->cpi.coin_pub, + &coin->coin_sig)) + { + TALER_LOG_WARNING ("Invalid signature on /purses/$PID/deposit request\n"); + GNUNET_JSON_parse_free (spec); + return (MHD_YES == + TALER_MHD_reply_with_error (connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_EXCHANGE_PURSE_DEPOSIT_COIN_SIGNATURE_INVALID, + TEH_base_url)) ? GNUNET_NO : GNUNET_SYSERR; + } } /* check denomination exists and is valid */ { diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 429647e1..92c585b4 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -391,6 +391,10 @@ TEH_RESPONSE_compile_transaction_history ( { struct TALER_EXCHANGEDB_PurseDepositListEntry *pd = pos->details.purse_deposit; + const struct TALER_AgeCommitmentHash *phac = NULL; + + if (! pd->no_age_commitment) + phac = &pd->h_age_commitment; if (0 != json_array_append_new ( @@ -404,6 +408,9 @@ TEH_RESPONSE_compile_transaction_history ( NULL == pd->exchange_base_url ? TEH_base_url : pd->exchange_base_url), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_data_auto ("h_age_commitment", + phac)), GNUNET_JSON_pack_data_auto ("purse_pub", &pd->purse_pub), GNUNET_JSON_pack_bool ("refunded", |