From 00d613728fdddf4f28e3c50cb2f70bfbba65e298 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 8 Aug 2015 19:52:05 +0200 Subject: completing TALER_MINT_refresh_melt implementation --- src/include/taler_crypto_lib.h | 17 +++++++++++++++++ src/include/taler_mint_service.h | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 4126894a..5f142507 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -468,6 +468,23 @@ TALER_link_decrypt_secret2 (const struct TALER_EncryptedLinkSecretP *secret_enc, struct TALER_LinkSecretP *secret); +/** + * Given the coin and the transfer private keys, compute the + * transfer secret. (Technically, we only need one of the two + * private keys, but the caller currently trivially only has + * the two private keys, so we derive one of the public keys + * internally to this function.) + * + * @param coin_priv coin key + * @param trans_priv transfer private key + * @param[out] computed transfer secret + */ +void +TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin_priv, + const struct TALER_TransferPrivateKeyP *trans_priv, + struct TALER_TransferSecretP *ts); + + /** * Encrypt the shared @a secret to generate the encrypted link secret. * Also creates the transfer key. diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index b228acc5..fa1f7a50 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -181,7 +181,7 @@ struct TALER_MINT_DenomPublicKey struct TALER_Amount fee_deposit; /** - *The applicable fee to refresh a coin of this denomination + *The applicable fee to melt/refresh a coin of this denomination */ struct TALER_Amount fee_refresh; }; -- cgit v1.2.3 From 7e47853a5e2bbba529fad06a349d67439d03e5ab Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 8 Aug 2015 23:03:26 +0200 Subject: implement parse_refresh_link_ok --- src/include/taler_mint_service.h | 2 + src/mint-lib/mint_api_refresh_link.c | 231 ++++++++++++++++++++++++++++++----- src/mint-lib/mint_api_withdraw.c | 1 + 3 files changed, 206 insertions(+), 28 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index fa1f7a50..ea06d95f 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -841,6 +841,7 @@ struct TALER_MINT_RefreshLinkHandle; * @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed * @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error * @param sigs array of signature over @a num_coins coins, NULL on error + * @param pubs array of public keys for the @a sigs, NULL on error * @param full_response full response from the mint (for logging, in case of errors) */ typedef void @@ -849,6 +850,7 @@ typedef void unsigned int num_coins, const struct TALER_CoinSpendPrivateKeyP *coin_privs, const struct TALER_DenominationSignature *sigs, + const struct TALER_DenominationPublicKey *pubs, json_t *full_response); diff --git a/src/mint-lib/mint_api_refresh_link.c b/src/mint-lib/mint_api_refresh_link.c index 3ea6b23e..f17949af 100644 --- a/src/mint-lib/mint_api_refresh_link.c +++ b/src/mint-lib/mint_api_refresh_link.c @@ -47,11 +47,6 @@ struct TALER_MINT_RefreshLinkHandle */ char *url; - /** - * JSON encoding of the request to POST. - */ - char *json_enc; - /** * Handle for the request. */ @@ -72,9 +67,190 @@ struct TALER_MINT_RefreshLinkHandle */ struct MAC_DownloadBuffer db; + /** + * Private key of the coin, required to decode link information. + */ + struct TALER_CoinSpendPrivateKeyP coin_priv; + }; +/** + * Parse the provided linkage data from the "200 OK" response + * for one of the coins. + * + * @param rlh refresh link handle + * @param json json reply with the data for one coin + * @param trans_pub our transfer public key + * @param secret_enc encrypted key to decrypt link data + * @param[out] coin_priv where to return private coin key + * @param[out] sig where to return private coin signature + * @param[out] pub where to return the public key for the coin + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error + */ +static int +parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh, + json_t *json, + const struct TALER_TransferPublicKeyP *trans_pub, + const struct TALER_EncryptedLinkSecretP *secret_enc, + struct TALER_CoinSpendPrivateKeyP *coin_priv, + struct TALER_DenominationSignature *sig, + struct TALER_DenominationPublicKey *pub) +{ + void *link_enc; + size_t link_enc_size; + struct GNUNET_CRYPTO_rsa_Signature *bsig; + struct MAJ_Specification spec[] = { + MAJ_spec_varsize ("link_enc", &link_enc, &link_enc_size), + MAJ_spec_rsa_public_key ("denom_pub", &pub->rsa_public_key), + MAJ_spec_rsa_signature ("ev_sig", &bsig), + MAJ_spec_end + }; + struct TALER_RefreshLinkEncrypted *rle; + struct TALER_RefreshLinkDecrypted *rld; + struct TALER_LinkSecretP secret; + + /* parse reply */ + if (GNUNET_OK != + MAJ_parse_json (json, + spec)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + + /* decode and decrypt link data */ + rle = TALER_refresh_link_encrypted_decode (link_enc, + link_enc_size); + if (NULL == rle) + { + GNUNET_break_op (0); + MAJ_parse_free (spec); + return GNUNET_SYSERR; + } + if (GNUNET_OK != + TALER_link_decrypt_secret2 (secret_enc, + trans_pub, + &rlh->coin_priv, + &secret)) + { + GNUNET_break_op (0); + MAJ_parse_free (spec); + return GNUNET_SYSERR; + } + rld = TALER_refresh_decrypt (rle, + &secret); + if (NULL == rld) + { + GNUNET_break_op (0); + MAJ_parse_free (spec); + return GNUNET_SYSERR; + } + + /* extract coin and signature */ + *coin_priv = rld->coin_priv; + sig->rsa_signature + = GNUNET_CRYPTO_rsa_unblind (bsig, + rld->blinding_key.rsa_blinding_key, + pub->rsa_public_key); + + /* clean up */ + GNUNET_free (rld); + MAJ_parse_free (spec); + return GNUNET_OK; +} + + +/** + * Parse the provided linkage data from the "200 OK" response + * for one of the coins. + * + * @param[in,out] rlh refresh link handle (callback may be zero'ed out) + * @param json json reply with the data for one coin + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error + */ +static int +parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh, + json_t *json) +{ + json_t *jsona; + struct TALER_TransferPublicKeyP trans_pub; + struct TALER_EncryptedLinkSecretP secret_enc; + struct MAJ_Specification spec[] = { + MAJ_spec_json ("new_coins", &jsona), + MAJ_spec_fixed_auto ("trans_pub", &trans_pub), + MAJ_spec_fixed_auto ("secret_enc", &secret_enc), + MAJ_spec_end + }; + unsigned int num_coins; + int ret; + + if (GNUNET_OK != + MAJ_parse_json (json, + spec)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + if (! json_is_array (jsona)) + { + GNUNET_break_op (0); + MAJ_parse_free (spec); + return GNUNET_SYSERR; + } + + /* decode all coins */ + num_coins = json_array_size (json); + { + unsigned int i; + struct TALER_CoinSpendPrivateKeyP coin_privs[num_coins]; + struct TALER_DenominationSignature sigs[num_coins]; + struct TALER_DenominationPublicKey pubs[num_coins]; + + for (i=0;ilink_cb (rlh->link_cb_cls, + MHD_HTTP_OK, + num_coins, + coin_privs, + sigs, + pubs, + json); + rlh->link_cb = NULL; + ret = GNUNET_OK; + } + + /* clean up */ + for (i=0;ilink_cb = NULL; (call with real result, do not call again below) + if (GNUNET_OK != + parse_refresh_link_ok (rlh, + json)) + { + GNUNET_break_op (0); + response_code = 0; + } break; case MHD_HTTP_BAD_REQUEST: /* This should never happen, either us or the mint is buggy @@ -126,7 +307,7 @@ handle_refresh_link_finished (void *cls, if (NULL != rlh->link_cb) rlh->link_cb (rlh->link_cb_cls, response_code, - 0, NULL, NULL, + 0, NULL, NULL, NULL, json); json_decref (json); TALER_MINT_refresh_link_cancel (rlh); @@ -153,10 +334,12 @@ TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint, TALER_MINT_RefreshLinkCallback link_cb, void *link_cb_cls) { - json_t *link_obj; struct TALER_MINT_RefreshLinkHandle *rlh; CURL *eh; struct TALER_MINT_Context *ctx; + struct TALER_CoinSpendPublicKeyP coin_pub; + char *pub_str; + char *arg_str; if (GNUNET_YES != MAH_handle_is_ready (mint)) @@ -164,36 +347,29 @@ TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint, GNUNET_break (0); return NULL; } - /* FIXME: totally bogus request building here: */ - link_obj = json_pack ("{s:o, s:O}", /* f/wire */ - "4", 42, - "6", 62); + GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, + &coin_pub.eddsa_pub); + pub_str = GNUNET_STRINGS_data_to_string_alloc (&coin_pub, + sizeof (struct TALER_CoinSpendPublicKeyP)); + GNUNET_asprintf (&arg_str, + "/refresh/link?coin_pub=%s", + pub_str); + GNUNET_free (pub_str); rlh = GNUNET_new (struct TALER_MINT_RefreshLinkHandle); rlh->mint = mint; rlh->link_cb = link_cb; rlh->link_cb_cls = link_cb_cls; - - rlh->url = MAH_path_to_url (mint, "/refresh/link"); + rlh->coin_priv = *coin_priv; + rlh->url = MAH_path_to_url (mint, arg_str); + GNUNET_free (arg_str); eh = curl_easy_init (); - GNUNET_assert (NULL != (rlh->json_enc = - json_dumps (link_obj, - JSON_COMPACT))); - json_decref (link_obj); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, CURLOPT_URL, rlh->url)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDS, - rlh->json_enc)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDSIZE, - strlen (rlh->json_enc))); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, CURLOPT_WRITEFUNCTION, @@ -228,7 +404,6 @@ TALER_MINT_refresh_link_cancel (struct TALER_MINT_RefreshLinkHandle *rlh) } GNUNET_free_non_null (rlh->db.buf); GNUNET_free (rlh->url); - GNUNET_free (rlh->json_enc); GNUNET_free (rlh); } diff --git a/src/mint-lib/mint_api_withdraw.c b/src/mint-lib/mint_api_withdraw.c index e7a1a61d..ddabb811 100644 --- a/src/mint-lib/mint_api_withdraw.c +++ b/src/mint-lib/mint_api_withdraw.c @@ -287,6 +287,7 @@ handle_withdraw_status_finished (void *cls, break; case MHD_HTTP_OK: { + /* TODO: move into separate function... */ json_t *history; unsigned int len; struct TALER_Amount balance; -- cgit v1.2.3 From aaab2ed2d4de62b36f9e802978cd47a642bf90f0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 15:24:02 +0200 Subject: fix FTBFS, towards implementing OC_REFRESH_REVEAL --- src/include/taler_mint_service.h | 10 ++-- src/mint-lib/test_mint_api.c | 105 +++++++++++++++++++++++++++++++++------ 2 files changed, 95 insertions(+), 20 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index ea06d95f..8c5f520d 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -727,11 +727,11 @@ typedef void * In this case, neither callback will be called. */ struct TALER_MINT_RefreshMeltHandle * -TALER_MINT_refresh_melt_execute (struct TALER_MINT_Handle *mint, - size_t refresh_data_length, - const char *refresh_data, - TALER_MINT_RefreshMeltCallback melt_cb, - void *melt_cb_cls); +TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint, + size_t refresh_data_length, + const char *refresh_data, + TALER_MINT_RefreshMeltCallback melt_cb, + void *melt_cb_cls); /** diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index 1722b29b..e5ac2b51 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -365,6 +365,11 @@ struct Command */ const char *melt_ref; + /** + * Reveal handle while operation is running. + */ + struct TALER_MINT_RefreshRevealHandle *rrh; + /** * Number of fresh coins withdrawn, set by the interpreter. * Length of the @e fresh_coins array. @@ -410,6 +415,11 @@ struct Command */ const char *reveal_ref; + /** + * Link handle while operation is running. + */ + struct TALER_MINT_RefreshLinkHandle *rlh; + } refresh_link; } details; @@ -864,6 +874,47 @@ melt_cb (void *cls, } +/** + * Function called with the result of the /refresh/reveal operation. + * + * @param cls closure with the interpreter state + * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request + * 0 if the mint's reply is bogus (fails to follow the protocol) + * @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed + * @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error + * @param sigs array of signature over @a num_coins coins, NULL on error + * @param full_response full response from the mint (for logging, in case of errors) + */ +static void +reveal_cb (void *cls, + unsigned int http_status, + unsigned int num_coins, + const struct TALER_CoinSpendPrivateKeyP *coin_privs, + const struct TALER_DenominationSignature *sigs, + json_t *full_response) +{ + struct InterpreterState *is = cls; + struct Command *cmd = &is->commands[is->ip]; + unsigned int i; + + cmd->details.refresh_reveal.rrh = NULL; + if (cmd->expected_response_code != http_status) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unexpected response code %u to command %s\n", + http_status, + cmd->label); + fail (is); + return; + } + cmd->details.refresh_reveal.num_fresh_coins = num_coins; + // FIXME: init rest... + is->ip++; + is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, + is); +} + + /** * Find denomination key matching the given amount. * @@ -1205,7 +1256,7 @@ interpreter_run (void *cls, cmd->details.refresh_melt.noreveal_index = UINT16_MAX; for (num_melted_coins=0; - NULL != cmd->details.refresh_melt.melted_coins[num_melted_coins]; + NULL != cmd->details.refresh_melt.melted_coins[num_melted_coins].amount; num_melted_coins++) ; for (num_fresh_coins=0; NULL != cmd->details.refresh_melt.fresh_amounts[num_fresh_coins]; @@ -1225,7 +1276,7 @@ interpreter_run (void *cls, ref = find_command (is, md->coin_ref); GNUNET_assert (NULL != ref); - GNUNET_assert (OC_WITHDRAW_SIGN == ref_cmd->oc); + GNUNET_assert (OC_WITHDRAW_SIGN == ref->oc); melt_privs[i] = ref->details.withdraw_sign.coin_priv; if (GNUNET_OK != @@ -1240,12 +1291,23 @@ interpreter_run (void *cls, return; } melt_sigs[i] = ref->details.withdraw_sign.sig; - melt_pks[i] = ref->details.withdraw_sign.pk; + melt_pks[i] = *ref->details.withdraw_sign.pk; } for (i=0;ikeys, - cmd->details.refresh_melt.fresh_amounts[i]); + if (GNUNET_OK != + TALER_string_to_amount (cmd->details.refresh_melt.fresh_amounts[i], + &amount)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to parse amount `%s' at %u\n", + cmd->details.withdraw_sign.amount, + is->ip); + fail (is); + return; + } + fresh_pks[i] = *find_pk (is->keys, + &amount); } cmd->details.refresh_melt.refresh_data = TALER_MINT_refresh_prepare (num_melted_coins, @@ -1264,11 +1326,11 @@ interpreter_run (void *cls, return; } cmd->details.refresh_melt.rmh - = TALER_MINT_refresh_melt_execute (mint, - cmd->details.refresh_melt.refresh_data_length, - cmd->details.refresh_melt.refresh_data, - &melt_cb, - is); + = TALER_MINT_refresh_melt (mint, + cmd->details.refresh_melt.refresh_data_length, + cmd->details.refresh_melt.refresh_data, + &melt_cb, + is); if (NULL == cmd->details.refresh_melt.rmh) { GNUNET_break (0); @@ -1281,10 +1343,23 @@ interpreter_run (void *cls, } break; case OC_REFRESH_REVEAL: - /* not implemented */ - GNUNET_break (0); - is->ip++; - break; + ref = find_command (is, + cmd->details.refresh_reveal.melt_ref); + cmd->details.refresh_reveal.rrh + = TALER_MINT_refresh_reveal (mint, + ref->details.refresh_melt.refresh_data_length, + ref->details.refresh_melt.refresh_data, + ref->details.refresh_melt.noreveal_index, + &reveal_cb, + is); + if (NULL == cmd->details.refresh_reveal.rrh) + { + GNUNET_break (0); + fail (is); + return; + } + trigger_context_task (); + return; case OC_REFRESH_LINK: /* not implemented */ GNUNET_break (0); @@ -1407,7 +1482,7 @@ do_shutdown (void *cls, } break; case OC_REFRESH_LINK: - if (NULL != cmd->details.refresh_link.rl) + if (NULL != cmd->details.refresh_link.rlh) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Command %u (%s) did not complete\n", -- cgit v1.2.3 From c6f88ebd61ba69cddf71b1b70a1952c61f1112b4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 15:40:16 +0200 Subject: doxygen-fixes --- src/include/taler_crypto_lib.h | 2 +- src/include/taler_mint_service.h | 10 +++++----- src/mint-lib/mint_api_deposit.c | 2 +- src/mint-lib/mint_api_refresh.c | 10 +++++----- src/util/crypto.c | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 5f142507..0f25ea3c 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -477,7 +477,7 @@ TALER_link_decrypt_secret2 (const struct TALER_EncryptedLinkSecretP *secret_enc, * * @param coin_priv coin key * @param trans_priv transfer private key - * @param[out] computed transfer secret + * @param[out] ts computed transfer secret */ void TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin_priv, diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index 8c5f520d..68813306 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -396,11 +396,11 @@ typedef void * * @param mint the mint handle; the mint must be ready to operate * @param amount the amount to be deposited - * @param wire the merchant’s account details, in a format supported by the mint + * @param wire_details the merchant’s account details, in a format supported by the mint * @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint) * @param coin_pub coin’s public key * @param denom_pub denomination key with which the coin is signed - * @param ub_sig mint’s unblinded signature of the coin + * @param denom_sig mint’s unblinded signature of the coin * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the mint * @param transaction_id transaction id for the transaction between merchant and customer * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) @@ -635,7 +635,7 @@ TALER_MINT_withdraw_sign_cancel (struct TALER_MINT_WithdrawSignHandle *sign); * no money is lost in case of hardware failures, is operation does * not actually initiate the request. Instead, it generates a buffer * which the caller must store before proceeding with the actual call - * to #TALER_MINT_refresh_execute() that will generate the request. + * to #TALER_MINT_refresh_melt() that will generate the request. * * This function does verify that the given request data is internally * consistent. However, the @a melts_sigs are only verified if @a @@ -660,11 +660,11 @@ TALER_MINT_withdraw_sign_cancel (struct TALER_MINT_WithdrawSignHandle *sign); * @param check_sigs verify the validity of the signatures of @a melt_sigs * @param fresh_pks_len length of the @a pks array * @param fresh_pks array of @a pks_len denominations of fresh coins to create - * @param[OUT] res_size set to the size of the return value, or 0 on error + * @param[out] res_size set to the size of the return value, or 0 on error * @return NULL * if the inputs are invalid (i.e. denomination key not with this mint). * Otherwise, pointer to a buffer of @a res_size to store persistently - * before proceeding to #TALER_MINT_refresh_execute(). + * before proceeding to #TALER_MINT_refresh_melt(). * Non-null results should be freed using #GNUNET_free(). */ char * diff --git a/src/mint-lib/mint_api_deposit.c b/src/mint-lib/mint_api_deposit.c index 4484f1cd..3da9d0ae 100644 --- a/src/mint-lib/mint_api_deposit.c +++ b/src/mint-lib/mint_api_deposit.c @@ -358,7 +358,7 @@ verify_signatures (const struct TALER_MINT_DenomPublicKey *dki, * * @param mint the mint handle; the mint must be ready to operate * @param amount the amount to be deposited - * @param wire the merchant’s account details, in a format supported by the mint + * @param wire_details the merchant’s account details, in a format supported by the mint * @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint) * @param coin_pub coin’s public key * @param denom_pub denomination key with which the coin is signed diff --git a/src/mint-lib/mint_api_refresh.c b/src/mint-lib/mint_api_refresh.c index 53526265..d8391ac4 100644 --- a/src/mint-lib/mint_api_refresh.c +++ b/src/mint-lib/mint_api_refresh.c @@ -820,11 +820,11 @@ setup_fresh_coin (struct FreshCoin *fc, * no money is lost in case of hardware failures, is operation does * not actually initiate the request. Instead, it generates a buffer * which the caller must store before proceeding with the actual call - * to #TALER_MINT_refresh_execute() that will generate the request. + * to #TALER_MINT_refresh_melt() that will generate the request. * * This function does verify that the given request data is internally - * consistent. However, the @a melts_sigs are only verified if @a - * check_sigs is set to #GNUNET_YES, as this may be relatively + * consistent. However, the @a melts_sigs are only verified if + * @a check_sigs is set to #GNUNET_YES, as this may be relatively * expensive and should be redundant. * * Aside from some non-trivial cryptographic operations that might @@ -845,11 +845,11 @@ setup_fresh_coin (struct FreshCoin *fc, * @param check_sigs verify the validity of the signatures of @a melt_sigs * @param fresh_pks_len length of the @a pks array * @param fresh_pks array of @a pks_len denominations of fresh coins to create - * @param[OUT] res_size set to the size of the return value, or 0 on error + * @param[out] res_size set to the size of the return value, or 0 on error * @return NULL * if the inputs are invalid (i.e. denomination key not with this mint). * Otherwise, pointer to a buffer of @a res_size to store persistently - * before proceeding to #TALER_MINT_refresh_execute(). + * before proceeding to #TALER_MINT_refresh_melt(). * Non-null results should be freed using #GNUNET_free(). */ char * diff --git a/src/util/crypto.c b/src/util/crypto.c index edc30087..ebf6413d 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -171,7 +171,7 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecretP *secret_enc, * * @param coin_priv coin key * @param trans_priv transfer private key - * @param[out] computed transfer secret + * @param[out] ts computed transfer secret */ void TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin_priv, -- cgit v1.2.3 From 2da8705c9653729f6e46f7586c049db8cb280a4c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 15:46:29 +0200 Subject: doxygen --- src/include/taler_mint_service.h | 7 +++---- src/mint-lib/mint_api_context.h | 2 +- src/mint-lib/mint_api_json.h | 2 +- src/mint/taler-mint-httpd_responses.h | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index 68813306..02407a3a 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -188,7 +188,7 @@ struct TALER_MINT_DenomPublicKey /** - * Information we get from the mint about auditors. + * @brief Information we get from the mint about auditors. */ struct TALER_MINT_AuditorInformation { @@ -222,9 +222,8 @@ struct TALER_MINT_AuditorInformation }; - /** - * Information about keys from the mint. + * @brief Information about keys from the mint. */ struct TALER_MINT_Keys { @@ -466,7 +465,7 @@ enum TALER_MINT_ReserveTransactionType { /** - * Entry in the reserve's transaction history. + * @brief Entry in the reserve's transaction history. */ struct TALER_MINT_ReserveHistory { diff --git a/src/mint-lib/mint_api_context.h b/src/mint-lib/mint_api_context.h index c545a3fe..79613cc8 100644 --- a/src/mint-lib/mint_api_context.h +++ b/src/mint-lib/mint_api_context.h @@ -90,7 +90,7 @@ MAC_job_cancel (struct MAC_Job *job); /** - * Buffer data structure we use to buffer the HTTP download + * @brief Buffer data structure we use to buffer the HTTP download * before giving it to the JSON parser. */ struct MAC_DownloadBuffer diff --git a/src/mint-lib/mint_api_json.h b/src/mint-lib/mint_api_json.h index bca3b47c..2af5588e 100644 --- a/src/mint-lib/mint_api_json.h +++ b/src/mint-lib/mint_api_json.h @@ -97,7 +97,7 @@ enum MAJ_Command /** - * Entry in parser specification for #MAJ_parse_json. + * @brief Entry in parser specification for #MAJ_parse_json. */ struct MAJ_Specification { diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index 7afd0188..a3535638 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h @@ -350,7 +350,7 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, /** - * Information for each session a coin was melted into. + * @brief Information for each session a coin was melted into. */ struct TMH_RESPONSE_LinkSessionInfo { -- cgit v1.2.3 From e6ff049c203a8a5ab0d14a44bca3e2aae356d786 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 18:03:42 +0200 Subject: fix #3935 by removing error message: the test provokes this intentionally --- src/include/taler_mintdb_plugin.h | 7 ++----- src/mintdb/plugin_mintdb_postgres.c | 12 ++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index 21d83d9d..a7a73574 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -830,11 +830,8 @@ struct TALER_MINTDB_Plugin * @param sesssion database connection * @param deposit deposit to search for * @return #GNUNET_YES if we know this operation, - * #GNUNET_NO if this deposit is unknown to us, - * #GNUNET_SYSERR on DB error or if same coin(pub), merchant(pub) and - * transaction ID are already in DB, but for different - * other transaction details (contract, wiring details, - * amount, etc.) + * #GNUNET_NO if this exact deposit is unknown to us, + * #GNUNET_SYSERR on DB error */ int (*have_deposit) (void *cls, diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 16330e04..b0f378e4 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -1751,11 +1751,8 @@ postgres_get_reserve_history (void *cls, * @param session database connection * @param deposit deposit to search for * @return #GNUNET_YES if we know this operation, - * #GNUNET_NO if this deposit is unknown to us - * #GNUNET_SYSERR on DB error or if same coin(pub), merchant(pub) and - * transaction ID are already in DB, but for different - * other transaction details (contract, wiring details, - * amount, etc.) + * #GNUNET_NO if this exact deposit is unknown to us + * #GNUNET_SYSERR on DB error */ static int postgres_have_deposit (void *cls, @@ -1823,13 +1820,12 @@ postgres_have_deposit (void *cls, &deposit2.h_wire, sizeof (struct GNUNET_HashCode))) ) { - /* Inconsistencies detected! Bug in merchant! (We might want to + /* Inconsistencies detected! Does not match! (We might want to expand the API with a 'get_deposit' function to return the original transaction details to be used for an error message in the future!) #3838 */ - GNUNET_break_op (0); PQclear (result); - return GNUNET_SYSERR; + return GNUNET_NO; } } PQclear (result); -- cgit v1.2.3 From 3ead9d772a6850a7654e7e483ebfce5acac8da86 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 21:25:02 +0200 Subject: move struct TALER_MINTDB_RefreshCommitLinkP to taler_signatures.h --- src/include/taler_mintdb_plugin.h | 27 --------------------------- src/include/taler_signatures.h | 25 +++++++++++++++++++++++++ src/mint-lib/test_mint_api.c | 5 ++--- src/mint/taler-mint-httpd_refresh.c | 3 --- 4 files changed, 27 insertions(+), 33 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index a7a73574..ba83c814 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -388,33 +388,6 @@ struct TALER_MINTDB_RefreshCommitCoin }; -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief For each (old) coin being melted, we have a `struct - * RefreshCommitLinkP` that allows the user to find the shared secret - * to decrypt the respective refresh links for the new coins in the - * `struct TALER_MINTDB_RefreshCommitCoin`. - */ -struct TALER_MINTDB_RefreshCommitLinkP -{ - /** - * Transfer public key, used to decrypt the @e shared_secret_enc - * in combintation with the corresponding private key of the - * coin. - */ - struct TALER_TransferPublicKeyP transfer_pub; - - /** - * Encrypted shared secret to decrypt the link. - */ - struct TALER_EncryptedLinkSecretP shared_secret_enc; -}; - -GNUNET_NETWORK_STRUCT_END - - - /** * @brief Linked list of refresh information linked to a coin. */ diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 402e67fe..0b05bace 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -648,6 +648,31 @@ struct TALER_MintKeyValidityPS }; +/** + * @brief For each (old) coin being melted, we have a `struct + * RefreshCommitLinkP` that allows the user to find the shared secret + * to decrypt the respective refresh links for the new coins in the + * `struct TALER_MINTDB_RefreshCommitCoin`. + * + * Part of the construction of the refresh session's hash and + * thus of what is signed there. + */ +struct TALER_MINTDB_RefreshCommitLinkP +{ + /** + * Transfer public key, used to decrypt the @e shared_secret_enc + * in combintation with the corresponding private key of the + * coin. + */ + struct TALER_TransferPublicKeyP transfer_pub; + + /** + * Encrypted shared secret to decrypt the link. + */ + struct TALER_EncryptedLinkSecretP shared_secret_enc; +}; + + GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index fcc5db10..bae96dfb 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -1933,15 +1933,14 @@ run (void *cls, /* Melt the rest of the coin's value (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ -#if TEST_REFRESH - - { .oc = OC_REFRESH_MELT, .label = "refresh-melt-1", .expected_response_code = MHD_HTTP_OK, .details.refresh_melt.melted_coins = melt_coins_1, .details.refresh_melt.fresh_amounts = melt_fresh_amounts_1 }, +#if TEST_REFRESH + /* Complete (successful) melt operation, and withdraw the coins */ { .oc = OC_REFRESH_REVEAL, .label = "refresh-reveal-1", diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index eb205ed1..7bcaa799 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -252,9 +252,6 @@ verify_coin_public_info (struct MHD_Connection *connection, body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); body.session_hash = *session_hash; - fprintf (stderr, - "Verifying hash %s\n", - GNUNET_h2s (session_hash)); TALER_amount_hton (&body.amount_with_fee, &melt_detail->melt_amount_with_fee); -- cgit v1.2.3 From 6237981d9652889bbcc042e8b374c0addc65932f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 21:25:49 +0200 Subject: rename struct TALER_MINTDB_RefreshCommitLinkP to struct TALER_RefreshCommitLinkP --- src/include/taler_mintdb_plugin.h | 6 +++--- src/include/taler_signatures.h | 2 +- src/mint-lib/mint_api_refresh.c | 4 ++-- src/mint/taler-mint-httpd_db.c | 6 +++--- src/mint/taler-mint-httpd_db.h | 2 +- src/mint/taler-mint-httpd_refresh.c | 12 ++++++------ src/mint/taler-mint-httpd_responses.c | 2 +- src/mintdb/plugin_mintdb_postgres.c | 6 +++--- 8 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index ba83c814..c5b9828d 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -539,7 +539,7 @@ struct TALER_MINTDB_MeltCommitment /** * 2D-Array of #TALER_CNC_KAPPA and @e new_oldcoins links. */ - struct TALER_MINTDB_RefreshCommitLinkP *commit_links[TALER_CNC_KAPPA]; + struct TALER_RefreshCommitLinkP *commit_links[TALER_CNC_KAPPA]; }; @@ -1002,7 +1002,7 @@ struct TALER_MINTDB_Plugin const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - const struct TALER_MINTDB_RefreshCommitLinkP *commit_links); + const struct TALER_RefreshCommitLinkP *commit_links); /** * Obtain the commited (encrypted) refresh link data @@ -1024,7 +1024,7 @@ struct TALER_MINTDB_Plugin const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - struct TALER_MINTDB_RefreshCommitLinkP *links); + struct TALER_RefreshCommitLinkP *links); /** diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 0b05bace..c5348eb5 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -657,7 +657,7 @@ struct TALER_MintKeyValidityPS * Part of the construction of the refresh session's hash and * thus of what is signed there. */ -struct TALER_MINTDB_RefreshCommitLinkP +struct TALER_RefreshCommitLinkP { /** * Transfer public key, used to decrypt the @e shared_secret_enc diff --git a/src/mint-lib/mint_api_refresh.c b/src/mint-lib/mint_api_refresh.c index 796eb23f..66e8ea83 100644 --- a/src/mint-lib/mint_api_refresh.c +++ b/src/mint-lib/mint_api_refresh.c @@ -990,7 +990,7 @@ TALER_MINT_refresh_prepare (unsigned int num_melts, { for (j = 0; j < num_melts; j++) { - struct TALER_MINTDB_RefreshCommitLinkP rcl; + struct TALER_RefreshCommitLinkP rcl; struct TALER_TransferSecretP trans_sec; GNUNET_CRYPTO_ecdhe_key_get_public (&md.melted_coins[j].transfer_priv[i].ecdhe_priv, @@ -1003,7 +1003,7 @@ TALER_MINT_refresh_prepare (unsigned int num_melts, &rcl.shared_secret_enc); GNUNET_CRYPTO_hash_context_read (hash_context, &rcl, - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); } } diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index 4e91e7e7..e24102ea 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -623,7 +623,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, unsigned int coin_count, const struct TMH_DB_MeltDetails *coin_melt_details, struct TALER_MINTDB_RefreshCommitCoin *const* commit_coin, - struct TALER_MINTDB_RefreshCommitLinkP *const* commit_link) + struct TALER_RefreshCommitLinkP *const* commit_link) { struct TMH_KS_StateHandle *key_state; struct TALER_MINTDB_RefreshSession refresh_session; @@ -839,11 +839,11 @@ check_commitment (struct MHD_Connection *connection, unsigned int j; struct TALER_LinkSecretP last_shared_secret; int secret_initialized = GNUNET_NO; - struct TALER_MINTDB_RefreshCommitLinkP *commit_links; + struct TALER_RefreshCommitLinkP *commit_links; struct TALER_MINTDB_RefreshCommitCoin *commit_coins; commit_links = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); if (GNUNET_OK != TMH_plugin->get_refresh_commit_links (TMH_plugin->cls, session, diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h index 8a171153..c2f9a310 100644 --- a/src/mint/taler-mint-httpd_db.h +++ b/src/mint/taler-mint-httpd_db.h @@ -130,7 +130,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, unsigned int coin_count, const struct TMH_DB_MeltDetails *coin_melt_details, struct TALER_MINTDB_RefreshCommitCoin *const* commit_coin, - struct TALER_MINTDB_RefreshCommitLinkP *const* commit_link); + struct TALER_RefreshCommitLinkP *const* commit_link); /** diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 7bcaa799..954d8daf 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -57,7 +57,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, const struct TMH_DB_MeltDetails *coin_melt_details, const struct GNUNET_HashCode *session_hash, struct TALER_MINTDB_RefreshCommitCoin *const* commit_coin, - struct TALER_MINTDB_RefreshCommitLinkP *const* commit_link) + struct TALER_RefreshCommitLinkP *const* commit_link) { unsigned int i; struct TMH_KS_StateHandle *key_state; @@ -324,7 +324,7 @@ free_commit_coins (struct TALER_MINTDB_RefreshCommitCoin **commit_coin, * @param num_old_coins size of 2nd dimension */ static void -free_commit_links (struct TALER_MINTDB_RefreshCommitLinkP **commit_link, +free_commit_links (struct TALER_RefreshCommitLinkP **commit_link, unsigned int kappa, unsigned int num_old_coins) { @@ -378,7 +378,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, struct GNUNET_HashCode session_hash; struct GNUNET_HashContext *hash_context; struct TALER_MINTDB_RefreshCommitCoin *commit_coin[TALER_CNC_KAPPA]; - struct TALER_MINTDB_RefreshCommitLinkP *commit_link[TALER_CNC_KAPPA]; + struct TALER_RefreshCommitLinkP *commit_link[TALER_CNC_KAPPA]; /* For the signature check, we hash most of the inputs together (except for the signatures on the coins). */ @@ -532,10 +532,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection, for (i = 0; i < TALER_CNC_KAPPA; i++) { commit_link[i] = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); for (j = 0; j < num_oldcoins; j++) { - struct TALER_MINTDB_RefreshCommitLinkP *rcl = &commit_link[i][j]; + struct TALER_RefreshCommitLinkP *rcl = &commit_link[i][j]; res = TMH_PARSE_navigate_json (connection, transfer_pubs, @@ -582,7 +582,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, GNUNET_CRYPTO_hash_context_read (hash_context, rcl, - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); } } diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 0e2f9070..9a6813f1 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -900,7 +900,7 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, info_link_k = json_array (); for (i=0;inum_newcoins;i++) { - const struct TALER_MINTDB_RefreshCommitLinkP *cl; + const struct TALER_RefreshCommitLinkP *cl; json_t *cl_json; cl = &mc->commit_links[k][i]; diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 57455fcc..658d8dd9 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -2640,7 +2640,7 @@ postgres_insert_refresh_commit_links (void *cls, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - const struct TALER_MINTDB_RefreshCommitLinkP *links) + const struct TALER_RefreshCommitLinkP *links) { // FIXME: check logic! links is array! struct TALER_PQ_QueryParam params[] = { @@ -2693,7 +2693,7 @@ postgres_get_refresh_commit_links (void *cls, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - struct TALER_MINTDB_RefreshCommitLinkP *links) + struct TALER_RefreshCommitLinkP *links) { // FIXME: check logic: was written for a single link! struct TALER_PQ_QueryParam params[] = { @@ -2801,7 +2801,7 @@ postgres_get_melt_commitment (void *cls, goto cleanup; mc->commit_links[cnc_index] = GNUNET_malloc (mc->num_oldcoins * - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); if (GNUNET_OK != postgres_get_refresh_commit_links (cls, session, -- cgit v1.2.3