public static byte[] XTS(byte[] Key1, byte[] Key2, int SectorSize, byte[] Data, ulong Sector, bool Encrypt) { byte[] TransformedBytes, BlockData; Xts XTS128 = XtsAes128.Create(Key1, Key2); int Blocks; var MemStrm = new MemoryStream(); var Writer = new BinaryWriter(MemStrm); XtsCryptoTransform CryptoTransform; if (Encrypt) { CryptoTransform = XTS128.CreateEncryptor(); } else { CryptoTransform = XTS128.CreateDecryptor(); } BlockData = new byte[SectorSize]; Blocks = Data.Length / SectorSize; for (int i = 0; i < Blocks; i++) { CryptoTransform.TransformBlock(Data, i * SectorSize, SectorSize, BlockData, 0, Sector++); Writer.Write(BlockData); } TransformedBytes = MemStrm.ToArray(); return(TransformedBytes); }
public XtsStream(Stream baseStream, Xts xts, int sectorSize, long offset) : base(new XtsSectorStream(baseStream, xts, sectorSize, offset), true) { }
public XtsStream(Stream baseStream, Xts xts, int sectorSize) : base(new XtsSectorStream(baseStream, xts, sectorSize), true) { }
public XtsStream(Stream baseStream, Xts xts) : this(baseStream, xts, XtsSectorStream.DEFAULT_SECTOR_SIZE) { }
public XtsSectorStream(Stream baseStream, Xts xts, int sectorSize, long offset) : base(baseStream, sectorSize, offset) { _xts = xts; _tempBuffer = new byte[sectorSize]; }
public XtsSectorStream(Stream baseStream, Xts xts, int sectorSize) : this(baseStream, xts, sectorSize, 0) { }