aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/taler-merchant-httpd_contract.h2
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c21
-rw-r--r--src/backenddb/pg_insert_token_family_key.c22
-rw-r--r--src/backenddb/pg_insert_token_family_key.h4
-rw-r--r--src/backenddb/pg_lookup_token_family_key.c199
-rw-r--r--src/include/taler_merchantdb_plugin.h14
6 files changed, 122 insertions, 140 deletions
diff --git a/src/backend/taler-merchant-httpd_contract.h b/src/backend/taler-merchant-httpd_contract.h
index 3196b469..b231d732 100644
--- a/src/backend/taler-merchant-httpd_contract.h
+++ b/src/backend/taler-merchant-httpd_contract.h
@@ -259,7 +259,7 @@ struct TALER_MerchantContractTokenFamilyKey
/**
* Public key.
*/
- struct TALER_TokenFamilyPublicKey pub;
+ struct TALER_TokenIssuePublicKey pub;
/**
* Tokens signed by this key will be valid after this time.
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index 4ac997ae..e959b221 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1518,12 +1518,12 @@ set_token_family (struct OrderContext *oc,
return GNUNET_SYSERR;
}
- if (GNUNET_CRYPTO_BSA_INVALID == key_details.pub.public_key.cipher)
+ if (NULL == key_details.pub.public_key)
{
/* There is no matching key for this token family yet. */
/* We have to generate one. */
/* If public key is invalid, private key must also be invalid */
- GNUNET_assert (GNUNET_CRYPTO_BSA_INVALID == key_details.priv.private_key.cipher);
+ GNUNET_assert (NULL == key_details.priv.private_key);
enum GNUNET_DB_QueryStatus iqs;
struct GNUNET_CRYPTO_BlindSignPrivateKey *priv;
@@ -1539,16 +1539,13 @@ set_token_family (struct OrderContext *oc,
GNUNET_CRYPTO_BSA_RSA,
4096);
- struct TALER_TokenFamilyPublicKey token_pub = {
- .public_key = *pub,
+ struct TALER_TokenIssuePublicKey token_pub = {
+ .public_key = pub,
};
- struct TALER_TokenFamilyPrivateKey token_priv = {
- .private_key = *priv,
+ struct TALER_TokenIssuePrivateKey token_priv = {
+ .private_key = priv,
};
- // TODO: Check if I have to decref pub and priv here.
- // GNUNET_CRYPTO_blind_sign_pub_decref (pub);
-
iqs = TMH_db->insert_token_family_key (TMH_db->cls,
slug,
&token_pub,
@@ -1706,14 +1703,14 @@ serialize_order (struct OrderContext *oc)
for (unsigned int j = 0; j<family->keys_len; j++)
{
struct TALER_MerchantContractTokenFamilyKey key = family->keys[j];
- cipher = key.pub.public_key.cipher;
+ cipher = key.pub.public_key->cipher;
json_t *jkey = GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("h_pub",
- &key.pub.public_key.pub_key_hash),
+ &key.pub.public_key->pub_key_hash),
GNUNET_JSON_pack_allow_null(
GNUNET_JSON_pack_rsa_public_key ("rsa_pub",
- key.pub.public_key.details.rsa_public_key)),
+ key.pub.public_key->details.rsa_public_key)),
// GNUNET_JSON_pack_allow_null(
// GNUNET_JSON_pack_data_auto ("cs_pub",
// &key.pub.public_key.details.cs_public_key)),
diff --git a/src/backenddb/pg_insert_token_family_key.c b/src/backenddb/pg_insert_token_family_key.c
index b13c8079..69d49bbb 100644
--- a/src/backenddb/pg_insert_token_family_key.c
+++ b/src/backenddb/pg_insert_token_family_key.c
@@ -30,8 +30,8 @@
enum GNUNET_DB_QueryStatus
TMH_PG_insert_token_family_key (void *cls,
const char *token_family_slug,
- const struct TALER_TokenFamilyPublicKey *pub,
- const struct TALER_TokenFamilyPrivateKey *priv,
+ const struct TALER_TokenIssuePublicKey *pub,
+ const struct TALER_TokenIssuePrivateKey *priv,
const struct GNUNET_TIME_Timestamp valid_after,
const struct GNUNET_TIME_Timestamp valid_before)
{
@@ -39,17 +39,17 @@ TMH_PG_insert_token_family_key (void *cls,
const char *cipher = NULL;
struct GNUNET_HashCode pub_hash;
- switch (pub->public_key.cipher)
+ switch (pub->public_key->cipher)
{
case GNUNET_CRYPTO_BSA_RSA:
cipher = "rsa";
- GNUNET_CRYPTO_rsa_public_key_hash (pub->public_key.details.rsa_public_key,
+ GNUNET_CRYPTO_rsa_public_key_hash (pub->public_key->details.rsa_public_key,
&pub_hash);
break;
case GNUNET_CRYPTO_BSA_CS:
cipher = "cs";
- GNUNET_CRYPTO_hash (&pub->public_key.details.cs_public_key,
- sizeof (pub->public_key.details.cs_public_key),
+ GNUNET_CRYPTO_hash (&pub->public_key->details.cs_public_key,
+ sizeof (pub->public_key->details.cs_public_key),
&pub_hash);
break;
case GNUNET_CRYPTO_BSA_INVALID:
@@ -59,20 +59,20 @@ TMH_PG_insert_token_family_key (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (token_family_slug),
- GNUNET_PQ_query_param_blind_sign_pub (&pub->public_key),
- GNUNET_PQ_query_param_auto_from_type (&pub->public_key.pub_key_hash),
- GNUNET_PQ_query_param_blind_sign_priv (&priv->private_key),
+ GNUNET_PQ_query_param_blind_sign_pub (pub->public_key),
+ GNUNET_PQ_query_param_auto_from_type (&pub->public_key->pub_key_hash),
+ GNUNET_PQ_query_param_blind_sign_priv (priv->private_key),
GNUNET_PQ_query_param_timestamp (&valid_after),
GNUNET_PQ_query_param_timestamp (&valid_before),
GNUNET_PQ_query_param_string (cipher),
GNUNET_PQ_query_param_end
};
- GNUNET_assert (pub->public_key.cipher == priv->private_key.cipher);
+ GNUNET_assert (pub->public_key->cipher == priv->private_key->cipher);
GNUNET_assert (0 ==
GNUNET_memcmp (&pub_hash,
- &pub->public_key.pub_key_hash));
+ &pub->public_key->pub_key_hash));
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
valid_after.abs_time));
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
diff --git a/src/backenddb/pg_insert_token_family_key.h b/src/backenddb/pg_insert_token_family_key.h
index c4fc8d85..45ba8589 100644
--- a/src/backenddb/pg_insert_token_family_key.h
+++ b/src/backenddb/pg_insert_token_family_key.h
@@ -38,8 +38,8 @@
enum GNUNET_DB_QueryStatus
TMH_PG_insert_token_family_key (void *cls,
const char *token_family_slug,
- const struct TALER_TokenFamilyPublicKey *pub,
- const struct TALER_TokenFamilyPrivateKey *priv,
+ const struct TALER_TokenIssuePublicKey *pub,
+ const struct TALER_TokenIssuePrivateKey *priv,
const struct GNUNET_TIME_Timestamp valid_after,
const struct GNUNET_TIME_Timestamp valid_before);
diff --git a/src/backenddb/pg_lookup_token_family_key.c b/src/backenddb/pg_lookup_token_family_key.c
index ec9e8096..51c969ec 100644
--- a/src/backenddb/pg_lookup_token_family_key.c
+++ b/src/backenddb/pg_lookup_token_family_key.c
@@ -57,119 +57,104 @@ TMH_PG_lookup_token_family_key (void *cls,
params,
rs_null);
}
- else
- {
- char *kind;
- struct GNUNET_CRYPTO_BlindSignPublicKey *pub;
- struct GNUNET_CRYPTO_BlindSignPrivateKey *priv;
- details->valid_after = GNUNET_TIME_UNIT_ZERO_TS;
- details->valid_before = GNUNET_TIME_UNIT_ZERO_TS;
+ char *kind;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_blind_sign_pub ("pub",
- &pub),
- NULL),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_blind_sign_priv ("priv",
- &priv),
- NULL),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_timestamp ("key_valid_after",
- &details->valid_after),
- NULL),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_timestamp ("key_valid_before",
- &details->valid_before),
- NULL),
- GNUNET_PQ_result_spec_string ("slug",
- &details->token_family.slug),
- GNUNET_PQ_result_spec_string ("name",
- &details->token_family.name),
- GNUNET_PQ_result_spec_string ("description",
- &details->token_family.description),
- TALER_PQ_result_spec_json ("description_i18n",
- &details->token_family.description_i18n),
- GNUNET_PQ_result_spec_timestamp ("valid_after",
- &details->token_family.valid_after),
- GNUNET_PQ_result_spec_timestamp ("valid_before",
- &details->token_family.valid_before),
- GNUNET_PQ_result_spec_relative_time ("duration",
- &details->token_family.duration),
- GNUNET_PQ_result_spec_string ("kind",
- &kind),
- GNUNET_PQ_result_spec_uint64 ("issued",
- &details->token_family.issued),
- GNUNET_PQ_result_spec_uint64 ("redeemed",
- &details->token_family.redeemed),
- GNUNET_PQ_result_spec_end
- };
+ details->valid_after = GNUNET_TIME_UNIT_ZERO_TS;
+ details->valid_before = GNUNET_TIME_UNIT_ZERO_TS;
- memset (details,
- 0,
- sizeof (*details));
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_blind_sign_pub ("pub",
+ &details->pub.public_key),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_blind_sign_priv ("priv",
+ &details->priv.private_key),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_timestamp ("key_valid_after",
+ &details->valid_after),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_timestamp ("key_valid_before",
+ &details->valid_before),
+ NULL),
+ GNUNET_PQ_result_spec_string ("slug",
+ &details->token_family.slug),
+ GNUNET_PQ_result_spec_string ("name",
+ &details->token_family.name),
+ GNUNET_PQ_result_spec_string ("description",
+ &details->token_family.description),
+ TALER_PQ_result_spec_json ("description_i18n",
+ &details->token_family.description_i18n),
+ GNUNET_PQ_result_spec_timestamp ("valid_after",
+ &details->token_family.valid_after),
+ GNUNET_PQ_result_spec_timestamp ("valid_before",
+ &details->token_family.valid_before),
+ GNUNET_PQ_result_spec_relative_time ("duration",
+ &details->token_family.duration),
+ GNUNET_PQ_result_spec_string ("kind",
+ &kind),
+ GNUNET_PQ_result_spec_uint64 ("issued",
+ &details->token_family.issued),
+ GNUNET_PQ_result_spec_uint64 ("redeemed",
+ &details->token_family.redeemed),
+ GNUNET_PQ_result_spec_end
+ };
- check_connection (pg);
- PREPARE (pg,
- "lookup_token_family_key",
- "SELECT"
- " h_pub"
- ",pub"
- ",priv"
- ",cipher"
- ",merchant_token_family_keys.valid_after as key_valid_after"
- ",merchant_token_family_keys.valid_before as key_valid_before"
- ",slug"
- ",name"
- ",description"
- ",description_i18n"
- ",merchant_token_families.valid_after"
- ",merchant_token_families.valid_before"
- ",duration"
- ",kind"
- ",issued"
- ",redeemed"
- " FROM merchant_token_families"
- " LEFT JOIN merchant_token_family_keys"
- " ON merchant_token_families.token_family_serial = merchant_token_family_keys.token_family_serial"
- " AND merchant_token_family_keys.valid_after >= $3"
- " AND merchant_token_family_keys.valid_after < $4"
- " JOIN merchant_instances"
- " USING (merchant_serial)"
- " WHERE merchant_instances.merchant_id=$1"
- " AND slug=$2"
- " LIMIT 1");
- enum GNUNET_DB_QueryStatus qs;
- qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_token_family_key",
- params,
- rs);
+ memset (details,
+ 0,
+ sizeof (*details));
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
- {
- if (0 == strcmp(kind, "discount"))
- details->token_family.kind = TALER_MERCHANTDB_TFK_Discount;
- else if (0 == strcmp(kind, "subscription"))
- details->token_family.kind = TALER_MERCHANTDB_TFK_Subscription;
- else
- {
- GNUNET_break (0);
- return GNUNET_DB_STATUS_HARD_ERROR;
- }
+ check_connection (pg);
+ PREPARE (pg,
+ "lookup_token_family_key",
+ "SELECT"
+ " h_pub"
+ ",pub"
+ ",priv"
+ ",cipher"
+ ",merchant_token_family_keys.valid_after as key_valid_after"
+ ",merchant_token_family_keys.valid_before as key_valid_before"
+ ",slug"
+ ",name"
+ ",description"
+ ",description_i18n"
+ ",merchant_token_families.valid_after"
+ ",merchant_token_families.valid_before"
+ ",duration"
+ ",kind"
+ ",issued"
+ ",redeemed"
+ " FROM merchant_token_families"
+ " LEFT JOIN merchant_token_family_keys"
+ " ON merchant_token_families.token_family_serial = merchant_token_family_keys.token_family_serial"
+ " AND merchant_token_family_keys.valid_after >= $3"
+ " AND merchant_token_family_keys.valid_after < $4"
+ " JOIN merchant_instances"
+ " USING (merchant_serial)"
+ " WHERE merchant_instances.merchant_id=$1"
+ " AND slug=$2"
+ " LIMIT 1");
+ enum GNUNET_DB_QueryStatus qs;
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_token_family_key",
+ params,
+ rs);
- if (NULL != pub)
- {
- details->pub.public_key = *pub;
- // GNUNET_CRYPTO_blind_sign_pub_decref(pub);
- }
- if (NULL != priv)
- {
- details->priv.private_key = *priv;
- // GNUNET_CRYPTO_blind_sign_priv_decref(priv);
- }
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ {
+ if (0 == strcmp(kind, "discount"))
+ details->token_family.kind = TALER_MERCHANTDB_TFK_Discount;
+ else if (0 == strcmp(kind, "subscription"))
+ details->token_family.kind = TALER_MERCHANTDB_TFK_Subscription;
+ else
+ {
+ GNUNET_break (0);
+ return GNUNET_DB_STATUS_HARD_ERROR;
}
-
- return qs;
}
+
+ return qs;
} \ No newline at end of file
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index ba38b20f..7439d6b7 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -1096,12 +1096,12 @@ struct TALER_MERCHANTDB_TokenFamilyKeyDetails
/**
* Token family public key.
*/
- struct TALER_TokenFamilyPublicKey pub;
+ struct TALER_TokenIssuePublicKey pub;
/**
* Token family private key.
*/
- struct TALER_TokenFamilyPrivateKey priv;
+ struct TALER_TokenIssuePrivateKey priv;
/**
* Details about the token family this key belongs to.
@@ -1117,17 +1117,17 @@ struct TALER_MERCHANTDB_SpentTokenDetails
/**
* Public key of the spent token.
*/
- struct TALER_TokenPublicKey pub;
+ struct TALER_TokenUsePublicKey pub;
/**
* Signature that this token was spent on the specified order.
*/
- struct TALER_TokenSignature sig;
+ struct TALER_TokenUseSignature sig;
/**
* Blind signature for the spent token to prove validity of it.
*/
- struct TALER_TokenBlindSignature blind_sig;
+ struct TALER_TokenIssueBlindSignature blind_sig;
};
@@ -3294,8 +3294,8 @@ struct TALER_MERCHANTDB_Plugin
(*insert_token_family_key)(
void *cls,
const char *token_family_slug,
- const struct TALER_TokenFamilyPublicKey *pub,
- const struct TALER_TokenFamilyPrivateKey *priv,
+ const struct TALER_TokenIssuePublicKey *pub,
+ const struct TALER_TokenIssuePrivateKey *priv,
struct GNUNET_TIME_Timestamp valid_after,
struct GNUNET_TIME_Timestamp valid_before);