From f860590d5f27ae0d6199e9b6d559a435410aef40 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 28 Mar 2024 04:43:07 -0700 Subject: [PATCH] spl: add support for new spl:es command 33 --- .../include/stratosphere/spl/impl/spl_api_impl.hpp | 1 + .../include/stratosphere/spl/impl/spl_es_interface.hpp | 3 ++- libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp | 4 ++++ stratosphere/spl/source/spl_es_service.hpp | 4 ++++ stratosphere/spl/source/spl_secure_monitor_manager.cpp | 4 ++++ stratosphere/spl/source/spl_secure_monitor_manager.hpp | 1 + 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libraries/libstratosphere/include/stratosphere/spl/impl/spl_api_impl.hpp b/libraries/libstratosphere/include/stratosphere/spl/impl/spl_api_impl.hpp index db2354329..1a79d67b1 100644 --- a/libraries/libstratosphere/include/stratosphere/spl/impl/spl_api_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/spl/impl/spl_api_impl.hpp @@ -70,6 +70,7 @@ namespace ams::spl::impl { Result ModularExponentiateWithDrmDeviceCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size); 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 LoadPreparedAesKey(s32 keyslot, const AccessKey &access_key); + 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); /* FS */ Result DecryptAndStoreGcKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option); diff --git a/libraries/libstratosphere/include/stratosphere/spl/impl/spl_es_interface.hpp b/libraries/libstratosphere/include/stratosphere/spl/impl/spl_es_interface.hpp index 0fda18172..237c3124e 100644 --- a/libraries/libstratosphere/include/stratosphere/spl/impl/spl_es_interface.hpp +++ b/libraries/libstratosphere/include/stratosphere/spl/impl/spl_es_interface.hpp @@ -28,6 +28,7 @@ AMS_SF_METHOD_INFO(C, H, 28, Result, DecryptAndStoreDrmDeviceCertKey, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source), (src, access_key, key_source), hos::Version_5_0_0) \ AMS_SF_METHOD_INFO(C, H, 29, Result, ModularExponentiateWithDrmDeviceCertKey, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod), (out, base, mod), hos::Version_5_0_0) \ AMS_SF_METHOD_INFO(C, H, 31, Result, PrepareEsArchiveKey, (sf::Out out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), (out_access_key, base, mod, label_digest, generation), hos::Version_6_0_0) \ - AMS_SF_METHOD_INFO(C, H, 32, Result, LoadPreparedAesKey, (s32 keyslot, spl::AccessKey access_key), (keyslot, access_key), hos::Version_6_0_0) + AMS_SF_METHOD_INFO(C, H, 32, Result, LoadPreparedAesKey, (s32 keyslot, spl::AccessKey access_key), (keyslot, access_key), hos::Version_6_0_0) \ + AMS_SF_METHOD_INFO(C, H, 33, Result, PrepareEsUnknown2Key, (sf::Out out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), (out_access_key, base, mod, label_digest, generation), hos::Version_18_0_0) AMS_SF_DEFINE_INTERFACE_WITH_BASE(ams::spl::impl, IEsInterface, ::ams::spl::impl::IDeviceUniqueDataInterface, AMS_SPL_I_ES_INTERFACE_INTERFACE_INFO, 0x346D5001) diff --git a/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp b/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp index acec07407..c5c450b1b 100644 --- a/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp +++ b/libraries/libstratosphere/source/spl/impl/spl_api_impl.cpp @@ -893,6 +893,10 @@ namespace ams::spl::impl { R_RETURN(PrepareEsDeviceUniqueKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, smc::EsDeviceUniqueKeyType::ArchiveKey, 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) { + R_RETURN(PrepareEsDeviceUniqueKey(out_access_key, base, base_size, mod, mod_size, label_digest, label_digest_size, smc::EsDeviceUniqueKeyType::Unknown2, generation)); + } + /* FS */ Result DecryptAndStoreGcKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option) { R_RETURN(DecryptAndStoreDeviceUniqueKey(src, src_size, access_key, key_source, option)); diff --git a/stratosphere/spl/source/spl_es_service.hpp b/stratosphere/spl/source/spl_es_service.hpp index a4cba97f6..57943ec24 100644 --- a/stratosphere/spl/source/spl_es_service.hpp +++ b/stratosphere/spl/source/spl_es_service.hpp @@ -55,6 +55,10 @@ namespace ams::spl { Result LoadPreparedAesKey(s32 keyslot, AccessKey access_key) { R_RETURN(m_manager.LoadPreparedAesKey(keyslot, this, access_key)); } + + Result PrepareEsUnknown2Key(sf::Out 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); diff --git a/stratosphere/spl/source/spl_secure_monitor_manager.cpp b/stratosphere/spl/source/spl_secure_monitor_manager.cpp index e5b899169..c31bae8bf 100644 --- a/stratosphere/spl/source/spl_secure_monitor_manager.cpp +++ b/stratosphere/spl/source/spl_secure_monitor_manager.cpp @@ -121,6 +121,10 @@ namespace ams::spl { 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)); } diff --git a/stratosphere/spl/source/spl_secure_monitor_manager.hpp b/stratosphere/spl/source/spl_secure_monitor_manager.hpp index f54ff5da0..c01311ef3 100644 --- a/stratosphere/spl/source/spl_secure_monitor_manager.hpp +++ b/stratosphere/spl/source/spl_secure_monitor_manager.hpp @@ -52,6 +52,7 @@ namespace ams::spl { 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);