diff --git a/src/LibHac/Fs/IStorage.cs b/src/LibHac/Fs/IStorage.cs index 9c023322..f4d1885c 100644 --- a/src/LibHac/Fs/IStorage.cs +++ b/src/LibHac/Fs/IStorage.cs @@ -126,7 +126,7 @@ namespace LibHac.Fs { return offset >= 0 && size >= 0 && - offset <= offset - size; + offset <= offset + size; } protected abstract Result DoRead(long offset, Span destination); diff --git a/src/LibHac/FsSystem/AesXtsFile.cs b/src/LibHac/FsSystem/AesXtsFile.cs index f71cab96..1f08138a 100644 --- a/src/LibHac/FsSystem/AesXtsFile.cs +++ b/src/LibHac/FsSystem/AesXtsFile.cs @@ -42,7 +42,10 @@ namespace LibHac.FsSystem ThrowHelper.ThrowResult(ResultFs.AesXtsFileTooShort.Value, "NAX0 key derivation failed."); } - IStorage encStorage = BaseFile.AsStorage().Slice(HeaderLength, Utilities.AlignUp(Header.Size, 0x10)); + var fileStorage = new FileStorage2(baseFile); + var encStorage = new SubStorage(fileStorage, HeaderLength, fileSize - HeaderLength); + encStorage.SetResizable(true); + BaseStorage = new CachedStorage(new Aes128XtsStorage(encStorage, Header.DecryptedKey1, Header.DecryptedKey2, BlockSize, true), 4, true); }