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 GenerateKey() { Key = KeyBuilder.Key(KeySizeValue >> 3); }