AI guid changes
This commit is contained in:
parent
5ba6c25c6b
commit
f772604bb2
@ -33,20 +33,13 @@ namespace auth
|
||||
|
||||
std::string get_hw_profile_guid()
|
||||
{
|
||||
auto hw_profile_path = (utils::properties::get_appdata_path() / "iw7-guid.dat").generic_string();
|
||||
if (utils::io::file_exists(hw_profile_path))
|
||||
{
|
||||
utils::io::remove_file(hw_profile_path);
|
||||
}
|
||||
|
||||
HW_PROFILE_INFO info;
|
||||
HW_PROFILE_INFO info{};
|
||||
if (!GetCurrentHwProfileA(&info))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto hw_profile_info = std::string{ info.szHwProfileGuid, sizeof(info.szHwProfileGuid) };
|
||||
return hw_profile_info;
|
||||
return std::string{ info.szHwProfileGuid, std::strlen(info.szHwProfileGuid) };
|
||||
}
|
||||
|
||||
std::string get_protected_data()
|
||||
@ -70,28 +63,29 @@ namespace auth
|
||||
|
||||
std::string get_key_entropy()
|
||||
{
|
||||
std::string entropy{};
|
||||
entropy.append(utils::smbios::get_uuid());
|
||||
entropy.append(get_hw_profile_guid());
|
||||
entropy.append(get_protected_data());
|
||||
entropy.append(get_hdd_serial());
|
||||
std::string raw_entropy;
|
||||
raw_entropy.append(utils::smbios::get_uuid());
|
||||
raw_entropy.append(get_hw_profile_guid());
|
||||
raw_entropy.append(get_protected_data());
|
||||
raw_entropy.append(get_hdd_serial());
|
||||
|
||||
if (entropy.empty())
|
||||
if (raw_entropy.empty())
|
||||
{
|
||||
entropy.resize(32);
|
||||
utils::cryptography::random::get_data(entropy.data(), entropy.size());
|
||||
raw_entropy.resize(32);
|
||||
utils::cryptography::random::get_data(raw_entropy.data(), raw_entropy.size());
|
||||
}
|
||||
|
||||
return entropy;
|
||||
return utils::cryptography::sha256::compute(raw_entropy);
|
||||
}
|
||||
|
||||
bool load_key(utils::cryptography::ecc::key& key)
|
||||
{
|
||||
std::string data{};
|
||||
const auto key_path = (utils::properties::get_appdata_path() / "iw7-private.key").generic_string();
|
||||
|
||||
auto key_path = (utils::properties::get_appdata_path() / "iw7-private.key").generic_string();
|
||||
if (!utils::io::read_file(key_path, &data))
|
||||
{
|
||||
console::warn("Private key file not found at: %s\n", key_path.data());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -113,10 +107,10 @@ namespace auth
|
||||
throw std::runtime_error("Failed to generate cryptographic key!");
|
||||
}
|
||||
|
||||
auto key_path = (utils::properties::get_appdata_path() / "iw7-private.key").generic_string();
|
||||
const auto key_path = (utils::properties::get_appdata_path() / "iw7-private.key").generic_string();
|
||||
if (!utils::io::write_file(key_path, key.serialize()))
|
||||
{
|
||||
console::error("Failed to write cryptographic key!\n");
|
||||
console::error("Failed to write cryptographic key to: %s\n", key_path.data());
|
||||
}
|
||||
|
||||
console::info("Generated cryptographic key: %llX\n", key.get_hash());
|
||||
@ -137,12 +131,12 @@ namespace auth
|
||||
|
||||
utils::cryptography::ecc::key get_key_internal()
|
||||
{
|
||||
auto key = load_or_generate_key();
|
||||
const auto key = load_or_generate_key();
|
||||
const auto key_path = (utils::properties::get_appdata_path() / "iw7-public.key").generic_string();
|
||||
|
||||
auto key_path = (utils::properties::get_appdata_path() / "iw7-public.key").generic_string();
|
||||
if (!utils::io::write_file(key_path, key.get_public_key()))
|
||||
{
|
||||
console::error("Failed to write public key!\n");
|
||||
console::error("Failed to write public key to: %s\n", key_path.data());
|
||||
}
|
||||
|
||||
return key;
|
||||
@ -150,7 +144,14 @@ namespace auth
|
||||
|
||||
utils::cryptography::ecc::key& get_key()
|
||||
{
|
||||
static auto key = get_key_internal();
|
||||
static std::once_flag init_flag;
|
||||
static utils::cryptography::ecc::key key{};
|
||||
|
||||
std::call_once(init_flag, []()
|
||||
{
|
||||
key = get_key_internal();
|
||||
});
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
@ -159,7 +160,8 @@ namespace auth
|
||||
{
|
||||
if (game::environment::is_dedi())
|
||||
{
|
||||
return 0x110000100000000 | (::utils::cryptography::random::get_integer() & ~0x80000000);
|
||||
static uint64_t session_guid = 0x110000100000000 | (::utils::cryptography::random::get_integer() & ~0x80000000);
|
||||
return session_guid;
|
||||
}
|
||||
|
||||
return get_key().get_hash();
|
||||
|
Loading…
x
Reference in New Issue
Block a user