private void WriteXtsHeader(AesXtsFileHeader header, string filePath, string keyPath) { Debug.Assert(PathTools.IsNormalized(filePath.AsSpan())); Debug.Assert(PathTools.IsNormalized(keyPath.AsSpan())); header.EncryptHeader(keyPath, KekSource, ValidationKey); BaseFileSystem.OpenFile(out IFile file, filePath.ToU8Span(), OpenMode.ReadWrite); using (file) { file.Write(0, header.ToBytes(false), WriteOption.Flush).ThrowIfFailure(); } }
public PathParser(ReadOnlySpan <byte> path) { Debug.Assert(PathTools.IsNormalized(path)); if (path.Length < 1 || path[0] != '/') { throw new ArgumentException("Path must begin with a '/'"); } _path = path; _offset = 0; _length = 0; _finished = path.Length == 1; }
private bool TryReadXtsHeader(string filePath, string keyPath, out AesXtsFileHeader header) { Debug.Assert(PathTools.IsNormalized(filePath.AsSpan())); Debug.Assert(PathTools.IsNormalized(keyPath.AsSpan())); header = null; Result rc = BaseFileSystem.OpenFile(out IFile file, filePath.ToU8Span(), OpenMode.Read); if (rc.IsFailure()) { return(false); } using (file) { header = new AesXtsFileHeader(file); return(header.TryDecryptHeader(keyPath, KekSource, ValidationKey)); } }