summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exchange/taler-exchange-httpd_purses_create.c12
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_purse.c13
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c62
-rw-r--r--src/include/taler_exchangedb_plugin.h18
-rw-r--r--src/lib/exchange_api_purse_create_with_deposit.c5
5 files changed, 33 insertions, 77 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_create.c b/src/exchange/taler-exchange-httpd_purses_create.c
index 65cd5d455..434984d85 100644
--- a/src/exchange/taler-exchange-httpd_purses_create.c
+++ b/src/exchange/taler-exchange-httpd_purses_create.c
@@ -369,13 +369,9 @@ create_transaction (void *cls,
}
/* 3) if present, persist contract */
in_conflict = true;
- // FIXME: combine econtract arguments into one!
qs = TEH_plugin->insert_contract (TEH_plugin->cls,
pcc->purse_pub,
- &pcc->econtract.contract_pub,
- pcc->econtract.econtract_size,
- pcc->econtract.econtract,
- &pcc->econtract.econtract_sig,
+ &pcc->econtract,
&in_conflict);
if (qs < 0)
{
@@ -393,14 +389,10 @@ create_transaction (void *cls,
struct TALER_EncryptedContract econtract;
struct GNUNET_HashCode h_econtract;
- // FIXME: combine econtract arguments into one!
qs = TEH_plugin->select_contract_by_purse (
TEH_plugin->cls,
pcc->purse_pub,
- &econtract.contract_pub,
- &econtract.econtract_sig,
- &econtract.econtract_size,
- &econtract.econtract);
+ &econtract);
if (qs <= 0)
{
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
diff --git a/src/exchange/taler-exchange-httpd_reserves_purse.c b/src/exchange/taler-exchange-httpd_reserves_purse.c
index af86bc91e..74291976d 100644
--- a/src/exchange/taler-exchange-httpd_reserves_purse.c
+++ b/src/exchange/taler-exchange-httpd_reserves_purse.c
@@ -411,13 +411,9 @@ purse_transaction (void *cls,
{
bool in_conflict = true;
- // FIXME: combine econtract args!
qs = TEH_plugin->insert_contract (TEH_plugin->cls,
&rpc->purse_pub,
- &rpc->econtract.contract_pub,
- rpc->econtract.econtract_size,
- rpc->econtract.econtract,
- &rpc->econtract.econtract_sig,
+ &rpc->econtract,
&in_conflict);
if (qs < 0)
{
@@ -435,15 +431,10 @@ purse_transaction (void *cls,
struct TALER_EncryptedContract econtract;
struct GNUNET_HashCode h_econtract;
- /* FIXME: change API to only pass econtract
- instead of all members! */
qs = TEH_plugin->select_contract_by_purse (
TEH_plugin->cls,
&rpc->purse_pub,
- &econtract.contract_pub,
- &econtract.econtract_sig,
- &econtract.econtract_size,
- &econtract.econtract);
+ &econtract);
if (qs <= 0)
{
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 9fcd6203a..b259e3519 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -13959,21 +13959,14 @@ postgres_select_contract (void *cls,
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param purse_pub key to lookup the contract by
- * @param[out] pub_ckey set to the ephemeral DH used to encrypt the contract
- * @param[out] econtract_sig set to the signature over the encrypted contract
- * @param[out] econtract_size set to the number of bytes in @a econtract
* @param[out] econtract set to the encrypted contract on success, to be freed by the caller
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
-postgres_select_contract_by_purse (void *cls,
- const struct
- TALER_PurseContractPublicKeyP *purse_pub,
- struct TALER_ContractDiffiePublicP *pub_ckey,
- struct TALER_PurseContractSignatureP *
- econtract_sig,
- size_t *econtract_size,
- void **econtract)
+postgres_select_contract_by_purse (
+ void *cls,
+ const struct TALER_PurseContractPublicKeyP *purse_pub,
+ struct TALER_EncryptedContract *econtract)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -13982,12 +13975,12 @@ postgres_select_contract_by_purse (void *cls,
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("pub_ckey",
- pub_ckey),
+ &econtract->contract_pub),
GNUNET_PQ_result_spec_auto_from_type ("contract_sig",
- econtract_sig),
+ &econtract->econtract_sig),
GNUNET_PQ_result_spec_variable_size ("e_contract",
- econtract,
- econtract_size),
+ &econtract->econtract,
+ &econtract->econtract_size),
GNUNET_PQ_result_spec_end
};
@@ -14004,10 +13997,7 @@ postgres_select_contract_by_purse (void *cls,
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param purse_pub the purse the contract is associated with (must exist)
- * @param pub_ckey ephemeral key for DH used to encrypt the contract
- * @param econtract_size number of bytes in @a econtract
* @param econtract the encrypted contract
- * @param[out] econtract_sig set to the signature over the encrypted contract
* @param[out] in_conflict set to true if @a econtract
* conflicts with an existing contract;
* in this case, the return value will be
@@ -14018,20 +14008,17 @@ static enum GNUNET_DB_QueryStatus
postgres_insert_contract (
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_ContractDiffiePublicP *pub_ckey,
- size_t econtract_size,
- const void *econtract,
- const struct TALER_PurseContractSignatureP *econtract_sig,
+ const struct TALER_EncryptedContract *econtract,
bool *in_conflict)
{
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (purse_pub),
- GNUNET_PQ_query_param_auto_from_type (pub_ckey),
- GNUNET_PQ_query_param_fixed_size (econtract,
- econtract_size),
- GNUNET_PQ_query_param_auto_from_type (econtract_sig),
+ GNUNET_PQ_query_param_auto_from_type (&econtract->contract_pub),
+ GNUNET_PQ_query_param_fixed_size (econtract->econtract,
+ econtract->econtract_size),
+ GNUNET_PQ_query_param_auto_from_type (&econtract->econtract_sig),
GNUNET_PQ_query_param_end
};
@@ -14042,31 +14029,28 @@ postgres_insert_contract (
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs)
return qs;
{
- struct TALER_ContractDiffiePublicP pub_ckey2;
- struct TALER_PurseContractSignatureP esig2;
- size_t econtract_size2;
- void *econtract2;
+ struct TALER_EncryptedContract econtract2;
qs = postgres_select_contract_by_purse (pg,
purse_pub,
- &pub_ckey2,
- &esig2,
- &econtract_size2,
&econtract2);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{
GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
}
- if ( (0 == GNUNET_memcmp (&pub_ckey2,
- pub_ckey)) &&
- (econtract_size2 == econtract_size) &&
- (0 == memcmp (econtract2,
- econtract,
- econtract_size)) )
+ if ( (0 == GNUNET_memcmp (&econtract->contract_pub,
+ &econtract2.contract_pub)) &&
+ (econtract2.econtract_size ==
+ econtract->econtract_size) &&
+ (0 == memcmp (econtract2.econtract,
+ econtract->econtract,
+ econtract->econtract_size)) )
{
+ GNUNET_free (econtract2.econtract);
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
+ GNUNET_free (econtract2.econtract);
*in_conflict = true;
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
}
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index 394177751..15f5661d0 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -24,6 +24,7 @@
#include <jansson.h>
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_db_lib.h>
+#include "taler_json_lib.h"
#include "taler_signatures.h"
@@ -4779,9 +4780,6 @@ struct TALER_EXCHANGEDB_Plugin
* Function called to persist an encrypted contract associated with a reserve.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param purse_pub the purse the contract is associated with (must exist)
- * @param pub_ckey ephemeral key for DH used to encrypt the contract
- * @param econtract_size number of bytes in @a econtract
* @param econtract the encrypted contract
* @param[out] econtract_sig set to the signature over the encrypted contract
* @param[out] in_conflict set to true if @a econtract
@@ -4793,10 +4791,7 @@ struct TALER_EXCHANGEDB_Plugin
enum GNUNET_DB_QueryStatus
(*insert_contract)(void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- const struct TALER_ContractDiffiePublicP *pub_ckey,
- size_t econtract_size,
- const void *econtract,
- const struct TALER_PurseContractSignatureP *econtract_sig,
+ const struct TALER_EncryptedContract *econtract,
bool *in_conflict);
@@ -4820,14 +4815,12 @@ struct TALER_EXCHANGEDB_Plugin
size_t *econtract_size,
void **econtract);
+
/**
* Function called to retrieve an encrypted contract.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param purse_pub key to lookup the contract by
- * @param[out] pub_ckey set to the ephemeral DH used to encrypt the contract
- * @param[out] econtract_sig set to the signature over the encrypted contract
- * @param[out] econtract_size set to the number of bytes in @a econtract
* @param[out] econtract set to the encrypted contract on success, to be freed by the caller
* @return transaction status code
*/
@@ -4835,10 +4828,7 @@ struct TALER_EXCHANGEDB_Plugin
(*select_contract_by_purse)(
void *cls,
const struct TALER_PurseContractPublicKeyP *purse_pub,
- struct TALER_ContractDiffiePublicP *pub_ckey,
- struct TALER_PurseContractSignatureP *econtract_sig,
- size_t *econtract_size,
- void **econtract);
+ struct TALER_EncryptedContract *econtract);
/**
diff --git a/src/lib/exchange_api_purse_create_with_deposit.c b/src/lib/exchange_api_purse_create_with_deposit.c
index e77bbf2da..cace73249 100644
--- a/src/lib/exchange_api_purse_create_with_deposit.c
+++ b/src/lib/exchange_api_purse_create_with_deposit.c
@@ -254,7 +254,6 @@ TALER_EXCHANGE_purse_create_with_deposit (
CURL *eh;
struct TALER_PurseContractSignatureP purse_sig;
struct TALER_EncryptedContract econtract;
- struct TALER_ContractDiffiePublicP contract_pub;
char arg_str[sizeof (pch->purse_pub) * 2 + 32];
char *url;
uint32_t min_age = 0;
@@ -402,10 +401,10 @@ TALER_EXCHANGE_purse_create_with_deposit (
&econtract.econtract,
&econtract.econtract_size);
GNUNET_CRYPTO_ecdhe_key_get_public (&contract_priv->ecdhe_priv,
- &contract_pub.ecdhe_pub);
+ &econtract.contract_pub.ecdhe_pub);
TALER_wallet_econtract_upload_sign (econtract.econtract,
econtract.econtract_size,
- &contract_pub,
+ &econtract.contract_pub,
purse_priv,
&econtract.econtract_sig);
}