diff options
| -rw-r--r-- | contrib/depends/packages/openssl.mk | 6 | ||||
| -rw-r--r-- | src/cryptonote_basic/miner.cpp | 3 | ||||
| -rw-r--r-- | src/cryptonote_core/cryptonote_tx_utils.cpp | 3 | ||||
| -rw-r--r-- | src/net/zmq.cpp | 6 | ||||
| -rw-r--r-- | src/net/zmq.h | 2 | ||||
| -rw-r--r-- | src/rpc/zmq_server.cpp | 4 | ||||
| -rw-r--r-- | src/wallet/wallet2.cpp | 71 | ||||
| -rw-r--r-- | src/wallet/wallet2.h | 3 | ||||
| -rw-r--r-- | src/wallet/wallet_errors.h | 2 |
9 files changed, 66 insertions, 34 deletions
diff --git a/contrib/depends/packages/openssl.mk b/contrib/depends/packages/openssl.mk index 77d4b2d11..926b3b180 100644 --- a/contrib/depends/packages/openssl.mk +++ b/contrib/depends/packages/openssl.mk @@ -1,8 +1,8 @@ package=openssl -$(package)_version=3.0.19 -$(package)_download_path=https://www.openssl.org/source +$(package)_version=3.0.21 +$(package)_download_path=https://github.com/openssl/openssl/releases/download/openssl-$($(package)_version) $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=fa5a4143b8aae18be53ef2f3caf29a2e0747430b8bc74d32d88335b94ab63072 +$(package)_sha256_hash=617e29af8e421f46649484a4937e48c685e47f46488167c982f88bc4ec1d522f define $(package)_set_vars $(package)_config_env=AR="$($(package)_ar)" ARFLAGS=$($(package)_arflags) RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index 71b8f78cc..fd13ff74d 100644 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -578,7 +578,8 @@ namespace cryptonote if ((b.major_version >= RX_BLOCK_VERSION) && !rx_set) { - crypto::rx_set_miner_thread(th_local_index, tools::get_max_concurrency()); + // Must be non-zero value because 0 means "not a miner thread, run with secure JIT" in rx-slow-hash.c + crypto::rx_set_miner_thread(th_local_index + 1, tools::get_max_concurrency()); rx_set = true; } diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index c350e24c4..7aea5cf50 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -453,11 +453,12 @@ namespace cryptonote crypto::public_key out_eph_public_key; crypto::view_tag view_tag; - hwdev.generate_output_ephemeral_keys(tx.version,sender_account_keys, txkey_pub, tx_key, + const bool r = hwdev.generate_output_ephemeral_keys(tx.version,sender_account_keys, txkey_pub, tx_key, dst_entr, change_addr, output_index, need_additional_txkeys, additional_tx_keys, additional_tx_public_keys, amount_keys, out_eph_public_key, use_view_tags, view_tag); + CHECK_AND_ASSERT_MES(r, false, "Failed to generate output ephemeral keys"); tx_out out; cryptonote::set_tx_out(dst_entr.amount, out_eph_public_key, use_view_tags, view_tag, out); diff --git a/src/net/zmq.cpp b/src/net/zmq.cpp index 2b3ca8376..4a9d3e162 100644 --- a/src/net/zmq.cpp +++ b/src/net/zmq.cpp @@ -150,6 +150,12 @@ namespace zmq if ((last = zmq_msg_recv(part.handle(), socket, flags)) < 0) return last; + if (max_message_size < payload.size() || + max_message_size - payload.size() < part.size()) + { + errno = EMSGSIZE; + return -1; + } payload.append(part.data(), part.size()); if (!zmq_msg_more(part.handle())) break; diff --git a/src/net/zmq.h b/src/net/zmq.h index 18bb80c8b..68b6a71be 100644 --- a/src/net/zmq.h +++ b/src/net/zmq.h @@ -64,6 +64,8 @@ namespace net { namespace zmq { + constexpr std::size_t max_message_size = 10 * 1024 * 1024; // 10 MiB + //! \return Category for ZMQ errors. const std::error_category& error_category() noexcept; diff --git a/src/rpc/zmq_server.cpp b/src/rpc/zmq_server.cpp index 7ebb6c49f..3f1f38e21 100644 --- a/src/rpc/zmq_server.cpp +++ b/src/rpc/zmq_server.cpp @@ -46,7 +46,7 @@ namespace cryptonote namespace { constexpr const int num_zmq_threads = 1; - constexpr const std::int64_t max_message_size = 10 * 1024 * 1024; // 10 MiB + constexpr const std::int64_t max_frame_size = net::zmq::max_message_size; constexpr const std::chrono::seconds linger_timeout{2}; // wait period for pending out messages net::zmq::socket init_socket(void* context, int type, epee::span<const std::string> addresses) @@ -62,7 +62,7 @@ namespace return nullptr; } - if (zmq_setsockopt(out.get(), ZMQ_MAXMSGSIZE, std::addressof(max_message_size), sizeof(max_message_size)) != 0) + if (zmq_setsockopt(out.get(), ZMQ_MAXMSGSIZE, std::addressof(max_frame_size), sizeof(max_frame_size)) != 0) { MONERO_LOG_ZMQ_ERROR("Failed to set maximum incoming message size"); return nullptr; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 883e29225..8a74e711c 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -8155,14 +8155,6 @@ std::string wallet2::save_multisig_tx(multisig_tx_set txs) { LOG_PRINT_L0("saving " << txs.m_ptx.size() << " multisig transactions"); - // txes generated, get rid of used k values - for (size_t n = 0; n < txs.m_ptx.size(); ++n) - for (size_t idx: txs.m_ptx[n].construction_data.selected_transfers) - { - memwipe(m_transfers[idx].m_multisig_k.data(), m_transfers[idx].m_multisig_k.size() * sizeof(m_transfers[idx].m_multisig_k[0])); - m_transfers[idx].m_multisig_k.clear(); - } - // zero out some data we don't want to share for (auto &ptx: txs.m_ptx) { @@ -8190,6 +8182,11 @@ std::string wallet2::save_multisig_tx(multisig_tx_set txs) } LOG_PRINT_L2("Saving multisig unsigned tx data: " << oss.str()); std::string ciphertext = encrypt_with_view_secret_key(oss.str()); + + // The transaction creator has already signed, so do not expose the txset + // until the corresponding one-time nonce erasure is stored. + clear_multisig_k_and_store(txs); + return std::string(MULTISIG_UNSIGNED_TX_PREFIX) + ciphertext; } //---------------------------------------------------------------------------------------------------- @@ -8348,8 +8345,12 @@ bool wallet2::load_multisig_tx_from_file(const std::string &filename, multisig_t return true; } //---------------------------------------------------------------------------------------------------- -bool wallet2::sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids) +bool wallet2::sign_multisig_tx(multisig_tx_set &exported_txs_inout, std::vector<crypto::hash> &txids) { + multisig_tx_set exported_txs = exported_txs_inout; + std::vector<crypto::hash> signed_txids; + std::vector<std::pair<crypto::hash, size_t>> signed_tx_key_indices; + THROW_WALLET_EXCEPTION_IF(exported_txs.m_ptx.empty(), error::wallet_internal_error, "No tx found"); const crypto::public_key local_signer = get_multisig_signer_public_key(); @@ -8363,8 +8364,6 @@ bool wallet2::sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto THROW_WALLET_EXCEPTION_IF(frozen(exported_txs), error::wallet_internal_error, "Will not sign multisig tx containing frozen outputs") - txids.clear(); - // The 'exported_txs' contains a set of different transactions for the multisig group to try to sign. Each of those // transactions has a set of 'signing attempts' corresponding to all the possible signing groups within the multisig. // - Here, we will partially sign as many of those signing attempts as possible, for each proposed transaction. @@ -8474,25 +8473,26 @@ bool wallet2::sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto "Unable to finalize the transaction: the ignore sets for these tx attempts seem to be malformed."); const crypto::hash txid = get_transaction_hash(ptx.tx); if (store_tx_info()) - { - m_tx_keys[txid] = ptx.tx_key; - m_additional_tx_keys[txid] = ptx.additional_tx_keys; - } - txids.push_back(txid); + signed_tx_key_indices.emplace_back(txid, n); + signed_txids.push_back(txid); } } - // signatures generated, get rid of any unused k values (must do export_multisig() to make more tx attempts with the - // inputs in the transactions worked on here) - for (size_t n = 0; n < exported_txs.m_ptx.size(); ++n) - for (size_t idx: exported_txs.m_ptx[n].construction_data.selected_transfers) - { - memwipe(m_transfers[idx].m_multisig_k.data(), m_transfers[idx].m_multisig_k.size() * sizeof(m_transfers[idx].m_multisig_k[0])); - m_transfers[idx].m_multisig_k.clear(); - } + exported_txs.m_signers.insert(local_signer); - exported_txs.m_signers.insert(get_multisig_signer_public_key()); + // Do not expose signatures until all nonce material for the selected inputs + // has been erased from the wallet cache. + clear_multisig_k_and_store(exported_txs); + for (const auto &entry: signed_tx_key_indices) + { + const auto &ptx = exported_txs.m_ptx[entry.second]; + m_tx_keys[entry.first] = ptx.tx_key; + m_additional_tx_keys[entry.first] = ptx.additional_tx_keys; + } + + exported_txs_inout = std::move(exported_txs); + txids = std::move(signed_txids); return true; } //---------------------------------------------------------------------------------------------------- @@ -15225,6 +15225,27 @@ void wallet2::get_multisig_k(size_t idx, const std::unordered_set<rct::key> &use THROW_WALLET_EXCEPTION(tools::error::multisig_export_needed); } //---------------------------------------------------------------------------------------------------- +void wallet2::clear_multisig_k_and_store(const multisig_tx_set &txs) +{ + // Must succeed before any txset produced with these nonces is exposed. + bool changed = false; + for (const auto &ptx: txs.m_ptx) + { + for (size_t idx: ptx.construction_data.selected_transfers) + { + std::vector<rct::key> &multisig_k = m_transfers[idx].m_multisig_k; + if (multisig_k.empty()) + continue; + memwipe(multisig_k.data(), multisig_k.size() * sizeof(multisig_k[0])); + multisig_k.clear(); + changed = true; + } + } + + if (changed) + store(); +} +//---------------------------------------------------------------------------------------------------- rct::multisig_kLRki wallet2::get_multisig_kLRki(size_t n, const rct::key &k) const { CHECK_AND_ASSERT_THROW_MES(n < m_transfers.size(), "Bad m_transfers index"); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index cedfecbeb..074755002 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1211,7 +1211,7 @@ private: bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL); bool load_multisig_tx_from_file(const std::string &filename, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL); bool sign_multisig_tx_from_file(const std::string &filename, std::vector<crypto::hash> &txids, std::function<bool(const multisig_tx_set&)> accept_func); - bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids); + bool sign_multisig_tx(multisig_tx_set &exported_txs_inout, std::vector<crypto::hash> &txids); bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector<crypto::hash> &txids); std::vector<pending_tx> create_unmixable_sweep_transactions(); void discard_unmixable_outputs(); @@ -1908,6 +1908,7 @@ private: rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const std::unordered_set<crypto::public_key> &ignore_set, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const; rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const; void get_multisig_k(size_t idx, const std::unordered_set<rct::key> &used_L, rct::key &nonce); + void clear_multisig_k_and_store(const multisig_tx_set &txs); void update_multisig_rescan_info(const std::vector<std::vector<rct::key>> &multisig_k, const std::vector<std::vector<tools::wallet2::multisig_info>> &info, size_t n); bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx); bool add_rings(const cryptonote::transaction_prefix &tx); diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h index c54cd3499..e0a767159 100644 --- a/src/wallet/wallet_errors.h +++ b/src/wallet/wallet_errors.h @@ -440,7 +440,7 @@ namespace tools struct out_of_hashchain_bounds_error : public refresh_error { explicit out_of_hashchain_bounds_error(std::string&& loc) - : refresh_error(std::move(loc), "Index out of bounds of of hashchain") + : refresh_error(std::move(loc), "Index out of bounds of hashchain") { } |
