Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"

This reverts commit 15b7df8ef1.
This commit is contained in:
souldbminersmwc
2025-11-09 16:14:52 -05:00
parent 22ec140738
commit 21a3f953d7
3804 changed files with 435 additions and 570162 deletions

View File

@@ -1,71 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_general_service.hpp"
namespace ams::spl {
class CryptoService : public GeneralService {
public:
explicit CryptoService(SecureMonitorManager *manager) : GeneralService(manager) { /* ... */ }
public:
virtual ~CryptoService(){
/* Free any keyslots this service is using. */
m_manager.DeallocateAesKeySlots(this);
}
public:
/* Actual commands. */
Result GenerateAesKek(sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation, u32 option) {
R_RETURN(m_manager.GenerateAesKek(out_access_key.GetPointer(), key_source, generation, option));
}
Result LoadAesKey(s32 keyslot, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.LoadAesKey(keyslot, this, access_key, key_source));
}
Result GenerateAesKey(sf::Out<AesKey> out_key, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.GenerateAesKey(out_key.GetPointer(), access_key, key_source));
}
Result DecryptAesKey(sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 option) {
R_RETURN(m_manager.DecryptAesKey(out_key.GetPointer(), key_source, generation, option));
}
Result ComputeCtr(const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, IvCtr iv_ctr) {
R_RETURN(m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr));
}
Result ComputeCmac(sf::Out<Cmac> out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf) {
R_RETURN(m_manager.ComputeCmac(out_cmac.GetPointer(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize()));
}
Result AllocateAesKeySlot(sf::Out<s32> out_keyslot) {
R_RETURN(m_manager.AllocateAesKeySlot(out_keyslot.GetPointer(), this));
}
Result DeallocateAesKeySlot(s32 keyslot) {
R_RETURN(m_manager.DeallocateAesKeySlot(keyslot, this));
}
Result GetAesKeySlotAvailableEvent(sf::OutCopyHandle out_hnd) {
out_hnd.SetValue(m_manager.GetAesKeySlotAvailableEvent()->GetReadableHandle(), false);
R_SUCCEED();
}
};
static_assert(spl::impl::IsICryptoInterface<CryptoService>);
}

View File

