From b5cba3251053c22bf1df46282f1dd0a4c46f6a38 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 1 Mar 2016 15:35:04 +0100 Subject: renaming mint->exchange --- src/exchangedb/perf_taler_exchangedb_init.c | 622 ++++++++++++++++++++++++++++ 1 file changed, 622 insertions(+) create mode 100644 src/exchangedb/perf_taler_exchangedb_init.c (limited to 'src/exchangedb/perf_taler_exchangedb_init.c') diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c new file mode 100644 index 00000000..2e613b3c --- /dev/null +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -0,0 +1,622 @@ +/* + This file is part of TALER + Copyright (C) 2014, 2015 GNUnet e.V. + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, If not, see + */ +/** + * @file exchangedb/perf_taler_exchangedb_init.c + * @brief Interpreter library for exchange database performance analysis + * @author Nicolas Fournier + */ +#include "platform.h" +#include "perf_taler_exchangedb_init.h" +#include +#include "taler_signatures.h" +#include "taler_amount_lib.h" + + +#define CURRENCY "EUR" +#define PERF_TALER_EXCHANGEDB_RSA_SIZE 512 + + +/** + * Generate a dummy DenominationKeyInformation for testing purposes + * @return a dummy denomination key + */ +struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * +PERF_TALER_EXCHANGEDB_denomination_init () +{ + struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt; + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; + struct TALER_DenominationPrivateKey denom_priv; + struct TALER_DenominationPublicKey denom_pub; + struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; + + master_prvt = GNUNET_CRYPTO_eddsa_key_create(); + + dki = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation); + GNUNET_assert (NULL != dki); + denom_priv.rsa_private_key + = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_EXCHANGEDB_RSA_SIZE); + GNUNET_assert (NULL != denom_priv.rsa_private_key); + denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_private_key_get_public (denom_priv.rsa_private_key); + GNUNET_assert (NULL != denom_pub.rsa_public_key); + {/* issue */ + struct TALER_MasterSignatureP signature; + struct TALER_DenominationKeyValidityPS properties; + + {/* properties */ + struct TALER_Amount amount; + + properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); + properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); + GNUNET_CRYPTO_eddsa_key_get_public (master_prvt, + &properties.master.eddsa_pub); + properties.start = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get()); + properties.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever_()); + properties.expire_spend = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever_()); + properties.expire_legal = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever_()); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1.1", &amount)); + TALER_amount_hton (&properties.value, &amount); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":0.1", &amount)); + TALER_amount_hton (&properties.fee_withdraw, &amount); + TALER_amount_hton (&properties.fee_deposit, &amount); + TALER_amount_hton (&properties.fee_refresh, &amount); + GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key, + &properties.denom_hash); + issue.properties = properties; + } + {/* signature */ + GNUNET_CRYPTO_eddsa_sign (master_prvt, + &properties.purpose, + &signature.eddsa_signature); + issue.signature = signature; + } + } + dki->denom_priv = denom_priv; + dki->denom_pub = denom_pub; + dki->issue = issue; + GNUNET_free (master_prvt); + return dki; +} + + +/** + * Copies the given denomination + * @param reserve the deposit copy + * @return a copy of @a deposit; NULL if error + */ +struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * +PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) +{ + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *copy; + + GNUNET_assert (NULL != + (copy = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation))); + {/* denom_priv */ + copy->denom_priv.rsa_private_key = + GNUNET_CRYPTO_rsa_private_key_dup ( dki->denom_priv.rsa_private_key); + } + {/* denom_pub */ + copy->denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key); + } + {/* issue */ + copy->issue.properties = dki->issue.properties; + copy->issue.signature = dki->issue.signature; + } + return copy; +} + + +/** + * Free memory of a DenominationKeyIssueInformation + * @param dki pointer to the struct to free + */ +int +PERF_TALER_EXCHANGEDB_denomination_free (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) +{ + if (NULL == dki) + return GNUNET_OK; + GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key); + + GNUNET_free (dki); + return GNUNET_OK; +} + + +/** + * Generate a dummy reserve for testing + * @return a reserve with 1000 EUR in it + */ +struct PERF_TALER_EXCHANGEDB_Reserve * +PERF_TALER_EXCHANGEDB_reserve_init () +{ + struct PERF_TALER_EXCHANGEDB_Reserve *reserve; + + GNUNET_assert (NULL != + (reserve = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve))); + {/* private */ + struct GNUNET_CRYPTO_EddsaPrivateKey *private; + private = GNUNET_CRYPTO_eddsa_key_create (); + GNUNET_assert (NULL != private); + reserve->private = *private; + GNUNET_free (private); + } + + GNUNET_CRYPTO_eddsa_key_get_public (&reserve->private, + &reserve->reserve.pub.eddsa_pub); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1000", &reserve->reserve.balance)); + reserve->reserve.expiry = GNUNET_TIME_absolute_get_forever_ (); + return reserve; +} + + +/** + * Copies the given reserve + * @param reserve the reserve to copy + * @return a copy of @a reserve; NULL if error + */ +struct PERF_TALER_EXCHANGEDB_Reserve * +PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve *reserve) +{ + struct PERF_TALER_EXCHANGEDB_Reserve *copy; + GNUNET_assert (NULL != + (copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve))); + *copy = *reserve; + return copy; +} + + +/** + * Free memory of a reserve + * @param reserve pointer to the structure to be freed + */ +int +PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserve) +{ + if (NULL == reserve) + return GNUNET_OK; + GNUNET_free (reserve); + return GNUNET_OK; +} + + +/** + * Generate a dummy deposit for testing purposes + * @param dki the denomination key used to sign the key + */ +struct TALER_EXCHANGEDB_Deposit * +PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coin) +{ + struct TALER_EXCHANGEDB_Deposit *deposit; + struct TALER_CoinSpendSignatureP csig; + struct TALER_MerchantPublicKeyP merchant_pub; + struct GNUNET_HashCode h_contract; + struct GNUNET_HashCode h_wire; + const char wire[] = "{" + "\"type\":\"SEPA\"," + "\"IBAN\":\"DE67830654080004822650\"," + "\"NAME\":\"GNUNET E.\"," + "\"BIC\":\"GENODEF1SRL\"" + "}"; + static uint64_t transaction_id = 0; + struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Absolute refund_deadline; + struct TALER_Amount amount_with_fee; + struct TALER_Amount deposit_fee; + + GNUNET_assert (NULL != + (deposit = GNUNET_malloc (sizeof (struct TALER_EXCHANGEDB_Deposit) + sizeof (wire)))); + GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, + &h_contract); + GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, + &h_wire); + { //csig + struct u32_presign + { + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + struct GNUNET_HashCode h_wire; + struct GNUNET_HashCode h_contract; + } unsigned_data; + + unsigned_data.h_contract = h_contract; + unsigned_data.h_wire = h_wire; + unsigned_data.purpose.size = htonl (sizeof (struct u32_presign)); + unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST); + GNUNET_assert (GNUNET_OK == + GNUNET_CRYPTO_eddsa_sign (&coin->priv, + &unsigned_data.purpose, + &csig.eddsa_signature)); + } + { //merchant_pub + struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv; + + eddsa_prv = GNUNET_CRYPTO_eddsa_key_create (); + GNUNET_assert(NULL != eddsa_prv); + GNUNET_CRYPTO_eddsa_key_get_public ( + eddsa_prv, + &merchant_pub.eddsa_pub); + GNUNET_free (eddsa_prv); + } + timestamp = GNUNET_TIME_absolute_get (); + refund_deadline = GNUNET_TIME_absolute_get (); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1.1", + &amount_with_fee)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":0.1", + &deposit_fee)); + { + deposit->coin.coin_pub = coin->public_info.coin_pub; + deposit->coin.denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup ( + coin->public_info.denom_pub.rsa_public_key); + GNUNET_assert (NULL != coin->public_info.denom_pub.rsa_public_key); + deposit->coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup ( + coin->public_info.denom_sig.rsa_signature); + GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature); + } + deposit->csig = csig; + deposit->h_contract = h_contract; + deposit->h_wire = h_wire; + deposit->wire = json_loads (wire, 0, NULL); + deposit->transaction_id = transaction_id++; + deposit->timestamp = timestamp; + deposit->refund_deadline = refund_deadline; + deposit->amount_with_fee = amount_with_fee; + deposit->deposit_fee = deposit_fee; + return deposit; +} + + +/** + * Copies the given deposit + * @param reserve the deposit copy + * @return a copy of @a deposit; NULL if error + */ +struct TALER_EXCHANGEDB_Deposit * +PERF_TALER_EXCHANGEDB_deposit_copy (const struct TALER_EXCHANGEDB_Deposit *deposit) +{ + struct TALER_EXCHANGEDB_Deposit *copy; + + copy = GNUNET_new (struct TALER_EXCHANGEDB_Deposit); + *copy = *deposit; + json_incref (copy->wire); + copy->coin.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (deposit->coin.denom_pub.rsa_public_key); + copy->coin.denom_sig.rsa_signature = + GNUNET_CRYPTO_rsa_signature_dup (deposit->coin.denom_sig.rsa_signature); + return copy; +} + + +/** + * Free memory of a deposit + * @param deposit pointer to the structure to free + */ +int +PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit) +{ + if (NULL == deposit) + return GNUNET_OK; + GNUNET_CRYPTO_rsa_public_key_free (deposit->coin.denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature); + json_decref (deposit->wire); + GNUNET_free (deposit); + return GNUNET_OK; +} + + +/** + * Generate a CollectableBlindcoin for testing purpuses + * @param dki denomination key used to sign the coin + * @param reserve reserve providing the money for the coin + * @return a randomly generated CollectableBlindcoin + */ +struct PERF_TALER_EXCHANGEDB_Coin * +PERF_TALER_EXCHANGEDB_coin_init ( + const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki, + const struct PERF_TALER_EXCHANGEDB_Reserve *reserve) +{ + struct PERF_TALER_EXCHANGEDB_Coin *coin; + struct GNUNET_CRYPTO_EddsaPrivateKey *priv; + + coin = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin); + GNUNET_assert (NULL != coin); + /* priv */ + + priv = GNUNET_CRYPTO_eddsa_key_create(); + GNUNET_assert (NULL != priv); + coin->priv = *priv; + GNUNET_free (priv); + + /* public_info */ + GNUNET_CRYPTO_eddsa_key_get_public (&coin->priv, + &coin->public_info.coin_pub.eddsa_pub); + coin->public_info.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key); + coin->public_info.denom_sig.rsa_signature = + GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, + &coin->public_info.coin_pub, + sizeof (struct TALER_CoinSpendPublicKeyP)); + GNUNET_assert (NULL != coin->public_info.denom_pub.rsa_public_key); + GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature); + + /* blind */ + coin->blind.sig.rsa_signature = + GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature); + coin->blind.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key); + GNUNET_assert (NULL != coin->blind.sig.rsa_signature); + GNUNET_assert (NULL != coin->blind.denom_pub.rsa_public_key); + TALER_amount_ntoh (&coin->blind.amount_with_fee, + &dki->issue.properties.value); + TALER_amount_ntoh (&coin->blind.withdraw_fee, + &dki->issue.properties.fee_withdraw); + coin->blind.reserve_pub = reserve->reserve.pub; + GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, + &coin->blind.h_coin_envelope); + + return coin; +} + + +/** + * Copies the given coin + * + * @param coin the coin to copy + * @return a copy of coin; NULL if error + */ +struct PERF_TALER_EXCHANGEDB_Coin * +PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin) +{ + struct PERF_TALER_EXCHANGEDB_Coin *copy; + + copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin); + /* priv */ + copy->priv = coin->priv; + /* public_info */ + copy->public_info.coin_pub = coin->public_info.coin_pub; + copy->public_info.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (coin->public_info.denom_pub.rsa_public_key); + copy->public_info.denom_sig.rsa_signature = + GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature); + + /* blind */ + copy->blind.sig.rsa_signature = + GNUNET_CRYPTO_rsa_signature_dup (coin->blind.sig.rsa_signature); + copy->blind.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (coin->blind.denom_pub.rsa_public_key); + copy->blind.amount_with_fee = coin->blind.amount_with_fee; + copy->blind.withdraw_fee = coin->blind.withdraw_fee; + copy->blind.reserve_pub = coin->blind.reserve_pub; + copy->blind.h_coin_envelope = coin->blind.h_coin_envelope; + copy->blind.reserve_sig = coin->blind.reserve_sig; + + return copy; +} + + +/** + * Free memory of @a coin + * + * @param coin pointer to the structure to free + */ +int +PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin) +{ + if (NULL == coin) + return GNUNET_OK; + GNUNET_CRYPTO_rsa_public_key_free (coin->public_info.denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_signature_free (coin->public_info.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free (coin->blind.sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (coin->blind.denom_pub.rsa_public_key); + GNUNET_free (coin); + return GNUNET_OK; +} + + +/** + * @return a randomly generated refresh session + */ +struct TALER_EXCHANGEDB_RefreshSession * +PERF_TALER_EXCHANGEDB_refresh_session_init () +{ + struct TALER_EXCHANGEDB_RefreshSession *refresh_session; + + GNUNET_assert (NULL != + (refresh_session = GNUNET_new (struct TALER_EXCHANGEDB_RefreshSession))); + refresh_session->noreveal_index = 1; + refresh_session->num_oldcoins = 1; + refresh_session->num_newcoins = 1; + + return refresh_session; +} + + +/** + * @return #GNUNET_OK if the copy was successful, #GNUNET_SYSERR if it wasn't + */ +int +PERF_TALER_EXCHANGEDB_refresh_session_copy (struct TALER_EXCHANGEDB_RefreshSession *session, + struct TALER_EXCHANGEDB_RefreshSession *copy) +{ + *copy = *session; + return GNUNET_OK; +} + + +/** + * Free a refresh session + */ +int +PERF_TALER_EXCHANGEDB_refresh_session_free (struct TALER_EXCHANGEDB_RefreshSession *refresh_session) +{ + if (NULL == refresh_session) + return GNUNET_OK; + GNUNET_free (refresh_session); + return GNUNET_OK; +} + + +/** + * Create a melt operation + * + * @param session the refresh session + * @param dki the denomination the melted coin uses + * @return a pointer to a #TALER_EXCHANGEDB_RefreshMelt + */ +struct TALER_EXCHANGEDB_RefreshMelt * +PERF_TALER_EXCHANGEDB_refresh_melt_init (struct GNUNET_HashCode *session, + struct PERF_TALER_EXCHANGEDB_Coin *coin) +{ + struct TALER_EXCHANGEDB_RefreshMelt *melt; + struct TALER_CoinSpendSignatureP coin_sig; + struct TALER_Amount amount; + struct TALER_Amount amount_with_fee; + + { + struct + { + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + struct GNUNET_HashCode session; + } to_sign; + + to_sign.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST; + to_sign.purpose.size = htonl (sizeof (to_sign)); + to_sign.session = *session; + GNUNET_CRYPTO_eddsa_sign (&coin->priv, + &to_sign.purpose, + &coin_sig.eddsa_signature); + } + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1.1", + &amount)); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":0.1", + &amount_with_fee)); + melt = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt); + melt->coin.coin_pub = coin->public_info.coin_pub; + melt->coin.denom_sig.rsa_signature = + GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature); + melt->coin.denom_pub.rsa_public_key = + GNUNET_CRYPTO_rsa_public_key_dup (coin->public_info.denom_pub.rsa_public_key); + GNUNET_assert (NULL != melt->coin.denom_pub.rsa_public_key); + GNUNET_assert (NULL != melt->coin.denom_sig.rsa_signature); + melt->coin_sig = coin_sig; + melt->session_hash = *session; + melt->amount_with_fee = amount; + melt->melt_fee = amount_with_fee; + return melt; +} + + +/** + * Copies the internals of a #TALER_EXCHANGEDB_RefreshMelt + * + * @param melt the refresh melt to copy + * @return an copy of @ melt + */ +struct TALER_EXCHANGEDB_RefreshMelt * +PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMelt *melt) +{ + struct TALER_EXCHANGEDB_RefreshMelt *copy; + + copy = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt); + *copy = *melt; + copy->coin.denom_sig.rsa_signature = + GNUNET_CRYPTO_rsa_signature_dup (melt->coin.denom_sig.rsa_signature); + GNUNET_assert (NULL != copy->coin.denom_sig.rsa_signature); + + return copy; +} + + +/** + * Free the internal memory of a #TALER_EXCHANGEDB_RefreshMelt + * + * @param melt the #TALER_EXCHANGEDB_RefreshMelt to free + * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR + */ +int +PERF_TALER_EXCHANGEDB_refresh_melt_free (struct TALER_EXCHANGEDB_RefreshMelt *melt) +{ + GNUNET_CRYPTO_rsa_signature_free (melt->coin.denom_sig.rsa_signature); + GNUNET_free (melt); + return GNUNET_OK; +} + + +/** + * Create a #TALER_EXCHANGEDB_RefreshCommitCoin + */ +struct TALER_EXCHANGEDB_RefreshCommitCoin * +PERF_TALER_EXCHANGEDB_refresh_commit_coin_init () +{ + struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coin; + struct TALER_RefreshLinkEncrypted refresh_link; + + commit_coin = GNUNET_new (struct TALER_EXCHANGEDB_RefreshCommitCoin); + GNUNET_assert (NULL != commit_coin); + {/* refresh_link */ + refresh_link = (struct TALER_RefreshLinkEncrypted) + { + .blinding_key_enc = "blinding_key", + .blinding_key_enc_size = 13 + }; + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &refresh_link.coin_priv_enc, + sizeof(struct TALER_CoinSpendPrivateKeyP)); + } + commit_coin->coin_ev = "coin_ev"; + commit_coin->coin_ev_size = 8; + commit_coin->refresh_link = GNUNET_new (struct TALER_RefreshLinkEncrypted); + *commit_coin->refresh_link = refresh_link; + return commit_coin; +} + + +/** + * Copies a #TALER_EXCHANGEDB_RefreshCommitCoin + * + * @param commit_coin the commit to copy + * @return a copy of @a commit_coin + */ +struct TALER_EXCHANGEDB_RefreshCommitCoin * +PERF_TALER_EXCHANGEDB_refresh_commit_coin_copy (struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coin) +{ + struct TALER_EXCHANGEDB_RefreshCommitCoin *copy; + + copy = GNUNET_new (struct TALER_EXCHANGEDB_RefreshCommitCoin); + copy->refresh_link = GNUNET_new (struct TALER_RefreshLinkEncrypted); + *copy->refresh_link = *commit_coin->refresh_link; + return copy; +} + + +/** + * Free a #TALER_EXCHANGEDB_RefreshCommitCoin + * + * @param commit_coin the coin to free + */ +void +PERF_TALER_EXCHANGEDB_refresh_commit_coin_free (struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coin) +{ + GNUNET_free (commit_coin->refresh_link); + GNUNET_free (commit_coin); +} -- cgit v1.2.3 From 553d6eb23e3ac1001dd6c4e0523cddb88bc5e723 Mon Sep 17 00:00:00 2001 From: Jeff Burdges Date: Sun, 20 Mar 2016 21:30:10 +0100 Subject: API change in GNUnet crypto for Full Domain Hashing --- src/exchange/taler-exchange-httpd_db.c | 12 ++++++------ src/exchange/taler-exchange-httpd_test.c | 6 +++--- src/exchangedb/perf_taler_exchangedb_init.c | 6 +++--- src/exchangedb/test_exchangedb.c | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/exchangedb/perf_taler_exchangedb_init.c') diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index e96653a6..7698b92b 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -453,9 +453,9 @@ execute_reserve_withdraw_transaction (struct MHD_Connection *connection, /* Balance is good, sign the coin! */ denom_sig->rsa_signature - = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, - blinded_msg, - blinded_msg_len); + = GNUNET_CRYPTO_rsa_sign_blinded (dki->denom_priv.rsa_private_key, + blinded_msg, + blinded_msg_len); if (NULL == denom_sig->rsa_signature) { GNUNET_break (0); @@ -1112,9 +1112,9 @@ refresh_exchange_coin (struct MHD_Connection *connection, return ev_sig; } ev_sig.rsa_signature - = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, - commit_coin->coin_ev, - commit_coin->coin_ev_size); + = GNUNET_CRYPTO_rsa_sign_blinded (dki->denom_priv.rsa_private_key, + commit_coin->coin_ev, + commit_coin->coin_ev_size); if (NULL == ev_sig.rsa_signature) { GNUNET_break (0); diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 0a4181ed..6f33fd4f 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -495,9 +495,9 @@ TMH_TEST_handler_test_rsa_sign (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_internal_error (connection, "Failed to create RSA key"); } - sig = GNUNET_CRYPTO_rsa_sign (rsa_pk, - in_ptr, - in_ptr_size); + sig = GNUNET_CRYPTO_rsa_sign_blinded (rsa_pk, + in_ptr, + in_ptr_size); if (NULL == sig) { GNUNET_break (0); diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index 2e613b3c..2c2989bd 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -351,9 +351,9 @@ PERF_TALER_EXCHANGEDB_coin_init ( coin->public_info.denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key); coin->public_info.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, - &coin->public_info.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP)); + GNUNET_CRYPTO_rsa_sign_fdh (dki->denom_priv.rsa_private_key, + &coin->public_info.coin_pub, + sizeof (struct TALER_CoinSpendPublicKeyP)); GNUNET_assert (NULL != coin->public_info.denom_pub.rsa_public_key); GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature); diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index df1adf56..d03bad53 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -337,9 +337,9 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) { RND_BLK (&melts[cnt].coin.coin_pub); melts[cnt].coin.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_sign (dkp->priv.rsa_private_key, - &melts[cnt].coin.coin_pub, - sizeof (melts[cnt].coin.coin_pub)); + GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, + &melts[cnt].coin.coin_pub, + sizeof (melts[cnt].coin.coin_pub)); melts[cnt].coin.denom_pub = dkp->pub; RND_BLK (&melts[cnt].coin_sig); melts[cnt].session_hash = session_hash; @@ -663,9 +663,9 @@ run (void *cls, RND_BLK(&cbc.reserve_sig); cbc.denom_pub = dkp->pub; cbc.sig.rsa_signature - = GNUNET_CRYPTO_rsa_sign (dkp->priv.rsa_private_key, - &cbc.h_coin_envelope, - sizeof (cbc.h_coin_envelope)); + = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, + &cbc.h_coin_envelope, + sizeof (cbc.h_coin_envelope)); cbc.reserve_pub = reserve_pub; cbc.amount_with_fee = value; GNUNET_assert (GNUNET_OK == -- cgit v1.2.3 From 130957f69d5dd37f9f58d9b3ec52c7b635901b70 Mon Sep 17 00:00:00 2001 From: Jeff Burdges Date: Mon, 21 Mar 2016 15:19:04 +0100 Subject: Note two errors in the tests suit --- src/exchangedb/perf_taler_exchangedb_init.c | 1 + src/exchangedb/test_exchangedb.c | 1 + 2 files changed, 2 insertions(+) (limited to 'src/exchangedb/perf_taler_exchangedb_init.c') diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index 2c2989bd..8036d859 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -350,6 +350,7 @@ PERF_TALER_EXCHANGEDB_coin_init ( &coin->public_info.coin_pub.eddsa_pub); coin->public_info.denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key); + // This is broken at the moment because it needs to be a hash of a coin public key. coin->public_info.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dki->denom_priv.rsa_private_key, &coin->public_info.coin_pub, diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index d03bad53..2ab91c72 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -336,6 +336,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) for (cnt=0; cnt < MELT_OLD_COINS; cnt++) { RND_BLK (&melts[cnt].coin.coin_pub); + // This appears to be broken because it needs to be a hash of a coin public key melts[cnt].coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, &melts[cnt].coin.coin_pub, -- cgit v1.2.3 From 4154e41a411df9d30ab0213a7409642c924e78b0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 Apr 2016 20:18:18 +0200 Subject: hash inputs to sign_fdh functions as required by new API --- src/exchangedb/perf_taler_exchangedb_init.c | 8 +++++--- src/exchangedb/test_exchangedb.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/exchangedb/perf_taler_exchangedb_init.c') diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index 8036d859..c669518a 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -335,6 +335,7 @@ PERF_TALER_EXCHANGEDB_coin_init ( { struct PERF_TALER_EXCHANGEDB_Coin *coin; struct GNUNET_CRYPTO_EddsaPrivateKey *priv; + struct GNUNET_HashCode hc; coin = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin); GNUNET_assert (NULL != coin); @@ -350,11 +351,12 @@ PERF_TALER_EXCHANGEDB_coin_init ( &coin->public_info.coin_pub.eddsa_pub); coin->public_info.denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key); - // This is broken at the moment because it needs to be a hash of a coin public key. + GNUNET_CRYPTO_hash (&coin->public_info.coin_pub, + sizeof (struct TALER_CoinSpendPublicKeyP), + &hc); coin->public_info.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dki->denom_priv.rsa_private_key, - &coin->public_info.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP)); + &hc); GNUNET_assert (NULL != coin->public_info.denom_pub.rsa_public_key); GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature); diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 090c08fb..56c30067 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -335,12 +335,15 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) melts = GNUNET_new_array (MELT_OLD_COINS, struct TALER_EXCHANGEDB_RefreshMelt); for (cnt=0; cnt < MELT_OLD_COINS; cnt++) { + struct GNUNET_HashCode hc; + RND_BLK (&melts[cnt].coin.coin_pub); - // This appears to be broken because it needs to be a hash of a coin public key + GNUNET_CRYPTO_hash (&melts[cnt].coin.coin_pub, + sizeof (melts[cnt].coin.coin_pub), + &hc); melts[cnt].coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, - &melts[cnt].coin.coin_pub, - sizeof (melts[cnt].coin.coin_pub)); + &hc); melts[cnt].coin.denom_pub = dkp->pub; RND_BLK (&melts[cnt].coin_sig); melts[cnt].session_hash = session_hash; @@ -569,6 +572,7 @@ run (void *cls, struct TALER_EXCHANGEDB_Deposit deposit; struct TALER_EXCHANGEDB_Deposit deposit2; struct TALER_WireTransferIdentifierRawP wtid; + struct GNUNET_HashCode hc; json_t *wire; json_t *just; const char * const json_wire_str = @@ -663,10 +667,12 @@ run (void *cls, RND_BLK(&cbc.h_coin_envelope); RND_BLK(&cbc.reserve_sig); cbc.denom_pub = dkp->pub; + GNUNET_CRYPTO_hash (&cbc.h_coin_envelope, + sizeof (cbc.h_coin_envelope), + &hc); cbc.sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, - &cbc.h_coin_envelope, - sizeof (cbc.h_coin_envelope)); + &hc); cbc.reserve_pub = reserve_pub; cbc.amount_with_fee = value; GNUNET_assert (GNUNET_OK == @@ -890,6 +896,7 @@ main (int argc, "test-exchange-db-%s", plugin_name); (void) GNUNET_asprintf (&config_filename, "%s.conf", testname); + argv2[0] = argv[0]; argv2[2] = config_filename; if (GNUNET_OK != -- cgit v1.2.3 From 1c568f8eb61e97dfefb61f7372e7338ed997e8c1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 Apr 2016 20:27:57 +0200 Subject: fix testcase init with new API --- src/exchangedb/perf_taler_exchangedb_init.c | 2 +- src/exchangedb/perf_taler_exchangedb_interpreter.c | 67 +++++++++++----------- src/exchangedb/test_exchangedb.c | 44 ++++++-------- 3 files changed, 50 insertions(+), 63 deletions(-) (limited to 'src/exchangedb/perf_taler_exchangedb_init.c') diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index c669518a..516f3ea5 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -486,7 +486,7 @@ PERF_TALER_EXCHANGEDB_refresh_session_free (struct TALER_EXCHANGEDB_RefreshSessi */ struct TALER_EXCHANGEDB_RefreshMelt * PERF_TALER_EXCHANGEDB_refresh_melt_init (struct GNUNET_HashCode *session, - struct PERF_TALER_EXCHANGEDB_Coin *coin) + struct PERF_TALER_EXCHANGEDB_Coin *coin) { struct TALER_EXCHANGEDB_RefreshMelt *melt; struct TALER_CoinSpendSignatureP coin_sig; diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 75b32cb6..78b58a5a 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -759,7 +759,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -785,7 +785,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -804,7 +804,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -828,7 +828,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -853,7 +853,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -873,7 +873,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -898,14 +898,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_refresh_order.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_refresh_order.index_hash = ret; + cmd[i].details.get_refresh_order.index_hash = ret; } break; @@ -923,15 +923,15 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.insert_refresh_commit_coin.label_hash); return GNUNET_SYSERR; } - cmd[i].details.insert_refresh_commit_coin.index_hash = ret; - } + cmd[i].details.insert_refresh_commit_coin.index_hash = ret; + } break; case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_COMMIT_COIN: @@ -948,14 +948,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_refresh_commit_coin.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_refresh_commit_coin.index_hash = ret; + cmd[i].details.get_refresh_commit_coin.index_hash = ret; } break; @@ -973,14 +973,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.insert_refresh_commit_link.label_hash); return GNUNET_SYSERR; } - cmd[i].details.insert_refresh_commit_link.index_hash = ret; + cmd[i].details.insert_refresh_commit_link.index_hash = ret; } break; @@ -998,14 +998,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_refresh_commit_link.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_refresh_commit_link.index_hash = ret; + cmd[i].details.get_refresh_commit_link.index_hash = ret; } break; @@ -1023,14 +1023,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_melt_commitment.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_melt_commitment.index_hash = ret; + cmd[i].details.get_melt_commitment.index_hash = ret; } break; @@ -1048,14 +1048,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.insert_refresh_out.label_hash); return GNUNET_SYSERR; } - cmd[i].details.insert_refresh_out.index_hash = ret; + cmd[i].details.insert_refresh_out.index_hash = ret; } break; @@ -1073,14 +1073,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_link_data_list.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_link_data_list.index_hash = ret; + cmd[i].details.get_link_data_list.index_hash = ret; } break; @@ -1098,14 +1098,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_transfer.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_transfer.index_hash = ret; + cmd[i].details.get_transfer.index_hash = ret; } break; @@ -1538,7 +1538,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) int ret; struct PERF_TALER_EXCHANGEDB_Data *data; - denom_index = state->cmd[state->i].details.get_denomination.index_denom; + denom_index = state->cmd[state->i].details.get_denomination.index_denom; data = &state->cmd[denom_index].exposed; ret = state->plugin->get_denomination_info (state->plugin->cls, state->session, @@ -1735,7 +1735,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) 1, 1, refresh_commit); - GNUNET_assert (GNUNET_OK == ret); + GNUNET_assert (GNUNET_OK == ret); } break; @@ -1743,7 +1743,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) { unsigned int hash_index; struct TALER_EXCHANGEDB_RefreshCommitCoin refresh_commit; - + hash_index = state->cmd[state->i].details.insert_refresh_commit_coin.index_hash; state->plugin->get_refresh_commit_coins (state->plugin->cls, state->session, @@ -1837,9 +1837,9 @@ PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin, */ int PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, - const char *configuration_file, - struct PERF_TALER_EXCHANGEDB_Cmd *init, - struct PERF_TALER_EXCHANGEDB_Cmd *benchmark) + const char *configuration_file, + struct PERF_TALER_EXCHANGEDB_Cmd *init, + struct PERF_TALER_EXCHANGEDB_Cmd *benchmark) { struct TALER_EXCHANGEDB_Plugin *plugin; struct GNUNET_CONFIGURATION_Handle *config; @@ -1927,9 +1927,8 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, "INFO", NULL); config = GNUNET_CONFIGURATION_create (); - - ret = GNUNET_CONFIGURATION_load (config, - configuration_file); + ret = GNUNET_CONFIGURATION_parse (config, + configuration_file); if (GNUNET_OK != ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 56c30067..f33bb18c 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -549,17 +549,14 @@ cb_wtid_check (void *cls, /** * Main function that will be run by the scheduler. * - * @param cls closure - * @param args remaining command-line arguments - * @param cfgfile name of the configuration file used (for saving, can be NULL!) - * @param cfg configuration + * @param cls closure with config + * @param tc unused */ static void run (void *cls, - char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_SCHEDULER_TaskContext *tc) { + struct GNUNET_CONFIGURATION_Handle *cfg = cls; struct TALER_EXCHANGEDB_Session *session; struct TALER_ReservePublicKeyP reserve_pub; struct DenomKeyPair *dkp; @@ -572,7 +569,6 @@ run (void *cls, struct TALER_EXCHANGEDB_Deposit deposit; struct TALER_EXCHANGEDB_Deposit deposit2; struct TALER_WireTransferIdentifierRawP wtid; - struct GNUNET_HashCode hc; json_t *wire; json_t *just; const char * const json_wire_str = @@ -659,6 +655,7 @@ run (void *cls, value.value * 2, value.fraction * 2, value.currency)); + result = 5; dkp = create_denom_key_pair (1024, session, &value, &fee_withdraw, @@ -667,12 +664,9 @@ run (void *cls, RND_BLK(&cbc.h_coin_envelope); RND_BLK(&cbc.reserve_sig); cbc.denom_pub = dkp->pub; - GNUNET_CRYPTO_hash (&cbc.h_coin_envelope, - sizeof (cbc.h_coin_envelope), - &hc); cbc.sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, - &hc); + &cbc.h_coin_envelope); cbc.reserve_pub = reserve_pub; cbc.amount_with_fee = value; GNUNET_assert (GNUNET_OK == @@ -699,10 +693,12 @@ run (void *cls, FAILIF (0 != memcmp (&cbc2.reserve_pub, &cbc.reserve_pub, sizeof (cbc2.reserve_pub))); + result = 6; FAILIF (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (&cbc.h_coin_envelope, cbc2.sig.rsa_signature, dkp->pub.rsa_public_key)); + result = 7; rh = plugin->get_reserve_history (plugin->cls, session, &reserve_pub); @@ -873,17 +869,10 @@ int main (int argc, char *const argv[]) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_OPTION_END - }; - char *argv2[] = { - "test-exchange-db-", /* will be replaced later */ - "-c", "test-exchange-db-.conf", /* will be replaced later */ - NULL, - }; const char *plugin_name; char *config_filename; char *testname; + struct GNUNET_CONFIGURATION_Handle *cfg; result = -1; if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) @@ -896,19 +885,18 @@ main (int argc, "test-exchange-db-%s", plugin_name); (void) GNUNET_asprintf (&config_filename, "%s.conf", testname); - - argv2[0] = argv[0]; - argv2[2] = config_filename; + cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != - GNUNET_PROGRAM_run ((sizeof (argv2)/sizeof (char *)) - 1, argv2, - testname, - "Test cases for exchange database helper functions.", - options, &run, NULL)) + GNUNET_CONFIGURATION_parse (cfg, + config_filename)) { + GNUNET_break (0); GNUNET_free (config_filename); GNUNET_free (testname); - return 3; + return 2; } + GNUNET_SCHEDULER_run (&run, cfg); + GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free (config_filename); GNUNET_free (testname); return result; -- cgit v1.2.3