Add support for uninitialized movable

This commit is contained in:
PabloMK7 2025-03-17 19:19:38 +01:00 committed by OpenSauce
parent 66d8e58dcd
commit 007b809ad7
2 changed files with 23 additions and 7 deletions

View File

@ -158,13 +158,14 @@ SecureDataLoadStatus LoadMovable() {
if (!file.IsOpen()) {
return SecureDataLoadStatus::IOError;
}
if (file.GetSize() != sizeof(MovableSedFull)) {
if (file.GetSize() == sizeof(MovableSed)) {
LOG_WARNING(HW, "Uninitialized movable.sed files are not supported");
}
std::size_t size = file.GetSize();
if (size != sizeof(MovableSedFull) && size != sizeof(MovableSed)) {
return SecureDataLoadStatus::Invalid;
}
if (file.ReadBytes(&movable, sizeof(MovableSedFull)) != sizeof(MovableSedFull)) {
std::memset(&movable, 0, sizeof(movable));
if (file.ReadBytes(&movable, size) != size) {
movable.Invalidate();
return SecureDataLoadStatus::IOError;
}
@ -172,7 +173,7 @@ SecureDataLoadStatus LoadMovable() {
HW::AES::InitKeys();
movable_signature_valid = movable.VerifySignature();
if (!movable_signature_valid) {
LOG_WARNING(HW, "LocalFriendCodeSeed_B signature check failed");
LOG_WARNING(HW, "movable.sed signature check failed");
}
return movable_signature_valid ? SecureDataLoadStatus::Loaded

View File

@ -66,7 +66,10 @@ struct MovableSed {
static constexpr std::array<u8, 0x4> seed_magic{0x53, 0x45, 0x45, 0x44};
std::array<u8, 0x4> magic;
u32 seed_info;
u8 unk0;
u8 is_full;
u8 unk1;
u8 unk2;
LocalFriendCodeSeedB lfcs;
std::array<u8, 0x8> key_y;
@ -79,6 +82,10 @@ struct MovableSed {
}
bool VerifySignature() const;
bool IsFull() {
return is_full != 0;
}
};
static_assert(sizeof(MovableSed) == 0x120);
@ -101,6 +108,14 @@ struct MovableSedFull {
// TODO(PabloMK7): Implement AES MAC verification
return body.sed.VerifySignature();
}
bool IsFull() {
return body.sed.IsFull();
}
size_t GetRealSize() {
return IsFull() ? sizeof(MovableSedFull) : sizeof(MovableSed);
}
};
static_assert(sizeof(MovableSedFull) == 0x140);