From eae1896a4bfc02b5d7586f81bbedfea69b29acc8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 27 Mar 2015 19:58:40 +0100 Subject: major rename-fest for more constent symbol names --- src/mint/Makefile.am | 3 +- src/mint/key_io.c | 16 +- src/mint/key_io.h | 18 +- src/mint/plugin.c | 2 +- src/mint/plugin_mintdb_postgres.c | 422 ++++---- src/mint/taler-mint-httpd.c | 79 +- src/mint/taler-mint-httpd.h | 14 +- src/mint/taler-mint-httpd_db.c | 268 ++--- src/mint/taler-mint-httpd_db.h | 58 +- src/mint/taler-mint-httpd_deposit.c | 80 +- src/mint/taler-mint-httpd_deposit.h | 10 +- src/mint/taler-mint-httpd_keystate.c | 122 +-- src/mint/taler-mint-httpd_keystate.h | 34 +- src/mint/taler-mint-httpd_mhd.c | 8 +- src/mint/taler-mint-httpd_mhd.h | 44 +- src/mint/taler-mint-httpd_parsing.c | 178 ++-- src/mint/taler-mint-httpd_parsing.h | 104 +- src/mint/taler-mint-httpd_refresh.c | 324 +++--- src/mint/taler-mint-httpd_refresh.h | 34 +- src/mint/taler-mint-httpd_responses.c | 194 ++-- src/mint/taler-mint-httpd_responses.h | 112 +-- src/mint/taler-mint-httpd_withdraw.c | 44 +- src/mint/taler-mint-httpd_withdraw.h | 20 +- src/mint/taler-mint-keycheck.c | 28 +- src/mint/taler-mint-keyup.c | 72 +- src/mint/taler-mint-reservemod.c | 18 +- src/mint/taler_mintdb_plugin.h | 1029 -------------------- src/mint/test_mint_common.c | 6 +- src/mint/test_mint_db.c | 6 +- src/mint/test_mint_deposits.c | 6 +- .../test_mint_nayapaisa/config/mint-common.conf | 2 +- .../test_mint_nyadirahim/config/mint-common.conf | 2 +- 32 files changed, 1164 insertions(+), 2193 deletions(-) delete mode 100644 src/mint/taler_mintdb_plugin.h (limited to 'src/mint') diff --git a/src/mint/Makefile.am b/src/mint/Makefile.am index 5afae3b30..f8e5696ff 100644 --- a/src/mint/Makefile.am +++ b/src/mint/Makefile.am @@ -22,8 +22,7 @@ lib_LTLIBRARIES = \ libtalermint_common_la_SOURCES = \ key_io.c key_io.h \ - plugin.c plugin.h \ - taler_mintdb_plugin.h + plugin.c plugin.h libtalermint_common_la_LIBADD = \ $(top_builddir)/src/util/libtalerutil.la \ diff --git a/src/mint/key_io.c b/src/mint/key_io.c index 182d6f3de..02d888d5d 100644 --- a/src/mint/key_io.c +++ b/src/mint/key_io.c @@ -60,12 +60,12 @@ signkeys_iterate_dir_iter (void *cls, { struct SignkeysIterateContext *skc = cls; ssize_t nread; - struct TALER_MINT_SignKeyIssuePriv issue; + struct TALER_MintSigningKeyValidityPSPriv issue; nread = GNUNET_DISK_fn_read (filename, &issue, - sizeof (struct TALER_MINT_SignKeyIssuePriv)); - if (nread != sizeof (struct TALER_MINT_SignKeyIssuePriv)) + sizeof (struct TALER_MintSigningKeyValidityPSPriv)); + if (nread != sizeof (struct TALER_MintSigningKeyValidityPSPriv)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid signkey file `%s': wrong size\n", @@ -122,7 +122,7 @@ TALER_MINT_signkeys_iterate (const char *mint_base_dir, */ int TALER_MINT_read_denom_key (const char *filename, - struct TALER_MINT_DenomKeyIssuePriv *dki) + struct TALER_DenominationKeyIssueInformation *dki) { uint64_t size; size_t offset; @@ -139,7 +139,7 @@ TALER_MINT_read_denom_key (const char *filename, filename); return GNUNET_SYSERR; } - offset = sizeof (struct TALER_MINT_DenomKeyIssue); + offset = sizeof (struct TALER_DenominationKeyValidityPS); if (size <= offset) { GNUNET_break (0); @@ -184,7 +184,7 @@ TALER_MINT_read_denom_key (const char *filename, */ int TALER_MINT_write_denom_key (const char *filename, - const struct TALER_MINT_DenomKeyIssuePriv *dki) + const struct TALER_DenominationKeyIssueInformation *dki) { char *priv_enc; size_t priv_enc_size; @@ -203,7 +203,7 @@ TALER_MINT_write_denom_key (const char *filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE))) goto cleanup; - wsize = sizeof (struct TALER_MINT_DenomKeyIssue); + wsize = sizeof (struct TALER_DenominationKeyValidityPS); if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, &dki->issue.signature, wsize))) @@ -267,7 +267,7 @@ denomkeys_iterate_keydir_iter (void *cls, const char *filename) { struct DenomkeysIterateContext *dic = cls; - struct TALER_MINT_DenomKeyIssuePriv issue; + struct TALER_DenominationKeyIssueInformation issue; if (GNUNET_OK != TALER_MINT_read_denom_key (filename, diff --git a/src/mint/key_io.h b/src/mint/key_io.h index 6c6722a8a..0ff968976 100644 --- a/src/mint/key_io.h +++ b/src/mint/key_io.h @@ -47,17 +47,17 @@ GNUNET_NETWORK_STRUCT_BEGIN * Includes the private key followed by the public information about * the signing key. */ -struct TALER_MINT_SignKeyIssuePriv +struct TALER_MintSigningKeyValidityPSPriv { /** * Private key part of the mint's signing key. */ - struct TALER_MintPrivateKey signkey_priv; + struct TALER_MintPrivateKeyP signkey_priv; /** * Public information about a mint signing key. */ - struct TALER_MINT_SignKeyIssue issue; + struct TALER_MintSigningKeyValidityPS issue; }; @@ -68,7 +68,7 @@ GNUNET_NETWORK_STRUCT_END * All information about a denomination key (which is used to * sign coins into existence). */ -struct TALER_MINT_DenomKeyIssuePriv +struct TALER_DenominationKeyIssueInformation { /** * The private key of the denomination. Will be NULL if the private @@ -86,7 +86,7 @@ struct TALER_MINT_DenomKeyIssuePriv /** * Signed public information about a denomination key. */ - struct TALER_MINT_DenomKeyIssue issue; + struct TALER_DenominationKeyValidityPS issue; }; @@ -103,7 +103,7 @@ struct TALER_MINT_DenomKeyIssuePriv typedef int (*TALER_MINT_SignkeyIterator)(void *cls, const char *filename, - const struct TALER_MINT_SignKeyIssuePriv *ski); + const struct TALER_MintSigningKeyValidityPSPriv *ski); /** @@ -119,7 +119,7 @@ typedef int typedef int (*TALER_MINT_DenomkeyIterator)(void *cls, const char *alias, - const struct TALER_MINT_DenomKeyIssuePriv *dki); + const struct TALER_DenominationKeyIssueInformation *dki); @@ -169,7 +169,7 @@ TALER_MINT_denomkeys_iterate (const char *mint_base_dir, */ int TALER_MINT_write_denom_key (const char *filename, - const struct TALER_MINT_DenomKeyIssuePriv *dki); + const struct TALER_DenominationKeyIssueInformation *dki); /** @@ -181,7 +181,7 @@ TALER_MINT_write_denom_key (const char *filename, */ int TALER_MINT_read_denom_key (const char *filename, - struct TALER_MINT_DenomKeyIssuePriv *dki); + struct TALER_DenominationKeyIssueInformation *dki); #endif diff --git a/src/mint/plugin.c b/src/mint/plugin.c index 455c7e8fa..147d4c4c7 100644 --- a/src/mint/plugin.c +++ b/src/mint/plugin.c @@ -109,7 +109,7 @@ plugin_init () opath = lt_dlgetsearchpath (); if (NULL != opath) old_dlsearchpath = GNUNET_strdup (opath); - path = TALER_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); + path = TALER_os_installation_get_path (GNUNET_OS_IPK_LIBDIR); if (NULL != path) { if (NULL != opath) diff --git a/src/mint/plugin_mintdb_postgres.c b/src/mint/plugin_mintdb_postgres.c index d33e0dbdb..9846d1720 100644 --- a/src/mint/plugin_mintdb_postgres.c +++ b/src/mint/plugin_mintdb_postgres.c @@ -22,7 +22,7 @@ * @author Sree Harsha Totakura */ #include "platform.h" -#include "db_pq.h" +#include "taler_pq_lib.h" #include "taler_signatures.h" #include "taler_mintdb_plugin.h" #include @@ -67,7 +67,7 @@ * that we need to use this at the DB layer instead of TALER_CURRENCY_LEN as the * DB only needs to store 3 bytes instead of 8 bytes. */ -#define TALER_DB_CURRENCY_LEN 3 +#define TALER_PQ_CURRENCY_LEN 3 /** @@ -99,7 +99,7 @@ struct PostgresClosure * Database connection string, as read from * the configuration. */ - char *TALER_MINT_db_connection_cfg_str; + char *connection_cfg_str; }; @@ -162,10 +162,10 @@ postgres_create_tables (void *cls, PGconn *conn; result = NULL; - conn = PQconnectdb (pc->TALER_MINT_db_connection_cfg_str); + conn = PQconnectdb (pc->connection_cfg_str); if (CONNECTION_OK != PQstatus (conn)) { - LOG_ERROR ("Database connection failed: %s\n", + TALER_LOG_ERROR ("Database connection failed: %s\n", PQerrorMessage (conn)); GNUNET_break (0); return GNUNET_SYSERR; @@ -247,7 +247,7 @@ postgres_create_tables (void *cls, // index of the old coin in the customer's request ",oldcoin_index INT2 NOT NULL" // index for cut and choose, - // ranges from 0 to #KAPPA-1 + // ranges from 0 to #TALER_CNC_KAPPA-1 ",cnc_index INT2 NOT NULL" ")"); SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_commit_coin" @@ -626,11 +626,11 @@ postgres_get_session (void *cls, if (NULL != (session = pthread_getspecific (pc->db_conn_threadlocal))) return session; - db_conn = PQconnectdb (pc->TALER_MINT_db_connection_cfg_str); + db_conn = PQconnectdb (pc->connection_cfg_str); if (CONNECTION_OK != PQstatus (db_conn)) { - LOG_ERROR ("Database connection failed: %s\n", + TALER_LOG_ERROR ("Database connection failed: %s\n", PQerrorMessage (db_conn)); GNUNET_break (0); return NULL; @@ -679,7 +679,7 @@ postgres_start (void *cls, if (PGRES_COMMAND_OK != PQresultStatus (result)) { - LOG_ERROR ("Failed to start transaction: %s\n", + TALER_LOG_ERROR ("Failed to start transaction: %s\n", PQresultErrorMessage (result)); GNUNET_break (0); PQclear (result); @@ -757,12 +757,12 @@ postgres_reserve_get (void *cls, { PGresult *result; uint64_t expiration_date_nbo; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(&reserve->pub), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(&reserve->pub), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "get_reserve", params); if (PGRES_TUPLES_OK != PQresultStatus (result)) @@ -776,13 +776,13 @@ postgres_reserve_get (void *cls, PQclear (result); return GNUNET_NO; } - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC("expiration_date", &expiration_date_nbo), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC("expiration_date", &expiration_date_nbo), + TALER_PQ_RESULT_SPEC_END }; - EXITIF (GNUNET_OK != TALER_DB_extract_result (result, rs, 0)); + EXITIF (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)); EXITIF (GNUNET_OK != - TALER_DB_extract_amount (result, 0, + TALER_PQ_extract_amount (result, 0, "current_balance_value", "current_balance_fraction", "balance_currency", @@ -819,17 +819,17 @@ postgres_reserves_update (void *cls, if (NULL == reserve) return GNUNET_SYSERR; ret = GNUNET_OK; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (&reserve->pub), - TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value), - TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction), - TALER_DB_QUERY_PARAM_PTR (&expiry_nbo), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (&reserve->pub), + TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.value), + TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.fraction), + TALER_PQ_QUERY_PARAM_PTR (&expiry_nbo), + TALER_PQ_QUERY_PARAM_END }; TALER_amount_hton (&balance_nbo, &reserve->balance); expiry_nbo = GNUNET_TIME_absolute_hton (reserve->expiry); - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "update_reserve", params); if (PGRES_COMMAND_OK != PQresultStatus(result)) @@ -895,16 +895,16 @@ postgres_reserves_in_insert (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reserve does not exist; creating a new one\n"); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (&reserve->pub), - TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value), - TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction), - TALER_DB_QUERY_PARAM_PTR_SIZED (balance_nbo.currency, - TALER_DB_CURRENCY_LEN), - TALER_DB_QUERY_PARAM_PTR (&expiry_nbo), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (&reserve->pub), + TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.value), + TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.fraction), + TALER_PQ_QUERY_PARAM_PTR_SIZED (balance_nbo.currency, + TALER_PQ_CURRENCY_LEN), + TALER_PQ_QUERY_PARAM_PTR (&expiry_nbo), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "create_reserve", params); if (PGRES_COMMAND_OK != PQresultStatus(result)) @@ -917,16 +917,16 @@ postgres_reserves_in_insert (void *cls, PQclear (result); result = NULL; /* create new incoming transaction */ - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (&reserve->pub), - TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value), - TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction), - TALER_DB_QUERY_PARAM_PTR_SIZED (&balance_nbo.currency, - TALER_DB_CURRENCY_LEN), - TALER_DB_QUERY_PARAM_PTR (&expiry_nbo), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (&reserve->pub), + TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.value), + TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.fraction), + TALER_PQ_QUERY_PARAM_PTR_SIZED (&balance_nbo.currency, + TALER_PQ_CURRENCY_LEN), + TALER_PQ_QUERY_PARAM_PTR (&expiry_nbo), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "create_reserves_in_transaction", params); if (PGRES_COMMAND_OK != PQresultStatus(result)) @@ -996,9 +996,9 @@ postgres_get_collectable_blindcoin (void *cls, struct CollectableBlindcoin *collectable) { PGresult *result; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (h_blind), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (h_blind), + TALER_PQ_QUERY_PARAM_END }; struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; struct GNUNET_CRYPTO_rsa_Signature *denom_sig; @@ -1012,7 +1012,7 @@ postgres_get_collectable_blindcoin (void *cls, denom_pub = NULL; denom_pub_enc = NULL; denom_sig_enc = NULL; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "get_collectable_blindcoin", params); @@ -1026,15 +1026,15 @@ postgres_get_collectable_blindcoin (void *cls, ret = GNUNET_NO; goto cleanup; } - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC_VAR("denom_pub", &denom_pub_enc, &denom_pub_enc_size), - TALER_DB_RESULT_SPEC_VAR("denom_sig", &denom_sig_enc, &denom_sig_enc_size), - TALER_DB_RESULT_SPEC("reserve_sig", &collectable->reserve_sig), - TALER_DB_RESULT_SPEC("reserve_pub", &collectable->reserve_pub), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC_VAR("denom_pub", &denom_pub_enc, &denom_pub_enc_size), + TALER_PQ_RESULT_SPEC_VAR("denom_sig", &denom_sig_enc, &denom_sig_enc_size), + TALER_PQ_RESULT_SPEC("reserve_sig", &collectable->reserve_sig), + TALER_PQ_RESULT_SPEC("reserve_pub", &collectable->reserve_pub), + TALER_PQ_RESULT_SPEC_END }; - if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0)) + if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)) { GNUNET_break (0); goto cleanup; @@ -1103,18 +1103,18 @@ postgres_insert_collectable_blindcoin (void *cls, denom_sig_enc_size = GNUNET_CRYPTO_rsa_signature_encode (collectable->sig.rsa_signature, &denom_sig_enc); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (h_blind), - TALER_DB_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size - 1), - TALER_DB_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size - 1), /* DB doesn't like the trailing \0 */ - TALER_DB_QUERY_PARAM_PTR (&collectable->reserve_pub), - TALER_DB_QUERY_PARAM_PTR (&collectable->reserve_sig), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (h_blind), + TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size - 1), + TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size - 1), /* DB doesn't like the trailing \0 */ + TALER_PQ_QUERY_PARAM_PTR (&collectable->reserve_pub), + TALER_PQ_QUERY_PARAM_PTR (&collectable->reserve_sig), + TALER_PQ_QUERY_PARAM_END }; if (GNUNET_OK != postgres_start (cls, session)) goto cleanup; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "insert_collectable_blindcoin", params); if (PGRES_COMMAND_OK != PQresultStatus (result)) @@ -1166,7 +1166,7 @@ postgres_insert_collectable_blindcoin (void *cls, static struct ReserveHistory * postgres_get_reserve_history (void *cls, struct TALER_MINTDB_Session *session, - const struct TALER_ReservePublicKey *reserve_pub) + const struct TALER_ReservePublicKeyP *reserve_pub) { PGresult *result; struct ReserveHistory *rh; @@ -1180,12 +1180,12 @@ postgres_get_reserve_history (void *cls, ret = GNUNET_SYSERR; { struct BankTransfer *bt; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (reserve_pub), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (reserve_pub), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "get_reserves_in_transactions", params); if (PGRES_TUPLES_OK != PQresultStatus (result)) @@ -1202,7 +1202,7 @@ postgres_get_reserve_history (void *cls, while (0 < rows) { bt = GNUNET_new (struct BankTransfer); - if (GNUNET_OK != TALER_DB_extract_amount (result, + if (GNUNET_OK != TALER_PQ_extract_amount (result, --rows, "balance_value", "balance_fraction", @@ -1232,18 +1232,18 @@ postgres_get_reserve_history (void *cls, result = NULL; { struct GNUNET_HashCode blind_ev; - struct TALER_ReserveSignature reserve_sig; + struct TALER_ReserveSignatureP reserve_sig; struct CollectableBlindcoin *cbc; char *denom_pub_enc; char *denom_sig_enc; size_t denom_pub_enc_size; size_t denom_sig_enc_size; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (reserve_pub), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (reserve_pub), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "get_reserves_blindcoins", params); if (PGRES_TUPLES_OK != PQresultStatus (result)) @@ -1256,19 +1256,19 @@ postgres_get_reserve_history (void *cls, ret = GNUNET_OK; /* Its OK if there are no withdrawls yet */ goto cleanup; } - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC ("blind_ev", &blind_ev), - TALER_DB_RESULT_SPEC_VAR ("denom_pub", &denom_pub_enc, &denom_pub_enc_size), - TALER_DB_RESULT_SPEC_VAR ("denom_sig", &denom_sig_enc, &denom_sig_enc_size), - TALER_DB_RESULT_SPEC ("reserve_sig", &reserve_sig), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC ("blind_ev", &blind_ev), + TALER_PQ_RESULT_SPEC_VAR ("denom_pub", &denom_pub_enc, &denom_pub_enc_size), + TALER_PQ_RESULT_SPEC_VAR ("denom_sig", &denom_sig_enc, &denom_sig_enc_size), + TALER_PQ_RESULT_SPEC ("reserve_sig", &reserve_sig), + TALER_PQ_RESULT_SPEC_END }; GNUNET_assert (NULL != rh); GNUNET_assert (NULL != rh_head); GNUNET_assert (NULL == rh_head->next); while (0 < rows) { - if (GNUNET_YES != TALER_DB_extract_result (result, rs, --rows)) + if (GNUNET_YES != TALER_PQ_extract_result (result, rs, --rows)) { GNUNET_break (0); goto cleanup; @@ -1333,17 +1333,17 @@ postgres_have_deposit (void *cls, struct TALER_MINTDB_Session *session, const struct Deposit *deposit) { - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (&deposit->coin.coin_pub), - TALER_DB_QUERY_PARAM_PTR (&deposit->transaction_id), - TALER_DB_QUERY_PARAM_PTR (&deposit->merchant_pub), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (&deposit->coin.coin_pub), + TALER_PQ_QUERY_PARAM_PTR (&deposit->transaction_id), + TALER_PQ_QUERY_PARAM_PTR (&deposit->merchant_pub), + TALER_PQ_QUERY_PARAM_END }; PGresult *result; int ret; ret = GNUNET_SYSERR; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "get_deposit", params); if (PGRES_TUPLES_OK != @@ -1399,24 +1399,24 @@ postgres_insert_deposit (void *cls, json_wire_enc = json_dumps (deposit->wire, JSON_COMPACT); TALER_amount_hton (&amount_nbo, &deposit->amount_with_fee); - struct TALER_DB_QueryParam params[]= { - TALER_DB_QUERY_PARAM_PTR (&deposit->coin.coin_pub), - TALER_DB_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size), - TALER_DB_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size), - TALER_DB_QUERY_PARAM_PTR (&deposit->transaction_id), - TALER_DB_QUERY_PARAM_PTR (&amount_nbo.value), - TALER_DB_QUERY_PARAM_PTR (&amount_nbo.fraction), - TALER_DB_QUERY_PARAM_PTR_SIZED (amount_nbo.currency, + struct TALER_PQ_QueryParam params[]= { + TALER_PQ_QUERY_PARAM_PTR (&deposit->coin.coin_pub), + TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size), + TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size), + TALER_PQ_QUERY_PARAM_PTR (&deposit->transaction_id), + TALER_PQ_QUERY_PARAM_PTR (&amount_nbo.value), + TALER_PQ_QUERY_PARAM_PTR (&amount_nbo.fraction), + TALER_PQ_QUERY_PARAM_PTR_SIZED (amount_nbo.currency, TALER_CURRENCY_LEN - 1), - TALER_DB_QUERY_PARAM_PTR (&deposit->merchant_pub), - TALER_DB_QUERY_PARAM_PTR (&deposit->h_contract), - TALER_DB_QUERY_PARAM_PTR (&deposit->h_wire), - TALER_DB_QUERY_PARAM_PTR (&deposit->csig), - TALER_DB_QUERY_PARAM_PTR_SIZED (json_wire_enc, + TALER_PQ_QUERY_PARAM_PTR (&deposit->merchant_pub), + TALER_PQ_QUERY_PARAM_PTR (&deposit->h_contract), + TALER_PQ_QUERY_PARAM_PTR (&deposit->h_wire), + TALER_PQ_QUERY_PARAM_PTR (&deposit->csig), + TALER_PQ_QUERY_PARAM_PTR_SIZED (json_wire_enc, strlen (json_wire_enc)), - TALER_DB_QUERY_PARAM_END + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, "insert_deposit", params); + result = TALER_PQ_exec_prepared (session->conn, "insert_deposit", params); if (PGRES_COMMAND_OK != PQresultStatus (result)) { BREAK_DB_ERR (result); @@ -1452,12 +1452,12 @@ postgres_get_refresh_session (void *cls, { // FIXME: check logic! int res; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_END }; - PGresult *result = TALER_DB_exec_prepared (session->conn, + PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_refresh_session", params); @@ -1483,14 +1483,14 @@ postgres_get_refresh_session (void *cls, memset (session, 0, sizeof (struct RefreshSession)); - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC("num_oldcoins", &refresh_session->num_oldcoins), - TALER_DB_RESULT_SPEC("num_newcoins", &refresh_session->num_newcoins), - TALER_DB_RESULT_SPEC("noreveal_index", &refresh_session->noreveal_index), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC("num_oldcoins", &refresh_session->num_oldcoins), + TALER_PQ_RESULT_SPEC("num_newcoins", &refresh_session->num_newcoins), + TALER_PQ_RESULT_SPEC("noreveal_index", &refresh_session->noreveal_index), + TALER_PQ_RESULT_SPEC_END }; - res = TALER_DB_extract_result (result, rs, 0); + res = TALER_PQ_extract_result (result, rs, 0); if (GNUNET_OK != res) { @@ -1526,16 +1526,16 @@ postgres_create_refresh_session (void *cls, { // FIXME: actually store session data! uint16_t noreveal_index; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_PTR(&noreveal_index), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_PTR(&noreveal_index), + TALER_PQ_QUERY_PARAM_END }; noreveal_index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1<<15); noreveal_index = htonl (noreveal_index); - PGresult *result = TALER_DB_exec_prepared (session->conn, + PGresult *result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_session", params); @@ -1577,14 +1577,14 @@ postgres_insert_refresh_melt (void *cls, buf_size = GNUNET_CRYPTO_rsa_public_key_encode (melt->coin.denom_pub.rsa_public_key, &buf); { - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(&melt->session_hash), - TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo), - TALER_DB_QUERY_PARAM_PTR(&melt->coin.coin_pub), - TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(&melt->session_hash), + TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo), + TALER_PQ_QUERY_PARAM_PTR(&melt->coin.coin_pub), + TALER_PQ_QUERY_PARAM_PTR_SIZED(buf, buf_size), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_melt", params); } @@ -1653,13 +1653,13 @@ postgres_insert_refresh_order (void *cls, &buf); { - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (&newcoin_index_nbo), - TALER_DB_QUERY_PARAM_PTR (session_hash), - TALER_DB_QUERY_PARAM_PTR_SIZED (buf, buf_size), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR (&newcoin_index_nbo), + TALER_PQ_QUERY_PARAM_PTR (session_hash), + TALER_PQ_QUERY_PARAM_PTR_SIZED (buf, buf_size), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_order", params); } @@ -1704,13 +1704,13 @@ postgres_get_refresh_order (void *cls, size_t buf_size; uint16_t newcoin_index_nbo = htons (num_newcoins); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), + TALER_PQ_QUERY_PARAM_END }; - PGresult *result = TALER_DB_exec_prepared (session->conn, + PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_refresh_order", params); if (PGRES_TUPLES_OK != PQresultStatus (result)) @@ -1727,11 +1727,11 @@ postgres_get_refresh_order (void *cls, return GNUNET_SYSERR; } GNUNET_assert (1 == PQntuples (result)); - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC_VAR ("denom_pub", &buf, &buf_size), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC_VAR ("denom_pub", &buf, &buf_size), + TALER_PQ_RESULT_SPEC_END }; - if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0)) + if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)) { PQclear (result); GNUNET_break (0); @@ -1771,18 +1771,18 @@ postgres_insert_refresh_commit_coins (void *cls, // FIXME: check logic! -- was written for single commit_coin! uint16_t cnc_index_nbo = htons (i); uint16_t newcoin_index_nbo = htons (num_newcoins); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size), - TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_DB_QUERY_PARAM_PTR_SIZED (commit_coins->refresh_link->coin_priv_enc, + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size), + TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), + TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), + TALER_PQ_QUERY_PARAM_PTR_SIZED (commit_coins->refresh_link->coin_priv_enc, commit_coins->refresh_link->blinding_key_enc_size + - sizeof (struct TALER_CoinSpendPrivateKey)), - TALER_DB_QUERY_PARAM_END + sizeof (union TALER_CoinSpendPrivateKeyP)), + TALER_PQ_QUERY_PARAM_END }; - PGresult *result = TALER_DB_exec_prepared (session->conn, + PGresult *result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_commit_coin", params); @@ -1829,11 +1829,11 @@ postgres_get_refresh_commit_coins (void *cls, // FIXME: check logic! uint16_t cnc_index_nbo = htons (cnc_index); uint16_t newcoin_index_nbo = htons (newcoin_index); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), + TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), + TALER_PQ_QUERY_PARAM_END }; char *c_buf; size_t c_buf_size; @@ -1841,7 +1841,7 @@ postgres_get_refresh_commit_coins (void *cls, size_t rl_buf_size; struct TALER_RefreshLinkEncrypted *rl; - PGresult *result = TALER_DB_exec_prepared (session->conn, + PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_refresh_commit_coin", params); @@ -1858,18 +1858,18 @@ postgres_get_refresh_commit_coins (void *cls, return GNUNET_NO; } - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC_VAR("coin_ev", &c_buf, &c_buf_size), - TALER_DB_RESULT_SPEC_VAR("link_vector_enc", &rl_buf, &rl_buf_size), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC_VAR("coin_ev", &c_buf, &c_buf_size), + TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &rl_buf, &rl_buf_size), + TALER_PQ_RESULT_SPEC_END }; - if (GNUNET_YES != TALER_DB_extract_result (result, rs, 0)) + if (GNUNET_YES != TALER_PQ_extract_result (result, rs, 0)) { PQclear (result); return GNUNET_SYSERR; } PQclear (result); - if (rl_buf_size < sizeof (struct TALER_CoinSpendPrivateKey)) + if (rl_buf_size < sizeof (union TALER_CoinSpendPrivateKeyP)) { GNUNET_free (c_buf); GNUNET_free (rl_buf); @@ -1908,16 +1908,16 @@ postgres_insert_refresh_commit_links (void *cls, // FIXME: check logic! uint16_t cnc_index_nbo = htons (i); uint16_t oldcoin_index_nbo = htons (j); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_PTR(&commit_link->transfer_pub), - TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo), - TALER_DB_QUERY_PARAM_PTR(&commit_link->shared_secret_enc), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_PTR(&commit_link->transfer_pub), + TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), + TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo), + TALER_PQ_QUERY_PARAM_PTR(&commit_link->shared_secret_enc), + TALER_PQ_QUERY_PARAM_END }; - PGresult *result = TALER_DB_exec_prepared (session->conn, + PGresult *result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_commit_link", params); if (PGRES_COMMAND_OK != PQresultStatus (result)) @@ -1964,14 +1964,14 @@ postgres_get_refresh_commit_links (void *cls, uint16_t cnc_index_nbo = htons (i); uint16_t oldcoin_index_nbo = htons (num_links); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), + TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo), + TALER_PQ_QUERY_PARAM_END }; - PGresult *result = TALER_DB_exec_prepared (session->conn, + PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_refresh_commit_link", params); if (PGRES_TUPLES_OK != PQresultStatus (result)) @@ -1987,13 +1987,13 @@ postgres_get_refresh_commit_links (void *cls, return GNUNET_NO; } - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC("transfer_pub", &links->transfer_pub), - TALER_DB_RESULT_SPEC("link_secret_enc", &links->shared_secret_enc), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC("transfer_pub", &links->transfer_pub), + TALER_PQ_RESULT_SPEC("link_secret_enc", &links->shared_secret_enc), + TALER_PQ_RESULT_SPEC_END }; - if (GNUNET_YES != TALER_DB_extract_result (result, rs, 0)) + if (GNUNET_YES != TALER_PQ_extract_result (result, rs, 0)) { PQclear (result); return GNUNET_SYSERR; @@ -2033,13 +2033,13 @@ postgres_insert_refresh_collectable (void *cls, buf_size = GNUNET_CRYPTO_rsa_signature_encode (ev_sig->rsa_signature, &buf); { - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(session_hash), - TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(session_hash), + TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), + TALER_PQ_QUERY_PARAM_PTR_SIZED(buf, buf_size), + TALER_PQ_QUERY_PARAM_END }; - result = TALER_DB_exec_prepared (session->conn, + result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_collectable", params); } @@ -2067,16 +2067,16 @@ postgres_insert_refresh_collectable (void *cls, static struct LinkDataList * postgres_get_link_data_list (void *cls, struct TALER_MINTDB_Session *session, - const struct TALER_CoinSpendPublicKey *coin_pub) + const union TALER_CoinSpendPublicKeyP *coin_pub) { // FIXME: check logic! struct LinkDataList *ldl; struct LinkDataList *pos; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(coin_pub), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(coin_pub), + TALER_PQ_QUERY_PARAM_END }; - PGresult *result = TALER_DB_exec_prepared (session->conn, "get_link", params); + PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_link", params); ldl = NULL; if (PGRES_TUPLES_OK != PQresultStatus (result)) @@ -2106,14 +2106,14 @@ postgres_get_link_data_list (void *cls, size_t pk_buf_size; char *sig_buf; size_t sig_buf_size; - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size), - TALER_DB_RESULT_SPEC_VAR("denom_pub", &pk_buf, &pk_buf_size), - TALER_DB_RESULT_SPEC_VAR("ev_sig", &sig_buf, &sig_buf_size), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size), + TALER_PQ_RESULT_SPEC_VAR("denom_pub", &pk_buf, &pk_buf_size), + TALER_PQ_RESULT_SPEC_VAR("ev_sig", &sig_buf, &sig_buf_size), + TALER_PQ_RESULT_SPEC_END }; - if (GNUNET_OK != TALER_DB_extract_result (result, rs, i)) + if (GNUNET_OK != TALER_PQ_extract_result (result, rs, i)) { PQclear (result); GNUNET_break (0); @@ -2192,17 +2192,17 @@ postgres_get_link_data_list (void *cls, static int postgres_get_transfer (void *cls, struct TALER_MINTDB_Session *session, - const struct TALER_CoinSpendPublicKey *coin_pub, - struct TALER_TransferPublicKey *transfer_pub, - struct TALER_EncryptedLinkSecret *shared_secret_enc) + const union TALER_CoinSpendPublicKeyP *coin_pub, + struct TALER_TransferPublicKeyP *transfer_pub, + struct TALER_EncryptedLinkSecretP *shared_secret_enc) { // FIXME: check logic! - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(coin_pub), - TALER_DB_QUERY_PARAM_END + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_QUERY_PARAM_PTR(coin_pub), + TALER_PQ_QUERY_PARAM_END }; - PGresult *result = TALER_DB_exec_prepared (session->conn, "get_transfer", params); + PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_transfer", params); if (PGRES_TUPLES_OK != PQresultStatus (result)) { @@ -2226,13 +2226,13 @@ postgres_get_transfer (void *cls, return GNUNET_SYSERR; } - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC("transfer_pub", transfer_pub), - TALER_DB_RESULT_SPEC("link_secret_enc", shared_secret_enc), - TALER_DB_RESULT_SPEC_END + struct TALER_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC("transfer_pub", transfer_pub), + TALER_PQ_RESULT_SPEC("link_secret_enc", shared_secret_enc), + TALER_PQ_RESULT_SPEC_END }; - if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0)) + if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)) { PQclear (result); GNUNET_break (0); @@ -2256,7 +2256,7 @@ postgres_get_transfer (void *cls, static struct TALER_MINT_DB_TransactionList * postgres_get_coin_transactions (void *cls, struct TALER_MINTDB_Session *session, - const struct TALER_CoinSpendPublicKey *coin_pub) + const union TALER_CoinSpendPublicKeyP *coin_pub) { // FIXME: check logic! GNUNET_break (0); // FIXME: implement! @@ -2283,14 +2283,14 @@ libtaler_plugin_mintdb_postgres_init (void *cls) if (0 != pthread_key_create (&pg->db_conn_threadlocal, &db_conn_destroy)) { - LOG_ERROR ("Cannnot create pthread key.\n"); + TALER_LOG_ERROR ("Cannnot create pthread key.\n"); return NULL; } /* FIXME: use configuration section with "postgres" in its name... */ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "mint", "db_conn_str", - &pg->TALER_MINT_db_connection_cfg_str)) + &pg->connection_cfg_str)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "mint", @@ -2348,7 +2348,7 @@ libtaler_plugin_mintdb_postgres_done (void *cls) struct TALER_MINTDB_Plugin *plugin = cls; struct PostgresClosure *pg = plugin->cls; - GNUNET_free (pg->TALER_MINT_db_connection_cfg_str); + GNUNET_free (pg->connection_cfg_str); GNUNET_free (pg); GNUNET_free (plugin); return NULL; diff --git a/src/mint/taler-mint-httpd.c b/src/mint/taler-mint-httpd.c index 70d3b64f0..13c77b033 100644 --- a/src/mint/taler-mint-httpd.c +++ b/src/mint/taler-mint-httpd.c @@ -42,7 +42,7 @@ /** * Base directory of the mint (global) */ -char *mintdir; +char *TMH_mint_directory; /** * The mint's configuration (global) @@ -53,12 +53,12 @@ struct GNUNET_CONFIGURATION_Handle *cfg; * Master public key (according to the * configuration in the mint directory). */ -struct GNUNET_CRYPTO_EddsaPublicKey master_pub; +struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key; /** * In which format does this MINT expect wiring instructions? */ -char *expected_wire_format = "sepa"; +char *TMH_expected_wire_format = "sepa"; /** * The HTTP Daemon. @@ -98,7 +98,7 @@ handle_mhd_completion_callback (void *cls, { if (NULL == *con_cls) return; - TALER_MINT_parse_post_cleanup_callback (*con_cls); + TMH_PARSE_post_cleanup_callback (*con_cls); *con_cls = NULL; } @@ -125,71 +125,71 @@ handle_mhd_request (void *cls, size_t *upload_data_size, void **con_cls) { - static struct RequestHandler handlers[] = + static struct TMH_RequestHandler handlers[] = { { "/", MHD_HTTP_METHOD_GET, "text/plain", "Hello, I'm the mint\n", 0, - &TALER_MINT_handler_static_response, MHD_HTTP_OK }, + &TMH_MHD_handler_static_response, MHD_HTTP_OK }, { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", NULL, 0, - &TALER_MINT_handler_agpl_redirect, MHD_HTTP_FOUND }, + &TMH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, { "/keys", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, - &TALER_MINT_handler_keys, MHD_HTTP_OK }, + &TMH_KS_handler_keys, MHD_HTTP_OK }, { "/keys", NULL, "text/plain", "Only GET is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/withdraw/status", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, - &TALER_MINT_handler_withdraw_status, MHD_HTTP_OK }, + &TMH_WITHDRAW_handler_withdraw_status, MHD_HTTP_OK }, { "/withdraw/status", NULL, "text/plain", "Only GET is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/withdraw/sign", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, - &TALER_MINT_handler_withdraw_sign, MHD_HTTP_OK }, + &TMH_WITHDRAW_handler_withdraw_sign, MHD_HTTP_OK }, { "/withdraw/sign", NULL, "text/plain", "Only GET is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json", NULL, 0, - &TALER_MINT_handler_refresh_melt, MHD_HTTP_OK }, + &TMH_REFRESH_handler_refresh_melt, MHD_HTTP_OK }, { "/refresh/melt", NULL, "text/plain", "Only POST is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", NULL, 0, - &TALER_MINT_handler_refresh_melt, MHD_HTTP_OK }, + &TMH_REFRESH_handler_refresh_melt, MHD_HTTP_OK }, { "/refresh/reveal", NULL, "text/plain", "Only POST is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/refresh/link", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, - &TALER_MINT_handler_refresh_link, MHD_HTTP_OK }, + &TMH_REFRESH_handler_refresh_link, MHD_HTTP_OK }, { "/refresh/link", NULL, "text/plain", "Only GET is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/refresh/reveal", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, - &TALER_MINT_handler_refresh_reveal, MHD_HTTP_OK }, + &TMH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, { "/refresh/reveal", NULL, "text/plain", "Only GET is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/deposit", MHD_HTTP_METHOD_POST, "application/json", NULL, 0, - &TALER_MINT_handler_deposit, MHD_HTTP_OK }, + &TMH_DEPOSIT_handler_deposit, MHD_HTTP_OK }, { "/deposit", NULL, "text/plain", "Only POST is allowed", 0, - &TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { NULL, NULL, NULL, NULL, 0, 0 } }; - static struct RequestHandler h404 = + static struct TMH_RequestHandler h404 = { "", NULL, "text/html", "404: not found", 0, - &TALER_MINT_handler_static_response, MHD_HTTP_NOT_FOUND + &TMH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND }; - struct RequestHandler *rh; + struct TMH_RequestHandler *rh; unsigned int i; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -209,7 +209,7 @@ handle_mhd_request (void *cls, upload_data, upload_data_size); } - return TALER_MINT_handler_static_response (&h404, + return TMH_MHD_handler_static_response (&h404, connection, con_cls, upload_data, @@ -229,7 +229,7 @@ mint_serve_process_config (const char *mint_directory) { unsigned long long port; unsigned long long kappa; - char *master_pub_str; + char *TMH_master_public_key_str; cfg = TALER_config_load (mint_directory); if (NULL == cfg) @@ -240,24 +240,25 @@ mint_serve_process_config (const char *mint_directory) } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, - "mint", "master_pub", - &master_pub_str)) + "mint", + "master_public_key", + &TMH_master_public_key_str)) { fprintf (stderr, "No master public key given in mint configuration."); return GNUNET_NO; } if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_public_key_from_string (master_pub_str, - strlen (master_pub_str), - &master_pub)) + GNUNET_CRYPTO_eddsa_public_key_from_string (TMH_master_public_key_str, + strlen (TMH_master_public_key_str), + &TMH_master_public_key)) { fprintf (stderr, "Invalid master public key given in mint configuration."); - GNUNET_free (master_pub_str); + GNUNET_free (TMH_master_public_key_str); return GNUNET_NO; } - GNUNET_free (master_pub_str); + GNUNET_free (TMH_master_public_key_str); if (GNUNET_OK != TALER_MINT_plugin_load (cfg)) @@ -314,7 +315,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-keyup OPTIONS"), {'d', "mint-dir", "DIR", "mint directory", 1, - &GNUNET_GETOPT_set_filename, &mintdir}, + &GNUNET_GETOPT_set_filename, &TMH_mint_directory}, GNUNET_GETOPT_OPTION_END }; int ret; @@ -327,14 +328,14 @@ main (int argc, char *const *argv) options, argc, argv) < 0) return 1; - if (NULL == mintdir) + if (NULL == TMH_mint_directory) { fprintf (stderr, "no mint dir given\n"); return 1; } - if (GNUNET_OK != mint_serve_process_config (mintdir)) + if (GNUNET_OK != mint_serve_process_config (TMH_mint_directory)) return 1; @@ -352,7 +353,7 @@ main (int argc, char *const *argv) return 1; } - ret = TALER_MINT_key_reload_loop (); + ret = TMH_KS_loop (); MHD_stop_daemon (mydaemon); return (GNUNET_OK == ret) ? 0 : 1; } diff --git a/src/mint/taler-mint-httpd.h b/src/mint/taler-mint-httpd.h index 50b745703..92ce54b84 100644 --- a/src/mint/taler-mint-httpd.h +++ b/src/mint/taler-mint-httpd.h @@ -29,7 +29,7 @@ * For now, we just do EUR. Should become configurable * in the future! */ -#define MINT_CURRENCY "EUR" +#define TMH_MINT_CURRENCY "EUR" /** @@ -41,29 +41,29 @@ extern struct GNUNET_CONFIGURATION_Handle *cfg; * Main directory with mint data. * FIXME: should we have those globals really here? */ -extern char *mintdir; +extern char *TMH_mint_directory; /** * In which format does this MINT expect wiring instructions? */ -extern char *expected_wire_format; +extern char *TMH_expected_wire_format; /** * Master public key (according to the * configuration in the mint directory). */ -extern struct GNUNET_CRYPTO_EddsaPublicKey master_pub; +extern struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key; /** * Private key of the mint we use to sign messages. */ -extern struct GNUNET_CRYPTO_EddsaPrivateKey mint_priv; +extern struct GNUNET_CRYPTO_EddsaPrivateKey TMH_mint_private_signing_key; /** * Struct describing an URL and the handler for it. */ -struct RequestHandler +struct TMH_RequestHandler { /** @@ -102,7 +102,7 @@ struct RequestHandler * @param[IN|OUT] upload_data_size number of bytes (left) in @a upload_data * @return MHD result code */ - int (*handler)(struct RequestHandler *rh, + int (*handler)(struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index 17f44c9c9..2fdd87188 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -98,29 +98,29 @@ calculate_transaction_list_totals (struct TALER_MINT_DB_TransactionList *tl, * @return MHD result code */ int -TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, +TMH_DB_execute_deposit (struct MHD_Connection *connection, const struct Deposit *deposit) { struct TALER_MINTDB_Session *session; struct TALER_MINT_DB_TransactionList *tl; struct TALER_Amount spent; struct TALER_Amount value; - struct MintKeyState *mks; - struct TALER_MINT_DenomKeyIssuePriv *dki; + struct TMH_KS_StateHandle *mks; + struct TALER_DenominationKeyIssueInformation *dki; int ret; if (NULL == (session = plugin->get_session (plugin->cls, GNUNET_NO))) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } if (GNUNET_YES == plugin->have_deposit (plugin->cls, session, deposit)) { - return TALER_MINT_reply_deposit_success (connection, + return TMH_RESPONSE_reply_deposit_success (connection, &deposit->coin.coin_pub, &deposit->h_wire, &deposit->h_contract, @@ -128,19 +128,19 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, &deposit->merchant_pub, &deposit->amount_with_fee); } - mks = TALER_MINT_key_state_acquire (); - dki = TALER_MINT_get_denom_key (mks, + mks = TMH_KS_acquire (); + dki = TMH_KS_denomination_key_lookup (mks, &deposit->coin.denom_pub); TALER_amount_ntoh (&value, &dki->issue.value); - TALER_MINT_key_state_release (mks); + TMH_KS_release (mks); if (GNUNET_OK != plugin->start (plugin->cls, session)) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } /* fee for THIS transaction */ spent = deposit->amount_with_fee; @@ -155,7 +155,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, { plugin->free_coin_transaction_list (plugin->cls, tl); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } /* Check that cost of all transactions is smaller than the value of the coin. */ @@ -164,7 +164,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - ret = TALER_MINT_reply_deposit_insufficient_funds (connection, + ret = TMH_RESPONSE_reply_deposit_insufficient_funds (connection, tl); plugin->free_coin_transaction_list (plugin->cls, tl); @@ -178,20 +178,20 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, session, deposit)) { - LOG_WARNING ("Failed to store /deposit information in database\n"); + TALER_LOG_WARNING ("Failed to store /deposit information in database\n"); plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } if (GNUNET_OK != plugin->commit (plugin->cls, session)) { - LOG_WARNING ("/deposit transaction commit failed\n"); - return TALER_MINT_reply_commit_error (connection); + TALER_LOG_WARNING ("/deposit transaction commit failed\n"); + return TMH_RESPONSE_reply_commit_error (connection); } - return TALER_MINT_reply_deposit_success (connection, + return TMH_RESPONSE_reply_deposit_success (connection, &deposit->coin.coin_pub, &deposit->h_wire, &deposit->h_contract, @@ -210,8 +210,8 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, - const struct TALER_ReservePublicKey *reserve_pub) +TMH_DB_execute_withdraw_status (struct MHD_Connection *connection, + const struct TALER_ReservePublicKeyP *reserve_pub) { struct TALER_MINTDB_Session *session; struct ReserveHistory *rh; @@ -221,17 +221,17 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, GNUNET_NO))) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } rh = plugin->get_reserve_history (plugin->cls, session, reserve_pub); if (NULL == rh) - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", "Reserve not found"); - res = TALER_MINT_reply_withdraw_status_success (connection, + res = TMH_RESPONSE_reply_withdraw_status_success (connection, rh); plugin->free_reserve_history (plugin->cls, rh); @@ -254,20 +254,20 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, - const struct TALER_ReservePublicKey *reserve, +TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection, + const struct TALER_ReservePublicKeyP *reserve, const struct TALER_DenominationPublicKey *denomination_pub, const char *blinded_msg, size_t blinded_msg_len, - const struct TALER_ReserveSignature *signature) + const struct TALER_ReserveSignatureP *signature) { struct TALER_MINTDB_Session *session; struct ReserveHistory *rh; const struct ReserveHistory *pos; - struct MintKeyState *key_state; + struct TMH_KS_StateHandle *key_state; struct CollectableBlindcoin collectable; - struct TALER_MINT_DenomKeyIssuePriv *dki; - struct TALER_MINT_DenomKeyIssuePriv *tdki; + struct TALER_DenominationKeyIssueInformation *dki; + struct TALER_DenominationKeyIssueInformation *tdki; struct GNUNET_CRYPTO_rsa_Signature *sig; struct TALER_Amount amount_required; struct TALER_Amount deposit_total; @@ -286,7 +286,7 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, GNUNET_NO))) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } res = plugin->get_collectable_blindcoin (plugin->cls, session, @@ -295,13 +295,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, if (GNUNET_SYSERR == res) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } /* Don't sign again if we have already signed the coin */ if (GNUNET_YES == res) { - res = TALER_MINT_reply_withdraw_sign_success (connection, + res = TMH_RESPONSE_reply_withdraw_sign_success (connection, &collectable); GNUNET_CRYPTO_rsa_signature_free (collectable.sig.rsa_signature); GNUNET_CRYPTO_rsa_public_key_free (collectable.denom_pub.rsa_public_key); @@ -310,13 +310,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, GNUNET_assert (GNUNET_NO == res); /* Check if balance is sufficient */ - key_state = TALER_MINT_key_state_acquire (); - dki = TALER_MINT_get_denom_key (key_state, + key_state = TMH_KS_acquire (); + dki = TMH_KS_denomination_key_lookup (key_state, denomination_pub); if (NULL == dki) { - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_json_pack (connection, + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", @@ -327,8 +327,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, session)) { GNUNET_break (0); - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_internal_db_error (connection); + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_internal_db_error (connection); } rh = plugin->get_reserve_history (plugin->cls, @@ -338,8 +338,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_json_pack (connection, + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", @@ -359,8 +359,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_internal_db_error (connection); + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_internal_db_error (connection); } /* calculate balance of the reserve */ @@ -380,13 +380,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_internal_db_error (connection); + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_internal_db_error (connection); } res |= 1; break; case TALER_MINT_DB_RO_WITHDRAW_COIN: - tdki = TALER_MINT_get_denom_key (key_state, + tdki = TMH_KS_denomination_key_lookup (key_state, &pos->details.withdraw->denom_pub); TALER_amount_ntoh (&value, &tdki->issue.value); @@ -400,8 +400,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_internal_db_error (connection); + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_internal_db_error (connection); } res |= 2; break; @@ -415,10 +415,10 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, if (0 < TALER_amount_cmp (&amount_required, &balance)) { - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); plugin->rollback (plugin->cls, session); - res = TALER_MINT_reply_withdraw_sign_insufficient_funds (connection, + res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection, rh); plugin->free_reserve_history (plugin->cls, rh); @@ -431,13 +431,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, blinded_msg, blinded_msg_len); - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); if (NULL == sig) { GNUNET_break (0); plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_error (connection, + return TMH_RESPONSE_reply_internal_error (connection, "Internal error"); } collectable.sig.rsa_signature = sig; @@ -458,16 +458,16 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, GNUNET_CRYPTO_rsa_signature_free (sig); plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } if (GNUNET_OK != plugin->commit (plugin->cls, session)) { - LOG_WARNING ("/withdraw/sign transaction commit failed\n"); - return TALER_MINT_reply_commit_error (connection); + TALER_LOG_WARNING ("/withdraw/sign transaction commit failed\n"); + return TMH_RESPONSE_reply_commit_error (connection); } - res = TALER_MINT_reply_withdraw_sign_success (connection, + res = TMH_RESPONSE_reply_withdraw_sign_success (connection, &collectable); GNUNET_CRYPTO_rsa_signature_free (sig); return res; @@ -492,13 +492,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, static int refresh_accept_melts (struct MHD_Connection *connection, struct TALER_MINTDB_Session *session, - const struct MintKeyState *key_state, + const struct TMH_KS_StateHandle *key_state, const struct GNUNET_HashCode *session_hash, const struct TALER_CoinPublicInfo *coin_public_info, - const struct MeltDetails *coin_details, + const struct TMH_DB_MeltDetails *coin_details, uint16_t oldcoin_index) { - struct TALER_MINT_DenomKeyIssue *dki; + struct TALER_DenominationKeyValidityPS *dki; struct TALER_MINT_DB_TransactionList *tl; struct TALER_Amount coin_value; struct TALER_Amount coin_residual; @@ -506,12 +506,12 @@ refresh_accept_melts (struct MHD_Connection *connection, struct RefreshMelt melt; int res; - dki = &TALER_MINT_get_denom_key (key_state, + dki = &TMH_KS_denomination_key_lookup (key_state, &coin_public_info->denom_pub)->issue; if (NULL == dki) return (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", @@ -534,7 +534,7 @@ refresh_accept_melts (struct MHD_Connection *connection, GNUNET_break (0); plugin->free_coin_transaction_list (plugin->cls, tl); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } /* Refuse to refresh when the coin's value is insufficient for the cost of all transactions. */ @@ -546,7 +546,7 @@ refresh_accept_melts (struct MHD_Connection *connection, &spent, &coin_details->melt_amount_with_fee)); res = (MHD_YES == - TALER_MINT_reply_refresh_melt_insufficient_funds (connection, + TMH_RESPONSE_reply_refresh_melt_insufficient_funds (connection, &coin_public_info->coin_pub, coin_value, tl, @@ -593,25 +593,25 @@ refresh_accept_melts (struct MHD_Connection *connection, * @param coin_melt_details signatures and (residual) value of the respective coin should be melted * @param commit_coin 2d array of coin commitments (what the mint is to sign * once the "/refres/reveal" of cut and choose is done), - * x-dimension must be #KAPPA + * x-dimension must be #TALER_CNC_KAPPA * @param commit_link 2d array of coin link commitments (what the mint is * to return via "/refresh/link" to enable linkage in the * future) - * x-dimension must be #KAPPA + * x-dimension must be #TALER_CNC_KAPPA * @return MHD result code */ int -TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, +TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, unsigned int num_new_denoms, const struct TALER_DenominationPublicKey *denom_pubs, unsigned int coin_count, const struct TALER_CoinPublicInfo *coin_public_infos, - const struct MeltDetails *coin_melt_details, + const struct TMH_DB_MeltDetails *coin_melt_details, struct RefreshCommitCoin *const* commit_coin, struct RefreshCommitLink *const* commit_link) { - struct MintKeyState *key_state; + struct TMH_KS_StateHandle *key_state; struct RefreshSession refresh_session; struct TALER_MINTDB_Session *session; int res; @@ -621,14 +621,14 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, GNUNET_NO))) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } if (GNUNET_OK != plugin->start (plugin->cls, session)) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } res = plugin->get_refresh_session (plugin->cls, session, @@ -638,7 +638,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - res = TALER_MINT_reply_refresh_melt_success (connection, + res = TMH_RESPONSE_reply_refresh_melt_success (connection, session_hash, refresh_session.noreveal_index); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; @@ -647,11 +647,11 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } /* Melt old coins and check that they had enough residual value */ - key_state = TALER_MINT_key_state_acquire (); + key_state = TMH_KS_acquire (); for (i=0;irollback (plugin->cls, session); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } } - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); /* store requested new denominations */ if (GNUNET_OK != @@ -681,10 +681,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } - for (i = 0; i < KAPPA; i++) + for (i = 0; i < TALER_CNC_KAPPA; i++) { if (GNUNET_OK != plugin->insert_refresh_commit_coins (plugin->cls, @@ -696,10 +696,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } } - for (i = 0; i < KAPPA; i++) + for (i = 0; i < TALER_CNC_KAPPA; i++) { if (GNUNET_OK != plugin->insert_refresh_commit_links (plugin->cls, @@ -711,7 +711,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } } @@ -721,7 +721,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, refresh_session.num_newcoins = num_new_denoms; refresh_session.noreveal_index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, - KAPPA); + TALER_CNC_KAPPA); if (GNUNET_OK != (res = plugin->create_refresh_session (plugin->cls, session, @@ -730,7 +730,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, { plugin->rollback (plugin->cls, session); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } @@ -739,10 +739,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, plugin->commit (plugin->cls, session)) { - LOG_WARNING ("/refresh/melt transaction commit failed\n"); - return TALER_MINT_reply_commit_error (connection); + TALER_LOG_WARNING ("/refresh/melt transaction commit failed\n"); + return TMH_RESPONSE_reply_commit_error (connection); } - return TALER_MINT_reply_refresh_melt_success (connection, + return TMH_RESPONSE_reply_refresh_melt_success (connection, session_hash, refresh_session.noreveal_index); } @@ -752,7 +752,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, * Check if the given @a transfer_privs correspond to an honest * commitment for the given session. * Checks that the transfer private keys match their commitments. - * Then derives the shared secret for each #KAPPA, and check that they match. + * Then derives the shared secret for each #TALER_CNC_KAPPA, and check that they match. * * @param connection the MHD connection to handle * @param session database connection to use @@ -773,13 +773,13 @@ check_commitment (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, unsigned int off, unsigned int num_oldcoins, - const struct TALER_TransferPrivateKey *transfer_privs, + const struct TALER_TransferPrivateKeyP *transfer_privs, const struct RefreshMelt *melts, unsigned int num_newcoins, const struct TALER_DenominationPublicKey *denom_pubs) { unsigned int j; - struct TALER_LinkSecret last_shared_secret; + struct TALER_LinkSecretP last_shared_secret; int secret_initialized = GNUNET_NO; struct GNUNET_CRYPTO_EcdhePublicKey coin_ecdhe; struct GNUNET_CRYPTO_EcdhePrivateKey transfer_ecdhe; @@ -798,29 +798,29 @@ check_commitment (struct MHD_Connection *connection, { GNUNET_break (0); GNUNET_free (commit_links); - return (MHD_YES == TALER_MINT_reply_internal_db_error (connection)) + return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection)) ? GNUNET_NO : GNUNET_SYSERR; } for (j = 0; j < num_oldcoins; j++) { - struct TALER_TransferSecret transfer_secret; - struct TALER_LinkSecret shared_secret; - struct TALER_TransferPublicKey transfer_pub_check; + struct TALER_TransferSecretP transfer_secret; + struct TALER_LinkSecretP shared_secret; + struct TALER_TransferPublicKeyP transfer_pub_check; GNUNET_CRYPTO_ecdsa_key_get_public (&transfer_privs[j].ecdsa_priv, &transfer_pub_check.ecdsa_pub); if (0 != memcmp (&transfer_pub_check, &commit_links[j].transfer_pub, - sizeof (struct TALER_TransferPublicKey))) + sizeof (struct TALER_TransferPublicKeyP))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "transfer keys do not match\n"); GNUNET_free (commit_links); /* FIXME: return more specific error with original signature (#3712) */ return (MHD_YES == - TALER_MINT_reply_refresh_reveal_missmatch (connection, + TMH_RESPONSE_reply_refresh_reveal_missmatch (connection, off, j, "transfer key")) @@ -841,7 +841,7 @@ check_commitment (struct MHD_Connection *connection, GNUNET_break (0); GNUNET_CRYPTO_ecdhe_key_clear (&transfer_ecdhe); GNUNET_free (commit_links); - return (MHD_YES == TALER_MINT_reply_internal_error (connection, + return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection, "ECDH error")) ? GNUNET_NO : GNUNET_SYSERR; } @@ -854,7 +854,7 @@ check_commitment (struct MHD_Connection *connection, GNUNET_break (0); GNUNET_free (commit_links); return (MHD_YES == - TALER_MINT_reply_internal_error (connection, + TMH_RESPONSE_reply_internal_error (connection, "Decryption error")) ? GNUNET_NO : GNUNET_SYSERR; } @@ -873,7 +873,7 @@ check_commitment (struct MHD_Connection *connection, GNUNET_free (commit_links); /* FIXME: return more specific error with original signature (#3712) */ return (MHD_YES == - TALER_MINT_reply_refresh_reveal_missmatch (connection, + TMH_RESPONSE_reply_refresh_reveal_missmatch (connection, off, j, "transfer secret")) @@ -897,14 +897,14 @@ check_commitment (struct MHD_Connection *connection, { GNUNET_break (0); GNUNET_free (commit_coins); - return (MHD_YES == TALER_MINT_reply_internal_db_error (connection)) + return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection)) ? GNUNET_NO : GNUNET_SYSERR; } for (j = 0; j < num_newcoins; j++) { - struct TALER_RefreshLinkDecrypted *link_data; - struct TALER_CoinSpendPublicKey coin_pub; + struct TALER_RefreshLinkDecryptedP *link_data; + union TALER_CoinSpendPublicKeyP coin_pub; struct GNUNET_HashCode h_msg; char *buf; size_t buf_len; @@ -915,7 +915,7 @@ check_commitment (struct MHD_Connection *connection, { GNUNET_break (0); GNUNET_free (commit_coins); - return (MHD_YES == TALER_MINT_reply_internal_error (connection, + return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection, "Decryption error")) ? GNUNET_NO : GNUNET_SYSERR; } @@ -923,7 +923,7 @@ check_commitment (struct MHD_Connection *connection, GNUNET_CRYPTO_ecdsa_key_get_public (&link_data->coin_priv.ecdsa_priv, &coin_pub.ecdsa_pub); GNUNET_CRYPTO_hash (&coin_pub, - sizeof (struct TALER_CoinSpendPublicKey), + sizeof (union TALER_CoinSpendPublicKeyP), &h_msg); if (0 == (buf_len = GNUNET_CRYPTO_rsa_blind (&h_msg, @@ -934,7 +934,7 @@ check_commitment (struct MHD_Connection *connection, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "blind failed\n"); GNUNET_free (commit_coins); - return (MHD_YES == TALER_MINT_reply_internal_error (connection, + return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection, "Blinding error")) ? GNUNET_NO : GNUNET_SYSERR; } @@ -951,7 +951,7 @@ check_commitment (struct MHD_Connection *connection, /* FIXME: return more specific error with original signature (#3712) */ GNUNET_free (commit_coins); return (MHD_YES == - TALER_MINT_reply_refresh_reveal_missmatch (connection, + TMH_RESPONSE_reply_refresh_reveal_missmatch (connection, off, j, "envelope")) @@ -982,15 +982,15 @@ static struct TALER_DenominationSignature refresh_mint_coin (struct MHD_Connection *connection, struct TALER_MINTDB_Session *session, const struct GNUNET_HashCode *session_hash, - struct MintKeyState *key_state, + struct TMH_KS_StateHandle *key_state, const struct TALER_DenominationPublicKey *denom_pub, const struct RefreshCommitCoin *commit_coin, unsigned int coin_off) { - struct TALER_MINT_DenomKeyIssuePriv *dki; + struct TALER_DenominationKeyIssueInformation *dki; struct TALER_DenominationSignature ev_sig; - dki = TALER_MINT_get_denom_key (key_state, + dki = TMH_KS_denomination_key_lookup (key_state, denom_pub); if (NULL == dki) { @@ -1024,7 +1024,7 @@ refresh_mint_coin (struct MHD_Connection *connection, /** * Execute a "/refresh/reveal". The client is revealing to us the - * transfer keys for @a #KAPPA-1 sets of coins. Verify that the + * transfer keys for @a #TALER_CNC_KAPPA-1 sets of coins. Verify that the * revealed transfer keys would allow linkage to the blinded coins, * and if so, return the signed coins for corresponding to the set of * coins that was not chosen. @@ -1033,19 +1033,19 @@ refresh_mint_coin (struct MHD_Connection *connection, * @param session_hash hash identifying the refresh session * @param num_oldcoins size of y-dimension of @transfer_privs array * @param transfer_pubs array with the revealed transfer keys, - * x-dimension must be #KAPPA - 1 + * x-dimension must be #TALER_CNC_KAPPA - 1 * @return MHD result code */ int -TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, +TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, unsigned int num_oldcoins, - struct TALER_TransferPrivateKey **transfer_privs) + struct TALER_TransferPrivateKeyP **transfer_privs) { int res; struct TALER_MINTDB_Session *session; struct RefreshSession refresh_session; - struct MintKeyState *key_state; + struct TMH_KS_StateHandle *key_state; struct RefreshMelt *melts; struct TALER_DenominationPublicKey *denom_pubs; struct TALER_DenominationSignature *ev_sigs; @@ -1058,7 +1058,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, GNUNET_NO))) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } res = plugin->get_refresh_session (plugin->cls, @@ -1066,14 +1066,14 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, session_hash, &refresh_session); if (GNUNET_NO == res) - return TALER_MINT_reply_arg_invalid (connection, + return TMH_RESPONSE_reply_arg_invalid (connection, "session_hash"); if (GNUNET_SYSERR == res) - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); if (0 == refresh_session.num_oldcoins) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } melts = GNUNET_malloc (refresh_session.num_oldcoins * @@ -1089,7 +1089,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, { GNUNET_break (0); GNUNET_free (melts); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } } denom_pubs = GNUNET_malloc (refresh_session.num_newcoins * @@ -1104,13 +1104,13 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, GNUNET_break (0); GNUNET_free (denom_pubs); GNUNET_free (melts); - return (MHD_YES == TALER_MINT_reply_internal_db_error (connection)) + return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection)) ? GNUNET_NO : GNUNET_SYSERR; } off = 0; - for (i=0;icommit (plugin->cls, session)) { - LOG_WARNING ("/refresh/reveal transaction commit failed\n"); + TALER_LOG_WARNING ("/refresh/reveal transaction commit failed\n"); for (i=0;iget_session (plugin->cls, GNUNET_NO))) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } res = plugin->get_transfer (plugin->cls, session, @@ -1248,11 +1248,11 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection, if (GNUNET_SYSERR == res) { GNUNET_break (0); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } if (GNUNET_NO == res) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", @@ -1265,13 +1265,13 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection, coin_pub); if (NULL == ldl) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", "link data not found (link)"); } - res = TALER_MINT_reply_refresh_link_success (connection, + res = TMH_RESPONSE_reply_refresh_link_success (connection, &transfer_pub, &shared_secret_enc, ldl); diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h index b2061850c..44d11ffc9 100644 --- a/src/mint/taler-mint-httpd_db.h +++ b/src/mint/taler-mint-httpd_db.h @@ -39,8 +39,8 @@ * @return MHD result code */ int -TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, - const struct Deposit *deposit); +TMH_DB_execute_deposit (struct MHD_Connection *connection, + const struct Deposit *deposit); /** @@ -52,8 +52,8 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, - const struct TALER_ReservePublicKey *reserve_pub); +TMH_DB_execute_withdraw_status (struct MHD_Connection *connection, + const struct TALER_ReservePublicKeyP *reserve_pub); /** @@ -71,24 +71,24 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, - const struct TALER_ReservePublicKey *reserve, - const struct TALER_DenominationPublicKey *denomination_pub, - const char *blinded_msg, - size_t blinded_msg_len, - const struct TALER_ReserveSignature *signature); +TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection, + const struct TALER_ReservePublicKeyP *reserve, + const struct TALER_DenominationPublicKey *denomination_pub, + const char *blinded_msg, + size_t blinded_msg_len, + const struct TALER_ReserveSignatureP *signature); /** * Details about a melt operation of an individual coin. */ -struct MeltDetails +struct TMH_DB_MeltDetails { /** * Signature allowing the melt (using * a `struct RefreshMeltConfirmSignRequestBody`) to sign over. */ - struct TALER_CoinSpendSignature melt_sig; + union TALER_CoinSpendSignatureP melt_sig; /** * How much of the coin's value did the client allow to be melted? @@ -121,20 +121,20 @@ struct MeltDetails * @return MHD result code */ int -TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, - const struct GNUNET_HashCode *session_hash, - unsigned int num_new_denoms, - const struct TALER_DenominationPublicKey *denom_pubs, - unsigned int coin_count, - const struct TALER_CoinPublicInfo *coin_public_infos, - const struct MeltDetails *coin_melt_details, - struct RefreshCommitCoin *const* commit_coin, - struct RefreshCommitLink *const* commit_link); +TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, + const struct GNUNET_HashCode *session_hash, + unsigned int num_new_denoms, + const struct TALER_DenominationPublicKey *denom_pubs, + unsigned int coin_count, + const struct TALER_CoinPublicInfo *coin_public_infos, + const struct TMH_DB_MeltDetails *coin_melt_details, + struct RefreshCommitCoin *const* commit_coin, + struct RefreshCommitLink *const* commit_link); /** * Execute a "/refresh/reveal". The client is revealing to us the - * transfer keys for #KAPPA-1 sets of coins. Verify that the + * transfer keys for #TALER_CNC_KAPPA-1 sets of coins. Verify that the * revealed transfer keys would allow linkage to the blinded coins, * and if so, return the signed coins for corresponding to the set of * coins that was not chosen. @@ -142,14 +142,14 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, * @param connection the MHD connection to handle * @param session_hash hash over the refresh session * @param num_oldcoins size of y-dimension of @transfer_privs array - * @param transfer_pubs array with the revealed transfer keys, #KAPPA is 1st-dimension + * @param transfer_pubs array with the revealed transfer keys, #TALER_CNC_KAPPA is 1st-dimension * @return MHD result code */ int -TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, - const struct GNUNET_HashCode *session_hash, - unsigned int num_oldcoins, - struct TALER_TransferPrivateKey **transfer_privs); +TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, + const struct GNUNET_HashCode *session_hash, + unsigned int num_oldcoins, + struct TALER_TransferPrivateKeyP **transfer_privs); /** @@ -162,8 +162,8 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKey *coin_pub); +TMH_DB_execute_refresh_link (struct MHD_Connection *connection, + const union TALER_CoinSpendPublicKeyP *coin_pub); #endif diff --git a/src/mint/taler-mint-httpd_deposit.c b/src/mint/taler-mint-httpd_deposit.c index 7ecf8bfe6..a1d64be45 100644 --- a/src/mint/taler-mint-httpd_deposit.c +++ b/src/mint/taler-mint-httpd_deposit.c @@ -56,13 +56,13 @@ static int verify_and_execute_deposit (struct MHD_Connection *connection, const struct Deposit *deposit) { - struct MintKeyState *key_state; - struct TALER_DepositRequest dr; - struct TALER_MINT_DenomKeyIssuePriv *dki; + struct TMH_KS_StateHandle *key_state; + struct TALER_DepositRequestPS dr; + struct TALER_DenominationKeyIssueInformation *dki; struct TALER_Amount fee_deposit; dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_DEPOSIT); - dr.purpose.size = htonl (sizeof (struct TALER_DepositRequest)); + dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS)); dr.h_contract = deposit->h_contract; dr.h_wire = deposit->h_wire; dr.transaction_id = GNUNET_htonll (deposit->transaction_id); @@ -75,43 +75,43 @@ verify_and_execute_deposit (struct MHD_Connection *connection, &deposit->csig.ecdsa_signature, &deposit->coin.coin_pub.ecdsa_pub)) { - LOG_WARNING ("Invalid signature on /deposit request\n"); - return TALER_MINT_reply_arg_invalid (connection, + TALER_LOG_WARNING ("Invalid signature on /deposit request\n"); + return TMH_RESPONSE_reply_arg_invalid (connection, "csig"); } /* check denomination exists and is valid */ - key_state = TALER_MINT_key_state_acquire (); - dki = TALER_MINT_get_denom_key (key_state, + key_state = TMH_KS_acquire (); + dki = TMH_KS_denomination_key_lookup (key_state, &deposit->coin.denom_pub); if (NULL == dki) { - TALER_MINT_key_state_release (key_state); - LOG_WARNING ("Unknown denomination key in /deposit request\n"); - return TALER_MINT_reply_arg_invalid (connection, + TMH_KS_release (key_state); + TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n"); + return TMH_RESPONSE_reply_arg_invalid (connection, "denom_pub"); } /* check coin signature */ if (GNUNET_YES != TALER_test_coin_valid (&deposit->coin)) { - LOG_WARNING ("Invalid coin passed for /deposit\n"); - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_coin_invalid (connection); + TALER_LOG_WARNING ("Invalid coin passed for /deposit\n"); + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_coin_invalid (connection); } TALER_amount_ntoh (&fee_deposit, &dki->issue.fee_deposit); if (TALER_amount_cmp (&fee_deposit, &deposit->amount_with_fee) < 0) { - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); return (MHD_YES == - TALER_MINT_reply_external_error (connection, + TMH_RESPONSE_reply_external_error (connection, "deposited amount smaller than depositing fee")) ? GNUNET_NO : GNUNET_SYSERR; } - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); - return TALER_MINT_db_execute_deposit (connection, + return TMH_DB_execute_deposit (connection, deposit); } @@ -137,20 +137,20 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection, struct Deposit deposit; char *wire_enc; size_t len; - struct GNUNET_MINT_ParseFieldSpec spec[] = { - TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &deposit.coin.denom_pub), - TALER_MINT_PARSE_RSA_SIGNATURE ("ubsig", &deposit.coin.denom_sig), - TALER_MINT_PARSE_FIXED ("coin_pub", &deposit.coin.coin_pub), - TALER_MINT_PARSE_FIXED ("merchant_pub", &deposit.merchant_pub), - TALER_MINT_PARSE_FIXED ("H_a", &deposit.h_contract), - TALER_MINT_PARSE_FIXED ("H_wire", &deposit.h_wire), - TALER_MINT_PARSE_FIXED ("csig", &deposit.csig), - TALER_MINT_PARSE_FIXED ("transaction_id", &deposit.transaction_id), - TALER_MINT_PARSE_END + struct TMH_PARSE_FieldSpecification spec[] = { + TMH_PARSE_MEMBER_RSA_PUBLIC_KEY ("denom_pub", &deposit.coin.denom_pub), + TMH_PARSE_MEMBER_RSA_SIGNATURE ("ubsig", &deposit.coin.denom_sig), + TMH_PARSE_MEMBER_FIXED ("coin_pub", &deposit.coin.coin_pub), + TMH_PARSE_MEMBER_FIXED ("merchant_pub", &deposit.merchant_pub), + TMH_PARSE_MEMBER_FIXED ("H_a", &deposit.h_contract), + TMH_PARSE_MEMBER_FIXED ("H_wire", &deposit.h_wire), + TMH_PARSE_MEMBER_FIXED ("csig", &deposit.csig), + TMH_PARSE_MEMBER_FIXED ("transaction_id", &deposit.transaction_id), + TMH_PARSE_MEMBER_END }; memset (&deposit, 0, sizeof (deposit)); - res = TALER_MINT_parse_json_data (connection, + res = TMH_PARSE_json_data (connection, root, spec); if (GNUNET_SYSERR == res) @@ -158,18 +158,18 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection, if (GNUNET_NO == res) return MHD_YES; /* failure */ if (GNUNET_YES != - TALER_JSON_validate_wireformat (expected_wire_format, + TALER_json_validate_wireformat (TMH_expected_wire_format, wire)) { - TALER_MINT_release_parsed_data (spec); - return TALER_MINT_reply_arg_invalid (connection, + TMH_PARSE_release_data (spec); + return TMH_RESPONSE_reply_arg_invalid (connection, "wire"); } if (NULL == (wire_enc = json_dumps (wire, JSON_COMPACT | JSON_SORT_KEYS))) { - LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n"); - TALER_MINT_release_parsed_data (spec); - return TALER_MINT_reply_arg_invalid (connection, + TALER_LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n"); + TMH_PARSE_release_data (spec); + return TMH_RESPONSE_reply_arg_invalid (connection, "wire"); } len = strlen (wire_enc) + 1; @@ -182,7 +182,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection, deposit.amount_with_fee = *amount; res = verify_and_execute_deposit (connection, &deposit); - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return res; } @@ -204,7 +204,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_handler_deposit (struct RequestHandler *rh, +TMH_DEPOSIT_handler_deposit (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, @@ -216,7 +216,7 @@ TALER_MINT_handler_deposit (struct RequestHandler *rh, struct TALER_Amount amount; json_t *f; - res = TALER_MINT_parse_post_json (connection, + res = TMH_PARSE_post_json (connection, connection_cls, upload_data, upload_data_size, @@ -232,12 +232,12 @@ TALER_MINT_handler_deposit (struct RequestHandler *rh, { GNUNET_break_op (0); json_decref (json); - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s}", "error", "Bad format"); } - res = TALER_MINT_parse_amount_json (connection, + res = TMH_PARSE_amount_json (connection, f, &amount); json_decref (f); diff --git a/src/mint/taler-mint-httpd_deposit.h b/src/mint/taler-mint-httpd_deposit.h index e37c23c7e..bf1a32321 100644 --- a/src/mint/taler-mint-httpd_deposit.h +++ b/src/mint/taler-mint-httpd_deposit.h @@ -45,10 +45,10 @@ * @return MHD result code */ int -TALER_MINT_handler_deposit (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_DEPOSIT_handler_deposit (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/mint/taler-mint-httpd_keystate.c b/src/mint/taler-mint-httpd_keystate.c index c29c5c516..746c257a9 100644 --- a/src/mint/taler-mint-httpd_keystate.c +++ b/src/mint/taler-mint-httpd_keystate.c @@ -30,12 +30,12 @@ * the mint. There can be multiple instances of this struct, as it is * reference counted and only destroyed once the last user is done * with it. The current instance is acquired using - * #TALER_MINT_key_state_acquire(). Using this function increases the + * #TMH_KS_acquire(). Using this function increases the * reference count. The contents of this structure (except for the * reference counter) should be considered READ-ONLY until it is * ultimately destroyed (as there can be many concurrent users). */ -struct MintKeyState +struct TMH_KS_StateHandle { /** * JSON array with denomination keys. (Currently not really used @@ -51,7 +51,7 @@ struct MintKeyState /** * Cached JSON text that the mint will send for a "/keys" request. - * Includes our @e master_pub public key, the signing and + * Includes our @e TMH_master_public_key public key, the signing and * denomination keys as well as the @e reload_time. */ char *keys_json; @@ -76,7 +76,7 @@ struct MintKeyState /** * Mint signing key that should be used currently. */ - struct TALER_MINT_SignKeyIssuePriv current_sign_key_issue; + struct TALER_MintSigningKeyValidityPSPriv current_sign_key_issue; /** * Reference count. The struct is released when the RC hits zero. @@ -87,9 +87,9 @@ struct MintKeyState /** * Mint key state. Never use directly, instead access via - * #TALER_MINT_key_state_acquire() and #TALER_MINT_key_state_release(). + * #TMH_KS_acquire() and #TMH_KS_release(). */ -static struct MintKeyState *internal_key_state; +static struct TMH_KS_StateHandle *internal_key_state; /** * Mutex protecting access to #internal_key_state. @@ -112,7 +112,7 @@ static int reload_pipe[2]; */ static json_t * denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, - const struct TALER_MINT_DenomKeyIssue *dki) + const struct TALER_DenominationKeyValidityPS *dki) { struct TALER_Amount value; struct TALER_Amount fee_withdraw; @@ -130,24 +130,24 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, return json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", "master_sig", - TALER_JSON_from_data (&dki->signature, + TALER_json_from_data (&dki->signature, sizeof (struct GNUNET_CRYPTO_EddsaSignature)), "stamp_start", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->start)), + TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->start)), "stamp_expire_withdraw", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw)), + TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw)), "stamp_expire_deposit", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)), + TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)), "denom_pub", - TALER_JSON_from_rsa_public_key (pk->rsa_public_key), + TALER_json_from_rsa_public_key (pk->rsa_public_key), "value", - TALER_JSON_from_amount (&value), + TALER_json_from_amount (&value), "fee_withdraw", - TALER_JSON_from_amount (&fee_withdraw), + TALER_json_from_amount (&fee_withdraw), "fee_deposit", - TALER_JSON_from_amount (&fee_deposit), + TALER_json_from_amount (&fee_deposit), "fee_refresh", - TALER_JSON_from_amount (&fee_refresh)); + TALER_json_from_amount (&fee_refresh)); } @@ -189,13 +189,13 @@ TALER_MINT_conf_duration_provide () static int reload_keys_denom_iter (void *cls, const char *alias, - const struct TALER_MINT_DenomKeyIssuePriv *dki) + const struct TALER_DenominationKeyIssueInformation *dki) { - struct MintKeyState *ctx = cls; + struct TMH_KS_StateHandle *ctx = cls; struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute horizon; struct GNUNET_HashCode denom_key_hash; - struct TALER_MINT_DenomKeyIssuePriv *d2; + struct TALER_DenominationKeyIssueInformation *d2; int res; horizon = GNUNET_TIME_relative_to_absolute (TALER_MINT_conf_duration_provide ()); @@ -220,7 +220,7 @@ reload_keys_denom_iter (void *cls, GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, &denom_key_hash); d2 = GNUNET_memdup (dki, - sizeof (struct TALER_MINT_DenomKeyIssuePriv)); + sizeof (struct TALER_DenominationKeyIssueInformation)); res = GNUNET_CONTAINER_multihashmap_put (ctx->denomkey_map, &denom_key_hash, d2, @@ -247,19 +247,19 @@ reload_keys_denom_iter (void *cls, * @return a JSON object describing the sign key isue (public part) */ static json_t * -sign_key_issue_to_json (const struct TALER_MINT_SignKeyIssue *ski) +sign_key_issue_to_json (const struct TALER_MintSigningKeyValidityPS *ski) { return json_pack ("{s:o, s:o, s:o, s:o}", "stamp_start", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)), + TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)), "stamp_expire", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)), + TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)), "master_sig", - TALER_JSON_from_data (&ski->signature, + TALER_json_from_data (&ski->signature, sizeof (struct GNUNET_CRYPTO_EddsaSignature)), "key", - TALER_JSON_from_data (&ski->signkey_pub, + TALER_json_from_data (&ski->signkey_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))); } @@ -277,9 +277,9 @@ sign_key_issue_to_json (const struct TALER_MINT_SignKeyIssue *ski) static int reload_keys_sign_iter (void *cls, const char *filename, - const struct TALER_MINT_SignKeyIssuePriv *ski) + const struct TALER_MintSigningKeyValidityPSPriv *ski) { - struct MintKeyState *ctx = cls; + struct TMH_KS_StateHandle *ctx = cls; struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute horizon; @@ -320,7 +320,7 @@ reload_keys_sign_iter (void *cls, /** * Iterator for freeing denomination keys. * - * @param cls closure with the `struct MintKeyState` + * @param cls closure with the `struct TMH_KS_StateHandle` * @param key key for the denomination key * @param alias coin alias * @return #GNUNET_OK to continue to iterate, @@ -332,7 +332,7 @@ free_denom_key (void *cls, const struct GNUNET_HashCode *key, void *value) { - struct TALER_MINT_DenomKeyIssuePriv *dki = value; + struct TALER_DenominationKeyIssueInformation *dki = value; GNUNET_free (dki); return GNUNET_OK; @@ -345,7 +345,7 @@ free_denom_key (void *cls, * @param key_state the key state to release */ void -TALER_MINT_key_state_release (struct MintKeyState *key_state) +TMH_KS_release (struct TMH_KS_StateHandle *key_state) { GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex)); GNUNET_assert (0 < key_state->refcnt); @@ -367,30 +367,30 @@ TALER_MINT_key_state_release (struct MintKeyState *key_state) /** * Acquire the key state of the mint. Updates keys if necessary. - * For every call to #TALER_MINT_key_state_acquire(), a matching call - * to #TALER_MINT_key_state_release() must be made. + * For every call to #TMH_KS_acquire(), a matching call + * to #TMH_KS_release() must be made. * * @return the key state */ -struct MintKeyState * -TALER_MINT_key_state_acquire (void) +struct TMH_KS_StateHandle * +TMH_KS_acquire (void) { struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); - struct MintKeyState *key_state; + struct TMH_KS_StateHandle *key_state; json_t *keys; char *inner; - struct TALER_MINT_KeySetSignature ks; - struct TALER_MintSignature sig; + struct TALER_MintKeySetPS ks; + struct TALER_MintSignatureP sig; GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex)); if (internal_key_state->next_reload.abs_value_us <= now.abs_value_us) { - TALER_MINT_key_state_release (internal_key_state); + TMH_KS_release (internal_key_state); internal_key_state = NULL; } if (NULL == internal_key_state) { - key_state = GNUNET_new (struct MintKeyState); + key_state = GNUNET_new (struct TMH_KS_StateHandle); key_state->denom_keys_array = json_array (); GNUNET_assert (NULL != key_state->denom_keys_array); key_state->sign_keys_array = json_array (); @@ -398,10 +398,10 @@ TALER_MINT_key_state_acquire (void) key_state->denomkey_map = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO); key_state->reload_time = GNUNET_TIME_absolute_get (); - TALER_MINT_denomkeys_iterate (mintdir, + TALER_MINT_denomkeys_iterate (TMH_mint_directory, &reload_keys_denom_iter, key_state); - TALER_MINT_signkeys_iterate (mintdir, + TALER_MINT_signkeys_iterate (TMH_mint_directory, &reload_keys_sign_iter, key_state); key_state->next_reload = GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire); @@ -410,26 +410,26 @@ TALER_MINT_key_state_acquire (void) "No valid signing key found!\n"); keys = json_pack ("{s:o, s:o, s:o, s:o}", - "master_pub", - TALER_JSON_from_data (&master_pub, + "TMH_master_public_key", + TALER_json_from_data (&TMH_master_public_key, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)), "signkeys", key_state->sign_keys_array, "denoms", key_state->denom_keys_array, - "list_issue_date", TALER_JSON_from_abs (key_state->reload_time)); + "list_issue_date", TALER_json_from_abs (key_state->reload_time)); inner = json_dumps (keys, JSON_INDENT(2)); ks.purpose.size = htonl (sizeof (ks)); - ks.purpose.purpose = htonl (TALER_SIGNATURE_KEYS_SET); + ks.purpose.purpose = htonl (TALER_SIGNATURE_MINT_KEY_SET); ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time); GNUNET_CRYPTO_hash (inner, strlen (inner), &ks.hc); GNUNET_free (inner); - TALER_MINT_keys_sign (&ks.purpose, + TMH_KS_sign (&ks.purpose, &sig); keys = json_pack ("{s:o, s:o}", "keys", keys, - "eddsa-signature", TALER_JSON_from_eddsa_sig (&ks.purpose, + "eddsa-signature", TALER_json_from_eddsa_sig (&ks.purpose, &sig.eddsa_signature)); key_state->keys_json = json_dumps (keys, JSON_INDENT (2)); @@ -452,8 +452,8 @@ TALER_MINT_key_state_acquire (void) * @return the denomination key issue, * or NULL if denom_pub could not be found */ -struct TALER_MINT_DenomKeyIssuePriv * -TALER_MINT_get_denom_key (const struct MintKeyState *key_state, +struct TALER_DenominationKeyIssueInformation * +TMH_KS_denomination_key_lookup (const struct TMH_KS_StateHandle *key_state, const struct TALER_DenominationPublicKey *denom_pub) { struct GNUNET_HashCode hc; @@ -505,7 +505,7 @@ handle_signal (int signal_number) * (FIXME: #3474) */ int -TALER_MINT_key_reload_loop (void) +TMH_KS_loop (void) { struct sigaction act; struct sigaction rec; @@ -541,12 +541,12 @@ TALER_MINT_key_reload_loop (void) "(re-)loading keys\n"); if (NULL != internal_key_state) { - TALER_MINT_key_state_release (internal_key_state); + TMH_KS_release (internal_key_state); internal_key_state = NULL; } /* This will re-initialize 'internal_key_state' with an initial refcnt of 1 */ - (void) TALER_MINT_key_state_acquire (); + (void) TMH_KS_acquire (); read_again: errno = 0; @@ -582,18 +582,18 @@ read_again: * @param[OUT] sig signature over purpose using current signing key */ void -TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct TALER_MintSignature *sig) +TMH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, + struct TALER_MintSignatureP *sig) { - struct MintKeyState *key_state; + struct TMH_KS_StateHandle *key_state; - key_state = TALER_MINT_key_state_acquire (); + key_state = TMH_KS_acquire (); GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv, purpose, &sig->eddsa_signature)); - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); } @@ -609,21 +609,21 @@ TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, * @return MHD result code */ int -TALER_MINT_handler_keys (struct RequestHandler *rh, +TMH_KS_handler_keys (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, size_t *upload_data_size) { - struct MintKeyState *key_state; + struct TMH_KS_StateHandle *key_state; struct MHD_Response *response; int ret; - key_state = TALER_MINT_key_state_acquire (); + key_state = TMH_KS_acquire (); response = MHD_create_response_from_buffer (strlen (key_state->keys_json), key_state->keys_json, MHD_RESPMEM_MUST_COPY); - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); if (NULL == response) { GNUNET_break (0); diff --git a/src/mint/taler-mint-httpd_keystate.h b/src/mint/taler-mint-httpd_keystate.h index faccc8f00..4946ec1a3 100644 --- a/src/mint/taler-mint-httpd_keystate.h +++ b/src/mint/taler-mint-httpd_keystate.h @@ -33,18 +33,18 @@ * Snapshot of the (coin and signing) * keys (including private keys) of the mint. */ -struct MintKeyState; +struct TMH_KS_StateHandle; /** * Acquire the key state of the mint. Updates keys if necessary. - * For every call to #TALER_MINT_key_state_acquire(), a matching call - * to #TALER_MINT_key_state_release() must be made. + * For every call to #TMH_KS_acquire(), a matching call + * to #TMH_KS_release() must be made. * * @return the key state */ -struct MintKeyState * -TALER_MINT_key_state_acquire (void); +struct TMH_KS_StateHandle * +TMH_KS_acquire (void); /** @@ -53,7 +53,7 @@ TALER_MINT_key_state_acquire (void); * @param key_state the key state to release */ void -TALER_MINT_key_state_release (struct MintKeyState *key_state); +TMH_KS_release (struct TMH_KS_StateHandle *key_state); /** @@ -65,9 +65,9 @@ TALER_MINT_key_state_release (struct MintKeyState *key_state); * @return the denomination key issue, * or NULL if denom_pub could not be found */ -struct TALER_MINT_DenomKeyIssuePriv * -TALER_MINT_get_denom_key (const struct MintKeyState *key_state, - const struct TALER_DenominationPublicKey *denom_pub); +struct TALER_DenominationKeyIssueInformation * +TMH_KS_denomination_key_lookup (const struct TMH_KS_StateHandle *key_state, + const struct TALER_DenominationPublicKey *denom_pub); /** @@ -78,7 +78,7 @@ TALER_MINT_get_denom_key (const struct MintKeyState *key_state, * #GNUNET_SYSERR on error */ int -TALER_MINT_key_reload_loop (void); +TMH_KS_loop (void); /** @@ -89,8 +89,8 @@ TALER_MINT_key_reload_loop (void); * @param[OUT] sig signature over purpose using current signing key */ void -TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct TALER_MintSignature *sig); +TMH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, + struct TALER_MintSignatureP *sig); /** @@ -104,11 +104,11 @@ TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, * @return MHD result code */ int -TALER_MINT_handler_keys (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_KS_handler_keys (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/mint/taler-mint-httpd_mhd.c b/src/mint/taler-mint-httpd_mhd.c index 9d796dd0e..934a2f9d2 100644 --- a/src/mint/taler-mint-httpd_mhd.c +++ b/src/mint/taler-mint-httpd_mhd.c @@ -47,7 +47,7 @@ * @return MHD result code */ int -TALER_MINT_handler_static_response (struct RequestHandler *rh, +TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, @@ -90,7 +90,7 @@ TALER_MINT_handler_static_response (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh, +TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, @@ -136,13 +136,13 @@ TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_send_json_pack_error (struct RequestHandler *rh, +TMH_MHD_handler_send_json_pack_error (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, size_t *upload_data_size) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, rh->response_code, "{s:s}", "error", diff --git a/src/mint/taler-mint-httpd_mhd.h b/src/mint/taler-mint-httpd_mhd.h index 941585bf3..4ab8e803c 100644 --- a/src/mint/taler-mint-httpd_mhd.h +++ b/src/mint/taler-mint-httpd_mhd.h @@ -40,11 +40,11 @@ * @return MHD result code */ int -TALER_MINT_handler_static_response (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -59,11 +59,11 @@ TALER_MINT_handler_static_response (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -80,13 +80,13 @@ TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_helper_send_json_pack (struct RequestHandler *rh, - struct MHD_Connection *connection, - void *connection_cls, - int response_code, - int do_cache, - const char *fmt, - ...); +TMH_MHD_helper_send_json_pack (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void *connection_cls, + int response_code, + int do_cache, + const char *fmt, + ...); /** @@ -101,11 +101,11 @@ TALER_MINT_helper_send_json_pack (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_send_json_pack_error (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_MHD_handler_send_json_pack_error (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/mint/taler-mint-httpd_parsing.c b/src/mint/taler-mint-httpd_parsing.c index dedf4af9a..99b060fec 100644 --- a/src/mint/taler-mint-httpd_parsing.c +++ b/src/mint/taler-mint-httpd_parsing.c @@ -146,7 +146,7 @@ buffer_append (struct Buffer *buf, * (incrementally) process JSON data uploaded to the HTTP * server. It will store the required state in the * "connection_cls", which must be cleaned up using - * #TALER_MINT_parse_post_cleanup_callback(). + * #TMH_PARSE_post_cleanup_callback(). * * @param connection the MHD connection * @param con_cs the closure (points to a `struct Buffer *`) @@ -165,7 +165,7 @@ buffer_append (struct Buffer *buf, * close HTTP session with MHD_NO) */ int -TALER_MINT_parse_post_json (struct MHD_Connection *connection, +TMH_PARSE_post_json (struct MHD_Connection *connection, void **con_cls, const char *upload_data, size_t *upload_data_size, @@ -189,7 +189,7 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection, buffer_deinit (r); GNUNET_free (r); return (MHD_NO == - TALER_MINT_reply_internal_error (connection, + TMH_RESPONSE_reply_internal_error (connection, "out of memory")) ? GNUNET_SYSERR : GNUNET_NO; } @@ -213,7 +213,7 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection, buffer_deinit (r); GNUNET_free (r); return (MHD_NO == - TALER_MINT_reply_request_too_large (connection)) + TMH_RESPONSE_reply_request_too_large (connection)) ? GNUNET_SYSERR : GNUNET_NO; } /* everything OK, wait for more POST data */ @@ -234,7 +234,7 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to parse JSON request body\n"); return (MHD_YES == - TALER_MINT_reply_invalid_json (connection)) + TMH_RESPONSE_reply_invalid_json (connection)) ? GNUNET_NO : GNUNET_SYSERR; } *con_cls = NULL; @@ -248,10 +248,10 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection, * to clean up our state. * * @param con_cls value as it was left by - * #TALER_MINT_parse_post_json(), to be cleaned up + * #TMH_PARSE_post_json(), to be cleaned up */ void -TALER_MINT_parse_post_cleanup_callback (void *con_cls) +TMH_PARSE_post_cleanup_callback (void *con_cls) { struct Buffer *r = con_cls; @@ -276,7 +276,7 @@ TALER_MINT_parse_post_cleanup_callback (void *con_cls) * #GNUNET_SYSERR on internal error (error response could not be sent) */ int -TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection, +TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, const char *param_name, void *out_data, size_t out_size) @@ -289,7 +289,7 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection, if (NULL == str) { return (MHD_NO == - TALER_MINT_reply_arg_missing (connection, param_name)) + TMH_RESPONSE_reply_arg_missing (connection, param_name)) ? GNUNET_SYSERR : GNUNET_NO; } if (GNUNET_OK != @@ -298,7 +298,7 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection, out_data, out_size)) return (MHD_NO == - TALER_MINT_reply_arg_invalid (connection, param_name)) + TMH_RESPONSE_reply_arg_invalid (connection, param_name)) ? GNUNET_SYSERR : GNUNET_NO; return GNUNET_OK; } @@ -320,7 +320,7 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection, * #GNUNET_SYSERR on internal error (error response could not be sent) */ int -TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection, +TMH_PARSE_mhd_request_var_arg_data (struct MHD_Connection *connection, const char *param_name, void **out_data, size_t *out_size) @@ -336,7 +336,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection, if (NULL == str) { return (MHD_NO == - TALER_MINT_reply_arg_missing (connection, param_name)) + TMH_RESPONSE_reply_arg_missing (connection, param_name)) ? GNUNET_SYSERR : GNUNET_NO; } slen = strlen (str); @@ -351,7 +351,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection, GNUNET_free (out); *out_size = 0; return (MHD_NO == - TALER_MINT_reply_arg_invalid (connection, param_name)) + TMH_RESPONSE_reply_arg_invalid (connection, param_name)) ? GNUNET_SYSERR : GNUNET_NO; } *out_data = out; @@ -368,7 +368,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection, * * @param connection the connection to send an error response to * @param root the JSON node to start the navigation at. - * @param ... navigation specification (see `enum TALER_MINT_JsonNavigationCommand`) + * @param ... navigation specification (see `enum TMH_PARSE_JsonNavigationCommand`) * @return * #GNUNET_YES if navigation was successful * #GNUNET_NO if json is malformed, error response was generated @@ -376,7 +376,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection, * connection must be closed) */ int -GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, +TMH_PARSE_navigate_json (struct MHD_Connection *connection, const json_t *root, ...) { @@ -389,13 +389,13 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, ret = 2; /* just not any of the valid return values */ while (2 == ret) { - enum TALER_MINT_JsonNavigationCommand command + enum TMH_PARSE_JsonNavigationCommand command = va_arg (argp, - enum TALER_MINT_JsonNavigationCommand); + enum TMH_PARSE_JsonNavigationCommand); switch (command) { - case JNAV_FIELD: + case TMH_PARSE_JNC_FIELD: { const char *fname = va_arg(argp, const char *); @@ -406,7 +406,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == root) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:s, s:o}", "error", @@ -421,7 +421,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, } break; - case JNAV_INDEX: + case TMH_PARSE_JNC_INDEX: { int fnum = va_arg(argp, int); @@ -432,7 +432,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == root) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -444,7 +444,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, } break; - case JNAV_RET_DATA: + case TMH_PARSE_JNC_RET_DATA: { void *where = va_arg (argp, void *); size_t len = va_arg (argp, size_t); @@ -456,7 +456,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == str) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -471,7 +471,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (GNUNET_OK != res) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -485,7 +485,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, } break; - case JNAV_RET_DATA_VAR: + case TMH_PARSE_JNC_RET_DATA_VAR: { void **where = va_arg (argp, void **); size_t *len = va_arg (argp, size_t *); @@ -496,7 +496,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == str) { ret = (MHD_YES == - TALER_MINT_reply_internal_error (connection, + TMH_RESPONSE_reply_internal_error (connection, "json_string_value() failed")) ? GNUNET_NO : GNUNET_SYSERR; break; @@ -517,7 +517,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, *where = NULL; *len = 0; ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -531,7 +531,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, } break; - case JNAV_RET_TYPED_JSON: + case TMH_PARSE_JNC_RET_TYPED_JSON: { int typ = va_arg (argp, int); const json_t **r_json = va_arg (argp, const json_t **); @@ -539,7 +539,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if ( (-1 != typ) && (json_typeof (root) != typ)) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:i, s:i, s:o}", "error", "wrong JSON field type", @@ -554,7 +554,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, } break; - case JNAV_RET_RSA_PUBLIC_KEY: + case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY: { void **where = va_arg (argp, void **); size_t len; @@ -567,7 +567,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == str) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -587,7 +587,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, { GNUNET_free (buf); ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -603,7 +603,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == *where) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -617,7 +617,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, break; } - case JNAV_RET_RSA_SIGNATURE: + case TMH_PARSE_JNC_RET_RSA_SIGNATURE: { void **where = va_arg (argp, void **); size_t len; @@ -630,7 +630,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == str) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -650,7 +650,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, { GNUNET_free (buf); ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -666,7 +666,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, if (NULL == *where) { ret = (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:o}", "error", @@ -680,11 +680,11 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, break; } - case JNAV_RET_AMOUNT: + case TMH_PARSE_JNC_RET_AMOUNT: { struct TALER_Amount *where = va_arg (argp, void *); - ret = TALER_MINT_parse_amount_json (connection, + ret = TMH_PARSE_amount_json (connection, (json_t *) root, where); break; @@ -693,7 +693,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, default: GNUNET_break (0); ret = (MHD_YES == - TALER_MINT_reply_internal_error (connection, + TMH_RESPONSE_reply_internal_error (connection, "unhandled value in switch")) ? GNUNET_NO : GNUNET_SYSERR; break; @@ -715,14 +715,14 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, * @return * #GNUNET_YES if navigation was successful (caller is responsible * for freeing allocated variable-size data using - * #TALER_MINT_release_parsed_data() when done) + * #TMH_PARSE_release_data() when done) * #GNUNET_NO if json is malformed, error response was generated * #GNUNET_SYSERR on internal error */ int -TALER_MINT_parse_json_data (struct MHD_Connection *connection, +TMH_PARSE_json_data (struct MHD_Connection *connection, const json_t *root, - struct GNUNET_MINT_ParseFieldSpec *spec) + struct TMH_PARSE_FieldSpecification *spec) { unsigned int i; int ret; @@ -735,77 +735,77 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, break; switch (spec[i].command) { - case JNAV_FIELD: + case TMH_PARSE_JNC_FIELD: GNUNET_break (0); return GNUNET_SYSERR; - case JNAV_INDEX: + case TMH_PARSE_JNC_INDEX: GNUNET_break (0); return GNUNET_SYSERR; - case JNAV_RET_DATA: - ret = GNUNET_MINT_parse_navigate_json (connection, + case TMH_PARSE_JNC_RET_DATA: + ret = TMH_PARSE_navigate_json (connection, root, - JNAV_FIELD, + TMH_PARSE_JNC_FIELD, spec[i].field_name, - JNAV_RET_DATA, + TMH_PARSE_JNC_RET_DATA, spec[i].destination, spec[i].destination_size_in); break; - case JNAV_RET_DATA_VAR: + case TMH_PARSE_JNC_RET_DATA_VAR: ptr = NULL; - ret = GNUNET_MINT_parse_navigate_json (connection, + ret = TMH_PARSE_navigate_json (connection, root, - JNAV_FIELD, + TMH_PARSE_JNC_FIELD, spec[i].field_name, - JNAV_RET_DATA_VAR, + TMH_PARSE_JNC_RET_DATA_VAR, &ptr, &spec[i].destination_size_out); spec[i].destination = ptr; break; - case JNAV_RET_TYPED_JSON: + case TMH_PARSE_JNC_RET_TYPED_JSON: ptr = NULL; - ret = GNUNET_MINT_parse_navigate_json (connection, + ret = TMH_PARSE_navigate_json (connection, root, - JNAV_FIELD, + TMH_PARSE_JNC_FIELD, spec[i].field_name, - JNAV_RET_TYPED_JSON, + TMH_PARSE_JNC_RET_TYPED_JSON, spec[i].type, &ptr); *((void**)spec[i].destination) = ptr; break; - case JNAV_RET_RSA_PUBLIC_KEY: + case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY: ptr = NULL; - ret = GNUNET_MINT_parse_navigate_json (connection, + ret = TMH_PARSE_navigate_json (connection, root, - JNAV_FIELD, + TMH_PARSE_JNC_FIELD, spec[i].field_name, - JNAV_RET_RSA_PUBLIC_KEY, + TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, &ptr); spec[i].destination = ptr; break; - case JNAV_RET_RSA_SIGNATURE: + case TMH_PARSE_JNC_RET_RSA_SIGNATURE: ptr = NULL; - ret = GNUNET_MINT_parse_navigate_json (connection, + ret = TMH_PARSE_navigate_json (connection, root, - JNAV_FIELD, + TMH_PARSE_JNC_FIELD, spec[i].field_name, - JNAV_RET_RSA_SIGNATURE, + TMH_PARSE_JNC_RET_RSA_SIGNATURE, &ptr); spec[i].destination = ptr; break; - case JNAV_RET_AMOUNT: + case TMH_PARSE_JNC_RET_AMOUNT: GNUNET_assert (sizeof (struct TALER_Amount) == spec[i].destination_size_in); - ret = GNUNET_MINT_parse_navigate_json (connection, + ret = TMH_PARSE_navigate_json (connection, root, - JNAV_FIELD, + TMH_PARSE_JNC_FIELD, spec[i].field_name, - JNAV_RET_AMOUNT, + TMH_PARSE_JNC_RET_AMOUNT, &spec[i].destination); break; } } if (GNUNET_YES != ret) - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return ret; } @@ -817,7 +817,7 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, * @param spec specification to free */ void -TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) +TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec) { unsigned int i; void *ptr; @@ -826,15 +826,15 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) { switch (spec[i].command) { - case JNAV_FIELD: + case TMH_PARSE_JNC_FIELD: GNUNET_break (0); return; - case JNAV_INDEX: + case TMH_PARSE_JNC_INDEX: GNUNET_break (0); return; - case JNAV_RET_DATA: + case TMH_PARSE_JNC_RET_DATA: break; - case JNAV_RET_DATA_VAR: + case TMH_PARSE_JNC_RET_DATA_VAR: if (0 != spec[i].destination_size_out) { GNUNET_free (spec[i].destination); @@ -842,7 +842,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) spec[i].destination_size_out = 0; } break; - case JNAV_RET_TYPED_JSON: + case TMH_PARSE_JNC_RET_TYPED_JSON: ptr = *(void **) spec[i].destination; if (NULL != ptr) { @@ -850,7 +850,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) *(void**) spec[i].destination = NULL; } break; - case JNAV_RET_RSA_PUBLIC_KEY: + case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY: ptr = *(void **) spec[i].destination; if (NULL != ptr) { @@ -858,7 +858,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) *(void**) spec[i].destination = NULL; } break; - case JNAV_RET_RSA_SIGNATURE: + case TMH_PARSE_JNC_RET_RSA_SIGNATURE: ptr = *(void **) spec[i].destination; if (NULL != ptr) { @@ -866,7 +866,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) *(void**) spec[i].destination = NULL; } break; - case JNAV_RET_AMOUNT: + case TMH_PARSE_JNC_RET_AMOUNT: memset (spec[i].destination, 0, sizeof (struct TALER_Amount)); @@ -888,7 +888,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) * #GNUNET_SYSERR on internal error, error response was not generated */ int -TALER_MINT_parse_amount_json (struct MHD_Connection *connection, +TMH_PARSE_amount_json (struct MHD_Connection *connection, json_t *f, struct TALER_Amount *amount) { @@ -905,9 +905,9 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, "fraction", &fraction, "currency", ¤cy)) { - LOG_WARNING ("Failed to parse JSON amount specification\n"); + TALER_LOG_WARNING ("Failed to parse JSON amount specification\n"); if (MHD_YES != - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s}", "error", "Bad format")) @@ -919,9 +919,9 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, (value > UINT64_MAX) || (fraction > UINT32_MAX) ) { - LOG_WARNING ("Amount specified not in allowed range\n"); + TALER_LOG_WARNING ("Amount specified not in allowed range\n"); if (MHD_YES != - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s}", "error", "Amount outside of allowed range")) @@ -929,11 +929,11 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, return GNUNET_NO; } if (0 != strcmp (currency, - MINT_CURRENCY)) + TMH_MINT_CURRENCY)) { - LOG_WARNING ("Currency specified not supported by this mint\n"); + TALER_LOG_WARNING ("Currency specified not supported by this mint\n"); if (MHD_YES != - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:s}", "error", "Currency not supported", @@ -943,8 +943,8 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, } amount->value = (uint64_t) value; amount->fraction = (uint32_t) fraction; - GNUNET_assert (strlen (MINT_CURRENCY) < TALER_CURRENCY_LEN); - strcpy (amount->currency, MINT_CURRENCY); + GNUNET_assert (strlen (TMH_MINT_CURRENCY) < TALER_CURRENCY_LEN); + strcpy (amount->currency, TMH_MINT_CURRENCY); TALER_amount_normalize (amount); return GNUNET_OK; } diff --git a/src/mint/taler-mint-httpd_parsing.h b/src/mint/taler-mint-httpd_parsing.h index 7a322d4d7..99376cac4 100644 --- a/src/mint/taler-mint-httpd_parsing.h +++ b/src/mint/taler-mint-httpd_parsing.h @@ -20,8 +20,8 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_MICROHTTPD_LIB_H_ -#define TALER_MICROHTTPD_LIB_H_ +#ifndef TALER_MINT_HTTPD_PARSING_H +#define TALER_MINT_HTTPD_PARSING_H #include #include @@ -34,7 +34,7 @@ * (incrementally) process JSON data uploaded to the HTTP * server. It will store the required state in the * "connection_cls", which must be cleaned up using - * #TALER_MINT_parse_post_cleanup_callback(). + * #TMH_PARSE_post_cleanup_callback(). * * @param connection the MHD connection * @param con_cs the closure (points to a `struct Buffer *`) @@ -53,11 +53,11 @@ * close HTTP session with MHD_NO) */ int -TALER_MINT_parse_post_json (struct MHD_Connection *connection, - void **con_cls, - const char *upload_data, - size_t *upload_data_size, - json_t **json); +TMH_PARSE_post_json (struct MHD_Connection *connection, + void **con_cls, + const char *upload_data, + size_t *upload_data_size, + json_t **json); /** @@ -65,42 +65,42 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection, * to clean up our state. * * @param con_cls value as it was left by - * #TALER_MINT_parse_post_json(), to be cleaned up + * #TMH_PARSE_post_json(), to be cleaned up */ void -TALER_MINT_parse_post_cleanup_callback (void *con_cls); +TMH_PARSE_post_cleanup_callback (void *con_cls); /** * Constants for JSON navigation description. */ -enum TALER_MINT_JsonNavigationCommand +enum TMH_PARSE_JsonNavigationCommand { /** * Access a field. * Param: const char * */ - JNAV_FIELD, + TMH_PARSE_JNC_FIELD, /** * Access an array index. * Param: int */ - JNAV_INDEX, + TMH_PARSE_JNC_INDEX, /** * Return base32crockford encoded data of * constant size. * Params: (void *, size_t) */ - JNAV_RET_DATA, + TMH_PARSE_JNC_RET_DATA, /** * Return base32crockford encoded data of * variable size. * Params: (void **, size_t *) */ - JNAV_RET_DATA_VAR, + TMH_PARSE_JNC_RET_DATA_VAR, /** * Return a json object, which must be @@ -108,25 +108,25 @@ enum TALER_MINT_JsonNavigationCommand * or -1 for any type). * Params: (int, json_t **) */ - JNAV_RET_TYPED_JSON, + TMH_PARSE_JNC_RET_TYPED_JSON, /** * Return a `struct GNUNET_CRYPTO_rsa_PublicKey` which was * encoded as variable-size base32crockford encoded data. */ - JNAV_RET_RSA_PUBLIC_KEY, + TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, /** * Return a `struct GNUNET_CRYPTO_rsa_Signature` which was * encoded as variable-size base32crockford encoded data. */ - JNAV_RET_RSA_SIGNATURE, + TMH_PARSE_JNC_RET_RSA_SIGNATURE, /** * Return a `struct TALER_Amount` which was * encoded within its own json object. */ - JNAV_RET_AMOUNT + TMH_PARSE_JNC_RET_AMOUNT }; @@ -138,22 +138,22 @@ enum TALER_MINT_JsonNavigationCommand * * @param connection the connection to send an error response to * @param root the JSON node to start the navigation at. - * @param ... navigation specification (see `enum TALER_MINT_JsonNavigationCommand`) + * @param ... navigation specification (see `enum TMH_PARSE_JsonNavigationCommand`) * @return * #GNUNET_YES if navigation was successful * #GNUNET_NO if json is malformed, error response was generated * #GNUNET_SYSERR on internal error */ int -GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, - const json_t *root, - ...); +TMH_PARSE_navigate_json (struct MHD_Connection *connection, + const json_t *root, + ...); /** * Specification for how to parse a JSON field. */ -struct GNUNET_MINT_ParseFieldSpec +struct TMH_PARSE_FieldSpecification { /** * Name of the field. NULL only to terminate array. @@ -183,15 +183,15 @@ struct GNUNET_MINT_ParseFieldSpec /** * Navigation command to use to extract the value. Note that - * #JNAV_RET_DATA or #JNAV_RET_DATA_VAR must be used for @e + * #TMH_PARSE_JNC_RET_DATA or #TMH_PARSE_JNC_RET_DATA_VAR must be used for @e * destination_size_in and @e destination_size_out to have a - * meaning. #JNAV_FIELD and #JNAV_INDEX must not be used here! + * meaning. #TMH_PARSE_JNC_FIELD and #TMH_PARSE_JNC_INDEX must not be used here! */ - enum TALER_MINT_JsonNavigationCommand command; + enum TMH_PARSE_JsonNavigationCommand command; /** * JSON type to use, only meaningful in connection with a @e command - * value of #JNAV_RET_TYPED_JSON. Typical values are + * value of #TMH_PARSE_JNC_RET_TYPED_JSON. Typical values are * #JSON_ARRAY and #JSON_OBJECT. */ int type; @@ -209,14 +209,14 @@ struct GNUNET_MINT_ParseFieldSpec * @return * #GNUNET_YES if navigation was successful (caller is responsible * for freeing allocated variable-size data using - * #TALER_MINT_release_parsed_data() when done) + * #TMH_PARSE_release_data() when done) * #GNUNET_NO if json is malformed, error response was generated * #GNUNET_SYSERR on internal error */ int -TALER_MINT_parse_json_data (struct MHD_Connection *connection, +TMH_PARSE_json_data (struct MHD_Connection *connection, const json_t *root, - struct GNUNET_MINT_ParseFieldSpec *spec); + struct TMH_PARSE_FieldSpecification *spec); /** @@ -226,7 +226,7 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, * @param spec specification to free */ void -TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); +TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec); /** @@ -235,14 +235,14 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); * @param field name of the field * @param value where to store the value */ -#define TALER_MINT_PARSE_FIXED(field,value) { field, value, sizeof (*value), 0, JNAV_RET_DATA, 0 } +#define TMH_PARSE_MEMBER_FIXED(field,value) { field, value, sizeof (*value), 0, TMH_PARSE_JNC_RET_DATA, 0 } /** * Generate line in parser specification for variable-size value. * * @param field name of the field */ -#define TALER_MINT_PARSE_VARIABLE(field) { field, NULL, 0, 0, JNAV_RET_DATA_VAR, 0 } +#define TMH_PARSE_MEMBER_VARIABLE(field) { field, NULL, 0, 0, TMH_PARSE_JNC_RET_DATA_VAR, 0 } /** * Generate line in parser specification for JSON array value. @@ -250,7 +250,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); * @param field name of the field * @param ptraddr address of pointer to initialize (a `void **`) */ -#define TALER_MINT_PARSE_ARRAY(field,ptraddr) { field, ptraddr, 0, 0, JNAV_RET_TYPED_JSON, JSON_ARRAY } +#define TMH_PARSE_MEMBER_ARRAY(field,ptraddr) { field, ptraddr, 0, 0, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_ARRAY } /** * Generate line in parser specification for JSON object value. @@ -258,7 +258,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); * @param field name of the field * @param ptraddr address of pointer to initialize (a `void **`) */ -#define TALER_MINT_PARSE_OBJECT(field,ptraddr) { field, ptraddr, 0, 0, JNAV_RET_TYPED_JSON, JSON_OBJECT } +#define TMH_PARSE_MEMBER_OBJECT(field,ptraddr) { field, ptraddr, 0, 0, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_OBJECT } /** * Generate line in parser specification for RSA public key. @@ -266,7 +266,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); * @param field name of the field * @param ptraddr address of `struct GNUNET_CRYPTO_rsa_PublicKey *` initialize */ -#define TALER_MINT_PARSE_RSA_PUBLIC_KEY(field,ptrpk) { field, ptrpk, 0, 0, JNAV_RET_RSA_PUBLIC_KEY, 0 } +#define TMH_PARSE_MEMBER_RSA_PUBLIC_KEY(field,ptrpk) { field, ptrpk, 0, 0, TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, 0 } /** * Generate line in parser specification for RSA public key. @@ -274,7 +274,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); * @param field name of the field * @param ptrsig address of `struct GNUNET_CRYPTO_rsa_Signature *` initialize */ -#define TALER_MINT_PARSE_RSA_SIGNATURE(field,ptrsig) { field, ptrsig, 0, 0, JNAV_RET_RSA_SIGNATURE, 0 } +#define TMH_PARSE_MEMBER_RSA_SIGNATURE(field,ptrsig) { field, ptrsig, 0, 0, TMH_PARSE_JNC_RET_RSA_SIGNATURE, 0 } /** * Generate line in parser specification for an amount. @@ -282,12 +282,12 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); * @param field name of the field * @param amount a `struct TALER_Amount *` to initialize */ -#define TALER_MINT_PARSE_AMOUNT(field,amount) { field, amount, sizeof(*amount), 0, JNAV_RET_AMOUNT, 0 } +#define TMH_PARSE_MEMBER_AMOUNT(field,amount) { field, amount, sizeof(*amount), 0, TMH_PARSE_JNC_RET_AMOUNT, 0 } /** * Generate line in parser specification indicating the end of the spec. */ -#define TALER_MINT_PARSE_END { NULL, NULL, 0, 0, JNAV_FIELD, 0 } +#define TMH_PARSE_MEMBER_END { NULL, NULL, 0, 0, TMH_PARSE_JNC_FIELD, 0 } /** @@ -302,9 +302,9 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec); * #GNUNET_SYSERR on internal error, error response was not generated */ int -TALER_MINT_parse_amount_json (struct MHD_Connection *connection, - json_t *f, - struct TALER_Amount *amount); +TMH_PARSE_amount_json (struct MHD_Connection *connection, + json_t *f, + struct TALER_Amount *amount); /** @@ -323,10 +323,10 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, * #GNUNET_SYSERR on internal error (error response could not be sent) */ int -TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection, - const char *param_name, - void *out_data, - size_t out_size); +TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, + const char *param_name, + void *out_data, + size_t out_size); /** @@ -345,12 +345,12 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection, * #GNUNET_SYSERR on internal error (error response could not be sent) */ int -TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection, - const char *param_name, - void **out_data, - size_t *out_size); +TMH_PARSE_mhd_request_var_arg_data (struct MHD_Connection *connection, + const char *param_name, + void **out_data, + size_t *out_size); -#endif /* TALER_MICROHTTPD_LIB_H_ */ +#endif /* TALER_MINT_HTTPD_PARSING_H */ diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 5fc8fd5b0..e315555c9 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -60,15 +60,15 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, const struct TALER_DenominationPublicKey *denom_pubs, unsigned int coin_count, struct TALER_CoinPublicInfo *coin_public_infos, - const struct MeltDetails *coin_melt_details, + const struct TMH_DB_MeltDetails *coin_melt_details, const struct GNUNET_HashCode *session_hash, struct RefreshCommitCoin *const* commit_coin, struct RefreshCommitLink *const* commit_link) { unsigned int i; - struct MintKeyState *key_state; - struct TALER_MINT_DenomKeyIssue *dki; + struct TMH_KS_StateHandle *key_state; + struct TALER_DenominationKeyValidityPS *dki; struct TALER_Amount cost; struct TALER_Amount total_cost; struct TALER_Amount melt; @@ -78,12 +78,12 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, struct TALER_Amount total_melt; GNUNET_assert (GNUNET_OK == - TALER_amount_get_zero (MINT_CURRENCY, + TALER_amount_get_zero (TMH_MINT_CURRENCY, &total_cost)); - key_state = TALER_MINT_key_state_acquire (); + key_state = TMH_KS_acquire (); for (i=0;iissue; TALER_amount_ntoh (&value, &dki->value); @@ -98,20 +98,20 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, &cost, &total_cost)) ) { - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_internal_error (connection, + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_internal_error (connection, "cost calculation failure"); } } GNUNET_assert (GNUNET_OK == - TALER_amount_get_zero (MINT_CURRENCY, + TALER_amount_get_zero (TMH_MINT_CURRENCY, &total_melt)); for (i=0;iissue; TALER_amount_ntoh (&fee_melt, &dki->fee_refresh); @@ -120,8 +120,8 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, &coin_melt_details->melt_amount_with_fee, &fee_melt)) { - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_external_error (connection, + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_external_error (connection, "Melt contribution below melting fee"); } if (GNUNET_OK != @@ -129,24 +129,24 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, &melt, &total_melt)) { - TALER_MINT_key_state_release (key_state); - return TALER_MINT_reply_internal_error (connection, + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_internal_error (connection, "balance calculation failure"); } } - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); if (0 != TALER_amount_cmp (&total_cost, &total_melt)) { /* We require total value of coins being melted and total value of coins being generated to match! */ - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s}", "error", "value mismatch"); } - return TALER_MINT_db_execute_refresh_melt (connection, + return TMH_DB_execute_refresh_melt (connection, session_hash, num_new_denoms, denom_pubs, @@ -173,23 +173,23 @@ static int get_coin_public_info (struct MHD_Connection *connection, json_t *coin_info, struct TALER_CoinPublicInfo *r_public_info, - struct MeltDetails *r_melt_detail) + struct TMH_DB_MeltDetails *r_melt_detail) { int ret; - struct TALER_CoinSpendSignature melt_sig; + union TALER_CoinSpendSignatureP melt_sig; struct TALER_DenominationSignature sig; struct TALER_DenominationPublicKey pk; struct TALER_Amount amount; - struct GNUNET_MINT_ParseFieldSpec spec[] = { - TALER_MINT_PARSE_FIXED ("coin_pub", &r_public_info->coin_pub), - TALER_MINT_PARSE_RSA_SIGNATURE ("denom_sig", &sig.rsa_signature), - TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &pk.rsa_public_key), - TALER_MINT_PARSE_FIXED ("confirm_sig", &melt_sig), - TALER_MINT_PARSE_AMOUNT ("value_with_fee", &amount), - TALER_MINT_PARSE_END + struct TMH_PARSE_FieldSpecification spec[] = { + TMH_PARSE_MEMBER_FIXED ("coin_pub", &r_public_info->coin_pub), + TMH_PARSE_MEMBER_RSA_SIGNATURE ("denom_sig", &sig.rsa_signature), + TMH_PARSE_MEMBER_RSA_PUBLIC_KEY ("denom_pub", &pk.rsa_public_key), + TMH_PARSE_MEMBER_FIXED ("confirm_sig", &melt_sig), + TMH_PARSE_MEMBER_AMOUNT ("value_with_fee", &amount), + TMH_PARSE_MEMBER_END }; - ret = TALER_MINT_parse_json_data (connection, + ret = TMH_PARSE_json_data (connection, coin_info, spec); if (GNUNET_OK != ret) @@ -200,11 +200,11 @@ get_coin_public_info (struct MHD_Connection *connection, if (GNUNET_OK != TALER_test_coin_valid (r_public_info)) { - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); r_public_info->denom_sig.rsa_signature = NULL; r_public_info->denom_pub.rsa_public_key = NULL; return (MHD_YES == - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", "coin invalid")) @@ -212,7 +212,7 @@ get_coin_public_info (struct MHD_Connection *connection, } r_melt_detail->melt_sig = melt_sig; r_melt_detail->melt_amount_with_fee = amount; - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return GNUNET_OK; } @@ -236,41 +236,41 @@ static int verify_coin_public_info (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, const struct TALER_CoinPublicInfo *r_public_info, - const struct MeltDetails *r_melt_detail) + const struct TMH_DB_MeltDetails *r_melt_detail) { - struct RefreshMeltCoinSignature body; - struct MintKeyState *key_state; - struct TALER_MINT_DenomKeyIssuePriv *dki; + struct TALER_RefreshMeltCoinAffirmationPS body; + struct TMH_KS_StateHandle *key_state; + struct TALER_DenominationKeyIssueInformation *dki; struct TALER_Amount fee_refresh; - body.purpose.size = htonl (sizeof (struct RefreshMeltCoinSignature)); - body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_COIN); + body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + body.purpose.purpose = htonl (TALER_SIGNATURE_COIN_MELT); body.session_hash = *session_hash; TALER_amount_hton (&body.amount_with_fee, &r_melt_detail->melt_amount_with_fee); body.coin_pub = r_public_info->coin_pub; if (GNUNET_OK != - GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_REFRESH_MELT_COIN, + GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_COIN_MELT, &body.purpose, &r_melt_detail->melt_sig.ecdsa_signature, &r_public_info->coin_pub.ecdsa_pub)) { if (MHD_YES != - TALER_MINT_reply_json_pack (connection, + TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_UNAUTHORIZED, "{s:s}", "error", "signature invalid")) return GNUNET_SYSERR; return GNUNET_NO; } - key_state = TALER_MINT_key_state_acquire (); - dki = TALER_MINT_get_denom_key (key_state, + key_state = TMH_KS_acquire (); + dki = TMH_KS_denomination_key_lookup (key_state, &r_public_info->denom_pub); if (NULL == dki) { - TALER_MINT_key_state_release (key_state); - LOG_WARNING ("Unknown denomination key in /refresh/melt request\n"); - return TALER_MINT_reply_arg_invalid (connection, + TMH_KS_release (key_state); + TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n"); + return TMH_RESPONSE_reply_arg_invalid (connection, "denom_pub"); } /* FIXME: need to check if denomination key is still @@ -280,14 +280,14 @@ verify_coin_public_info (struct MHD_Connection *connection, if (TALER_amount_cmp (&fee_refresh, &r_melt_detail->melt_amount_with_fee) < 0) { - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); return (MHD_YES == - TALER_MINT_reply_external_error (connection, + TMH_RESPONSE_reply_external_error (connection, "melt amount smaller than melting fee")) ? GNUNET_NO : GNUNET_SYSERR; } - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); return GNUNET_OK; } @@ -357,11 +357,11 @@ free_commit_links (struct RefreshCommitLink **commit_link, * @param melt_sig_json signature affirming the melt operation * @param commit_signature signature over the commit * @param num_oldcoins number of coins that are being melted - * @param transfer_pubs #KAPPA-dimensional array of @a num_oldcoins transfer keys - * @param secret_encs #KAPPA-dimensional array of @a num_oldcoins secrets + * @param transfer_pubs #TALER_CNC_KAPPA-dimensional array of @a num_oldcoins transfer keys + * @param secret_encs #TALER_CNC_KAPPA-dimensional array of @a num_oldcoins secrets * @param num_newcoins number of coins that the refresh will generate - * @param coin_envs #KAPPA-dimensional array of @a num_newcoins envelopes to sign - * @param link_encs #KAPPA-dimensional array of @a num_newcoins encrypted links + * @param coin_envs #TALER_CNC_KAPPA-dimensional array of @a num_newcoins envelopes to sign + * @param link_encs #TALER_CNC_KAPPA-dimensional array of @a num_newcoins encrypted links * @return MHD result code */ static int @@ -384,12 +384,12 @@ handle_refresh_melt_json (struct MHD_Connection *connection, struct TALER_DenominationPublicKey *denom_pubs; unsigned int num_new_denoms; struct TALER_CoinPublicInfo *coin_public_infos; - struct MeltDetails *coin_melt_details; + struct TMH_DB_MeltDetails *coin_melt_details; unsigned int coin_count; struct GNUNET_HashCode session_hash; struct GNUNET_HashContext *hash_context; - struct RefreshCommitCoin *commit_coin[KAPPA]; - struct RefreshCommitLink *commit_link[KAPPA]; + struct RefreshCommitCoin *commit_coin[TALER_CNC_KAPPA]; + struct RefreshCommitLink *commit_link[TALER_CNC_KAPPA]; /* For the signature check, we hash most of the inputs together (except for the signatures on the coins). */ @@ -402,10 +402,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection, char *buf; size_t buf_size; - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, new_denoms, - JNAV_INDEX, (int) i, - JNAV_RET_RSA_PUBLIC_KEY, + TMH_PARSE_JNC_INDEX, (int) i, + TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, &denom_pubs[i].rsa_public_key); if (GNUNET_OK != res) { @@ -423,12 +423,12 @@ handle_refresh_melt_json (struct MHD_Connection *connection, } coin_count = json_array_size (melt_coins); - /* FIXME: make 'struct TALER_CoinPublicInfo' part of `struct MeltDetails` + /* FIXME: make 'struct TALER_CoinPublicInfo' part of `struct TMH_DB_MeltDetails` and combine these two arrays/arguments! (#3726) */ coin_public_infos = GNUNET_malloc (coin_count * sizeof (struct TALER_CoinPublicInfo)); coin_melt_details = GNUNET_malloc (coin_count * - sizeof (struct MeltDetails)); + sizeof (struct TMH_DB_MeltDetails)); for (i=0;icoin_ev, &rcc->coin_ev_size); @@ -511,25 +511,25 @@ handle_refresh_melt_json (struct MHD_Connection *connection, { GNUNET_CRYPTO_hash_context_abort (hash_context); free_commit_coins (commit_coin, - KAPPA, + TALER_CNC_KAPPA, num_newcoins); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } GNUNET_CRYPTO_hash_context_read (hash_context, rcc->coin_ev, rcc->coin_ev_size); - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, link_encs, - JNAV_INDEX, (int) i, - JNAV_INDEX, (int) j, - JNAV_RET_DATA_VAR, + TMH_PARSE_JNC_INDEX, (int) i, + TMH_PARSE_JNC_INDEX, (int) j, + TMH_PARSE_JNC_RET_DATA_VAR, &link_enc, &link_enc_size); if (GNUNET_OK != res) { GNUNET_CRYPTO_hash_context_abort (hash_context); free_commit_coins (commit_coin, - KAPPA, + TALER_CNC_KAPPA, num_newcoins); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } @@ -542,7 +542,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, } } - for (i = 0; i < KAPPA; i++) + for (i = 0; i < TALER_CNC_KAPPA; i++) { commit_link[i] = GNUNET_malloc (num_oldcoins * sizeof (struct RefreshCommitLink)); @@ -550,31 +550,31 @@ handle_refresh_melt_json (struct MHD_Connection *connection, { struct RefreshCommitLink *rcl = &commit_link[i][j]; - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, transfer_pubs, - JNAV_INDEX, (int) i, - JNAV_INDEX, (int) j, - JNAV_RET_DATA, + TMH_PARSE_JNC_INDEX, (int) i, + TMH_PARSE_JNC_INDEX, (int) j, + TMH_PARSE_JNC_RET_DATA, &rcl->transfer_pub, - sizeof (struct TALER_TransferPublicKey)); + sizeof (struct TALER_TransferPublicKeyP)); if (GNUNET_OK != res) { GNUNET_break (GNUNET_SYSERR != res); GNUNET_CRYPTO_hash_context_abort (hash_context); free_commit_coins (commit_coin, - KAPPA, + TALER_CNC_KAPPA, num_newcoins); free_commit_links (commit_link, - KAPPA, + TALER_CNC_KAPPA, num_oldcoins); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, secret_encs, - JNAV_INDEX, (int) i, - JNAV_INDEX, (int) j, - JNAV_RET_DATA, + TMH_PARSE_JNC_INDEX, (int) i, + TMH_PARSE_JNC_INDEX, (int) j, + TMH_PARSE_JNC_RET_DATA, &rcl->shared_secret_enc, sizeof (struct GNUNET_HashCode)); @@ -583,10 +583,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection, GNUNET_break (GNUNET_SYSERR != res); GNUNET_CRYPTO_hash_context_abort (hash_context); free_commit_coins (commit_coin, - KAPPA, + TALER_CNC_KAPPA, num_newcoins); free_commit_links (commit_link, - KAPPA, + TALER_CNC_KAPPA, num_oldcoins); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } @@ -626,10 +626,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection, commit_link); cleanup: free_commit_coins (commit_coin, - KAPPA, + TALER_CNC_KAPPA, num_newcoins); free_commit_links (commit_link, - KAPPA, + TALER_CNC_KAPPA, num_oldcoins); for (j=0;jdetails.deposit; type = "deposit"; value = deposit->amount_with_fee; dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_DEPOSIT); - dr.purpose.size = htonl (sizeof (struct TALER_DepositRequest)); + dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS)); dr.h_contract = deposit->h_contract; dr.h_wire = deposit->h_wire; dr.transaction_id = GNUNET_htonll (deposit->transaction_id); TALER_amount_hton (&dr.amount_with_fee, &deposit->amount_with_fee); dr.coin_pub = deposit->coin.coin_pub; - transaction = TALER_JSON_from_ecdsa_sig (&dr.purpose, + transaction = TALER_json_from_ecdsa_sig (&dr.purpose, &deposit->csig.ecdsa_signature); break; } case TALER_MINT_DB_TT_REFRESH_MELT: { - struct RefreshMeltCoinSignature ms; + struct TALER_RefreshMeltCoinAffirmationPS ms; const struct RefreshMelt *melt = pos->details.melt; type = "melt"; value = melt->amount_with_fee; - ms.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_COIN); - ms.purpose.size = htonl (sizeof (struct RefreshMeltCoinSignature)); + ms.purpose.purpose = htonl (TALER_SIGNATURE_COIN_MELT); + ms.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); ms.session_hash = melt->session_hash; TALER_amount_hton (&ms.amount_with_fee, &melt->amount_with_fee); ms.coin_pub = melt->coin.coin_pub; - transaction = TALER_JSON_from_ecdsa_sig (&ms.purpose, + transaction = TALER_json_from_ecdsa_sig (&ms.purpose, &melt->coin_sig.ecdsa_signature); } break; @@ -387,7 +387,7 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl) json_array_append_new (history, json_pack ("{s:s, s:o}", "type", type, - "amount", TALER_JSON_from_amount (&value), + "amount", TALER_json_from_amount (&value), "signature", transaction)); } return history; @@ -404,13 +404,13 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl) * @return MHD result code */ int -TALER_MINT_reply_deposit_insufficient_funds (struct MHD_Connection *connection, +TMH_RESPONSE_reply_deposit_insufficient_funds (struct MHD_Connection *connection, const struct TALER_MINT_DB_TransactionList *tl) { json_t *history; history = compile_transaction_history (tl); - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_FORBIDDEN, "{s:s, s:o}", "error", "insufficient funds", @@ -437,9 +437,9 @@ compile_reserve_history (const struct ReserveHistory *rh, json_t *transaction; int ret; const struct ReserveHistory *pos; - struct TALER_MINT_DenomKeyIssuePriv *dki; - struct MintKeyState *key_state; - struct TALER_WithdrawRequest wr; + struct TALER_DenominationKeyIssueInformation *dki; + struct TMH_KS_StateHandle *key_state; + struct TALER_WithdrawRequestPS wr; json_history = json_array (); ret = 0; @@ -464,14 +464,14 @@ compile_reserve_history (const struct ReserveHistory *rh, json_pack ("{s:s, s:o, s:o}", "type", "DEPOSIT", "wire", pos->details.bank->wire, - "amount", TALER_JSON_from_amount (&pos->details.bank->amount))); + "amount", TALER_json_from_amount (&pos->details.bank->amount))); break; case TALER_MINT_DB_RO_WITHDRAW_COIN: break; } } - key_state = TALER_MINT_key_state_acquire (); + key_state = TMH_KS_acquire (); ret = 0; for (pos = rh; NULL != pos; pos = pos->next) { @@ -481,7 +481,7 @@ compile_reserve_history (const struct ReserveHistory *rh, break; case TALER_MINT_DB_RO_WITHDRAW_COIN: - dki = TALER_MINT_get_denom_key (key_state, + dki = TMH_KS_denomination_key_lookup (key_state, &pos->details.withdraw->denom_pub); TALER_amount_ntoh (&value, &dki->issue.value); @@ -493,31 +493,31 @@ compile_reserve_history (const struct ReserveHistory *rh, &withdraw_total, &value)) { - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); json_decref (json_history); return NULL; } ret = 1; - wr.purpose.purpose = htonl (TALER_SIGNATURE_WITHDRAW); - wr.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest)); + wr.purpose.purpose = htonl (TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST); + wr.purpose.size = htonl (sizeof (struct TALER_WithdrawRequestPS)); wr.reserve_pub = pos->details.withdraw->reserve_pub; GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub.rsa_public_key, &wr.h_denomination_pub); wr.h_coin_envelope = pos->details.withdraw->h_coin_envelope; - transaction = TALER_JSON_from_eddsa_sig (&wr.purpose, + transaction = TALER_json_from_eddsa_sig (&wr.purpose, &pos->details.withdraw->reserve_sig.eddsa_signature); json_array_append_new (json_history, json_pack ("{s:s, s:o, s:o}", "type", "WITHDRAW", "signature", transaction, - "amount", TALER_JSON_from_amount (&value))); + "amount", TALER_json_from_amount (&value))); break; } } - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); if (GNUNET_SYSERR == TALER_amount_subtract (balance, @@ -540,7 +540,7 @@ compile_reserve_history (const struct ReserveHistory *rh, * @return MHD result code */ int -TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, +TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection, const struct ReserveHistory *rh) { json_t *json_balance; @@ -551,10 +551,10 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, json_history = compile_reserve_history (rh, &balance); if (NULL == json_history) - return TALER_MINT_reply_internal_error (connection, + return TMH_RESPONSE_reply_internal_error (connection, "balance calculation failure"); - json_balance = TALER_JSON_from_amount (&balance); - ret = TALER_MINT_reply_json_pack (connection, + json_balance = TALER_json_from_amount (&balance); + ret = TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o}", "balance", json_balance, @@ -575,7 +575,7 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection, +TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection, const struct ReserveHistory *rh) { json_t *json_balance; @@ -586,10 +586,10 @@ TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connec json_history = compile_reserve_history (rh, &balance); if (NULL == json_history) - return TALER_MINT_reply_internal_error (connection, + return TMH_RESPONSE_reply_internal_error (connection, "balance calculation failure"); - json_balance = TALER_JSON_from_amount (&balance); - ret = TALER_MINT_reply_json_pack (connection, + json_balance = TALER_json_from_amount (&balance); + ret = TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_PAYMENT_REQUIRED, "{s:s, s:o, s:o}", "error", "Insufficient funds" @@ -609,14 +609,14 @@ TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connec * @return MHD result code */ int -TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection, +TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection, const struct CollectableBlindcoin *collectable) { json_t *sig_json; int ret; - sig_json = TALER_JSON_from_rsa_signature (collectable->sig.rsa_signature); - ret = TALER_MINT_reply_json_pack (connection, + sig_json = TALER_json_from_rsa_signature (collectable->sig.rsa_signature); + ret = TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o}", "ev_sig", sig_json); @@ -641,8 +641,8 @@ TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKey *coin_pub, +TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, + const union TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_Amount coin_value, struct TALER_MINT_DB_TransactionList *tl, struct TALER_Amount requested, @@ -651,15 +651,15 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect json_t *history; history = compile_transaction_history (tl); - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s, s:o, s:o, s:o, s:o, s:o}", "error", "insufficient funds", - "coin-pub", TALER_JSON_from_data (coin_pub, - sizeof (struct TALER_CoinSpendPublicKey)), - "original-value", TALER_JSON_from_amount (&coin_value), - "residual-value", TALER_JSON_from_amount (&residual), - "requested-value", TALER_JSON_from_amount (&requested), + "coin-pub", TALER_json_from_data (coin_pub, + sizeof (union TALER_CoinSpendPublicKeyP)), + "original-value", TALER_json_from_amount (&coin_value), + "residual-value", TALER_json_from_amount (&residual), + "requested-value", TALER_json_from_amount (&requested), "history", history); } @@ -673,25 +673,25 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect * @return a MHD status code */ int -TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, +TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, uint16_t noreveal_index) { - struct RefreshMeltResponseSignatureBody body; - struct TALER_MintSignature sig; + struct TALER_RefreshMeltConfirmationPS body; + struct TALER_MintSignatureP sig; json_t *sig_json; int ret; - body.purpose.size = htonl (sizeof (struct RefreshMeltResponseSignatureBody)); - body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_RESPONSE); + body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltConfirmationPS)); + body.purpose.purpose = htonl (TALER_SIGNATURE_MINT_MELT_RESPONSE); body.session_hash = *session_hash; body.noreveal_index = htons (noreveal_index); - TALER_MINT_keys_sign (&body.purpose, + TMH_KS_sign (&body.purpose, &sig); - sig_json = TALER_JSON_from_eddsa_sig (&body.purpose, + sig_json = TALER_json_from_eddsa_sig (&body.purpose, &sig.eddsa_signature); GNUNET_assert (NULL != sig_json); - ret = TALER_MINT_reply_json_pack (connection, + ret = TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:i, s:o}", "noreveal_index", (int) noreveal_index, @@ -710,7 +710,7 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, +TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection, unsigned int num_newcoins, const struct TALER_DenominationSignature *sigs) { @@ -726,8 +726,8 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, list); for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++) json_array_append_new (list, - TALER_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature)); - ret = TALER_MINT_reply_json (connection, + TALER_json_from_rsa_signature (sigs[newcoin_index].rsa_signature)); + ret = TMH_RESPONSE_reply_json (connection, root, MHD_HTTP_OK); json_decref (root); @@ -753,12 +753,12 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, +TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, unsigned int off, unsigned int j, const char *missmatch_object) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:i, s:i, s:s}", "error", "commitment violation", @@ -778,9 +778,9 @@ TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, - const struct TALER_TransferPublicKey *transfer_pub, - const struct TALER_EncryptedLinkSecret *shared_secret_enc, +TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection, + const struct TALER_TransferPublicKeyP *transfer_pub, + const struct TALER_EncryptedLinkSecretP *shared_secret_enc, const struct LinkDataList *ldl) { const struct LinkDataList *pos; @@ -795,15 +795,15 @@ TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, obj = json_object (); json_object_set_new (obj, "link_enc", - TALER_JSON_from_data (ldl->link_data_enc->coin_priv_enc, - sizeof (struct TALER_CoinSpendPrivateKey) + + TALER_json_from_data (ldl->link_data_enc->coin_priv_enc, + sizeof (union TALER_CoinSpendPrivateKeyP) + ldl->link_data_enc->blinding_key_enc_size)); json_object_set_new (obj, "denom_pub", - TALER_JSON_from_rsa_public_key (ldl->denom_pub.rsa_public_key)); + TALER_json_from_rsa_public_key (ldl->denom_pub.rsa_public_key)); json_object_set_new (obj, "ev_sig", - TALER_JSON_from_rsa_signature (ldl->ev_sig.rsa_signature)); + TALER_json_from_rsa_signature (ldl->ev_sig.rsa_signature)); json_array_append_new (list, obj); } @@ -813,13 +813,13 @@ TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, list); json_object_set_new (root, "transfer_pub", - TALER_JSON_from_data (transfer_pub, - sizeof (struct TALER_TransferPublicKey))); + TALER_json_from_data (transfer_pub, + sizeof (struct TALER_TransferPublicKeyP))); json_object_set_new (root, "secret_enc", - TALER_JSON_from_data (shared_secret_enc, - sizeof (struct TALER_EncryptedLinkSecret))); - res = TALER_MINT_reply_json (connection, + TALER_json_from_data (shared_secret_enc, + sizeof (struct TALER_EncryptedLinkSecretP))); + res = TMH_RESPONSE_reply_json (connection, root, MHD_HTTP_OK); json_decref (root); diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index d7e563505..c3a8daa70 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h @@ -17,7 +17,7 @@ /** * @file taler-mint-httpd_responses.h * @brief API for generating the various replies of the mint; these - * functions are called TALER_MINT_reply_ and they generate + * functions are called TMH_RESPONSE_reply_ and they generate * and queue MHD response objects for a given connection. * @author Florian Dold * @author Benedikt Mueller @@ -42,9 +42,9 @@ * @return MHD result code */ int -TALER_MINT_reply_json (struct MHD_Connection *connection, - const json_t *json, - unsigned int response_code); +TMH_RESPONSE_reply_json (struct MHD_Connection *connection, + const json_t *json, + unsigned int response_code); /** @@ -58,10 +58,10 @@ TALER_MINT_reply_json (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_json_pack (struct MHD_Connection *connection, - unsigned int response_code, - const char *fmt, - ...); +TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, + unsigned int response_code, + const char *fmt, + ...); /** @@ -72,8 +72,8 @@ TALER_MINT_reply_json_pack (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection, - const char *param_name); +TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, + const char *param_name); /** @@ -85,7 +85,7 @@ TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_coin_invalid (struct MHD_Connection *connection); +TMH_RESPONSE_reply_coin_invalid (struct MHD_Connection *connection); /** @@ -96,8 +96,8 @@ TALER_MINT_reply_coin_invalid (struct MHD_Connection *connection); * @return a MHD result code */ int -TALER_MINT_reply_arg_missing (struct MHD_Connection *connection, - const char *param_name); +TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, + const char *param_name); /** @@ -108,8 +108,8 @@ TALER_MINT_reply_arg_missing (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_internal_error (struct MHD_Connection *connection, - const char *hint); +TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, + const char *hint); /** @@ -120,8 +120,8 @@ TALER_MINT_reply_internal_error (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_external_error (struct MHD_Connection *connection, - const char *hint); +TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection, + const char *hint); /** @@ -132,7 +132,7 @@ TALER_MINT_reply_external_error (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_commit_error (struct MHD_Connection *connection); +TMH_RESPONSE_reply_commit_error (struct MHD_Connection *connection); /** @@ -143,7 +143,7 @@ TALER_MINT_reply_commit_error (struct MHD_Connection *connection); * @return a MHD result code */ int -TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection); +TMH_RESPONSE_reply_internal_db_error (struct MHD_Connection *connection); /** @@ -153,7 +153,7 @@ TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection); * @return a MHD result code */ int -TALER_MINT_reply_request_too_large (struct MHD_Connection *connection); +TMH_RESPONSE_reply_request_too_large (struct MHD_Connection *connection); /** @@ -163,7 +163,7 @@ TALER_MINT_reply_request_too_large (struct MHD_Connection *connection); * @return a MHD result code */ int -TALER_MINT_reply_invalid_json (struct MHD_Connection *connection); +TMH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection); /** @@ -184,13 +184,13 @@ TALER_MINT_reply_invalid_json (struct MHD_Connection *connection); * @return MHD result code */ int -TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKey *coin_pub, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract, - uint64_t transaction_id, - const struct TALER_MerchantPublicKey *merchant, - const struct TALER_Amount *amount); +TMH_RESPONSE_reply_deposit_success (struct MHD_Connection *connection, + const union TALER_CoinSpendPublicKeyP *coin_pub, + const struct GNUNET_HashCode *h_wire, + const struct GNUNET_HashCode *h_contract, + uint64_t transaction_id, + const struct TALER_MerchantPublicKeyP *merchant, + const struct TALER_Amount *amount); /** @@ -203,8 +203,8 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_deposit_insufficient_funds (struct MHD_Connection *connection, - const struct TALER_MINT_DB_TransactionList *tl); +TMH_RESPONSE_reply_deposit_insufficient_funds (struct MHD_Connection *connection, + const struct TALER_MINT_DB_TransactionList *tl); /** @@ -215,8 +215,8 @@ TALER_MINT_reply_deposit_insufficient_funds (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, - const struct ReserveHistory *rh); +TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection, + const struct ReserveHistory *rh); /** @@ -229,8 +229,8 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection, - const struct ReserveHistory *rh); +TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection, + const struct ReserveHistory *rh); /** @@ -241,8 +241,8 @@ TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connec * @return MHD result code */ int -TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection, - const struct CollectableBlindcoin *collectable); +TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection, + const struct CollectableBlindcoin *collectable); /** @@ -254,9 +254,9 @@ TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection, * @return a MHD status code */ int -TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, - const struct GNUNET_HashCode *session_hash, - uint16_t noreveal_index); +TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection, + const struct GNUNET_HashCode *session_hash, + uint16_t noreveal_index); /** @@ -275,12 +275,12 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKey *coin_pub, - struct TALER_Amount coin_value, - struct TALER_MINT_DB_TransactionList *tl, - struct TALER_Amount requested, - struct TALER_Amount residual); +TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, + const union TALER_CoinSpendPublicKeyP *coin_pub, + struct TALER_Amount coin_value, + struct TALER_MINT_DB_TransactionList *tl, + struct TALER_Amount requested, + struct TALER_Amount residual); /** @@ -292,9 +292,9 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect * @return a MHD result code */ int -TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, - unsigned int num_newcoins, - const struct TALER_DenominationSignature *sigs); +TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection, + unsigned int num_newcoins, + const struct TALER_DenominationSignature *sigs); /** @@ -315,10 +315,10 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, - unsigned int off, - unsigned int j, - const char *missmatch_object); +TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, + unsigned int off, + unsigned int j, + const char *missmatch_object); /** @@ -331,10 +331,10 @@ TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, - const struct TALER_TransferPublicKey *transfer_pub, - const struct TALER_EncryptedLinkSecret *shared_secret_enc, - const struct LinkDataList *ldl); +TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection, + const struct TALER_TransferPublicKeyP *transfer_pub, + const struct TALER_EncryptedLinkSecretP *shared_secret_enc, + const struct LinkDataList *ldl); #endif diff --git a/src/mint/taler-mint-httpd_withdraw.c b/src/mint/taler-mint-httpd_withdraw.c index 7d7ca8060..0d700df6f 100644 --- a/src/mint/taler-mint-httpd_withdraw.c +++ b/src/mint/taler-mint-httpd_withdraw.c @@ -43,24 +43,24 @@ * @return MHD result code */ int -TALER_MINT_handler_withdraw_status (struct RequestHandler *rh, +TMH_WITHDRAW_handler_withdraw_status (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, size_t *upload_data_size) { - struct TALER_ReservePublicKey reserve_pub; + struct TALER_ReservePublicKeyP reserve_pub; int res; - res = TALER_MINT_mhd_request_arg_data (connection, + res = TMH_PARSE_mhd_request_arg_data (connection, "reserve_pub", &reserve_pub, - sizeof (struct TALER_ReservePublicKey)); + sizeof (struct TALER_ReservePublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) return MHD_YES; /* parse error */ - return TALER_MINT_db_execute_withdraw_status (connection, + return TMH_DB_execute_withdraw_status (connection, &reserve_pub); } @@ -82,38 +82,38 @@ TALER_MINT_handler_withdraw_status (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, +TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, size_t *upload_data_size) { - struct TALER_WithdrawRequest wsrd; + struct TALER_WithdrawRequestPS wsrd; int res; struct TALER_DenominationPublicKey denomination_pub; char *denomination_pub_data; size_t denomination_pub_data_size; char *blinded_msg; size_t blinded_msg_len; - struct TALER_ReserveSignature signature; + struct TALER_ReserveSignatureP signature; - res = TALER_MINT_mhd_request_arg_data (connection, + res = TMH_PARSE_mhd_request_arg_data (connection, "reserve_pub", &wsrd.reserve_pub, - sizeof (struct TALER_ReservePublicKey)); + sizeof (struct TALER_ReservePublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) return MHD_YES; /* invalid request */ - res = TALER_MINT_mhd_request_arg_data (connection, + res = TMH_PARSE_mhd_request_arg_data (connection, "reserve_sig", &signature, - sizeof (struct TALER_ReserveSignature)); + sizeof (struct TALER_ReserveSignatureP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) return MHD_YES; /* invalid request */ - res = TALER_MINT_mhd_request_var_arg_data (connection, + res = TMH_PARSE_mhd_request_var_arg_data (connection, "denom_pub", (void **) &denomination_pub_data, &denomination_pub_data_size); @@ -121,7 +121,7 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, return MHD_NO; /* internal error */ if (GNUNET_NO == res) return MHD_YES; /* invalid request */ - res = TALER_MINT_mhd_request_var_arg_data (connection, + res = TMH_PARSE_mhd_request_var_arg_data (connection, "coin_ev", (void **) &blinded_msg, &blinded_msg_len); @@ -137,8 +137,8 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, } /* verify signature! */ - wsrd.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest)); - wsrd.purpose.purpose = htonl (TALER_SIGNATURE_WITHDRAW); + wsrd.purpose.size = htonl (sizeof (struct TALER_WithdrawRequestPS)); + wsrd.purpose.purpose = htonl (TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST); GNUNET_CRYPTO_hash (denomination_pub_data, denomination_pub_data_size, &wsrd.h_denomination_pub); @@ -146,15 +146,15 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, blinded_msg_len, &wsrd.h_coin_envelope); if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WITHDRAW, + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST, &wsrd.purpose, &signature.eddsa_signature, &wsrd.reserve_pub.eddsa_pub)) { - LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n"); + TALER_LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n"); GNUNET_free (denomination_pub_data); GNUNET_free (blinded_msg); - return TALER_MINT_reply_arg_invalid (connection, + return TMH_RESPONSE_reply_arg_invalid (connection, "reserve_sig"); } denomination_pub.rsa_public_key @@ -163,12 +163,12 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, GNUNET_free (denomination_pub_data); if (NULL == denomination_pub.rsa_public_key) { - LOG_WARNING ("Client supplied ill-formed denomination public key for /withdraw/sign request\n"); + TALER_LOG_WARNING ("Client supplied ill-formed denomination public key for /withdraw/sign request\n"); GNUNET_free (blinded_msg); - return TALER_MINT_reply_arg_invalid (connection, + return TMH_RESPONSE_reply_arg_invalid (connection, "denom_pub"); } - res = TALER_MINT_db_execute_withdraw_sign (connection, + res = TMH_DB_execute_withdraw_sign (connection, &wsrd.reserve_pub, &denomination_pub, blinded_msg, diff --git a/src/mint/taler-mint-httpd_withdraw.h b/src/mint/taler-mint-httpd_withdraw.h index ff1dedc5d..abf97a1d4 100644 --- a/src/mint/taler-mint-httpd_withdraw.h +++ b/src/mint/taler-mint-httpd_withdraw.h @@ -40,11 +40,11 @@ * @return MHD result code */ int -TALER_MINT_handler_withdraw_status (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_WITHDRAW_handler_withdraw_status (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -64,10 +64,10 @@ TALER_MINT_handler_withdraw_status (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/mint/taler-mint-keycheck.c b/src/mint/taler-mint-keycheck.c index 370b1c51a..4e8885fd3 100644 --- a/src/mint/taler-mint-keycheck.c +++ b/src/mint/taler-mint-keycheck.c @@ -29,7 +29,7 @@ /** * Mint directory with the keys. */ -static char *mintdir; +static char *mint_directory; /** * Our configuration. @@ -50,7 +50,7 @@ static struct GNUNET_CONFIGURATION_Handle *kcfg; static int signkeys_iter (void *cls, const char *filename, - const struct TALER_MINT_SignKeyIssuePriv *ski) + const struct TALER_MintSigningKeyValidityPSPriv *ski) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iterating over key `%s' for start time %s\n", @@ -59,8 +59,8 @@ signkeys_iter (void *cls, (GNUNET_TIME_absolute_ntoh (ski->issue.start))); if (ntohl (ski->issue.purpose.size) != - (sizeof (struct TALER_MINT_SignKeyIssue) - - offsetof (struct TALER_MINT_SignKeyIssue, purpose))) + (sizeof (struct TALER_MintSigningKeyValidityPS) - + offsetof (struct TALER_MintSigningKeyValidityPS, purpose))) { fprintf (stderr, "Signing key `%s' has invalid purpose size\n", @@ -68,10 +68,10 @@ signkeys_iter (void *cls, return GNUNET_SYSERR; } if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY, + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY, &ski->issue.purpose, &ski->issue.signature.eddsa_signature, - &ski->issue.master_pub.eddsa_pub)) + &ski->issue.master_public_key.eddsa_pub)) { fprintf (stderr, "Signing key `%s' has invalid signature\n", @@ -93,7 +93,7 @@ signkeys_iter (void *cls, static int mint_signkeys_check () { - if (0 > TALER_MINT_signkeys_iterate (mintdir, + if (0 > TALER_MINT_signkeys_iterate (mint_directory, &signkeys_iter, NULL)) return GNUNET_NO; @@ -114,12 +114,12 @@ mint_signkeys_check () static int denomkeys_iter (void *cls, const char *alias, - const struct TALER_MINT_DenomKeyIssuePriv *dki) + const struct TALER_DenominationKeyIssueInformation *dki) { struct GNUNET_HashCode hc; if (ntohl (dki->issue.purpose.size) != - sizeof (struct TALER_MINT_DenomKeyIssue)) + sizeof (struct TALER_DenominationKeyValidityPS)) { fprintf (stderr, "Denomination key for `%s' has invalid purpose size\n", @@ -128,7 +128,7 @@ denomkeys_iter (void *cls, } if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM, + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY, &dki->issue.purpose, &dki->issue.signature.eddsa_signature, &dki->issue.master.eddsa_pub)) @@ -165,7 +165,7 @@ denomkeys_iter (void *cls, static int mint_denomkeys_check () { - if (0 > TALER_MINT_denomkeys_iterate (mintdir, + if (0 > TALER_MINT_denomkeys_iterate (mint_directory, &denomkeys_iter, NULL)) return GNUNET_NO; @@ -187,7 +187,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-keycheck OPTIONS"), {'d', "directory", "DIRECTORY", "mint directory with keys to check", 1, - &GNUNET_GETOPT_set_filename, &mintdir}, + &GNUNET_GETOPT_set_filename, &mint_directory}, GNUNET_GETOPT_OPTION_END }; @@ -200,14 +200,14 @@ main (int argc, char *const *argv) options, argc, argv) < 0) return 1; - if (NULL == mintdir) + if (NULL == mint_directory) { fprintf (stderr, "Mint directory not given\n"); return 1; } - kcfg = TALER_config_load (mintdir); + kcfg = TALER_config_load (mint_directory); if (NULL == kcfg) { fprintf (stderr, diff --git a/src/mint/taler-mint-keyup.c b/src/mint/taler-mint-keyup.c index 603154f65..ab457426c 100644 --- a/src/mint/taler-mint-keyup.c +++ b/src/mint/taler-mint-keyup.c @@ -51,7 +51,7 @@ GNUNET_NETWORK_STRUCT_BEGIN * Struct with all of the key information for a kind of coin. Hashed * to generate a unique directory name per coin type. */ -struct CoinTypeNBO +struct CoinTypeNBOP { /** * How long can the coin be spend? @@ -158,7 +158,7 @@ static char *masterkeyfile; /** * Director of the mint, containing the keys. */ -static char *mintdir; +static char *mint_directory; /** * Time to pretend when the key update is executed. @@ -179,12 +179,12 @@ static struct GNUNET_TIME_Absolute now; /** * Master private key of the mint. */ -static struct TALER_MasterPrivateKey master_priv; +static struct TALER_MasterPrivateKeyP master_priv; /** * Master public key of the mint. */ -static struct TALER_MasterPublicKey master_pub; +static struct TALER_MasterPublicKeyP master_public_key; /** * Until what time do we provide keys? @@ -208,7 +208,7 @@ get_signkey_file (struct GNUNET_TIME_Absolute start) GNUNET_snprintf (dir, sizeof (dir), "%s" DIR_SEPARATOR_STR DIR_SIGNKEYS DIR_SEPARATOR_STR "%llu", - mintdir, + mint_directory, (unsigned long long) start.abs_value_us); return dir; } @@ -226,11 +226,11 @@ static void hash_coin_type (const struct CoinTypeParams *p, struct GNUNET_HashCode *hash) { - struct CoinTypeNBO p_nbo; + struct CoinTypeNBOP p_nbo; memset (&p_nbo, 0, - sizeof (struct CoinTypeNBO)); + sizeof (struct CoinTypeNBOP)); p_nbo.duration_spend = GNUNET_TIME_relative_hton (p->duration_spend); p_nbo.duration_withdraw = GNUNET_TIME_relative_hton (p->duration_withdraw); TALER_amount_hton (&p_nbo.value, @@ -243,7 +243,7 @@ hash_coin_type (const struct CoinTypeParams *p, &p->fee_refresh); p_nbo.rsa_keysize = htonl (p->rsa_keysize); GNUNET_CRYPTO_hash (&p_nbo, - sizeof (struct CoinTypeNBO), + sizeof (struct CoinTypeNBOP), hash); } @@ -286,7 +286,7 @@ get_cointype_dir (const struct CoinTypeParams *p) GNUNET_snprintf (dir, sizeof (dir), "%s" DIR_SEPARATOR_STR DIR_DENOMKEYS DIR_SEPARATOR_STR "%s-%s", - mintdir, + mint_directory, val_str, hash_str); GNUNET_free (hash_str); @@ -434,23 +434,23 @@ get_anchor (const char *dir, static void create_signkey_issue_priv (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration, - struct TALER_MINT_SignKeyIssuePriv *pi) + struct TALER_MintSigningKeyValidityPSPriv *pi) { struct GNUNET_CRYPTO_EddsaPrivateKey *priv; - struct TALER_MINT_SignKeyIssue *issue = &pi->issue; + struct TALER_MintSigningKeyValidityPS *issue = &pi->issue; priv = GNUNET_CRYPTO_eddsa_key_create (); pi->signkey_priv.eddsa_priv = *priv; GNUNET_free (priv); - issue->master_pub = master_pub; + issue->master_public_key = master_public_key; issue->start = GNUNET_TIME_absolute_hton (start); issue->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (start, duration)); GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv.eddsa_priv, &issue->signkey_pub.eddsa_pub); - issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY); - issue->purpose.size = htonl (sizeof (struct TALER_MINT_SignKeyIssue) - - offsetof (struct TALER_MINT_SignKeyIssue, + issue->purpose.purpose = htonl (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY); + issue->purpose.size = htonl (sizeof (struct TALER_MintSigningKeyValidityPS) - + offsetof (struct TALER_MintSigningKeyValidityPS, purpose)); GNUNET_assert (GNUNET_OK == @@ -488,7 +488,7 @@ mint_keys_update_signkeys () rel_value_us); GNUNET_asprintf (&signkey_dir, "%s" DIR_SEPARATOR_STR DIR_SIGNKEYS, - mintdir); + mint_directory); /* make sure the directory exists */ if (GNUNET_OK != GNUNET_DISK_directory_create (signkey_dir)) @@ -506,7 +506,7 @@ mint_keys_update_signkeys () while (anchor.abs_value_us < lookahead_sign_stamp.abs_value_us) { const char *skf; - struct TALER_MINT_SignKeyIssuePriv signkey_issue; + struct TALER_MintSigningKeyValidityPSPriv signkey_issue; ssize_t nwrite; skf = get_signkey_file (anchor); @@ -520,9 +520,9 @@ mint_keys_update_signkeys () &signkey_issue); nwrite = GNUNET_DISK_fn_write (skf, &signkey_issue, - sizeof (struct TALER_MINT_SignKeyIssue), + sizeof (struct TALER_MintSigningKeyValidityPS), GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ); - if (nwrite != sizeof (struct TALER_MINT_SignKeyIssue)) + if (nwrite != sizeof (struct TALER_MintSigningKeyValidityPS)) { fprintf (stderr, "Failed to write to file `%s': %s\n", @@ -676,7 +676,7 @@ get_cointype_params (const char *ct, */ static void create_denomkey_issue (const struct CoinTypeParams *params, - struct TALER_MINT_DenomKeyIssuePriv *dki) + struct TALER_DenominationKeyIssueInformation *dki) { dki->denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize); @@ -685,7 +685,7 @@ create_denomkey_issue (const struct CoinTypeParams *params, = GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key); GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, &dki->issue.denom_hash); - dki->issue.master = master_pub; + dki->issue.master = master_public_key; dki->issue.start = GNUNET_TIME_absolute_hton (params->anchor); dki->issue.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, @@ -701,9 +701,9 @@ create_denomkey_issue (const struct CoinTypeParams *params, ¶ms->fee_deposit); TALER_amount_hton (&dki->issue.fee_refresh, ¶ms->fee_refresh); - dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOM); - dki->issue.purpose.size = htonl (sizeof (struct TALER_MINT_DenomKeyIssuePriv) - - offsetof (struct TALER_MINT_DenomKeyIssuePriv, + dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY); + dki->issue.purpose.size = htonl (sizeof (struct TALER_DenominationKeyIssueInformation) - + offsetof (struct TALER_DenominationKeyIssueInformation, issue.purpose)); GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, @@ -726,7 +726,7 @@ mint_keys_update_cointype (void *cls, int *ret = cls; struct CoinTypeParams p; const char *dkf; - struct TALER_MINT_DenomKeyIssuePriv denomkey_issue; + struct TALER_DenominationKeyIssueInformation denomkey_issue; if (0 != strncasecmp (coin_alias, "coin_", @@ -820,7 +820,7 @@ main (int argc, &GNUNET_GETOPT_set_filename, &masterkeyfile}, {'d', "mint-dir", "DIR", "mint directory with keys to update", 1, - &GNUNET_GETOPT_set_filename, &mintdir}, + &GNUNET_GETOPT_set_filename, &mint_directory}, {'t', "time", "TIMESTAMP", "pretend it is a different time for the update", 0, &GNUNET_GETOPT_set_string, &pretend_time_str}, @@ -838,7 +838,7 @@ main (int argc, options, argc, argv) < 0) return 1; - if (NULL == mintdir) + if (NULL == mint_directory) { fprintf (stderr, "Mint directory not given\n"); @@ -862,7 +862,7 @@ main (int argc, } ROUND_TO_SECS (now, abs_value_us); - kcfg = TALER_config_load (mintdir); + kcfg = TALER_config_load (mint_directory); if (NULL == kcfg) { fprintf (stderr, @@ -886,32 +886,32 @@ main (int argc, master_priv.eddsa_priv = *eddsa_priv; GNUNET_free (eddsa_priv); GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv, - &master_pub.eddsa_pub); + &master_public_key.eddsa_pub); /* check if key from file matches the one from the configuration */ { - struct GNUNET_CRYPTO_EddsaPublicKey master_pub_from_cfg; + struct GNUNET_CRYPTO_EddsaPublicKey master_public_key_from_cfg; if (GNUNET_OK != GNUNET_CONFIGURATION_get_data (kcfg, "mint", - "master_pub", - &master_pub_from_cfg, + "master_public_key", + &master_public_key_from_cfg, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "mint", - "master_pub"); + "master_public_key"); return 1; } if (0 != - memcmp (&master_pub, - &master_pub_from_cfg, + memcmp (&master_public_key, + &master_public_key_from_cfg, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "mint", - "master_pub", + "master_public_key", _("does not match with private key")); return 1; } diff --git a/src/mint/taler-mint-reservemod.c b/src/mint/taler-mint-reservemod.c index 68f736ffb..125748704 100644 --- a/src/mint/taler-mint-reservemod.c +++ b/src/mint/taler-mint-reservemod.c @@ -25,13 +25,13 @@ #include "taler_util.h" #include "taler_signatures.h" #include "taler_mintdb_plugin.h" -#include "db_pq.h" +#include "taler_pq_lib.h" /** * Director of the mint, containing the keys. */ -static char *mintdir; +static char *mint_directory; /** * Public key of the reserve to manipulate. @@ -156,7 +156,7 @@ reservemod_add (struct TALER_Amount denom) }; GNUNET_assert (GNUNET_OK == - TALER_DB_extract_amount (result, 0, + TALER_PQ_extract_amount (result, 0, "balance_value", "balance_fraction", "balance_currency", @@ -214,7 +214,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-reservemod OPTIONS"), {'d', "mint-dir", "DIR", "mint directory with keys to update", 1, - &GNUNET_GETOPT_set_filename, &mintdir}, + &GNUNET_GETOPT_set_filename, &mint_directory}, {'R', "reserve", "KEY", "reserve (public key) to modify", 1, &GNUNET_GETOPT_set_string, &reserve_pub_str}, @@ -223,7 +223,7 @@ main (int argc, char *const *argv) &GNUNET_GETOPT_set_string, &add_str}, GNUNET_GETOPT_OPTION_END }; - char *TALER_MINT_db_connection_cfg_str; + char *connection_cfg_str; GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-mint-reservemod", @@ -234,7 +234,7 @@ main (int argc, char *const *argv) options, argc, argv) < 0) return 1; - if (NULL == mintdir) + if (NULL == mint_directory) { fprintf (stderr, "Mint directory not given\n"); @@ -253,7 +253,7 @@ main (int argc, char *const *argv) "Parsing reserve key invalid\n"); return 1; } - cfg = TALER_config_load (mintdir); + cfg = TALER_config_load (mint_directory); if (NULL == cfg) { fprintf (stderr, @@ -264,13 +264,13 @@ main (int argc, char *const *argv) GNUNET_CONFIGURATION_get_value_string (cfg, "mint", "db", - &TALER_MINT_db_connection_cfg_str)) + &connection_cfg_str)) { fprintf (stderr, "Database configuration string not found\n"); return 1; } - db_conn = PQconnectdb (TALER_MINT_db_connection_cfg_str); + db_conn = PQconnectdb (connection_cfg_str); if (CONNECTION_OK != PQstatus (db_conn)) { fprintf (stderr, diff --git a/src/mint/taler_mintdb_plugin.h b/src/mint/taler_mintdb_plugin.h deleted file mode 100644 index 4d74b88db..000000000 --- a/src/mint/taler_mintdb_plugin.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors) - - 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 mint/taler_mintdb_plugin.h - * @brief Low-level (statement-level) database access for the mint - * @author Florian Dold - * @author Christian Grothoff - */ -#ifndef TALER_MINTDB_PLUGIN_H -#define TALER_MINTDB_PLUGIN_H - -#include -#include "taler_util.h" - - -/** - * Information we keep on bank transfer(s) that established a reserve. - */ -struct BankTransfer -{ - - /** - * Public key of the reserve that was filled. - */ - struct TALER_ReservePublicKey reserve_pub; - - /** - * Amount that was transferred to the mint. - */ - struct TALER_Amount amount; - - /** - * Detailed wire information about the transaction. - */ - json_t *wire; - -}; - - -/** - * A summary of a Reserve - */ -struct Reserve -{ - /** - * The reserve's public key. This uniquely identifies the reserve - */ - struct TALER_ReservePublicKey pub; - - /** - * The balance amount existing in the reserve - */ - struct TALER_Amount balance; - - /** - * The expiration date of this reserve - */ - struct GNUNET_TIME_Absolute expiry; -}; - - -/** - * Information we keep for a withdrawn coin to reproduce - * the /withdraw operation if needed, and to have proof - * that a reserve was drained by this amount. - */ -struct CollectableBlindcoin -{ - - /** - * Our signature over the (blinded) coin. - */ - struct TALER_DenominationSignature sig; - - /** - * Denomination key (which coin was generated). - * FIXME: we should probably instead have the - * AMOUNT *including* fee in what is being signed - * as well! - */ - struct TALER_DenominationPublicKey denom_pub; - - /** - * Public key of the reserve that was drained. - */ - struct TALER_ReservePublicKey reserve_pub; - - /** - * Hash over the blinded message, needed to verify - * the @e reserve_sig. - */ - struct GNUNET_HashCode h_coin_envelope; - - /** - * Signature confirming the withdrawl, matching @e reserve_pub, - * @e denom_pub and @e h_coin_envelope. - */ - struct TALER_ReserveSignature reserve_sig; -}; - - - -/** - * Types of operations on a reserved. - */ -enum TALER_MINT_DB_ReserveOperation -{ - /** - * Money was deposited into the reserve via a bank transfer. - */ - TALER_MINT_DB_RO_BANK_TO_MINT = 0, - - /** - * A Coin was withdrawn from the reserve using /withdraw. - */ - TALER_MINT_DB_RO_WITHDRAW_COIN = 1 -}; - - -/** - * Reserve history as a linked list. Lists all of the transactions - * associated with this reserve (such as the bank transfers that - * established the reserve and all /withdraw operations we have done - * since). - */ -struct ReserveHistory -{ - - /** - * Next entry in the reserve history. - */ - struct ReserveHistory *next; - - /** - * Type of the event, determins @e details. - */ - enum TALER_MINT_DB_ReserveOperation type; - - /** - * Details of the operation, depending on @e type. - */ - union - { - - /** - * Details about a bank transfer to the mint. - */ - struct BankTransfer *bank; - - /** - * Details about a /withdraw operation. - */ - struct CollectableBlindcoin *withdraw; - - } details; - -}; - - -/** - * Specification for a /deposit operation. - */ -struct Deposit -{ - /** - * Information about the coin that is being deposited. - */ - struct TALER_CoinPublicInfo coin; - - /** - * ECDSA signature affirming that the customer intends - * this coin to be deposited at the merchant identified - * by @e h_wire in relation to the contract identified - * by @e h_contract. - */ - struct TALER_CoinSpendSignature csig; - - /** - * Public key of the merchant. Enables later identification - * of the merchant in case of a need to rollback transactions. - */ - struct TALER_MerchantPublicKey merchant_pub; - - /** - * Hash over the contract between merchant and customer - * (remains unknown to the Mint). - */ - struct GNUNET_HashCode h_contract; - - /** - * Hash of the (canonical) representation of @e wire, used - * to check the signature on the request. Generated by - * the mint from the detailed wire data provided by the - * merchant. - */ - struct GNUNET_HashCode h_wire; - - /** - * Detailed wire information for executing the transaction. - */ - json_t *wire; - - /** - * Merchant-generated transaction ID to detect duplicate - * transactions. - */ - uint64_t transaction_id; - - /** - * Fraction of the coin's remaining value to be deposited, including - * depositing fee (if any). The coin is identified by @e coin_pub. - */ - struct TALER_Amount amount_with_fee; - -}; - - -/** - * Global information for a refreshing session. Includes - * dimensions of the operation, security parameters and - * client signatures from "/refresh/melt" and "/refresh/commit". - */ -struct RefreshSession -{ - - /** - * Number of coins we are melting. - */ - uint16_t num_oldcoins; - - /** - * Number of new coins we are creating. - */ - uint16_t num_newcoins; - - /** - * Index (smaller #KAPPA) which the mint has chosen to not - * have revealed during cut and choose. - */ - uint16_t noreveal_index; - -}; - - -/** - * Specification for coin in a /refresh/melt operation. - */ -struct RefreshMelt -{ - /** - * Information about the coin that is being melted. - */ - struct TALER_CoinPublicInfo coin; - - /** - * Signature over the melting operation. - */ - struct TALER_CoinSpendSignature coin_sig; - - /** - * Hash of the refresh session this coin is melted into. - */ - struct GNUNET_HashCode session_hash; - - /** - * How much value is being melted? This amount includes the fees, - * so the final amount contributed to the melt is this value minus - * the fee for melting the coin. We include the fee in what is - * being signed so that we can verify a reserve's remaining total - * balance without needing to access the respective denomination key - * information each time. - */ - struct TALER_Amount amount_with_fee; - -}; - - -/** - * We have as many `struct RefreshCommitCoin` as there are new - * coins being created by the refresh (for each of the #KAPPA - * sets). These are the coins we ask the mint to sign if the - * respective set is selected. - */ -struct RefreshCommitCoin -{ - - /** - * Encrypted data allowing those able to decrypt it to derive - * the private keys of the new coins created by the refresh. - */ - struct TALER_RefreshLinkEncrypted *refresh_link; - - /** - * Blinded message to be signed (in envelope), with @e coin_env_size bytes. - */ - char *coin_ev; - - /** - * Number of bytes in @e coin_ev. - */ - size_t coin_ev_size; - -}; - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * For each (old) coin being melted, we have a `struct - * RefreshCommitLink` that allows the user to find the shared secret - * to decrypt the respective refresh links for the new coins in the - * `struct RefreshCommitCoin`. - */ -struct RefreshCommitLink -{ - /** - * Transfer public key, used to decrypt the @e shared_secret_enc - * in combintation with the corresponding private key of the - * coin. - */ - struct TALER_TransferPublicKey transfer_pub; - - /** - * Encrypted shared secret to decrypt the link. - */ - struct TALER_EncryptedLinkSecret shared_secret_enc; -}; - -GNUNET_NETWORK_STRUCT_END - - - -/** - * Linked list of refresh information linked to a coin. - */ -struct LinkDataList -{ - /** - * Information is stored in a NULL-terminated linked list. - */ - struct LinkDataList *next; - - /** - * Link data, used to recover the private key of the coin - * by the owner of the old coin. - */ - struct TALER_RefreshLinkEncrypted *link_data_enc; - - /** - * Denomination public key, determines the value of the coin. - */ - struct TALER_DenominationPublicKey denom_pub; - - /** - * Signature over the blinded envelope. - */ - struct TALER_DenominationSignature ev_sig; -}; - - -/** - * Specification for a /lock operation. - */ -struct Lock -{ - /** - * Information about the coin that is being locked. - */ - struct TALER_CoinPublicInfo coin; - - /** - * Signature over the locking operation. - */ - struct TALER_CoinSpendSignature coin_sig; - - /** - * How much value is being locked? - */ - struct TALER_Amount amount; - - // FIXME: more needed... -}; - - -/** - * Enumeration to classify the different types of transactions - * that can be done with a coin. - */ -enum TALER_MINT_DB_TransactionType -{ - /** - * /deposit operation. - */ - TALER_MINT_DB_TT_DEPOSIT = 0, - - /** - * /refresh/melt operation. - */ - TALER_MINT_DB_TT_REFRESH_MELT = 1, - - /** - * /lock operation. - */ - TALER_MINT_DB_TT_LOCK = 2 -}; - - -/** - * List of transactions we performed for a particular coin. - */ -struct TALER_MINT_DB_TransactionList -{ - - /** - * Next pointer in the NULL-terminated linked list. - */ - struct TALER_MINT_DB_TransactionList *next; - - /** - * Type of the transaction, determines what is stored in @e details. - */ - enum TALER_MINT_DB_TransactionType type; - - /** - * Details about the transaction, depending on @e type. - */ - union - { - - /** - * Details if transaction was a /deposit operation. - */ - struct Deposit *deposit; - - /** - * Details if transaction was a /refresh/melt operation. - */ - struct RefreshMelt *melt; - - /** - * Details if transaction was a /lock operation. - */ - struct Lock *lock; - - } details; - -}; - - -/** - * Handle for a database session (per-thread, for transactions). - */ -struct TALER_MINTDB_Session; - - -/** - * The plugin API, returned from the plugin's "init" function. - * The argument given to "init" is simply a configuration handle. - */ -struct TALER_MINTDB_Plugin -{ - - /** - * Closure for all callbacks. - */ - void *cls; - - /** - * Name of the library which generated this plugin - */ - const char *library_name; - - /** - * Get the thread-local database-handle. - * Connect to the db if the connection does not exist yet. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param temporary #GNUNET_YES to use a temporary schema; #GNUNET_NO to use the - * database default one - * @param the database connection, or NULL on error - */ - struct TALER_MINTDB_Session * - (*get_session) (void *cls, - int temporary); - - - /** - * Drop the temporary taler schema. This is only useful for testcases. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure - */ - int - (*drop_temporary) (void *cls, - struct TALER_MINTDB_Session *db); - - - /** - * Create the necessary tables if they are not present - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param temporary should we use a temporary schema - * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure - */ - int - (*create_tables) (void *cls, - int temporary); - - - /** - * Start a transaction. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion connection to use - * @return #GNUNET_OK on success - */ - int - (*start) (void *cls, - struct TALER_MINTDB_Session *sesssion); - - - /** - * Commit a transaction. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion connection to use - * @return #GNUNET_OK on success - */ - int - (*commit) (void *cls, - struct TALER_MINTDB_Session *sesssion); - - - /** - * Abort/rollback a transaction. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion connection to use - */ - void - (*rollback) (void *cls, - struct TALER_MINTDB_Session *sesssion); - - - /** - * Get the summary of a reserve. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param db the database connection handle - * @param reserve the reserve data. The public key of the reserve should be set - * in this structure; it is used to query the database. The balance - * and expiration are then filled accordingly. - * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure - */ - int - (*reserve_get) (void *cls, - struct TALER_MINTDB_Session *db, - struct Reserve *reserve); - - /* FIXME: add functions to add bank transfers to our DB - (and to test if we already did add one) (#3633/#3717) */ - - - /** - * Insert a incoming transaction into reserves. New reserves are also created - * through this function. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param db the database connection handle - * @param reserve the reserve structure. The public key of the reserve should - * be set here. Upon successful execution of this function, the - * balance and expiration of the reserve will be updated. - * @param balance the amount that has to be added to the reserve - * @param expiry the new expiration time for the reserve - * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failures - */ - int - (*reserves_in_insert) (void *cls, - struct TALER_MINTDB_Session *db, - struct Reserve *reserve, - const struct TALER_Amount *balance, - const struct GNUNET_TIME_Absolute expiry); - - - /** - * Locate the response for a /withdraw request under the - * key of the hash of the blinded message. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection to use - * @param h_blind hash of the blinded message - * @param collectable corresponding collectable coin (blind signature) - * if a coin is found - * @return #GNUNET_SYSERR on internal error - * #GNUNET_NO if the collectable was not found - * #GNUNET_YES on success - */ - int - (*get_collectable_blindcoin) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *h_blind, - struct CollectableBlindcoin *collectable); - - - /** - * Store collectable bit coin under the corresponding - * hash of the blinded message. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection to use - * @param h_blind hash of the blinded message - * @param withdraw amount by which the reserve will be withdrawn with this - * transaction - * @param collectable corresponding collectable coin (blind signature) - * if a coin is found - * @return #GNUNET_SYSERR on internal error - * #GNUNET_NO if the collectable was not found - * #GNUNET_YES on success - */ - int - (*insert_collectable_blindcoin) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *h_blind, - struct TALER_Amount withdraw, - const struct CollectableBlindcoin *collectable); - - - /** - * Get all of the transaction history associated with the specified - * reserve. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion connection to use - * @param reserve_pub public key of the reserve - * @return known transaction history (NULL if reserve is unknown) - */ - struct ReserveHistory * - (*get_reserve_history) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct TALER_ReservePublicKey *reserve_pub); - - - /** - * Free memory associated with the given reserve history. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param rh history to free. - */ - void - (*free_reserve_history) (void *cls, - struct ReserveHistory *rh); - - - /** - * Check if we have the specified deposit already in the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param deposit deposit to search for - * @return #GNUNET_YES if we know this operation, - * #GNUNET_NO if this deposit is unknown to us, - * #GNUNET_SYSERR on internal error - */ - int - (*have_deposit) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct Deposit *deposit); - - - /** - * Insert information about deposited coin into the - * database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion connection to the database - * @param deposit deposit information to store - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ - int - (*insert_deposit) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct Deposit *deposit); - - - /** - * Lookup refresh session data under the given @a session_hash. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database handle to use - * @param session_hash hash over the melt to use for the lookup - * @param refresh_session[OUT] where to store the result - * @return #GNUNET_YES on success, - * #GNUNET_NO if not found, - * #GNUNET_SYSERR on DB failure - */ - int - (*get_refresh_session) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - struct RefreshSession *refresh_session); - - - /** - * Store new refresh session data under the given @a session_hash. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database handle to use - * @param session_hash hash over the melt to use to locate the session - * @param refresh_session session data to store - * @return #GNUNET_YES on success, - * #GNUNET_SYSERR on DB failure - */ - int - (*create_refresh_session) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - const struct RefreshSession *refresh_session); - - - /** - * Store the given /refresh/melt request in the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param oldcoin_index index of the coin to store - * @param melt coin melt operation details to store; includes - * the session hash of the melt - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on internal error - */ - int - (*insert_refresh_melt) (void *cls, - struct TALER_MINTDB_Session *sesssion, - uint16_t oldcoin_index, - const struct RefreshMelt *melt); - - - /** - * Get information about melted coin details from the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param session_hash hash to identify refresh session - * @param oldcoin_index index of the coin to retrieve - * @param melt melt data to fill in - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on internal error - */ - int - (*get_refresh_melt) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - uint16_t oldcoin_index, - struct RefreshMelt *melt); - - - /** - * Store in the database which coin(s) we want to create - * in a given refresh operation. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param session_hash hash to identify refresh session - * @param num_newcoins number of coins to generate, size of the @a denom_pubs array - * @param denom_pubs array denominations of the coins to create - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on internal error - */ - int - (*insert_refresh_order) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - uint16_t num_newcoins, - const struct TALER_DenominationPublicKey *denom_pubs); - - - /** - * Lookup in the database for the @a num_newcoins coins that we want to - * create in the given refresh operation. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param session_hash hash to identify refresh session - * @param num_newcoins size of the @a denom_pubs array - * @param denom_pubs[OUT] where to write @a num_newcoins denomination keys - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on internal error - */ - int - (*get_refresh_order) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - uint16_t num_newcoins, - struct TALER_DenominationPublicKey *denom_pubs); - - - /** - * Store information about the commitments of the given index @a i - * for the given refresh session in the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection to use - * @param session_hash hash to identify refresh session - * @param i set index (1st dimension), relating to #KAPPA - * @param num_newcoins coin index size of the @a commit_coins array - * @param commit_coin array of coin commitments to store - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on error - */ - int - (*insert_refresh_commit_coins) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - unsigned int i, - unsigned int num_newcoins, - const struct RefreshCommitCoin *commit_coins); - - - /** - * Obtain information about the commitment of the - * given coin of the given refresh session from the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection to use - * @param session_hash hash to identify refresh session - * @param i set index (1st dimension) - * @param num_coins size of the @a commit_coins array - * @param commit_coin[OUT] array of coin commitments to return - * @return #GNUNET_OK on success - * #GNUNET_NO if not found - * #GNUNET_SYSERR on error - */ - int - (*get_refresh_commit_coins) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - unsigned int i, - unsigned int num_coins, - struct RefreshCommitCoin *commit_coins); - - - /** - * Store the commitment to the given (encrypted) refresh link data - * for the given refresh session. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection to use - * @param session_hash hash to identify refresh session - * @param i set index (1st dimension), relating to #KAPPA - * @param num_links size of the @a commit_link array - * @param commit_links array of link information to store - * @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success - */ - int - (*insert_refresh_commit_links) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - unsigned int i, - unsigned int num_links, - const struct RefreshCommitLink *commit_links); - - /** - * Obtain the commited (encrypted) refresh link data - * for the given refresh session. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection to use - * @param session_hash hash to identify refresh session - * @param i set index (1st dimension) - * @param num_links size of the @links array to return - * @param links[OUT] array link information to return - * @return #GNUNET_SYSERR on internal error, - * #GNUNET_NO if commitment was not found - * #GNUNET_OK on success - */ - int - (*get_refresh_commit_links) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - unsigned int i, - unsigned int num_links, - struct RefreshCommitLink *links); - - - /** - * Insert signature of a new coin generated during refresh into - * the database indexed by the refresh session and the index - * of the coin. This data is later used should an old coin - * be used to try to obtain the private keys during "/refresh/link". - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param session_hash hash to identify refresh session - * @param newcoin_index coin index - * @param ev_sig coin signature - * @return #GNUNET_OK on success - */ - int - (*insert_refresh_collectable) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct GNUNET_HashCode *session_hash, - uint16_t newcoin_index, - const struct TALER_DenominationSignature *ev_sig); - - - /** - * Obtain the link data of a coin, that is the encrypted link - * information, the denomination keys and the signatures. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param coin_pub public key to use to retrieve linkage data - * @return all known link data for the coin - */ - struct LinkDataList * - (*get_link_data_list) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct TALER_CoinSpendPublicKey *coin_pub); - - - /** - * Free memory of the link data list. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param ldl link data list to release - */ - void - (*free_link_data_list) (void *cls, - struct LinkDataList *ldl); - - - /** - * Obtain shared secret and transfer public key from the public key of - * the coin. This information and the link information returned by - * #TALER_db_get_link() enable the owner of an old coin to determine - * the private keys of the new coins after the melt. - * - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param coin_pub public key of the coin - * @param transfer_pub[OUT] public transfer key - * @param shared_secret_enc[OUT] set to shared secret - * @return #GNUNET_OK on success, - * #GNUNET_NO on failure (not found) - * #GNUNET_SYSERR on internal failure (database issue) - */ - int - (*get_transfer) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct TALER_CoinSpendPublicKey *coin_pub, - struct TALER_TransferPublicKey *transfer_pub, - struct TALER_EncryptedLinkSecret *shared_secret_enc); - - - /** - * Test if the given /lock request is known to us. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param lock lock operation - * @return #GNUNET_YES if known, - * #GNUENT_NO if not, - * #GNUNET_SYSERR on internal error - */ - int - (*have_lock) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct Lock *lock); - - - /** - * Store the given /lock request in the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param lock lock operation - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on internal error - */ - int - (*insert_lock) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct Lock *lock); - - - /** - * Compile a list of all (historic) transactions performed - * with the given coin (/refresh/melt and /deposit operations). - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param sesssion database connection - * @param coin_pub coin to investigate - * @return list of transactions, NULL if coin is fresh - */ - struct TALER_MINT_DB_TransactionList * - (*get_coin_transactions) (void *cls, - struct TALER_MINTDB_Session *sesssion, - const struct TALER_CoinSpendPublicKey *coin_pub); - - - /** - * Free linked list of transactions. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param list list to free - */ - void - (*free_coin_transaction_list) (void *cls, - struct TALER_MINT_DB_TransactionList *list); - - -}; - - -#endif /* _NEURO_MINT_DB_H */ diff --git a/src/mint/test_mint_common.c b/src/mint/test_mint_common.c index f6771474c..83df25046 100644 --- a/src/mint/test_mint_common.c +++ b/src/mint/test_mint_common.c @@ -36,10 +36,10 @@ int main (int argc, const char *const argv[]) { - struct TALER_MINT_DenomKeyIssuePriv dki; + struct TALER_DenominationKeyIssueInformation dki; char *enc; size_t enc_size; - struct TALER_MINT_DenomKeyIssuePriv dki_read; + struct TALER_DenominationKeyIssueInformation dki_read; char *enc_read; size_t enc_read_size; char *tmpfile; @@ -53,7 +53,7 @@ main (int argc, dki_read.denom_priv.rsa_private_key = NULL; GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &dki.issue.signature, - sizeof (dki) - offsetof (struct TALER_MINT_DenomKeyIssue, + sizeof (dki) - offsetof (struct TALER_DenominationKeyValidityPS, signature)); dki.denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE); diff --git a/src/mint/test_mint_db.c b/src/mint/test_mint_db.c index 13823ba86..a82094075 100644 --- a/src/mint/test_mint_db.c +++ b/src/mint/test_mint_db.c @@ -54,7 +54,7 @@ static int result; */ static int check_reserve (struct TALER_MINTDB_Session *session, - const struct TALER_ReservePublicKey *pub, + const struct TALER_ReservePublicKeyP *pub, uint64_t value, uint32_t fraction, const char *currency, @@ -123,7 +123,7 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct TALER_MINTDB_Session *session; - struct TALER_ReservePublicKey reserve_pub; + struct TALER_ReservePublicKeyP reserve_pub; struct Reserve reserve; struct GNUNET_TIME_Absolute expiry; struct TALER_Amount amount; @@ -355,7 +355,7 @@ main (int argc, static const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - const char *argv2[] = { + char *argv2[] = { "test-mint-db-", /* will be replaced later */ "-c", "test-mint-db-.conf", /* will be replaced later */ NULL, diff --git a/src/mint/test_mint_deposits.c b/src/mint/test_mint_deposits.c index 4107c1aee..dbe12e88d 100644 --- a/src/mint/test_mint_deposits.c +++ b/src/mint/test_mint_deposits.c @@ -22,7 +22,7 @@ #include #include #include "plugin.h" -#include "db_pq.h" +#include "taler_pq_lib.h" #include "taler-mint-httpd.h" #define DB_URI "postgres:///taler" @@ -98,8 +98,8 @@ run (void *cls, htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)); deposit->amount_with_fee.fraction = htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)); - GNUNET_assert (strlen (MINT_CURRENCY) < sizeof (deposit->amount_with_fee.currency)); - strcpy (deposit->amount_with_fee.currency, MINT_CURRENCY); + GNUNET_assert (strlen (TMH_MINT_CURRENCY) < sizeof (deposit->amount_with_fee.currency)); + strcpy (deposit->amount_with_fee.currency, TMH_MINT_CURRENCY); /* Copy wireformat */ deposit->wire = json_loads (wire, 0, NULL); EXITIF (GNUNET_OK != diff --git a/src/mint/test_mint_nayapaisa/config/mint-common.conf b/src/mint/test_mint_nayapaisa/config/mint-common.conf index c1fede7a2..6026628b0 100644 --- a/src/mint/test_mint_nayapaisa/config/mint-common.conf +++ b/src/mint/test_mint_nayapaisa/config/mint-common.conf @@ -1,6 +1,6 @@ [mint] db = postgres:///taler port = 4241 -master_pub = 6ZE0HEY2M0FWP61M0470HYBF4K6RRD5DP54372PD2TN9N9VX2VJG +TMH_master_public_key = 6ZE0HEY2M0FWP61M0470HYBF4K6RRD5DP54372PD2TN9N9VX2VJG refresh_security_parameter = 3 diff --git a/src/mint/test_mint_nyadirahim/config/mint-common.conf b/src/mint/test_mint_nyadirahim/config/mint-common.conf index c4d528634..beb904538 100644 --- a/src/mint/test_mint_nyadirahim/config/mint-common.conf +++ b/src/mint/test_mint_nyadirahim/config/mint-common.conf @@ -1,6 +1,6 @@ [mint] db = postgres:///taler port = 4241 -master_pub = 7995WKK71KPKTBBMA5BHNBSZFGNRZPYNXDJMQ8EK86V9598H03TG +TMH_master_public_key = 7995WKK71KPKTBBMA5BHNBSZFGNRZPYNXDJMQ8EK86V9598H03TG refresh_security_parameter = 3 -- cgit v1.2.3