mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-21 02:52:44 +02:00
loader: update to reflect latest 18.0.0 changes
well, this sure is late, whoops
This commit is contained in:
parent
fadec29817
commit
9dc1479dee
@ -16,6 +16,7 @@
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_nca_file_system_driver.hpp>
|
||||
#include <stratosphere/ldr/ldr_platform_id.hpp>
|
||||
|
||||
namespace ams::fssystem {
|
||||
|
||||
@ -25,10 +26,13 @@ namespace ams::fssystem {
|
||||
|
||||
void InvalidateHardwareAesKey();
|
||||
|
||||
const u8 *GetAcidSignatureKeyModulus(bool prod, size_t key_generation);
|
||||
bool IsValidSignatureKeyGeneration(ldr::PlatformId platform, size_t key_generation);
|
||||
|
||||
const u8 *GetAcidSignatureKeyModulus(ldr::PlatformId platform, bool prod, size_t key_generation, bool unk_unused);
|
||||
size_t GetAcidSignatureKeyModulusSize(ldr::PlatformId platform, bool unk_unused);
|
||||
|
||||
const u8 *GetAcidSignatureKeyPublicExponent();
|
||||
|
||||
constexpr inline size_t AcidSignatureKeyModulusSize = NcaCryptoConfiguration::Rsa2048KeyModulusSize;
|
||||
constexpr inline size_t AcidSignatureKeyPublicExponentSize = NcaCryptoConfiguration::Rsa2048KeyPublicExponentSize;
|
||||
|
||||
}
|
||||
|
27
libstratosphere/include/stratosphere/ldr/ldr_platform_id.hpp
Normal file
27
libstratosphere/include/stratosphere/ldr/ldr_platform_id.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 <vapours.hpp>
|
||||
|
||||
namespace ams::ldr {
|
||||
|
||||
/* TODO: Is this really a FS type? What namespace does this actually live inside? */
|
||||
enum PlatformId {
|
||||
PlatformId_Nx = 0,
|
||||
};
|
||||
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
#include <stratosphere/ncm/ncm_ids.hpp>
|
||||
#include <stratosphere/ncm/ncm_program_location.hpp>
|
||||
#include <stratosphere/sf/sf_buffer_tags.hpp>
|
||||
#include <stratosphere/ldr/ldr_platform_id.hpp>
|
||||
|
||||
namespace ams::ldr {
|
||||
|
||||
@ -224,6 +225,7 @@ namespace ams::ldr {
|
||||
|
||||
MetaFlag_OptimizeMemoryAllocation = (1 << 4),
|
||||
MetaFlag_DisableDeviceAddressSpaceMerge = (1 << 5),
|
||||
MetaFlag_EnableAliasRegionExtraSize = (1 << 6),
|
||||
};
|
||||
|
||||
enum AddressSpaceType {
|
||||
|
@ -22,9 +22,11 @@ namespace ams::fssystem {
|
||||
|
||||
constexpr inline const size_t KeySize = crypto::AesDecryptor128::KeySize;
|
||||
|
||||
constexpr inline const size_t AcidSignatureKeyGenerationMax = 1;
|
||||
constexpr inline const size_t NxAcidSignatureKeyGenerationMax = 1;
|
||||
|
||||
constexpr inline const u8 AcidSignatureKeyModulusDev[AcidSignatureKeyGenerationMax + 1][AcidSignatureKeyModulusSize] = {
|
||||
constexpr inline const size_t NxAcidSignatureKeyModulusSize = NcaCryptoConfiguration::Rsa2048KeyModulusSize;
|
||||
|
||||
constexpr inline const u8 NxAcidSignatureKeyModulusDev[NxAcidSignatureKeyGenerationMax + 1][NxAcidSignatureKeyModulusSize] = {
|
||||
{
|
||||
0xD6, 0x34, 0xA5, 0x78, 0x6C, 0x68, 0xCE, 0x5A, 0xC2, 0x37, 0x17, 0xF3, 0x82, 0x45, 0xC6, 0x89,
|
||||
0xE1, 0x2D, 0x06, 0x67, 0xBF, 0xB4, 0x06, 0x19, 0x55, 0x6B, 0x27, 0x66, 0x0C, 0xA4, 0xB5, 0x87,
|
||||
@ -63,7 +65,7 @@ namespace ams::fssystem {
|
||||
}
|
||||
};
|
||||
|
||||
constexpr inline const u8 AcidSignatureKeyModulusProd[AcidSignatureKeyGenerationMax + 1][AcidSignatureKeyModulusSize] = {
|
||||
constexpr inline const u8 NxAcidSignatureKeyModulusProd[NxAcidSignatureKeyGenerationMax + 1][NxAcidSignatureKeyModulusSize] = {
|
||||
{
|
||||
0xDD, 0xC8, 0xDD, 0xF2, 0x4E, 0x6D, 0xF0, 0xCA, 0x9E, 0xC7, 0x5D, 0xC7, 0x7B, 0xAD, 0xFE, 0x7D,
|
||||
0x23, 0x89, 0x69, 0xB6, 0xF2, 0x06, 0xA2, 0x02, 0x88, 0xE1, 0x55, 0x91, 0xAB, 0xCB, 0x4D, 0x50,
|
||||
@ -102,7 +104,7 @@ namespace ams::fssystem {
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(AcidSignatureKeyModulusProd) == sizeof(AcidSignatureKeyModulusDev));
|
||||
static_assert(sizeof(NxAcidSignatureKeyModulusProd) == sizeof(NxAcidSignatureKeyModulusDev));
|
||||
|
||||
constexpr inline const u8 AcidSignatureKeyPublicExponent[] = {
|
||||
0x01, 0x00, 0x01
|
||||
@ -295,10 +297,36 @@ namespace ams::fssystem {
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetAcidSignatureKeyModulus(bool prod, size_t key_generation) {
|
||||
AMS_ASSERT(key_generation <= AcidSignatureKeyGenerationMax);
|
||||
const size_t used_keygen = (key_generation % (AcidSignatureKeyGenerationMax + 1));
|
||||
return prod ? AcidSignatureKeyModulusProd[used_keygen] : AcidSignatureKeyModulusDev[used_keygen];
|
||||
bool IsValidSignatureKeyGeneration(ldr::PlatformId platform, size_t key_generation) {
|
||||
switch (platform) {
|
||||
case ldr::PlatformId_Nx:
|
||||
return key_generation <= NxAcidSignatureKeyGenerationMax;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetAcidSignatureKeyModulus(ldr::PlatformId platform, bool prod, size_t key_generation, bool unk_unused) {
|
||||
AMS_ASSERT(IsValidSignatureKeyGeneration(platform, key_generation));
|
||||
AMS_UNUSED(unk_unused);
|
||||
|
||||
switch (platform) {
|
||||
case ldr::PlatformId_Nx:
|
||||
{
|
||||
const size_t used_keygen = (key_generation % (NxAcidSignatureKeyGenerationMax + 1));
|
||||
return prod ? NxAcidSignatureKeyModulusProd[used_keygen] : NxAcidSignatureKeyModulusDev[used_keygen];
|
||||
}
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
size_t GetAcidSignatureKeyModulusSize(ldr::PlatformId platform, bool unk_unused) {
|
||||
AMS_UNUSED(unk_unused);
|
||||
|
||||
switch (platform) {
|
||||
case ldr::PlatformId_Nx:
|
||||
return NxAcidSignatureKeyModulusSize;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetAcidSignatureKeyPublicExponent() {
|
||||
|
@ -34,6 +34,8 @@ namespace ams::ldr {
|
||||
R_DEFINE_ERROR_RESULT(InvalidAcidSignature, 11);
|
||||
R_DEFINE_ERROR_RESULT(InvalidNcaSignature, 12);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(InvalidPlatformId, 14);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 51);
|
||||
R_DEFINE_ERROR_RESULT(InvalidNroImage, 52);
|
||||
R_DEFINE_ERROR_RESULT(InvalidNrrImage, 53);
|
||||
|
Loading…
Reference in New Issue
Block a user