diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-28 17:27:08 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-28 17:27:08 +0100 |
commit | bb15fdd21532cf24772e7f57a0b997002c288911 (patch) | |
tree | 0f043058da02ba619a0efa49d38a9d1707a46de5 /src/mint/taler-mint-httpd_refresh.c | |
parent | cf13997ffc638d8b99d23d22d84cc857cfe592cb (diff) | |
download | exchange-bb15fdd21532cf24772e7f57a0b997002c288911.tar.xz |
fix use of struct TALER_RefreshMeltCoinAffirmationPS
Diffstat (limited to 'src/mint/taler-mint-httpd_refresh.c')
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 8a2232e25..5673adb19 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -242,51 +242,53 @@ verify_coin_public_info (struct MHD_Connection *connection, struct TALER_MINTDB_DenominationKeyIssueInformation *dki; struct TALER_Amount fee_refresh; - body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); - body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); - body.session_hash = *session_hash; - TALER_amount_hton (&body.amount_with_fee, - &r_melt_detail->melt_amount_with_fee); - body.coin_pub = r_public_info->coin_pub; - if (GNUNET_OK != - GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, - &body.purpose, - &r_melt_detail->melt_sig.ecdsa_signature, - &r_public_info->coin_pub.ecdsa_pub)) - { - if (MHD_YES != - TMH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_UNAUTHORIZED, - "{s:s}", - "error", "signature invalid")) - return GNUNET_SYSERR; - return GNUNET_NO; - } key_state = TMH_KS_acquire (); dki = TMH_KS_denomination_key_lookup (key_state, - &r_public_info->denom_pub); + &r_public_info->denom_pub); if (NULL == dki) { TMH_KS_release (key_state); TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n"); return TMH_RESPONSE_reply_arg_invalid (connection, - "denom_pub"); + "denom_pub"); } /* FIXME: need to check if denomination key is still valid for issuing! (#3634) */ TALER_amount_ntoh (&fee_refresh, &dki->issue.fee_refresh); + body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); + body.session_hash = *session_hash; + TALER_amount_hton (&body.amount_with_fee, + &r_melt_detail->melt_amount_with_fee); + TALER_amount_hton (&body.melt_fee, + &fee_refresh); + body.coin_pub = r_public_info->coin_pub; if (TALER_amount_cmp (&fee_refresh, &r_melt_detail->melt_amount_with_fee) < 0) { TMH_KS_release (key_state); return (MHD_YES == TMH_RESPONSE_reply_external_error (connection, - "melt amount smaller than melting fee")) + "melt amount smaller than melting fee")) ? GNUNET_NO : GNUNET_SYSERR; } TMH_KS_release (key_state); + if (GNUNET_OK != + GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, + &body.purpose, + &r_melt_detail->melt_sig.ecdsa_signature, + &r_public_info->coin_pub.ecdsa_pub)) + { + if (MHD_YES != + TMH_RESPONSE_reply_json_pack (connection, + MHD_HTTP_UNAUTHORIZED, + "{s:s}", + "error", "signature invalid")) + return GNUNET_SYSERR; + return GNUNET_NO; + } return GNUNET_OK; } |