mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-23 17:00:57 +01:00
spl: Add the general SPL interface
This commit is contained in:
parent
faf11fe46d
commit
ded36b8688
4 changed files with 64 additions and 45 deletions
|
@ -9,7 +9,7 @@ namespace Service::SPL {
|
||||||
CSRNG::CSRNG(Core::System& system_, std::shared_ptr<Module> module_)
|
CSRNG::CSRNG(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
: Interface(system_, std::move(module_), "csrng") {
|
: Interface(system_, std::move(module_), "csrng") {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &CSRNG::GetRandomBytes, "GetRandomBytes"},
|
{0, &CSRNG::GenerateRandomBytes, "GenerateRandomBytes"},
|
||||||
};
|
};
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,13 @@ Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> modu
|
||||||
|
|
||||||
Module::Interface::~Interface() = default;
|
Module::Interface::~Interface() = default;
|
||||||
|
|
||||||
void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) {
|
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) {
|
||||||
LOG_DEBUG(Service_SPL, "called");
|
LOG_DEBUG(Service_SPL, "called");
|
||||||
|
|
||||||
const std::size_t size = ctx.GetWriteBufferSize();
|
const std::size_t size = ctx.GetWriteBufferSize();
|
||||||
|
@ -39,6 +45,12 @@ void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) {
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::Interface::IsDevelopment(Kernel::HLERequestContext& ctx) {}
|
||||||
|
|
||||||
|
void Module::Interface::SetBootReason(Kernel::HLERequestContext& ctx) {}
|
||||||
|
|
||||||
|
void Module::Interface::GetBootReason(Kernel::HLERequestContext& ctx) {}
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
||||||
auto module = std::make_shared<Module>();
|
auto module = std::make_shared<Module>();
|
||||||
std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager);
|
std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager);
|
||||||
|
|
|
@ -21,7 +21,14 @@ public:
|
||||||
const char* name);
|
const char* name);
|
||||||
~Interface() override;
|
~Interface() override;
|
||||||
|
|
||||||
void GetRandomBytes(Kernel::HLERequestContext& ctx);
|
// General
|
||||||
|
void GetConfig(Kernel::HLERequestContext& ctx);
|
||||||
|
void ModularExponentiate(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetConfig(Kernel::HLERequestContext& ctx);
|
||||||
|
void GenerateRandomBytes(Kernel::HLERequestContext& ctx);
|
||||||
|
void IsDevelopment(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetBootReason(Kernel::HLERequestContext& ctx);
|
||||||
|
void GetBootReason(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<Module> module;
|
std::shared_ptr<Module> module;
|
||||||
|
|
|
@ -10,13 +10,13 @@ SPL::SPL(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
: Interface(system_, std::move(module_), "spl:") {
|
: Interface(system_, std::move(module_), "spl:") {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "GetConfig"},
|
{0, &SPL::GetConfig, "GetConfig"},
|
||||||
{1, nullptr, "ModularExponentiate"},
|
{1, &SPL::ModularExponentiate, "ModularExponentiate"},
|
||||||
{5, nullptr, "SetConfig"},
|
{5, &SPL::SetConfig, "SetConfig"},
|
||||||
{7, &SPL::GetRandomBytes, "GetRandomBytes"},
|
{7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"},
|
||||||
{11, nullptr, "IsDevelopment"},
|
{11, &SPL::IsDevelopment, "IsDevelopment"},
|
||||||
{24, nullptr, "SetBootReason"},
|
{24, &SPL::SetBootReason, "SetBootReason"},
|
||||||
{25, nullptr, "GetBootReason"},
|
{25, &SPL::GetBootReason, "GetBootReason"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -27,22 +27,22 @@ SPL_MIG::SPL_MIG(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
: Interface(system_, std::move(module_), "spl:mig") {
|
: Interface(system_, std::move(module_), "spl:mig") {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "GetConfig"},
|
{0, &SPL::GetConfig, "GetConfig"},
|
||||||
{1, nullptr, "ModularExponentiate"},
|
{1, &SPL::ModularExponentiate, "ModularExponentiate"},
|
||||||
{2, nullptr, "GenerateAesKek"},
|
{2, nullptr, "GenerateAesKek"},
|
||||||
{3, nullptr, "LoadAesKey"},
|
{3, nullptr, "LoadAesKey"},
|
||||||
{4, nullptr, "GenerateAesKey"},
|
{4, nullptr, "GenerateAesKey"},
|
||||||
{5, nullptr, "SetConfig"},
|
{5, &SPL::SetConfig, "SetConfig"},
|
||||||
{7, &SPL::GetRandomBytes, "GenerateRandomBytes"},
|
{7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"},
|
||||||
{11, nullptr, "IsDevelopment"},
|
{11, &SPL::IsDevelopment, "IsDevelopment"},
|
||||||
{14, nullptr, "DecryptAesKey"},
|
{14, nullptr, "DecryptAesKey"},
|
||||||
{15, nullptr, "CryptAesCtr"},
|
{15, nullptr, "CryptAesCtr"},
|
||||||
{16, nullptr, "ComputeCmac"},
|
{16, nullptr, "ComputeCmac"},
|
||||||
{21, nullptr, "AllocateAesKeyslot"},
|
{21, nullptr, "AllocateAesKeyslot"},
|
||||||
{22, nullptr, "DeallocateAesKeySlot"},
|
{22, nullptr, "DeallocateAesKeySlot"},
|
||||||
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
||||||
{24, nullptr, "SetBootReason"},
|
{24, &SPL::SetBootReason, "SetBootReason"},
|
||||||
{25, nullptr, "GetBootReason"},
|
{25, &SPL::GetBootReason, "GetBootReason"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -53,16 +53,16 @@ SPL_FS::SPL_FS(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
: Interface(system_, std::move(module_), "spl:fs") {
|
: Interface(system_, std::move(module_), "spl:fs") {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "GetConfig"},
|
{0, &SPL::GetConfig, "GetConfig"},
|
||||||
{1, nullptr, "ModularExponentiate"},
|
{1, &SPL::ModularExponentiate, "ModularExponentiate"},
|
||||||
{2, nullptr, "GenerateAesKek"},
|
{2, nullptr, "GenerateAesKek"},
|
||||||
{3, nullptr, "LoadAesKey"},
|
{3, nullptr, "LoadAesKey"},
|
||||||
{4, nullptr, "GenerateAesKey"},
|
{4, nullptr, "GenerateAesKey"},
|
||||||
{5, nullptr, "SetConfig"},
|
{5, &SPL::SetConfig, "SetConfig"},
|
||||||
{7, &SPL::GetRandomBytes, "GenerateRandomBytes"},
|
{7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"},
|
||||||
{9, nullptr, "ImportLotusKey"},
|
{9, nullptr, "ImportLotusKey"},
|
||||||
{10, nullptr, "DecryptLotusMessage"},
|
{10, nullptr, "DecryptLotusMessage"},
|
||||||
{11, nullptr, "IsDevelopment"},
|
{11, &SPL::IsDevelopment, "IsDevelopment"},
|
||||||
{12, nullptr, "GenerateSpecificAesKey"},
|
{12, nullptr, "GenerateSpecificAesKey"},
|
||||||
{14, nullptr, "DecryptAesKey"},
|
{14, nullptr, "DecryptAesKey"},
|
||||||
{15, nullptr, "CryptAesCtr"},
|
{15, nullptr, "CryptAesCtr"},
|
||||||
|
@ -71,8 +71,8 @@ SPL_FS::SPL_FS(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
{21, nullptr, "AllocateAesKeyslot"},
|
{21, nullptr, "AllocateAesKeyslot"},
|
||||||
{22, nullptr, "DeallocateAesKeySlot"},
|
{22, nullptr, "DeallocateAesKeySlot"},
|
||||||
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
||||||
{24, nullptr, "SetBootReason"},
|
{24, &SPL::SetBootReason, "SetBootReason"},
|
||||||
{25, nullptr, "GetBootReason"},
|
{25, &SPL::GetBootReason, "GetBootReason"},
|
||||||
{31, nullptr, "GetPackage2Hash"},
|
{31, nullptr, "GetPackage2Hash"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -84,14 +84,14 @@ SPL_SSL::SPL_SSL(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
: Interface(system_, std::move(module_), "spl:ssl") {
|
: Interface(system_, std::move(module_), "spl:ssl") {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "GetConfig"},
|
{0, &SPL::GetConfig, "GetConfig"},
|
||||||
{1, nullptr, "ModularExponentiate"},
|
{1, &SPL::ModularExponentiate, "ModularExponentiate"},
|
||||||
{2, nullptr, "GenerateAesKek"},
|
{2, nullptr, "GenerateAesKek"},
|
||||||
{3, nullptr, "LoadAesKey"},
|
{3, nullptr, "LoadAesKey"},
|
||||||
{4, nullptr, "GenerateAesKey"},
|
{4, nullptr, "GenerateAesKey"},
|
||||||
{5, nullptr, "SetConfig"},
|
{5, &SPL::SetConfig, "SetConfig"},
|
||||||
{7, &SPL::GetRandomBytes, "GetRandomBytes"},
|
{7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"},
|
||||||
{11, nullptr, "IsDevelopment"},
|
{11, &SPL::IsDevelopment, "IsDevelopment"},
|
||||||
{13, nullptr, "DecryptDeviceUniqueData"},
|
{13, nullptr, "DecryptDeviceUniqueData"},
|
||||||
{14, nullptr, "DecryptAesKey"},
|
{14, nullptr, "DecryptAesKey"},
|
||||||
{15, nullptr, "CryptAesCtr"},
|
{15, nullptr, "CryptAesCtr"},
|
||||||
|
@ -99,8 +99,8 @@ SPL_SSL::SPL_SSL(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
{21, nullptr, "AllocateAesKeyslot"},
|
{21, nullptr, "AllocateAesKeyslot"},
|
||||||
{22, nullptr, "DeallocateAesKeySlot"},
|
{22, nullptr, "DeallocateAesKeySlot"},
|
||||||
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
||||||
{24, nullptr, "SetBootReason"},
|
{24, &SPL::SetBootReason, "SetBootReason"},
|
||||||
{25, nullptr, "GetBootReason"},
|
{25, &SPL::GetBootReason, "GetBootReason"},
|
||||||
{26, nullptr, "DecryptAndStoreSslClientCertKey"},
|
{26, nullptr, "DecryptAndStoreSslClientCertKey"},
|
||||||
{27, nullptr, "ModularExponentiateWithSslClientCertKey"},
|
{27, nullptr, "ModularExponentiateWithSslClientCertKey"},
|
||||||
};
|
};
|
||||||
|
@ -113,14 +113,14 @@ SPL_ES::SPL_ES(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
: Interface(system_, std::move(module_), "spl:es") {
|
: Interface(system_, std::move(module_), "spl:es") {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "GetConfig"},
|
{0, &SPL::GetConfig, "GetConfig"},
|
||||||
{1, nullptr, "ModularExponentiate"},
|
{1, &SPL::ModularExponentiate, "ModularExponentiate"},
|
||||||
{2, nullptr, "GenerateAesKek"},
|
{2, nullptr, "GenerateAesKek"},
|
||||||
{3, nullptr, "LoadAesKey"},
|
{3, nullptr, "LoadAesKey"},
|
||||||
{4, nullptr, "GenerateAesKey"},
|
{4, nullptr, "GenerateAesKey"},
|
||||||
{5, nullptr, "SetConfig"},
|
{5, &SPL::SetConfig, "SetConfig"},
|
||||||
{7, &SPL::GetRandomBytes, "GenerateRandomBytes"},
|
{7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"},
|
||||||
{11, nullptr, "IsDevelopment"},
|
{11, &SPL::IsDevelopment, "IsDevelopment"},
|
||||||
{13, nullptr, "DecryptDeviceUniqueData"},
|
{13, nullptr, "DecryptDeviceUniqueData"},
|
||||||
{14, nullptr, "DecryptAesKey"},
|
{14, nullptr, "DecryptAesKey"},
|
||||||
{15, nullptr, "CryptAesCtr"},
|
{15, nullptr, "CryptAesCtr"},
|
||||||
|
@ -131,8 +131,8 @@ SPL_ES::SPL_ES(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
{21, nullptr, "AllocateAesKeyslot"},
|
{21, nullptr, "AllocateAesKeyslot"},
|
||||||
{22, nullptr, "DeallocateAesKeySlot"},
|
{22, nullptr, "DeallocateAesKeySlot"},
|
||||||
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
||||||
{24, nullptr, "SetBootReason"},
|
{24, &SPL::SetBootReason, "SetBootReason"},
|
||||||
{25, nullptr, "GetBootReason"},
|
{25, &SPL::GetBootReason, "GetBootReason"},
|
||||||
{28, nullptr, "DecryptAndStoreDrmDeviceCertKey"},
|
{28, nullptr, "DecryptAndStoreDrmDeviceCertKey"},
|
||||||
{29, nullptr, "ModularExponentiateWithDrmDeviceCertKey"},
|
{29, nullptr, "ModularExponentiateWithDrmDeviceCertKey"},
|
||||||
{31, nullptr, "PrepareEsArchiveKey"},
|
{31, nullptr, "PrepareEsArchiveKey"},
|
||||||
|
@ -147,14 +147,14 @@ SPL_MANU::SPL_MANU(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
: Interface(system_, std::move(module_), "spl:manu") {
|
: Interface(system_, std::move(module_), "spl:manu") {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "GetConfig"},
|
{0, &SPL::GetConfig, "GetConfig"},
|
||||||
{1, nullptr, "ModularExponentiate"},
|
{1, &SPL::ModularExponentiate, "ModularExponentiate"},
|
||||||
{2, nullptr, "GenerateAesKek"},
|
{2, nullptr, "GenerateAesKek"},
|
||||||
{3, nullptr, "LoadAesKey"},
|
{3, nullptr, "LoadAesKey"},
|
||||||
{4, nullptr, "GenerateAesKey"},
|
{4, nullptr, "GenerateAesKey"},
|
||||||
{5, nullptr, "SetConfig"},
|
{5, &SPL::SetConfig, "SetConfig"},
|
||||||
{7, &SPL::GetRandomBytes, "GetRandomBytes"},
|
{7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"},
|
||||||
{11, nullptr, "IsDevelopment"},
|
{11, &SPL::IsDevelopment, "IsDevelopment"},
|
||||||
{13, nullptr, "DecryptDeviceUniqueData"},
|
{13, nullptr, "DecryptDeviceUniqueData"},
|
||||||
{14, nullptr, "DecryptAesKey"},
|
{14, nullptr, "DecryptAesKey"},
|
||||||
{15, nullptr, "CryptAesCtr"},
|
{15, nullptr, "CryptAesCtr"},
|
||||||
|
@ -162,8 +162,8 @@ SPL_MANU::SPL_MANU(Core::System& system_, std::shared_ptr<Module> module_)
|
||||||
{21, nullptr, "AllocateAesKeyslot"},
|
{21, nullptr, "AllocateAesKeyslot"},
|
||||||
{22, nullptr, "DeallocateAesKeySlot"},
|
{22, nullptr, "DeallocateAesKeySlot"},
|
||||||
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
{23, nullptr, "GetAesKeyslotAvailableEvent"},
|
||||||
{24, nullptr, "SetBootReason"},
|
{24, &SPL::SetBootReason, "SetBootReason"},
|
||||||
{25, nullptr, "GetBootReason"},
|
{25, &SPL::GetBootReason, "GetBootReason"},
|
||||||
{30, nullptr, "ReencryptDeviceUniqueData"},
|
{30, nullptr, "ReencryptDeviceUniqueData"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
Loading…
Reference in a new issue