コード例 #1
0
        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);
        }
コード例 #2
0
 public XtsStream(Stream baseStream, Xts xts, int sectorSize, long offset)
     : base(new XtsSectorStream(baseStream, xts, sectorSize, offset), true)
 {
 }
コード例 #3
0
 public XtsStream(Stream baseStream, Xts xts, int sectorSize)
     : base(new XtsSectorStream(baseStream, xts, sectorSize), true)
 {
 }
コード例 #4
0
 public XtsStream(Stream baseStream, Xts xts)
     : this(baseStream, xts, XtsSectorStream.DEFAULT_SECTOR_SIZE)
 {
 }
コード例 #5
0
 public XtsSectorStream(Stream baseStream, Xts xts, int sectorSize, long offset)
     : base(baseStream, sectorSize, offset)
 {
     _xts        = xts;
     _tempBuffer = new byte[sectorSize];
 }
コード例 #6
0
 public XtsSectorStream(Stream baseStream, Xts xts, int sectorSize)
     : this(baseStream, xts, sectorSize, 0)
 {
 }