-----BEGIN PGP SIGNATURE----- iQFJBAABCAAzFiEEh3erj3eO6JSHovjn9KygGDZB4BAFAmXrvy0VHGx1aWdpMTEx MXdAZ21haWwuY29tAAoJEPSsoBg2QeAQsjMH/AlPMeMlennNpTJ2jISL+lUNc/zK EpWZxf5dbtHeMKwfu0BDkrzAtvbKB1g38xqnq9nD6iAJ7lnD76IFZ6CrUQVfIr7W 5S7D0gYN4WkCWQML8gUYO9WKjFLVfy/IsUzEmup5eHI72yflYKjt/N9B/RCE3wbV C9uYaYhWQHHFTjtmxmMbmtFAJnH9R/D2O+13kfAKmEqM/u+JWoWEuVI/d1JWcJuc 77vW5D/alzfup7b33mRVvtFDIMAT5fAlSR9+h6aS9GzML4+VwV4ze31fa1nKwVOO pV/p2iDw9PYgGTJDQflzONKEIxqjw6deTDy6XTAllRqkjx+/8+RMYDC7Jjs= =2l3y -----END PGP SIGNATURE----- Merge tag 'v0.18.3.2' of https://github.com/monero-project/monero into release-v0.18.3.2 Fluorine Fermi # -----BEGIN PGP SIGNATURE----- # # iQFJBAABCAAzFiEEh3erj3eO6JSHovjn9KygGDZB4BAFAmXrvy0VHGx1aWdpMTEx # MXdAZ21haWwuY29tAAoJEPSsoBg2QeAQsjMH/AlPMeMlennNpTJ2jISL+lUNc/zK # EpWZxf5dbtHeMKwfu0BDkrzAtvbKB1g38xqnq9nD6iAJ7lnD76IFZ6CrUQVfIr7W # 5S7D0gYN4WkCWQML8gUYO9WKjFLVfy/IsUzEmup5eHI72yflYKjt/N9B/RCE3wbV # C9uYaYhWQHHFTjtmxmMbmtFAJnH9R/D2O+13kfAKmEqM/u+JWoWEuVI/d1JWcJuc # 77vW5D/alzfup7b33mRVvtFDIMAT5fAlSR9+h6aS9GzML4+VwV4ze31fa1nKwVOO # pV/p2iDw9PYgGTJDQflzONKEIxqjw6deTDy6XTAllRqkjx+/8+RMYDC7Jjs= # =2l3y # -----END PGP SIGNATURE----- # Conflicts: # src/wallet/wallet2.cpp # src/wallet/wallet2.hpull/9247/head
commit
37a860a1fa
@ -1 +1 @@
|
||||
Subproject commit bff7fdfe436c727982cc553bdfb29a9021b423b0
|
||||
Subproject commit 6405ac6e2708938ffd863129e187879bf74d22f3
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2023-2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "common/util.h"
|
||||
|
||||
TEST(LocalAddress, localhost) { ASSERT_TRUE(tools::is_local_address("localhost")); }
|
||||
TEST(LocalAddress, localhost_port) { ASSERT_TRUE(tools::is_local_address("localhost:18081")); }
|
||||
TEST(LocalAddress, localhost_suffix) { ASSERT_TRUE(tools::is_local_address("test.localhost")); }
|
||||
TEST(LocalAddress, loopback) { ASSERT_TRUE(tools::is_local_address("127.0.0.1")); }
|
||||
TEST(LocalAddress, loopback_port) { ASSERT_TRUE(tools::is_local_address("127.0.0.1:18081")); }
|
||||
TEST(LocalAddress, loopback_protocol) { ASSERT_TRUE(tools::is_local_address("http://127.0.0.1")); }
|
||||
TEST(LocalAddress, loopback_hi) { ASSERT_TRUE(tools::is_local_address("127.255.255.255")); }
|
||||
TEST(LocalAddress, loopback_lo) { ASSERT_TRUE(tools::is_local_address("127.0.0.0")); }
|
||||
TEST(LocalAddress, loopback_ipv6) { ASSERT_TRUE(tools::is_local_address("[0:0:0:0:0:0:0:1]")); }
|
||||
|
||||
TEST(LocalAddress, onion) { ASSERT_FALSE(tools::is_local_address("vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion")); }
|
||||
TEST(LocalAddress, i2p) { ASSERT_FALSE(tools::is_local_address("xmrto2bturnore26xmrto2bturnore26xmrto2bturnore26xmr2.b32.i2p")); }
|
||||
TEST(LocalAddress, valid_ip) { ASSERT_FALSE(tools::is_local_address("1.2.3.4")); }
|
||||
TEST(LocalAddress, valid_ipv6) { ASSERT_FALSE(tools::is_local_address("[0:0:0:0:0:0:0:2]")); }
|
||||
TEST(LocalAddress, valid_domain) { ASSERT_FALSE(tools::is_local_address("getmonero.org")); }
|
||||
TEST(LocalAddress, local_prefix) { ASSERT_FALSE(tools::is_local_address("localhost.com")); }
|
||||
TEST(LocalAddress, invalid) { ASSERT_FALSE(tools::is_local_address("test")); }
|
||||
TEST(LocalAddress, empty) { ASSERT_FALSE(tools::is_local_address("")); }
|
@ -0,0 +1,266 @@
|
||||
// Copyright (c) 2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "unit_tests_utils.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "file_io_utils.h"
|
||||
#include "wallet/wallet2.h"
|
||||
|
||||
using namespace boost::filesystem;
|
||||
using namespace epee::file_io_utils;
|
||||
|
||||
static constexpr const char WALLET_00fd416a_PRIMARY_ADDRESS[] =
|
||||
"45p2SngJAPSJbqSiUvYfS3BfhEdxZmv8pDt25oW1LzxrZv9Uq6ARagiFViMGUE3gJk5VPWingCXVf1p2tyAy6SUeSHPhbve";
|
||||
|
||||
TEST(wallet_storage, store_to_file2file)
|
||||
{
|
||||
const path source_wallet_file = unit_test::data_dir / "wallet_00fd416a";
|
||||
const path interm_wallet_file = unit_test::data_dir / "wallet_00fd416a_copy_file2file";
|
||||
const path target_wallet_file = unit_test::data_dir / "wallet_00fd416a_new_file2file";
|
||||
|
||||
ASSERT_TRUE(is_file_exist(source_wallet_file.string()));
|
||||
ASSERT_TRUE(is_file_exist(source_wallet_file.string() + ".keys"));
|
||||
|
||||
copy_file(source_wallet_file, interm_wallet_file, copy_option::overwrite_if_exists);
|
||||
copy_file(source_wallet_file.string() + ".keys", interm_wallet_file.string() + ".keys", copy_option::overwrite_if_exists);
|
||||
|
||||
ASSERT_TRUE(is_file_exist(interm_wallet_file.string()));
|
||||
ASSERT_TRUE(is_file_exist(interm_wallet_file.string() + ".keys"));
|
||||
|
||||
if (is_file_exist(target_wallet_file.string()))
|
||||
remove(target_wallet_file);
|
||||
if (is_file_exist(target_wallet_file.string() + ".keys"))
|
||||
remove(target_wallet_file.string() + ".keys");
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string()));
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
|
||||
epee::wipeable_string password("beepbeep");
|
||||
|
||||
const auto files_are_expected = [&]()
|
||||
{
|
||||
EXPECT_FALSE(is_file_exist(interm_wallet_file.string()));
|
||||
EXPECT_FALSE(is_file_exist(interm_wallet_file.string() + ".keys"));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string()));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
};
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(interm_wallet_file.string(), password);
|
||||
const std::string primary_address = w.get_address_as_str();
|
||||
EXPECT_EQ(WALLET_00fd416a_PRIMARY_ADDRESS, primary_address);
|
||||
w.store_to(target_wallet_file.string(), password);
|
||||
files_are_expected();
|
||||
}
|
||||
|
||||
files_are_expected();
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(target_wallet_file.string(), password);
|
||||
const std::string primary_address = w.get_address_as_str();
|
||||
EXPECT_EQ(WALLET_00fd416a_PRIMARY_ADDRESS, primary_address);
|
||||
w.store_to("", "");
|
||||
files_are_expected();
|
||||
}
|
||||
|
||||
files_are_expected();
|
||||
}
|
||||
|
||||
TEST(wallet_storage, store_to_mem2file)
|
||||
{
|
||||
const path target_wallet_file = unit_test::data_dir / "wallet_mem2file";
|
||||
|
||||
if (is_file_exist(target_wallet_file.string()))
|
||||
remove(target_wallet_file);
|
||||
if (is_file_exist(target_wallet_file.string() + ".keys"))
|
||||
remove(target_wallet_file.string() + ".keys");
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string()));
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
|
||||
epee::wipeable_string password("beepbeep2");
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.generate("", password);
|
||||
w.store_to(target_wallet_file.string(), password);
|
||||
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string()));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
}
|
||||
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string()));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(target_wallet_file.string(), password);
|
||||
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string()));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
}
|
||||
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string()));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
}
|
||||
|
||||
TEST(wallet_storage, change_password_same_file)
|
||||
{
|
||||
const path source_wallet_file = unit_test::data_dir / "wallet_00fd416a";
|
||||
const path interm_wallet_file = unit_test::data_dir / "wallet_00fd416a_copy_change_password_same";
|
||||
|
||||
ASSERT_TRUE(is_file_exist(source_wallet_file.string()));
|
||||
ASSERT_TRUE(is_file_exist(source_wallet_file.string() + ".keys"));
|
||||
|
||||
copy_file(source_wallet_file, interm_wallet_file, copy_option::overwrite_if_exists);
|
||||
copy_file(source_wallet_file.string() + ".keys", interm_wallet_file.string() + ".keys", copy_option::overwrite_if_exists);
|
||||
|
||||
ASSERT_TRUE(is_file_exist(interm_wallet_file.string()));
|
||||
ASSERT_TRUE(is_file_exist(interm_wallet_file.string() + ".keys"));
|
||||
|
||||
epee::wipeable_string old_password("beepbeep");
|
||||
epee::wipeable_string new_password("meepmeep");
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(interm_wallet_file.string(), old_password);
|
||||
const std::string primary_address = w.get_address_as_str();
|
||||
EXPECT_EQ(WALLET_00fd416a_PRIMARY_ADDRESS, primary_address);
|
||||
w.change_password(w.get_wallet_file(), old_password, new_password);
|
||||
}
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(interm_wallet_file.string(), new_password);
|
||||
const std::string primary_address = w.get_address_as_str();
|
||||
EXPECT_EQ(WALLET_00fd416a_PRIMARY_ADDRESS, primary_address);
|
||||
}
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
EXPECT_THROW(w.load(interm_wallet_file.string(), old_password), tools::error::invalid_password);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(wallet_storage, change_password_different_file)
|
||||
{
|
||||
const path source_wallet_file = unit_test::data_dir / "wallet_00fd416a";
|
||||
const path interm_wallet_file = unit_test::data_dir / "wallet_00fd416a_copy_change_password_diff";
|
||||
const path target_wallet_file = unit_test::data_dir / "wallet_00fd416a_new_change_password_diff";
|
||||
|
||||
ASSERT_TRUE(is_file_exist(source_wallet_file.string()));
|
||||
ASSERT_TRUE(is_file_exist(source_wallet_file.string() + ".keys"));
|
||||
|
||||
copy_file(source_wallet_file, interm_wallet_file, copy_option::overwrite_if_exists);
|
||||
copy_file(source_wallet_file.string() + ".keys", interm_wallet_file.string() + ".keys", copy_option::overwrite_if_exists);
|
||||
|
||||
ASSERT_TRUE(is_file_exist(interm_wallet_file.string()));
|
||||
ASSERT_TRUE(is_file_exist(interm_wallet_file.string() + ".keys"));
|
||||
|
||||
if (is_file_exist(target_wallet_file.string()))
|
||||
remove(target_wallet_file);
|
||||
if (is_file_exist(target_wallet_file.string() + ".keys"))
|
||||
remove(target_wallet_file.string() + ".keys");
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string()));
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
|
||||
epee::wipeable_string old_password("beepbeep");
|
||||
epee::wipeable_string new_password("meepmeep");
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(interm_wallet_file.string(), old_password);
|
||||
const std::string primary_address = w.get_address_as_str();
|
||||
EXPECT_EQ(WALLET_00fd416a_PRIMARY_ADDRESS, primary_address);
|
||||
w.change_password(target_wallet_file.string(), old_password, new_password);
|
||||
}
|
||||
|
||||
EXPECT_FALSE(is_file_exist(interm_wallet_file.string()));
|
||||
EXPECT_FALSE(is_file_exist(interm_wallet_file.string() + ".keys"));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string()));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(target_wallet_file.string(), new_password);
|
||||
const std::string primary_address = w.get_address_as_str();
|
||||
EXPECT_EQ(WALLET_00fd416a_PRIMARY_ADDRESS, primary_address);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(wallet_storage, change_password_in_memory)
|
||||
{
|
||||
const epee::wipeable_string password1("monero");
|
||||
const epee::wipeable_string password2("means money");
|
||||
const epee::wipeable_string password_wrong("is traceable");
|
||||
|
||||
tools::wallet2 w;
|
||||
w.generate("", password1);
|
||||
const std::string primary_address_1 = w.get_address_as_str();
|
||||
w.change_password("", password1, password2);
|
||||
const std::string primary_address_2 = w.get_address_as_str();
|
||||
EXPECT_EQ(primary_address_1, primary_address_2);
|
||||
|
||||
EXPECT_THROW(w.change_password("", password_wrong, password1), tools::error::invalid_password);
|
||||
}
|
||||
|
||||
TEST(wallet_storage, change_password_mem2file)
|
||||
{
|
||||
const path target_wallet_file = unit_test::data_dir / "wallet_change_password_mem2file";
|
||||
|
||||
if (is_file_exist(target_wallet_file.string()))
|
||||
remove(target_wallet_file);
|
||||
if (is_file_exist(target_wallet_file.string() + ".keys"))
|
||||
remove(target_wallet_file.string() + ".keys");
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string()));
|
||||
ASSERT_FALSE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
|
||||
const epee::wipeable_string password1("https://safecurves.cr.yp.to/rigid.html");
|
||||
const epee::wipeable_string password2(
|
||||
"https://csrc.nist.gov/csrc/media/projects/crypto-standards-development-process/documents/dualec_in_x982_and_sp800-90.pdf");
|
||||
|
||||
std::string primary_address_1, primary_address_2;
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.generate("", password1);
|
||||
primary_address_1 = w.get_address_as_str();
|
||||
w.change_password(target_wallet_file.string(), password1, password2);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string()));
|
||||
EXPECT_TRUE(is_file_exist(target_wallet_file.string() + ".keys"));
|
||||
|
||||
{
|
||||
tools::wallet2 w;
|
||||
w.load(target_wallet_file.string(), password2);
|
||||
primary_address_2 = w.get_address_as_str();
|
||||
}
|
||||
|
||||
EXPECT_EQ(primary_address_1, primary_address_2);
|
||||
}
|
Loading…
Reference in new issue