sf: Change interface definition methodology (#1074)
* sf: Begin experimenting with new interface declaration format * sf: convert fs interfaces to new format * sf: finish conversion of libstrat to new definitions * sf: convert loader to new format * sf: convert spl to new format * sf: update ncm for new format * sf: convert pm to new format * sf: convert ro/sm to new format * sf: update fatal for new format * sf: support building dmnt under new scheme * sf: update ams.mitm for new format * sf: correct invocation def for pointer holder * fs: correct 10.x+ user bindings for Get*SpaceSize
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
#include <stratosphere/spl/impl/spl_general_interface.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_CRYPTO_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SPL_I_GENERAL_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, GenerateAesKek, (sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation, u32 option)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, LoadAesKey, (s32 keyslot, AccessKey access_key, KeySource key_source)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, GenerateAesKey, (sf::Out<AesKey> out_key, AccessKey access_key, KeySource key_source)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 14, Result, DecryptAesKey, (sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 option)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 15, Result, ComputeCtr, (const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, IvCtr iv_ctr)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 16, Result, ComputeCmac, (sf::Out<Cmac> out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 21, Result, AllocateAesKeySlot, (sf::Out<s32> out_keyslot)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 22, Result, DeallocateAesKeySlot, (s32 keyslot)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 23, Result, GetAesKeySlotAvailableEvent, (sf::OutCopyHandle out_hnd))
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ICryptoInterface, AMS_SPL_I_CRYPTO_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_DEPRECATED_GENERAL_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, GetConfig, (sf::Out<u64> out, u32 which)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, ModularExponentiate, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, GenerateAesKek, (sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation, u32 option)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, LoadAesKey, (s32 keyslot, AccessKey access_key, KeySource key_source)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, GenerateAesKey, (sf::Out<AesKey> out_key, AccessKey access_key, KeySource key_source)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, SetConfig, (u32 which, u64 value)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 7, Result, GenerateRandomBytes, (const sf::OutPointerBuffer &out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, DecryptAndStoreGcKey, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, DecryptGcMessage, (sf::Out<u32> out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 11, Result, IsDevelopment, (sf::Out<bool> is_dev)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 12, Result, GenerateSpecificAesKey, (sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 which)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 13, Result, DecryptDeviceUniqueData, (const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 14, Result, DecryptAesKey, (sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 option)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 15, Result, ComputeCtrDeprecated, (const sf::OutBuffer &out_buf, s32 keyslot, const sf::InBuffer &in_buf, IvCtr iv_ctr), hos::Version_1_0_0, hos::Version_1_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 15, Result, ComputeCtr, (const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, IvCtr iv_ctr), hos::Version_2_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 16, Result, ComputeCmac, (sf::Out<Cmac> out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 17, Result, LoadEsDeviceKey, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 18, Result, PrepareEsTitleKeyDeprecated, (sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest), hos::Version_1_0_0, hos::Version_2_3_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 18, Result, PrepareEsTitleKey, (sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), hos::Version_3_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 19, Result, LoadPreparedAesKey, (s32 keyslot, AccessKey access_key)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 20, Result, PrepareCommonEsTitleKeyDeprecated, (sf::Out<AccessKey> out_access_key, KeySource key_source), hos::Version_2_0_0, hos::Version_2_3_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 20, Result, PrepareCommonEsTitleKey, (sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation), hos::Version_3_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 22, Result, DeallocateAesKeySlot, (s32 keyslot)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 23, Result, GetAesKeySlotAvailableEvent, (sf::OutCopyHandle out_hnd)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 24, Result, SetBootReason, (spl::BootReasonValue boot_reason), hos::Version_3_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 25, Result, GetBootReason, (sf::Out<spl::BootReasonValue> out), hos::Version_3_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IDeprecatedGeneralInterface, AMS_SPL_I_DEPRECATED_GENERAL_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
#include <stratosphere/spl/impl/spl_crypto_interface.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_DEVICE_UNIQUE_DATA_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SPL_I_CRYPTO_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 13, Result, DecryptDeviceUniqueDataDeprecated, (const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option), hos::Version_Min, hos::Version_4_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 13, Result, DecryptDeviceUniqueData, (const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source), hos::Version_5_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IDeviceUniqueDataInterface, AMS_SPL_I_DEVICE_UNIQUE_DATA_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
#include <stratosphere/spl/impl/spl_device_unique_data_interface.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_ES_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SPL_I_DEVICE_UNIQUE_DATA_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 17, Result, LoadEsDeviceKeyDeprecated, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option), hos::Version_Min, hos::Version_4_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 17, Result, LoadEsDeviceKey, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source), hos::Version_5_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 18, Result, PrepareEsTitleKey, (sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 20, Result, PrepareCommonEsTitleKey, (sf::Out<AccessKey> out_access_key, KeySource key_source, u32 generation), hos::Version_2_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 28, Result, DecryptAndStoreDrmDeviceCertKey, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource 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), hos::Version_5_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 31, Result, PrepareEsArchiveKey, (sf::Out<AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), hos::Version_6_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 32, Result, LoadPreparedAesKey, (s32 keyslot, AccessKey access_key), hos::Version_6_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IEsInterface, AMS_SPL_I_ES_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
#include <stratosphere/spl/impl/spl_crypto_interface.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_FS_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SPL_I_CRYPTO_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, DecryptAndStoreGcKeyDeprecated, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source, u32 option), hos::Version_Min, hos::Version_4_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, DecryptAndStoreGcKey, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source), hos::Version_5_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, DecryptGcMessage, (sf::Out<u32> out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 12, Result, GenerateSpecificAesKey, (sf::Out<AesKey> out_key, KeySource key_source, u32 generation, u32 which)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 19, Result, LoadPreparedAesKey, (s32 keyslot, AccessKey access_key)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 31, Result, GetPackage2Hash, (const sf::OutPointerBuffer &dst), hos::Version_5_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IFsInterface, AMS_SPL_I_FS_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_GENERAL_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, GetConfig, (sf::Out<u64> out, u32 which)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, ModularExponentiate, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, SetConfig, (u32 which, u64 value)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 7, Result, GenerateRandomBytes, (const sf::OutPointerBuffer &out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 11, Result, IsDevelopment, (sf::Out<bool> is_dev)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 24, Result, SetBootReason, (spl::BootReasonValue boot_reason), hos::Version_3_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 25, Result, GetBootReason, (sf::Out<spl::BootReasonValue> out), hos::Version_3_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IGeneralInterface, AMS_SPL_I_GENERAL_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
#include <stratosphere/spl/impl/spl_device_unique_data_interface.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_MANU_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SPL_I_DEVICE_UNIQUE_DATA_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 30, 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)) \
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IManuInterface, AMS_SPL_I_MANU_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_RANDOM_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, GenerateRandomBytes, (const sf::OutBuffer &out))
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IRandomInterface, AMS_SPL_I_RANDOM_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 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 <vapours.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
#include <stratosphere/spl/impl/spl_device_unique_data_interface.hpp>
|
||||
|
||||
namespace ams::spl::impl {
|
||||
|
||||
#define AMS_SPL_I_SSL_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SPL_I_DEVICE_UNIQUE_DATA_INTERFACE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 26, Result, DecryptAndStoreSslClientCertKey, (const sf::InPointerBuffer &src, AccessKey access_key, KeySource key_source), hos::Version_5_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 27, Result, ModularExponentiateWithSslClientCertKey, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod), hos::Version_5_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ISslInterface, AMS_SPL_I_SSL_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
}
|
||||
@@ -20,54 +20,47 @@
|
||||
namespace ams::spl::smc {
|
||||
|
||||
/* Helpers for converting arguments. */
|
||||
inline u32 GetCryptAesMode(CipherMode mode, u32 keyslot) {
|
||||
inline u32 GetComputeAesMode(CipherMode mode, u32 keyslot) {
|
||||
return static_cast<u32>((static_cast<u32>(mode) << 4) | (keyslot & 7));
|
||||
}
|
||||
|
||||
inline u32 GetUnwrapEsKeyOption(EsKeyType type, u32 generation) {
|
||||
inline u32 GetPrepareEsDeviceUniqueKeyOption(EsCommonKeyType type, u32 generation) {
|
||||
return static_cast<u32>((static_cast<u32>(type) << 6) | (generation & 0x3F));
|
||||
}
|
||||
|
||||
/* Functions. */
|
||||
Result SetConfig(SplConfigItem which, const u64 *value, size_t num_qwords);
|
||||
Result GetConfig(u64 *out, size_t num_qwords, SplConfigItem which);
|
||||
Result CheckStatus(Result *out, AsyncOperationKey op);
|
||||
Result GetResult(Result *out, void *out_buf, size_t out_buf_size, AsyncOperationKey op);
|
||||
Result ExpMod(AsyncOperationKey *out_op, const void *base, const void *exp, size_t exp_size, const void *mod);
|
||||
Result SetConfig(spl::ConfigItem which, const u64 *value, size_t num_qwords);
|
||||
Result GetConfig(u64 *out, size_t num_qwords, spl::ConfigItem which);
|
||||
Result GetResult(Result *out, AsyncOperationKey op);
|
||||
Result GetResultData(Result *out, void *out_buf, size_t out_buf_size, AsyncOperationKey op);
|
||||
Result ModularExponentiate(AsyncOperationKey *out_op, const void *base, const void *exp, size_t exp_size, const void *mod);
|
||||
Result GenerateRandomBytes(void *out, size_t size);
|
||||
Result GenerateAesKek(AccessKey *out, const KeySource &source, u32 generation, u32 option);
|
||||
Result LoadAesKey(u32 keyslot, const AccessKey &access_key, const KeySource &source);
|
||||
Result CryptAes(AsyncOperationKey *out_op, u32 mode, const IvCtr &iv_ctr, u32 dst_addr, u32 src_addr, size_t size);
|
||||
Result ComputeAes(AsyncOperationKey *out_op, u32 mode, const IvCtr &iv_ctr, u32 dst_addr, u32 src_addr, size_t size);
|
||||
Result GenerateSpecificAesKey(AesKey *out_key, const KeySource &source, u32 generation, u32 which);
|
||||
Result ComputeCmac(Cmac *out_mac, u32 keyslot, const void *data, size_t size);
|
||||
Result ReEncryptRsaPrivateKey(void *data, size_t size, const AccessKey &access_key_dec, const KeySource &source_dec, const AccessKey &access_key_enc, const KeySource &source_enc, u32 option);
|
||||
Result DecryptOrImportRsaPrivateKey(void *data, size_t size, const AccessKey &access_key, const KeySource &source, DecryptOrImportMode mode);
|
||||
Result SecureExpMod(AsyncOperationKey *out_op, const void *base, const void *mod, SecureExpModMode mode);
|
||||
Result UnwrapTitleKey(AsyncOperationKey *out_op, const void *base, const void *mod, const void *label_digest, size_t label_digest_size, u32 option);
|
||||
Result LoadTitleKey(u32 keyslot, const AccessKey &access_key);
|
||||
Result UnwrapCommonTitleKey(AccessKey *out, const KeySource &source, u32 generation);
|
||||
Result ReencryptDeviceUniqueData(void *data, size_t size, const AccessKey &access_key_dec, const KeySource &source_dec, const AccessKey &access_key_enc, const KeySource &source_enc, u32 option);
|
||||
Result DecryptDeviceUniqueData(void *data, size_t size, const AccessKey &access_key, const KeySource &source, DeviceUniqueDataMode mode);
|
||||
Result ModularExponentiateWithStorageKey(AsyncOperationKey *out_op, const void *base, const void *mod, ModularExponentiateWithStorageKeyMode mode);
|
||||
Result PrepareEsDeviceUniqueKey(AsyncOperationKey *out_op, const void *base, const void *mod, const void *label_digest, size_t label_digest_size, u32 option);
|
||||
Result LoadPreparedAesKey(u32 keyslot, const AccessKey &access_key);
|
||||
Result PrepareCommonEsTitleKey(AccessKey *out, const KeySource &source, u32 generation);
|
||||
|
||||
/* Deprecated functions. */
|
||||
Result ImportEsKey(const void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
|
||||
Result DecryptRsaPrivateKey(size_t *out_size, void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
|
||||
Result ImportSecureExpModKey(const void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
|
||||
Result LoadEsDeviceKey(const void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
|
||||
Result DecryptDeviceUniqueData(size_t *out_size, void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
|
||||
Result DecryptAndStoreGcKey(const void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
|
||||
|
||||
/* Atmosphere functions. */
|
||||
Result AtmosphereCopyToIram(uintptr_t iram_dst, const void *dram_src, size_t size);
|
||||
Result AtmosphereCopyFromIram(void *dram_dst, uintptr_t iram_src, size_t size);
|
||||
Result AtmosphereReadWriteRegister(uint64_t address, uint32_t mask, uint32_t value, uint32_t *out_value);
|
||||
Result AtmosphereWriteAddress(void *dst, const void *src, size_t size);
|
||||
Result AtmosphereGetEmummcConfig(void *out_config, void *out_paths, u32 storage_id);
|
||||
|
||||
/* Helpers. */
|
||||
inline Result SetConfig(SplConfigItem which, const u64 value) {
|
||||
inline Result SetConfig(spl::ConfigItem which, const u64 value) {
|
||||
return SetConfig(which, &value, 1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Result AtmosphereWriteAddress(void *dst, const T value) {
|
||||
static_assert(std::is_integral<T>::value && sizeof(T) <= 8 && (sizeof(T) & (sizeof(T) - 1)) == 0, "AtmosphereWriteAddress requires integral type.");
|
||||
return AtmosphereWriteAddress(dst, &value, sizeof(T));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,35 +22,34 @@ namespace ams::spl {
|
||||
namespace smc {
|
||||
|
||||
enum class FunctionId : u32 {
|
||||
SetConfig = 0xC3000401,
|
||||
GetConfig = 0xC3000002,
|
||||
CheckStatus = 0xC3000003,
|
||||
GetResult = 0xC3000404,
|
||||
ExpMod = 0xC3000E05,
|
||||
GenerateRandomBytes = 0xC3000006,
|
||||
GenerateAesKek = 0xC3000007,
|
||||
LoadAesKey = 0xC3000008,
|
||||
CryptAes = 0xC3000009,
|
||||
GenerateSpecificAesKey = 0xC300000A,
|
||||
ComputeCmac = 0xC300040B,
|
||||
ReEncryptRsaPrivateKey = 0xC300D60C,
|
||||
DecryptOrImportRsaPrivateKey = 0xC300100D,
|
||||
SetConfig = 0xC3000401,
|
||||
GetConfig = 0xC3000002,
|
||||
GetResult = 0xC3000003,
|
||||
GetResultData = 0xC3000404,
|
||||
ModularExponentiate = 0xC3000E05,
|
||||
GenerateRandomBytes = 0xC3000006,
|
||||
GenerateAesKek = 0xC3000007,
|
||||
LoadAesKey = 0xC3000008,
|
||||
ComputeAes = 0xC3000009,
|
||||
GenerateSpecificAesKey = 0xC300000A,
|
||||
ComputeCmac = 0xC300040B,
|
||||
ReencryptDeviceUniqueData = 0xC300D60C,
|
||||
DecryptDeviceUniqueData = 0xC300100D,
|
||||
|
||||
SecureExpMod = 0xC300060F,
|
||||
UnwrapTitleKey = 0xC3000610,
|
||||
LoadTitleKey = 0xC3000011,
|
||||
UnwrapCommonTitleKey = 0xC3000012,
|
||||
ModularExponentiateWithStorageKey = 0xC300060F,
|
||||
PrepareEsDeviceUniqueKey = 0xC3000610,
|
||||
LoadPreparedAesKey = 0xC3000011,
|
||||
PrepareCommonEsTitleKey = 0xC3000012,
|
||||
|
||||
/* Deprecated functions. */
|
||||
ImportEsKey = 0xC300100C,
|
||||
DecryptRsaPrivateKey = 0xC300100D,
|
||||
ImportSecureExpModKey = 0xC300100E,
|
||||
LoadEsDeviceKey = 0xC300100C,
|
||||
DecryptAndStoreGcKey = 0xC300100E,
|
||||
|
||||
/* Atmosphere functions. */
|
||||
AtmosphereIramCopy = 0xF0000201,
|
||||
AtmosphereReadWriteRegister = 0xF0000002,
|
||||
AtmosphereWriteAddress = 0xF0000003,
|
||||
AtmosphereGetEmummcConfig = 0xF0000404,
|
||||
AtmosphereIramCopy = 0xF0000201,
|
||||
AtmosphereReadWriteRegister = 0xF0000002,
|
||||
|
||||
AtmosphereGetEmummcConfig = 0xF0000404,
|
||||
};
|
||||
|
||||
enum class Result {
|
||||
@@ -61,6 +60,7 @@ namespace ams::spl {
|
||||
NoAsyncOperation = 4,
|
||||
InvalidAsyncOperation = 5,
|
||||
NotPermitted = 6,
|
||||
NotInitialized = 7,
|
||||
};
|
||||
|
||||
constexpr inline ::ams::Result ConvertResult(Result smc_result) {
|
||||
@@ -69,11 +69,10 @@ namespace ams::spl {
|
||||
|
||||
/* Convert to the list of known SecureMonitorErrors. */
|
||||
const auto converted = R_MAKE_NAMESPACE_RESULT(::ams::spl, static_cast<u32>(smc_result));
|
||||
if (spl::ResultSecureMonitorError::Includes(converted)) {
|
||||
return converted;
|
||||
}
|
||||
R_UNLESS(spl::ResultSecureMonitorError::Includes(converted), spl::ResultUnknownSecureMonitorError());
|
||||
|
||||
return spl::ResultUnknownSecureMonitorError();
|
||||
/* Return the error. */
|
||||
return converted;
|
||||
}
|
||||
|
||||
enum class CipherMode {
|
||||
@@ -82,23 +81,23 @@ namespace ams::spl {
|
||||
Ctr = 2,
|
||||
};
|
||||
|
||||
enum class DecryptOrImportMode {
|
||||
DecryptRsaPrivateKey = 0,
|
||||
ImportLotusKey = 1,
|
||||
ImportEsKey = 2,
|
||||
ImportSslKey = 3,
|
||||
ImportDrmKey = 4,
|
||||
enum class DeviceUniqueDataMode {
|
||||
DecryptDeviceUniqueData = 0,
|
||||
DecryptAndStoreGcKey = 1,
|
||||
DecryptAndStoreEsDeviceKey = 2,
|
||||
DecryptAndStoreSslKey = 3,
|
||||
DecryptAndStoreDrmDeviceCertKey = 4,
|
||||
};
|
||||
|
||||
enum class SecureExpModMode {
|
||||
Lotus = 0,
|
||||
Ssl = 1,
|
||||
Drm = 2,
|
||||
enum class ModularExponentiateWithStorageKeyMode {
|
||||
Gc = 0,
|
||||
Ssl = 1,
|
||||
DrmDeviceCert = 2,
|
||||
};
|
||||
|
||||
enum class EsKeyType {
|
||||
TitleKey = 0,
|
||||
ElicenseKey = 1,
|
||||
enum class EsCommonKeyType {
|
||||
TitleKey = 0,
|
||||
ArchiveKey = 1,
|
||||
};
|
||||
|
||||
struct AsyncOperationKey {
|
||||
@@ -196,23 +195,23 @@ namespace ams::spl {
|
||||
|
||||
enum class ConfigItem : u32 {
|
||||
/* Standard config items. */
|
||||
DisableProgramVerification = 1,
|
||||
DramId = 2,
|
||||
SecurityEngineIrqNumber = 3,
|
||||
FuseVersion = 4,
|
||||
HardwareType = 5,
|
||||
HardwareState = 6,
|
||||
IsRecoveryBoot = 7,
|
||||
DeviceId = 8,
|
||||
BootReason = 9,
|
||||
MemoryMode = 10,
|
||||
IsDevelopmentFunctionEnabled = 11,
|
||||
KernelConfiguration = 12,
|
||||
IsChargerHiZModeEnabled = 13,
|
||||
IsQuest = 14,
|
||||
RegulatorType = 15,
|
||||
DeviceUniqueKeyGeneration = 16,
|
||||
Package2Hash = 17,
|
||||
DisableProgramVerification = 1,
|
||||
DramId = 2,
|
||||
SecurityEngineInterruptNumber = 3,
|
||||
FuseVersion = 4,
|
||||
HardwareType = 5,
|
||||
HardwareState = 6,
|
||||
IsRecoveryBoot = 7,
|
||||
DeviceId = 8,
|
||||
BootReason = 9,
|
||||
MemoryMode = 10,
|
||||
IsDevelopmentFunctionEnabled = 11,
|
||||
KernelConfiguration = 12,
|
||||
IsChargerHiZModeEnabled = 13,
|
||||
QuestState = 14,
|
||||
RegulatorType = 15,
|
||||
DeviceUniqueKeyGeneration = 16,
|
||||
Package2Hash = 17,
|
||||
|
||||
/* Extension config items for exosphere. */
|
||||
ExosphereApiVersion = 65000,
|
||||
|
||||
Reference in New Issue
Block a user