From a2c77cd36a2b0d0ebb7d8b999cabcc8a36ccd6bb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 11 Jun 2015 14:58:23 +0200 Subject: fixing #3823 --- src/include/taler_mintdb_plugin.h | 8 ++++---- src/mintdb/plugin_mintdb_postgres.c | 25 ++++++++++++++----------- src/mintdb/test_mintdb.c | 9 ++++++++- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index 17edd83e5..2eeead26f 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -678,15 +678,15 @@ struct TALER_MINTDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param sesssion connection to use - * @param dki the denomination key information (#3823) + * @param denom_pub the public key used for signing coins of this denomination + * @param issue issuing information with value, fees and other info about the coin * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure */ int (*insert_denomination) (void *cls, struct TALER_MINTDB_Session *session, - const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); - - + const struct TALER_DenominationPublicKey *denom_pub, + const struct TALER_DenominationKeyValidityPS *issue); /** diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 870bfb756..fe2362844 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -211,6 +211,8 @@ postgres_create_tables (void *cls, referencing these rows */ SQLEXEC ("CREATE TABLE IF NOT EXISTS denominations" "(pub BYTEA PRIMARY KEY" + ",master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)" + ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" ",valid_from INT8 NOT NULL" ",expire_withdraw INT8 NOT NULL" ",expire_spend INT8 NOT NULL" @@ -440,6 +442,8 @@ postgres_prepare (PGconn *db_conn) PREPARE ("insert_denomination", "INSERT INTO denominations " "(pub" + ",master_pub" + ",master_sig" ",valid_from" ",expire_withdraw" ",expire_spend" @@ -457,9 +461,9 @@ postgres_prepare (PGconn *db_conn) ",fee_refresh_frac" ",fee_refresh_curr" /* must match coin_curr */ ") VALUES " - "($1, $2, $3, $4, $5, $6," - "$7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17);", - 14, NULL); + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10," + " $11, $12, $13, $14, $15, $16, $17, $18, $19);", + 19, NULL); /* FIXME: #3808: need a 'select_denominations' for auditor */ @@ -1004,24 +1008,23 @@ postgres_commit (void *cls, * * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use - * @param dki the denomination key information; - * NOTE: we might want to avoid passing the RSA private key here, - * as we do not want that in the DB (#3823) + * @param denom_pub the public key used for signing coins of this denomination + * @param issue issuing information with value, fees and other info about the coin * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure */ static int postgres_insert_denomination (void *cls, struct TALER_MINTDB_Session *session, - const struct TALER_MINTDB_DenominationKeyIssueInformation *dki) + const struct TALER_DenominationPublicKey *denom_pub, + const struct TALER_DenominationKeyValidityPS *issue) { - const struct TALER_DenominationKeyValidityPS *issue = &dki->issue; PGresult *result; int ret; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_query_param_rsa_public_key (dki->denom_pub.rsa_public_key), - /* FIXME: MasterSignature not stored (required for audit), #3823 */ - /* FIXME: MasterPublicKey not stored (required for audit), #3823 */ + TALER_PQ_query_param_rsa_public_key (denom_pub->rsa_public_key), + TALER_PQ_query_param_auto_from_type (&issue->master), + TALER_PQ_query_param_auto_from_type (&issue->signature), TALER_PQ_query_param_auto_from_type (&issue->start.abs_value_us__), TALER_PQ_query_param_auto_from_type (&issue->expire_withdraw.abs_value_us__), TALER_PQ_query_param_auto_from_type (&issue->expire_spend.abs_value_us__), diff --git a/src/mintdb/test_mintdb.c b/src/mintdb/test_mintdb.c index ed6986cc0..edf0c4e68 100644 --- a/src/mintdb/test_mintdb.c +++ b/src/mintdb/test_mintdb.c @@ -98,6 +98,12 @@ register_denomination(struct TALER_DenominationPublicKey denom_pub, struct TALER_MINTDB_Session *session) { struct TALER_MINTDB_DenominationKeyIssueInformation dki; + + /* Using memset() as fields like master key and signature + are not properly initialized for this test. */ + memset (&dki, + 0, + sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation)); dki.denom_pub = denom_pub; dki.issue.start = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); dki.issue.expire_withdraw = GNUNET_TIME_absolute_hton @@ -122,7 +128,8 @@ register_denomination(struct TALER_DenominationPublicKey denom_pub, if (GNUNET_OK != plugin->insert_denomination (plugin->cls, session, - &dki)) + &denom_pub, + &dki.issue)) { GNUNET_break(0); return GNUNET_SYSERR; -- cgit v1.2.3