Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        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));
            }
        }