mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Skeleton AesXtsFileSystemImpl
This commit is contained in:
parent
a3a226599b
commit
245dff0e6d
2 changed files with 334 additions and 0 deletions
157
src/LibHac/FsSystem/AesXtsFile.cs
Normal file
157
src/LibHac/FsSystem/AesXtsFile.cs
Normal file
|
@ -0,0 +1,157 @@
|
|||
// ReSharper disable UnusedMember.Local UnusedType.Local
|
||||
#pragma warning disable CS0169 // Field is never used
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.FixedArrays;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
namespace LibHac.FsSystem;
|
||||
|
||||
public interface IAesXtsFileHeader
|
||||
{
|
||||
public interface IFileSystemContext
|
||||
{
|
||||
}
|
||||
|
||||
public interface IFileContext
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public struct AesXtsFileHeaderV0 : IAesXtsFileHeader
|
||||
{
|
||||
public struct FileSystemContext : IAesXtsFileHeader.IFileSystemContext
|
||||
{
|
||||
public Array16<byte> MacKey;
|
||||
public Array16<byte> EncryptionKeyGenerationKey;
|
||||
public RandomDataGenerator GenerateRandomData;
|
||||
}
|
||||
|
||||
public struct FileContext : IAesXtsFileHeader.IFileContext
|
||||
{
|
||||
public Array16<byte> MacKey;
|
||||
public Array32<byte> Keys;
|
||||
}
|
||||
|
||||
public readonly bool HasValidSignature()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static bool IsValidSignature(uint signature)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Create(long fileSize, ref FileSystemContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private readonly void ComputeMac(Span<byte> outMac, ReadOnlySpan<byte> macKey)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private readonly void ComputeKeys(Span<byte> outKeys, ReadOnlySpan<byte> path,
|
||||
ReadOnlySpan<byte> encryptionKeyGenerationKey)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void Encrypt(ReadOnlySpan<byte> keys)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void Decrypt(ReadOnlySpan<byte> keys)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result SignAndEncryptKeys(ReadOnlySpan<byte> path, in FileSystemContext fsContext)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result DecryptKeysAndVerify(ref FileContext fileContext, ReadOnlySpan<byte> path, in FileSystemContext fsContext)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result Update(long fileSize, ref FileContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result CreateStorage(ref UniqueRef<IStorage> outStorage, in FileSystemContext fsContext,
|
||||
IStorage baseStorage, ReadOnlySpan<byte> iv, int blockSize)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class AesXtsFile<THeader, TFileContext, TFsContext> : IFile where THeader : IAesXtsFileHeader
|
||||
where TFileContext : IAesXtsFileHeader.IFileContext
|
||||
where TFsContext : IAesXtsFileHeader.IFileSystemContext
|
||||
{
|
||||
private UniqueRef<IFile> _baseFile;
|
||||
private UniqueRef<IStorage> _fileStorage;
|
||||
private UniqueRef<IStorage> _fileSubStorage;
|
||||
private UniqueRef<IStorage> _aesXtsStorage;
|
||||
private UniqueRef<IStorage> _alignmentMatchingStorage;
|
||||
private UniqueRef<IFile> _storageFile;
|
||||
private long _fileSize;
|
||||
private TFileContext _context;
|
||||
private OpenMode _openMode;
|
||||
|
||||
public AesXtsFile()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result Initialize(OpenMode mode, ref UniqueRef<IFile> baseFile, ReadOnlySpan<byte> path,
|
||||
in TFsContext fsContext, ReadOnlySpan<byte> iv, int blockSize)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoRead(out long bytesRead, long offset, Span<byte> destination, in ReadOption option)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoWrite(long offset, ReadOnlySpan<byte> source, in WriteOption option)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoFlush()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoSetSize(long size)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoOperateRange(Span<byte> outBuffer, OperationId operationId, long offset, long size,
|
||||
ReadOnlySpan<byte> inBuffer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class AesXtsFileV0 : AesXtsFile<AesXtsFileHeaderV0, AesXtsFileHeaderV0.FileContext, AesXtsFileHeaderV0.FileSystemContext>;
|
177
src/LibHac/FsSystem/AesXtsFileSystem.cs
Normal file
177
src/LibHac/FsSystem/AesXtsFileSystem.cs
Normal file
|
@ -0,0 +1,177 @@
|
|||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
namespace LibHac.FsSystem.Impl
|
||||
{
|
||||
public class AesXtsFileSystemDirectory<THeader> : IDirectory where THeader : IAesXtsFileHeader
|
||||
{
|
||||
private IFileSystem _baseFileSystem;
|
||||
private UniqueRef<IDirectory> _baseDirectory;
|
||||
private OpenDirectoryMode _openMode;
|
||||
private Path.Stored _path;
|
||||
|
||||
public AesXtsFileSystemDirectory(IFileSystem fileSystem, ref UniqueRef<IDirectory> baseDirectory,
|
||||
OpenDirectoryMode mode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Result Initialize(ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoGetEntryCount(out long entryCount)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoRead(out long entriesRead, Span<DirectoryEntry> entryBuffer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace LibHac.FsSystem
|
||||
{
|
||||
public class AesXtsFileSystemImpl<THeader, TFileContext, TFsContext> : IFileSystem
|
||||
where THeader : IAesXtsFileHeader
|
||||
where TFileContext : IAesXtsFileHeader.IFileContext
|
||||
where TFsContext : IAesXtsFileHeader.IFileSystemContext
|
||||
{
|
||||
private SharedRef<IFileSystem> _baseFileSystem;
|
||||
private TFsContext _context;
|
||||
private int _xtsBlockSize;
|
||||
|
||||
public AesXtsFileSystemImpl(ref readonly SharedRef<IFileSystem> baseFileSystem, ref TFsContext context,
|
||||
int xtsBlockSize)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Result CheckPathFormat(ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoCreateFile(ref readonly Path path, long size, CreateFileOptions option)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoDeleteFile(ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoCreateDirectory(ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoDeleteDirectory(ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoDeleteDirectoryRecursively(ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoCleanDirectoryRecursively(ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoRenameFile(ref readonly Path currentPath, ref readonly Path newPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoRenameDirectory(ref readonly Path currentPath, ref readonly Path newPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoGetEntryType(out DirectoryEntryType entryType, ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoGetFreeSpaceSize(out long freeSpace, ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoGetTotalSpaceSize(out long totalSpace, ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoOpenFile(ref UniqueRef<IFile> outFile, ref readonly Path path, OpenMode mode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoOpenDirectory(ref UniqueRef<IDirectory> outDirectory, ref readonly Path path,
|
||||
OpenDirectoryMode mode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoCommit()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoCommitProvisionally(long counter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoRollback()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Result DoQueryEntry(Span<byte> outBuffer, ReadOnlySpan<byte> inBuffer, QueryId queryId,
|
||||
ref readonly Path path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Result DecryptHeader(ref THeader header, ref readonly Path path, ReadOnlySpan<byte> keyPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Result EncryptHeader(ref THeader header, ref readonly Path path, ReadOnlySpan<byte> keyPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AesXtsFileSystemV0 : AesXtsFileSystemImpl<AesXtsFileHeaderV0, AesXtsFileHeaderV0.FileContext,
|
||||
AesXtsFileHeaderV0.FileSystemContext>
|
||||
{
|
||||
public AesXtsFileSystemV0(ref readonly SharedRef<IFileSystem> baseFileSystem,
|
||||
ref AesXtsFileHeaderV0.FileSystemContext context, int xtsBlockSize) : base(in baseFileSystem, ref context,
|
||||
xtsBlockSize)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue