using System; using System.Runtime.InteropServices; namespace System.Security.Cryptography { /// Represents the base class for Triple Data Encryption Standard algorithms from which all implementations must derive. // Token: 0x0200053A RID: 1338 [ComVisible(true)] public abstract class TripleDES : SymmetricAlgorithm { /// Initializes a new instance of the class. // Token: 0x06003109 RID: 12553 RVA: 0x000A87C0 File Offset: 0x000A69C0 protected TripleDES() { this.KeySizeValue = 192; this.BlockSizeValue = 64; this.FeedbackSizeValue = 8; this.LegalKeySizesValue = new KeySizes[1]; this.LegalKeySizesValue[0] = new KeySizes(128, 192, 64); this.LegalBlockSizesValue = new KeySizes[1]; this.LegalBlockSizesValue[0] = new KeySizes(64, 64, 0); } /// Gets or sets the secret key for the algorithm. /// The secret key for the algorithm. /// An attempt was made to set the key to null. /// An attempt was made to set a key whose length is invalid.-or- An attempt was made to set a weak key (see ). // Token: 0x1700099C RID: 2460 // (get) Token: 0x0600310A RID: 12554 RVA: 0x000A8830 File Offset: 0x000A6A30 // (set) Token: 0x0600310B RID: 12555 RVA: 0x000A887C File Offset: 0x000A6A7C public override byte[] Key { get { if (this.KeyValue == null) { this.GenerateKey(); while (TripleDES.IsWeakKey(this.KeyValue)) { this.GenerateKey(); } } return (byte[])this.KeyValue.Clone(); } set { if (value == null) { throw new ArgumentNullException("Key"); } if (TripleDES.IsWeakKey(value)) { throw new CryptographicException(Locale.GetText("Weak Key")); } this.KeyValue = (byte[])value.Clone(); } } /// Determines whether the specified key is weak. /// true if the key is weak; otherwise, false. /// The secret key to test for weakness. /// The size of the parameter is not valid. // Token: 0x0600310C RID: 12556 RVA: 0x000A88BC File Offset: 0x000A6ABC public static bool IsWeakKey(byte[] rgbKey) { if (rgbKey == null) { throw new CryptographicException(Locale.GetText("Null Key")); } if (rgbKey.Length == 16) { for (int i = 0; i < 8; i++) { if (rgbKey[i] != rgbKey[i + 8]) { return false; } } } else { if (rgbKey.Length != 24) { throw new CryptographicException(Locale.GetText("Wrong Key Length")); } bool flag = true; for (int j = 0; j < 8; j++) { if (rgbKey[j] != rgbKey[j + 8]) { flag = false; break; } } if (!flag) { for (int k = 8; k < 16; k++) { if (rgbKey[k] != rgbKey[k + 8]) { return false; } } } } return true; } /// Creates an instance of a cryptographic object to perform the algorithm. /// An instance of a cryptographic object. /// /// /// // Token: 0x0600310D RID: 12557 RVA: 0x000A8980 File Offset: 0x000A6B80 public new static TripleDES Create() { return TripleDES.Create("System.Security.Cryptography.TripleDES"); } /// Creates an instance of a cryptographic object to perform the specified implementation of the algorithm. /// An instance of a cryptographic object. /// The name of the specific implementation of to use. // Token: 0x0600310E RID: 12558 RVA: 0x000A898C File Offset: 0x000A6B8C public new static TripleDES Create(string str) { return (TripleDES)CryptoConfig.CreateFromName(str); } } }