use properly typed merchant pub/priv key in trait
This commit is contained in:
parent
9d2ff364dc
commit
27457d94e4
@ -2139,7 +2139,7 @@ struct TALER_TESTING_FreshCoinData
|
||||
* Offer a _array_ of fresh coins.
|
||||
*
|
||||
* @param index which array of fresh coins to offer,
|
||||
* if there are multiple on offer. Tipically passed as
|
||||
* if there are multiple on offer. Typically passed as
|
||||
* zero.
|
||||
* @param fresh_coins the array of fresh coins to offer
|
||||
*
|
||||
@ -2255,74 +2255,69 @@ TALER_TESTING_make_trait_exchange_keys (unsigned int index,
|
||||
|
||||
|
||||
/**
|
||||
* Obtain a private key from a "peer". Used e.g. to obtain
|
||||
* Obtain a private key from a "merchant". Used e.g. to obtain
|
||||
* a merchant's priv to sign a /track request.
|
||||
*
|
||||
* @param cmd command that is offering the key.
|
||||
* @param index (tipically zero) which key to return if there
|
||||
* @param index (typically zero) which key to return if there
|
||||
* are multiple on offer.
|
||||
* @param priv[out] set to the key coming from @a cmd.
|
||||
* @return #GNUNET_OK on success.
|
||||
*/
|
||||
int
|
||||
TALER_TESTING_get_trait_peer_key (const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int index,
|
||||
const struct
|
||||
GNUNET_CRYPTO_EddsaPrivateKey **priv);
|
||||
TALER_TESTING_get_trait_merchant_priv (const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int index,
|
||||
const struct
|
||||
TALER_MerchantPrivateKeyP **priv);
|
||||
|
||||
// FIXME: private get_trait_merchant_priv instead, rather have
|
||||
// more traits with precise types than this!
|
||||
|
||||
|
||||
/**
|
||||
* Offer private key, typically done when CMD_1 needs it to
|
||||
* Offer private key of a merchant, typically done when CMD_1 needs it to
|
||||
* sign a request.
|
||||
*
|
||||
* @param index (tipically zero) which key to return if there are
|
||||
* @param index (typically zero) which key to return if there are
|
||||
* multiple on offer.
|
||||
* @param priv which object should be offered.
|
||||
* @return the trait.
|
||||
*/
|
||||
struct TALER_TESTING_Trait
|
||||
TALER_TESTING_make_trait_peer_key (unsigned int index,
|
||||
const struct
|
||||
GNUNET_CRYPTO_EddsaPrivateKey *priv);
|
||||
|
||||
// FIXME: private get_trait_merchant_priv instead, rather have
|
||||
// more traits with precise types than this!
|
||||
TALER_TESTING_make_trait_merchant_priv (unsigned int index,
|
||||
const struct
|
||||
TALER_MerchantPrivateKeyP *priv);
|
||||
|
||||
|
||||
/**
|
||||
* Obtain a public key from a "peer". Used e.g. to obtain
|
||||
* Obtain a public key from a "merchant". Used e.g. to obtain
|
||||
* a merchant's public key to use backend's API.
|
||||
*
|
||||
* @param cmd command offering the key.
|
||||
* @param index (tipically zero) which key to return if there
|
||||
* @param index (typically zero) which key to return if there
|
||||
* are multiple on offer.
|
||||
* @param pub[out] set to the key coming from @a cmd.
|
||||
*
|
||||
* @return #GNUNET_OK on success.
|
||||
*/
|
||||
int
|
||||
TALER_TESTING_get_trait_peer_key_pub (const struct TALER_TESTING_Command *cmd,
|
||||
TALER_TESTING_get_trait_merchant_pub (const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int index,
|
||||
const struct
|
||||
GNUNET_CRYPTO_EddsaPublicKey **pub);
|
||||
TALER_MerchantPublicKeyP **pub);
|
||||
|
||||
|
||||
/**
|
||||
* Offer public key.
|
||||
*
|
||||
* @param index (tipically zero) which key to return if there
|
||||
* @param index (typically zero) which key to return if there
|
||||
* are multiple on offer. NOTE: if one key is offered, it
|
||||
* is mandatory to set this as zero.
|
||||
* @param pub which object should be returned.
|
||||
*
|
||||
* @return the trait.
|
||||
*/
|
||||
struct TALER_TESTING_Trait
|
||||
TALER_TESTING_make_trait_peer_key_pub (unsigned int index,
|
||||
struct GNUNET_CRYPTO_EddsaPublicKey *pub);
|
||||
TALER_TESTING_make_trait_merchant_pub (unsigned int index,
|
||||
struct TALER_MerchantPublicKeyP *pub);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ libtalertesting_la_SOURCES = \
|
||||
testing_api_trait_exchange_sig.c \
|
||||
testing_api_trait_fresh_coin.c \
|
||||
testing_api_trait_json.c \
|
||||
testing_api_trait_key_peer.c \
|
||||
testing_api_trait_merchant_key.c \
|
||||
testing_api_trait_number.c \
|
||||
testing_api_trait_process.c \
|
||||
testing_api_trait_reserve_pub.c \
|
||||
|
@ -197,7 +197,7 @@ deposit_confirmation_run (void *cls,
|
||||
struct GNUNET_TIME_Absolute refund_deadline;
|
||||
struct TALER_Amount amount_without_fee;
|
||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
||||
const struct TALER_MerchantPrivateKeyP *merchant_priv;
|
||||
struct TALER_MerchantPublicKeyP merchant_pub;
|
||||
const struct TALER_ExchangePublicKeyP *exchange_pub;
|
||||
const struct TALER_ExchangeSignatureP *exchange_sig;
|
||||
@ -255,10 +255,10 @@ deposit_confirmation_run (void *cls,
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
|
||||
&coin_pub.eddsa_pub);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_peer_key (deposit_cmd,
|
||||
dcs->coin_index,
|
||||
&merchant_priv));
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (merchant_priv,
|
||||
TALER_TESTING_get_trait_merchant_priv (deposit_cmd,
|
||||
dcs->coin_index,
|
||||
&merchant_priv));
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&merchant_priv->eddsa_priv,
|
||||
&merchant_pub.eddsa_pub);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_string_to_amount (dcs->amount_without_fee,
|
||||
|
@ -446,8 +446,8 @@ deposit_traits (void *cls,
|
||||
ds->wire_details),
|
||||
TALER_TESTING_make_trait_contract_terms (0,
|
||||
ds->contract_terms),
|
||||
TALER_TESTING_make_trait_peer_key (0,
|
||||
&ds->merchant_priv.eddsa_priv),
|
||||
TALER_TESTING_make_trait_merchant_priv (0,
|
||||
&ds->merchant_priv),
|
||||
TALER_TESTING_make_trait_amount_obj (0,
|
||||
&ds->amount),
|
||||
TALER_TESTING_trait_end ()
|
||||
|
@ -16,14 +16,12 @@
|
||||
License along with TALER; see the file COPYING. If not, see
|
||||
<http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file exchange/testing_api_cmd_refund.c
|
||||
* @brief Implement the /refund test command, plus other
|
||||
* corollary commands (?).
|
||||
* @author Marcello Stanisci
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "taler_json_lib.h"
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
@ -137,7 +135,7 @@ refund_run (void *cls,
|
||||
struct GNUNET_HashCode h_contract_terms;
|
||||
struct TALER_Amount refund_fee;
|
||||
struct TALER_Amount refund_amount;
|
||||
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
||||
const struct TALER_MerchantPrivateKeyP *merchant_priv;
|
||||
const struct TALER_TESTING_Command *coin_cmd;
|
||||
|
||||
rs->exchange = is->exchange;
|
||||
@ -168,31 +166,32 @@ refund_run (void *cls,
|
||||
return;
|
||||
}
|
||||
|
||||
coin_cmd = TALER_TESTING_interpreter_lookup_command
|
||||
(is, rs->coin_reference);
|
||||
|
||||
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
rs->coin_reference);
|
||||
if (NULL == coin_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
|
||||
if (GNUNET_OK != TALER_TESTING_get_trait_contract_terms
|
||||
(coin_cmd, 0, &contract_terms))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_contract_terms (coin_cmd,
|
||||
0,
|
||||
&contract_terms))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_JSON_hash (contract_terms,
|
||||
&h_contract_terms));
|
||||
|
||||
/* Hunting for a coin .. */
|
||||
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
|
||||
(coin_cmd, 0, &coin_priv))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_coin_priv (coin_cmd,
|
||||
0,
|
||||
&coin_priv))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
@ -201,24 +200,24 @@ refund_run (void *cls,
|
||||
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
|
||||
&coin.eddsa_pub);
|
||||
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key
|
||||
(coin_cmd, 0, &merchant_priv))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_merchant_priv (coin_cmd,
|
||||
0,
|
||||
&merchant_priv))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
|
||||
rs->rh = TALER_EXCHANGE_refund
|
||||
(rs->exchange,
|
||||
&refund_amount,
|
||||
&refund_fee,
|
||||
&h_contract_terms,
|
||||
&coin,
|
||||
rs->refund_transaction_id,
|
||||
(const struct TALER_MerchantPrivateKeyP *) merchant_priv,
|
||||
&refund_cb, rs);
|
||||
|
||||
rs->rh = TALER_EXCHANGE_refund (rs->exchange,
|
||||
&refund_amount,
|
||||
&refund_fee,
|
||||
&h_contract_terms,
|
||||
&coin,
|
||||
rs->refund_transaction_id,
|
||||
merchant_priv,
|
||||
&refund_cb,
|
||||
rs);
|
||||
GNUNET_assert (NULL != rs->rh);
|
||||
}
|
||||
|
||||
|
@ -156,15 +156,14 @@ struct TrackTransferState
|
||||
* if @a http_status is #MHD_HTTP_OK).
|
||||
*/
|
||||
static void
|
||||
deposit_wtid_cb
|
||||
(void *cls,
|
||||
unsigned int http_status,
|
||||
enum TALER_ErrorCode ec,
|
||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||
const json_t *json,
|
||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||
struct GNUNET_TIME_Absolute execution_time,
|
||||
const struct TALER_Amount *coin_contribution)
|
||||
deposit_wtid_cb (void *cls,
|
||||
unsigned int http_status,
|
||||
enum TALER_ErrorCode ec,
|
||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||
const json_t *json,
|
||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||
struct GNUNET_TIME_Absolute execution_time,
|
||||
const struct TALER_Amount *coin_contribution)
|
||||
{
|
||||
struct TrackTransactionState *tts = cls;
|
||||
struct TALER_TESTING_Interpreter *is = tts->is;
|
||||
@ -255,12 +254,12 @@ track_transaction_run (void *cls,
|
||||
const json_t *wire_details;
|
||||
struct GNUNET_HashCode h_wire_details;
|
||||
struct GNUNET_HashCode h_contract_terms;
|
||||
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
||||
const struct TALER_MerchantPrivateKeyP *merchant_priv;
|
||||
|
||||
tts->is = is;
|
||||
transaction_cmd = TALER_TESTING_interpreter_lookup_command
|
||||
(tts->is, tts->transaction_reference);
|
||||
|
||||
transaction_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (tts->is,
|
||||
tts->transaction_reference);
|
||||
if (NULL == transaction_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -268,8 +267,10 @@ track_transaction_run (void *cls,
|
||||
return;
|
||||
}
|
||||
|
||||
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
|
||||
(transaction_cmd, tts->coin_index, &coin_priv))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_coin_priv (transaction_cmd,
|
||||
tts->coin_index,
|
||||
&coin_priv))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (tts->is);
|
||||
@ -280,23 +281,28 @@ track_transaction_run (void *cls,
|
||||
&coin_pub.eddsa_pub);
|
||||
|
||||
/* Get the strings.. */
|
||||
if (GNUNET_OK != TALER_TESTING_get_trait_wire_details
|
||||
(transaction_cmd, 0, &wire_details))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_wire_details (transaction_cmd,
|
||||
0,
|
||||
&wire_details))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (tts->is);
|
||||
return;
|
||||
}
|
||||
|
||||
if (GNUNET_OK != TALER_TESTING_get_trait_contract_terms
|
||||
(transaction_cmd, 0, &contract_terms))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_contract_terms (transaction_cmd,
|
||||
0,
|
||||
&contract_terms))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (tts->is);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((NULL == wire_details) || (NULL == contract_terms))
|
||||
if ( (NULL == wire_details) ||
|
||||
(NULL == contract_terms) )
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (tts->is);
|
||||
@ -312,23 +318,23 @@ track_transaction_run (void *cls,
|
||||
TALER_JSON_hash (contract_terms,
|
||||
&h_contract_terms)) );
|
||||
|
||||
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key
|
||||
(transaction_cmd, 0, &merchant_priv))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_merchant_priv (transaction_cmd,
|
||||
0,
|
||||
&merchant_priv))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (tts->is);
|
||||
return;
|
||||
}
|
||||
|
||||
tts->tth = TALER_EXCHANGE_track_transaction
|
||||
(is->exchange,
|
||||
(struct TALER_MerchantPrivateKeyP *) merchant_priv,
|
||||
&h_wire_details,
|
||||
&h_contract_terms,
|
||||
&coin_pub,
|
||||
&deposit_wtid_cb,
|
||||
tts);
|
||||
|
||||
tts->tth = TALER_EXCHANGE_track_transaction (is->exchange,
|
||||
merchant_priv,
|
||||
&h_wire_details,
|
||||
&h_contract_terms,
|
||||
&coin_pub,
|
||||
&deposit_wtid_cb,
|
||||
tts);
|
||||
GNUNET_assert (NULL != tts->tth);
|
||||
}
|
||||
|
||||
@ -341,9 +347,8 @@ track_transaction_run (void *cls,
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
track_transaction_cleanup
|
||||
(void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
track_transaction_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct TrackTransactionState *tts = cls;
|
||||
|
||||
@ -404,12 +409,11 @@ track_transaction_traits (void *cls,
|
||||
* @return the command.
|
||||
*/
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_track_transaction
|
||||
(const char *label,
|
||||
const char *transaction_reference,
|
||||
unsigned int coin_index,
|
||||
unsigned int expected_response_code,
|
||||
const char *bank_transfer_reference)
|
||||
TALER_TESTING_cmd_track_transaction (const char *label,
|
||||
const char *transaction_reference,
|
||||
unsigned int coin_index,
|
||||
unsigned int expected_response_code,
|
||||
const char *bank_transfer_reference)
|
||||
{
|
||||
struct TrackTransactionState *tts;
|
||||
|
||||
@ -418,16 +422,17 @@ TALER_TESTING_cmd_track_transaction
|
||||
tts->expected_response_code = expected_response_code;
|
||||
tts->bank_transfer_reference = bank_transfer_reference;
|
||||
tts->coin_index = coin_index;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = tts,
|
||||
.label = label,
|
||||
.run = &track_transaction_run,
|
||||
.cleanup = &track_transaction_cleanup,
|
||||
.traits = &track_transaction_traits
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = tts,
|
||||
.label = label,
|
||||
.run = &track_transaction_run,
|
||||
.cleanup = &track_transaction_cleanup,
|
||||
.traits = &track_transaction_traits
|
||||
};
|
||||
|
||||
return cmd;
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -483,18 +488,17 @@ track_transfer_cleanup (void *cls,
|
||||
* transactions.
|
||||
*/
|
||||
static void
|
||||
track_transfer_cb
|
||||
(void *cls,
|
||||
unsigned int http_status,
|
||||
enum TALER_ErrorCode ec,
|
||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||
const json_t *json,
|
||||
const struct GNUNET_HashCode *h_wire,
|
||||
struct GNUNET_TIME_Absolute execution_time,
|
||||
const struct TALER_Amount *total_amount,
|
||||
const struct TALER_Amount *wire_fee,
|
||||
unsigned int details_length,
|
||||
const struct TALER_TrackTransferDetails *details)
|
||||
track_transfer_cb (void *cls,
|
||||
unsigned int http_status,
|
||||
enum TALER_ErrorCode ec,
|
||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||
const json_t *json,
|
||||
const struct GNUNET_HashCode *h_wire,
|
||||
struct GNUNET_TIME_Absolute execution_time,
|
||||
const struct TALER_Amount *total_amount,
|
||||
const struct TALER_Amount *wire_fee,
|
||||
unsigned int details_length,
|
||||
const struct TALER_TrackTransferDetails *details)
|
||||
{
|
||||
struct TrackTransferState *tts = cls;
|
||||
struct TALER_TESTING_Interpreter *is = tts->is;
|
||||
@ -668,7 +672,7 @@ track_transfer_cb
|
||||
* @param cmd the command under execution.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
track_transfer_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
@ -733,28 +737,27 @@ track_transfer_run (void *cls,
|
||||
* @return the command.
|
||||
*/
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_track_transfer_empty
|
||||
(const char *label,
|
||||
const char *wtid_reference,
|
||||
unsigned int index,
|
||||
unsigned int expected_response_code)
|
||||
TALER_TESTING_cmd_track_transfer_empty (const char *label,
|
||||
const char *wtid_reference,
|
||||
unsigned int index,
|
||||
unsigned int expected_response_code)
|
||||
{
|
||||
struct TrackTransferState *tts;
|
||||
|
||||
tts = GNUNET_new (struct TrackTransferState);
|
||||
|
||||
tts->wtid_reference = wtid_reference;
|
||||
tts->index = index;
|
||||
tts->expected_response_code = expected_response_code;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = tts,
|
||||
.label = label,
|
||||
.run = &track_transfer_run,
|
||||
.cleanup = &track_transfer_cleanup
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = tts,
|
||||
.label = label,
|
||||
.run = &track_transfer_run,
|
||||
.cleanup = &track_transfer_cleanup
|
||||
};
|
||||
|
||||
return cmd;
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -775,32 +778,31 @@ TALER_TESTING_cmd_track_transfer_empty
|
||||
* @return the command
|
||||
*/
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_track_transfer
|
||||
(const char *label,
|
||||
const char *wtid_reference,
|
||||
unsigned int index,
|
||||
unsigned int expected_response_code,
|
||||
const char *expected_total_amount,
|
||||
const char *expected_wire_fee)
|
||||
TALER_TESTING_cmd_track_transfer (const char *label,
|
||||
const char *wtid_reference,
|
||||
unsigned int index,
|
||||
unsigned int expected_response_code,
|
||||
const char *expected_total_amount,
|
||||
const char *expected_wire_fee)
|
||||
{
|
||||
struct TrackTransferState *tts;
|
||||
|
||||
tts = GNUNET_new (struct TrackTransferState);
|
||||
|
||||
tts->wtid_reference = wtid_reference;
|
||||
tts->index = index;
|
||||
tts->expected_response_code = expected_response_code;
|
||||
tts->expected_total_amount = expected_total_amount;
|
||||
tts->expected_wire_fee = expected_wire_fee;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = tts,
|
||||
.label = label,
|
||||
.run = &track_transfer_run,
|
||||
.cleanup = &track_transfer_cleanup
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = tts,
|
||||
.label = label,
|
||||
.run = &track_transfer_run,
|
||||
.cleanup = &track_transfer_cleanup
|
||||
};
|
||||
|
||||
return cmd;
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,9 +16,8 @@
|
||||
License along with TALER; see the file COPYING. If not, see
|
||||
<http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file exchange-lib/testing_api_trait_key_peer.c
|
||||
* @file lib/testing_api_trait_merchant_key.c
|
||||
* @brief traits to offer peer's (private) keys
|
||||
* @author Marcello Stanisci
|
||||
*/
|
||||
@ -29,28 +28,28 @@
|
||||
#include "taler_signatures.h"
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
#define TALER_TESTING_TRAIT_KEY_PEER "key-peer"
|
||||
#define TALER_TESTING_TRAIT_KEY_PEER_PUB "key-peer-pub"
|
||||
#define TALER_TESTING_TRAIT_MERCHANT_PRIV "merchant-priv"
|
||||
#define TALER_TESTING_TRAIT_MERCHANT_PUB "merchant-pub-pub"
|
||||
|
||||
/**
|
||||
* Obtain a private key from a "peer". Used e.g. to obtain
|
||||
* a merchant's priv to sign a /track request.
|
||||
*
|
||||
* @param cmd command that is offering the key.
|
||||
* @param index (tipically zero) which key to return if there
|
||||
* @param index (typically zero) which key to return if there
|
||||
* are multiple on offer.
|
||||
* @param priv[out] set to the key coming from @a cmd.
|
||||
* @return #GNUNET_OK on success.
|
||||
*/
|
||||
int
|
||||
TALER_TESTING_get_trait_peer_key
|
||||
TALER_TESTING_get_trait_merchant_priv
|
||||
(const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int index,
|
||||
const struct GNUNET_CRYPTO_EddsaPrivateKey **priv)
|
||||
const struct TALER_MerchantPrivateKeyP **priv)
|
||||
{
|
||||
return cmd->traits (cmd->cls,
|
||||
(const void **) priv,
|
||||
TALER_TESTING_TRAIT_KEY_PEER,
|
||||
TALER_TESTING_TRAIT_MERCHANT_PRIV,
|
||||
index);
|
||||
}
|
||||
|
||||
@ -59,21 +58,22 @@ TALER_TESTING_get_trait_peer_key
|
||||
* Offer private key, typically done when CMD_1 needs it to
|
||||
* sign a request.
|
||||
*
|
||||
* @param index (tipically zero) which key to return if there are
|
||||
* @param index (typically zero) which key to return if there are
|
||||
* multiple on offer.
|
||||
* @param priv which object should be offered.
|
||||
* @return the trait.
|
||||
*/
|
||||
struct TALER_TESTING_Trait
|
||||
TALER_TESTING_make_trait_peer_key
|
||||
(unsigned int index,
|
||||
const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
|
||||
TALER_TESTING_make_trait_merchant_priv (unsigned int index,
|
||||
const struct
|
||||
TALER_MerchantPrivateKeyP *priv)
|
||||
{
|
||||
struct TALER_TESTING_Trait ret = {
|
||||
.index = index,
|
||||
.trait_name = TALER_TESTING_TRAIT_KEY_PEER,
|
||||
.trait_name = TALER_TESTING_TRAIT_MERCHANT_PRIV,
|
||||
.ptr = (const void *) priv
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -83,21 +83,21 @@ TALER_TESTING_make_trait_peer_key
|
||||
* a merchant's public key to use backend's API.
|
||||
*
|
||||
* @param cmd command offering the key.
|
||||
* @param index (tipically zero) which key to return if there
|
||||
* @param index (typically zero) which key to return if there
|
||||
* are multiple on offer.
|
||||
* @param pub[out] set to the key coming from @a cmd.
|
||||
*
|
||||
* @return #GNUNET_OK on success.
|
||||
*/
|
||||
int
|
||||
TALER_TESTING_get_trait_peer_key_pub
|
||||
TALER_TESTING_get_trait_merchant_pub
|
||||
(const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int index,
|
||||
const struct GNUNET_CRYPTO_EddsaPublicKey **pub)
|
||||
const struct TALER_MerchantPublicKeyP **pub)
|
||||
{
|
||||
return cmd->traits (cmd->cls,
|
||||
(const void **) pub,
|
||||
TALER_TESTING_TRAIT_KEY_PEER_PUB,
|
||||
TALER_TESTING_TRAIT_MERCHANT_PUB,
|
||||
index);
|
||||
}
|
||||
|
||||
@ -105,25 +105,24 @@ TALER_TESTING_get_trait_peer_key_pub
|
||||
/**
|
||||
* Offer public key.
|
||||
*
|
||||
* @param index (tipically zero) which key to return if there
|
||||
* @param index (typically zero) which key to return if there
|
||||
* are multiple on offer. NOTE: if one key is offered, it
|
||||
* is mandatory to set this as zero.
|
||||
* @param pub which object should be returned.
|
||||
*
|
||||
* @return the trait.
|
||||
*/
|
||||
struct TALER_TESTING_Trait
|
||||
TALER_TESTING_make_trait_peer_key_pub
|
||||
(unsigned int index,
|
||||
struct GNUNET_CRYPTO_EddsaPublicKey *pub)
|
||||
TALER_TESTING_make_trait_merchant_pub (unsigned int index,
|
||||
struct TALER_MerchantPublicKeyP *pub)
|
||||
{
|
||||
struct TALER_TESTING_Trait ret = {
|
||||
.index = index,
|
||||
.trait_name = TALER_TESTING_TRAIT_KEY_PEER_PUB,
|
||||
.trait_name = TALER_TESTING_TRAIT_MERCHANT_PUB,
|
||||
.ptr = (const void *) pub
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* end of testing_api_trait_key_peer.c */
|
||||
/* end of testing_api_trait_merchant_key.c */
|
Loading…
Reference in New Issue
Block a user