@@ -1,145 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_secure_monitor_manager.hpp"
namespace ams::spl {
class DeprecatedService {
protected:
SecureMonitorManager &m_manager;
public:
explicit DeprecatedService(SecureMonitorManager *manager) : m_manager(*manager) { /* ... */ }
public:
virtual ~DeprecatedService() {
/* Free any keyslots this service is using. */
m_manager.DeallocateAesKeySlots(this);
}
public:
/* Actual commands. */
Result GetConfig(sf::Out<u64> out, u32 which) {
R_RETURN(m_manager.GetConfig(out.GetPointer(), static_cast<spl::ConfigItem>(which)));
}
Result ModularExponentiate(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod) {
R_RETURN(m_manager.ModularExponentiate(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), exp.GetPointer(), exp.GetSize(), mod.GetPointer(), mod.GetSize()));
}
Result GenerateAesKek(sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation, u32 option) {
R_RETURN(m_manager.GenerateAesKek(out_access_key.GetPointer(), key_source, generation, option));
}
Result LoadAesKey(s32 keyslot, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.LoadAesKey(keyslot, this, access_key, key_source));
}
Result GenerateAesKey(sf::Out<AesKey> out_key, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.GenerateAesKey(out_key.GetPointer(), access_key, key_source));
}
Result SetConfig(u32 which, u64 value) {
R_RETURN(m_manager.SetConfig(static_cast<spl::ConfigItem>(which), value));
}
Result GenerateRandomBytes(const sf::OutPointerBuffer &out) {
R_RETURN(m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize()));
}
Result DecryptAndStoreGcKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) {
R_RETURN(m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, option));
}
Result DecryptGcMessage(sf::Out<u32> out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest) {
R_RETURN(m_manager.DecryptGcMessage(out_size.GetPointer(), out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize()));
}
Result IsDevelopment(sf::Out<bool> is_dev) {
R_RETURN(m_manager.IsDevelopment(is_dev.GetPointer()));
}
Result GenerateSpecificAesKey(sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 which) {
R_RETURN(m_manager.GenerateSpecificAesKey(out_key.GetPointer(), key_source, generation, which));
}
Result DecryptDeviceUniqueData(const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) {
R_RETURN(m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, option));
}
Result DecryptAesKey(sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 option) {
R_RETURN(m_manager.DecryptAesKey(out_key.GetPointer(), key_source, generation, option));
}
Result ComputeCtrDeprecated(const sf::OutBuffer &out_buf, s32 keyslot, const sf::InBuffer &in_buf, IvCtr iv_ctr) {
R_RETURN(m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr));
}
Result ComputeCtr(const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, IvCtr iv_ctr) {
R_RETURN(m_manager.ComputeCtr(out_buf.GetPointer(), out_buf.GetSize(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize(), iv_ctr));
}
Result ComputeCmac(sf::Out<Cmac> out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf) {
R_RETURN(m_manager.ComputeCmac(out_cmac.GetPointer(), keyslot, this, in_buf.GetPointer(), in_buf.GetSize()));
}
Result LoadEsDeviceKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) {
R_RETURN(m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, option));
}
Result PrepareEsTitleKeyDeprecated(sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest) {
R_RETURN(m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), 0));
}
Result PrepareEsTitleKey(sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation) {
R_RETURN(m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation));
}
Result LoadPreparedAesKey(s32 keyslot, AccessKey access_key) {
R_RETURN(m_manager.LoadPreparedAesKey(keyslot, this, access_key));
}
Result PrepareCommonEsTitleKeyDeprecated(sf::Out<AccessKey> out_access_key, KeySource key_source) {
R_RETURN(m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, 0));
}
Result PrepareCommonEsTitleKey(sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation) {
R_RETURN(m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, generation));
}
Result AllocateAesKeySlot(sf::Out<s32> out_keyslot) {
R_RETURN(m_manager.AllocateAesKeySlot(out_keyslot.GetPointer(), this));
}
Result DeallocateAesKeySlot(s32 keyslot) {
R_RETURN(m_manager.DeallocateAesKeySlot(keyslot, this));
}
Result GetAesKeySlotAvailableEvent(sf::OutCopyHandle out_hnd) {
out_hnd.SetValue(m_manager.GetAesKeySlotAvailableEvent()->GetReadableHandle(), false);
R_SUCCEED();
}
Result SetBootReason(BootReasonValue boot_reason) {
R_RETURN(m_manager.SetBootReason(boot_reason));
}
Result GetBootReason(sf::Out<BootReasonValue> out) {
R_RETURN(m_manager.GetBootReason(out.GetPointer()));
}
};
static_assert(spl::impl::IsIDeprecatedGeneralInterface<DeprecatedService>);
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_crypto_service.hpp"
namespace ams::spl {
class DeviceUniqueDataService : public CryptoService {
public:
explicit DeviceUniqueDataService(SecureMonitorManager *manager) : CryptoService(manager) { /* ... */ }
public:
/* Actual commands. */
Result DecryptDeviceUniqueDataDeprecated(const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) {
R_RETURN(m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, option));
}
Result DecryptDeviceUniqueData(const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.DecryptDeviceUniqueData(dst.GetPointer(), dst.GetSize(), src.GetPointer(), src.GetSize(), access_key, key_source, static_cast<u32>(smc::DeviceUniqueDataMode::DecryptDeviceUniqueData)));
}
};
static_assert(spl::impl::IsIDeviceUniqueDataInterface<DeviceUniqueDataService>);
}

View File

