This commit is contained in:
Christian Grothoff 2015-06-11 14:58:23 +02:00
parent eedfc04850
commit a2c77cd36a
3 changed files with 26 additions and 16 deletions

View File

@ -678,15 +678,15 @@ struct TALER_MINTDB_Plugin
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param sesssion connection to use * @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 * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
*/ */
int int
(*insert_denomination) (void *cls, (*insert_denomination) (void *cls,
struct TALER_MINTDB_Session *session, struct TALER_MINTDB_Session *session,
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_DenominationKeyValidityPS *issue);
/** /**

View File

@ -211,6 +211,8 @@ postgres_create_tables (void *cls,
referencing these rows */ referencing these rows */
SQLEXEC ("CREATE TABLE IF NOT EXISTS denominations" SQLEXEC ("CREATE TABLE IF NOT EXISTS denominations"
"(pub BYTEA PRIMARY KEY" "(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" ",valid_from INT8 NOT NULL"
",expire_withdraw INT8 NOT NULL" ",expire_withdraw INT8 NOT NULL"
",expire_spend INT8 NOT NULL" ",expire_spend INT8 NOT NULL"
@ -440,6 +442,8 @@ postgres_prepare (PGconn *db_conn)
PREPARE ("insert_denomination", PREPARE ("insert_denomination",
"INSERT INTO denominations " "INSERT INTO denominations "
"(pub" "(pub"
",master_pub"
",master_sig"
",valid_from" ",valid_from"
",expire_withdraw" ",expire_withdraw"
",expire_spend" ",expire_spend"
@ -457,9 +461,9 @@ postgres_prepare (PGconn *db_conn)
",fee_refresh_frac" ",fee_refresh_frac"
",fee_refresh_curr" /* must match coin_curr */ ",fee_refresh_curr" /* must match coin_curr */
") VALUES " ") VALUES "
"($1, $2, $3, $4, $5, $6," "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
"$7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17);", " $11, $12, $13, $14, $15, $16, $17, $18, $19);",
14, NULL); 19, NULL);
/* FIXME: #3808: need a 'select_denominations' for auditor */ /* 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 cls the @e cls of this struct with the plugin-specific state
* @param session connection to use * @param session connection to use
* @param dki the denomination key information; * @param denom_pub the public key used for signing coins of this denomination
* NOTE: we might want to avoid passing the RSA private key here, * @param issue issuing information with value, fees and other info about the coin
* as we do not want that in the DB (#3823)
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
*/ */
static int static int
postgres_insert_denomination (void *cls, postgres_insert_denomination (void *cls,
struct TALER_MINTDB_Session *session, 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; PGresult *result;
int ret; int ret;
struct TALER_PQ_QueryParam params[] = { struct TALER_PQ_QueryParam params[] = {
TALER_PQ_query_param_rsa_public_key (dki->denom_pub.rsa_public_key), TALER_PQ_query_param_rsa_public_key (denom_pub->rsa_public_key),
/* FIXME: MasterSignature not stored (required for audit), #3823 */ TALER_PQ_query_param_auto_from_type (&issue->master),
/* FIXME: MasterPublicKey not stored (required for audit), #3823 */ 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->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_withdraw.abs_value_us__),
TALER_PQ_query_param_auto_from_type (&issue->expire_spend.abs_value_us__), TALER_PQ_query_param_auto_from_type (&issue->expire_spend.abs_value_us__),

View File

@ -98,6 +98,12 @@ register_denomination(struct TALER_DenominationPublicKey denom_pub,
struct TALER_MINTDB_Session *session) struct TALER_MINTDB_Session *session)
{ {
struct TALER_MINTDB_DenominationKeyIssueInformation dki; 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.denom_pub = denom_pub;
dki.issue.start = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); dki.issue.start = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
dki.issue.expire_withdraw = GNUNET_TIME_absolute_hton dki.issue.expire_withdraw = GNUNET_TIME_absolute_hton
@ -122,7 +128,8 @@ register_denomination(struct TALER_DenominationPublicKey denom_pub,
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_denomination (plugin->cls, plugin->insert_denomination (plugin->cls,
session, session,
&dki)) &denom_pub,
&dki.issue))
{ {
GNUNET_break(0); GNUNET_break(0);
return GNUNET_SYSERR; return GNUNET_SYSERR;