aboutsummaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2024-04-20 10:53:42 +0200
committerChristian Blättler <blatc2@bfh.ch>2024-04-20 10:53:42 +0200
commitfe9a1da369a9e46dcad373ff2ffa935ea3ae8278 (patch)
treec1d12b8d5a4fee24ea5da4d84a9b75da207b2914 /src/backenddb
parent105974b59fea2a475e15e455de57ab9f07a6841e (diff)
rename keys
Diffstat (limited to 'src/backenddb')
-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
3 files changed, 105 insertions, 120 deletions
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