aboutsummaryrefslogtreecommitdiff
path: root/src/mint
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-04-11 21:29:15 +0200
committerChristian Grothoff <christian@grothoff.org>2015-04-11 21:29:15 +0200
commit4f078c7666bfc1c2379b242c38674932dbf832ee (patch)
tree2ad069f96d69e63ed299d042511a29bd49e97a44 /src/mint
parent8b321252230a2e87ec8f50cec0c344122952c387 (diff)
scaffolding work towards #3712
Diffstat (limited to 'src/mint')
-rw-r--r--src/mint/taler-mint-httpd_db.c87
-rw-r--r--src/mint/taler-mint-httpd_refresh.c3
-rw-r--r--src/mint/taler-mint-httpd_responses.c4
-rw-r--r--src/mint/taler-mint-httpd_responses.h6
4 files changed, 73 insertions, 27 deletions
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c
index 742868272..11bd60f7b 100644
--- a/src/mint/taler-mint-httpd_db.c
+++ b/src/mint/taler-mint-httpd_db.c
@@ -744,6 +744,54 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
/**
+ * Send an error response with the details of the original melt
+ * commitment and the location of the mismatch.
+ *
+ * @param connection the MHD connection to handle
+ * @param session database connection to use
+ * @param session_hash hash of session to query
+ * @param off commitment offset to check
+ * @param index index of the mismatch
+ * @param object_name name of the object with the problem
+ * @return #GNUNET_NO if we generated the error message
+ * #GNUNET_SYSERR if we could not even generate an error message
+ */
+static int
+send_melt_commitment_error (struct MHD_Connection *connection,
+ struct TALER_MINTDB_Session *session,
+ const struct GNUNET_HashCode *session_hash,
+ unsigned int off,
+ unsigned int index,
+ const char *object_name)
+{
+ struct TALER_MINTDB_MeltCommitment *mc;
+ int ret;
+
+ mc = TMH_plugin->get_melt_commitment (TMH_plugin->cls,
+ session,
+ session_hash);
+ if (NULL == mc)
+ {
+ GNUNET_break (0);
+ return (MHD_YES ==
+ TMH_RESPONSE_reply_internal_error (connection,
+ "Melt commitment assembly"))
+ ? GNUNET_NO : GNUNET_SYSERR;
+ }
+ ret = (MHD_YES ==
+ TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
+ mc,
+ off,
+ index,
+ object_name))
+ ? GNUNET_NO : GNUNET_SYSERR;
+ TMH_plugin->free_melt_commitment (TMH_plugin->cls,
+ mc);
+ return ret;
+}
+
+
+/**
* Check if the given @a transfer_privs correspond to an honest
* commitment for the given session.
* Checks that the transfer private keys match their commitments.
@@ -811,13 +859,12 @@ check_commitment (struct MHD_Connection *connection,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"transfer keys do not match\n");
GNUNET_free (commit_links);
- /* FIXME: return more specific error with original signature (#3712) */
- return (MHD_YES ==
- TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
- off,
- j,
- "transfer key"))
- ? GNUNET_NO : GNUNET_SYSERR;
+ return send_melt_commitment_error (connection,
+ session,
+ session_hash,
+ off,
+ j,
+ "transfer key");
}
/* We're converting key types here, which is not very nice
@@ -858,13 +905,12 @@ check_commitment (struct MHD_Connection *connection,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"shared secrets do not match\n");
GNUNET_free (commit_links);
- /* FIXME: return more specific error with original signature (#3712) */
- return (MHD_YES ==
- TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
- off,
- j,
- "transfer secret"))
- ? GNUNET_NO : GNUNET_SYSERR;
+ return send_melt_commitment_error (connection,
+ session,
+ session_hash,
+ off,
+ j,
+ "transfer secret");
}
}
GNUNET_break (GNUNET_YES == secret_initialized);
@@ -935,14 +981,13 @@ check_commitment (struct MHD_Connection *connection,
"blind envelope does not match for k=%u, old=%d\n",
off,
(int) j);
- /* FIXME: return more specific error with original signature (#3712) */
GNUNET_free (commit_coins);
- return (MHD_YES ==
- TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
- off,
- j,
- "envelope"))
- ? GNUNET_NO : GNUNET_SYSERR;
+ return send_melt_commitment_error (connection,
+ session,
+ session_hash,
+ off,
+ j,
+ "envelope");
}
GNUNET_free (buf);
}
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c
index 805d4f9c5..38af09d85 100644
--- a/src/mint/taler-mint-httpd_refresh.c
+++ b/src/mint/taler-mint-httpd_refresh.c
@@ -61,7 +61,6 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
const struct GNUNET_HashCode *session_hash,
struct TALER_MINTDB_RefreshCommitCoin *const* commit_coin,
struct TALER_MINTDB_RefreshCommitLinkP *const* commit_link)
-
{
unsigned int i;
struct TMH_KS_StateHandle *key_state;
@@ -509,6 +508,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
free_commit_coins (commit_coin,
TALER_CNC_KAPPA,
num_newcoins);
+ GNUNET_free (link_enc);
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
}
rcc->refresh_link
@@ -517,6 +517,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
GNUNET_CRYPTO_hash_context_read (hash_context,
link_enc,
link_enc_size);
+ GNUNET_free (link_enc);
}
}
diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c
index c567103f0..57170e0b8 100644
--- a/src/mint/taler-mint-httpd_responses.c
+++ b/src/mint/taler-mint-httpd_responses.c
@@ -776,9 +776,10 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
*
* FIXME: should also include the client's signature over
* the original reveal operation and the data that was signed
- * over eventually... (#3712)
+ * over eventually... (#3712) -- need to use @a mc!
*
* @param connection the connection to send the response to
+ * @param mc all information about the original commitment
* @param off offset in the array of kappa-commitments where
* the missmatch was detected
* @param j index of the coin for which the missmatch was
@@ -789,6 +790,7 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
*/
int
TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
+ const struct TALER_MINTDB_MeltCommitment *mc,
unsigned int off,
unsigned int j,
const char *missmatch_object)
diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h
index cedb90d36..ab062c2a7 100644
--- a/src/mint/taler-mint-httpd_responses.h
+++ b/src/mint/taler-mint-httpd_responses.h
@@ -316,11 +316,8 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
* Send a response for a failed "/refresh/reveal", where the
* revealed value(s) do not match the original commitment.
*
- * FIXME: should also include the client's signature over
- * the original reveal operation and the data that was signed
- * over eventually... (#3712)
- *
* @param connection the connection to send the response to
+ * @param mc all information about the original commitment
* @param off offset in the array of kappa-commitments where
* the missmatch was detected
* @param j index of the coin for which the missmatch was
@@ -331,6 +328,7 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
*/
int
TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
+ const struct TALER_MINTDB_MeltCommitment *mc,
unsigned int off,
unsigned int j,
const char *missmatch_object);