@@ -1,65 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_device_unique_data_service.hpp"
namespace ams::spl {
class EsService : public DeviceUniqueDataService {
public:
explicit EsService(SecureMonitorManager *manager) : DeviceUniqueDataService(manager) { /* ... */ }
public:
/* Actual commands. */
Result LoadEsDeviceKeyDeprecated(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) {
R_RETURN(m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, option));
}
Result LoadEsDeviceKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.LoadEsDeviceKey(src.GetPointer(), src.GetSize(), access_key, key_source, static_cast<u32>(smc::DeviceUniqueDataMode::DecryptAndStoreEsDeviceKey)));
}
Result PrepareEsTitleKey(sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation) {
R_RETURN(m_manager.PrepareEsTitleKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation));
}
Result PrepareCommonEsTitleKey(sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation) {
R_RETURN(m_manager.PrepareCommonEsTitleKey(out_access_key.GetPointer(), key_source, generation));
}
Result DecryptAndStoreDrmDeviceCertKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.DecryptAndStoreDrmDeviceCertKey(src.GetPointer(), src.GetSize(), access_key, key_source));
}
Result ModularExponentiateWithDrmDeviceCertKey(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod) {
R_RETURN(m_manager.ModularExponentiateWithDrmDeviceCertKey(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize()));
}
Result PrepareEsArchiveKey(sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation) {
R_RETURN(m_manager.PrepareEsArchiveKey(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation));
}
Result LoadPreparedAesKey(s32 keyslot, AccessKey access_key) {
R_RETURN(m_manager.LoadPreparedAesKey(keyslot, this, access_key));
}
Result PrepareEsUnknown2Key(sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation) {
R_RETURN(m_manager.PrepareEsUnknown2Key(out_access_key.GetPointer(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize(), generation));
}
};
static_assert(spl::impl::IsIEsInterface<EsService>);
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_crypto_service.hpp"
namespace ams::spl {
class FsService : public CryptoService {
public:
explicit FsService(SecureMonitorManager *manager) : CryptoService(manager) { /* ... */ }
public:
/* Actual commands. */
Result DecryptAndStoreGcKeyDeprecated(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option) {
R_RETURN(m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, option));
}
Result DecryptAndStoreGcKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.DecryptAndStoreGcKey(src.GetPointer(), src.GetSize(), access_key, key_source, static_cast<u32>(smc::DeviceUniqueDataMode::DecryptAndStoreGcKey)));
}
Result DecryptGcMessage(sf::Out<u32> out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest) {
R_RETURN(m_manager.DecryptGcMessage(out_size.GetPointer(), out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize(), label_digest.GetPointer(), label_digest.GetSize()));
}
Result GenerateSpecificAesKey(sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 which) {
R_RETURN(m_manager.GenerateSpecificAesKey(out_key.GetPointer(), key_source, generation, which));
}
Result LoadPreparedAesKey(s32 keyslot, AccessKey access_key) {
R_RETURN(m_manager.LoadPreparedAesKey(keyslot, this, access_key));
}
Result GetPackage2Hash(const sf::OutPointerBuffer &dst) {
R_RETURN(m_manager.GetPackage2Hash(dst.GetPointer(), dst.GetSize()));
}
};
static_assert(spl::impl::IsIFsInterface<FsService>);
}

View File

@@ -1,59 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_secure_monitor_manager.hpp"
namespace ams::spl {
class GeneralService {
protected:
SecureMonitorManager &m_manager;
public:
explicit GeneralService(SecureMonitorManager *manager) : m_manager(*manager) { /* ... */ }
public:
/* Actual commands. */
Result GetConfig(sf::Out<u64> out, u32 key) {
R_RETURN(m_manager.GetConfig(out.GetPointer(), static_cast<spl::ConfigItem>(key)));
}
Result ModularExponentiate(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod) {
R_RETURN(m_manager.ModularExponentiate(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), exp.GetPointer(), exp.GetSize(), mod.GetPointer(), mod.GetSize()));
}
Result SetConfig(u32 key, u64 value) {
R_RETURN(m_manager.SetConfig(static_cast<spl::ConfigItem>(key), value));
}
Result GenerateRandomBytes(const sf::OutPointerBuffer &out) {
R_RETURN(m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize()));
}
Result IsDevelopment(sf::Out<bool> is_dev) {
R_RETURN(m_manager.IsDevelopment(is_dev.GetPointer()));
}
Result SetBootReason(BootReasonValue boot_reason) {
R_RETURN(m_manager.SetBootReason(boot_reason));
}
Result GetBootReason(sf::Out<BootReasonValue> out) {
R_RETURN(m_manager.GetBootReason(out.GetPointer()));
}
};
static_assert(spl::impl::IsIGeneralInterface<GeneralService>);
}

