public SymmetricTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] rgbIV) { algo = symmAlgo; encrypt = encryption; BlockSizeByte = (algo.BlockSize >> 3); if (rgbIV == null) { rgbIV = KeyBuilder.IV(BlockSizeByte); } else { rgbIV = (byte[])rgbIV.Clone(); } // compare the IV length with the "currently selected" block size and *ignore* IV that are too big if (rgbIV.Length < BlockSizeByte) { string msg = String.Format("IV слишком мало ({0} байт), длина должна быть {1} байт.", rgbIV.Length, BlockSizeByte); throw new CryptographicException(msg); } padmode = algo.Padding; // mode buffers temp = new byte [BlockSizeByte]; Buffer.BlockCopy(rgbIV, 0, temp, 0, System.Math.Min(BlockSizeByte, rgbIV.Length)); temp2 = new byte [BlockSizeByte]; FeedBackByte = (algo.FeedbackSize >> 3); // transform buffers workBuff = new byte [BlockSizeByte]; workout = new byte [BlockSizeByte]; }
public SymmetricTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] rgbIV) { this.algo = symmAlgo; this.encrypt = encryption; this.BlockSizeByte = this.algo.BlockSize >> 3; if (rgbIV == null) { rgbIV = KeyBuilder.IV(this.BlockSizeByte); } else { rgbIV = (byte[])rgbIV.Clone(); } if (rgbIV.Length < this.BlockSizeByte) { string text = Locale.GetText("IV is too small ({0} bytes), it should be {1} bytes long.", new object[] { rgbIV.Length, this.BlockSizeByte }); throw new CryptographicException(text); } this.temp = new byte[this.BlockSizeByte]; Buffer.BlockCopy(rgbIV, 0, this.temp, 0, Math.Min(this.BlockSizeByte, rgbIV.Length)); this.temp2 = new byte[this.BlockSizeByte]; this.FeedBackByte = this.algo.FeedbackSize >> 3; if (this.FeedBackByte != 0) { this.FeedBackIter = this.BlockSizeByte / this.FeedBackByte; } this.workBuff = new byte[this.BlockSizeByte]; this.workout = new byte[this.BlockSizeByte]; }
public SymmetricTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] rgbIV) { this.algo = symmAlgo; this.encrypt = encryption; this.BlockSizeByte = this.algo.BlockSize >> 3; rgbIV = rgbIV != null ? (byte[])rgbIV.Clone() : KeyBuilder.IV(this.BlockSizeByte); if (rgbIV.Length < this.BlockSizeByte) { throw new CryptographicException(Locale.GetText("IV is too small ({0} bytes), it should be {1} bytes long.", (object)rgbIV.Length, (object)this.BlockSizeByte)); } this.temp = new byte[this.BlockSizeByte]; Buffer.BlockCopy((Array)rgbIV, 0, (Array)this.temp, 0, System.Math.Min(this.BlockSizeByte, rgbIV.Length)); this.temp2 = new byte[this.BlockSizeByte]; this.FeedBackByte = this.algo.FeedbackSize >> 3; if (this.FeedBackByte != 0) { this.FeedBackIter = this.BlockSizeByte / this.FeedBackByte; } this.workBuff = new byte[this.BlockSizeByte]; this.workout = new byte[this.BlockSizeByte]; }
public SymmetricTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] rgbIV) { algo = symmAlgo; encrypt = encryption; BlockSizeByte = algo.BlockSize >> 3; rgbIV = ((rgbIV != null) ? ((byte[])rgbIV.Clone()) : KeyBuilder.IV(BlockSizeByte)); if (rgbIV.Length < BlockSizeByte) { string text = Locale.GetText("IV is too small ({0} bytes), it should be {1} bytes long.", rgbIV.Length, BlockSizeByte); throw new CryptographicException(text); } temp = new byte[BlockSizeByte]; Buffer.BlockCopy(rgbIV, 0, temp, 0, System.Math.Min(BlockSizeByte, rgbIV.Length)); temp2 = new byte[BlockSizeByte]; FeedBackByte = algo.FeedbackSize >> 3; if (FeedBackByte != 0) { FeedBackIter = BlockSizeByte / FeedBackByte; } workBuff = new byte[BlockSizeByte]; workout = new byte[BlockSizeByte]; }
public SymmetricTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] rgbIV) { algo = symmAlgo; encrypt = encryption; BlockSizeByte = (algo.BlockSize >> 3); if (rgbIV == null) { rgbIV = KeyBuilder.IV(BlockSizeByte); } else { rgbIV = (byte[])rgbIV.Clone(); } #if NET_2_0 // compare the IV length with the "currently selected" block size and *ignore* IV that are too big if (rgbIV.Length < BlockSizeByte) { string msg = Locale.GetText("IV is too small ({0} bytes), it should be {1} bytes long.", rgbIV.Length, BlockSizeByte); throw new CryptographicException(msg); } #endif // mode buffers temp = new byte [BlockSizeByte]; Buffer.BlockCopy(rgbIV, 0, temp, 0, System.Math.Min(BlockSizeByte, rgbIV.Length)); temp2 = new byte [BlockSizeByte]; #if !NET_2_1 || MONOTOUCH FeedBackByte = (algo.FeedbackSize >> 3); if (FeedBackByte != 0) { FeedBackIter = (int)BlockSizeByte / FeedBackByte; } #endif // transform buffers workBuff = new byte [BlockSizeByte]; workout = new byte [BlockSizeByte]; }
public override void GenerateIV() { IVValue = KeyBuilder.IV(BlockSizeValue >> 3); }