2018-03-22 09:54:16 +03:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
2018-11-11 22:33:31 -05:00
|
|
|
#include <chrono>
|
2018-03-22 09:54:16 +03:00
|
|
|
#include <cstdlib>
|
2018-11-11 22:33:31 -05:00
|
|
|
#include <ctime>
|
|
|
|
|
#include <functional>
|
2018-03-22 09:54:16 +03:00
|
|
|
#include <vector>
|
|
|
|
|
#include "common/logging/log.h"
|
2021-04-14 16:07:40 -07:00
|
|
|
#include "common/settings.h"
|
2018-03-22 09:54:16 +03:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
|
|
#include "core/hle/service/spl/csrng.h"
|
|
|
|
|
#include "core/hle/service/spl/module.h"
|
|
|
|
|
#include "core/hle/service/spl/spl.h"
|
|
|
|
|
|
2018-04-19 21:41:44 -04:00
|
|
|
namespace Service::SPL {
|
2018-03-22 09:54:16 +03:00
|
|
|
|
2020-11-26 15:19:08 -05:00
|
|
|
Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_,
|
|
|
|
|
const char* name)
|
|
|
|
|
: ServiceFramework{system_, name}, module{std::move(module_)},
|
2020-07-09 22:42:09 -04:00
|
|
|
rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))) {}
|
2018-03-22 09:54:16 +03:00
|
|
|
|
2018-09-10 21:20:52 -04:00
|
|
|
Module::Interface::~Interface() = default;
|
|
|
|
|
|
2021-06-15 02:36:52 -04:00
|
|
|
void Module::Interface::GetConfig(Kernel::HLERequestContext& ctx) {}
|
|
|
|
|
|
|
|
|
|
void Module::Interface::ModularExponentiate(Kernel::HLERequestContext& ctx) {}
|
|
|
|
|
|
|
|
|
|
void Module::Interface::SetConfig(Kernel::HLERequestContext& ctx) {}
|
|
|
|
|
|
|
|
|
|
void Module::Interface::GenerateRandomBytes(Kernel::HLERequestContext& ctx) {
|
2018-11-26 17:06:13 +11:00
|
|
|
LOG_DEBUG(Service_SPL, "called");
|
|
|
|
|
|
2019-04-04 12:56:04 -04:00
|
|
|
const std::size_t size = ctx.GetWriteBufferSize();
|
2018-03-22 09:54:16 +03:00
|
|
|
|
2018-11-15 18:44:22 -05:00
|
|
|
std::uniform_int_distribution<u16> distribution(0, std::numeric_limits<u8>::max());
|
2018-03-22 09:54:16 +03:00
|
|
|
std::vector<u8> data(size);
|
2018-11-15 18:44:22 -05:00
|
|
|
std::generate(data.begin(), data.end(), [&] { return static_cast<u8>(distribution(rng)); });
|
2018-03-22 09:54:16 +03:00
|
|
|
|
|
|
|
|
ctx.WriteBuffer(data);
|
|
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-03-22 09:54:16 +03:00
|
|
|
}
|
|
|
|
|
|
2021-06-15 02:36:52 -04:00
|
|
|
void Module::Interface::IsDevelopment(Kernel::HLERequestContext& ctx) {}
|
|
|
|
|
|
|
|
|
|
void Module::Interface::SetBootReason(Kernel::HLERequestContext& ctx) {}
|
|
|
|
|
|
|
|
|
|
void Module::Interface::GetBootReason(Kernel::HLERequestContext& ctx) {}
|
|
|
|
|
|
2020-11-26 15:19:08 -05:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
2018-03-22 09:54:16 +03:00
|
|
|
auto module = std::make_shared<Module>();
|
2020-11-26 15:19:08 -05:00
|
|
|
std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager);
|
|
|
|
|
std::make_shared<SPL>(system, module)->InstallAsService(service_manager);
|
2021-03-11 02:36:48 -05:00
|
|
|
std::make_shared<SPL_MIG>(system, module)->InstallAsService(service_manager);
|
|
|
|
|
std::make_shared<SPL_FS>(system, module)->InstallAsService(service_manager);
|
|
|
|
|
std::make_shared<SPL_SSL>(system, module)->InstallAsService(service_manager);
|
|
|
|
|
std::make_shared<SPL_ES>(system, module)->InstallAsService(service_manager);
|
|
|
|
|
std::make_shared<SPL_MANU>(system, module)->InstallAsService(service_manager);
|
2018-03-22 09:54:16 +03:00
|
|
|
}
|
|
|
|
|
|
2018-04-19 21:41:44 -04:00
|
|
|
} // namespace Service::SPL
|