diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-08-11 16:53:04 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-08-11 16:53:04 +0200 |
commit | 563b30bbfb6869679f74bdd731367210d19e3c47 (patch) | |
tree | d4c5470dfdc046afe809b231094215ba24df6f5e /src/mint-tools | |
parent | 3662be1bac9c65756c2edf419b9ad55c045a668f (diff) |
finishing taler-mint-sepa
Diffstat (limited to 'src/mint-tools')
-rw-r--r-- | src/mint-tools/Makefile.am | 2 | ||||
-rw-r--r-- | src/mint-tools/taler-mint-sepa.c | 53 |
2 files changed, 53 insertions, 2 deletions
diff --git a/src/mint-tools/Makefile.am b/src/mint-tools/Makefile.am index b76d9b68c..a1b1302de 100644 --- a/src/mint-tools/Makefile.am +++ b/src/mint-tools/Makefile.am @@ -30,7 +30,7 @@ taler_mint_sepa_SOURCES = \ taler_mint_sepa_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/util/libtalerutil.la \ - -lgnunetutil $(XLIB) + -lgnunetutil -ljansson $(XLIB) taler_mint_sepa_LDFLAGS = $(POSTGRESQL_LDFLAGS) taler_mint_keycheck_SOURCES = \ diff --git a/src/mint-tools/taler-mint-sepa.c b/src/mint-tools/taler-mint-sepa.c index 9c7060b58..ffd2200f7 100644 --- a/src/mint-tools/taler-mint-sepa.c +++ b/src/mint-tools/taler-mint-sepa.c @@ -19,7 +19,10 @@ * @author Christian Grothoff */ #include <platform.h> +#include <jansson.h> #include "taler_crypto_lib.h" +#include "taler_signatures.h" + /** * Filename of the master private key. @@ -79,6 +82,11 @@ main (int argc, GNUNET_GETOPT_OPTION_END }; struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv; + struct TALER_MasterWireSepaDetailsPS wsd; + struct TALER_MasterSignatureP sig; + struct GNUNET_HashContext *hc; + json_t *reply; + char *json_str; GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-mint-sepa", @@ -103,8 +111,51 @@ main (int argc, masterkeyfile); return 1; } - /* FIXME: do real work! */ + + /* Compute message to sign */ + hc = GNUNET_CRYPTO_hash_context_start (); + GNUNET_CRYPTO_hash_context_read (hc, + sepa_name, + strlen (sepa_name) + 1); + GNUNET_CRYPTO_hash_context_read (hc, + iban, + strlen (iban) + 1); + GNUNET_CRYPTO_hash_context_read (hc, + bic, + strlen (bic) + 1); + wsd.purpose.size = htonl (sizeof (wsd)); + wsd.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SEPA_DETAILS); + GNUNET_CRYPTO_hash_context_finish (hc, + &wsd.h_sepa_details); + GNUNET_CRYPTO_eddsa_sign (eddsa_priv, + &wsd.purpose, + &sig.eddsa_signature); GNUNET_free (eddsa_priv); + + /* build JSON message */ + reply = json_pack ("{s:s, s:s, s:s, s:o}", + "receiver_name", sepa_name, + "iban", iban, + "bic", bic, + "sig", TALER_json_from_data (&sig, + sizeof (sig))); + GNUNET_assert (NULL != reply); + + /* dump result to stdout */ + json_str = json_dumps (reply, JSON_INDENT(2)); + GNUNET_assert (NULL != json_str); + + if (NULL != output_filename) + { + fclose (stdout); + stdout = fopen (output_filename, + "w+"); + } + fprintf (stdout, + "%s", + json_str); + fflush (stdout); + free (json_str); return 0; } |