View File

@@ -1,192 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "spl_random_service.hpp"
#include "spl_general_service.hpp"
#include "spl_crypto_service.hpp"
#include "spl_ssl_service.hpp"
#include "spl_es_service.hpp"
#include "spl_fs_service.hpp"
#include "spl_manu_service.hpp"
#include "spl_deprecated_service.hpp"
namespace ams {
namespace spl {
namespace {
struct SplServerOptions {
static constexpr size_t PointerBufferSize = 0x800;
static constexpr size_t MaxDomains = 0;
static constexpr size_t MaxDomainObjects = 0;
static constexpr bool CanDeferInvokeRequest = false;
static constexpr bool CanManageMitmServers = false;
};
enum PortIndex {
PortIndex_General,
PortIndex_Random,
PortIndex_Crypto,
PortIndex_Fs,
PortIndex_Ssl,
PortIndex_Es,
PortIndex_Manu,
PortIndex_Count,
};
constexpr sm::ServiceName RandomServiceName = sm::ServiceName::Encode("csrng");
constexpr size_t RandomMaxSessions = 10; /* NOTE: Official is 9. */
constexpr sm::ServiceName GeneralServiceName = sm::ServiceName::Encode("spl:");
constexpr size_t DeprecatedMaxSessions = 13;
constexpr size_t GeneralMaxSessions = 9; /* NOTE: Official is 8. */
constexpr sm::ServiceName CryptoServiceName = sm::ServiceName::Encode("spl:mig");
constexpr size_t CryptoMaxSessions = 7; /* NOTE: Official is 6. */
constexpr sm::ServiceName SslServiceName = sm::ServiceName::Encode("spl:ssl");
constexpr size_t SslMaxSessions = 2; /* NOTE: Official is 2. */
constexpr sm::ServiceName EsServiceName = sm::ServiceName::Encode("spl:es");
constexpr size_t EsMaxSessions = 2; /* NOTE: Official is 2. */
constexpr sm::ServiceName FsServiceName = sm::ServiceName::Encode("spl:fs");
constexpr size_t FsMaxSessions = 3; /* NOTE: Official is 1. */
constexpr sm::ServiceName ManuServiceName = sm::ServiceName::Encode("spl:manu");
constexpr size_t ManuMaxSessions = 1; /* NOTE: Official is 1. */
/* csrng, spl:, spl:mig, spl:ssl, spl:es, spl:fs, spl:manu. */
/* TODO: Consider max sessions enforcement? */
constexpr size_t ModernMaxSessions = GeneralMaxSessions + CryptoMaxSessions + SslMaxSessions + EsMaxSessions + FsMaxSessions + ManuMaxSessions;
constexpr size_t NumSessions = RandomMaxSessions + std::max(DeprecatedMaxSessions, ModernMaxSessions) + 1;
class ServerManager final : public sf::hipc::ServerManager<PortIndex_Count, SplServerOptions, NumSessions> {
private:
sf::ExpHeapAllocator *m_allocator;
spl::SecureMonitorManager *m_secure_monitor_manager;
spl::GeneralService m_general_service;
sf::UnmanagedServiceObjectByPointer<spl::impl::IGeneralInterface, spl::GeneralService> m_general_service_object;
spl::RandomService m_random_service;
sf::UnmanagedServiceObjectByPointer<spl::impl::IRandomInterface, spl::RandomService> m_random_service_object;
public:
ServerManager(sf::ExpHeapAllocator *allocator, spl::SecureMonitorManager *manager) : m_allocator(allocator), m_secure_monitor_manager(manager), m_general_service(manager), m_general_service_object(std::addressof(m_general_service)), m_random_service(manager), m_random_service_object(std::addressof(m_random_service)) {
/* ... */
}
private:
virtual ams::Result OnNeedsToAccept(int port_index, Server *server) override;
};
using Allocator = sf::ExpHeapAllocator;
using ObjectFactory = sf::ObjectFactory<sf::ExpHeapAllocator::Policy>;
alignas(0x40) constinit u8 g_server_allocator_buffer[8_KB];
Allocator g_server_allocator;
constinit SecureMonitorManager g_secure_monitor_manager;
constinit bool g_use_new_server = false;
ServerManager g_server_manager(std::addressof(g_server_allocator), std::addressof(g_secure_monitor_manager));
ams::Result ServerManager::OnNeedsToAccept(int port_index, Server *server) {
switch (port_index) {
case PortIndex_General:
if (g_use_new_server) {
R_RETURN(this->AcceptImpl(server, m_general_service_object.GetShared()));
} else {
R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<spl::impl::IDeprecatedGeneralInterface, spl::DeprecatedService>(m_allocator, m_secure_monitor_manager)));
}
case PortIndex_Random:
R_RETURN(this->AcceptImpl(server, m_random_service_object.GetShared()));
case PortIndex_Crypto:
R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<spl::impl::ICryptoInterface, spl::CryptoService>(m_allocator, m_secure_monitor_manager)));
case PortIndex_Fs:
R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<spl::impl::IFsInterface, spl::FsService>(m_allocator, m_secure_monitor_manager)));
case PortIndex_Ssl:
R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<spl::impl::ISslInterface, spl::SslService>(m_allocator, m_secure_monitor_manager)));
case PortIndex_Es:
R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<spl::impl::IEsInterface, spl::EsService>(m_allocator, m_secure_monitor_manager)));
case PortIndex_Manu:
R_RETURN(this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<spl::impl::IManuInterface, spl::ManuService>(m_allocator, m_secure_monitor_manager)));
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
void SplMain() {
/* Setup server allocator. */
g_server_allocator.Attach(lmem::CreateExpHeap(g_server_allocator_buffer, sizeof(g_server_allocator_buffer), lmem::CreateOption_None));
/* Initialize secure monitor manager. */
g_secure_monitor_manager.Initialize();
g_use_new_server = hos::GetVersion() >= hos::Version_4_0_0;
/* Create services. */
const auto fw_ver = hos::GetVersion();
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_General, GeneralServiceName, fw_ver >= hos::Version_4_0_0 ? GeneralMaxSessions : DeprecatedMaxSessions));
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_Random, RandomServiceName, RandomMaxSessions));
if (fw_ver >= hos::Version_4_0_0) {
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_Crypto, CryptoServiceName, CryptoMaxSessions));
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_Fs, FsServiceName, FsMaxSessions));
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_Ssl, SslServiceName, SslMaxSessions));
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_Es, EsServiceName, EsMaxSessions));
if (fw_ver >= hos::Version_5_0_0) {
g_server_manager.RegisterServer(PortIndex_Manu, ManuServiceName, ManuMaxSessions);
}
}
/* Loop forever, servicing our services. */
g_server_manager.LoopProcess();
}
}
}
namespace init {
void InitializeSystemModule() {
/* Initialize our connection to sm. */
R_ABORT_UNLESS(sm::Initialize());
}
void FinalizeSystemModule() { /* ... */ }
void Startup() { /* ... */ }
}
void NORETURN Exit(int rc) {
AMS_UNUSED(rc);
AMS_ABORT("Exit called by immortal process");
}
void Main() {
/* Set thread name. */
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(spl, Main));
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(spl, Main));
/* Invoke SPL main. */
spl::SplMain();
/* This can never be reached. */
AMS_ASSUME(false);
}
}

