summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-04-05 17:15:58 +0200
committerChristian Grothoff <christian@grothoff.org>2022-04-05 17:15:58 +0200
commit58f1ae25c69e0e378af2c45b929c8bbf7d5c1b2a (patch)
treeef9625d7929245f48d0142a658a702ca758399bd /src/backenddb
parent69131a3253264dd8e7b595f4dd985c5ad8a8e2de (diff)
downloadmerchant-58f1ae25c69e0e378af2c45b929c8bbf7d5c1b2a.tar.gz
merchant-58f1ae25c69e0e378af2c45b929c8bbf7d5c1b2a.tar.bz2
merchant-58f1ae25c69e0e378af2c45b929c8bbf7d5c1b2a.zip
adapt to latest GNUnet API: GNUNET_JSON_spec_mark_optional() changed
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c3
-rw-r--r--src/backenddb/test_merchantdb.c134
2 files changed, 84 insertions, 53 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index d45e2fbb..8a86c2a0 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -2151,7 +2151,8 @@ postgres_update_contract_terms (void *cls,
&refund_deadline),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("fulfillment_url",
- &fulfillment_url)),
+ &fulfillment_url),
+ NULL),
GNUNET_JSON_spec_end ()
};
enum GNUNET_GenericReturnValue res;
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 57b38899..f7c2dde7 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -2330,14 +2330,7 @@ struct ExchangeSignkeyData
static void
make_exchange_signkey (struct ExchangeSignkeyData *signkey)
{
- struct TALER_ExchangeSigningKeyValidityPS exch_sign = {
- .purpose = {
- .size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)),
- .purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY)
- }
-
-
- };
+ struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
GNUNET_CRYPTO_eddsa_key_create (&signkey->exchange_priv.eddsa_priv);
GNUNET_CRYPTO_eddsa_key_get_public (&signkey->exchange_priv.eddsa_priv,
@@ -2345,12 +2338,16 @@ make_exchange_signkey (struct ExchangeSignkeyData *signkey)
GNUNET_CRYPTO_eddsa_key_create (&signkey->master_priv.eddsa_priv);
GNUNET_CRYPTO_eddsa_key_get_public (&signkey->master_priv.eddsa_priv,
&signkey->master_pub.eddsa_pub);
- GNUNET_CRYPTO_eddsa_sign (&signkey->master_priv.eddsa_priv,
- &exch_sign,
- &signkey->master_sig.eddsa_signature);
- signkey->start_date = GNUNET_TIME_timestamp_get ();
- signkey->expire_date = GNUNET_TIME_timestamp_get ();
- signkey->end_date = GNUNET_TIME_timestamp_get ();
+ signkey->start_date = now;
+ signkey->expire_date = now;
+ signkey->end_date = now;
+ TALER_exchange_offline_signkey_validity_sign (
+ &signkey->exchange_pub,
+ signkey->start_date,
+ signkey->expire_date,
+ signkey->end_date,
+ &signkey->master_priv,
+ &signkey->master_sig);
}
@@ -2413,6 +2410,39 @@ struct DepositData
/**
+ * Private key for my_sign_cb().
+ */
+static const struct TALER_ExchangePrivateKeyP *msc_exchange_priv;
+
+/**
+ * Function that signs the message in @a purpose with the
+ * exchange's signing key from #msc_exchange_priv.
+ *
+ * The @a purpose data is the beginning of the data of which the signature is
+ * to be created. The `size` field in @a purpose must correctly indicate the
+ * number of bytes of the data structure, including its header. *
+ * @param purpose the message to sign
+ * @param[out] pub set to the current public signing key of the exchange
+ * @param[out] sig signature over purpose using current signing key
+ * @return #TALER_EC_NONE on success
+ */
+static enum TALER_ErrorCode
+my_sign_cb (
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
+ struct TALER_ExchangePublicKeyP *pub,
+ struct TALER_ExchangeSignatureP *sig)
+{
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_sign_ (&msc_exchange_priv->eddsa_priv,
+ purpose,
+ &sig->eddsa_signature));
+ GNUNET_CRYPTO_eddsa_key_get_public (&msc_exchange_priv->eddsa_priv,
+ &pub->eddsa_pub);
+ return TALER_EC_NONE;
+}
+
+
+/**
* Generates deposit data for an order.
*
* @param instance the instance to make the deposit to.
@@ -2429,13 +2459,12 @@ make_deposit (const struct InstanceData *instance,
struct DepositData *deposit)
{
struct TALER_CoinSpendPrivateKeyP coin_priv;
- struct TALER_DepositConfirmationPS deposit_sign = {
- .purpose.size = htonl (sizeof (deposit_sign)),
- .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT)
- };
+ struct GNUNET_TIME_Timestamp now;
struct TALER_Amount amount_without_fee;
+ struct TALER_ExchangePublicKeyP exchange_pub;
- deposit->timestamp = GNUNET_TIME_timestamp_get ();
+ now = GNUNET_TIME_timestamp_get ();
+ deposit->timestamp = now;
GNUNET_assert (GNUNET_OK ==
TALER_JSON_contract_hash (order->contract,
&deposit->h_contract_terms));
@@ -2460,21 +2489,22 @@ make_deposit (const struct InstanceData *instance,
&deposit->amount_with_fee,
&deposit->deposit_fee));
deposit->h_wire = account->h_wire;
- deposit_sign.h_contract_terms = deposit->h_contract_terms;
- deposit_sign.h_wire = deposit->h_wire;
- deposit_sign.exchange_timestamp = GNUNET_TIME_timestamp_hton (
- GNUNET_TIME_timestamp_get ());
- deposit_sign.wire_deadline = GNUNET_TIME_timestamp_hton (
- GNUNET_TIME_timestamp_get ());
- deposit_sign.refund_deadline = GNUNET_TIME_timestamp_hton (
- GNUNET_TIME_timestamp_get ());
- TALER_amount_hton (&deposit_sign.amount_without_fee,
- &amount_without_fee);
- deposit_sign.merchant_pub = instance->merchant_pub;
- deposit_sign.coin_pub = deposit->coin_pub;
- GNUNET_CRYPTO_eddsa_sign (&signkey->exchange_priv.eddsa_priv,
- &deposit_sign,
- &deposit->exchange_sig.eddsa_signature);
+ msc_exchange_priv = &signkey->exchange_priv;
+ GNUNET_assert (TALER_EC_NONE ==
+ TALER_exchange_online_deposit_confirmation_sign (
+ &my_sign_cb,
+ &deposit->h_contract_terms,
+ &deposit->h_wire,
+ NULL,
+ now,
+ now,
+ now,
+ &amount_without_fee,
+ &deposit->coin_pub,
+ &instance->merchant_pub,
+ &exchange_pub,
+ &deposit->exchange_sig));
+ msc_exchange_priv = NULL;
}
@@ -3267,12 +3297,12 @@ make_wire_fee (const struct ExchangeSignkeyData *signkey,
wire_fee->wire_fee_end = GNUNET_TIME_relative_to_timestamp (
GNUNET_TIME_UNIT_MONTHS);
TALER_exchange_offline_wire_fee_sign (
- wire_fee->wire_method,
- wire_fee->wire_fee_start,
- wire_fee->wire_fee_end,
- &wire_fee->fees,
- &signkey->master_priv,
- &wire_fee->fee_sig);
+ wire_fee->wire_method,
+ wire_fee->wire_fee_start,
+ wire_fee->wire_fee_end,
+ &wire_fee->fees,
+ &signkey->master_priv,
+ &wire_fee->fee_sig);
}
@@ -3807,13 +3837,13 @@ test_insert_wire_fee (const struct ExchangeSignkeyData *signkey,
{
TEST_COND_RET_ON_FAIL (expected_result ==
plugin->store_wire_fee_by_exchange (
- plugin->cls,
- &signkey->master_pub,
- &wire_fee->h_wire_method,
- &wire_fee->fees,
- wire_fee->wire_fee_start,
- wire_fee->wire_fee_end,
- &wire_fee->fee_sig),
+ plugin->cls,
+ &signkey->master_pub,
+ &wire_fee->h_wire_method,
+ &wire_fee->fees,
+ wire_fee->wire_fee_start,
+ wire_fee->wire_fee_end,
+ &wire_fee->fee_sig),
"Store wire fee by exchange failed\n");
return 0;
}
@@ -5904,11 +5934,11 @@ lookup_refunds_detailed_cb (void *cls,
*/
static int
test_lookup_refunds_detailed (
- const struct InstanceData *instance,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- bool cmp_timestamps,
- unsigned int refunds_length,
- const struct RefundData *refunds)
+ const struct InstanceData *instance,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ bool cmp_timestamps,
+ unsigned int refunds_length,
+ const struct RefundData *refunds)
{
unsigned int results_matching[refunds_length];
struct TestLookupRefundsDetailed_Closure cmp = {