Esempio n. 1
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 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++;
            }
        }
Esempio n. 3
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)
 {
 }
Esempio n. 4
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)
 {
 }
Esempio n. 5
0
 /// <summary>
 /// Creates a new stream
 /// </summary>
 /// <param name="baseStream">The base stream</param>
 /// <param name="xts">Xts implementation to use</param>
 public XtsStream(Stream baseStream, Xts xts)
     : this(baseStream, xts, XtsSectorStream.DefaultSectorSize)
 {
 }
 /// <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];
 }
 /// <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)
 {
 }