diff options
Diffstat (limited to 'src')
46 files changed, 1385 insertions, 1384 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 60f8a3491..4d4c6771e 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -8,4 +8,6 @@ talerinclude_HEADERS = \ taler_json_lib.h \ taler_util.h \ taler_mint_service.h \ + taler_mintdb_plugin.h \ + taler_pq_lib.h \ taler_signatures.h diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 3156e63ed..cfd588a52 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -32,7 +32,7 @@ GNUNET_NETWORK_STRUCT_BEGIN /** * Type of public keys for Taler reserves. */ -struct TALER_ReservePublicKey +struct TALER_ReservePublicKeyP { /** * Taler uses EdDSA for reserves. @@ -44,7 +44,7 @@ struct TALER_ReservePublicKey /** * Type of private keys for Taler reserves. */ -struct TALER_ReservePrivateKey +struct TALER_ReservePrivateKeyP { /** * Taler uses EdDSA for reserves. @@ -56,7 +56,7 @@ struct TALER_ReservePrivateKey /** * Type of signatures used with Taler reserves. */ -struct TALER_ReserveSignature +struct TALER_ReserveSignatureP { /** * Taler uses EdDSA for reserves. @@ -70,7 +70,7 @@ struct TALER_ReserveSignature * Merchants can issue refunds using the corresponding * private key. */ -struct TALER_MerchantPublicKey +struct TALER_MerchantPublicKeyP { /** * Taler uses EdDSA for merchants. @@ -84,7 +84,7 @@ struct TALER_MerchantPublicKey * Merchants can issue refunds using the corresponding * private key. */ -struct TALER_MerchantPrivateKey +struct TALER_MerchantPrivateKeyP { /** * Taler uses EdDSA for merchants. @@ -97,7 +97,7 @@ struct TALER_MerchantPrivateKey * Type of transfer public keys used during refresh * operations. */ -struct TALER_TransferPublicKey +struct TALER_TransferPublicKeyP { /** * Taler uses ECDSA for transfer keys. @@ -111,7 +111,7 @@ struct TALER_TransferPublicKey * Type of transfer public keys used during refresh * operations. */ -struct TALER_TransferPrivateKey +struct TALER_TransferPrivateKeyP { /** * Taler uses ECDSA for melting session keys. @@ -125,7 +125,7 @@ struct TALER_TransferPrivateKey * Type of online public keys used by the mint to sign * messages. */ -struct TALER_MintPublicKey +struct TALER_MintPublicKeyP { /** * Taler uses EdDSA for online mint message signing. @@ -138,7 +138,7 @@ struct TALER_MintPublicKey * Type of online public keys used by the mint to * sign messages. */ -struct TALER_MintPrivateKey +struct TALER_MintPrivateKeyP { /** * Taler uses EdDSA for online signatures sessions. @@ -150,7 +150,7 @@ struct TALER_MintPrivateKey /** * Type of signatures used by the mint to sign messages online. */ -struct TALER_MintSignature +struct TALER_MintSignatureP { /** * Taler uses EdDSA for online signatures sessions. @@ -162,7 +162,7 @@ struct TALER_MintSignature /** * Type of the offline master public key used by the mint. */ -struct TALER_MasterPublicKey +struct TALER_MasterPublicKeyP { /** * Taler uses EdDSA for the long-term offline master key. @@ -174,7 +174,7 @@ struct TALER_MasterPublicKey /** * Type of the offline master public keys used by the mint. */ -struct TALER_MasterPrivateKey +struct TALER_MasterPrivateKeyP { /** * Taler uses EdDSA for the long-term offline master key. @@ -186,7 +186,7 @@ struct TALER_MasterPrivateKey /** * Type of signatures by the offline master public key used by the mint. */ -struct TALER_MasterSignature +struct TALER_MasterSignatureP { /** * Taler uses EdDSA for the long-term offline master key. @@ -199,7 +199,7 @@ struct TALER_MasterSignature /** * Type of public keys for Taler coins. */ -struct TALER_CoinSpendPublicKey +union TALER_CoinSpendPublicKeyP { /** * Taler uses ECDSA for coins. @@ -211,7 +211,7 @@ struct TALER_CoinSpendPublicKey /** * Type of private keys for Taler coins. */ -struct TALER_CoinSpendPrivateKey +union TALER_CoinSpendPrivateKeyP { /** * Taler uses ECDSA for coins. @@ -223,7 +223,7 @@ struct TALER_CoinSpendPrivateKey /** * Type of signatures made with Taler coins. */ -struct TALER_CoinSpendSignature +union TALER_CoinSpendSignatureP { /** * Taler uses ECDSA for coins. @@ -294,7 +294,7 @@ struct TALER_CoinPublicInfo /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; /** * Public key representing the denomination of the coin @@ -331,10 +331,10 @@ GNUNET_NETWORK_STRUCT_BEGIN /** * Secret used to decrypt the key to decrypt link secrets. */ -struct TALER_TransferSecret +struct TALER_TransferSecretP { /** - * Secret used to encrypt/decrypt the `struct TALER_LinkSecret`. + * Secret used to encrypt/decrypt the `struct TALER_LinkSecretP`. * Must be (currently) a hash as this is what * #GNUNET_CRYPTO_ecc_ecdh() returns to us. */ @@ -345,7 +345,7 @@ struct TALER_TransferSecret /** * Secret used to decrypt refresh links. */ -struct TALER_LinkSecret +struct TALER_LinkSecretP { /** * Secret used to decrypt the refresh link data. @@ -357,25 +357,25 @@ struct TALER_LinkSecret /** * Encrypted secret used to decrypt refresh links. */ -struct TALER_EncryptedLinkSecret +struct TALER_EncryptedLinkSecretP { /** * Encrypted secret, must be the given size! */ - char enc[sizeof (struct TALER_LinkSecret)]; + char enc[sizeof (struct TALER_LinkSecretP)]; }; /** * Representation of an refresh link in cleartext. */ -struct TALER_RefreshLinkDecrypted +struct TALER_RefreshLinkDecryptedP { /** * Private key of the coin. */ - struct TALER_CoinSpendPrivateKey coin_priv; + union TALER_CoinSpendPrivateKeyP coin_priv; /** * Blinding key. @@ -408,7 +408,7 @@ struct TALER_RefreshLinkEncrypted /** * Encrypted private key of the coin. */ - char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKey)]; + char coin_priv_enc[sizeof (union TALER_CoinSpendPrivateKeyP)]; }; @@ -423,9 +423,9 @@ struct TALER_RefreshLinkEncrypted * @return #GNUNET_OK on success */ int -TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, - const struct TALER_TransferSecret *trans_sec, - struct TALER_LinkSecret *secret); +TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecretP *secret_enc, + const struct TALER_TransferSecretP *trans_sec, + struct TALER_LinkSecretP *secret); /** @@ -438,9 +438,9 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, * @return #GNUNET_OK on success */ int -TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, - const struct TALER_TransferSecret *trans_sec, - struct TALER_EncryptedLinkSecret *secret_enc); +TALER_transfer_encrypt (const struct TALER_LinkSecretP *secret, + const struct TALER_TransferSecretP *trans_sec, + struct TALER_EncryptedLinkSecretP *secret_enc); /** @@ -450,9 +450,9 @@ TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, * @param secret shared secret to use for decryption * @return NULL on error */ -struct TALER_RefreshLinkDecrypted * +struct TALER_RefreshLinkDecryptedP * TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, - const struct TALER_LinkSecret *secret); + const struct TALER_LinkSecretP *secret); /** @@ -463,8 +463,8 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, * @return NULL on error (should never happen) */ struct TALER_RefreshLinkEncrypted * -TALER_refresh_encrypt (const struct TALER_RefreshLinkDecrypted *input, - const struct TALER_LinkSecret *secret); +TALER_refresh_encrypt (const struct TALER_RefreshLinkDecryptedP *input, + const struct TALER_LinkSecretP *secret); /** diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index c5515966f..dbf2293d0 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -18,15 +18,15 @@ * @brief helper functions for JSON processing using libjansson * @author Sree Harsha Totakura <sreeharsha@totakura.in> */ -#ifndef TALER_JSON_LIB_H_ -#define TALER_JSON_LIB_H_ +#ifndef TALER_json_LIB_H_ +#define TALER_json_LIB_H_ #include <jansson.h> /** * Print JSON parsing related error information */ -#define TALER_JSON_warn(error) \ +#define TALER_json_warn(error) \ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ "JSON parsing failed at %s:%u: %s (%s)\n", \ __FILE__, __LINE__, error.text, error.source) @@ -39,7 +39,7 @@ * @return a json object describing the amount */ json_t * -TALER_JSON_from_amount (const struct TALER_Amount *amount); +TALER_json_from_amount (const struct TALER_Amount *amount); /** @@ -49,7 +49,7 @@ TALER_JSON_from_amount (const struct TALER_Amount *amount); * @return a json string with the timestamp in @a stamp */ json_t * -TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp); +TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp); /** @@ -60,7 +60,7 @@ TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp); * @return the JSON reporesentation of the signature with purpose */ json_t * -TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, +TALER_json_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, const struct GNUNET_CRYPTO_EddsaSignature *signature); @@ -72,7 +72,7 @@ TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo * @return the JSON reporesentation of the signature with purpose */ json_t * -TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, +TALER_json_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, const struct GNUNET_CRYPTO_EcdsaSignature *signature); @@ -83,7 +83,7 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo * @return corresponding JSON encoding */ json_t * -TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk); +TALER_json_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk); /** @@ -93,7 +93,7 @@ TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk); * @return corresponding JSON encoding */ json_t * -TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig); +TALER_json_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig); /** @@ -105,7 +105,7 @@ TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig); * @return json string that encodes @a data */ json_t * -TALER_JSON_from_data (const void *data, size_t size); +TALER_json_from_data (const void *data, size_t size); /** @@ -116,7 +116,7 @@ TALER_JSON_from_data (const void *data, size_t size); * @return json string that encodes @a hc */ json_t * -TALER_JSON_from_hash (const struct GNUNET_HashCode *hc); +TALER_json_from_hash (const struct GNUNET_HashCode *hc); /** @@ -127,7 +127,7 @@ TALER_JSON_from_hash (const struct GNUNET_HashCode *hc); * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_amount (json_t *json, +TALER_json_to_amount (json_t *json, struct TALER_Amount *r_amount); /** @@ -138,7 +138,7 @@ TALER_JSON_to_amount (json_t *json, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_abs (json_t *json, +TALER_json_to_abs (json_t *json, struct GNUNET_TIME_Absolute *r_abs); /** @@ -150,7 +150,7 @@ TALER_JSON_to_abs (json_t *json, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_data (json_t *json, +TALER_json_to_data (json_t *json, void *out, size_t out_size); @@ -162,10 +162,10 @@ TALER_JSON_to_data (json_t *json, * @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not */ int -TALER_JSON_validate_wireformat (const char *type, +TALER_json_validate_wireformat (const char *type, const json_t *wire); -#endif /* TALER_JSON_LIB_H_ */ +#endif /* TALER_json_LIB_H_ */ /* End of taler_json_lib.h */ diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index 30aaad38e..774f40f54 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -42,7 +42,7 @@ struct TALER_MINT_SigningPublicKey /** * The signing public key */ - struct TALER_MintPublicKey key; + struct TALER_MintPublicKeyP key; /** * Validity start time @@ -140,7 +140,7 @@ struct TALER_MINT_Handle * TALER_MINT_connect (struct TALER_MINT_Context *ctx, const char *hostname, uint16_t port, - const struct TALER_MasterPublicKey *master_key); + const struct TALER_MasterPublicKeyP *master_key); /** * Disconnect from the mint @@ -287,7 +287,7 @@ TALER_MINT_deposit_submit_json_ (struct TALER_MINT_Handle *mint, struct TALER_BLIND_Signature *ubsig, uint64_t transaction_id, struct TALER_Amount *amount, - const struct TALER_MerchantPublicKey *merchant_pub, + const struct TALER_MerchantPublicKeyP *merchant_pub, const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_wire, const struct TALER_CoinSignature *csig, diff --git a/src/mint/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index 4d74b88db..8c9f4af23 100644 --- a/src/mint/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -35,7 +35,7 @@ struct BankTransfer /** * Public key of the reserve that was filled. */ - struct TALER_ReservePublicKey reserve_pub; + struct TALER_ReservePublicKeyP reserve_pub; /** * Amount that was transferred to the mint. @@ -58,7 +58,7 @@ struct Reserve /** * The reserve's public key. This uniquely identifies the reserve */ - struct TALER_ReservePublicKey pub; + struct TALER_ReservePublicKeyP pub; /** * The balance amount existing in the reserve @@ -96,7 +96,7 @@ struct CollectableBlindcoin /** * Public key of the reserve that was drained. */ - struct TALER_ReservePublicKey reserve_pub; + struct TALER_ReservePublicKeyP reserve_pub; /** * Hash over the blinded message, needed to verify @@ -108,7 +108,7 @@ struct CollectableBlindcoin * Signature confirming the withdrawl, matching @e reserve_pub, * @e denom_pub and @e h_coin_envelope. */ - struct TALER_ReserveSignature reserve_sig; + struct TALER_ReserveSignatureP reserve_sig; }; @@ -186,13 +186,13 @@ struct Deposit * by @e h_wire in relation to the contract identified * by @e h_contract. */ - struct TALER_CoinSpendSignature csig; + union TALER_CoinSpendSignatureP 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; + struct TALER_MerchantPublicKeyP merchant_pub; /** * Hash over the contract between merchant and customer @@ -247,7 +247,7 @@ struct RefreshSession uint16_t num_newcoins; /** - * Index (smaller #KAPPA) which the mint has chosen to not + * Index (smaller #TALER_CNC_KAPPA) which the mint has chosen to not * have revealed during cut and choose. */ uint16_t noreveal_index; @@ -268,7 +268,7 @@ struct RefreshMelt /** * Signature over the melting operation. */ - struct TALER_CoinSpendSignature coin_sig; + union TALER_CoinSpendSignatureP coin_sig; /** * Hash of the refresh session this coin is melted into. @@ -290,7 +290,7 @@ struct RefreshMelt /** * We have as many `struct RefreshCommitCoin` as there are new - * coins being created by the refresh (for each of the #KAPPA + * coins being created by the refresh (for each of the #TALER_CNC_KAPPA * sets). These are the coins we ask the mint to sign if the * respective set is selected. */ @@ -331,12 +331,12 @@ struct RefreshCommitLink * in combintation with the corresponding private key of the * coin. */ - struct TALER_TransferPublicKey transfer_pub; + struct TALER_TransferPublicKeyP transfer_pub; /** * Encrypted shared secret to decrypt the link. */ - struct TALER_EncryptedLinkSecret shared_secret_enc; + struct TALER_EncryptedLinkSecretP shared_secret_enc; }; GNUNET_NETWORK_STRUCT_END @@ -384,7 +384,7 @@ struct Lock /** * Signature over the locking operation. */ - struct TALER_CoinSpendSignature coin_sig; + union TALER_CoinSpendSignatureP coin_sig; /** * How much value is being locked? @@ -650,7 +650,7 @@ struct TALER_MINTDB_Plugin struct ReserveHistory * (*get_reserve_history) (void *cls, struct TALER_MINTDB_Session *sesssion, - const struct TALER_ReservePublicKey *reserve_pub); + const struct TALER_ReservePublicKeyP *reserve_pub); /** @@ -814,7 +814,7 @@ struct TALER_MINTDB_Plugin * @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 i set index (1st dimension), relating to #TALER_CNC_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 @@ -859,7 +859,7 @@ struct TALER_MINTDB_Plugin * @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 i set index (1st dimension), relating to #TALER_CNC_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 @@ -928,7 +928,7 @@ struct TALER_MINTDB_Plugin struct LinkDataList * (*get_link_data_list) (void *cls, struct TALER_MINTDB_Session *sesssion, - const struct TALER_CoinSpendPublicKey *coin_pub); + const union TALER_CoinSpendPublicKeyP *coin_pub); /** @@ -961,9 +961,9 @@ struct TALER_MINTDB_Plugin 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); + const union TALER_CoinSpendPublicKeyP *coin_pub, + struct TALER_TransferPublicKeyP *transfer_pub, + struct TALER_EncryptedLinkSecretP *shared_secret_enc); /** @@ -1009,7 +1009,7 @@ struct TALER_MINTDB_Plugin struct TALER_MINT_DB_TransactionList * (*get_coin_transactions) (void *cls, struct TALER_MINTDB_Session *sesssion, - const struct TALER_CoinSpendPublicKey *coin_pub); + const union TALER_CoinSpendPublicKeyP *coin_pub); /** diff --git a/src/pq/db_pq.h b/src/include/taler_pq_lib.h index 720dad5c5..3cfd27f91 100644 --- a/src/pq/db_pq.h +++ b/src/include/taler_pq_lib.h @@ -14,15 +14,14 @@ TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> */ /** - * @file pq/db_pq.h + * @file pq/taler_pq_lib.h * @brief helper functions for DB interactions * @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Florian Dold * @author Christian Grothoff */ - -#ifndef TALER_DB_LIB_H_ -#define TALER_DB_LIB_H_ +#ifndef TALER_PQ_LIB_H_ +#define TALER_PQ_LIB_H_ #include <libpq-fe.h> #include "taler_util.h" @@ -30,7 +29,7 @@ /** * Description of a DB query parameter. */ -struct TALER_DB_QueryParam +struct TALER_PQ_QueryParam { /** * Data or NULL @@ -52,7 +51,7 @@ struct TALER_DB_QueryParam /** * End of query parameter specification. */ -#define TALER_DB_QUERY_PARAM_END { NULL, 0, 0 } +#define TALER_PQ_QUERY_PARAM_END { NULL, 0, 0 } /** * Generate fixed-size query parameter with size given explicitly. @@ -60,7 +59,7 @@ struct TALER_DB_QueryParam * @param x pointer to the query parameter to pass * @param s number of bytes of @a x to use for the query */ -#define TALER_DB_QUERY_PARAM_PTR_SIZED(x, s) { (x), (s), 1 } +#define TALER_PQ_QUERY_PARAM_PTR_SIZED(x, s) { (x), (s), 1 } /** * Generate fixed-size query parameter with size determined @@ -68,13 +67,13 @@ struct TALER_DB_QueryParam * * @param x pointer to the query parameter to pass. */ -#define TALER_DB_QUERY_PARAM_PTR(x) TALER_DB_QUERY_PARAM_PTR_SIZED(x, sizeof (*(x))) +#define TALER_PQ_QUERY_PARAM_PTR(x) TALER_PQ_QUERY_PARAM_PTR_SIZED(x, sizeof (*(x))) /** * Description of a DB result cell. */ -struct TALER_DB_ResultSpec +struct TALER_PQ_ResultSpec { /** * Destination for the data. @@ -104,7 +103,7 @@ struct TALER_DB_ResultSpec /** * End of result parameter specification. */ -#define TALER_DB_RESULT_SPEC_END { NULL, 0, NULL, NULL } +#define TALER_PQ_RESULT_SPEC_END { NULL, 0, NULL, NULL } /** * We expect a fixed-size result, with size given explicitly @@ -113,7 +112,7 @@ struct TALER_DB_ResultSpec * @param dst point to where to store the result * @param s number of bytes we should use in @a dst */ -#define TALER_DB_RESULT_SPEC_SIZED(name, dst, s) { (void *) (dst), (s), (name), NULL } +#define TALER_PQ_RESULT_SPEC_SIZED(name, dst, s) { (void *) (dst), (s), (name), NULL } /** * We expect a fixed-size result, with size determined by the type of `* dst` @@ -121,7 +120,7 @@ struct TALER_DB_ResultSpec * @param name name of the field in the table * @param dst point to where to store the result, type fits expected result size */ -#define TALER_DB_RESULT_SPEC(name, dst) TALER_DB_RESULT_SPEC_SIZED(name, dst, sizeof (*(dst))) +#define TALER_PQ_RESULT_SPEC(name, dst) TALER_PQ_RESULT_SPEC_SIZED(name, dst, sizeof (*(dst))) /** * Variable-size result expected. @@ -130,16 +129,16 @@ struct TALER_DB_ResultSpec * @param dst where to store the result (of type void **), to be allocated * @param sptr pointer to a `size_t` for where to store the size of @a dst */ -#define TALER_DB_RESULT_SPEC_VAR(name, dst, sptr) { (void *) (dst), 0, (name), sptr } +#define TALER_PQ_RESULT_SPEC_VAR(name, dst, sptr) { (void *) (dst), 0, (name), sptr } /** * Execute a prepared statement. */ PGresult * -TALER_DB_exec_prepared (PGconn *db_conn, +TALER_PQ_exec_prepared (PGconn *db_conn, const char *name, - const struct TALER_DB_QueryParam *params); + const struct TALER_PQ_QueryParam *params); /** @@ -153,19 +152,19 @@ TALER_DB_exec_prepared (PGconn *db_conn, * #GNUNET_SYSERR if a result was invalid (non-existing field) */ int -TALER_DB_extract_result (PGresult *result, - struct TALER_DB_ResultSpec *rs, +TALER_PQ_extract_result (PGresult *result, + struct TALER_PQ_ResultSpec *rs, int row); int -TALER_DB_field_isnull (PGresult *result, +TALER_PQ_field_isnull (PGresult *result, int row, const char *fname); int -TALER_DB_extract_amount_nbo (PGresult *result, +TALER_PQ_extract_amount_nbo (PGresult *result, int row, const char *val_name, const char *frac_name, @@ -174,7 +173,7 @@ TALER_DB_extract_amount_nbo (PGresult *result, int -TALER_DB_extract_amount (PGresult *result, +TALER_PQ_extract_amount (PGresult *result, int row, const char *val_name, const char *frac_name, @@ -184,6 +183,6 @@ TALER_DB_extract_amount (PGresult *result, -#endif /* TALER_DB_LIB_H_ */ +#endif /* TALER_PQ_LIB_H_ */ -/* end of db/db_pq.h */ +/* end of db/taler_pq_lib.h */ diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 007a309f3..41b694d09 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -32,61 +32,61 @@ /** * Cut-and-choose size for refreshing. Client looses the gamble (of - * unaccountable transfers) with probability 1/KAPPA. Refresh cost - * increases linearly with KAPPA, and 3 is sufficient up to a + * unaccountable transfers) with probability 1/TALER_CNC_KAPPA. Refresh cost + * increases linearly with TALER_CNC_KAPPA, and 3 is sufficient up to a * income/sales tax of 66% of total transaction value. As there is * no good reason to change this security parameter, we declare it * fixed and part of the protocol. */ -#define KAPPA 3 +#define TALER_CNC_KAPPA 3 /** * Purpose for signing public keys signed * by the mint master key. */ -#define TALER_SIGNATURE_MASTER_SIGNKEY 1 +#define TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY 1 /** * Purpose for denomination keys signed * by the mint master key. */ -#define TALER_SIGNATURE_MASTER_DENOM 2 +#define TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY 2 /** * Purpose for the state of a reserve, * signed by the mint's signing key. */ -#define TALER_SIGNATURE_RESERVE_STATUS 3 +#define TALER_SIGNATURE_MINT_RESERVE_STATUS 3 /** * Signature where the reserve key * confirms a withdraw request. */ -#define TALER_SIGNATURE_WITHDRAW 4 +#define TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST 4 /** * Signature using a coin key confirming the melting of * a coin. */ -#define TALER_SIGNATURE_REFRESH_MELT_COIN 5 +#define TALER_SIGNATURE_COIN_MELT 5 /** * Signature where the mint (current signing key) * confirms the no-reveal index for cut-and-choose and * the validity of the melted coins. */ -#define TALER_SIGNATURE_REFRESH_MELT_RESPONSE 6 +#define TALER_SIGNATURE_MINT_MELT_RESPONSE 6 /** * Signature where the Mint confirms a deposit request. */ -#define TALER_SIGNATURE_MINT_DEPOSIT 7 +#define TALER_SIGNATURE_COIN_DEPOSIT 7 /** * Signature where the Mint confirms the full /keys response set. */ -#define TALER_SIGNATURE_KEYS_SET 8 +#define TALER_SIGNATURE_MINT_KEY_SET 8 /***********************/ @@ -104,11 +104,14 @@ /** * Signature made by the wallet of a user to confirm a deposit permission + * FIXME: this is #TALER_SIGNATURE_COIN_DEPOSIT already! */ #define TALER_SIGNATURE_WALLET_DEPOSIT 201 /** - * Signature made by the wallet of a user to confirm a incremental deposit permission + * Signature made by the wallet of a user to confirm a incremental + * deposit permission. + * FIXME: this MIGHT also be #TALER_SIGNATURE_COIN_DEPOSIT already! */ #define TALER_SIGNATURE_INCREMENTAL_WALLET_DEPOSIT 202 @@ -120,11 +123,11 @@ GNUNET_NETWORK_STRUCT_BEGIN * Format used for to generate the signature on a request to withdraw * coins from a reserve. */ -struct TALER_WithdrawRequest +struct TALER_WithdrawRequestPS { /** - * Purpose must be #TALER_SIGNATURE_WITHDRAW. + * Purpose must be #TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -132,7 +135,7 @@ struct TALER_WithdrawRequest * Reserve public key (which reserve to withdraw from). This is * the public key which must match the signature. */ - struct TALER_ReservePublicKey reserve_pub; + struct TALER_ReservePublicKeyP reserve_pub; /** * Value of the coin being minted (matching the denomination key) @@ -159,7 +162,7 @@ struct TALER_WithdrawRequest * Format used to generate the signature on a request to deposit * a coin into the account of a merchant. */ -struct TALER_DepositRequest +struct TALER_DepositRequestPS { /** * Purpose must be #TALER_SIGNATURE_WALLET_DEPOSIT @@ -192,7 +195,7 @@ struct TALER_DepositRequest /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; }; @@ -201,10 +204,10 @@ struct TALER_DepositRequest * Format used to generate the signature on a confirmation * from the mint that a deposit request succeeded. */ -struct TALER_DepositConfirmation +struct TALER_DepositConfirmationPS { /** - * Purpose must be #TALER_SIGNATURE_MINT_DEPOSIT + * Purpose must be #TALER_SIGNATURE_COIN_DEPOSIT */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -235,12 +238,12 @@ struct TALER_DepositConfirmation /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; /** * The Merchant's public key. */ - struct TALER_MerchantPublicKey merchant; + struct TALER_MerchantPublicKeyP merchant; }; @@ -249,10 +252,10 @@ struct TALER_DepositConfirmation * Message signed by a coin to indicate that the coin should * be melted. */ -struct RefreshMeltCoinSignature +struct TALER_RefreshMeltCoinAffirmationPS { /** - * Purpose is #TALER_SIGNATURE_REFRESH_MELT_COIN. + * Purpose is #TALER_SIGNATURE_COIN_MELT. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -277,7 +280,7 @@ struct RefreshMeltCoinSignature /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; }; @@ -287,10 +290,10 @@ struct RefreshMeltCoinSignature * coins were successfully melted. This also commits the mint to a * particular index to not be revealed during the refresh. */ -struct RefreshMeltResponseSignatureBody +struct TALER_RefreshMeltConfirmationPS { /** - * Purpose is #TALER_SIGNATURE_REFRESH_MELT_RESPONSE. + * Purpose is #TALER_SIGNATURE_MINT_MELT_RESPONSE. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -311,15 +314,15 @@ struct RefreshMeltResponseSignatureBody * to sign mint messages other than coins, i.e. to confirm that a * deposit was successful or that a refresh was accepted. */ -struct TALER_MINT_SignKeyIssue +struct TALER_MintSigningKeyValidityPS { /** * Signature over the signing key (by the master key of the mint). */ - struct TALER_MasterSignature signature; + struct TALER_MasterSignatureP signature; /** - * Purpose is #TALER_SIGNATURE_MASTER_SIGNKEY. + * Purpose is #TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -327,7 +330,7 @@ struct TALER_MINT_SignKeyIssue * Master public key of the mint corresponding to @e signature. * This is the long-term offline master key of the mint. */ - struct TALER_MasterPublicKey master_pub; + struct TALER_MasterPublicKeyP master_public_key; /** * When does this signing key begin to be valid? @@ -346,7 +349,7 @@ struct TALER_MINT_SignKeyIssue * The public online signing key that the mint will use * between @e start and @e expire. */ - struct TALER_MintPublicKey signkey_pub; + struct TALER_MintPublicKeyP signkey_pub; }; @@ -355,11 +358,11 @@ struct TALER_MINT_SignKeyIssue * to detect cheating mints that give out different sets to * different users. */ -struct TALER_MINT_KeySetSignature +struct TALER_MintKeySetPS { /** - * Purpose is #TALER_SIGNATURE_KEYS_SET + * Purpose is #TALER_SIGNATURE_MINT_KEY_SET */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -379,16 +382,16 @@ struct TALER_MINT_KeySetSignature * Information about a denomination key. Denomination keys * are used to sign coins of a certain value into existence. */ -struct TALER_MINT_DenomKeyIssue +struct TALER_DenominationKeyValidityPS { /** * Signature over this struct to affirm the validity * of the key. */ - struct TALER_MasterSignature signature; + struct TALER_MasterSignatureP signature; /** - * Purpose is #TALER_SIGNATURE_MASTER_DENOM. + * Purpose is #TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -396,7 +399,7 @@ struct TALER_MINT_DenomKeyIssue * The long-term offline master key of the mint that was * used to create @e signature. */ - struct TALER_MasterPublicKey master; + struct TALER_MasterPublicKeyP master; /** * Start time of the validity period for this key. diff --git a/src/include/taler_util.h b/src/include/taler_util.h index e46583989..b92f22170 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -29,13 +29,13 @@ /* Define logging functions */ -#define LOG_DEBUG(...) \ +#define TALER_LOG_DEBUG(...) \ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) -#define LOG_WARNING(...) \ +#define TALER_LOG_WARNING(...) \ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, __VA_ARGS__) -#define LOG_ERROR(...) \ +#define TALER_LOG_ERROR(...) \ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__) @@ -49,7 +49,7 @@ #define TALER_assert_as(EXP, reason) \ do { \ if (EXP) break; \ - LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \ + TALER_LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \ abort(); \ } while(0) @@ -59,11 +59,11 @@ * a failure of the command 'cmd' with the message given * by gcry_strerror(rc). */ -#define LOG_GCRY_ERROR(cmd, rc) do { LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) +#define TALER_LOG_GCRY_ERROR(cmd, rc) do { TALER_LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) #define TALER_gcry_ok(cmd) \ - do {int rc; rc = cmd; if (!rc) break; LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0) + do {int rc; rc = cmd; if (!rc) break; TALER_LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0) /** @@ -108,7 +108,7 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg, * @return a pointer to the dir path (to be freed by the caller) */ char * -TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); +TALER_os_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); #endif diff --git a/src/lib/mint_api.c b/src/lib/mint_api.c index 305fc95d9..019793b78 100644 --- a/src/lib/mint_api.c +++ b/src/lib/mint_api.c @@ -246,7 +246,7 @@ parse_timestamp (struct GNUNET_TIME_Absolute *abs, static int parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key, json_t *sign_key_obj, - struct TALER_MasterPublicKey *master_key) + struct TALER_MasterPublicKeyP *master_key) { json_t *valid_from_obj; json_t *valid_until_obj; @@ -257,7 +257,7 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key, const char *key_enc; const char *sig_enc; struct TALER_MINT_SigningPublicKey *sign_key; - struct TALER_MINT_SignKeyIssue sign_key_issue; + struct TALER_MintSigningKeyValidityPS sign_key_issue; struct GNUNET_CRYPTO_EddsaSignature sig; struct GNUNET_TIME_Absolute valid_from; struct GNUNET_TIME_Absolute valid_until; @@ -286,15 +286,15 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key, GNUNET_CRYPTO_eddsa_public_key_from_string (key_enc, 52, &sign_key_issue.signkey_pub.eddsa_pub)); - sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY); + sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY); sign_key_issue.purpose.size = htonl (sizeof (sign_key_issue) - - offsetof (struct TALER_MINT_SignKeyIssue, purpose)); - sign_key_issue.master_pub = *master_key; + - offsetof (struct TALER_MintSigningKeyValidityPS, purpose)); + sign_key_issue.master_public_key = *master_key; sign_key_issue.start = GNUNET_TIME_absolute_hton (valid_from); sign_key_issue.expire = GNUNET_TIME_absolute_hton (valid_until); EXITIF (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY, + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY, &sign_key_issue.purpose, &sig, &master_key->eddsa_pub)); @@ -341,7 +341,7 @@ parse_json_amount (json_t *amount_obj, struct TALER_Amount *amt) static int parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key, json_t *denom_key_obj, - struct TALER_MasterPublicKey *master_key) + struct TALER_MasterPublicKeyP *master_key) { json_t *obj; const char *sig_enc; @@ -359,7 +359,7 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key, struct TALER_Amount fee_withdraw; struct TALER_Amount fee_deposit; struct TALER_Amount fee_refresh; - struct TALER_MINT_DenomKeyIssue denom_key_issue; + struct TALER_DenominationKeyValidityPS denom_key_issue; struct GNUNET_CRYPTO_rsa_PublicKey *pk; struct GNUNET_CRYPTO_EddsaSignature sig; @@ -408,10 +408,10 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key, EXITIF (GNUNET_SYSERR == parse_json_amount (obj, &fee_deposit)); EXITIF (NULL == (obj = json_object_get (denom_key_obj, "fee_refresh"))); EXITIF (GNUNET_SYSERR == parse_json_amount (obj, &fee_refresh)); - denom_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOM); + denom_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY); denom_key_issue.purpose.size = htonl - (sizeof (struct TALER_MINT_DenomKeyIssue) - - offsetof (struct TALER_MINT_DenomKeyIssue, purpose)); + (sizeof (struct TALER_DenominationKeyValidityPS) - + offsetof (struct TALER_DenominationKeyValidityPS, purpose)); denom_key_issue.master = *master_key; denom_key_issue.start = GNUNET_TIME_absolute_hton (valid_from); denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton (withdraw_valid_until); @@ -425,7 +425,7 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key, TALER_amount_hton (&denom_key_issue.fee_refresh, &fee_refresh); EXITIF (GNUNET_SYSERR == - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM, + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY, &denom_key_issue.purpose, &sig, &master_key->eddsa_pub)); @@ -455,7 +455,7 @@ parse_response_keys_get (const char *in, size_t size, { json_t *resp_obj; struct TALER_MINT_DenomPublicKey **denom_keys; - struct TALER_MasterPublicKey master_key; + struct TALER_MasterPublicKeyP master_key; struct GNUNET_TIME_Absolute list_issue_date; struct TALER_MINT_SigningPublicKey **sign_keys; unsigned int n_denom_keys; @@ -485,7 +485,7 @@ parse_response_keys_get (const char *in, size_t size, json_t *master_key_obj; const char *master_key_enc; - EXITIF (NULL == (master_key_obj = json_object_get (resp_obj, "master_pub"))); + EXITIF (NULL == (master_key_obj = json_object_get (resp_obj, "TMH_master_public_key"))); EXITIF (NULL == (master_key_enc = json_string_value (master_key_obj))); EXITIF (52 != strlen (master_key_enc)); /* strlen(base32(char[32])) = 52 */ EXITIF (GNUNET_OK != @@ -584,7 +584,7 @@ parse_deposit_response (void *buf, size_t size, int *r_status, json_t **r_obj) return GNUNET_SYSERR; } EXITIF (-1 == json_unpack (obj, "{s:s}", "status", &status_str)); - LOG_DEBUG ("Received deposit response: %s from mint\n", status_str); + TALER_LOG_DEBUG ("Received deposit response: %s from mint\n", status_str); if (0 == strcmp ("DEPOSIT_OK", status_str)) *r_status = 1; else if (0 == strcmp ("DEPOSIT_QUEUED", status_str)) @@ -916,7 +916,7 @@ struct TALER_MINT_Handle * TALER_MINT_connect (struct TALER_MINT_Context *ctx, const char *hostname, uint16_t port, - const struct TALER_MasterPublicKey *mint_key) + const struct TALER_MasterPublicKeyP *mint_key) { struct TALER_MINT_Handle *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 <pthread.h> @@ -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", "<html><title>404: not found</title></html>", 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;i<coin_count;i++) { if (GNUNET_OK != @@ -663,13 +663,13 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, &coin_melt_details[i], i))) { - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); plugin->rollback (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;i<KAPPA - 1;i++) + for (i=0;i<TALER_CNC_KAPPA - 1;i++) { if (i == refresh_session.noreveal_index) off = 1; @@ -1143,7 +1143,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, for (j=0;j<refresh_session.num_newcoins;j++) GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } commit_coins = GNUNET_malloc (refresh_session.num_newcoins * @@ -1161,11 +1161,11 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, for (j=0;j<refresh_session.num_newcoins;j++) GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } ev_sigs = GNUNET_malloc (refresh_session.num_newcoins * sizeof (struct TALER_DenominationSignature)); - key_state = TALER_MINT_key_state_acquire (); + key_state = TMH_KS_acquire (); for (j=0;j<refresh_session.num_newcoins;j++) { ev_sigs[j] = refresh_mint_coin (connection, @@ -1177,7 +1177,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, j); if (NULL == ev_sigs[j].rsa_signature) { - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); for (i=0;i<j;i++) GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature); GNUNET_free (ev_sigs); @@ -1185,10 +1185,10 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); GNUNET_free (commit_coins); - return TALER_MINT_reply_internal_db_error (connection); + return TMH_RESPONSE_reply_internal_db_error (connection); } } - TALER_MINT_key_state_release (key_state); + TMH_KS_release (key_state); for (j=0;j<refresh_session.num_newcoins;j++) GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); @@ -1198,14 +1198,14 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, plugin->commit (plugin->cls, session)) { - LOG_WARNING ("/refresh/reveal transaction commit failed\n"); + TALER_LOG_WARNING ("/refresh/reveal transaction commit failed\n"); for (i=0;i<refresh_session.num_newcoins;i++) GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature); GNUNET_free (ev_sigs); - return TALER_MINT_reply_commit_error (connection); + return TMH_RESPONSE_reply_commit_error (connection); } - res = TALER_MINT_reply_refresh_reveal_success (connection, + res = TMH_RESPONSE_reply_refresh_reveal_success (connection, refresh_session.num_newcoins, ev_sigs); for (i=0;i<refresh_session.num_newcoins;i++) @@ -1225,20 +1225,20 @@ 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) { int res; struct TALER_MINTDB_Session *session; - struct TALER_TransferPublicKey transfer_pub; - struct TALER_EncryptedLinkSecret shared_secret_enc; + struct TALER_TransferPublicKeyP transfer_pub; + struct TALER_EncryptedLinkSecretP shared_secret_enc; struct LinkDataList *ldl; 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); } 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 <microhttpd.h> #include <jansson.h> @@ -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;i<num_new_denoms;i++) { - dki = &TALER_MINT_get_denom_key (key_state, + dki = &TMH_KS_denomination_key_lookup (key_state, &denom_pubs[i])->issue; 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;i<coin_count;i++) { /* calculate contribution of the i-th melt by subtracting the fee; add the rest to the total_melt value */ - dki = &TALER_MINT_get_denom_key (key_state, + dki = &TMH_KS_denomination_key_lookup (key_state, &coin_public_infos[i].denom_pub)->issue; 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;i<coin_count;i++) { /* decode JSON data on coin to melt */ @@ -458,7 +458,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, { if (0 == memcmp (&coin_public_infos[i].coin_pub, &coin_public_infos[j].coin_pub, - sizeof (struct TALER_CoinSpendPublicKey))) + sizeof (union TALER_CoinSpendPublicKeyP))) { for (j=0;j<i;j++) { @@ -470,7 +470,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (coin_melt_details); GNUNET_free (denom_pubs); - return TALER_MINT_reply_external_error (connection, + return TMH_RESPONSE_reply_external_error (connection, "melting same coin twice in same session is not allowed"); } } @@ -478,7 +478,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, &coin_melt_details[i].melt_amount_with_fee); GNUNET_CRYPTO_hash_context_read (hash_context, &coin_public_infos[i].coin_pub, - sizeof (struct TALER_CoinSpendPublicKey)); + sizeof (union TALER_CoinSpendPublicKeyP)); GNUNET_CRYPTO_hash_context_read (hash_context, &melt_amount, sizeof (struct TALER_AmountNBO)); @@ -489,7 +489,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, together for the signature check */ memset (commit_coin, 0, sizeof (commit_coin)); memset (commit_link, 0, sizeof (commit_link)); - for (i = 0; i < KAPPA; i++) + for (i = 0; i < TALER_CNC_KAPPA; i++) { commit_coin[i] = GNUNET_malloc (num_newcoins * sizeof (struct RefreshCommitCoin)); @@ -499,11 +499,11 @@ handle_refresh_melt_json (struct MHD_Connection *connection, size_t link_enc_size; struct RefreshCommitCoin *rcc = &commit_coin[i][j]; - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, coin_evs, - 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, &rcc->coin_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;j<coin_count;j++) { @@ -649,7 +649,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, * Handle a "/refresh/melt" request. Parses the request into the JSON * components and then hands things of to #handle_referesh_melt_json() * to validate the melted coins, the signature and execute the melt - * using TALER_MINT_db_execute_refresh_melt(). + * using TMH_DB_execute_refresh_melt(). * * @param rh context of the handler * @param connection the MHD connection to handle @@ -659,11 +659,11 @@ handle_refresh_melt_json (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) +TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *root; json_t *new_denoms; @@ -678,19 +678,19 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, unsigned int num_newcoins; json_t *coin_detail; int res; - struct GNUNET_MINT_ParseFieldSpec spec[] = { - TALER_MINT_PARSE_ARRAY ("new_denoms", &new_denoms), - TALER_MINT_PARSE_ARRAY ("melt_coins", &melt_coins), - TALER_MINT_PARSE_ARRAY ("melt_signature", &melt_sig_json), - TALER_MINT_PARSE_ARRAY ("coin_evs", &coin_evs), - TALER_MINT_PARSE_ARRAY ("link_encs", &link_encs), - TALER_MINT_PARSE_ARRAY ("transfer_pubs", &transfer_pubs), - TALER_MINT_PARSE_ARRAY ("secret_encs", &secret_encs), - TALER_MINT_PARSE_OBJECT ("commit_signature", &commit_sig_json), - TALER_MINT_PARSE_END + struct TMH_PARSE_FieldSpecification spec[] = { + TMH_PARSE_MEMBER_ARRAY ("new_denoms", &new_denoms), + TMH_PARSE_MEMBER_ARRAY ("melt_coins", &melt_coins), + TMH_PARSE_MEMBER_ARRAY ("melt_signature", &melt_sig_json), + TMH_PARSE_MEMBER_ARRAY ("coin_evs", &coin_evs), + TMH_PARSE_MEMBER_ARRAY ("link_encs", &link_encs), + TMH_PARSE_MEMBER_ARRAY ("transfer_pubs", &transfer_pubs), + TMH_PARSE_MEMBER_ARRAY ("secret_encs", &secret_encs), + TMH_PARSE_MEMBER_OBJECT ("commit_signature", &commit_sig_json), + TMH_PARSE_MEMBER_END }; - res = TALER_MINT_parse_post_json (connection, + res = TMH_PARSE_post_json (connection, connection_cls, upload_data, upload_data_size, @@ -700,7 +700,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == root) ) return MHD_YES; - res = TALER_MINT_parse_json_data (connection, + res = TMH_PARSE_json_data (connection, root, spec); json_decref (root); @@ -708,38 +708,38 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; /* Determine dimensionality of the request (kappa, #old and #new coins) */ - if (KAPPA != json_array_size (coin_evs)) + if (TALER_CNC_KAPPA != json_array_size (coin_evs)) { GNUNET_break_op (0); - 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, "coin_evs"); } - if (KAPPA != json_array_size (transfer_pubs)) + if (TALER_CNC_KAPPA != json_array_size (transfer_pubs)) { GNUNET_break_op (0); - 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, "transfer_pubs"); } - res = GNUNET_MINT_parse_navigate_json (connection, coin_evs, - JNAV_INDEX, (int) 0, - JNAV_RET_DATA, + res = TMH_PARSE_navigate_json (connection, coin_evs, + TMH_PARSE_JNC_INDEX, (int) 0, + TMH_PARSE_JNC_RET_DATA, JSON_ARRAY, &coin_detail); if (GNUNET_OK != res) { - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } num_newcoins = json_array_size (coin_detail); - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, transfer_pubs, - JNAV_INDEX, (int) 0, - JNAV_RET_DATA, + TMH_PARSE_JNC_INDEX, (int) 0, + TMH_PARSE_JNC_RET_DATA, JSON_ARRAY, &coin_detail); if (GNUNET_OK != res) { - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } num_oldcoins = json_array_size (coin_detail); @@ -756,7 +756,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, coin_evs, link_encs); - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return res; } @@ -764,7 +764,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, /** * Handle a "/refresh/reveal" request. Parses the given JSON * transfer private keys and if successful, passes everything to - * #TALER_MINT_db_execute_refresh_reveal() which will verify that the + * #TMH_DB_execute_refresh_reveal() which will verify that the * revealed information is valid then returns the signed refreshed * coins. * @@ -780,16 +780,16 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, unsigned int num_oldcoins, const json_t *tp_json) { - struct TALER_TransferPrivateKey *transfer_privs[KAPPA - 1]; + struct TALER_TransferPrivateKeyP *transfer_privs[TALER_CNC_KAPPA - 1]; unsigned int i; unsigned int j; int res; - for (i = 0; i < KAPPA - 1; i++) + for (i = 0; i < TALER_CNC_KAPPA - 1; i++) transfer_privs[i] = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_TransferPrivateKey)); + sizeof (struct TALER_TransferPrivateKeyP)); res = GNUNET_OK; - for (i = 0; i < KAPPA - 1; i++) + for (i = 0; i < TALER_CNC_KAPPA - 1; i++) { if (GNUNET_OK != res) break; @@ -797,23 +797,23 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, { if (GNUNET_OK != res) break; - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, tp_json, - 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, &transfer_privs[i][j], - sizeof (struct TALER_TransferPrivateKey)); + sizeof (struct TALER_TransferPrivateKeyP)); } } if (GNUNET_OK != res) res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; else - res = TALER_MINT_db_execute_refresh_reveal (connection, + res = TMH_DB_execute_refresh_reveal (connection, session_hash, num_oldcoins, transfer_privs); - for (i = 0; i < KAPPA - 1; i++) + for (i = 0; i < TALER_CNC_KAPPA - 1; i++) GNUNET_free (transfer_privs[i]); return res; } @@ -824,7 +824,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, * the private transfer keys except for the cut-and-choose value * returned from "/refresh/melt". This function parses the revealed * keys and secrets and ultimately passes everything to - * #TALER_MINT_db_execute_refresh_reveal() which will verify that the + * #TMH_DB_execute_refresh_reveal() which will verify that the * revealed information is valid then returns the signed refreshed * coins. * @@ -836,11 +836,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) +TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { struct GNUNET_HashCode session_hash; int res; @@ -848,13 +848,13 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, json_t *reveal_detail; json_t *root; json_t *transfer_privs; - struct GNUNET_MINT_ParseFieldSpec spec[] = { - TALER_MINT_PARSE_FIXED ("session_hash", &session_hash), - TALER_MINT_PARSE_ARRAY ("transfer_privs", &transfer_privs), - TALER_MINT_PARSE_END + struct TMH_PARSE_FieldSpecification spec[] = { + TMH_PARSE_MEMBER_FIXED ("session_hash", &session_hash), + TMH_PARSE_MEMBER_ARRAY ("transfer_privs", &transfer_privs), + TMH_PARSE_MEMBER_END }; - res = TALER_MINT_parse_post_json (connection, + res = TMH_PARSE_post_json (connection, connection_cls, upload_data, upload_data_size, @@ -864,7 +864,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == root) ) return MHD_YES; - res = TALER_MINT_parse_json_data (connection, + res = TMH_PARSE_json_data (connection, root, spec); json_decref (root); @@ -872,22 +872,22 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; /* Determine dimensionality of the request (kappa and #old coins) */ - if (KAPPA != json_array_size (transfer_privs) + 1) + if (TALER_CNC_KAPPA != json_array_size (transfer_privs) + 1) { - 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, "transfer_privs"); } /* Note we do +1 as 1 row (cut-and-choose!) is missing! */ - res = GNUNET_MINT_parse_navigate_json (connection, + res = TMH_PARSE_navigate_json (connection, transfer_privs, - JNAV_INDEX, 0, - JNAV_RET_TYPED_JSON, + TMH_PARSE_JNC_INDEX, 0, + TMH_PARSE_JNC_RET_TYPED_JSON, JSON_ARRAY, &reveal_detail); if (GNUNET_OK != res) { - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } num_oldcoins = json_array_size (reveal_detail); @@ -895,7 +895,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, &session_hash, num_oldcoins, transfer_privs); - TALER_MINT_release_parsed_data (spec); + TMH_PARSE_release_data (spec); return res; } @@ -911,25 +911,25 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_refresh_link (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) +TMH_REFRESH_handler_refresh_link (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; int res; - res = TALER_MINT_mhd_request_arg_data (connection, + res = TMH_PARSE_mhd_request_arg_data (connection, "coin_pub", &coin_pub, - sizeof (struct TALER_CoinSpendPublicKey)); + sizeof (union TALER_CoinSpendPublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; if (GNUNET_OK != res) return MHD_YES; - return TALER_MINT_db_execute_refresh_link (connection, + return TMH_DB_execute_refresh_link (connection, &coin_pub); } diff --git a/src/mint/taler-mint-httpd_refresh.h b/src/mint/taler-mint-httpd_refresh.h index 55a780243..934874f10 100644 --- a/src/mint/taler-mint-httpd_refresh.h +++ b/src/mint/taler-mint-httpd_refresh.h @@ -32,7 +32,7 @@ * Handle a "/refresh/melt" request. Parses the request into the JSON * components and then hands things of to #handle_referesh_melt_json() * to validate the melted coins, the signature and execute the melt - * using TALER_MINT_db_execute_refresh_melt(). + * using TMH_DB_execute_refresh_melt(). * * @param rh context of the handler * @param connection the MHD connection to handle @@ -42,11 +42,11 @@ * @return MHD result code */ int -TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -54,7 +54,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, * the private transfer keys except for the cut-and-choose value * returned from "/refresh/commit". This function parses the revealed * keys and secrets and ultimately passes everything to - * #TALER_MINT_db_execute_refresh_reveal() which will verify that the + * #TMH_DB_execute_refresh_reveal() which will verify that the * revealed information is valid then returns the signed refreshed * coins. * @@ -66,11 +66,11 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -84,11 +84,11 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, * @return MHD result code */ int -TALER_MINT_handler_refresh_link (struct RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); +TMH_REFRESH_handler_refresh_link (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_responses.c b/src/mint/taler-mint-httpd_responses.c index 667ce7927..31a4ecd0b 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -16,7 +16,7 @@ /** * @file taler-mint-httpd_responses.c * @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 @@ -38,7 +38,7 @@ * @return MHD result code */ int -TALER_MINT_reply_json (struct MHD_Connection *connection, +TMH_RESPONSE_reply_json (struct MHD_Connection *connection, const json_t *json, unsigned int response_code) { @@ -71,7 +71,7 @@ TALER_MINT_reply_json (struct MHD_Connection *connection, * @return MHD result code */ int -TALER_MINT_reply_json_pack (struct MHD_Connection *connection, +TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, unsigned int response_code, const char *fmt, ...) @@ -85,7 +85,7 @@ TALER_MINT_reply_json_pack (struct MHD_Connection *connection, va_end (argp); if (NULL == json) return MHD_NO; - ret = TALER_MINT_reply_json (connection, + ret = TMH_RESPONSE_reply_json (connection, json, response_code); json_decref (json); @@ -101,10 +101,10 @@ TALER_MINT_reply_json_pack (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection, +TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, const char *param_name) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:s}", "error", "invalid parameter", @@ -121,11 +121,11 @@ 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) { /* TODO: may want to be more precise in the future and distinguish bogus signatures from bogus public keys. */ - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s}", "error", "Coin is not valid"); @@ -140,10 +140,10 @@ TALER_MINT_reply_coin_invalid (struct MHD_Connection *connection) * @return a MHD result code */ int -TALER_MINT_reply_arg_missing (struct MHD_Connection *connection, +TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, const char *param_name) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{ s:s, s:s}", "error", "missing parameter", @@ -159,10 +159,10 @@ TALER_MINT_reply_arg_missing (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_internal_error (struct MHD_Connection *connection, +TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, const char *hint) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:s}", "error", "internal error", @@ -178,10 +178,10 @@ TALER_MINT_reply_internal_error (struct MHD_Connection *connection, * @return a MHD result code */ int -TALER_MINT_reply_external_error (struct MHD_Connection *connection, +TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection, const char *hint) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:s}", "error", "client error", @@ -197,9 +197,9 @@ 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) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s}", "error", "commit failure"); @@ -214,9 +214,9 @@ 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) { - return TALER_MINT_reply_internal_error (connection, + return TMH_RESPONSE_reply_internal_error (connection, "Failed to connect to database"); } @@ -228,7 +228,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) { struct MHD_Response *resp; int ret; @@ -253,9 +253,9 @@ 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) { - return TALER_MINT_reply_json_pack (connection, + return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s}", "error", @@ -281,21 +281,21 @@ 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, +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_MerchantPublicKey *merchant, + const struct TALER_MerchantPublicKeyP *merchant, const struct TALER_Amount *amount) { - struct TALER_DepositConfirmation dc; - struct TALER_MintSignature sig; + struct TALER_DepositConfirmationPS dc; + struct TALER_MintSignatureP sig; json_t *sig_json; int ret; - dc.purpose.purpose = htonl (TALER_SIGNATURE_MINT_DEPOSIT); - dc.purpose.size = htonl (sizeof (struct TALER_DepositConfirmation)); + dc.purpose.purpose = htonl (TALER_SIGNATURE_COIN_DEPOSIT); + dc.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)); dc.h_contract = *h_contract; dc.h_wire = *h_wire; dc.transaction_id = GNUNET_htonll (transaction_id); @@ -303,11 +303,11 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, amount); dc.coin_pub = *coin_pub; dc.merchant = *merchant; - TALER_MINT_keys_sign (&dc.purpose, + TMH_KS_sign (&dc.purpose, &sig); - sig_json = TALER_JSON_from_eddsa_sig (&dc.purpose, + sig_json = TALER_json_from_eddsa_sig (&dc.purpose, &sig.eddsa_signature); - ret = TALER_MINT_reply_json_pack (connection, + ret = TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:s, s:o}", "status", "DEPOSIT_OK", @@ -339,37 +339,37 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl) { case TALER_MINT_DB_TT_DEPOSIT: { - struct TALER_DepositRequest dr; + struct TALER_DepositRequestPS dr; const struct Deposit *deposit = pos->details.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/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-<plugin_name>", /* will be replaced later */ "-c", "test-mint-db-<plugin_name>.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 <libpq-fe.h> #include <gnunet/gnunet_util_lib.h> #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 diff --git a/src/pq/Makefile.am b/src/pq/Makefile.am index c94029bc6..db9d4aa23 100644 --- a/src/pq/Makefile.am +++ b/src/pq/Makefile.am @@ -3,14 +3,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include $(LIBGCRYPT_CFLAGS) $(POSTGRESQL_CPPFL talerincludedir = $(includedir)/taler -talerinclude_HEADERS = \ - db_pq.h - lib_LTLIBRARIES = \ libtalerpq.la libtalerpq_la_SOURCES = \ - db_pq.c db_pq.h + db_pq.c libtalerpq_la_LIBADD = \ -lgnunetutil \ diff --git a/src/pq/db_pq.c b/src/pq/db_pq.c index 3594fcbf2..48ffb6c88 100644 --- a/src/pq/db_pq.c +++ b/src/pq/db_pq.c @@ -14,7 +14,7 @@ TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> */ /** - * @file util/db_pq.c + * @file pq/db_pq.c * @brief helper functions for libpq (PostGres) interactions * @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Florian Dold @@ -22,23 +22,23 @@ */ #include "platform.h" #include <gnunet/gnunet_util_lib.h> -#include "db_pq.h" +#include "taler_pq_lib.h" /** * Execute a prepared statement. */ PGresult * -TALER_DB_exec_prepared (PGconn *db_conn, +TALER_PQ_exec_prepared (PGconn *db_conn, const char *name, - const struct TALER_DB_QueryParam *params) + const struct TALER_PQ_QueryParam *params) { unsigned len; unsigned i; /* count the number of parameters */ { - const struct TALER_DB_QueryParam *x; + const struct TALER_PQ_QueryParam *x; for (len = 0, x = params; x->more; len++, x++); @@ -76,8 +76,8 @@ TALER_DB_exec_prepared (PGconn *db_conn, * #GNUNET_SYSERR if a result was invalid (non-existing field) */ int -TALER_DB_extract_result (PGresult *result, - struct TALER_DB_ResultSpec *rs, +TALER_PQ_extract_result (PGresult *result, + struct TALER_PQ_ResultSpec *rs, int row) { int had_null = GNUNET_NO; @@ -141,7 +141,7 @@ TALER_DB_extract_result (PGresult *result, int -TALER_DB_field_isnull (PGresult *result, +TALER_PQ_field_isnull (PGresult *result, int row, const char *fname) { @@ -156,7 +156,7 @@ TALER_DB_field_isnull (PGresult *result, int -TALER_DB_extract_amount_nbo (PGresult *result, +TALER_PQ_extract_amount_nbo (PGresult *result, int row, const char *val_name, const char *frac_name, @@ -196,7 +196,7 @@ TALER_DB_extract_amount_nbo (PGresult *result, int -TALER_DB_extract_amount (PGresult *result, +TALER_PQ_extract_amount (PGresult *result, int row, const char *val_name, const char *frac_name, @@ -206,7 +206,7 @@ TALER_DB_extract_amount (PGresult *result, struct TALER_AmountNBO amount_nbo; (void) - TALER_DB_extract_amount_nbo (result, + TALER_PQ_extract_amount_nbo (result, row, val_name, frac_name, diff --git a/src/util/crypto.c b/src/util/crypto.c index ffc12fed9..eca4e407a 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -40,7 +40,7 @@ fatal_error_handler (void *cls, int wtf, const char *msg) { - LOG_ERROR ("Fatal error in libgcrypt: %s\n", + TALER_LOG_ERROR ("Fatal error in libgcrypt: %s\n", msg); abort(); } @@ -71,7 +71,7 @@ TALER_gcrypt_init () * @param[out] skey set to session key */ static void -derive_refresh_key (const struct TALER_LinkSecret *secret, +derive_refresh_key (const struct TALER_LinkSecretP *secret, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, struct GNUNET_CRYPTO_SymmetricSessionKey *skey) { @@ -81,12 +81,12 @@ derive_refresh_key (const struct TALER_LinkSecret *secret, GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey), ctx_key, strlen (ctx_key), - secret, sizeof (struct TALER_LinkSecret), + secret, sizeof (struct TALER_LinkSecretP), NULL, 0)); GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector), ctx_iv, strlen (ctx_iv), - secret, sizeof (struct TALER_LinkSecret), + secret, sizeof (struct TALER_LinkSecretP), NULL, 0)); } @@ -100,7 +100,7 @@ derive_refresh_key (const struct TALER_LinkSecret *secret, * @param[out] skey set to session key */ static void -derive_transfer_key (const struct TALER_TransferSecret *secret, +derive_transfer_key (const struct TALER_TransferSecretP *secret, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, struct GNUNET_CRYPTO_SymmetricSessionKey *skey) { @@ -110,12 +110,12 @@ derive_transfer_key (const struct TALER_TransferSecret *secret, GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey), ctx_key, strlen (ctx_key), - secret, sizeof (struct TALER_TransferSecret), + secret, sizeof (struct TALER_TransferSecretP), NULL, 0)); GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector), ctx_iv, strlen (ctx_iv), - secret, sizeof (struct TALER_TransferSecret), + secret, sizeof (struct TALER_TransferSecretP), NULL, 0)); } @@ -130,18 +130,18 @@ derive_transfer_key (const struct TALER_TransferSecret *secret, * @return #GNUNET_OK on success */ int -TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, - const struct TALER_TransferSecret *trans_sec, - struct TALER_LinkSecret *secret) +TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecretP *secret_enc, + const struct TALER_TransferSecretP *trans_sec, + struct TALER_LinkSecretP *secret) { struct GNUNET_CRYPTO_SymmetricInitializationVector iv; struct GNUNET_CRYPTO_SymmetricSessionKey skey; - GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecret) == - sizeof (struct TALER_LinkSecret)); + GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecretP) == + sizeof (struct TALER_LinkSecretP)); derive_transfer_key (trans_sec, &iv, &skey); return GNUNET_CRYPTO_symmetric_decrypt (secret_enc, - sizeof (struct TALER_LinkSecret), + sizeof (struct TALER_LinkSecretP), &skey, &iv, secret); @@ -158,18 +158,18 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, * @return #GNUNET_OK on success */ int -TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, - const struct TALER_TransferSecret *trans_sec, - struct TALER_EncryptedLinkSecret *secret_enc) +TALER_transfer_encrypt (const struct TALER_LinkSecretP *secret, + const struct TALER_TransferSecretP *trans_sec, + struct TALER_EncryptedLinkSecretP *secret_enc) { struct GNUNET_CRYPTO_SymmetricInitializationVector iv; struct GNUNET_CRYPTO_SymmetricSessionKey skey; - GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecret) == - sizeof (struct TALER_LinkSecret)); + GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecretP) == + sizeof (struct TALER_LinkSecretP)); derive_transfer_key (trans_sec, &iv, &skey); return GNUNET_CRYPTO_symmetric_encrypt (secret, - sizeof (struct TALER_LinkSecret), + sizeof (struct TALER_LinkSecretP), &skey, &iv, secret_enc); @@ -183,11 +183,11 @@ TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, * @param secret shared secret to use for decryption * @return NULL on error */ -struct TALER_RefreshLinkDecrypted * +struct TALER_RefreshLinkDecryptedP * TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, - const struct TALER_LinkSecret *secret) + const struct TALER_LinkSecretP *secret) { - struct TALER_RefreshLinkDecrypted *ret; + struct TALER_RefreshLinkDecryptedP *ret; struct GNUNET_CRYPTO_SymmetricInitializationVector iv; struct GNUNET_CRYPTO_SymmetricSessionKey skey; size_t buf_size = input->blinding_key_enc_size @@ -203,10 +203,10 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, &iv, buf)) return NULL; - ret = GNUNET_new (struct TALER_RefreshLinkDecrypted); + ret = GNUNET_new (struct TALER_RefreshLinkDecryptedP); memcpy (&ret->coin_priv, buf, - sizeof (struct TALER_CoinSpendPrivateKey)); + sizeof (union TALER_CoinSpendPrivateKeyP)); ret->blinding_key.rsa_blinding_key = GNUNET_CRYPTO_rsa_blinding_key_decode (&buf[sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)], input->blinding_key_enc_size); @@ -227,8 +227,8 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, * @return NULL on error (should never happen) */ struct TALER_RefreshLinkEncrypted * -TALER_refresh_encrypt (const struct TALER_RefreshLinkDecrypted *input, - const struct TALER_LinkSecret *secret) +TALER_refresh_encrypt (const struct TALER_RefreshLinkDecryptedP *input, + const struct TALER_LinkSecretP *secret) { char *b_buf; size_t b_buf_size; diff --git a/src/util/json.c b/src/util/json.c index 7390eb474..d3496c42c 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -36,7 +36,7 @@ */ #define UNPACK_EXITIF(cond) \ do { \ - if (cond) { TALER_JSON_warn (error); goto EXITIF_exit; } \ + if (cond) { TALER_json_warn (error); goto EXITIF_exit; } \ } while (0) @@ -48,7 +48,7 @@ * @return a json object describing the amount */ json_t * -TALER_JSON_from_amount (const struct TALER_Amount *amount) +TALER_json_from_amount (const struct TALER_Amount *amount) { json_t *j; @@ -79,7 +79,7 @@ TALER_JSON_from_amount (const struct TALER_Amount *amount) * @return a json string with the timestamp in @a stamp */ json_t * -TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp) +TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp) { json_t *j; char *mystr; @@ -101,7 +101,7 @@ TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp) * @return the JSON reporesentation of the signature with purpose */ json_t * -TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, +TALER_json_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, const struct GNUNET_CRYPTO_EddsaSignature *signature) { json_t *root; @@ -115,11 +115,11 @@ TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo el = json_integer ((json_int_t) ntohl (purpose->purpose)); json_object_set_new (root, "purpose", el); - el = TALER_JSON_from_data (purpose, + el = TALER_json_from_data (purpose, ntohl (purpose->size)); json_object_set_new (root, "eddsa-val", el); - el = TALER_JSON_from_data (signature, + el = TALER_json_from_data (signature, sizeof (struct GNUNET_CRYPTO_EddsaSignature)); json_object_set_new (root, "eddsa-sig", el); @@ -135,7 +135,7 @@ TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo * @return the JSON reporesentation of the signature with purpose */ json_t * -TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, +TALER_json_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, const struct GNUNET_CRYPTO_EcdsaSignature *signature) { json_t *root; @@ -149,11 +149,11 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo el = json_integer ((json_int_t) ntohl (purpose->purpose)); json_object_set_new (root, "purpose", el); - el = TALER_JSON_from_data (purpose, + el = TALER_json_from_data (purpose, ntohl (purpose->size)); json_object_set_new (root, "ecdsa-val", el); - el = TALER_JSON_from_data (signature, + el = TALER_json_from_data (signature, sizeof (struct GNUNET_CRYPTO_EddsaSignature)); json_object_set_new (root, "ecdsa-sig", el); @@ -168,7 +168,7 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo * @return corresponding JSON encoding */ json_t * -TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk) +TALER_json_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk) { char *buf; size_t buf_len; @@ -176,7 +176,7 @@ TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk) buf_len = GNUNET_CRYPTO_rsa_public_key_encode (pk, &buf); - ret = TALER_JSON_from_data (buf, + ret = TALER_json_from_data (buf, buf_len); GNUNET_free (buf); return ret; @@ -190,7 +190,7 @@ TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk) * @return corresponding JSON encoding */ json_t * -TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig) +TALER_json_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig) { char *buf; size_t buf_len; @@ -198,7 +198,7 @@ TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig) buf_len = GNUNET_CRYPTO_rsa_signature_encode (sig, &buf); - ret = TALER_JSON_from_data (buf, + ret = TALER_json_from_data (buf, buf_len); GNUNET_free (buf); return ret; @@ -214,7 +214,7 @@ TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig) * @return json string that encodes @a data */ json_t * -TALER_JSON_from_data (const void *data, size_t size) +TALER_json_from_data (const void *data, size_t size) { char *buf; json_t *json; @@ -234,9 +234,9 @@ TALER_JSON_from_data (const void *data, size_t size) * @return json string that encodes @a hc */ json_t * -TALER_JSON_from_hash (const struct GNUNET_HashCode *hc) +TALER_json_from_hash (const struct GNUNET_HashCode *hc) { - return TALER_JSON_from_data (hc, sizeof (struct GNUNET_HashCode)); + return TALER_json_from_data (hc, sizeof (struct GNUNET_HashCode)); } @@ -248,7 +248,7 @@ TALER_JSON_from_hash (const struct GNUNET_HashCode *hc) * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_amount (json_t *json, +TALER_json_to_amount (json_t *json, struct TALER_Amount *r_amount) { char *currency; @@ -279,7 +279,7 @@ TALER_JSON_to_amount (json_t *json, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_abs (json_t *json, +TALER_json_to_abs (json_t *json, struct GNUNET_TIME_Absolute *abs) { const char *str; @@ -304,7 +304,7 @@ TALER_JSON_to_abs (json_t *json, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_data (json_t *json, +TALER_json_to_data (json_t *json, void *out, size_t out_size) { @@ -563,7 +563,7 @@ validate_iban (const char *iban) * @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not */ int -TALER_JSON_validate_wireformat (const char *type, +TALER_json_validate_wireformat (const char *type, const json_t *wire) { json_error_t error; diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 82dc49180..5abd64493 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -454,7 +454,7 @@ os_get_exec_path () * @return a pointer to the dir path (to be freed by the caller) */ char * -TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) +TALER_os_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) { size_t n; const char *dirname; diff --git a/src/util/test_json_validations.c b/src/util/test_json_validations.c index a5747c94a..26ec4b79f 100644 --- a/src/util/test_json_validations.c +++ b/src/util/test_json_validations.c @@ -44,10 +44,10 @@ int main(int argc, const char *const argv[]) wire = json_loads (json_wire_str, 0, &error); if (NULL == wire) { - TALER_JSON_warn (error); + TALER_json_warn (error); return 2; } - ret = TALER_JSON_validate_wireformat ("SEPA", wire); + ret = TALER_json_validate_wireformat ("SEPA", wire); if (1 == ret) return 0; return 1; |