/// <summary>
        /// Creates a new stream
        /// </summary>
        /// <param name="baseStream">The base stream</param>
        /// <param name="xts">The xts transform</param>
        /// <param name="sectorSize">Sector size</param>
        public XTSWriteOnlyStream(Stream baseStream, Xts xts, int sectorSize = DefaultSectorSize)
        {
            _baseStream = baseStream;

            _encryptor = xts.CreateEncryptor();

            _sectorSize      = sectorSize;
            _encriptedBuffer = new byte[sectorSize];
            _sectorBuffer    = new byte[sectorSize];
        }
        public XTSReadOnlyStream(Stream baseStream, Xts xts, int sectorSize, ulong startSector, int trimStart, uint trimEnd) : base(baseStream, xts, sectorSize)
        {
            _baseStream    = baseStream;
            _tempBuffer    = new byte[SectorSize];
            _decryptor     = xts.CreateDecryptor();
            _currentSector = startSector;
            Length         = baseStream.Length - trimStart - trimEnd;

            if (trimStart > 0)
            {
                int read = ReadExactly(_baseStream, _tempBuffer, sectorSize);
                _decryptor.TransformBlock(_tempBuffer, 0, SectorSize, _tempBuffer, 0, _currentSector);
                _tempBufferCount = read;
                _tempBufferPos   = trimStart;
                _currentSector++;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new stream
 /// </summary>
 /// <param name="baseStream">The base stream</param>
 /// <param name="xts">The xts transform</param>
 /// <param name="sectorSize">Sector size</param>
 /// <param name="offset">Offset to start counting sectors</param>
 public XtsSectorStream(Stream baseStream, Xts xts, int sectorSize, long offset)
     : base(baseStream, sectorSize, offset)
 {
     _xts        = xts;
     _tempBuffer = new byte[sectorSize];
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new stream
 /// </summary>
 /// <param name="baseStream">The base stream</param>
 /// <param name="xts">The xts transform</param>
 /// <param name="sectorSize">Sector size</param>
 public XtsSectorStream(Stream baseStream, Xts xts, int sectorSize)
     : this(baseStream, xts, sectorSize, 0)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new stream with the default sector size
 /// </summary>
 /// <param name="baseStream">The base stream</param>
 /// <param name="xts">The xts transform</param>
 public XtsSectorStream(Stream baseStream, Xts xts)
     : this(baseStream, xts, DefaultSectorSize)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new stream
 /// </summary>
 /// <param name="baseStream">The base stream</param>
 /// <param name="xts">Xts implementation to use</param>
 /// <param name="sectorSize">Sector size</param>
 /// <param name="offset">Offset to start counting sectors</param>
 public XtsStream(Stream baseStream, Xts xts, int sectorSize, long offset)
     : base(new XtsSectorStream(baseStream, xts, sectorSize, offset), true)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new stream
 /// </summary>
 /// <param name="baseStream">The base stream</param>
 /// <param name="xts">Xts implementation to use</param>
 /// <param name="sectorSize">Sector size</param>
 public XtsStream(Stream baseStream, Xts xts, int sectorSize)
     : base(new XtsSectorStream(baseStream, xts, sectorSize), true)
 {
 }