using System; using Mono.Security.Cryptography; namespace System.Security.Cryptography { // Token: 0x0200053C RID: 1340 internal class TripleDESTransform : SymmetricTransform { // Token: 0x06003114 RID: 12564 RVA: 0x000A89E4 File Offset: 0x000A6BE4 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 des = 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(des, true, array, iv); this.D2 = new DESTransform(des, false, array2, iv); this.E3 = new DESTransform(des, true, array3, iv); } else { this.D1 = new DESTransform(des, false, array3, iv); this.E2 = new DESTransform(des, true, array2, iv); this.D3 = new DESTransform(des, false, array, iv); } } // Token: 0x06003115 RID: 12565 RVA: 0x000A8AF8 File Offset: 0x000A6CF8 protected override void ECB(byte[] input, byte[] output) { DESTransform.Permutation(input, output, DESTransform.ipTab, false); if (this.encrypt) { this.E1.ProcessBlock(output, output); this.D2.ProcessBlock(output, output); this.E3.ProcessBlock(output, output); } else { this.D1.ProcessBlock(output, output); this.E2.ProcessBlock(output, output); this.D3.ProcessBlock(output, output); } DESTransform.Permutation(output, output, DESTransform.fpTab, true); } // Token: 0x06003116 RID: 12566 RVA: 0x000A8B80 File Offset: 0x000A6D80 internal static byte[] GetStrongKey() { int num = DESTransform.BLOCK_BYTE_SIZE * 3; byte[] array = KeyBuilder.Key(num); while (TripleDES.IsWeakKey(array)) { array = KeyBuilder.Key(num); } return array; } // Token: 0x04001406 RID: 5126 private DESTransform E1; // Token: 0x04001407 RID: 5127 private DESTransform D2; // Token: 0x04001408 RID: 5128 private DESTransform E3; // Token: 0x04001409 RID: 5129 private DESTransform D1; // Token: 0x0400140A RID: 5130 private DESTransform E2; // Token: 0x0400140B RID: 5131 private DESTransform D3; } }