diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/taler_signatures.h | 2 | ||||
-rw-r--r-- | src/include/taler_util.h | 11 | ||||
-rw-r--r-- | src/lib/exchange_api_common.c | 6 | ||||
-rw-r--r-- | src/lib/exchange_api_deposit.c | 7 | ||||
-rw-r--r-- | src/lib/exchange_api_kyc_check.c | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_link.c | 32 | ||||
-rw-r--r-- | src/lib/exchange_api_management_get_keys.c | 31 | ||||
-rw-r--r-- | src/lib/exchange_api_management_revoke_denomination_key.c | 2 | ||||
-rw-r--r-- | src/util/payto.c | 10 |
9 files changed, 61 insertions, 44 deletions
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 34d133807..6293a2577 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -1677,7 +1677,7 @@ struct TALER_ReserveCloseConfirmationPS /** * Hash of the receiver's bank account. */ - struct TALER_PaytoHash h_wire; + struct TALER_PaytoHash h_payto; /** * Wire transfer subject. diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 4faa75c4f..d62882b4c 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -328,6 +328,17 @@ TALER_payto_get_method (const char *payto_uri); /** + * Compute the hash of a payto URI. + * + * @param payto URI to hash + * @param[out] h_payto where to write the hash + */ +void +TALER_payto_hash (const char *payto, + struct TALER_PaytoHash *h_payto); + + +/** * Obtain the account name from a payto URL. * * @param payto an x-taler-bank payto URL diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 143ceddae..1cb11f1be 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -340,10 +340,8 @@ TALER_EXCHANGE_parse_reserve_history ( } TALER_amount_hton (&rcc.closing_amount, &amount); - GNUNET_CRYPTO_hash ( - rh->details.close_details.receiver_account_details, - strlen (rh->details.close_details.receiver_account_details) + 1, - &rcc.h_wire); + TALER_payto_hash (rh->details.close_details.receiver_account_details, + &rcc.h_payto); rcc.wtid = rh->details.close_details.wtid; rcc.purpose.size = htonl (sizeof (rcc)); rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED); diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index 461a282cf..e8fe5faf6 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c @@ -502,6 +502,7 @@ TALER_EXCHANGE_deposit_permission_sign ( const struct TALER_Amount *deposit_fee, const struct TALER_MerchantWireHash *h_wire, const struct TALER_PrivateContractHash *h_contract_terms, + const struct TALER_ExtensionContractHash *h_extensions, const struct TALER_DenominationHash *h_denom_pub, const struct TALER_CoinSpendPrivateKeyP *coin_priv, struct GNUNET_TIME_Absolute wallet_timestamp, @@ -520,6 +521,7 @@ TALER_EXCHANGE_deposit_permission_sign ( .merchant = *merchant_pub }; + // FIXME: sign also over h_extensions! GNUNET_assert (GNUNET_OK == GNUNET_TIME_round_abs (&wallet_timestamp)); GNUNET_assert (GNUNET_OK == @@ -541,8 +543,9 @@ TALER_EXCHANGE_deposit ( struct TALER_EXCHANGE_Handle *exchange, const struct TALER_Amount *amount, struct GNUNET_TIME_Absolute wire_deadline, - json_t *wire_details, + const json_t *wire_details, const struct TALER_PrivateContractHash *h_contract_terms, + const json_t *extension_details, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_DenominationSignature *denom_sig, const struct TALER_DenominationPublicKey *denom_pub, @@ -642,7 +645,7 @@ TALER_EXCHANGE_deposit ( TALER_JSON_pack_amount ("contribution", amount), GNUNET_JSON_pack_object_incref ("wire", - wire_details), + (json_t *) wire_details), GNUNET_JSON_pack_data_auto ("h_wire", &h_wire), GNUNET_JSON_pack_data_auto ("h_contract_terms", diff --git a/src/lib/exchange_api_kyc_check.c b/src/lib/exchange_api_kyc_check.c index 82fddd455..f64dfe4ea 100644 --- a/src/lib/exchange_api_kyc_check.c +++ b/src/lib/exchange_api_kyc_check.c @@ -64,7 +64,7 @@ struct TALER_EXCHANGE_KycCheckHandle /** * Hash of the payto:// URL that is being KYC'ed. */ - struct GNUNET_HashCode h_payto; + struct TALER_PaytoHash h_payto; }; @@ -216,7 +216,7 @@ handle_kyc_check_finished (void *cls, struct TALER_EXCHANGE_KycCheckHandle * TALER_EXCHANGE_kyc_check (struct TALER_EXCHANGE_Handle *exchange, uint64_t payment_target, - const struct GNUNET_HashCode *h_payto, + const struct TALER_PaytoHash *h_payto, struct GNUNET_TIME_Relative timeout, TALER_EXCHANGE_KycStatusCallback cb, void *cb_cls) diff --git a/src/lib/exchange_api_link.c b/src/lib/exchange_api_link.c index ceb318841..e36ffcd93 100644 --- a/src/lib/exchange_api_link.c +++ b/src/lib/exchange_api_link.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -92,12 +92,15 @@ parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh, struct TALER_DenominationPublicKey *pub) { struct GNUNET_CRYPTO_RsaSignature *bsig; - struct GNUNET_CRYPTO_RsaPublicKey *rpub; + struct TALER_DenominationPublicKey rpub; struct TALER_CoinSpendSignatureP link_sig; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_rsa_public_key ("denom_pub", &rpub), - GNUNET_JSON_spec_rsa_signature ("ev_sig", &bsig), - GNUNET_JSON_spec_fixed_auto ("link_sig", &link_sig), + TALER_JSON_spec_denomination_public_key ("denom_pub", + &rpub), + GNUNET_JSON_spec_rsa_signature ("ev_sig", + &bsig), + GNUNET_JSON_spec_fixed_auto ("link_sig", + &link_sig), GNUNET_JSON_spec_end () }; struct TALER_TransferSecretP secret; @@ -121,21 +124,21 @@ parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh, /* extract coin and signature */ *coin_priv = fc.coin_priv; - sig->rsa_signature + sig->cipher = TALER_DENOMINATION_RSA; + sig->details.rsa_signature = TALER_rsa_unblind (bsig, &fc.blinding_key.bks, - rpub); + rpub.details.rsa_public_key); /* verify link_sig */ { struct TALER_PlanchetDetail pd; - struct GNUNET_HashCode c_hash; + struct TALER_CoinPubHash c_hash; struct TALER_CoinSpendPublicKeyP old_coin_pub; GNUNET_CRYPTO_eddsa_key_get_public (&lh->coin_priv.eddsa_priv, &old_coin_pub.eddsa_pub); - pub->rsa_public_key = rpub; if (GNUNET_OK != - TALER_planchet_prepare (pub, + TALER_planchet_prepare (&rpub, &fc, &c_hash, &pd)) @@ -161,7 +164,8 @@ parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh, } /* clean up */ - pub->rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (rpub); + TALER_denom_pub_deep_copy (pub, + &rpub); GNUNET_JSON_parse_free (spec); return GNUNET_OK; } @@ -323,10 +327,8 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh, GNUNET_assert (off_coin <= num_coins); for (i = 0; i<off_coin; i++) { - if (NULL != sigs[i].rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (sigs[i].rsa_signature); - if (NULL != pubs[i].rsa_public_key) - GNUNET_CRYPTO_rsa_public_key_free (pubs[i].rsa_public_key); + TALER_denom_sig_free (&sigs[i]); + TALER_denom_pub_free (&pubs[i]); } } return ret; diff --git a/src/lib/exchange_api_management_get_keys.c b/src/lib/exchange_api_management_get_keys.c index e9cab5810..a3e3eccce 100644 --- a/src/lib/exchange_api_management_get_keys.c +++ b/src/lib/exchange_api_management_get_keys.c @@ -179,8 +179,8 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh, &denom_key->expire_deposit), TALER_JSON_spec_absolute_time ("stamp_expire_legal", &denom_key->expire_legal), - GNUNET_JSON_spec_rsa_public_key ("denom_pub", - &denom_key->key.rsa_public_key), + TALER_JSON_spec_denomination_public_key ("denom_pub", + &denom_key->key), TALER_JSON_spec_amount_any ("fee_withdraw", &denom_key->fee_withdraw), TALER_JSON_spec_amount_any ("fee_deposit", @@ -212,20 +212,20 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh, } { + struct TALER_DenominationHash h_denom_pub; struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference (denom_key->valid_from, denom_key->withdraw_valid_until); - struct GNUNET_HashCode h_denom_pub; - GNUNET_CRYPTO_rsa_public_key_hash (denom_key->key.rsa_public_key, - &h_denom_pub); + TALER_denom_pub_hash (&denom_key->key, + &h_denom_pub); if (GNUNET_OK != - TALER_exchange_secmod_rsa_verify (&h_denom_pub, - section_name, - denom_key->valid_from, - duration, - &fk.denom_secmod_public_key, - &denom_key->denom_secmod_sig)) + TALER_exchange_secmod_denom_verify (&h_denom_pub, + section_name, + denom_key->valid_from, + duration, + &fk.denom_secmod_public_key, + &denom_key->denom_secmod_sig)) { GNUNET_break_op (0); ok = false; @@ -246,14 +246,7 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh, &fk); } for (unsigned int i = 0; i<fk.num_denom_keys; i++) - { - if (NULL != fk.denom_keys[i].key.rsa_public_key) - { - GNUNET_CRYPTO_rsa_public_key_free ( - fk.denom_keys[i].key.rsa_public_key); - fk.denom_keys[i].key.rsa_public_key = NULL; - } - } + TALER_denom_pub_free (&fk.denom_keys[i].key); GNUNET_free (fk.sign_keys); GNUNET_free (fk.denom_keys); GNUNET_JSON_parse_free (spec); diff --git a/src/lib/exchange_api_management_revoke_denomination_key.c b/src/lib/exchange_api_management_revoke_denomination_key.c index b9e2a556a..4a1a79d03 100644 --- a/src/lib/exchange_api_management_revoke_denomination_key.c +++ b/src/lib/exchange_api_management_revoke_denomination_key.c @@ -125,7 +125,7 @@ struct TALER_EXCHANGE_ManagementRevokeDenominationKeyHandle * TALER_EXCHANGE_management_revoke_denomination_key ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct GNUNET_HashCode *h_denom_pub, + const struct TALER_DenominationHash *h_denom_pub, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementRevokeDenominationKeyCallback cb, void *cb_cls) diff --git a/src/util/payto.c b/src/util/payto.c index 58f1bf635..26872f1ee 100644 --- a/src/util/payto.c +++ b/src/util/payto.c @@ -254,3 +254,13 @@ TALER_payto_validate (const char *payto_uri) return NULL; } + + +void +TALER_payto_hash (const char *payto, + struct TALER_PaytoHash *h_payto) +{ + GNUNET_CRYPTO_hash (payto, + strlen (payto) + 1, + &h_payto->hash); +} |