SubStorage in AesXtsFile should be resizable

This commit is contained in:
Alex Barney 2020-07-06 08:38:12 -07:00
parent ff96c8575b
commit 7dd21ae05b
2 changed files with 5 additions and 2 deletions

View file

@ -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<byte> destination);

View file

@ -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);
}