View File

@@ -1,33 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_device_unique_data_service.hpp"
namespace ams::spl {
class ManuService : public DeviceUniqueDataService {
public:
explicit ManuService(SecureMonitorManager *manager) : DeviceUniqueDataService(manager) { /* ... */ }
public:
/* Actual commands. */
Result ReencryptDeviceUniqueData(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &src, AccessKey access_key_dec, KeySource source_dec, AccessKey access_key_enc, KeySource source_enc, u32 option) {
R_RETURN(m_manager.ReencryptDeviceUniqueData(out.GetPointer(), out.GetSize(), src.GetPointer(), src.GetSize(), access_key_dec, source_dec, access_key_enc, source_enc, option));
}
};
static_assert(spl::impl::IsIManuInterface<ManuService>);
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_secure_monitor_manager.hpp"
namespace ams::spl {
class RandomService final {
protected:
SecureMonitorManager &m_manager;
public:
explicit RandomService(SecureMonitorManager *manager) : m_manager(*manager) { /* ... */ }
public:
/* Actual commands. */
Result GenerateRandomBytes(const sf::OutBuffer &out) {
R_RETURN(m_manager.GenerateRandomBytes(out.GetPointer(), out.GetSize()));
}
};
static_assert(spl::impl::IsIRandomInterface<RandomService>);
}

View File

@@ -1,201 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "spl_secure_monitor_manager.hpp"
namespace ams::spl {
void SecureMonitorManager::Initialize() {
return impl::Initialize();
}
Result SecureMonitorManager::ModularExponentiate(void *out, size_t out_size, const void *base, size_t base_size, const void *exp, size_t exp_size, const void *mod, size_t mod_size) {
R_RETURN(impl::ModularExponentiate(out, out_size, base, base_size, exp, exp_size, mod, mod_size));
}
Result SecureMonitorManager::GenerateAesKek(AccessKey *out_access_key, const KeySource &key_source, u32 generation, u32 option) {
R_RETURN(impl::GenerateAesKek(out_access_key, key_source, generation, option));
}
Result SecureMonitorManager::LoadAesKey(s32 keyslot, const void *owner, const AccessKey &access_key, const KeySource &key_source) {
R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner));
R_RETURN(impl::LoadAesKey(keyslot, access_key, key_source));
}
Result SecureMonitorManager::GenerateAesKey(AesKey *out_key, const AccessKey &access_key, const KeySource &key_source) {
R_RETURN(impl::GenerateAesKey(out_key, access_key, key_source));
}
Result SecureMonitorManager::DecryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) {
R_RETURN(impl::DecryptDeviceUniqueData(dst, dst_size, src, src_size, access_key, key_source, option));
}
Result SecureMonitorManager::ReencryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key_dec, const KeySource &source_dec, const AccessKey &access_key_enc, const KeySource &source_enc, u32 option) {
R_RETURN(impl::ReencryptDeviceUniqueData(dst, dst_size, src, src_size, access_key_dec, source_dec, access_key_enc, source_enc, option));
}
Result SecureMonitorManager::GetConfig(u64 *out, spl::ConfigItem key) {
R_RETURN(impl::GetConfig(out, key));
}
Result SecureMonitorManager::SetConfig(spl::ConfigItem key, u64 value) {
R_RETURN(impl::SetConfig(key, value));
}
Result SecureMonitorManager::GetPackage2Hash(void *dst, const size_t size) {
R_RETURN(impl::GetPackage2Hash(dst, size));
}
Result SecureMonitorManager::GenerateRandomBytes(void *out, size_t size) {
R_RETURN(impl::GenerateRandomBytes(out, size));
}
Result SecureMonitorManager::DecryptAndStoreGcKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) {
R_RETURN(impl::DecryptAndStoreGcKey(src, src_size, access_key, key_source, option));
}
Result SecureMonitorManager::DecryptGcMessage(u32 *out_size, void *dst, size_t dst_size, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size) {
R_RETURN(impl::DecryptGcMessage(out_size, dst, dst_size, base, base_size, mod, mod_size, label_digest, label_digest_size));
}
Result SecureMonitorManager::DecryptAndStoreSslClientCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source) {
R_RETURN(impl::DecryptAndStoreSslClientCertKey(src, src_size, access_key, key_source));
}
Result SecureMonitorManager::ModularExponentiateWithSslClientCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size) {
R_RETURN(impl::ModularExponentiateWithSslClientCertKey(out, out_size, base, base_size, mod, mod_size));
}
Result SecureMonitorManager::DecryptAndStoreDrmDeviceCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source) {
R_RETURN(impl::DecryptAndStoreDrmDeviceCertKey(src, src_size, access_key, key_source));
}
Result SecureMonitorManager::ModularExponentiateWithDrmDeviceCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size) {
R_RETURN(impl::ModularExponentiateWithDrmDeviceCertKey(out, out_size, base, base_size, mod, mod_size));
}
Result SecureMonitorManager::IsDevelopment(bool *out) {
R_RETURN(impl::IsDevelopment(out));
}
Result SecureMonitorManager::GenerateSpecificAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 which) {
R_RETURN(impl::GenerateSpecificAesKey(out_key, key_source, generation, which));
}
Result SecureMonitorManager::DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option) {
R_RETURN(impl::DecryptAesKey(out_key, key_source, generation, option));
}
Result SecureMonitorManager::ComputeCtr(void *dst, size_t dst_size, s32 keyslot, const void *owner, const void *src, size_t src_size, const IvCtr &iv_ctr) {
R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner));
R_RETURN(impl::ComputeCtr(dst, dst_size, keyslot, src, src_size, iv_ctr));
}
Result SecureMonitorManager::ComputeCmac(Cmac *out_cmac, s32 keyslot, const void *owner, const void *data, size_t size) {
R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner));
R_RETURN(impl::ComputeCmac(out_cmac, keyslot, data, size));
}
Result SecureMonitorManager::LoadEsDeviceKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) {
R_RETURN(impl::LoadEsDeviceKey(src, src_size, access_key, key_source, option));
}
Result SecureMonitorManager::PrepareEsTitleKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation) {
R_RETURN(impl::PrepareEsTitleKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, generation));
}
Result SecureMonitorManager::PrepareEsArchiveKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation) {
R_RETURN(impl::PrepareEsArchiveKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, generation));
}
Result SecureMonitorManager::PrepareEsUnknown2Key(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation) {
R_RETURN(impl::PrepareEsUnknown2Key(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, generation));
}
Result SecureMonitorManager::PrepareCommonEsTitleKey(AccessKey *out_access_key, const KeySource &key_source, u32 generation) {
R_RETURN(impl::PrepareCommonEsTitleKey(out_access_key, key_source, generation));
}
Result SecureMonitorManager::LoadPreparedAesKey(s32 keyslot, const void *owner, const AccessKey &access_key) {
R_TRY(this->TestAesKeySlot(nullptr, keyslot, owner));
R_RETURN(impl::LoadPreparedAesKey(keyslot, access_key));
}
Result SecureMonitorManager::AllocateAesKeySlot(s32 *out_keyslot, const void *owner) {
/* Allocate a new virtual keyslot. */
s32 keyslot;
R_TRY(impl::AllocateAesKeySlot(std::addressof(keyslot)));
/* Get the keyslot's index. */
s32 index;
bool virt;
R_ABORT_UNLESS(impl::TestAesKeySlot(std::addressof(index), std::addressof(virt), keyslot));
/* All allocated keyslots must be virtual. */
AMS_ABORT_UNLESS(virt);
m_aes_keyslot_owners[index] = owner;
*out_keyslot = keyslot;
R_SUCCEED();
}
Result SecureMonitorManager::DeallocateAesKeySlot(s32 keyslot, const void *owner) {
s32 index;
R_TRY(this->TestAesKeySlot(std::addressof(index), keyslot, owner));
m_aes_keyslot_owners[index] = nullptr;
R_RETURN(impl::DeallocateAesKeySlot(keyslot));
}
void SecureMonitorManager::DeallocateAesKeySlots(const void *owner) {
for (auto i = 0; i < impl::AesKeySlotCount; ++i) {
if (m_aes_keyslot_owners[i] == owner) {
m_aes_keyslot_owners[i] = nullptr;
impl::DeallocateAesKeySlot(impl::AesKeySlotMin + i);
}
}
}
Result SecureMonitorManager::SetBootReason(BootReasonValue boot_reason) {
R_RETURN(impl::SetBootReason(boot_reason));
}
Result SecureMonitorManager::GetBootReason(BootReasonValue *out) {
R_RETURN(impl::GetBootReason(out));
}
os::SystemEvent *SecureMonitorManager::GetAesKeySlotAvailableEvent() {
return impl::GetAesKeySlotAvailableEvent();
}
Result SecureMonitorManager::TestAesKeySlot(s32 *out_index, s32 keyslot, const void *owner) {
/* Validate the keyslot (and get the index). */
s32 index;
bool virt;
R_TRY(impl::TestAesKeySlot(std::addressof(index), std::addressof(virt), keyslot));
/* Check that the keyslot is physical (for legacy compat) or owned by the request maker. */
R_UNLESS(!virt || m_aes_keyslot_owners[index] == owner, spl::ResultInvalidKeySlot());
/* Set output index. */
if (out_index != nullptr) {
*out_index = index;
}
R_SUCCEED();
}
}

