Inheritance: Mono.Security.Cryptography.SymmetricTransform
        public TripleDESTransform(TripleDES algo, bool encryption, byte[] key, byte[] iv) : base(algo, encryption, iv)
        {
            if (key == null)
            {
                key = TripleDESTransform.GetStrongKey();
            }
            if (TripleDES.IsWeakKey(key))
            {
                string text = Locale.GetText("This is a known weak key.");
                throw new CryptographicException(text);
            }
            byte[] array    = new byte[8];
            byte[] array2   = new byte[8];
            byte[] array3   = new byte[8];
            DES    symmAlgo = DES.Create();

            Buffer.BlockCopy(key, 0, array, 0, 8);
            Buffer.BlockCopy(key, 8, array2, 0, 8);
            if (key.Length == 16)
            {
                Buffer.BlockCopy(key, 0, array3, 0, 8);
            }
            else
            {
                Buffer.BlockCopy(key, 16, array3, 0, 8);
            }
            if (encryption || algo.Mode == CipherMode.CFB)
            {
                this.E1 = new DESTransform(symmAlgo, true, array, iv);
                this.D2 = new DESTransform(symmAlgo, false, array2, iv);
                this.E3 = new DESTransform(symmAlgo, true, array3, iv);
            }
            else
            {
                this.D1 = new DESTransform(symmAlgo, false, array3, iv);
                this.E2 = new DESTransform(symmAlgo, true, array2, iv);
                this.D3 = new DESTransform(symmAlgo, false, array, iv);
            }
        }
Ejemplo n.º 2
0
 public override void GenerateKey()
 {
     KeyValue = TripleDESTransform.GetStrongKey();
 }