diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-09 13:21:55 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-09 13:21:55 +0100 |
commit | 8eaeda99589fe5d0b43818033fc8871b62f50090 (patch) | |
tree | 237ea2a4dbb8470cde40f56efdb7d3e183119c27 | |
parent | ce8272446eebebb73cbab8ab4e388a2ec7e164fd (diff) | |
download | exchange-8eaeda99589fe5d0b43818033fc8871b62f50090.tar.gz exchange-8eaeda99589fe5d0b43818033fc8871b62f50090.zip |
fix use of signature for noreveal index, needs to be tied to session hash
-rw-r--r-- | src/include/taler_signatures.h | 5 | ||||
-rw-r--r-- | src/mint/mint_db.h | 8 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_db.c | 8 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 1 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.c | 16 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 8 |
6 files changed, 32 insertions, 14 deletions
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 8984165e6..bf39c0aba 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h | |||
@@ -321,6 +321,11 @@ struct RefreshCommitResponseSignatureBody | |||
321 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | 321 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; |
322 | 322 | ||
323 | /** | 323 | /** |
324 | * Hash of the refresh session. | ||
325 | */ | ||
326 | struct GNUNET_HashCode session_hash; | ||
327 | |||
328 | /** | ||
324 | * Index that the client will not have to reveal. | 329 | * Index that the client will not have to reveal. |
325 | */ | 330 | */ |
326 | uint16_t noreveal_index GNUNET_PACKED; | 331 | uint16_t noreveal_index GNUNET_PACKED; |
diff --git a/src/mint/mint_db.h b/src/mint/mint_db.h index 48fb5ea39..403e1f394 100644 --- a/src/mint/mint_db.h +++ b/src/mint/mint_db.h | |||
@@ -444,7 +444,13 @@ struct RefreshSession | |||
444 | */ | 444 | */ |
445 | struct GNUNET_CRYPTO_EddsaSignature commit_sig; | 445 | struct GNUNET_CRYPTO_EddsaSignature commit_sig; |
446 | 446 | ||
447 | /** | 447 | /** |
448 | * Hash over coins to melt and coins to create of the | ||
449 | * refresh session. | ||
450 | */ | ||
451 | struct GNUNET_HashCode session_hash; | ||
452 | |||
453 | /** | ||
448 | * Signature over the melt by the client. | 454 | * Signature over the melt by the client. |
449 | */ | 455 | */ |
450 | struct GNUNET_CRYPTO_EddsaSignature melt_sig; | 456 | struct GNUNET_CRYPTO_EddsaSignature melt_sig; |
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index b20e88494..d9a172a40 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c | |||
@@ -588,6 +588,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, | |||
588 | 588 | ||
589 | /* store 'global' session data */ | 589 | /* store 'global' session data */ |
590 | session.melt_sig = *client_signature; | 590 | session.melt_sig = *client_signature; |
591 | session.session_hash = *melt_hash; | ||
591 | session.num_oldcoins = coin_count; | 592 | session.num_oldcoins = coin_count; |
592 | session.num_newcoins = num_new_denoms; | 593 | session.num_newcoins = num_new_denoms; |
593 | session.kappa = KAPPA; | 594 | session.kappa = KAPPA; |
@@ -691,7 +692,8 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection, | |||
691 | { | 692 | { |
692 | TALER_MINT_DB_rollback (db_conn); | 693 | TALER_MINT_DB_rollback (db_conn); |
693 | res = TALER_MINT_reply_refresh_commit_success (connection, | 694 | res = TALER_MINT_reply_refresh_commit_success (connection, |
694 | &refresh_session); | 695 | &refresh_session.session_hash, |
696 | refresh_session.noreveal_index); | ||
695 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; | 697 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; |
696 | } | 698 | } |
697 | for (i = 0; i < kappa; i++) | 699 | for (i = 0; i < kappa; i++) |
@@ -749,7 +751,9 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection, | |||
749 | return TALER_MINT_reply_commit_error (connection); | 751 | return TALER_MINT_reply_commit_error (connection); |
750 | } | 752 | } |
751 | 753 | ||
752 | return TALER_MINT_reply_refresh_commit_success (connection, &refresh_session); | 754 | return TALER_MINT_reply_refresh_commit_success (connection, |
755 | &refresh_session.session_hash, | ||
756 | refresh_session.noreveal_index); | ||
753 | } | 757 | } |
754 | 758 | ||
755 | 759 | ||
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 5625dc8c7..cfb3ba0f5 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c | |||
@@ -179,6 +179,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, | |||
179 | 179 | ||
180 | /* check that signature from the session public key is ok */ | 180 | /* check that signature from the session public key is ok */ |
181 | hash_context = GNUNET_CRYPTO_hash_context_start (); | 181 | hash_context = GNUNET_CRYPTO_hash_context_start (); |
182 | /* FIXME: also hash session public key here!? */ | ||
182 | for (i = 0; i < num_new_denoms; i++) | 183 | for (i = 0; i < num_new_denoms; i++) |
183 | { | 184 | { |
184 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pubs[i], | 185 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pubs[i], |
diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 995f46bb8..21e208115 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c | |||
@@ -631,15 +631,15 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, | |||
631 | /** | 631 | /** |
632 | * Send a response to a "/refresh/commit" request. | 632 | * Send a response to a "/refresh/commit" request. |
633 | * | 633 | * |
634 | * FIXME: maybe not the ideal argument type for @a refresh_session here. | ||
635 | * | ||
636 | * @param connection the connection to send the response to | 634 | * @param connection the connection to send the response to |
637 | * @param refresh_session the refresh session | 635 | * @param session_hash hash of the refresh session |
636 | * @param noreveal_index which index will the client not have to reveal | ||
638 | * @return a MHD status code | 637 | * @return a MHD status code |
639 | */ | 638 | */ |
640 | int | 639 | int |
641 | TALER_MINT_reply_refresh_commit_success (struct MHD_Connection *connection, | 640 | TALER_MINT_reply_refresh_commit_success (struct MHD_Connection *connection, |
642 | const struct RefreshSession *refresh_session) | 641 | const struct GNUNET_HashCode *session_hash, |
642 | uint16_t noreveal_index) | ||
643 | { | 643 | { |
644 | struct RefreshCommitResponseSignatureBody body; | 644 | struct RefreshCommitResponseSignatureBody body; |
645 | struct GNUNET_CRYPTO_EddsaSignature sig; | 645 | struct GNUNET_CRYPTO_EddsaSignature sig; |
@@ -648,15 +648,17 @@ TALER_MINT_reply_refresh_commit_success (struct MHD_Connection *connection, | |||
648 | 648 | ||
649 | body.purpose.size = htonl (sizeof (struct RefreshCommitResponseSignatureBody)); | 649 | body.purpose.size = htonl (sizeof (struct RefreshCommitResponseSignatureBody)); |
650 | body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_COMMIT_RESPONSE); | 650 | body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_COMMIT_RESPONSE); |
651 | body.noreveal_index = htons (refresh_session->noreveal_index); | 651 | body.session_hash = *session_hash; |
652 | body.noreveal_index = htons (noreveal_index); | ||
652 | TALER_MINT_keys_sign (&body.purpose, | 653 | TALER_MINT_keys_sign (&body.purpose, |
653 | &sig); | 654 | &sig); |
654 | sig_json = TALER_JSON_from_eddsa_sig (&body.purpose, &sig); | 655 | sig_json = TALER_JSON_from_eddsa_sig (&body.purpose, |
656 | &sig); | ||
655 | GNUNET_assert (NULL != sig_json); | 657 | GNUNET_assert (NULL != sig_json); |
656 | ret = TALER_MINT_reply_json_pack (connection, | 658 | ret = TALER_MINT_reply_json_pack (connection, |
657 | MHD_HTTP_OK, | 659 | MHD_HTTP_OK, |
658 | "{s:i, s:o}", | 660 | "{s:i, s:o}", |
659 | "noreveal_index", (int) refresh_session->noreveal_index, | 661 | "noreveal_index", (int) noreveal_index, |
660 | "signature", sig_json); | 662 | "signature", sig_json); |
661 | json_decref (sig_json); | 663 | json_decref (sig_json); |
662 | return ret; | 664 | return ret; |
diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index 08b88ea29..abfb4318c 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h | |||
@@ -249,15 +249,15 @@ TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection, | |||
249 | /** | 249 | /** |
250 | * Send a response to a "/refresh/commit" request. | 250 | * Send a response to a "/refresh/commit" request. |
251 | * | 251 | * |
252 | * FIXME: maybe not the ideal argument type for @a refresh_session here. | ||
253 | * | ||
254 | * @param connection the connection to send the response to | 252 | * @param connection the connection to send the response to |
255 | * @param refresh_session the refresh session | 253 | * @param session_hash hash of the refresh session |
254 | * @param noreveal_index which index will the client not have to reveal | ||
256 | * @return a MHD status code | 255 | * @return a MHD status code |
257 | */ | 256 | */ |
258 | int | 257 | int |
259 | TALER_MINT_reply_refresh_commit_success (struct MHD_Connection *connection, | 258 | TALER_MINT_reply_refresh_commit_success (struct MHD_Connection *connection, |
260 | const struct RefreshSession *refresh_session); | 259 | const struct GNUNET_HashCode *session_hash, |
260 | uint16_t noreveal_index); | ||
261 | 261 | ||
262 | 262 | ||
263 | /** | 263 | /** |