View File

@@ -1,67 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::spl {
class SecureMonitorManager {
private:
const void *m_aes_keyslot_owners[impl::AesKeySlotCount]{};
public:
constexpr SecureMonitorManager() = default;
public:
void Initialize();
private:
Result TestAesKeySlot(s32 *out_index, s32 keyslot, const void *owner);
public:
Result ModularExponentiate(void *out, size_t out_size, const void *base, size_t base_size, const void *exp, size_t exp_size, const void *mod, size_t mod_size);
Result GenerateAesKek(AccessKey *out_access_key, const KeySource &key_source, u32 generation, u32 option);
Result LoadAesKey(s32 keyslot, const void *owner, const AccessKey &access_key, const KeySource &key_source);
Result GenerateAesKey(AesKey *out_key, const AccessKey &access_key, const KeySource &key_source);
Result DecryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option);
Result ReencryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key_dec, const KeySource &source_dec, const AccessKey &access_key_enc, const KeySource &source_enc, u32 option);
Result GetConfig(u64 *out, spl::ConfigItem key);
Result SetConfig(spl::ConfigItem key, u64 value);
Result GetPackage2Hash(void *dst, const size_t size);
Result GenerateRandomBytes(void *out, size_t size);
Result DecryptAndStoreGcKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option);
Result DecryptGcMessage(u32 *out_size, void *dst, size_t dst_size, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size);
Result DecryptAndStoreSslClientCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source);
Result ModularExponentiateWithSslClientCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size);
Result DecryptAndStoreDrmDeviceCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source);
Result ModularExponentiateWithDrmDeviceCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size);
Result IsDevelopment(bool *out);
Result GenerateSpecificAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 which);
Result DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option);
Result ComputeCtr(void *dst, size_t dst_size, s32 keyslot, const void *owner, const void *src, size_t src_size, const IvCtr &iv_ctr);
Result ComputeCmac(Cmac *out_cmac, s32 keyslot, const void *owner, const void *data, size_t size);
Result LoadEsDeviceKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option);
Result PrepareEsTitleKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation);
Result PrepareEsArchiveKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation);
Result PrepareEsUnknown2Key(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation);
Result PrepareCommonEsTitleKey(AccessKey *out_access_key, const KeySource &key_source, u32 generation);
Result LoadPreparedAesKey(s32 keyslot, const void *owner, const AccessKey &access_key);
Result AllocateAesKeySlot(s32 *out_keyslot, const void *owner);
Result DeallocateAesKeySlot(s32 keyslot, const void *owner);
void DeallocateAesKeySlots(const void *owner);
Result SetBootReason(BootReasonValue boot_reason);
Result GetBootReason(BootReasonValue *out);
os::SystemEvent *GetAesKeySlotAvailableEvent();
};
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "spl_device_unique_data_service.hpp"
namespace ams::spl {
class SslService : public DeviceUniqueDataService {
public:
explicit SslService(SecureMonitorManager *manager) : DeviceUniqueDataService(manager) { /* ... */ }
public:
/* Actual commands. */
Result DecryptAndStoreSslClientCertKey(const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source) {
R_RETURN(m_manager.DecryptAndStoreSslClientCertKey(src.GetPointer(), src.GetSize(), access_key, key_source));
}
Result ModularExponentiateWithSslClientCertKey(const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod) {
R_RETURN(m_manager.ModularExponentiateWithSslClientCertKey(out.GetPointer(), out.GetSize(), base.GetPointer(), base.GetSize(), mod.GetPointer(), mod.GetSize()));
}
};
static_assert(spl::impl::IsISslInterface<SslService>);
}