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];
 }
Example #2
0
 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];
 }
Example #3
0
        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];
        }
Example #4
0
 public override void GenerateKey()
 {
     KeyValue = KeyBuilder.Key(KeySizeValue >> 3);
 }
Example #5
0
 public override void GenerateKey()
 {
     this.Key = KeyBuilder.Key(this.KeySizeValue >> 3);
 }
Example #6
0
 public override void GenerateIV()
 {
     IVValue = KeyBuilder.IV(BlockSizeValue >> 3);
 }