network: check Console ID conflicts
As Console ID can be sensitive data sometimes, this implementation sent a SHA256 hash of it instead.
This commit is contained in:
parent
3c589f473f
commit
c396e3c6e5
14 changed files with 109 additions and 23 deletions
|
@ -734,4 +734,21 @@ void InstallInterfaces(Core::System& system) {
|
|||
std::make_shared<CFG_NOR>()->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
std::string GetConsoleIdHash(Core::System& system) {
|
||||
u64_le console_id{};
|
||||
std::array<u8, sizeof(console_id)> buffer;
|
||||
if (system.IsPoweredOn()) {
|
||||
auto cfg = GetModule(system);
|
||||
ASSERT_MSG(cfg, "CFG Module missing!");
|
||||
console_id = cfg->GetConsoleUniqueId();
|
||||
} else {
|
||||
console_id = std::make_unique<Service::CFG::Module>()->GetConsoleUniqueId();
|
||||
}
|
||||
std::memcpy(buffer.data(), &console_id, sizeof(console_id));
|
||||
|
||||
std::array<u8, CryptoPP::SHA256::DIGESTSIZE> hash;
|
||||
CryptoPP::SHA256().CalculateDigest(hash.data(), buffer.data(), sizeof(buffer));
|
||||
return fmt::format("{:02x}", fmt::join(hash.begin(), hash.end(), ""));
|
||||
}
|
||||
|
||||
} // namespace Service::CFG
|
||||
|
|
|
@ -415,4 +415,7 @@ std::shared_ptr<Module> GetModule(Core::System& system);
|
|||
|
||||
void InstallInterfaces(Core::System& system);
|
||||
|
||||
/// Convenience function for getting a SHA256 hash of the Console ID
|
||||
std::string GetConsoleIdHash(Core::System& system);
|
||||
|
||||
} // namespace Service::CFG
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue