Add SetSize to AesXtsFileHeader

This commit is contained in:
Alex Barney 2019-02-10 16:58:21 -06:00
parent b1fd90dc4d
commit 0b79dfe93a
5 changed files with 22 additions and 4 deletions

View file

@ -72,6 +72,8 @@ namespace LibHac.IO
public override void SetSize(long size)
{
Header.SetSize(size, VerificationKey);
throw new NotImplementedException();
}
}

View file

@ -13,7 +13,7 @@ namespace LibHac.IO
public uint Magic { get; }
public byte[] EncryptedKey1 { get; } = new byte[0x10];
public byte[] EncryptedKey2 { get; } = new byte[0x10];
public long Size { get; }
public long Size { get; private set; }
public byte[] DecryptedKey1 { get; } = new byte[0x10];
public byte[] DecryptedKey2 { get; } = new byte[0x10];
@ -63,6 +63,12 @@ namespace LibHac.IO
return Util.ArraysEqual(hmac, Signature);
}
public void SetSize(long size, byte[] verificationKey)
{
Size = size;
Signature = CalculateHmac(verificationKey);
}
private void DecryptKeys()
{
Crypto.DecryptEcb(Kek1, EncryptedKey1, DecryptedKey1, 0x10);

View file

@ -35,7 +35,7 @@ namespace LibHac.IO
destFs.CreateFile(subDstPath, entry.Size, options);
using (IFile srcFile = sourceFs.OpenFile(subSrcPath, OpenMode.Read))
using (IFile dstFile = destFs.OpenFile(subDstPath, OpenMode.Write))
using (IFile dstFile = destFs.OpenFile(subDstPath, OpenMode.Write | OpenMode.Append))
{
logger?.LogMessage(subSrcPath);
srcFile.CopyTo(dstFile, logger);

View file

@ -6,9 +6,19 @@ namespace LibHac.IO
{
private string BasePath { get; }
/// <summary>
/// Opens a directory on local storage as an <see cref="IFileSystem"/>.
/// The directory will be created if it does not exist.
/// </summary>
/// <param name="basePath">The path that will be the root of the <see cref="LocalFileSystem"/>.</param>
public LocalFileSystem(string basePath)
{
BasePath = Path.GetFullPath(basePath);
if (!Directory.Exists(BasePath))
{
Directory.CreateDirectory(BasePath);
}
}
internal string ResolveLocalPath(string path)

View file

@ -268,13 +268,13 @@ namespace LibHac
Control,
Manual,
Data,
AocData
PublicData
}
public enum DistributionType
{
Download,
Gamecard
GameCard
}
public enum NcaEncryptionType