From 2e7b28765ea2871df03353681f0680c53ec3ebef Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 6 Jul 2015 10:16:49 +0200 Subject: simplifying use of struct TALER_DenominationKeyValidityPS by removing signature --- src/mintdb/perf_taler_mintdb_init.c | 30 ++++++++++----------- src/mintdb/plugin_mintdb_postgres.c | 52 ++++++++++++++++++------------------- src/mintdb/test_mintdb.c | 24 ++++++++--------- src/mintdb/test_mintdb_keyio.c | 3 +-- 4 files changed, 53 insertions(+), 56 deletions(-) (limited to 'src/mintdb') diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c index 90015e37a..be47f76d4 100644 --- a/src/mintdb/perf_taler_mintdb_init.c +++ b/src/mintdb/perf_taler_mintdb_init.c @@ -50,36 +50,34 @@ PERF_TALER_MINTDB_denomination_init () (dki->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key))); GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, - &dki->issue.denom_hash); + &dki->issue.properties.denom_hash); GNUNET_assert (NULL != (master_prvt = GNUNET_CRYPTO_eddsa_key_create ())); GNUNET_CRYPTO_eddsa_key_get_public (master_prvt, - &dki->issue.master.eddsa_pub); + &dki->issue.properties.master.eddsa_pub); anchor = GNUNET_TIME_absolute_get (); - dki->issue.start = GNUNET_TIME_absolute_hton (anchor); - dki->issue.expire_withdraw = + dki->issue.properties.start = GNUNET_TIME_absolute_hton (anchor); + dki->issue.properties.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, GNUNET_TIME_relative_get_hour_ ())); - dki->issue.expire_spend = + dki->issue.properties.expire_spend = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, GNUNET_TIME_relative_get_hour_ ())); - dki->issue.expire_legal = + dki->issue.properties.expire_legal = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (anchor, GNUNET_TIME_relative_get_hour_ ())); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":1.1", &amount)); - TALER_amount_hton (&dki->issue.value, &amount); - TALER_amount_hton (&dki->issue.fee_withdraw, &amount); - TALER_amount_hton (&dki->issue.fee_deposit, &amount); - TALER_amount_hton (&dki->issue.fee_refresh, &amount); - dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); - dki->issue.purpose.size = - htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation) - - offsetof (struct TALER_MINTDB_DenominationKeyIssueInformation, - issue.purpose)); + TALER_amount_hton (&dki->issue.properties.value, &amount); + TALER_amount_hton (&dki->issue.properties.fee_withdraw, &amount); + TALER_amount_hton (&dki->issue.properties.fee_deposit, &amount); + TALER_amount_hton (&dki->issue.properties.fee_refresh, &amount); + dki->issue.properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); + dki->issue.properties.purpose.size = + htonl (sizeof (struct TALER_MINTDB_DenominationKeyIssueInformation)); GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (master_prvt, - &dki->issue.purpose, + &dki->issue.properties.purpose, &dki->issue.signature.eddsa_signature)); GNUNET_free (master_prvt); diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 015e8bbe7..bef3f9301 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -1045,35 +1045,35 @@ static int postgres_insert_denomination_info (void *cls, struct TALER_MINTDB_Session *session, const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_DenominationKeyValidityPS *issue) + const struct TALER_MINTDB_DenominationKeyInformationP *issue) { PGresult *result; int ret; struct TALER_PQ_QueryParam params[] = { 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->properties.master), TALER_PQ_query_param_auto_from_type (&issue->signature), - TALER_PQ_query_param_absolute_time_nbo (&issue->start), - TALER_PQ_query_param_absolute_time_nbo (&issue->expire_withdraw), - TALER_PQ_query_param_absolute_time_nbo (&issue->expire_spend), - TALER_PQ_query_param_absolute_time_nbo (&issue->expire_legal), - TALER_PQ_query_param_amount_nbo (&issue->value), - TALER_PQ_query_param_amount_nbo (&issue->fee_withdraw), - TALER_PQ_query_param_amount_nbo (&issue->fee_deposit), - TALER_PQ_query_param_amount_nbo (&issue->fee_refresh), + TALER_PQ_query_param_absolute_time_nbo (&issue->properties.start), + TALER_PQ_query_param_absolute_time_nbo (&issue->properties.expire_withdraw), + TALER_PQ_query_param_absolute_time_nbo (&issue->properties.expire_spend), + TALER_PQ_query_param_absolute_time_nbo (&issue->properties.expire_legal), + TALER_PQ_query_param_amount_nbo (&issue->properties.value), + TALER_PQ_query_param_amount_nbo (&issue->properties.fee_withdraw), + TALER_PQ_query_param_amount_nbo (&issue->properties.fee_deposit), + TALER_PQ_query_param_amount_nbo (&issue->properties.fee_refresh), TALER_PQ_query_param_end }; /* check fees match coin currency */ GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_withdraw)); + TALER_amount_cmp_currency_nbo (&issue->properties.value, + &issue->properties.fee_withdraw)); GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_deposit)); + TALER_amount_cmp_currency_nbo (&issue->properties.value, + &issue->properties.fee_deposit)); GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_refresh)); + TALER_amount_cmp_currency_nbo (&issue->properties.value, + &issue->properties.fee_refresh)); result = TALER_PQ_exec_prepared (session->conn, "denomination_insert", @@ -1105,7 +1105,7 @@ static int postgres_get_denomination_info (void *cls, struct TALER_MINTDB_Session *session, const struct TALER_DenominationPublicKey *denom_pub, - struct TALER_DenominationKeyValidityPS *issue) + struct TALER_MINTDB_DenominationKeyInformationP *issue) { PGresult *result; struct TALER_PQ_QueryParam params[] = { @@ -1141,25 +1141,25 @@ postgres_get_denomination_info (void *cls, { struct TALER_PQ_ResultSpec rs[] = { TALER_PQ_result_spec_auto_from_type ("master_pub", - &issue->master), + &issue->properties.master), TALER_PQ_result_spec_auto_from_type ("master_sig", &issue->signature), TALER_PQ_result_spec_absolute_time_nbo ("valid_from", - &issue->start), + &issue->properties.start), TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw", - &issue->expire_withdraw), + &issue->properties.expire_withdraw), TALER_PQ_result_spec_absolute_time_nbo ("expire_spend", - &issue->expire_spend), + &issue->properties.expire_spend), TALER_PQ_result_spec_absolute_time_nbo ("expire_legal", - &issue->expire_legal), + &issue->properties.expire_legal), TALER_PQ_result_spec_amount_nbo ("coin", - &issue->value), + &issue->properties.value), TALER_PQ_result_spec_amount_nbo ("fee_withdraw", - &issue->fee_withdraw), + &issue->properties.fee_withdraw), TALER_PQ_result_spec_amount_nbo ("fee_deposit", - &issue->fee_deposit), + &issue->properties.fee_deposit), TALER_PQ_result_spec_amount_nbo ("fee_refresh", - &issue->fee_refresh), + &issue->properties.fee_refresh), TALER_PQ_result_spec_end }; diff --git a/src/mintdb/test_mintdb.c b/src/mintdb/test_mintdb.c index 857d54413..a01518e14 100644 --- a/src/mintdb/test_mintdb.c +++ b/src/mintdb/test_mintdb.c @@ -105,26 +105,26 @@ register_denomination(struct TALER_DenominationPublicKey denom_pub, 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 + dki.issue.properties.start = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); + dki.issue.properties.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_HOURS)); - dki.issue.expire_spend = GNUNET_TIME_absolute_hton + dki.issue.properties.expire_spend = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 2))); - dki.issue.expire_legal = GNUNET_TIME_absolute_hton + dki.issue.properties.expire_legal = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 3))); - dki.issue.value.value = GNUNET_htonll (1); - dki.issue.value.fraction = htonl (100); - (void) strcpy (dki.issue.value.currency, CURRENCY); - dki.issue.fee_withdraw.value = 0; - dki.issue.fee_withdraw.fraction = htonl (100); - (void) strcpy (dki.issue.fee_withdraw.currency, CURRENCY); - dki.issue.fee_deposit = dki.issue.fee_withdraw; - dki.issue.fee_refresh = dki.issue.fee_withdraw; + dki.issue.properties.value.value = GNUNET_htonll (1); + dki.issue.properties.value.fraction = htonl (100); + (void) strcpy (dki.issue.properties.value.currency, CURRENCY); + dki.issue.properties.fee_withdraw.value = 0; + dki.issue.properties.fee_withdraw.fraction = htonl (100); + (void) strcpy (dki.issue.properties.fee_withdraw.currency, CURRENCY); + dki.issue.properties.fee_deposit = dki.issue.properties.fee_withdraw; + dki.issue.properties.fee_refresh = dki.issue.properties.fee_withdraw; if (GNUNET_OK != plugin->insert_denomination_info (plugin->cls, session, diff --git a/src/mintdb/test_mintdb_keyio.c b/src/mintdb/test_mintdb_keyio.c index a32d64931..aa1ba2f20 100644 --- a/src/mintdb/test_mintdb_keyio.c +++ b/src/mintdb/test_mintdb_keyio.c @@ -53,8 +53,7 @@ main (int argc, dki_read.denom_priv.rsa_private_key = NULL; GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &dki.issue.signature, - sizeof (dki) - offsetof (struct TALER_DenominationKeyValidityPS, - signature)); + sizeof (struct TALER_MasterSignatureP)); dki.denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE); enc_size = GNUNET_CRYPTO_rsa_private_key_encode (dki.denom_priv.rsa_private_key, -- cgit v1.2.3