exchange/src/json/test_json_wire.c

81 lines
2.7 KiB
C
Raw Normal View History

2019-06-26 20:43:08 +02:00
/*
This file is part of TALER
2020-01-19 19:21:58 +01:00
(C) 2015, 2016 Taler Systems SA
2019-06-26 20:43:08 +02:00
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, see <http://www.gnu.org/licenses/>
*/
/**
* @file json/test_json_wire.c
* @brief Tests for Taler-specific crypto logic
* @author Christian Grothoff <christian@grothoff.org>
*/
#include "platform.h"
#include "taler_util.h"
#include "taler_json_lib.h"
int
2019-08-25 16:18:24 +02:00
main (int argc,
const char *const argv[])
2019-06-26 20:43:08 +02:00
{
struct TALER_MasterPublicKeyP master_pub;
struct TALER_MasterPrivateKeyP master_priv;
2020-06-10 11:01:27 +02:00
json_t *wire_xtalerbank;
json_t *wire_iban;
const char *payto_xtalerbank = "payto://x-taler-bank/42";
const char *payto_iban =
"payto://iban/BIC-TO-BE-SKIPPED/DE89370400440532013000";
2020-06-10 11:01:27 +02:00
char *p_xtalerbank;
char *p_iban;
2019-08-25 16:18:24 +02:00
2020-03-27 17:28:33 +01:00
(void) argc;
(void) argv;
2019-06-26 20:43:08 +02:00
GNUNET_log_setup ("test-json-wire",
"WARNING",
NULL);
2020-04-11 21:06:30 +02:00
GNUNET_CRYPTO_eddsa_key_create (&master_priv.eddsa_priv);
2019-06-26 20:43:08 +02:00
GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv,
&master_pub.eddsa_pub);
2020-06-10 11:01:27 +02:00
wire_xtalerbank = TALER_JSON_exchange_wire_signature_make (payto_xtalerbank,
&master_priv);
wire_iban = TALER_JSON_exchange_wire_signature_make (payto_iban,
&master_priv);
2020-06-10 17:56:58 +02:00
if (NULL == wire_iban)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not parse payto/IBAN (%s) into 'wire object'\n",
payto_iban);
return 1;
}
2020-06-10 11:01:27 +02:00
p_xtalerbank = TALER_JSON_wire_to_payto (wire_xtalerbank);
p_iban = TALER_JSON_wire_to_payto (wire_iban);
GNUNET_assert (0 == strcmp (p_xtalerbank, payto_xtalerbank));
GNUNET_assert (0 == strcmp (p_iban, payto_iban));
GNUNET_free (p_xtalerbank);
GNUNET_free (p_iban);
GNUNET_assert (GNUNET_OK ==
TALER_JSON_exchange_wire_signature_check (wire_xtalerbank,
&master_pub));
2019-06-26 20:43:08 +02:00
GNUNET_assert (GNUNET_OK ==
2020-06-10 11:01:27 +02:00
TALER_JSON_exchange_wire_signature_check (wire_iban,
2019-06-26 20:43:08 +02:00
&master_pub));
2020-06-10 11:01:27 +02:00
json_decref (wire_xtalerbank);
json_decref (wire_iban);
2019-08-25 16:18:24 +02:00
2019-06-26 20:43:08 +02:00
return 0;
}
2019-10-31 12:59:50 +01:00
2019-06-26 20:43:08 +02:00
/* end of test_json_wire.c */