finishing taler-mint-sepa

This commit is contained in:
Christian Grothoff 2015-08-11 16:53:04 +02:00
parent 3662be1bac
commit 563b30bbfb
3 changed files with 63 additions and 5 deletions

View File

@ -30,7 +30,7 @@ taler_mint_sepa_SOURCES = \
taler_mint_sepa_LDADD = \ taler_mint_sepa_LDADD = \
$(LIBGCRYPT_LIBS) \ $(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \ $(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil $(XLIB) -lgnunetutil -ljansson $(XLIB)
taler_mint_sepa_LDFLAGS = $(POSTGRESQL_LDFLAGS) taler_mint_sepa_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_mint_keycheck_SOURCES = \ taler_mint_keycheck_SOURCES = \

View File

@ -19,7 +19,10 @@
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#include <platform.h> #include <platform.h>
#include <jansson.h>
#include "taler_crypto_lib.h" #include "taler_crypto_lib.h"
#include "taler_signatures.h"
/** /**
* Filename of the master private key. * Filename of the master private key.
@ -79,6 +82,11 @@ main (int argc,
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
}; };
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv; 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_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-mint-sepa", GNUNET_log_setup ("taler-mint-sepa",
@ -103,8 +111,51 @@ main (int argc,
masterkeyfile); masterkeyfile);
return 1; 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); 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; return 0;
} }

View File

@ -22,7 +22,7 @@
#include "taler-mint-httpd_keystate.h" #include "taler-mint-httpd_keystate.h"
#include "taler-mint-httpd_responses.h" #include "taler-mint-httpd_responses.h"
#include "taler-mint-httpd_wire.h" #include "taler-mint-httpd_wire.h"
#include <jansson.h>
/** /**
* Handle a "/wire" request. * Handle a "/wire" request.
@ -44,6 +44,7 @@ TMH_WIRE_handler_wire (struct TMH_RequestHandler *rh,
struct TALER_MintWireSupportMethodsPS wsm; struct TALER_MintWireSupportMethodsPS wsm;
struct TALER_MintPublicKeyP pub; struct TALER_MintPublicKeyP pub;
struct TALER_MintSignatureP sig; struct TALER_MintSignatureP sig;
json_t *methods;
wsm.purpose.size = htonl (sizeof (wsm)); wsm.purpose.size = htonl (sizeof (wsm));
wsm.purpose.purpose = htonl (TALER_SIGNATURE_MINT_WIRE_TYPES); wsm.purpose.purpose = htonl (TALER_SIGNATURE_MINT_WIRE_TYPES);
@ -53,11 +54,17 @@ TMH_WIRE_handler_wire (struct TMH_RequestHandler *rh,
TMH_KS_sign (&wsm.purpose, TMH_KS_sign (&wsm.purpose,
&pub, &pub,
&sig); &sig);
/* FIXME: check against spec! */ methods = json_array ();
/* NOTE: for now, we only support *ONE* wire format per
mint instance; if we supply multiple, we need to
add the strings for each type separately here -- and
hash the 0-terminated strings above differently as well... */
json_array_append_new (methods,
json_string (TMH_expected_wire_format));
return TMH_RESPONSE_reply_json_pack (connection, return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:s, s:o, s:o}", "{s:s, s:o, s:o}",
"wire", TMH_expected_wire_format, "methods", methods,
"sig", TALER_json_from_data (&sig, "sig", TALER_json_from_data (&sig,
sizeof (sig)), sizeof (sig)),
"pub", TALER_json_from_data (&pub, "pub", TALER_json_from_data (&pub,